'How to set GUIDED_NOGPS mode with Arducopter on Dronekit?

How do I command Arducopter to enter guided_nogps mode? I am planning to operate in a gps denied environment, and although other posts indicate this is possible with guided-nogps, I cannot see how to set that mode. Using Dronekit (python) vehicle.mode = VehicleMode("Guided_NoGPS") returns an error indicating there is no such mode.

Mavlink also refuses to acknowledge the mode.

My setup is a Pixhawk running Arducopter with a Raspberry Pi companion. Firmware is v3.5 dev, and v3.4 on the DroneKit-SITL (I compiled my own v3.4 binary for this).

Everything else is working great (e.g. controlling via set_attitude_target thanks to this post How to set copters Attitude via DroneKit -- SET_ATTITUDE_TARGET not working ) - I just need to be able to go indoors!

Also - I did notice in this post prior to the release of Arducopter v3.4 Controlling movement without GPS that an optical flow sensor might be required. Did that requirement come to pass?

Thanks again!

All advice welcome.

Thanks Squilter for your help. I created a function to change the flightmode (20):

def set_mode(flightmode):
# create the MAV_CMD_DO_SET_MODE command
msg = vehicle.message_factory.command_long_encode(
    0, 0,    # target system, target component
    mavutil.mavlink.MAV_CMD_DO_SET_MODE, #command
    0, #confirmation
    flightmode,
    0, 0, 0, 0, 0, 0 )
# send command to vehicle
vehicle.send_mavlink(msg)

The message is correctly received but was not successful (result 3 returned). One thing I wasn't sure about was parameter 2, which the spec indicates is platform specific. I put 0 as I wasn't sure what to do with it for Arducopter.

Again, any suggestions welcome and many thanks!



Solution 1:[1]

Try setting the mode to 20. This is the internal representation of the mode. It looks like dronekit-python does not know this yet.

Optical flow is required for normal guided mode, not guided_nogps. However, guided_nogps does not allow sending velocity or position requests, only angles.

Solution 2:[2]

I know that this question is a little old but I have found the answer. Update your installs of MAVProxy and PyMAVLink.

pip install -U pymavlink mavproxy

DroneKit will automatically install older versions of them without the new modes available. You want PyMAVLink >= 2.2.4 and MAVProxy >= 1.6.1.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 squilter
Solution 2 markrjr