Repository for basic mav functions implemented in ROS 2
- ROS2 running with Mavros (Recommended installation: skyrats-workplace)
sudo apt install python3-opencv
sudo apt install ros-$ROS_DISTRO-tf-transformations
pip3 install transforms3d
pip3 install pygeodesy
pip3 install scipy
In order to test autonomous flights, you can run the mav_testing.py
. This script follows the mission above:
- Takeoff to 3 m
- Go to local position (2, 0, 0)
- Hold for 5 seconds
- Land
In your computer, open 2 different terminals. In the fisrt one, run the following command:
ros2 launch mavbase2 px4_telemetry.launch.py
In the other terminal, go the the mavbase2 package directory and run:
python3 mav_testing.py
This repository also contains launch files used to connect MAVROS in different situations. Here are some examples on how to use them:
For a simple simulation, go to your PX4-Autopiot root and type the following:
make px4_sitl gazebo
This should launch gazebo with a drone spawned. After that, open another terminal and run:
ros2 launch mavbase2 px4_sitl.launch.py
Mavros will start and connect to the simulated drone. From here just run whichever ros2 node you wish to test!
For telemetry connection with the FCU, run the following:
ros2 launch mavbase2 px4_telemetry.launch.py
For usb connection with the FCU, run the following:
ros2 launch mavbase2 px4_usb.launch.py
If you followed the default installation through skyrats-workplace, just add the following lines to your python code:
sys.path.insert(0,'/home/' + os.environ["USER"] + '/skyrats_ws2/src/mavbase2')
from MAV2 import MAV2