This project aims to develop a UAV system capable of approaching, detecting, identifying, and mapping Precariously Balanced Rocks (PBRs) using advanced exploration algorithms. The mapping process is divided into three main stages:
- Approach Stage: The UAV plans and follows a path to the PBR using the Fast Planner algorithm.
- Detection and Identification Stage: The UAV detects rocks using YOLOv8 and identifies the target PBR with a recognition algorithm.
- Mapping Stage: The UAV maps the identified PBR using the FUEL exploration algorithm and RTAB-Map.
- PX4_msgs: installation instructions below
- Fast Planner: Path planning algorithm.
- YOLOv8: Object detection algorithm.
- FUEL: Fast UAV Exploration Algorithm.
- RTAB-Map: Simultaneous localization and mapping library.
- ROS Noetic: Used for running ROS1 packages.
- ROS2 Humble: Used for running ROS2 packages.
Follow these steps to install Docker on your Ubuntu system:
-
Remove any old versions of Docker:
sudo apt-get remove docker docker-engine docker.io containerd runc
-
Update your package list:
sudo apt-get update
-
Install required packages:
sudo apt-get install \ ca-certificates \ curl \ gnupg \ lsb-release -
Add Docker’s official GPG key:
sudo mkdir -p /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg -
Set up the Docker repository:
echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
-
Update your package list again:
sudo apt-get update
-
Install Docker:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
-
Verify Docker installation and version (make sure the version is 27.0.3):
sudo docker --version
To build the Docker image for this project, follow these steps:
-
Clone the Git repository:
git clone repository_url
-
Navigate to the cloned repository:
cd repository_name -
Build the Docker image:
sudo docker build -t your_image_name .
Follow instructions on YOLOv7 Github page: https://github.com/WongKinYiu/yolov7
- Run Micro XRCE-DDS Agent
- Run PX4 Autopilot with Gazebo
- Run Gazebo Bridges
3.1. Run the Clock Bridge
3.2. Run the Camera Bridge - Run YOLOv7
4.1. Run YOLOv7 ROS Node
4.2. Run ros_iou_tracking Node - Run ROS1-ROS2 Bridge
- Running the FUEL-Based Exploration Algorithm
- Run the packages
7.1. Build and launch the perception node
7.2. Build and run the image node
7.3. Build and run the state_machine node
7.4. Build and run the position_control node
7.5. Build and run the velocity control node
7.6. Run rtabmap
The Micro XRCE-DDS Agent allows PX4 to communicate with ROS 2 over DDS.
cd Micro-XRCE-DDS-Agent
MicroXRCEAgent udp4 -p 8888Open another terminal and start PX4 SITL with Gazebo:
```bash
cd PX4-Autopilot/
make px4_sitl gz_x500
```
To run with your own model:
```bash
cd .gz
mkdir models
cd models
mkdir model_name
```
Run the commands above and place model.sdf, model.config, and meshes file.
Now run
```bash
cd PX4-Autopilot/Tool/simulation/gz/worlds
```
and create a new world.config file under the directory that contains your new model.
Afterwards,
```bash
export GZ_SIM_RESOURCE_PATH="$pwd/.gz/models"
PX4_GZ_WORLD=model_name make px4_sitl gz_x500_depth
```
Run ROS 2 bridges to connect ROS topics with Gazebo simulation.
cd ros2_ws/
source install/setup.bash
ros2 run ros_gz_bridge parameter_bridge /clock@rosgraph_msgs/msg/Clock[gz.msgs.Clockcd ros2_ws/
source install/setup.bash
ros2 run ros_gz_image image_bridge /camera /depth_cameraIf the bridge doesn't work, try the following:
export GZ_VERSION=harmonic
colcon buildALTERNATIVELY:
Install and run ROS-gazebo bridge
```bash
sudo apt-get install ros-humble-ros-gzgarden
ros2 run ros_gz_image image_bridge /camera /depth_camera
ros2 run ros_gz_bridge parameter_bridge /clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock
```
Replace with your version of ROS and Gazebo. Tested on ROS Humble and Gazebo Garden.
To run YOLOv7 ROS node, first make a new workspace and copy contents of yolov7_ws:
```bash
cd
mkdir yolov7_ws
cd yolov7_ws
git clone https://github.com/yunhajo03/yolov7-ros.git
```
Next, launch yolov7:
bash cd ros2_ws/src/yolov7_ros/ source install/setup.bash ros2 launch yolov7_ros yolov7.launch
Parameters can be modified in launch/yolov7.launch file.
cd ros2_ws/
git clone --branch ros2 https://github.com/yunhajo03/ros_iou_tracking.git
source install/setup.bash
ros2 run ros_iou_tracking iou_trackerOpen a new terminal and run the ROS1-ROS2 bridge:
```bash
source /opt/ros/humble/setup.bash
source ~/ros-humble-ros1-bridge/install/local_setup.bash
ros2 run ros1_bridge dynamic_bridge
```
To run the Docker container, use the following commands:
-
Run the Docker container:
xhost +local:docker docker run -it --rm \ -e DISPLAY=$DISPLAY \ -e LIBGL_ALWAYS_SOFTWARE=1 \ -v /tmp/.X11-unix:/tmp/.X11-unix \ --network=host \ your_image_name -
Inside the Docker container, start
roscore:roscore
-
Open a new terminal and run the ROS1-ROS2 bridge:
source /opt/ros/humble/setup.bash source ~/ros-humble-ros1-bridge/install/local_setup.bash ros2 run ros1_bridge dynamic_bridge
-
Get the Docker container name:
docker ps
-
Execute the exploration manager commands in the Docker container:
docker exec -it <container_name> bash source devel/setup.bash && roslaunch exploration_manager rviz.launch
-
Run the exploration launch file:
docker exec -it <container_name> bash source devel/setup.bash && roslaunch exploration_manager exploration.launch
Following packages are all packages under augmented_mapping folder. They should be cloned from Github and placed into ros2_ws/src folder.
```bash
cd ros2_ws/src
git clone https://github.com/PX4/px4_msgs
cd ros2_ws
source /opt/ros/humble/setup.bash
colcon build
source install/local_setup.bash
ros2 launch perception perception_launch.py
```
```bash
cd ros2_ws/src
git clone https://github.com/PX4/px4_msgs
cd ros2_ws
source /opt/ros/humble/setup.bash
colcon build
source install/local_setup.bash
ros2 run image image_bbox_node
```
```bash
cd ros2_ws
source /opt/ros/humble/setup.bash
colcon build
source install/local_setup.bash
ros2 run state_machine state_machine_node
```
```bash
cd ros2_ws
source /opt/ros/humble/setup.bash
colcon build
source install/local_setup.bash
ros2 run position_control position_control_final
```
```bash
cd ros2_ws
source /opt/ros/humble/setup.bash
colcon build
source install/local_setup.bash
ros2 run velocity_control velocity_fuel_node
```
Note:
Theposition_controlandvelocity_controlnodes both publish to/fmu/in/vehicle_command, which causes interference.
Therefore, do not run both nodes simultaneously to avoid conflicts.
```bash
sudo apt update
sudo apt install ros-humble-rtabmap
```
```bash
ros2 launch rtabmap_launch rtabmap.launch.py \
frame_id:=x500_depth_0/OakD-Lite/base_link/IMX214 \
args:="-d" \
use_sim_time:=true \
rgb_topic:=/camera \
depth_topic:=/depth_camera \
camera_info_topic:=/camera_info \
approx_sync:=true \
qos:=2
```
- Map Size: Adjust
map_size_x,map_size_y, andmap_size_zto match your simulation environment's dimensions. - Bounding Box: Set
box_min_x,box_min_y,box_min_z,box_max_x,box_max_y, andbox_max_zto define the operational area within the map. Ensure these values are smaller than the map size to prevent errors. - Note about bounding box: UAV will only explore the space defined by the bouding box. It is recommended that the map size is set much larger than the bounding box, as setting the map size close to bounding box often results in
These parameters are located in FUEL/fuel_planner/exploration_manager/launch/exploration.launch.
- Camera Parameters: Tune
Cx,Cy,Fx, andFyaccording to the X_500 depth camera specifications used in your Gazebo simulation to achieve accurate depth perception.
Camera calibration settings can also be found in FUEL/fuel_planner/exploration_manager/launch/exploration.launch.
- Velocity and Acceleration: Set
max_velandmax_accto 0.4 for steady and controlled UAV movement.
The motion control parameters are located in FUEL/fuel_planner/exploration_manager/launch/exploration.launch.
- Depth Scaling Factor: Use a
k_depth_scaling_factorof 3431.15 inAlgorithm.xmlto scale pixel values accurately. Alternatively, a value of 1000.0 can be used.
The Algorithm.xml file is located in FUEL/fuel_planner/exploration_manager/launch.
- Yaw Acceleration (ydd_): Limit the yaw acceleration to avoid sudden changes.
- Optimization Weights (w_dir_): Increase this value to reduce sharp yaw changes.
- Relaxation Time: Use a higher
relax_timeto achieve smoother yaw transitions. - Position Trajectory Duration (yd_): Adjust to set the minimum duration for position trajectories.
The following values have been determined to provide the best results for our simulation:
- exploration/yd: 50
- exploration/ydd: 55
- exploration/w_dir: 2.5
- exploration/relax_time: 2.0
These settings help minimize abrupt yaw changes while maintaining efficient exploration times. Be cautious not to reduce yaw rates excessively, as this may lead to FUEL exploration failures.
PID controllers are used to maintain precise control over the UAV's velocity in various directions. The parameters for these controllers are as follows:
- PID for X-axis (self.pid_x = PID(2.0, 0.1, 0.0))
- PID for Y-axis (self.pid_y = PID(0.8, 0.1, 0.0))
- PID for Z-axis (self.pid_z = PID(0.8, 0.1, 0.0))
- PID for Yaw (self.pid_yaw = PID(2.0, 0.1, 0.0))
- Proportional (P): This term responds to the current error. Increasing the P value typically results in a faster response but can cause overshoot or oscillations if set too high.
- Integral (I): This term responds to accumulated errors over time. It helps eliminate steady-state errors. If the I value is too high, it can cause the system to be slow or oscillate.
- Derivative (D): This term responds to the rate of change of the error, providing a damping effect. It can help stabilize the system but may lead to instability if set too high.
Carefully tuning these parameters will help achieve smooth and accurate UAV operation in your Gazebo simulations. Adjust settings as needed to fit specific simulation requirements or environments.
If FUEL package fails with error "No coverable frontiers" when triggered, then modify parameters in file fuel_planner/exploration_manager/launch/exploration.launch. Box_min_x, box_min_y, Box_min_z, Box_max_x, Box_max_y, Box_max_z values need to be changed.