Skip to content
Fixit-DavidePublic

About

ROS 2 navigation stack for PX4 drones: lidar voxel map (Bonxai), moving-object tracking, A* + Informed-RRT* planning, behavior-tree navigator with 3D recoveries

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Repository files navigation

uav_nav

Autonomous 3D navigation with obstacle avoidance for a PX4 multirotor on ROS 2.

Give it a goal and the drone flies there on its own: it maps the world in 3D as it flies, tracks the people and vehicles that move, plans around both, replans in flight when something new blocks the way, and recovers when no plan can be found. It runs on ROS 2 Lyrical with PX4 main (native Zenoh or uXRCE-DDS) and is tested end to end in PX4 SITL with Gazebo.

Flying through the dense half of mixed_field Left Gazebo, right RViz: the 3D map built in flight (voxels coloured by height), the global A* route (blue), the local path (green, Informed-RRT* then) and the track flown (orange).

Features

  • 3D mapping from a 3D lidar and a front depth camera into a Bonxai occupancy map, shared zero-copy between the servers.
  • Moving-object tracking: people, carts and flying objects are found in the lidar scans and the depth camera's cloud, tracked with their velocity, left out of the map, and planned around where they are going.
  • Two-level planning: a global A* route over the whole volume and a local AIT* path along it (OMPL), a few metres at a time; long detours are flown over.
  • Smooth flight: paths are flown as jerk-limited trajectories with feed-forward, and new paths are spliced on without stopping.
  • Replanning in flight when newly mapped obstacles or moving objects block the path, plus dodging what comes at the vehicle.
  • Recoveries driven by a BehaviorTree.CPP tree: wait for moving objects to pass, climb to see over what blocks the way, or back up.
  • Landing and return home: the drone lands at the goal (PX4's Land mode) and takes off for the next one; on a low battery it flies home around obstacles and lands there.
  • A real PX4 flight mode: "UAV Nav" shows up in QGroundControl and on the RC switch next to PX4's own modes; PX4's failsafes and the pilot always take precedence. OFFBOARD works too.
  • Nav2-style architecture: lifecycle servers in one container, pluginlib planners and path followers, Nav2's navigate_to_pose goal interface, health on /diagnostics.

Gallery

Large-scale navigation. A 390 m tour of the four corners of the 100 m × 100 m mixed_field (magenta), through a dense and a sparse half, past walkers (orange), turning bars (red) and sliding doors (blue). Moving objects. A flying ball crossing the drone's way, tracked as a moving object (orange box with its velocity), kept out of the map and planned around.
Lidar and depth camera. The front depth camera (cyan) covers the ground and low objects in front, below the lidar's ±15° view (red rings). Planning. In the obstacle course's pillar field, the A* route (cyan) and the local path (green, Informed-RRT* then) weave between the mapped pillars.
Maze. Inside a closed maze of 5 m walls, mapped as the drone works its way through. Changing obstacles. Past a wall whose sliding doors open and close.

How it works

flowchart LR
    subgraph PX4["PX4 autopilot (SITL or real)"]
        ODO["odometry, status,<br/>failsafe flags"]
        IN["trajectory setpoints,<br/>commands, mode"]
    end
    subgraph C["nav_container (one process, zero-copy)"]
        PE["perception"]
        MS["map_server"]
        PS["planner_server<br/>A* + AIT*"]
        CS["controller_server"]
        BS["behavior_server"]
        NV["navigator"]
    end
    LIDAR["3D lidar"] --> PE
    DEPTH["front depth camera"] --> PE
    PE -- "static points" --> MS
    PE -- "moving objects" --> PS
    PE -- "moving objects" --> CS
    ODO --> DP["drone_pose<br/>map → base_link"]
    DP -- tf --> MS
    MS -- "3D map" --> PS
    MS -- "3D map" --> CS
    GOAL["goal<br/>(RViz, navigate_to_pose)"] --> NV
    NV -- compute_path --> PS
    NV -- follow_path --> CS
    NV -- "climb, back_up, wait" --> BS
    BS -- follow_path --> CS
    ODO --> CS
    CS --> IN
Loading

Each server is its own package, with a README that explains what it does, its parameters and how it was measured:

Package Role
uav_map_server Mapping: lidar and depth camera → Bonxai 3D occupancy map, incremental snapshots, zero-copy transport, save / load
uav_perception Perception: moving objects found in the scans, tracked, and removed from what gets mapped
uav_planner_server Path planning: compute_path, a global route and a local path through plugins
uav_planners the planner plugins: A* (global) and AIT* / ABIT* (local, OMPL)
uav_controller_server Control: follow_path, the "UAV Nav" PX4 mode, failsafes, blocked-path checks, dodging
uav_controllers the path follower plugin: jerk-limited reference with feed-forward
uav_navigator Navigation: navigate_to_pose, a behavior tree over planning, following and recoveries
uav_behavior_server Recoveries: climb, back up, wait
uav_nav_core shared library: map snapshots, collision checking, plugin interfaces
uav_nav_msgs messages, actions and services
uav_nav_bringup launch, parameters, RViz view, PX4 SITL model and worlds; how the servers communicate

The map → base_link tf comes from drone_pose (separate repo). docs/bonxai_eval compares Bonxai with OctoMap on recorded scans.

Quick start

Needs ROS 2 Lyrical, PX4 main, Gazebo Jetty, rmw_zenoh_cpp, OMPL and the packages listed in the bringup README.

cd ~/ros2_ws/src && git clone https://github.com/facontidavide/Bonxai.git
cd ~/ros2_ws/src && git clone --recursive https://github.com/Auterion/px4-ros2-interface-lib
cd ~/ros2_ws && colcon build --packages-up-to uav_nav_bringup drone_pose

In simulation, each in its own terminal (source ~/ros2_ws/install/setup.bash, export RMW_IMPLEMENTATION=rmw_zenoh_cpp):

ros2 run rmw_zenoh_cpp rmw_zenohd
PX4_GZ_WORLD=obstacle_course uav_nav_bringup/sim/run_px4_sitl.sh
ros2 launch uav_nav_bringup bringup.launch.py use_sim_time:=true auto_arm:=true gz_bridge:=true rviz:=true

The drone arms and takes off by itself; then send a goal with RViz's 2D Goal Pose, or:

ros2 action send_goal /navigate_to_pose nav2_msgs/action/NavigateToPose "{pose: {header: {frame_id: map}, pose: {position: {x: 0.0, y: -8.0, z: 2.0}}}}" --feedback

Other worlds (recovery_course, mixed_field), the real-drone setup and every launch argument are in the bringup README.

Limitations

  • Unknown space is free for the planner: only what the sensors have mapped is planned around. The controller keeps the drone able to stop in seen space, so it crawls (about 0.6 m/s, 1 m/s on steep climbs) where a path leads into space nothing has seen yet.
  • Fresh obstacles close in front: when something appears right in front of the drone (a sliding door closing), the space under it now counts as unseen until the sensors see through it. The SITL door runs never reproduced the old duck-under, with or without it, so the fix is checked by unit tests only.
  • Below the lidar: to the sides and behind (the depth camera covers the front), a person closer than about 2 m is below the lidar's ±15° view and is followed by prediction only.
  • Flying objects: a moving object keeps its own height only once the lidar has seen the space under it empty on 3 scans in a row; until then its box reaches the ground.
  • Measured in simulation: every number in these READMEs comes from PX4 SITL; the depth camera has not been tried on real hardware yet.

Each package's README lists its own known issues.

About

ROS 2 navigation stack for PX4 drones: lidar voxel map (Bonxai), moving-object tracking, A* + Informed-RRT* planning, behavior-tree navigator with 3D recoveries

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages