Convert Figma logo to code with AI

mavlink logomavros

MAVLink to ROS gateway with proxy for Ground Control Station

1,048
1,050
1,048
406

Top Related Projects

PX4 Autopilot Software

DroneKit-Python library for communicating with Drones via MAVLink.

Paparazzi is a free and open-source hardware and software project for unmanned (air) vehicles. This is the main software repository.

Quick Overview

MAVROS is a ROS package that provides communication driver for various autopilots with MAVLink communication protocol. It serves as a bridge between the Robot Operating System (ROS) and MAVLink-enabled systems, allowing seamless integration of drones and other unmanned vehicles into ROS-based robotics projects.

Pros

  • Enables easy integration of MAVLink-based autopilots with ROS ecosystems
  • Supports a wide range of MAVLink-enabled devices and autopilots
  • Provides a standardized interface for controlling and monitoring drones through ROS
  • Actively maintained and has a large community of users and contributors

Cons

  • Can be complex to set up and configure for beginners
  • Requires understanding of both ROS and MAVLink protocols
  • May introduce latency in communication, which can be critical for some applications
  • Limited documentation for advanced use cases and troubleshooting

Code Examples

  1. Subscribing to GPS data:
import rospy
from sensor_msgs.msg import NavSatFix

def gps_callback(data):
    rospy.loginfo("Latitude: %f, Longitude: %f, Altitude: %f", 
                  data.latitude, data.longitude, data.altitude)

rospy.init_node('gps_subscriber')
rospy.Subscriber('/mavros/global_position/global', NavSatFix, gps_callback)
rospy.spin()
  1. Sending a takeoff command:
import rospy
from mavros_msgs.srv import CommandTOL

rospy.init_node('takeoff_command')
takeoff_service = rospy.ServiceProxy('/mavros/cmd/takeoff', CommandTOL)
takeoff_service(altitude=10, latitude=0, longitude=0, min_pitch=0, yaw=0)
  1. Setting flight mode:
import rospy
from mavros_msgs.srv import SetMode

rospy.init_node('set_mode')
set_mode_service = rospy.ServiceProxy('/mavros/set_mode', SetMode)
set_mode_service(custom_mode='GUIDED')

Getting Started

  1. Install ROS and MAVROS:

    sudo apt-get install ros-<distro>-mavros ros-<distro>-mavros-extras
    
  2. Install GeographicLib datasets:

    wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh
    sudo bash ./install_geographiclib_datasets.sh
    
  3. Create a ROS workspace and clone MAVROS:

    mkdir -p ~/catkin_ws/src
    cd ~/catkin_ws/src
    git clone https://github.com/mavlink/mavros.git
    
  4. Build the workspace:

    cd ~/catkin_ws
    catkin build
    
  5. Source the workspace:

    source ~/catkin_ws/devel/setup.bash
    

Now you can start using MAVROS in your ROS projects.

Competitor Comparisons

PX4 Autopilot Software

Pros of PX4-Autopilot

  • More comprehensive flight control system with a complete autopilot solution
  • Larger community and ecosystem, with extensive documentation and support
  • Supports a wider range of hardware platforms and sensors

Cons of PX4-Autopilot

  • Steeper learning curve due to its complexity and extensive codebase
  • Requires more computational resources to run effectively

Code Comparison

PX4-Autopilot (C++):

void MulticopterPositionControl::control_position(const float dt)
{
    // Position control logic
    Vector3f pos_error = _pos_sp - _pos;
    Vector3f vel_sp = pos_error.emult(_params.pos_p) + _vel_sp;
    control_velocity(dt, vel_sp);
}

MAVROS (C++):

void setpoint_raw_cb(const mavros_msgs::PositionTarget::ConstPtr &req)
{
    mavlink::common::msg::SET_POSITION_TARGET_LOCAL_NED sp;
    sp.type_mask = req->type_mask;
    sp.coordinate_frame = req->coordinate_frame;
    // ... (setting other fields)
    UAS_FCU(m_uas)->send_message_ignore_drop(sp);
}

PX4-Autopilot provides a more detailed implementation of position control, while MAVROS focuses on message handling and communication between ROS and MAVLink-enabled flight controllers.

DroneKit-Python library for communicating with Drones via MAVLink.

Pros of DroneKit-Python

  • Easier to learn and use, especially for Python developers
  • More beginner-friendly with higher-level abstractions
  • Extensive documentation and examples for various use cases

Cons of DroneKit-Python

  • Less flexible and customizable compared to MAVROS
  • Limited to Python, while MAVROS supports multiple languages through ROS
  • May have slightly higher latency due to additional abstraction layers

Code Comparison

DroneKit-Python:

from dronekit import connect, VehicleMode

vehicle = connect('udp:127.0.0.1:14550')
vehicle.mode = VehicleMode("GUIDED")
vehicle.armed = True
vehicle.simple_takeoff(10)

MAVROS:

#include <ros/ros.h>
#include <mavros_msgs/CommandBool.h>
#include <mavros_msgs/SetMode.h>

ros::ServiceClient arming_client = nh.serviceClient<mavros_msgs::CommandBool>("mavros/cmd/arming");
ros::ServiceClient set_mode_client = nh.serviceClient<mavros_msgs::SetMode>("mavros/set_mode");

mavros_msgs::SetMode offb_set_mode;
offb_set_mode.request.custom_mode = "OFFBOARD";
set_mode_client.call(offb_set_mode);

Both libraries provide ways to connect to and control drones, but DroneKit-Python offers a more straightforward approach, while MAVROS provides lower-level control and integration with ROS.

Paparazzi is a free and open-source hardware and software project for unmanned (air) vehicles. This is the main software repository.

Pros of Paparazzi

  • More comprehensive autopilot system with ground control station
  • Supports a wider range of hardware platforms
  • Includes simulation tools for testing and development

Cons of Paparazzi

  • Steeper learning curve due to its complexity
  • Less widespread adoption compared to MAVLink-based systems
  • May require more setup and configuration for basic operations

Code Comparison

Paparazzi (XML configuration):

<module name="nav" type="rotorcraft_nav"/>
<module name="guidance" type="rotorcraft_guidance_v1"/>
<module name="stabilization" type="rotorcraft_stabilization_int_quat"/>

MAVROS (ROS launch file):

<node pkg="mavros" type="mavros_node" name="mavros" clear_params="true" output="screen">
    <param name="fcu_url" value="udp://:14540@localhost:14557"/>
    <param name="gcs_url" value=""/>
    <param name="target_system_id" value="1"/>
    <param name="target_component_id" value="1"/>
</node>

Both repositories provide solutions for drone control and communication, but Paparazzi offers a more complete ecosystem while MAVROS focuses on integrating MAVLink with ROS. Paparazzi uses XML for configuration, while MAVROS relies on ROS launch files and parameters.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

MAVROS

GitHub release (latest by date) Gitter CI

MAVLink extendable communication node for ROS.

  • Since 2014-08-11 this repository contains several packages.
  • Since 2014-11-02 hydro support separated from master to hydro-devel branch.
  • Since 2015-03-04 all packages also dual licensed under terms of BSD license.
  • Since 2015-08-10 all messages moved to mavros_msgs package
  • Since 2016-02-05 (v0.17) frame conversion changed again
  • Since 2016-06-22 (pre v0.18) Indigo and Jade separated from master to indigo-devel branch.
  • Since 2016-06-23 (0.18.0) support MAVLink 2.0 without signing.
  • Since 2017-08-23 (0.20.0) GeographicLib and it's datasets are required. Used to convert AMSL (FCU) and WGS84 (ROS) altitudes.
  • Since 2018-05-11 (0.25.0) support building master for Indigo and Jade stopped. Mainly because update of console-bridge package.
  • Since 2018-05-14 (0.25.1) support for Indigo returned. We use compatibility layer for console-bridge.
  • Since 2019-01-03 (0.28.0) support for Indigo by master not guaranteed. Consider update to more recent distro.
  • 2020-01-01 version 1.0.0 released, please see #1369 for reasons and its purpose.
  • 2021-05-28 version 2.0.0 released, it's the first alpha release for ROS2.
  • 2023-09-09 version 2.6.0, dropped support for EOLed ROS2 releases. Now it require Humble+ (Humble, Iron, Rolling...).

mavros package

It is the main package, please see its README. Here you may read installation instructions.

mavros_extras package

This package contains some extra nodes and plugins for mavros, please see its README.

libmavconn package

This package contain mavconn library, see its README. LibMAVConn may be used outside of ROS environment.

test_mavros package

This package contain hand-tests and manual page for APM and PX4 SITL. Please see README first!

mavros_msgs package

This package contains messages and services used in MAVROS.

Support forums and chats

Please ask your questions not related to bugs/feature or requests on:

We'd like to keep the project bug tracker as free as possible, so please contact via the above methods. You can also PM us via Gitter and the PX4 Slack.

CI Statuses

  • ROS2 Humble: Build Status
  • ROS2 Jazzy: Build Status
  • ROS2 Kilted: Build Status
  • ROS2 Rolling: Build Status