Skip to content

AntonSHBK/dron_px4_ros2_docker

Repository files navigation

Aerial Drone Control with ROS 2 and PX4

This project provides a ROS 2 interface for controlling a drone using the PX4 autopilot in offboard mode. It includes nodes for keyboard control, offboard control, visualization, and more. The setup is primarily designed for simulation with PX4 SITL (Software In The Loop) and can be extended for use with real drones.

Intro

The project was inspired by the following sources:

Installation

Installation

  1. Clone the Repository:

    git clone https://github.com/AntonSHBK/dron_px4_ros2_docker
    cd dron_px4_ros2_docker/docker
    
    docker-compose up --build
  2. Build the Workspace:

    colcon build --packages-select px4_msgs px4_ros_com
    colcon build --packages-select aerial_drone_base
  3. Source the Workspace:

    source install/setup.bash

Launching the Drone

Start the ROS 2 Nodes

Launch the ROS 2 nodes required for controlling the drone:

ros2 launch aerial_drone_base aerial_drone_base.py

Run a script to collect data from a drone

ros2 run aerial_drone_base data_save.py

This launch file will start the following nodes:

  • processes_node: Manages different background processes such as the PX4 SITL simulation.
  • control_node: Handles the offboard control and sends commands to PX4.
  • velocity_node: Manages the drone's velocity commands.
  • visualizer_node: Provides visualization tools for Rviz.

Keyboard Controls

Use the following keys to control the drone:

  • W: Move Up
  • S: Move Down
  • A: Yaw Left
  • D: Yaw Right
  • Up Arrow: Pitch Forward
  • Down Arrow: Pitch Backward
  • Left Arrow: Roll Left
  • Right Arrow: Roll Right

Speed Adjustments:

  • Q: Increase linear and angular speed
  • Z: Decrease linear and angular speed
  • E: Increase angular speed only
  • C: Decrease angular speed only

Arm/Disarm:

  • Space: Arm or disarm the drone

Exit:

  • CTRL+C: Exit the teleop node

Troubleshooting

  • If the drone doesn't respond to commands, ensure that the PX4 is running properly and that the nodes are correctly launched.
  • Check the ROS 2 topics to ensure messages are being published correctly:
    ros2 topic list
  • Monitor logs for any errors or warnings.

Additional Information

It's important to ensure that the PX4 versions are consistent across all components of your system. When working with px4_msgs and px4_ros_com, it's essential to use the same version as the PX4 firmware, such as 1.14. Mismatched versions can lead to compatibility issues, affecting communication between the ROS 2 nodes and the PX4 autopilot. Make sure to check out the correct branches or tags in the repositories to align with your PX4 firmware version.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

About

Drone using Docker, ROS 2 Humble and PX4

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published