This repository contains a ROS2 package to simulation an orbit movement for a drone.
The scripts are ran in the px4_simulator_container
found in this gitlab repository here, which uses Ubuntu 20.04, ROS2 Galatic, Micro-XRCE Agent, PX4 and Gazebo.
The scripts were tested using software-in-the-loop (SITL). NED coordinate system is used in the code.
A video of the simulation demo can be found on YouTube here.
The drone will perform a clockwise orbit about the boat position, facing inwards towards the centre. It will start the orbit from the position (x+ORBIT_RADIUS, y)
. Boat positions are added to boat_queue
and the drone goes to the boat at the start of the queue
cmd_timer_callback
runs like a state machine to command the drone at different stages of the mission.
Start the px4 simulator container
cd px4_simulator_container
./launch_container.sh
Change directory into the ROS2 workspace
cd ~/ros_ws/src
Add SSH key to your github account. Follow instructions here.
View the generated public key.
cat ~/.ssh/id_ed25519.pub
Clone the repository
git clone [email protected]:yufanana/drone_orbit.git
Build with colon
colcon build
Alternatively, only build specific packages that were modified.
colcon build --packages-select <name-of-pkg>
Source the setup file
source /ros_ws/install/setup.bash
Start the px4 simulation container
cd px4_simulator_container
./launch_container.sh
Run tmux to have multiple terminals (tmux cheatsheet).
tmux
- The common shortcuts to use are
- Ctrl + b % : split pane with horizontal layout
- Ctrl + b " : split pane with vertical layout
- Ctrl + b arrow key : switch pane to the direction
Source the setup file in each new terminal session
source /ros_ws/install/setup.bash
Run software-in-the-loop. This brings up Gazebo.
./start_sitl.sh
In 2 new terminals,
- run the offboard control node that commands the drone movements
ros2 run drone_orbit offboard_orbit
- run the boat publisher node to output the boat positions
ros2 run drone_orbit boat_publisher
In the terminal for the boat_publisher
, enter dummy numerical values to introduce target positions for the drone to travel to.
Enter boat XY-position: <x> <y>