Raspberry Pi: Installing and Configuring MAVROS - LoCO-AUV/loco_config GitHub Wiki

Installing ROS and MAVROS

Now that we have a Raspberry Pi4 running Ubuntu and ROS, let's install MAVROS, which interfaces with MAVLink on the Pixhawk.

Run

sudo apt install ros-melodic-mavros ros-melodic-mavros-extras

and wait for the installation to proceed. Next, run

wget https://raw.githubusercontent.com/mavlink/mavros/main/mavros/scripts/install_geographiclib_datasets.sh
chmod +x install_geographiclib_datasets.sh
sudo ./install_geographiclib_datasets.sh

This will install a shell script that will fetch the remaining dependancies. Once this finishes, reboot the Raspberry Pi.

Running the Master node

To run the node, first you must change the apm.launch file which should be located at /opt/ros/melodic/share/mavros/launch/apm.launch. The argument fcu_url needs to be changed from /dev/ttyACM0 to /dev/ttyS0. Once this is done you must switch to the root user (as the node needs to be root to open the serial port) and run roslaunch mavros apm.launch. Finally, we need to set the data stream to 10Hz using rosservice call /mavros/set_stream_rate 0 10 1. Once this is done the bridge will be ready to go.