Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get gps location of Spark? #21

Open
ghost opened this issue Jul 8, 2020 · 6 comments
Open

How to get gps location of Spark? #21

ghost opened this issue Jul 8, 2020 · 6 comments

Comments

@ghost
Copy link

ghost commented Jul 8, 2020

Hi, I am trying to use this tutorial to make Spark's gps location but not able to access it, even flgihtcontroller class. how to get flightcontroller class from Spark?

@dji-dev
Copy link

dji-dev commented Jul 8, 2020

Agent comment from William Wong in Zendesk ticket #36667:

Dear Client
Thank you for contacting DJI.

please refer to the code below.
XXXApplication.getProductInstance().getFlightController.getState().getAircraftLocation.

Hopefully our solution can help you.
Kindly Regards,
DJI Developer Support

@ghost
Copy link
Author

ghost commented Jul 9, 2020

Thank you for your reply, Mr Wong! I have one more questions to ask!

What is the class "Flightcontollerkey" for? There are some flight controller key of aircraft location. Should we use that key for obtaining location info from flight controller?

@dji-dev
Copy link

dji-dev commented Jul 9, 2020

Agent comment from William Wong in Zendesk ticket #36667:

Dear Client
Thank you for contacting DJI.

You don't need to worry about the key for now. It is another way to access the data such as aircraft location. The tutorials do not describe clearly how to use them. So in this stage I would suggest you just simply use the getter and setter functions.

Hopefully our solution can help you.
Kindly Regards,
DJI Developer Support

@ghost
Copy link
Author

ghost commented Jul 9, 2020

private void initFlightController() {

    BaseProduct product = DJIDemoApplication.getProductInstance();
    if (product != null && product.isConnected()) {
        if (product instanceof Aircraft) {
            mFlightController = ((Aircraft) product).getFlightController();
            Log.d(TAG, "mFlightController :"+mFlightController);
            Log.d(TAG, "getAircraftlocaiton :"+mFlightController.getState().getAircraftLocation());



        }
    }

    if (mFlightController != null) {
        mFlightController.setStateCallback(new FlightControllerState.Callback() {

            @Override
            public void onUpdate(FlightControllerState djiFlightControllerCurrentState) {
                droneLocationLat = djiFlightControllerCurrentState.getAircraftLocation().getLatitude();
                droneLocationLng = djiFlightControllerCurrentState.getAircraftLocation().getLongitude();
                Log.d(TAG, "droneLocationLat :"+droneLocationLat+",\""+"droneLocationLng :"+droneLocationLng);
                updateDroneLocation();
            }
        });
    }
}

This is the original code that I added some logs. What should it be changed for Spark ?

@dji-dev
Copy link

dji-dev commented Jul 9, 2020

Agent comment from William Wong in Zendesk ticket #36667:

Dear Client
Thank you for contacting DJI.

You don't need to change it. By the way, what do you mean by cannot access it. What is the error return? You have to make sure the drone has good GPS signal to receive the data.

Hopefully our solution can help you.
Kindly Regards,
DJI Developer Support

@ghost
Copy link
Author

ghost commented Jul 9, 2020

I mean, when I make a log of aircraft location, it returns always null. But I think the problem is that I am testing it in a building. Thank you for your reply! I will use the dji assistant 2 simulation program

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant