@Test public void testChangeAcceleration() { gps.setAcceleration(D3Vector.fromString("(x:-3.4427316345680223, y:-9.363483685842366, z:-0.6875842910570499)")); gps.setPosition(D3Vector.fromString("(x:366.30329775852334, y:183.53828228906738, z:53.59830231645528)")); gps.setVelocity(D3Vector.fromString("(x:-10.047801568808978, y:-17.60877350319855, z:0.9541791137955318)")); engine.changeAcceleration(new D3Vector()); }
public void changeAcceleration(D3Vector input_acceleration) { D3Vector acceleration = input_acceleration; acceleration = limit_acceleration(acceleration); acceleration = this.limit_velocity(acceleration); if (Double.isNaN(acceleration.getX()) || Double.isNaN(acceleration.getY()) || Double.isNaN(acceleration.getZ())) { throw new IllegalArgumentException("Acceleration is not a number. Input acceleration: " + input_acceleration.toString() + ", Output acceleration: " + acceleration.toString()); } boolean change = true; if (lastAcceleration != null) { double diffX = Math.abs(lastAcceleration.getX() - acceleration.getX()); double diffY = Math.abs(lastAcceleration.getY() - acceleration.getY()); double diffZ = Math.abs(lastAcceleration.getZ() - acceleration.getZ()); double diffTot = diffX + diffY + diffZ; if (diffTot < 3) { change = false; } } if (change) { lastAcceleration = acceleration; MovementMessage msg = new MovementMessage(); msg.setAcceleration(acceleration); msg.setIdentifier(m_drone.getIdentifier()); m_publisher.send(msg); callbacks.forEach(callback -> callback.run(msg)); } }
Engine { public void changeAcceleration(D3Vector input_acceleration) { D3Vector acceleration = input_acceleration; acceleration = limit_acceleration(acceleration); acceleration = this.limit_velocity(acceleration); if (Double.isNaN(acceleration.getX()) || Double.isNaN(acceleration.getY()) || Double.isNaN(acceleration.getZ())) { throw new IllegalArgumentException("Acceleration is not a number. Input acceleration: " + input_acceleration.toString() + ", Output acceleration: " + acceleration.toString()); } boolean change = true; if (lastAcceleration != null) { double diffX = Math.abs(lastAcceleration.getX() - acceleration.getX()); double diffY = Math.abs(lastAcceleration.getY() - acceleration.getY()); double diffZ = Math.abs(lastAcceleration.getZ() - acceleration.getZ()); double diffTot = diffX + diffY + diffZ; if (diffTot < 3) { change = false; } } if (change) { lastAcceleration = acceleration; MovementMessage msg = new MovementMessage(); msg.setAcceleration(acceleration); msg.setIdentifier(m_drone.getIdentifier()); m_publisher.send(msg); callbacks.forEach(callback -> callback.run(msg)); } } }
Engine { public void changeAcceleration(D3Vector input_acceleration) { D3Vector acceleration = input_acceleration; acceleration = limit_acceleration(acceleration); acceleration = this.limit_velocity(acceleration); if (Double.isNaN(acceleration.getX()) || Double.isNaN(acceleration.getY()) || Double.isNaN(acceleration.getZ())) { throw new IllegalArgumentException("Acceleration is not a number. Input acceleration: " + input_acceleration.toString() + ", Output acceleration: " + acceleration.toString()); } boolean change = true; if (lastAcceleration != null) { double diffX = Math.abs(lastAcceleration.getX() - acceleration.getX()); double diffY = Math.abs(lastAcceleration.getY() - acceleration.getY()); double diffZ = Math.abs(lastAcceleration.getZ() - acceleration.getZ()); double diffTot = diffX + diffY + diffZ; if (diffTot < 3) { change = false; } } if (change) { lastAcceleration = acceleration; MovementMessage msg = new MovementMessage(); msg.setAcceleration(acceleration); msg.setIdentifier(m_drone.getIdentifier()); m_publisher.send(msg); callbacks.forEach(callback -> callback.run(msg)); } } Engine();  Engine(Publisher m_publisher, GPS m_gps, DroneInit m_drone, D3Vector lastAcceleration); }
Engine { public void changeAcceleration(D3Vector input_acceleration) { D3Vector acceleration = input_acceleration; acceleration = limit_acceleration(acceleration); acceleration = this.limit_velocity(acceleration); if (Double.isNaN(acceleration.getX()) || Double.isNaN(acceleration.getY()) || Double.isNaN(acceleration.getZ())) { throw new IllegalArgumentException("Acceleration is not a number. Input acceleration: " + input_acceleration.toString() + ", Output acceleration: " + acceleration.toString()); } boolean change = true; if (lastAcceleration != null) { double diffX = Math.abs(lastAcceleration.getX() - acceleration.getX()); double diffY = Math.abs(lastAcceleration.getY() - acceleration.getY()); double diffZ = Math.abs(lastAcceleration.getZ() - acceleration.getZ()); double diffTot = diffX + diffY + diffZ; if (diffTot < 3) { change = false; } } if (change) { lastAcceleration = acceleration; MovementMessage msg = new MovementMessage(); msg.setAcceleration(acceleration); msg.setIdentifier(m_drone.getIdentifier()); m_publisher.send(msg); callbacks.forEach(callback -> callback.run(msg)); } } Engine();  Engine(Publisher m_publisher, GPS m_gps, DroneInit m_drone, D3Vector lastAcceleration); D3Vector getLastAcceleration(); static D3Vector limit_acceleration(D3Vector input); static D3Vector maximize_acceleration(D3Vector input); D3Vector stagnate_acceleration(D3Vector input); void changeAcceleration(D3Vector input_acceleration); D3Vector changeVelocity(D3Vector input); final void registerCallback(EngineCallback callback); }
Engine { public void changeAcceleration(D3Vector input_acceleration) { D3Vector acceleration = input_acceleration; acceleration = limit_acceleration(acceleration); acceleration = this.limit_velocity(acceleration); if (Double.isNaN(acceleration.getX()) || Double.isNaN(acceleration.getY()) || Double.isNaN(acceleration.getZ())) { throw new IllegalArgumentException("Acceleration is not a number. Input acceleration: " + input_acceleration.toString() + ", Output acceleration: " + acceleration.toString()); } boolean change = true; if (lastAcceleration != null) { double diffX = Math.abs(lastAcceleration.getX() - acceleration.getX()); double diffY = Math.abs(lastAcceleration.getY() - acceleration.getY()); double diffZ = Math.abs(lastAcceleration.getZ() - acceleration.getZ()); double diffTot = diffX + diffY + diffZ; if (diffTot < 3) { change = false; } } if (change) { lastAcceleration = acceleration; MovementMessage msg = new MovementMessage(); msg.setAcceleration(acceleration); msg.setIdentifier(m_drone.getIdentifier()); m_publisher.send(msg); callbacks.forEach(callback -> callback.run(msg)); } } Engine();  Engine(Publisher m_publisher, GPS m_gps, DroneInit m_drone, D3Vector lastAcceleration); D3Vector getLastAcceleration(); static D3Vector limit_acceleration(D3Vector input); static D3Vector maximize_acceleration(D3Vector input); D3Vector stagnate_acceleration(D3Vector input); void changeAcceleration(D3Vector input_acceleration); D3Vector changeVelocity(D3Vector input); final void registerCallback(EngineCallback callback);  }