SITL no longer responds to setGuidedModeWP command

I used to be able to fly a virtual drone (SITL) around using computed WPs from a python script running in Mission Planner. I do this using MAV.setGuidedModeWP, which underneath sends the new coordinates to the autopilot via MAVLINK_MSG_ID.SET_POSITION_TARGET_GLOBAL_INT.

I suspect there was a recent change to the SITL autopilot that broke things, because all the test scripts that used to work no longer do. Guided Takeoff and Landing works, but the MAVLink command above no longer does anything.

Here’s the version I am seeing in MP:
Screenshot 2021-10-17 173907

Please help!

@seattleiteFPV

What is the Type_Mask? I have a feeling it is because a recent PR of mine rejects any command that has the FORCE_SET type true.

The 9th bit needs to be 0. See here link for the MAVLINK spec that is a little odd compared to the rest of the message.

The need for it was that we now accept acceleration commands and we don’t want to handle Newtons as an input. Mixing the the two, m/s^2 and Newtons could have led to a bad day for someone.

@hendjosh, I don’t know how to tell what the value of Type_Mask is. I am in Python, so I don’t see what’s happening below in C# land.

Does your change impact just SITL or all autopilots? Either way, it sounds like a bug was introduced, and setGuidedModeWP no longer works :frowning:

Here’s how to reproduce:

def newWP(lat, lng, alt):
    wp = MissionPlanner.Utilities.Locationwp()
    MissionPlanner.Utilities.Locationwp.lat.SetValue(wp, lat)
    MissionPlanner.Utilities.Locationwp.lng.SetValue(wp, lng)
    MissionPlanner.Utilities.Locationwp.alt.SetValue(wp, alt)
    return wp

def flyTo(lat, lng, alt):
    MAV.setGuidedModeWP(newWP(lat, lng, alt))

flyTo(47.6, -122, 10)

Would you send a log please? I’m presuming you are in Guided Mode? I haven’t played with mission planner code but I will download it.

Or could you tell what module/library MAV comes from pymavlink perhaps?

Basically, I need to find MAV.setGuidedModeWP is that coming from missionplanner?

Ok I found the relevant function in MissionPlanner and will put together a PR in MissionPlanner to fix it. That will take me a bit longer do since I haven’t built MissionPlanner in a long time.

Here are the relevant bits: Link

Sorry, about that usually if we think a change will effect GCSs we will stage those together.

Unfortunately, it is a case where the meaning of the mavlink spec wasn’t being taken into account for a long time and now we need to for safety.

@hendjosh “MAV” is a Python variable that maps to MainV2.comPort, which I believe is an instance of MAVLinkInterface. The latter, in MavLinkInterface.cs, defines the setGuidedModeWP method.

@hendjosh Oh, I just saw your second message. Thank you.
Do you know when a new MP build might become available so I can test your fix?
Also, will this fix (in MP) impact the behavior of older autopilots, such as 4.0.7? (because that’s what I have running on the real drone).

@seattleiteFPV No clue on the MP builds, but I don’t imagine it taking a long time.

BTW depending on your use the stable copter 4.1 SITL could be used in the mean time?
The files are located here.

I don’t think the MP change will effect behavior in older copter versions.
We weren’t handling that field before in ArduPilot or doing anything with acceleration. But I will check.

In the flight software,
Confirmed in Copter 4.07 we do not check the FORCE field so all good on that end.
Copter 4.1 we don’t check that bit either so good there as well.

OK, thanks for checking, @hendjosh.
The SITL gets downloaded by MP automatically into Documents\MissionPlanner\sitl. I would love to downgrade from 4.2.0-dev to an earlier version, but I am not seeing how… Are you suggesting I should just override all files in that folder, and check the “Skip Download” box in the Simulation tab in Mission Planner?

…actually nevermind, that seems to work. MP reports “Failed to download the SITL image” because of the weird linux extensions, but if I rename the “elf” files to “exe”, the sim starts just fine, and guided navigation works (as expected).

PR for this issue: here

Glad you figured it out. I think when MissionPlanner downloads those files in renames them probably? There was a request recently to add a dropdown box for Stable versions of SITL in MissionPlanner. But that may be a bit.

1 Like

Thanks Josh! @hendjosh

No problem! It is nice when the solution is easy :slight_smile:

Chiming in here 3 months later to confirm that I have upgraded to the latest MP, and your fix works as expected, @hendjosh. Guided WP navigation works once again with the latest SITL. Thanks!

1 Like