@Test @Ignore public void changeAcceleration() throws Exception { engine.changeAcceleration(new D3Vector(1, 1, 1)); MovementMessage msg = new MovementMessage(); msg.setAcceleration(new D3Vector(1, 1, 1)); msg.setIdentifier("drone_id"); Assert.assertTrue("The message is not found. These messages were found: " + publisher.getReceivedMessages(), publisher.getReceivedMessages().size() == 1); }
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);  }