ROBOTICSSHIPPED

Smooth Drone Landing with PX4 and ROS 2

A ROS 2 node that flies a PX4 drone through waypoints and lands it on target. The original mission lunged at almost 4 m/s and touched down while still sliding. I made it fly at a set speed, stop fully at each waypoint and only then land.

ROLEFlight control software (ROS 2 node)
TIMELINEOct 2026 - Nov 2026
CATEGORYRobotics

~4 → 0.8 m/s

CRUISE SPEED

0.1 m/s

MUST BE SLOWER THAN, TO COUNT AS ARRIVED

1 s

HOVER BEFORE LANDING

20 Hz

SETPOINT RATE

2 → 10

UNIT TESTS

Python + C++

IMPLEMENTATIONS

FLIGHT DECK // MISSION REPLAY, TOP VIEW

12345mSTART5 M MARKER
STATE
–
WAYPOINT
–
SPEED
–
ALTITUDE
–
FWD, RIGHT
–

The target slides ahead at 0.8 m/s. The drone stops for a second at each corner and lands only from a hover. Replay of the mission logic, not logged flight data.

COMPARISON // SAME SIMULATOR, SAME START PAD

BEFORE~4 m/s

The original mission: one jump to a point 5 m away, then Land.

  • Lunges forward with about 30° of tilt
  • Land starts while it is still moving
  • Touches down sliding, past the target
AFTER0.8 m/s

My version: a 5 m by 3 m rectangle, landing back on the start pad.

  • Follows a target that slides ahead at a set speed
  • Stops for a second at every waypoint
  • Lands only from a still hover

Overview

The mission is simple to say: take off, fly somewhere, land. A ROS 2 node sends position targets to the PX4 flight controller in Offboard mode, and PX4 flies the drone. I developed it in simulation (PX4 SITL with Gazebo Harmonic, ROS 2 Jazzy), and we also flew it on a real drone. I don't have footage of that flight, so the two videos here are from the simulator.

What was wrong

The starting point was a working node with three steps: take off to 1 m, send a target 5 m ahead, and switch to Land once the drone was within 25 cm of it. It completed the mission, but badly.

  • It lunged. PX4's Offboard position control does not smooth the targets it is given. Moving the target 5 m in one step made the drone fly at almost 4 m/s with about 30° of tilt, at a height of 1 m.
  • It landed while moving. "Within 25 cm" says nothing about speed. The drone passed through that zone at full speed, Land started, and PX4 landed at wherever the drone was while it was still sliding. It touched down moving sideways and ended up past the target.

What I changed

A moving target. The node no longer sends the waypoint itself. It sends a point that slides toward the waypoint at cruise_speed (0.8 m/s by default), updated 20 times a second. The drone follows a point that is always just ahead of it, so it never sees a large error and never tilts hard.

def step_toward(point, goal, max_step):
    """Move `point` toward `goal` by at most `max_step` meters."""
    distance = math.dist(point, goal)
    if distance <= max_step:
        return tuple(goal)
    ratio = max_step / distance
    return tuple(p + (g - p) * ratio for p, g in zip(point, goal))

Arrived means stopped. A waypoint counts as reached only when the drone is inside the acceptance radius (15 cm), slower than 0.1 m/s, and has stayed that way for the hold time (1 s). Position alone is not enough, because a drone can pass through a point at speed.

Land only from a hover. The Land command is sent only after the last waypoint has been reached by that rule. By then the drone is sitting still above the spot, so PX4 brings it straight down.

Waypoints instead of one leg. The route is a parameter, written as forward,right,height triples relative to where the drone started:

run_mission.sh waypoints:="5,0,1; 5,3,1.5; 0,3,1.5; 0,0,1" cruise_speed:=0.8

That default flies out to the green marker, around a 5 m by 3 m rectangle, and back to land on the blue marker it took off from. Leaving waypoints empty gives the original single-leg mission, so the old behaviour is still one flag away.

Making it testable

The geometry and the state machine are plain functions, so most of the behaviour can be tested without a simulator. The test file went from 2 tests to 10. The ones that matter most:

  • the target moves at exactly the cruise speed,
  • a multi-waypoint mission visits every point and lands at the last one,
  • the node does not send Land while the drone is still moving.

I also wrote a small script that reads a PX4 flight log (.ulg) and summarises the landing: speed and tilt during the flight, and how fast the drone was moving when Land began.

The same logic exists in Python and in C++, taking the same launch arguments.

What I learned

The bug was not in the controller. PX4 did exactly what it was asked. The node was asking for the wrong thing: a 5 m step, and a landing triggered by position with no thought for velocity. Both fixes are a few lines each. Finding them meant reading what Offboard mode actually promises, which is less than I had assumed.

APPENDIX A // MEDIA

FIG.01 · Coming back to the blue start marker after flying the rectangle
FIG.01 · COMING BACK TO THE BLUE START MARKER AFTER FLYING THE RECTANGLE