ROS2 Offboard - Transitioning from Position to Acceleration Setpoints

Hello.

I’m implementing a ROS2 offboard control package to fly a dev drone running PX4 (v1.14). I have it set up so that I publish offboard_control_mode messages with the position flag set true and publish trajectory_setpoint messages with just position setpoints (all other fields set to NAN) until the quad reaches a desired position. I then switch to publishing offboard_control_mode messages with the acceleration flag set true (all other fields false) and trajectory_setpoints with just acceleration setpoints (all other fields NAN) to implement a custom guidance law.

The issue I’m having is as soon as I transition to offboard acceleration setpoints, the vehicle just initiates a land sequence. Looking back at the log I can’t find any indication of a failsafe condition being implemented. I’ve read through the commander code and mc_pos_controller code and haven’t found anything that stands out as to what might have went wrong.

When I switch to acceleration, the vehicle_control_mode updates accordingly, flag_control_position_enabled and flag_control_velocity_enabled go from true to false and flag_control_acceleration_enabled goes from false to true. flag_multicopter_position_control_enabled and flag_control_offboard_enabled stay true the entire time.

The trajectory_setpoint messages look correct, but the vehicle_local_position_setpoints aren’t tracking the change. The vehicle_local_position.vx/vy stop when I switch to acceleration setpoints, but the vehicle_local_position.vz setpoint goes to +1.0m/s and the vehicle_local_position.az setpoint jumps to roughly +9m/s^2

Does anyone know why this might be happening? Should I be sending the same offboard control message the entire time (position, velocity and acceleration true) and just go from NAN accleration setpoints to NAN position setpoints when I want to switch?

Am I right to assume that vehicle_local_position_setpoint.vz should always be NAN if trajectory_setpoint.velocity[2] is NAN? Would the only way to see the sudden jump to vehicle_local_position_setpoint.vz = 1m/s if the position control is generating a failsafe trajectoryb setpoint? What failsafe would I have invoked by just switching to acceleration setpoints? Are there any additional requirements for flying with only acceleration setpoints?

Any advice on troubleshooting would be greatly appreciated.

I should add that I ran the offboard control package with px4_sitl in gazebo and it performs perfectly. I’m using a modalai sentinel drone w/ sdk1.1.2. The PX4 fork I’m using is here: