https://github.com/PX4/PX4-Avoidance
ROS node for safe drone landing site detection and waypoint generation.
The safe_landing_planner classifies the terrain underneath the vehicle based on the mean and standard deviation of the z coordinate of pointcloud points. The pointcloud from a downwards facing sensor is binned into a 2D grid based on the xy point coordinates. For each bin, the mean and standard deviation of z coordinate of the points are calculated and they are used to locate flat areas where it is safe to land.
-
Ubuntu 18.04 (Bionic Beaver)
-
ROS Melodic
-
MAVROS
-
Clone and build this repository in your catkin workspace.
cd ~/catkin_ws/src git clone https://github.com/AnujAgrawal7/avoidance.git catkin build source ~/catkin_ws/devel/setup.bash
-
PX4 Firmware (https://github.com/PX4/PX4-Autopilot)
-
Build the Firmware once in order to generate SDF model files for Gazebo. This step will actually run a simulation (that you can immediately close).
# This is necessary to prevent some Qt-related errors (feel free to try to omit it) export QT_X11_NO_MITSHM=1 # Build and run simulation make px4_sitl_default gazebo # Quit the simulation (Ctrl+C) # Setup some more Gazebo-related environment variables (modify this line based on the location of the Firmware folder on your machine) . ~/PX4-Autopilot/Tools/setup_gazebo.bash ~/PX4-Autopilot ~/PX4-Autopilot/build/px4_sitl_default
-
Add the Firmware directory to ROS_PACKAGE_PATH so that ROS can start PX4:
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:~/PX4-Autopilot
-
Finally, set the GAZEBO_MODEL_PATH in your bashrc:
echo "export GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:~/catkin_ws/src/avoidance/avoidance/sim/models:~/catkin_ws/src/avoidance/avoidance/sim/worlds" >> ~/.bashrc
The last three steps, together with sourcing your catkin setup.bash (source ~/catkin_ws/devel/setup.bash
) should be repeated each time a new terminal window is open.
This section shows how to start the safe_landing_planner and use it to land safely in mission or auto land mode. To run the node:
Set the parameter COM_OBS_AVOID
to 1 in QGroundControl.
roslaunch safe_landing_planner safe_landing_planner.launch
You will see an unarmed vehicle on the ground. Open QGroundControl, either plan a mission with the last item of type Land or fly around the world in Position Control, click the Land button on the left side where you wish to land.
At the land position, the vehicle will start to descend towards the ground until it is at loiter_height
from the ground/obstacle. Then it will start loitering to evaluate the ground underneeth.
If the ground is flat, the vehicle will continue landing. Otherwise it will evaluate the close by terrain in a squared spiral pattern until it finds a good enough ground to land on.
The planner require a 3D point cloud of type sensor_msgs::PointCloud2
. Any camera that can provide such data is compatible.
The officially supported camera is Intel Realsense D435. We recommend using Firmware version 5.9.13.0. The instructions on how to update the Firmware of the camera can be found here
Tip: Be careful when attaching the camera with a USB3 cable. USB3 might might interfere with GPS and other signals. If possible, always use USB2 cables.
Other tested camera models are: Intel Realsense D415 and R200, Occipital Structure Core.
Parameters to set through QGC:
COM_OBS_AVOID
to EnabledMAV_1_CONFIG
,MAV_1_MODE
,SER_TEL2_BAUD
to enable MAVLink on a serial port. For more information: PX4 Dev Guide
- OS: Ubuntu 18.04 OS
- ROS Melodic: see Installation
- Other Required Components for Intel Realsense:
- Librealsense (Realsense SDK). The installation instructions can be found here
- Librealsense ROS wrappers
roslaunch safe_landing_planner safe_landing_planner_launch_real_sense.launch
In the cfg/
folder there are camera specific configurations for the algorithm nodes. These parameters can be loaded by specifying the file in the VEHICLE_CONFIG_SLP
and VEHICLE_CONFIG_WPG
system variable for the safe_landing_planner_node and for the waypoint_generator_node respectively.
The size of the squared shape patch of terrain below the vehicle that is evaluated by the algorithm can be changed to suit different vehicle sizes with the WaypointGeneratorNode parameter smoothing_land_cell
. The algorithm behavior will also be affected by the height at which the decision to land or not is taken (loiter_height
parameter in WaypointGeneratorNode) and by the size of neighborhood filter smoothing (smoothing_size
in LandingSiteDetectionNode).
For different cameras you might also need to tune the thresholds on the number of points in each bin, standard deviation and mean.