MC offboard attitude control via ROS2 latching permanently

I have been following the JaeYoung Lim’s px4-offboard package for controlling a quadcopter via position/velocity commands using the offboard_control_mode and trajectory_setpoint topics. This is all working well.

However, I want to now control the quad with attitude setpoints, which I’m using the vehicle_attitude_setpoint topic to do. I can actually successfully set the quaternion and thrust setpoints and the quad will meet the setpoint, however when this setpoint is set on the ROS2 topic, it is permanently latched regardless of mode. For example, if I am in position and send the atti command the quad will try to reach the setpoint even though it is not in offboard. Also when I stop sending commands to quad will not stop trying to hit the old atti setpoint. The only way so far I’ve managed to get it to kick out of this atti control is to use QGC to set it to stablised (setting it to position, hold and altitude does nothing).

This leads me to believe setting this topic is setting an attitude setpoint quite low level in the flight controller which is unsuitable for switching modes between different types of offboard control. Ultimately, I need to be able to go from vel control → atti control → vel control. It is the mode switch back to velocity control which is blocking me right now. Any advice or insight is appreciated.

Problem is now solved. It was because the timestamps of the velocity msg was not being set whereas the attitude message did have an up to date timestamp. So if you come across something similar check that all timestamps have been set correctly in sent messages.

1 Like