I’m trying to control a drone with acceleration setpoints, sent via mavlink in offboard mode in SITL.
the code is:
mavros_msgs::msg::PositionTarget pt;
pt.coordinate_frame = mavros_msgs::msg::PositionTarget::FRAME_BODY_NED;
pt.type_mask = mavros_msgs::msg::PositionTarget::IGNORE_PX | mavros_msgs::msg::PositionTarget::IGNORE_PY |
mavros_msgs::msg::PositionTarget::IGNORE_PZ | mavros_msgs::msg::PositionTarget::IGNORE_VX |
mavros_msgs::msg::PositionTarget::IGNORE_VY | mavros_msgs::msg::PositionTarget::IGNORE_VZ |
mavros_msgs::msg::PositionTarget::IGNORE_YAW;
pt.acceleration_or_force.x = 0.0;
pt.acceleration_or_force.y = 0.0;
pt.acceleration_or_force.z = 0.0;
pt.yaw_rate = 0.0;
I have tuned MPC_THR_HOVER, so that when all accelerations are 0, the drone is just hovering, this is correct.
But when I set
` pt.acceleration_or_force.x = 5.0;
Instead of accelerating forward, the drone starts to move downwards (quite steep at 45 dergess), loses altitude and crashes.
What can be wrong here, and how to achieve horizontal acceleration?