Offboard Mode with MicroDDS-Agent (ROS2)
-
Hello, I've noticed with PX4 1.14 that sending TrajectorySetpoint messages causes "jittery", nearly unstable, behavior unless vehicle is in "offboard" mode. For background, consider there are two flight modes set to choose from: "Position" and "Offboard"; a custom modification of the px4_ros_com example has been created that removes programmatic arming and programmatic flight mode changes and only continually publishes TrajectorySetpoint and OffboardControlMode messages at 20 Hz. The "offboard_mode" field in voxl-vision-hub.conf has been set to "off" so there shouldn't be a conflict there.
Expected behavior: PX4 stack should ignore TrajectorySetpoint and OffboardControlMode messages while vehicle flight mode is in "position" control, then should start following the trajectory setpoints according to the offboardcontrolmode settings when flipped into "offboard"mode.
Observed behavior: When sending TrajectorySetpoint messages in "position" mode, vehicle becomes extremely jittery with reduced controllability, as if it's trying to implement these setpoints. Sending OffboardControlMode messages does NOT affect behavior whether in "position" or "offboard" mode and hence can be used as the "offboard heartbeat signal" to keep offboard mode active. Sending TrajectorySetpoint messages in offboard mode works as expected. This has been observed using both the VOXL2+VOXL2IO+m500 frame as well as the Starling.
Question: Are we to expect in PX4 1.14 that this behavior is correct and we need to only send TrajectorySetpoint messages as soon as offboard mode is switched on or is this a bug in the firmware?
Thanks!
-Joe
-
@JoeC Have you asked this question to the PX4 community as well?
-
@Eric-Katzfey I have not, but I can do that.
-
@JoeC trajectory setpoint and offboard is a subset of position based flight - meaning you cannot go into offboard mode if you cannot go into position mode. Sending the offboard control mode message will not effect position based flight, but sending the trajectory setpoints will affect position based flight as that is a heavily leveraged uorb in the flight manager module in PX4 - so by sending these in position mode, you will see issues arise as it is conflicting with the trajectory setpoints being produced by the EKF algorithm.
One you move into offboard mode, you no longer have the ekf2 algo playing into the flight dynamics in position mode, meaning that it is purely listening to the uorb topic of trajectory data being piped in from the dds which is why you see smoothness - hopefully this answers your question.
Zach
-
@Zachary-Lowell-0 Thanks Zach, this does answer. I have been used to ROS1/MAVROS where sending position targets was completely ignored unless in offboard mode so my node would typically blast setpoint_raw messages whether in offboard or not (in part to keep the option of switching to 'offboard' mode "alive").
I will proceed from now on in ROS2/MicroXRCE assuming I should constantly send offboard control mode messages, but send traj setpoints only when offboard mode is confirmed. I appreciate the clarification on why this is.
-Joe