Obstacle avoidance in PX4

PX4 now knows how to avoid obstacles on Intel Aero! The code is here: GitHub - PX4/PX4-Avoidance: PX4 avoidance ROS node for obstacle detection and avoidance.

The documentation is in the repository link above and it only requires a standard Intel Aero.


Great! But why is it restricted to Intel Aero?
Can it be ported to other platforms?

I wouldn’t know since when ROS nodes are limited to specific airframes - so no, it is not limited to Aero. You can use any drone with a suitable depth sensor.

Unfortunately the Intel aero compute board is out-of-stock @Intel online store. So even if we wanted to have collision and avoidance using a RealSense depth sensor, we will likely have to wait. It would be great if the RealSense could be plugged into the Pixhawk in an updated autopilot model.

Has anyone used the obstacle avoidance on hardware other than the Intel Aero? If so, what HW and how?

Hi Jesse,

Yes, The avoidance has been running on multiple of our (custom) frames. We use Intel Realsense D435 and a companion computer on which the algorithm runs. So far the Intel Nuc, TX2, Up core have been tested as companion boards.


1 Like

We will also introduce a racer-size frame shortly which is a lot more compact than Aero and has current realsense and a current Intel CPU.



I want to use Px4 avoidance library on the Intel Aero Ready to Fly Drone.

For that I need to execute only these two commands as it is given in this link https://docs.px4.io/en/complete_vehicles/intel_aero.html#obstacle-avoidance

And set MPC_OBS_AVOID to 1 in QGC.

Thats all?

I want to fly my drone in the mission mode, and the mission will be uploaded from the QGC directly.

First of all you need to set up the companion computer on the Aero. I would recommend to flash a Ubuntu 16.04, but you could also use docker containers (which require a bit more knowledge on how to set up). Then you go into the companion computer via shh and clone the avoidance repository, install ROS and generate a launch file, such that you can launch the local planner node. I would also suggest you run Rviz on your laptop and set ROS_MASTER_URI & ROS_IP such that you can see what is happening on the Aero. I would complete a few benchtests to see if the drone actually recognizes obstacles. After that you can fly just as you described. You upload a regular mission and set MPC_OBS_AVOID to 1.

1 Like


Yes I have installed the ubuntu 16.04 in my companion computer.

How to set ROS_MASTER_URI & ROS_IP in the laptop.

Please update me after your benchtests, so that then I can fly my drone.

Thank you very much for the updates.

@Utkarsh_Goyal you need to set the ROS_IP to the laptop IP. And the ROS_MASTER_URI to the drone IP.
I cannot do the benchtests for you, you need to perform them on your drone, to see if your setup works correctly.

Hello baumanta

Sorry, yes I have only do the benchtests.

Actually I am new to the field of drones, can you please tell me how to do the benchtests.

Is it gazebo that we use for the bench tests.


hi @Utkarsh_Goyal

No, gazbo is a simulator. You use gazebo (most likely) when you run the avoidance SITL on your laptop. PX4 SITL gazebo fakes the drone and firmware basically. Now that you have a drone, you will run PX4 and avoidance on your drone. For the bench tests the only thing you have to do is use you laptop to look inside the drone to see whether everything is running correctly. So you do the following:

  • Either have a external network (router) and connect your drone as well as the laptop to the same network. Or have your drone produce a hotspot and connect your laptop to this hotspot.
  • try to ssh into the drone without a wired connection. If that work you know you can reach your drone over the network.
  • Then do ifconfig on your laptop as well as your drone to find the IP adress of both devices in the current network.
  • On drone: export ROS_MASTER_URI=http://drone-ip:11311 export ROS_IP=drone-ip export ROS_HOSTNAME=drone-ip
  • On laptop: export ROS_MASTER_URI=http://drone-ip:11311 export ROS_IP=laptop-ip
  • try to run rostopic list on you laptop, can you see the topics?
    -On laptop: open Rviz

let me know if that works!


Hello Baumanta

Thank you so much for the quick response.

I will try this and let you know.

Thanks again



I have executed the following command: roslaunch local_planner local_planner_aero.launch

But it is stuck showing: /camera/driver - Setting dynamic camera options

This output means avoidance library is installed in the drone or I have to execute the above command always when i have to fly.

If I have to run this command on the drone always then my drone will not be connected to any screen when I want to fly it, it will be just connected to the laptop which is running Qgroundcontrol.

So how I make sure that px4 avoidance library is build in the drone and avoid the obstacles.


I would suggest you read up a bit about ROS and how it works. Here you can find some information about roslaunch: http://wiki.ros.org/roslaunch

The local_planner is run in a ROS node, which has to be started manually every time before you want to use it. To see whether everything start up correctly I would suggest you open 2 terminals (in both ssh to the drone). In the first you type the roslaunch command. In the second you inspect the rostopics with: rostopic list or rostopic hz /local_pointcloud. If the last command give you a value between 10-20 Hz the system should be up and running on your drone. Then you can proceed with step 3. in the list from before.

Hello Baumanta

I have established the ssh connection between the laptop and drone.

From the laptop I run the command: roslaunch local_planner local_planner_aero.launch
It successfully executes and stops at setting dynamic camera options.

In the next terminal I execute the: rostopic list
After this I can see all the topics.

I also execute the: rostopic hz /local_pointcloud
But after executing this I am just seeing: ‘no new messages’ in loop , not any value.

It means my system is not running properly.
Then what is the problem?

Please Help.


Ok that is a good start. The command roslaunch local_planner local_planner_aero.launch needs to be executed on the drone. You want the avoidance to run on your drone, not your laptop. So you need to open two terminals. Use ssh in both terminals to connect to your drone. In one do roslaunch in the other do the rostopic hz. Do you get about 10-20Hz like this?

Hello Baumanta

In both the terminals I have done the ssh, so I have run the command on the drone itself.

But I haven’t got any value just one message:‘no new messages’, as an output of rostopic hz/local_pointcloud command.

So it means on my drone avoidance library is not running?

Please help



Is there any other method through which I can check that my system is up with avoidance library or not?

I am also attaching the output file of the command roslaunch local_planner local_planner_aero.launch, so that you can check that atleast this command is working fine or not.
Output_File.pdf (16.0 KB)