Hi, I have a quad rotor with a pixhawk 1, raspberry pi 3b+ with mavros. I’m working on a script to send commands to the UAV throught /mavros/setpoint_velocity/cmd_vel.
Normally I flight in POSHOLD to positioning the UAV, then run my script, wich send cmd_vel messages, and switch to GUIDED with my RC. I’ve notice that /mavros/state-> mode change to GUIDED in situations where the UAV is in fact in POSHOLD, ie if I don’t send cmd_vel messages, but switch to GUIDED, the UAV is still in POSHOLD, but /mavros/state->mode indicate GUIDED.
So, my question is, is there a way to confirm, through mavros or through GCS, that AP is in GUIDED mode?
Once the UAV is in GUIDED mode, if I turn off my script the AP goes to POSHOLD, what happend if I start my script again? is AP goes to GUIDED again or do I need to change flight mode in order to re-enter in GUIDED mode?
I ask on mavros, but they tells me that it is up to AP on how this is implemented.
If there’s an onboard log I can have a look but in general ArduPilot won’t change modes unless something has command it to. So I strongly suspect that mavros is sending the mode changes.
Regarding mavros incorrectly showing the mode, this definitely sounds like a mavros problem. If the GCS says it’s in a particular mode then it’s in that mode.
I think the mode changing that’s happening must be part of the script (or mavros). So AP won’t be changing to PosHold withough being commanded too somehow. I wonder if maybe the script is sending RC_OVERRIDES or MANUAL_CONTROL messages which are overriding the regular pilot input. If “yes” then in general this is not a good way to control the vehicle. It’s much better to use the SET_POSITION_TARGET_xxx messages.
By the way, there’s a few ROS experts here in the ArduPilot Vision Projects gitter channel.
I think I don’t explain myself. Sorry.
I have my RC transiter configured to change flight mode. I usually take off in stabilized, then go to althold and finally go to poshold. As I want to test my script in guided mode, I need that previouse flight mode was poshold.
My script sends /mavros/setpoint_velocity/cmd_vel (my controller script has velocities as their output).
If I don’t start my script, but I change flight mode to GUIDED, the AP change to GUIDED. GCS shows GUIDED and mavros/state->mode shows GUIDED. But how can the copter be in GUIDED mode without any mavros command?, it will fall out, but it is in the air, maintaining their position. I think that internally, AP reject GUIDED mode (becouse it don’t receive messages) and remain in POSHOLD. But it inform that is in GUIDED mode. So, my question is how to be sure that AP is in GUIDED mode and is commanded by my messages…
I believe if you are in POS HOLD and switch to GUIDED, the functionality of GUIDED will just hold your current position. If I understand GUIDED correctly, then your drone is awaiting commands to move. If you were in POS HOLD and started sending commands the drone would not move.
Eric is right. The AP will not switch to GUIDED unless commanded by your RC, your GCS or through your MavROS script. And once in Guided, the drone will be holding its position waiting for position commands.
And you need to have a GPS (or Optical Flow) position to fly in Guided. Why are you going from Stabilize to Althold to Poshold? I would rather takeoff in Loiter and therewith have a valid position ensured.
I know that the AP siwtch to GUIDED through my RC transmitter, I do give the order with my flight mode switch. But, AP will accept or will not accept flight mode switch to GUIDED under certain conditions, at least px4 work like that.
I’m looking this:
in particular this:
“Before entering Offboard mode, you must have already started streaming setpoints. Otherwise the mode switch will be rejected. Here,
100 was chosen as an arbitrary amount.”
Then there is some check:
if( set_mode_client.call(offb_set_mode) &&
so, it seems that, for px4, if I don’t send commands through mavros topics (for example, cmd_vel, or position_local) and try to change flight mode (with my RC transmitter) to OFFBOARD, the firmware reject the flight mode change and stay in previous flight mode and there is a way to know if the firmware accept or reject the flight mode switch to OFFBOARD (GUIDED in AP).
So, if I don’t send commands to the AP through mavros topics and switch to GUIDED (with my RC transmiter flight mode switch), does AP accept or reject the GUIDED mode?
ArduPilot GUIDED mode doesn’t work like Offboard. We don’t need input before accepting the switch because by default the vehicle will wait on spot.
Nevertheless there are still some condition before being able to use GUIDED mode like having a good GPS fix
Finally!!! It’s make sense now!
Can You tell me where do I find those conditions?
Oh, I already read that doc. It seems old and it say nothing about ROS and mavros, just GCS. It say that guided flight mode is not achived by rc transmiter switch…
Perhaps we can change the wiki wording a bit. It current says this:
Guided mode is not a traditional flight mode that would be assigned to a mode switch like other flight modes
This is trying to steer normal users away from setting it up with a flight mode switch because most users would never want to switch into it from a receiver because the pilot’s stick inputs have no effect on the vehicle once it’s in Guided mode. It’s normally the GCS that switches the vehicle into Guided mode and then it starts sending target attitude, velocity or position commands.
Anyway… maybe we can make it a bit more clear.
Ok, I understand.
In our research team is it common to flight the agent to a specific position start a script and switch to OFFBOARD/GUIDED. In fact we don’t use any GCS. Sometimes we develop a rqt plugin for visualization/control purpose.
I think that it’s they way to work that most research people that uses ROS implement.
Anyway, it’s clear now how guided works on AP. Thanks again!