Attitude¶
The toolkit sends desired attitude and collective thrust to PX4. PX4 retains attitude/rate feedback and allocation. This mode requires a curated hover-thrust scale.
Force to rotation¶
Use the common translation errors and acceleration law:
Desired heading \(b_{1c}=(\cos\psi_d,\sin\psi_d,0)^\top\) fixes the remaining attitude:
\(R_d\) maps desired FRD axes into NED. The foundations explain degeneracy and the frame conventions. The runtime converts \(R_d\) to a normalized scalar-first quaternion \(q_d=(w,x,y,z)\), using trace/major-diagonal branches to avoid an unstable single formula near 180° rotations.
Collective projection and message¶
Collective uses the current body axis, not the norm of the desired specific force \(B=A/m\):
VehicleAttitudeSetpoint.q_d contains the FRD-to-NED quaternion. thrust_body=(0,0,-u_T) is dimensionless; negative FRD Z means upward thrust. yaw_sp_move_rate contains desired trajectory yaw rate in rad/s. Only OffboardControlMode.attitude is enabled.
Hover scale \(h\) comes from px4_allocator.hover_thrust in vehicle YAML. Collective projection/clipping can reduce thrust during attitude error. PX4 runs attitude/rate feedback.
Timing, run, and diagnosis¶
Valid position/velocity and attitude are required. The outer timer (100 Hz by default) publishes after confirmed Offboard; jerk/snap are not needed to construct \(R_d\) here. Shared lifecycle behavior still applies.
In a separate repository-root shell, with a matching, already airborne SITL vehicle and no competing controller:
source ros2/runtime_env.sh
ros2 launch offboard_controllers se3.launch.py \
vehicle:=gz_f450 trajectory:=line_x handoff:=attitude \
publish_diagnostics:=true record:=true
Inspect desired/measured attitude, specific-force direction, normalized collective, downstream rates, and motor limits. The law rejects invalid hover calibration and degenerate force/heading geometry.
Read attitude_reference.cpp, wrench.cpp, and publication.cpp.