il421 / DroneScan

MIT License
0 stars 0 forks source link

Pre-programmed flight path #2

Open CodeNeedsCoffee opened 5 years ago

CodeNeedsCoffee commented 5 years ago

Hello!

I was trying to recreate your NavigationExecutor.java but needed a different flight path. I'm trying to get the drone to move forward, but it doesn't move and was wondering if maybe I'm doing something wrong?

So I declare the variables on the class level:

static private Aircraft aircraft = new Aircraft(null);
static private FlightController flightController = aircraft.getFlightController();
 static private FlightAssistant flightAssistant = flightController.getFlightAssistant();

and then in my function, I declare:

        // Set Virtual Sticks in case they wasn't before
        flightController.setVirtualStickModeEnabled(true, null);
        flightController.setVirtualStickAdvancedModeEnabled(true);
        //Set modes for flight controller
        flightController.setVerticalControlMode(VerticalControlMode.VELOCITY);
        flightController.setYawControlMode(YawControlMode.ANGULAR_VELOCITY);
        flightController.setRollPitchControlMode(RollPitchControlMode.VELOCITY);
        flightController.setRollPitchCoordinateSystem(FlightCoordinateSystem.BODY);

        // Turn on Vision Assisted if it was OFF
        flightAssistant.getVisionAssistedPositioningEnabled(new CommonCallbacks.CompletionCallbackWith<Boolean>() {
            @Override
            public void onSuccess(Boolean aBoolean) {
                if (!aBoolean) {
                    flightAssistant.setVisionAssistedPositioningEnabled(true, null);
                }
            }

            @Override
            public void onFailure(DJIError djiError) {
            }
        });

        // Turn off Collision avoidance if it was ON
        flightAssistant.getCollisionAvoidanceEnabled(new CommonCallbacks.CompletionCallbackWith<Boolean>() {
            @Override
            public void onSuccess(Boolean aBoolean) {
                if (aBoolean) {
                    flightAssistant.setCollisionAvoidanceEnabled(false, null);
                }
            }

            @Override
            public void onFailure(DJIError djiError) {

            }
        });

and then in my case statement I run this: flightController.sendVirtualStickFlightControlData(new FlightControlData(1f, 0, 0, 0), null);

The drone takes off, hovers, and then lands when it should be moving forward; any thoughts?

Thanks in advance and cheers!

Android Studio: 3.3.0.0 Android: 8.0.1 Drone: Mavic Air