Open ghost opened 4 years ago
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
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?
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
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 ?
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
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
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?