mavlink / MAVSDK-Java

MAVSDK client for Java.
76 stars 44 forks source link

Getting INVALID_ARGUMENT while uploading an ArduCopter mission #120

Closed divyanshupundir closed 1 year ago

divyanshupundir commented 1 year ago

MAVSDK always throws an INVALID_ARGUMENT error while uploading an ArduCopter mission. At the same time, QGC is able to upload the exact same mission.

Setup:

I have gone down to replicating every param of the MissionItemInt generated in QGC using the MissionRaw.MissionItemInt of MAVSDK. I have noticed that MAVSDK throws the error before even sending a single message to the drone.

At the same time, the geofence upload function is working perfectly fine for the same ArduCopter.

divyanshupundir commented 1 year ago

As an example, this is a sequence of mission items generated using QGC

MissionItemInt{targetSystem=1, targetComponent=1, seq=0, frame=MAV_FRAME_GLOBAL, command=MAV_CMD_NAV_WAYPOINT, current=1, autocontinue=1, param1=0.0, param2=0.0, param3=0.0, param4=0.0, x=-353632622, y=1491652375, z=0.0, missionType=MAV_MISSION_TYPE_MISSION}
MissionItemInt{targetSystem=1, targetComponent=1, seq=1, frame=MAV_FRAME_GLOBAL_RELATIVE_ALT, command=MAV_CMD_NAV_TAKEOFF, current=0, autocontinue=1, param1=0.0, param2=0.0, param3=0.0, param4=0.0, x=-353632622, y=1491652375, z=50.0, missionType=MAV_MISSION_TYPE_MISSION}
MissionItemInt{targetSystem=1, targetComponent=1, seq=2, frame=MAV_FRAME_GLOBAL, command=MAV_CMD_NAV_RETURN_TO_LAUNCH, current=0, autocontinue=1, param1=0.0, param2=0.0, param3=0.0, param4=0.0, x=0, y=0, z=0.0, missionType=MAV_MISSION_TYPE_MISSION}

It is being uploaded quite easily, while the exact sequence of MAVSDK messages throws the error.

JonasVautherin commented 1 year ago

I have noticed that MAVSDK throws the error before even sending a single message to the drone.

That's interesting :thinking:.

Having a quick look at the code, I think it probably comes from here, which maybe (?) comes from here, but then it seems to come from a MISSION_ACK here?

Not sure... do you have a way to debug that in the C++ code directly? See what happens more precisely...

divyanshupundir commented 1 year ago

Yes, even I was going through the C++ code yesterday and couldn't find why this was happening. As I had said, I couldn't see any MISSION_ITEM_INT emitted by MAVSDK, and therefore any MISSION_ACK from the drone's side.

I'll try to do some debugging on the C++ side today and figure out.

divyanshupundir commented 1 year ago

Somewhat figured it out. It was a problem related to the sequencing of mission items over here

It became difficult to debug it as the mavsdk_server version used in MAVSDK-Java probably threw InvalidArgument instead of InvalidSequence (in the latest version).

julianoes commented 1 year ago

Yes, sorry this will improve in future versions.