DO_SET_MODE Mission Command

Is DO_SET_MODE supported in ArduRover (frame_class=2, boat)?

If so, I am setting Param1 = 4 (HOLD), and it doesn’t seem to kick. I do see an execution of ID=172 in the messages, but nothing happens in MP (mode doesn’t appear to change).

I read somewhere that I needed to enable custom modes, but don’t see a parameter that fits.

Any thoughts?

@LoopZilla,

I’m afraid we don’t support the DO_SET_MODE command in Rover (or any other ArduPilot vehicle I think). It’s not terribly hard to add support but I’m not sure we’ve heard of a good use case yet. Can I ask what use case you have in mind?

Thanks for the reply.

We saw Copter, Plane, and Rover were supported for MAV_CMD_DO_SET_MODE in the documentation, and MP takes the command without barking about incompatible firmware. We thought we were missing something.

Nevertheless, a use case:

The vessels we integrate are jet pumps, which are always turning, and engine idle equates to some forward velocity. We have shift ‘gates’ on separate actuators that require some manipulation to get ‘NEUTRAL’. We have written a bit of code in MAVROS to achieve braking, forward, reverse, etc. from the 1100-1900 PWM on throttle servo channel so things like pathing, braking before a turn, and LOITER work. But we need a different call to put the gate into a NEUTRAL position, otherwise the vessel idles around at like 6kts.

We have been utilizing the HOLD mode message to create our NEUTRAL command via MAVROS. So, end of mission, we see the HOLD mode and get our Neutral shift. Cool.

The complexity comes in when we have a target of interest during a mission, and want to create that Neutral shift via a HOLD mode so the sensor has some time to get its data.

Yes, we can utilize the DO_SET_SERVO to achieve the same goal (our actuators are CAN so we have to do more conversion in MAVROS), or even go to LOITER_TIME, but we thought we would try inserting a HOLD mode change mid-mission, followed by a conditional delay to get what we want and simplify things. At least our thought process for how to get Neutral would be linear, and we could train our guys on one method. Eg. - You want Neutral when preflighting? push the HOLD mode button. You want Neutral mid-mission? go to HOLD. End of mission, you get HOLD (and the vessel parks, but will drift with the barge or chase boat - unlike Loiter).

I have a few more use cases, but this should at least get the conversation going.

Thanks again!

Ok, so it sounds like the request is to have the (skid steering?) vehicle turn off all its motor (i.e. set motor outputs to SERVOx_TRIM) just like Hold mode does… but just for a specified period of time and then it should continue with the next mission command.

So the manual method of doing this would be to change the vehicle into Hold mode either from the transmitter or by sending a SET_MODE command from mavros. According to the AP ROS wiki page it looks like, “rosrun mavros mavsys mode -c 4” would switch it into Hold mode. And then later the vehicle could be switched back in Auto mode and it would continue with the mission.

Perhaps a better approach would be for us to add support for Hold-within-Auto. I.e. a mission command that simply shuts off the motors. That’s not very hard but we need to decide which mission command to use (list of existing commands starts here) or maybe we need to create a new one.

At the risk of being a bit pedantic, Hold-within-Auto is actually quite different than using DO_SET_MODE because if we added support for DO_SET_MODE then the vehicle would switch out of Auto into the Hold flight mode. We don’t process mission commands in any mode besides Auto so the vehicle wouldn’t move onto the next command after the NAV_DELAY completed.

Thanks again for your time.

This application isn’t skid steer, or electric motors (wish they were, everything would be much more simple). And, we can’t just shut off the engines (diesel, sometimes mogas) or we would loose all the higher current loads if they were down for a while (camera arrays, multiple radar, sonar arrays, etc).

And, no RC transmitter. Often, no GCS after the mission is created. MP is a great tool to create the missions, but after we upload a plan we have other ways to ensure safety and expected nav results (SatCom, VHF) - very very BLOS and weeks in duration.

I truly think your SET_MODE suggestion fits the bill for our issue. Thank you. We just haven’t stumbled across that option yet, but I’ll study the wiki you suggested.

The Hold-within-Auto concept is intriguing as well, but in our case it would be transmission shifting versus just stopping the motor. It would be awesome if there were a ‘hold for time’, or ‘hold until next’ and some parameters to specify where the output goes (Throttle to 1500, CH9 to some PWM).

The scenario changes a bit now to a different use case, but here is another great example of how we could use Hold-within-auto:

On other ground vehicle systems, we have a PAUSE mode. I guess it would be similar to HOLD in Rover, but we have been missing a few things there too (applying brake ramp to zero velocity, maintain brake at x%, then shifting the transmission to Neutral or Park). On PAUSE state change back to normal we clear ahead, shift to drive, and release brakes to resume mission.

For surface vessels, we really need a way to take in a signal (ADC, CAN, PWM, IP, anything) to trigger a PAUSE. Then a RESUME input signal would change the state back and kick AUTO. We would accomplish this through our discrete safety system (KillBox), and when a stakeholder (USCG, commercial operators, or incoming AIS target) needs the vehicle to stop what it is doing for a few (let traffic pass, whales swim by, do the ISR task, whatever), they just send the PAUSE. Once done, they flop the PAUSE.

Make sense?

We saw Copter, Plane, and Rover were supported for MAV_CMD_DO_SET_MODE in the documentation, and MP takes the command without barking about incompatible
firmware. We thought we were missing something.

Where was this documentation? While we decode that message we don’t
appear to use it for anything :slight_smile:

Yes, we can utilize the DO_SET_SERVO to achieve the same goal (our actuators are CAN so we have to do more conversion in MAVROS), or even go to
LOITER_TIME, but we thought we would try inserting a HOLD mode change mid-mission, followed by a conditional delay to get what we want and simplify
things. At least our thought process for how to get Neutral would be linear, and we could train our guys on one method. Eg. - You want Neutral when
preflighting? push the HOLD mode button. You want Neutral mid-mission? go to HOLD. End of mission, you get HOLD (and the vessel parks, but will drift with
the barge or chase boat - unlike Loiter).

This does sound like a MAV_CMD_NAV_DELAY or similar… either an option
to an existing one or a new one.

I found the reference to DO_SET_MODE with Rover support under Docs >> Mission Planning >> MAVLink Mission Command Messages (MAV_CMD).

Yes, what we really want is a NAV Delay, which we used to call a PAUSE on the military ground vehicles. It’s a great feature, but one which needs to be capable of execution from within the mission or flight plan and from an external trigger (sensor input, user pause, the state just before a full blown E-Stop). As well, it would be awesome to have a bit of logic or a series of parameters we could set other functions to. As I mentioned above, for something like a tank to PAUSE, we have to take a stepwise process:

1: Read velocity and zero throttle
2: Center steering at appropriate rate for current velocity
3: Apply braking force proportional to velocity to begin slowing vehicle
4: When velocity reaches zero, hold brakes at 100% and begin shift process (Park, Neutral, or Clutch)
5: When shift feedback is confirmed, you can usually release brakes to save power. We use IMU as inclinometer to help decide that.
6: If PAUSE lasts more than X seconds (minutes), then kill ignition and set low power mode.

Most of that logic still happens in MAVROS or similar elsewhere (the RoboteQ controllers have some scripting capabilities that are useful). So, the PAUSE just needs a parameter set to tell which logic to run. For the community at large, maybe a parameter to set a PWM out to a defined channel (to throw up a flag, turn on a light, trigger a camera, etc) would be cool.

Is support for the DO_SET_MODE command (in Plane) still being considered? I too was attempting to use this command for SITL testing of an glider that is air-launched from a mothership.

Perhaps there is a better way to do this beside mode switching, but my current idea for testing/controlling this configuration was to set the glider in a “armed but stationary and listening” kind of mode while the mothership carries it up. Then after release (physical switch for test flight but DO_SET_MODE switch for SITL) the glider will switch into an auto or a controlled descent mode that accomplishes some mission on descent.

I have been diving into the ArduPlane source code in an attempt to create these flight modes, but is this the proper approach to controlling this configuration? Is there another way to test this switch between modes in SITL?

Thanks in advance for any help!

@bignick26, it might be better/easier to use Lua scripts for this. Lua scripts can check the state of a relay (and a few others things) and also change the vehicle’s mode (once this PR goes into master which will probably happen this week)

1 Like

Ah shoot it looks like the flight controller we are using (RevoMini - yes its not the best choice but it is light weight!) only has 1MB of flash available. Do you think this switch between vehicle control styles would be possible by writing each different flight mode’s control algorithms inside of single flight mode?

Thanks again for the help

@bignick26, I can’t really give good advice on implementing stuff in Plane. In particular the flight mode architecture is quite different form the other vehicles (for now). It’s probably best to ask in the Plane forums or on the gitter channel (which is good place for development questions)

1 Like