I’m using a companion computer to fly in guided mode, which on the whole is working well.
However, I’m slightly puzzled by the behaviour of MAV_CMD_NAV_LOITER_UNLIM. I’m attempting to use this command to hold position until appropriately interrupted. The command is being issued with 0.0f values for latitude, longitude and altitude as suggested by the documentation, i.e. the copter should hold its position and altitude.
So, the copter does hold its latitude / longitude, but also descends as if it was performing a land. Specifying the current altitude value makes no difference, the copter still behaves the same way.
Am I missing something? Is there something else I need to do to make this work?
I also set up a load of telemetry streams, for brevity these have been omitted. They are used to control the scheduling of the guided commands etc. For example, the loiter is interrupted by the land command after 5 seconds.
Hopefully you’ll be able to see that as soon as the loiter is issued, the altitude starts to decrease before it is interrupted by the land command.
Let me know if there is anything else you need.
Request Guided Mode – MAV_CMD_DO_SET_MODE set to COPTER_MODE_GUIDED
Takeoff – MAV_CMD_NAV_TAKEOFF, to an altitude of 20.0m
Null Waypoint – MAV_CMD_DO_REPOSITION with the lat/lng/alt parameters set to the same values as the takeoff. This is the work around for #21080 (speed change after takeoff)
Speed Change – MAV_CMD_DO_CHANGE_SPEED, set to 8.0m/s
Waypoint – MAV_CMD_DO_REPOSITION, flies ~40m West from the takeoff point
Loiter – MAV_CMD_NAV_LOITER_UNLIM, the lat/lng/alt are all set to 0.0, this is being used to create a “delay”, i.e. in this example it is interrupted after 5s by issuing the land command
First of all, nothing is wrong with the firmware (w.r.t. that log).
You shouldn’t be able to send MAV_CMD_NAV_LOITER_UNLIM to the vehicle in GUIDED mode.
You can’t use every AUTO mode command in GUIDED mode.
In that log, there isn’t MAV_CMD_NAV_LOITER_UNLIM issued but there is a mode changing to LOITER mode.
The LOITER mode requires an RC controller, if the throttle is below 50% vehicle descends, if the throttle is above 50% the vehicle ascends.
During the flight, the throttle left at zero so this is why the vehicle start to descend (in LOITER mode).
There is no state machine like AUTO mode in GUIDED mode.
You need to send the command one by one, and the vehicle executes that command ASAP if it can.
I’m definitely sending a MAV_CMD_NAV_LOITER_UNLIM in guided mode and it is being ACKed. I had noticed the LOITER mode change, which I assumed was triggered by the MAV_CMD_NAV_LOITER_UNLIM command and was expected.
The documentation does state that this particular loiter command (i.e. the “UNLIM” version) can be issued in guide mode. I did try others and as expected they were NACKed.
I did wonder about whether the throttle setting was to blame, makes sense.
Question, if the throttle is at or above 50% and the loiter altitude is set to 0.0, is the loiter then expected to hold its altitude? When I get a chance I’ll test this.
I think like Henk I’ll abandon the use of loiter (the mode change is also a minor complicating aspect) and implement my halt / delay functionality using velocity control.
Actually there are some safety related precautions.
There is a parameter called guid_timeout.
This parameter make sure that you’re updating target vehicle state at a reasonable frequency.
Other that that, you can always create a fence to also limit target position.
If you want to limit target vehicle state, change guided timeout, and if you want to limit the entire flight, enable/disable fence.
There are other limits on automatic flight related with vehicle state like speeds accelerations angles etc.
Take a look at them.