{"id":13743862,"url":"https://github.com/PX4/PX4-Avoidance","last_synced_at":"2025-05-09T02:31:36.859Z","repository":{"id":38370231,"uuid":"57048600","full_name":"PX4/PX4-Avoidance","owner":"PX4","description":"PX4 avoidance ROS node for obstacle detection and avoidance.","archived":true,"fork":false,"pushed_at":"2024-04-10T16:01:50.000Z","size":6137,"stargazers_count":639,"open_issues_count":101,"forks_count":333,"subscribers_count":37,"default_branch":"master","last_synced_at":"2024-11-15T15:40:57.015Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://px4.io","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PX4.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-25T14:30:01.000Z","updated_at":"2024-11-12T01:54:30.000Z","dependencies_parsed_at":"2022-07-12T17:28:07.988Z","dependency_job_id":"595c0685-79b1-43c5-88bd-a756e048dabf","html_url":"https://github.com/PX4/PX4-Avoidance","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PX4%2FPX4-Avoidance","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PX4%2FPX4-Avoidance/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PX4%2FPX4-Avoidance/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PX4%2FPX4-Avoidance/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PX4","download_url":"https://codeload.github.com/PX4/PX4-Avoidance/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253177726,"owners_count":21866388,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T05:00:58.571Z","updated_at":"2025-05-09T02:31:36.450Z","avatar_url":"https://github.com/PX4.png","language":"C++","funding_links":[],"categories":["C++","Frameworks \u0026 Libraries"],"sub_categories":[],"readme":"# Obstacle Detection and Avoidance\n\n**Warning:** This project is currently not maintained.\n\u003e We'd welcome community support to maintain and update the project.\n\u003e If you're interested in contributing, please contact the [PX4 development team through normal channels](http://docs.px4.io/main/en/contribute/support.html#forums-and-chat).\n\n\n[![Release Status](https://img.shields.io/github/v/release/PX4/avoidance)](https://github.com/PX4/avoidance/releases)\n[![Build and Unit Test](https://github.com/PX4/PX4-Avoidance/workflows/Build%20and%20Unit%20Test/badge.svg)](https://github.com/PX4/PX4-Avoidance/actions)\n[![Coverage Status](https://coveralls.io/repos/github/PX4/avoidance/badge.svg)](https://coveralls.io/github/PX4/avoidance)\n\nPX4 computer vision algorithms packaged as ROS nodes for depth sensor fusion and obstacle avoidance.\nThis repository contains three different implementations:\n\n  * *local_planner* is a local VFH+* based planner that plans (including some history) in a vector field histogram\n  * *global_planner* is a global, graph based planner that plans in a traditional octomap occupancy grid\n  * *safe_landing_planner* is a local planner to find safe area to land\n\nThe three algorithms are standalone and they are not meant to be used together.\n\nThe *local_planner* requires less computational power but it doesn't compute optimal paths towards the goal since it doesn't store information about the already explored environment. An in-depth discussion on how it works can be found in [this thesis](https://drive.google.com/file/d/1EhjTvv1QyUxfdnQnBQcPc-T3Zg3OMnlD/edit). On the other hand, the *global_planner* is computationally more expensive since it builds a map of the environment. For the map to be good enough for navigation, accurate global position and heading are required. An in-depth discussion on how it works can be found in [this thesis](https://drive.google.com/file/d/1hZBBV6zNEpX1OYv_-U6flbC2gmNjqy-L/).\nThe *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.\n\n\u003e **Note** The most developed and used planner is the *local_planner*. This is where you should start.\n\nThe documentation contains information about how to setup and run the two planner systems on the Gazebo simulator and on a companion computer running Ubuntu 20.04 (recommended), for both avoidance and collision prevention use cases.\n\n\u003e **Note** PX4-side setup is covered in the PX4 User Guide:\n  - [Obstacle Avoidance](https://docs.px4.io/en/computer_vision/obstacle_avoidance.html)\n  - [Collision Prevention](https://docs.px4.io/en/computer_vision/collision_prevention.html)\n\n[![PX4 Avoidance video](http://img.youtube.com/vi/VqZkAWSl_U0/0.jpg)](https://www.youtube.com/watch?v=VqZkAWSl_U0)\n\n# Table of Contents\n- [Getting Started](#getting-started)\n  - [Installation](#installation)\n    - [Installation for Ubuntu](#installation)\n  - [Run the Avoidance Gazebo Simulation](#run-the-avoidance-gazebosimulation)\n    - [Local Planner](#local-planner)\n    - [Global Planner](#global-planner)\n    - [Safe Landing Planner](#safe-landing-planner)\n  - [Run on Hardware](#run-on-hardware)\n    - [Prerequisite](#prerequisite)\n    - [Local Planner](#local-planner)\n    - [Global Planner](#global-planner)\n- [Troubleshooting](#troubleshooting)\n- [Advanced](#advanced)\n  - [Message Flows](#message-flow)\n    - [PX4 and local planner](#px4-and-local-planner)\n    - [PX4 and global planner](#px4-and-global-planner)\n- [Contributing](#contributing)\n\n# Getting Started\n\n## Installation\n\n### Installation\n\nThis is a step-by-step guide to install and build all the prerequisites for running the avoidance module on **Ubuntu 20.04** with *ROS Noetic* (includes Gazebo 11).\nYou might want to skip some steps if your system is already partially installed.\n\n\u003e **Note:** These instructions assume your catkin workspace (in which we will build the avoidance module) is in `~/catkin_ws`, and the PX4 Firmware directory is `~/Firmware`.\n  Feel free to adapt this to your situation.\n\n1. Add ROS to sources.list:\n     ```bash\n     sudo sh -c 'echo \"deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main\" \u003e /etc/apt/sources.list.d/ros-latest.list'\n     sudo apt install curl\n     curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -\n     sudo apt update\n     ```\n\n1. Install ROS with Gazebo:\n     ```bash\n     sudo apt install ros-noetic-desktop-full\n\n     # Source ROS\n     echo \"source /opt/ros/noetic/setup.bash\" \u003e\u003e ~/.bashrc\n     source ~/.bashrc\n     ```\n   \u003e **Note** We recommend you use the version of Gazebo that comes with your (full) installation of ROS.\n   \u003e  If you must to use another Gazebo version, remember to install associated ros-gazebo related packages:\n   \u003e  - For Gazebo 8,\n       ```\n       sudo apt install ros-noetic-gazebo8-*\n       ```\n    \u003e - For Gazebo 9,\n       ```\n       sudo apt install ros-noetic-gazebo9-*\n       ```\n\n1. Dependencies for building packages\n   ```bash\n   sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential\n   ```\n\n1. Install and initialize rosdep.\n   ```bash\n   rosdep init\n   rosdep update\n   ```\n\n1. Install catkin and create your catkin workspace directory.\n\n   ```bash\n   sudo apt install python3-catkin-tools\n   mkdir -p ~/catkin_ws/src\n   ```\n\n1. Install MAVROS (version 0.29.0 or above).\n   \u003e **Note:** Instructions to install MAVROS from sources can be found [here](https://dev.px4.io/en/ros/mavros_installation.html).\n\n     ```bash\n     sudo apt install ros-noetic-mavros ros-noetic-mavros-extras\n     ```\n\n1. Install the *geographiclib* dataset\n\n   ```bash\n   wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh\n   chmod +x install_geographiclib_datasets.sh\n   sudo ./install_geographiclib_datasets.sh\n   ```\n\n1. Install avoidance module dependencies (pointcloud library and octomap).\n     ```bash\n     sudo apt install libpcl1 ros-noetic-octomap-*\n     ```\n\n1. Clone this repository in your catkin workspace in order to build the avoidance node.\n   ```bash\n   cd ~/catkin_ws/src\n   git clone https://github.com/PX4/avoidance.git\n   ```\n\n1. Actually build the avoidance node.\n\n   ```bash\n   catkin build -w ~/catkin_ws\n   ```\n\n   Note that you can build the node in release mode this way:\n\n   ```bash\n   catkin build -w ~/catkin_ws --cmake-args -DCMAKE_BUILD_TYPE=Release\n   ```\n\n1. Source the catkin setup.bash from your catkin workspace:\n   ```bash   \n   echo \"source ~/catkin_ws/devel/setup.bash\" \u003e\u003e ~/.bashrc\n   source ~/.bashrc\n   ```\n\n## Run the Avoidance Gazebo Simulation\n\nIn the following section we guide you through installing and running a Gazebo simulation of both local and global planner.\n\n### Build and Run the Simulator\n\n1. Clone the PX4 Firmware and all its submodules (it may take some time).\n\n   ```bash\n   cd ~\n   git clone https://github.com/PX4/Firmware.git --recursive\n   cd ~/Firmware\n   ```\n\n1. Install [PX4 dependencies](http://dev.px4.io/en/setup/dev_env_linux_ubuntu.html#common-dependencies). \n   ```bash\n   # Install PX4 \"common\" dependencies.\n   ./Tools/setup/ubuntu.sh --no-sim-tools --no-nuttx\n   \n   # Gstreamer plugins (for Gazebo camera)\n   sudo apt install gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly libgstreamer-plugins-base1.0-dev\n\n1. Build the Firmware once in order to generate SDF model files for Gazebo.\n   This step will actually run a simulation (that you can immediately close).\n\n   ```bash\n   # This is necessary to prevent some Qt-related errors (feel free to try to omit it)\n   export QT_X11_NO_MITSHM=1\n\n   # Build and run simulation\n   make px4_sitl_default gazebo\n   \n   # Quit the simulation (Ctrl+C)\n\n   # Setup some more Gazebo-related environment variables (modify this line based on the location of the Firmware folder on your machine)\n   . ~/Firmware/Tools/simulation/gazebo-classic/setup_gazebo.bash ~/Firmware ~/Firmware/build/px4_sitl_default\n   ```\n\n1. Add the Firmware directory to ROS_PACKAGE_PATH so that ROS can start PX4:\n   ```bash\n   export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:~/Firmware\n   ```\n1. Finally, set the GAZEBO_MODEL_PATH in your bashrc:\n   ```bash\n   echo \"export GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:~/catkin_ws/src/avoidance/avoidance/sim/models:~/catkin_ws/src/avoidance/avoidance/sim/worlds\" \u003e\u003e ~/.bashrc\n   ```\n\nThe 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.\n\n**OR** you can ensure your ~/.bashrc is setup correctly so that each new terminal is sourced correctly.  \n\n```bash\nsudo nano ~/.bashrc\n```\nEnsure that at the bottom of that document you have exactly this:\n```bash\nsource /opt/ros/noetic/setup.bash\nsource ~/catkin_ws/devel/setup.bash\n. ~/Firmware/Tools/simulation/gazebo-classic/setup_gazebo.bash ~/Firmware ~/Firmware/build/px4_sitl_default\nexport GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:~/catkin_ws/src/avoidance/avoidance/sim/models:~/catkin_ws/src/avoidance/avoidance/sim/worlds\nexport ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:~/Firmware\n```\n\nYou should now be ready to run the simulation using local or global planner.\n\n### Local Planner (default, heavily flight tested)\n\nThis section shows how to start the *local_planner* and use it for avoidance in mission or offboard mode.\n\nThe planner is based on the [3DVFH+](http://ceur-ws.org/Vol-1319/morse14_paper_08.pdf) algorithm.\n\n\u003e **Note:** You *may* need to install some additional dependencies to run the following code (if not installed):\n\u003e   ```sh\n\u003e   sudo apt install ros-noetic-stereo-image-proc ros-noetic-image-view\n\u003e   ```\n\nAny of the following three launch file scripts can be used to run local planner:\n\u003e **Note:** The scripts run the same planner but simulate different sensor/camera setups. They all enable *Obstacle Avoidance* and *Collision Prevention*.\n* `local_planner_stereo`: simulates a vehicle with a stereo camera that uses OpenCV's block matching algorithm (SGBM by default) to generate depth information\n  ```bash\n  roslaunch local_planner local_planner_stereo.launch\n  ```\n    \n  \u003e **Note:** The disparity map from `stereo-image-proc` is published as a [stereo_msgs/DisparityImage](http://docs.ros.org/api/stereo_msgs/html/msg/DisparityImage.html) message, which is not supported by rviz or rqt. \n  \u003e To visualize the message, first open a *new terminal* and setup the required environment variables:\n  \u003e ```bash\n  \u003e source devel/setup.bash\n  \u003e ```\n  \u003e Then do either of:\n  \u003e - run:\n  \u003e   ```bash\n  \u003e   rosrun image_view stereo_view stereo:=/stereo image:=image_rect_color\n  \u003e   ```\n  \u003e - publish the `DisparityImage` as a simple `sensor_msgs/Image`:\n  \u003e   ```bash\n  \u003e   rosrun topic_tools transform /stereo/disparity /stereo/disparity_image sensor_msgs/Image 'm.image' \n  \u003e   ```\n  \u003e The disparity map can then be visualized by *rviz* or *rqt* under the topic */stereo/disparity_image*.\n\n* `local_planner_depth_camera`: simulates vehicle with one forward-facing kinect sensor\n  ```bash\n  roslaunch local_planner local_planner_depth-camera.launch\n  ```\n\n* `local_planner_sitl_3cam`: simulates vehicle with 3 kinect sensors (left, right, front)\n  ```bash\n  roslaunch local_planner local_planner_sitl_3cam.launch\n  ```\n\nYou will see the Iris drone unarmed in the Gazebo world.\nTo start flying, there are two options: OFFBOARD or MISSION mode.\nFor OFFBOARD, run:\n\n```bash\n# In another terminal \nrosrun mavros mavsys mode -c OFFBOARD\nrosrun mavros mavsafety arm\n```\n\nThe drone will first change its altitude to reach the goal height.\nIt is possible to modify the goal altitude with `rqt_reconfigure` GUI.\n![Screenshot rqt_reconfigure goal height](docs/lp_goal_height.png)\nThen the drone will start moving towards the goal.\nThe default x, y goal position can be changed in Rviz by clicking on the 2D Nav Goal button and then choosing the new goal x and y position by clicking on the visualized gray space.\nIf the goal has been set correctly, a yellow sphere will appear where you have clicked in the grey world.\n![Screenshot rviz goal selection](docs/lp_goal_rviz.png)\n\nFor MISSIONS, open [QGroundControl](http://qgroundcontrol.com/) and plan a mission as described [here](https://docs.px4.io/en/flight_modes/mission.html). Set the parameter `COM_OBS_AVOID` true.\nStart the mission and the vehicle will fly the mission waypoints dynamically recomputing the path such that it is collision free.\n\n\n### Global Planner (advanced, not flight tested)\n\nThis section shows how to start the *global_planner* and use it for avoidance in offboard mode.\n\n```bash\nroslaunch global_planner global_planner_stereo.launch\n```\n\nYou should now see the drone unarmed on the ground in a forest environment as pictured below.\n\n![Screenshot showing gazebo and rviz](docs/simulation_screenshot.png)\n\nTo start flying, put the drone in OFFBOARD mode and arm it. The avoidance node will then take control of it.\n\n```bash\n# In another terminal\nrosrun mavros mavsys mode -c OFFBOARD\nrosrun mavros mavsafety arm\n```\n\nInitially the drone should just hover at 3.5m altitude.\n\nFrom the command line, you can also make Gazebo follow the drone, if you want.\n\n```bash\ngz camera --camera-name=gzclient_camera --follow=iris\n```\n\nOne can plan a new path by setting a new goal with the *2D Nav Goal* button in rviz.\nThe planned path should show up in rviz and the drone should follow the path, updating it when obstacles are detected.\nIt is also possible to set a goal without using the obstacle avoidance (i.e. the drone will go straight to this goal and potentially collide with obstacles). To do so, set the position with the *2D Pose Estimate* button in rviz.\n\n\n### Safe Landing Planner\n\nThis 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:\n\n```bash\nroslaunch safe_landing_planner safe_landing_planner.launch\n```\n\nYou will see an unarmed vehicle on the ground. Open [QGroundControl](http://qgroundcontrol.com/), 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.\nAt 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.\nIf 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.\n\n# Run on Hardware\n\n## Prerequisite\n\n### Camera\n\nBoth planners require a 3D point cloud of type `sensor_msgs::PointCloud2`. Any camera that can provide such data is compatible.\n\nThe 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](https://www.intel.com/content/www/us/en/support/articles/000028171/emerging-technologies/intel-realsense-technology.html)\n\n\u003e **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.\n\nOther tested camera models are: Intel Realsense D415 and R200, Occipital Structure Core.\n\n#### Generating Point-clouds from Depth-maps\n\nIn case the point-cloud stream already exists, this step can be skipped.\n\nAssuming there already exists a stream of depth-maps on the ROS-topic \u003cdepthmap_topic\u003e, we need to generate a corresponding stream of depth-maps.\nStart by following the instructions from [PX4/disparity_to_point_cloud](https://github.com/PX4/disparity_to_point_cloud).\nNow run the point-cloud generation with the parameters for the camera intrinsics:\n\n```bash\nrosrun disparity_to_point_cloud disparity_to_point_cloud_node \\\n    fx_:=fx fy_:=fy cx_:=cx cy_:=cy base_line_:=base_line disparity:=\u003cdepthmap_topic\u003e\n```\n\nA stream of point-clouds should now be published to */point_cloud*.\n\n### PX4 Autopilot\n\nParameters to set through QGC:\n* `COM_OBS_AVOID` to Enabled\n* `MAV_1_CONFIG`, `MAV_1_MODE`, `SER_TEL2_BAUD` to enable MAVLink on a serial port. For more information: [PX4 Dev Guide](http://dev.px4.io/en/companion_computer/pixhawk_companion.html#pixhawk-setup)\n\n### Companion Computer\n\n* OS: Ubuntu 20.04 OS or a docker container running Ubuntu 20.04 must be setup (e.g. if using on a Yocto based system).\n* ROS Noetic: see [Installation](#installation)\n* Other Required Components for Intel Realsense:\n  - Librealsense (Realsense SDK). The installation instructions can be found [here](https://github.com/IntelRealSense/librealsense/blob/master/doc/installation.md)\n  - [Librealsense ROS wrappers](https://github.com/intel-ros/realsense.git)\n* Other Required Components for Occipital Structure Core:\n  - Download the [Structure SDK](https://structure.io/developers). The version tested with this package is `0.7.1`. Create the `build` directory and build the SDK\n  ```bash\n  mkdir build\n  cd build\n  cmake ..\n  make\n  ```\n  - Clone the [ROS wrapper](https://github.com/Auterion/struct_core_ros) in the `catkin_ws`\n  - Copy the shared object `Libraries/Structure/Linux/x86_64/libStructure.so` from the SDK into `/usr/local/lib/`\n  - Copy the headers from `Libraries/Structure/Headers/` in the SDK to the ROS wrapper include directory `~/catkin_ws/src/struct_core_ros/include`\n\nTested models:\n- local planner: Intel NUC, Jetson TX2, Intel Atom x7-Z8750 (built-in on Intel Aero RTF drone)\n- global planner: Odroid\n\n## Global Planner\n\nThe global planner has been so far tested on a Odroid companion computer by the development team.\n\n## Local Planner\n\nOnce the catkin workspace has been built, to run the planner with a Realsense D435 or Occipital Structure Core camera you can generate the launch file using the script *generate_launchfile.sh*\n\n1. `export CAMERA_CONFIGS=\"camera_namespace, camera_type, serial_n, tf_x, tf_y, tf_z, tf_yaw, tf_pitch, tf_roll\"` where  `camera_type` is either `realsense` or `struct_core_ros`, `tf_*` represents the displacement between the camera and the flight controller. If more than one camera is present, list the different camera configuration separated by a semicolon. Within each camera configuration the parameters are separated by commas.\n2. `export DEPTH_CAMERA_FRAME_RATE=frame_rate`. If this variable isn't set, the default frame rate will be taken.\n3. `export VEHICLE_CONFIG=/path/to/params.yaml` where the yaml file contains the value of some parameters different from the defaults set in the cfg file. If this variable isn't set, the default parameters values will be used.\n\nChanging the serial number and `DEPTH_CAMERA_FRAME_RATE` don't have any effect on the Structure Core.\n\nFor example:\n```bash\nexport CAMERA_CONFIGS=\"camera_main,realsense,819612070807,0.3,0.32,-0.11,0,0,0\"\nexport DEPTH_CAMERA_FRAME_RATE=30\nexport VEHICLE_CONFIG=~/catkin_ws/src/avoidance/local_planner/cfg/params_vehicle_1.yaml\n./tools/generate_launchfile.sh\nroslaunch local_planner avoidance.launch fcu_url:=/dev/ttyACM0:57600\n```\n\nwhere `fcu_url` representing the port connecting the companion computer to the flight controller.\nThe planner is running correctly if the rate of the processed point cloud is around 10-20 Hz. To check the rate run:\n\n```bash\nrostopic hz /local_pointcloud\n```\n\nIf you would like to read debug statements on the console, please change `custom_rosconsole.conf` to\n```bash\nlog4j.logger.ros.local_planner=DEBUG\n```\n\n## Safe Landing Planner\n\nOnce the catkin workspace has been built, to run the planner with a Realsense D435 and Occipital Structure Core, you can generate the launch file using the script *generate_launchfile.sh*. The script works the same as described in the section above for the Local Planner. For example:\n\n```bash\nexport CAMERA_CONFIGS=\"camera_main,struct_core,819612070807,0.3,0.32,-0.11,0,0,0\"\nexport VEHICLE_CONFIG_SLP=~/catkin_ws/src/avoidance/safe_landing_planner/cfg/slpn_structure_core.yaml\nexport VEHICLE_CONFIG_WPG=~/catkin_ws/src/avoidance/safe_landing_planner/cfg/wpgn_structure_core.yaml\n./safe_landing_planner/tools/generate_launchfile.sh\nroslaunch safe_landing_planner safe_landing_planner_launch.launch\n```\n\nIn 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.\n\nThe 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).\n\nFor different cameras you might also need to tune the thresholds on the number of points in each bin, standard deviation and mean.\n\n# Troubleshooting\n\n### I see the drone position in rviz (shown as a red arrow), but the world around is empty\nCheck that some camera topics (including */camera/depth/points*) are published with the following command:\n\n```bash\nrostopic list | grep camera\n```\n\nIf */camera/depth/points* is the only one listed, it may be a sign that gazebo is not actually publishing data from the simulated depth camera. Verify this claim by running:\n\n```bash\nrostopic echo /camera/depth/points\n```\n\nWhen everything runs correctly, the previous command should show a lot of unreadable data in the terminal. If you don't receive any message, it probably means that gazebo is not publishing the camera data.\n\nCheck that the clock is being published by Gazebo:\n\n```bash\nrostopic echo /clock\n```\n\nIf it is not, you have a problem with Gazebo (Did it finish loading the world? Do you see the buildings and the drone in the Gazebo UI?). However, if it is publishing the clock, then it might be a problem with the depth camera plugin. Make sure the package `ros-kinetic-gazebo-ros-pkgs` is installed. If not, install it and rebuild the Firmware (with `$ make px4_sitl_default gazebo` as explained above).\n\n### I see the drone and world in rviz, but the drone does not move when I set a new \"2D Nav Goal\"\nIs the drone in OFFBOARD mode? Is it armed and flying?\n\n```bash\n# Set the drone to OFFBOARD mode\nrosrun mavros mavsys mode -c OFFBOARD\n# Arm\nrosrun mavros mavsafety arm\n```\n\n### I see the drone and world in rviz, but the drone does not follow the path properly\nSome tuning may be required in the file *\"\u003cFirmware_dir\u003e/posix-configs/SITL/init/rcS_gazebo_iris\"*.\n\n### I see the drone and world in rviz, I am in OFFBOARD mode, but the planner is still not working\nSome parameters that can be tuned in *rqt reconfigure*.\n\n# Advanced\n\n## Message Flows\n\nMore information about the communication between avoidance system and the Autopilot can be found in the [PX4 User Guide](https://docs.px4.io/en/computer_vision/obstacle_avoidance.html)\n\n### PX4 and local planner\n\nThis is the complete message flow *from* PX4 Firmware to the local planner.\n\nPX4 topic | MAVLink | MAVROS Plugin | ROS Msgs. | ROS Topic\n--- | --- | --- | --- | ---\nvehicle_local_position | LOCAL_POSITION_NED | local_position | geometry_msgs::PoseStamped | mavros/local_position/pose\nvehicle_local_position | LOCAL_POSITION_NED | local_position | geometry_msgs::TwistStamped | mavros/local_position/velocity\nvehicle_local_position | ALTITUDE | altitude | mavros_msgs::Altitude | mavros/altitude\nhome_position | ALTITUDE | altitude | mavros_msgs::Altitude | mavros/altitude\nvehicle_air_data | ALTITUDE | altitude | mavros_msgs::Altitude | mavros/altitude\nvehicle_status | HEARTBEAT | sys_status | mavros_msgs::State | mavros/state\nvehicle_trajectory_waypoint_desired | TRAJECTORY_REPRESENTATION_WAYPOINT | trajectory  | mavros_msgs::Trajectory | mavros/trajectory/desired\n*none* | MAVLINK_MSG_ID_PARAM_REQUEST_LIST | param | mavros_msgs::Param | /mavros/param/param_value\n*none* | MISSION_ITEM | waypoint | mavros_msgs::WaypointList | /mavros/mission/waypoints\n\n\nThis is the complete message flow *to* PX4 Firmware from the local planner.\n\nROS topic | ROS Msgs. | MAVROS Plugin | MAVLink | PX4 Topic\n--- | --- | --- | --- | ---\n/mavros/setpoint_position/local (offboard) | geometry_msgs::PoseStamped | setpoint_position | SET_POSITION_LOCAL_POSITION_NED | position_setpoint_triplet\n/mavros/trajectory/generated (mission) | mavros_msgs::Trajectory | trajectory | TRAJECTORY_REPRESENTATION_WAYPOINT | vehicle_trajectory_waypoint\n/mavros/obstacle/send | sensor_msgs::LaserScan | obstacle_distance | OBSTACLE_DISTANCE | obstacle_distance\n/mavros/companion_process/status | mavros_msgs::CompanionProcessStatus | companion_process_status | HEARTBEAT | telemetry_status\n\n\n### PX4 and global planner\n\nThis is the complete message flow *from* PX4 Firmware *to* the global planner.\n\nPX4 topic | MAVLink | MAVROS Plugin | ROS Msgs. | Topic\n--- | --- | --- | --- | ---\nvehicle_local_position | LOCAL_POSITION_NED | local_position | geometry_msgs::PoseStamped | mavros/local_position/pose\nvehicle_local_position | LOCAL_POSITION_NED | local_position | geometry_msgs::TwistStamped | mavros/local_position/velocity\nvehicle_trajectory_waypoint_desired | TRAJECTORY_REPRESENTATION_WAYPOINT | trajectory  | mavros_msgs::Trajectory | mavros/trajectory/desired\n\nThis is the complete message flow *to* PX4 Firmware *from* the global planner.\n\nROS topic | ROS Msgs. | MAVROS Plugin | MAVLink | PX4 Topic\n--- | --- | --- | --- | ---\n/mavros/setpoint_position/local (offboard) | geometry_msgs::PoseStamped | setpoint_position | SET_POSITION_LOCAL_POSITION_NED | position_setpoint_triplet\n/mavros/trajectory/generated (mission) | mavros_msgs::Trajectory | trajectory | TRAJECTORY_REPRESENTATION_WAYPOINT | vehicle_trajectory_waypoint\n\n### PX4 and safe landing planner\n\nThis is the complete message flow *from* PX4 Firmware to the safe landing planner.\n\nPX4 topic | MAVLink | MAVROS Plugin | ROS Msgs. | ROS Topic\n--- | --- | --- | --- | ---\nvehicle_local_position | LOCAL_POSITION_NED | local_position | geometry_msgs::PoseStamped | mavros/local_position/pose\nvehicle_status | HEARTBEAT | sys_status | mavros_msgs::State | mavros/state\nvehicle_trajectory_waypoint_desired | TRAJECTORY_REPRESENTATION_WAYPOINT | trajectory  | mavros_msgs::Trajectory | mavros/trajectory/desired\n*none* | MAVLINK_MSG_ID_PARAM_REQUEST_LIST | param | mavros_msgs::Param | /mavros/param/param_value\n\nThis is the complete message flow *to* PX4 Firmware from the safe landing planner.\n\nROS topic | ROS Msgs. | MAVROS Plugin | MAVLink | PX4 Topic\n--- | --- | --- | --- | ---\n/mavros/trajectory/generated (mission) | mavros_msgs::Trajectory | trajectory | TRAJECTORY_REPRESENTATION_WAYPOINT | vehicle_trajectory_waypoint\n/mavros/companion_process/status | mavros_msgs::CompanionProcessStatus | companion_process_status | HEARTBEAT | telemetry_status\n\n# Contributing\n\nFork the project and then clone your repository. Create a new branch off of master for your new feature or bug fix.\n\nPlease, take into consideration our [coding style](https://github.com/PX4/avoidance/blob/master/tools/fix_style.sh).\nFor convenience, you can install the commit hooks which will run this formatting on every commit. To do so, run\n`./tools/set_up_commit_hooks` from the main directory.\n\nCommit your changes with informative commit messages, push your branch and open a new pull request. Please provide ROS bags and the Autopilot flight logs relevant to the changes you have made.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPX4%2FPX4-Avoidance","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPX4%2FPX4-Avoidance","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPX4%2FPX4-Avoidance/lists"}