ArduPilot / ardupilot_ros

ArduPilot ROS integration
GNU General Public License v3.0
15 stars 9 forks source link
ardupilot ros

ardupilot_ros: ROS 2 use cases with Ardupilot

pre-commit

Requirements

System Requirements

Workspace Requirements

Installation

Clone this repository into your ros2 workspace alongside ardupilot_gz:

cd ~/ros2_ws/src
git clone git@github.com:ardupilot/ardupilot_ros.git

Install dependencies using rosdep:

cd ~/ros2_ws
rosdep install --from-paths src --ignore-src -r --skip-keys gazebo-ros-pkgs

Build

Build it with colcon build:

cd ~/ros2_ws
source /opt/ros/humble/setup.bash
colcon build --packages-up-to ardupilot_ros ardupilot_gz_bringup

Usage

1. Cartographer running with LiDAR on copter

This simulation has an Iris copter equipped with a 360 degrees 2D LiDAR in a maze world. To launch rviz and gazebo, run:

cd ~/ros2_ws
source install/setup.bash
ros2 launch ardupilot_gz_bringup iris_maze.launch.py

In another terminal, with the world and copter in place, launch cartographer to generate SLAM:

cd ~/ros2_ws
source install/setup.bash
ros2 launch ardupilot_ros cartographer.launch.py

If you'd like to get the information from Cartographer to go into Ardupilot's extended kalman filter, you will need to change some parameters. You can do that through any GCS, including mavproxy:

The parameters above are recommended for SITL. If you plan on using this on a real copter, it is a good idea to setup a second source of EKF. This way the robot doesn't crash if the external odometry you are providing stops publishing or gets lost.

Please refer to this link for more information on Common EKF Sources as well as this guide on GPS / Non-GPS Transitions.

2. Joystick Controller

The joystick controller allows you to control ArduPilot through a ROS joy topic.

cd ~/ros2_ws
source install/setup.bash
ros2 run ardupilot_ros joy_controller

Then run the controller using,

ros2 run ardupilot_ros joy_controller

Now, using the keyboard keys you can control the drone.

2. Obstacle avoidance using Cartographer and Nav2

Using the same simulation as before, the nav2 node can be launched to control the copter once it is in the air.

Launch the simulation:

cd ~/ros2_ws
source install/setup.sh
ros2 launch ardupilot_gz_bringup iris_maze.launch.py rviz:=false

Launch cartographer:

cd ~/ros2_ws
source install/setup.sh
ros2 launch ardupilot_ros cartographer.launch.py rviz:=false

Launch nav2:

cd ~/ros2_ws
source install/setup.sh
ros2 launch ardupilot_ros navigation.launch.py

Takeoff the Copter using mavproxy to an altitude of 2.5m:

mavproxy.py --console --map --aircraft test --master=:14550

mode guided

arm throttle

takeoff 2.5

You may now navigate while mapping using the Nav2 Goal tool in RVIZ!

Contribution Guideline