Hi! I am using the new flight modes feature from release v.1.15 implemented in a C++ node which publishes position setpoints (TrajectorySetpoints).
I have successfully implemented this for a quadcopter in simulation, and all is well. The flight mode seems to be called correctly and the drone flies as expected.
However, when switching to a fixed wing aircraft the aircraft does not respond to the messages. It slowly turns to the left instead of going in the direction of the target.
I have a difficulty understanding why…
My setpoint has the following implementation:
void PositionSetpointType::update(const Eigen::Vector3f &position_ned_m)
{
onUpdate();
px4_msgs::msg::TrajectorySetpoint sp{};
sp.timestamp = _node.get_clock()->now().nanoseconds() / 1000;
sp.position[0] = position_ned_m.x();
sp.position[1] = position_ned_m.y();
sp.position[2] = position_ned_m.z();
sp.velocity[0] = sp.velocity[1] = sp.velocity[2] = NAN;
sp.acceleration[0] = sp.acceleration[1] = sp.acceleration[2] = NAN;
sp.jerk[0] = sp.jerk[1] = sp.jerk[2] = NAN;
sp.yaw = NAN;
sp.yawspeed = NAN;
_trajectory_setpoint_pub->publish(sp);
}
SetpointBase::Configuration PositionSetpointType::getConfiguration()
{
Configuration config{};
config.rates_enabled = true;
config.attitude_enabled = true;
config.acceleration_enabled = true;
config.velocity_enabled = true;
config.position_enabled = true;
config.altitude_enabled = true;
config.climb_rate_enabled = true;
return config;
}
I have read this: https://docs.px4.io/main/en/flight_modes/offboard.html and noted that trajectory set point is not mentioned for fixed wing: https://docs.px4.io/main/en/flight_modes/offboard.html#fixed-wing
However some people have mentioned that this should be supported: https://github.com/PX4/PX4-Autopilot/pull/12532
How do I achieve this? Do I need to send SET_POSITION_TARGET_LOCAL_NED? How to achieve that from the new format of flight modes in v1.15 (which I generally like)?
Or should I start using offboard mode instead?