ArduPilot SITL + MAVROS + ROS2: Drone arms and flies from MAVProxy, but won’t take off when controlled from ROS2

Hello everyone,

I’m running ArduPilot SITL + Gazebo (Harmonic) + MAVROS + ROS2 Humble, using the official ArduPilot Gazebo plugin.

I’m facing a strange issue:

When I use MAVProxy manually:

mode guided
arm throttle
takeoff 5

The drone arms and takes off perfectly.

But when I use my ROS2 Python script with MAVROS to:

  • switch to GUIDED

  • arm

  • publish position setpoints

  • and perform a takeoff by commanding altitude

The drone does NOT take off.

The SITL console shows messages like:

AP: Arm: Need Position Estimate
AP: PreArm: Need Position Estimate
Got COMMAND_ACK: COMPONENT_ARM_DISARM: FAILED
Mode GUIDED

But the strange part is that if I do it running mavproxy and ROS commands, it works.

What my ROS2 script does

  • Waits for FCU connection

  • Publishes setpoints at ~10 Hz on /mavros/setpoint_position/local

  • Calls /mavros/cmd/arming

  • Calls /mavros/set_mode with "GUIDED"

  • Sends a position target at (0,0,10)

The script compiles and runs without errors, but the drone never leaves the ground.

My question

Why does the drone take off correctly when using MAVProxy commands,
but refuses to take off when performing the same sequence through MAVROS in ROS2?

What am I missing in the MAVROS/ROS2 workflow to allow the drone to arm and take off properly?

Any help or clarifications are greatly appreciated!

ArduPilot can’t arm because it’s not getting a position. Confirm your position setpoints are being published.

1 Like

At the end what I did was to firstly run some commands in order to takeoff first and then execute my ROS mission. I guess that this is not how it should be done but its free of errors.

Would you mind telling me how to confirming those setpoints or at least where to refer in the docs?

Oops, misread your original message.

The “Need Position Estimate” message occurs because your vehicle does not have a good enough GPS lock for arming. In SITL, ArduPilot may require up to ~30 seconds to have a stable GPS lock.

It’s unrelated to the position setpoints.