DroneKit mission not sent to drone

225 Views Asked by At

I'm trying to create simple mission using Drone-Kit android.

Mission myMission = new Mission();
myMission.clear();
Takeoff to = new Takeoff();
ReturnToLaunch rtl = new ReturnToLaunch();
//set Altitude in meters
rtl.setReturnAltitude(2);
to.setTakeoffAltitude(2);
myMission.addMissionItem(to);
myMission.addMissionItem(rtl);
MissionApi.getApi(this.drone).setMission(myMission,true);

The problem is that sometimes it works, and sometimes it's doesn't... I don't know why it not working... I'm not getting any errors in the code.

I'm listening to the

AttributeEvent.MISSION_UPDATED

AttributeEvent.MISSION_SENT

AttributeEvent.MISSION_RECEIVED

but only the AttributeEvent.MISSION_UPDATED is fired when I run the code. And even if its fired, this doesn't mean that the mission updated correctly. I'm checking the mission with Mission Planer. I just don't understand why it is working sometimes and sometimes not.

I did make sure that the drone connected to the app. Also I made sure that the drone is OK and arm-able. I really stuck here... and any help will be appreciated.

2

There are 2 best solutions below

0
On BEST ANSWER

I will answer my question, in case someone have the same problem.

I have contacted the developers, and it seems that I'm not the only one who have this BUG. It seems that when you add ReturnToLaunch to Mission something happening in the API and the mission is not sent to the drone. As soon as I removed ReturnToLaunch object from the Mission all worked properly.

Work-Around: To overcome the issue, I am putting the drone in RTL mode, when the Mission is done.

0
On

I have not tried dronekit-android before but I think it is better to open an issue here.

The source code for android project has not been updated for more than two years!

In general,there is a protocol to upload/download a mission. It is not easy to implement but you can implement it. I did that in c++. You should always check the acknowledgment from the drone before going in the next step. Check the protocol here.