This repository provides a streamlined platform to perform waypoint tracking in quadcopter in ROS2, Gazebo and PX4.
- ROS2 Humble
- Gazebo Harmonic
- PX4
- QGroundControl
- OffboardControl
First, clone the project using Git:
bash
git clone https://github.com/Srindot/assignment2_Introduction_To_UAV_Design.git
Ensure Docker is installed and configured on your device.
- Launch Visual Studio Code (VS Code) .
- Open the cloned project folder.
-
Press
Ctrl + Shift + P
to open the Command Palette . -
Search for "Dev Conatiners: Reopen in Container" and select it to start building the container.
-
Once inside the container, press
Ctrl + Shift + P
again. -
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/rosgzpx4
This is going to take some time.
Create a container instance from the pulled image with the name as myros:
xhost +local:docker && docker run -it \
--name myros \
--privileged \
--user rosusr \
-e DISPLAY=$DISPLAY \
-e PULSE_SERVER=unix:/run/user/$(id -u)/pulse/native \
--volume=/run/user/$(id -u)/pulse/native:/run/user/$(id -u)/pulse/native \
--device /dev/snd \
--group-add audio \
--net=host \
--volume /tmp/.X11-unix:/tmp/.X11-unix \
--volume /home/$(whoami)/.Xauthority:/root/.Xauthority:ro \
ghcr.io/srindot/rosgzpx4:latest
After this command, the container opens up automatically in /bin/bash.
To exit the container :
exit
To stop the container :
docker stop myros
To start the contianer:
docker start myros
To re enter a container:
docker exec -it myros /bin/bash
To delete the container instance:
docker rm -f myros
- 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-Autopilot
Make 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.bash
and 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.bash
Now run the offboard_control.py file present in the dir
cd && python3 ~/workspace/offboard_control.py
To set the waypoint for the quadcopter to track, navigate to here and set the waypoints in the list.
If you encounter any problems or have questions, feel free to raise an issue.