This repository provides a streamlined devcontainer to perform waypoint nagivation of quadcopters in ROS2, Gazebo and PX4.
- ROS2 Humble
- Gazebo Harmonic
- PX4
- QGroundControl
First, clone the project:
git clone https://github.com/Srindot/assignment2_Introduction_To_UAV_Design.gitEnsure Docker is installed and configured on your device.
- Launch Visual Studio Code (VS Code) .
- Open the cloned project folder.
For arch:
sudo pacman -S xorg-xhostFor Ubuntu:
sudo apt update && sudo apt install x11-xserver-utilsIf your host system doesn't have a Nvidia Card, remove the instance of gpus in devcontainer and you can ignore the below instruction to download Nvidia Container Toolkit. (Follow the comments in the devcontainer file)
For Arch:
sudo pacman -S nvidia-container-toolkitand restart the docker daemon
sudo systemctl restart dockerFor Ubuntu: Set up the Repository
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.listThen install the nvidia-contianer-toolkit
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkitAfter this restart the docker daemon:
sudo systemctl restart docker-
Press
Ctrl + Shift + Pto open the Command Palette . -
Search for "Dev Conatiners: Reopen in Container" and select it to start building the container and after a while it will ask for your platform(Linux, WSL, and Macos) choose accordingly.
This will take a long time, it will pull the image from the github container registry and to open it.
- After this, make sure to choose the terminal profile in vscode to be
bash. You can do this in the command pallete in github, search for terminal profile and selectbash.
-
Once inside the container, press
Ctrl + Shift + Pagain. -
Search for "Run Tasks" , then select and execute the following tasks :
- MicroXRCEAgent : Connection to ROS2 and PX4
- PX4 SITL : To start up PX4 with gazebo gui
- QGroundControl : To launch QGroundControl
- Sensor Combined Listener : To echo gyro readings and acceleration in all three axis
- Offboard Control : To arm the vehicle and publish waypoint for quadcopter to track
First pull the image: Open a terminal and run the following command
docker pull ghcr.io/srindot/rosgzpx4This is going to take some time.
Create a container instance from the pulled image refer to this repo for instructions
To run the simulator follow below steps.
- To launch MicroXRCEAgent: Navigate to a new terminal and run the below command to launch it
MicroXRCEAgent udp4 -p 8888- To make PX4_sitl, open another terminal and navigate to PX4-Autopilot dir
cd ~/PX4-AutopilotMake the PX4_sitl and launch the vehicle gz_x500
make px4_sitl gz_x500- To launch QGroundControl, Open another terminal and run the following command
QGroudControl- open a new terminal and source ros2 and local_setup.bash in sensor combined workspace
cd ~/ws_sensor_combined && source /opt/ros/humble/setup.bash && source install/local_setup.bashand run the below command to run the sensor combined listener
ros2 launch px4_ros_com sensor_combined_listener.launch.py- To arm the vehicle and switch it to offoard mode, open a new temrinal source ros2 and local setup by runnig below the command
cd ~/ws_offboard_control/src && cd .. && source /opt/ros/humble/setup.bash && source install/local_setup.bashNow run the offboard_control.py file present in the dir
cd && python3 ~/workspace/offboard_control.pyTo set the waypoint for the quadcopter to navigate, go to here and set the waypoints in the list.
If you encounter any problems or have questions, feel free to raise an issue.




