Repo symbol

real-time-uav-obstacle-avoidance-using-nonlinear-programming repository

intel obstacle-avoidance realsense ros2 px4-autopilot
Repo symbol

real-time-uav-obstacle-avoidance-using-nonlinear-programming repository

intel obstacle-avoidance realsense ros2 px4-autopilot
Repo symbol

real-time-uav-obstacle-avoidance-using-nonlinear-programming repository

intel obstacle-avoidance realsense ros2 px4-autopilot
Repo symbol

real-time-uav-obstacle-avoidance-using-nonlinear-programming repository

intel obstacle-avoidance realsense ros2 px4-autopilot

Repository Summary

Description Real-time obstacle avoidance utilizing the ModalAI Sentinel Drone with the PX4 flight stack and an Intel Realsense D435i .
Checkout URI https://github.com/theunknowninfinite/real-time-uav-obstacle-avoidance-using-nonlinear-programming.git
VCS Type git
VCS Version main
Last Updated 2024-07-07
Dev Status UNKNOWN
Released UNRELEASED
Tags intel obstacle-avoidance realsense ros2 px4-autopilot
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
px4_ros_com 0.1.0
assignment1 0.0.0
trajectory_controller 0.0.0
obstacle_avoidance 0.0.0

README

Real-Time UAV Obstacle Avoidance Using Nonlinear Programming

This project showcases real-time obstacle avoidance in UAVs by utilizing the ModalAI Voxl 2 Sentinel Drone with the PX4 flight stack and an Intel Realsense D435i camera to precisely detect obstacles in its environment. The detected object positions are incorporated as constraints in a non-linear programming-based path planning algorithm, allowing the UAV to autonomously generate safe flight paths with a defined distance threshold around these obstacles. To ensure continuous paths, reference velocities and accelerations are calculated at each waypoint. By accounting for room dimensions and drone dynamics as constraints in the optimizer, these paths ensure efficient and secure navigation, enabling the drone to reach its designated destination accurately and reliably.

PX4 Simulation Codes

This guide provides step-by-step instructions to launch the PX4 simulation, including setting up the necessary environment, starting essential services, and running trajectory and obstacle avoidance scripts.

Setting up the Simulation

Prerequisites

Make sure docker is installed on the host linux pc.

Setting Up Docker Container

  1. Pull the latest ubuntu 22.04 image by
docker pull ubuntu:22.04

  1. Use the Simulation Codes as the mounting point for your docker container so that you can access the files in docker as well as the host. A docker container can be opened by using the script Simulation Codes/run_simclassic_docker.sh . Make sure to edit the script for the right docker image.

The list of docker images on the host can be seen by using docker images.

  1. Run the following commands to install git and PX4 sim.
apt update && apt install git
apt-get install sudo # makes using sudo commands copied from internet easier to run 
git clone https://github.com/PX4/PX4-Autopilot.git -b release/1.14 --recursive
./Tools/setup/ubuntu.sh # this installs prerequisties 
pip uninstall em && pip install empy==3.3.4

  1. To verify the successful installation of the simulator, navigate to the PX4 folder and execute the command make px4_sitl gz_x500_depth. If a window labeled “Gazebo Sim” appears, it indicates that the simulator has been installed correctly. This command will launch the drone in an empty world. To load the drone in a simulated environment, use the command make px4_sitl gz_x500_depth_baylands.

  2. Install ROS2 humble in the docker image by following instructions from ROS Docs

  3. Install the apt version of Gazebo for ROS Humble by following this link.

  4. Make a directory in the root of the workspace and clone ros_gz bridge.

mkdir -p ros2_gzbridge/src
cd ros2_gzbridge/src
git clone https://github.com/gazebosim/ros_gz.git -b humble
export GZ_VERSION=garden

  1. Now go back to the root of the workspace and install dependencies for ros_gz bridge, then execute a colcon build of the same:
cd .. 
rosdep install -r --from-paths src -i -y --rosdistro humble
source /opt/ros/humble/setup.bash
colcon build

  1. Commit the docker container by getting the name of the docker container by running docker ps and then:
docker commit name_of_docker_container name_of_image:version

The name_of_image and version can be any desired names. Once you have specified these, exit the Docker container. This ensures that the terminal used for building is not the same one used for isolating build artifacts.

  1. Run the script to open the docker container again from step 2, with the required edits to change to respective image name and version from step 9. Source the built ros-gz_bridge:
source ros2_gzbridge/install/setup.bash

  1. Make a folder called models and run the script as given below to source gazebo. Make sure to edit the path in the script before it is run.
."/home/s/Downloads/Files/Simulation Codes/set_GZ_SIM_RESOURCE_PATH-2.sh"

  1. Once it is sourced, you can run the command to open the PX4 simulator using the script provided below. This command will launch the simulator:
./Simulation Codes/run_baylands_total-1.sh

QGC can be used to take off and control the drone, which can be downloaded from this link.

Notes

  • It is recommended to create a folder and always start the Docker container from it, as the command to run the container will mount the specific directory where the script is located. Docker containers typically sandbox themselves from the host system.
  • If the PX4 simulator with baylands does not open, try running cd px4-models && python3 simulation-gazebo --world baylands and cd PX4-Autopilot && PX4_GZ_STANDALONE=1 make px4_sitl gz_x500_depth in separate terminals from the root folder of the workspace.

Running the Simulation

Prerequisites

Ensure the following commands are added to your .bashrc file to set up the ROS environment:

source /opt/ros/humble/setup.bash
source /home/root/offboard_ws/install/setup.bash

Reload your .bashrc or source it manually:

source ~/.bashrc

Step-by-Step Instructions

File truncated at 100 lines see the full file

Repo symbol

real-time-uav-obstacle-avoidance-using-nonlinear-programming repository

intel obstacle-avoidance realsense ros2 px4-autopilot
Repo symbol

real-time-uav-obstacle-avoidance-using-nonlinear-programming repository

intel obstacle-avoidance realsense ros2 px4-autopilot
Repo symbol

real-time-uav-obstacle-avoidance-using-nonlinear-programming repository

intel obstacle-avoidance realsense ros2 px4-autopilot
Repo symbol

real-time-uav-obstacle-avoidance-using-nonlinear-programming repository

intel obstacle-avoidance realsense ros2 px4-autopilot