Hello, I am using the PX4 v1.15.0 firmware. I am trying to add additional behaviour to my drone by using offboard mode and publishing offboard_control_mode and trajectory_setpoint messages from my module inside PX4.
The drone needs to operate in environments without GPS or a velocity estimate, so I was trying to implement something similar to the altitude mode, where we control z velocity and xy acceleration. But it seems like (according to the table below from the docs) offboard acceleration requires a velocity estimate.
I am publishing the following offboard control mode message:
// Publish an offboard control mode message
offboard_control_mode_s ocm;
ocm.timestamp = hrt_absolute_time();
ocm.position = false;
ocm.velocity = false;
ocm.acceleration = true;
ocm.attitude = true;
ocm.body_rate = false;
ocm.thrust_and_torque = false;
ocm.direct_actuator = false;
_offboard_control_mode_pub.publish(ocm);
and the following trajectory_control message:
trajectory_setpoint_s trajectory_setpoint;
trajectory_setpoint.timestamp = hrt_absolute_time();
trajectory_setpoint.position[0] = NAN;
trajectory_setpoint.position[1] = NAN;
trajectory_setpoint.position[2] = NAN;
trajectory_setpoint.velocity[0] = NAN;
trajectory_setpoint.velocity[1] = NAN;
trajectory_setpoint.velocity[2] = 1;
trajectory_setpoint.acceleration[0] = 1;
trajectory_setpoint.acceleration[1] = 1;
trajectory_setpoint.acceleration[2] = NAN;
trajectory_setpoint.jerk[0] = NAN;
trajectory_setpoint.jerk[1] = NAN;
trajectory_setpoint.jerk[2] = NAN;
trajectory_setpoint.yaw = _target_attitude_absolute_euler.psi();
trajectory_setpoint.yawspeed = NAN;
_trajectory_setpoint_pub.publish(trajectory_setpoint);
From my understanding the xy acceleration in PX4 is not closed loop and is just directly mapped to an attitude setpoint, so it shouldnāt need either a position or velocity estimate. It looks like the altitude mode does the same as what I have done here as well, by publishing a trajectory_setpoint message with xy acceleration and z velocity.
If I change the offboard check in src/modules/commander/HealthAndArmingChecks/checks/offboardCheck.cpp
to remove the check on acceleration then my code seems to work fine in SITL simulation, I can command accelerations in offboard mode without GPS.
if (offboard_control_mode.position && reporter.failsafeFlags().local_position_invalid) {
offboard_available = false;
} else if (offboard_control_mode.velocity && reporter.failsafeFlags().local_velocity_invalid) {
offboard_available = false;
}
// else if (offboard_control_mode.acceleration && reporter.failsafeFlags().local_velocity_invalid) {
// // OFFBOARD acceleration handled by position controller
// offboard_available = false;
// }
I am just wondering if there is an issue with the logic here or there is some case I have not thought of where velocity estimates would be required for acceleration control?
Thanks