package quadcoptertest;
import org.roboticsapi.core.exception.InitializationException;
import org.roboticsapi.core.exception.RoboticsException;
import org.roboticsapi.core.world.Pose;
import org.roboticsapi.feature.startup.multicopter.autoquad.indoor.MulticopterApplication;
import org.roboticsapi.framework.cartesianmotion.activity.LinearMotionInterface;
import org.roboticsapi.framework.quadrotor.Quadrotor;
// a simple application for rapid prototyping, will open a simple test GUI with buttons to try out certain methods (see below)
public class SimpleQuadcopterApplication extends MulticopterApplication {
// a simple quadcopter
private Quadrotor quad;
public static void main(String[] args) throws InitializationException {
new SimpleQuadcopterApplication().start();
}
public SimpleQuadcopterApplication() throws InitializationException {
super(true); // true means simulation mode
}
@Override
protected void configure() throws RoboticsException {
super.configure();
// create a simulated quadcopter
quad = createSimulatedMulticopter("quad", 0, 0);
}
// all public methods that start with 'test' will have an auto-generated
// button in the application's test GUI
public void testSimpleMovement() throws RoboticsException {
// helper function for takeoff, will arm the quad and fly a linear
// motion to the given height above the start point
takeoff(1, quad);
// define a goal relative to the quadcopter's position; this goal will
// move with the quadcopter
Pose relativeGoal = quad.getMovingFrame().asPose().plus(1, 1, 0);
// fix the above goal relative to the global world origin
Pose fixedGoal = relativeGoal.snapshot(getRapi().getWorld().getOrigin());
// now we fly to the fixed goal
quad.use(LinearMotionInterface.class).lin(fixedGoal).execute();
// helper function for landing, will fly the quad a little below ground
// and disarm it
land(quad);
}
}