Cannot takeoff using VEHICLE_CMD_NAV_TAKEOFF


I have followed this tutorial for offboard control with ROS2 : ROS 2 Offboard Control Example | PX4 User Guide.

Everything is working fine but now I am trying to play a bit with this script. I want to takeoff the drone using the command VEHICLE_CMD_NAV_TAKEOFF (seen in VehicleCommand (UORB message) | PX4 User Guide).

I modified the timer_callback to :

auto timer_callback = [this]() -> void {

			if (offboard_setpoint_counter_ == 10) {
				// Arm the vehicle


			// stop the counter after reaching 11
			if (offboard_setpoint_counter_ < 11) {

My problem is that when I run this in gazebo with QGroundControl also opened, the drone arms (the propellers rotate in gazebo) and I see a message saying “Warning: Using minimum takeoff altitude: 2.50m” but the drone doesn’t move.

I might be doing something wrong but I don’t understand why it doesn’t work. Could someone please help me ?

Thanks !

Another interesting thing: I changed the script with VEHICLE_CMD_NAV_LAND instead of VEHICLE_CMD_NAV_TAKEOFF.

In QGroundControl I ask the drone to takeoff (it works), then I launch the ROS node that is supposed to land with this modified script and it works.