This repository contains a ROS2 stack for interfacing with an autopilot running the ROSflight firmware. For more information on the ROSflight autopilot firmware stack, visit http://rosflight.org.
This package contains the rosflight_io node, which provides the core functionality for interfacing an onboard computer with the autopilot. This node streams autopilot sensor and status data to the onboard computer, streams control setpoints to the autopilot, and provides an interface for configuring the autopilot. It also contains a mag_cal node that is used to calibrate the UAV's magnetometer parameters.
rosflight_io utilizes two libraries: mavrosflight and mavlink. Mavlink is the communication protocol used for serial communication between rosflight_io and the firmware. It exists as a separate Github repository, utilized by both rosflight_io and the firmware. Mavrosflight is what handles the actual serial communication in rosflight and is largely ROS independent. rosflight_io mostly just manages the interactions between mavrosflight and ROS.
This package contains an udp_board implementation of the ROSflight firmware and a copy of the firmware itself as a git submodule. udp_board can be used to run instances of the firmware on a device with UDP communication and is used by rosflight_sim for its sil_board.
This package contains the ROSflight message and service definitions.
This is a metapackage for grouping the other packages into a ROS stack.
This package contains files for running ROSflight in the Gazebo simulator. It has a SIL board implementation, forces and
moments calculations for both fixedwing and multirotors, launch files for launching the sim, and model and world files
for the Gazebo visualization. Dynamics for both multirotors and fixedwings can be modified in the .yaml files found in
the rosflight_sim/params
folder. To launch the sim, use ros2 launch rosflight_sim fixedwing.launch.py
for a
fixedwing simulation and ros2 launch rosflight_sim multirotor.launch.py
for a multirotor simulation. You can also add
gui:=false
to launch a sim without visualization. See the launch files under rosflight_sim/launch
for additional
parameters.
This script contains a node that allows for connecting a gamepad or transmitter to the simulator or using a simulated controller if neither of those are available.
To use a transmitter or controller, plug in a controller and launch ros2 run rosflight_sim rc.py --ros-args --remap RC:=/fixedwing/RC
for a fixedwing sim or ros2 run rosflight_sim rc.py --ros-args --remap RC:=/multirotor/RC
for a
multirotor sim. Currently supported devices are Taranis Q-X7 transmitters, XBox controllers, RealFlight InterLink
controllers, and RadioMaster TX16S transmitters. Adding additional devices can be done easily in the script (just
follow what has already been done), so long as the device has USB gamepad support.
To use a simulated transmitter, set up the firmware so the arm switch is on channel 4 and the override switch is on
channel 5. Launch the node with ros2 run rosflight_sim rc.py --ros-args --remap RC:=/fixedwing/RC
for a fixedwing
sim or ros2 run rosflight_sim rc.py --ros-args --remap RC:=/multirotor/RC
for a multirotor sim. Arm/disarm with
ros2 service call /toggle_arm std_srvs/srv/Trigger
, enable/disable override with ros2 service call /toggle_override std_srvs/srv/Trigger
.
The gazebo simulator with the sil_node can be launched alongside rosflight_io and rc_joy, for convenience. Use
ros2 launch rosflight_sim fixedwing_sim_io_joy.launch.py
for a fixedwing sim and
ros2 launch rosflight_sim multirotor_sim_io_joy.launch.py
for a multirotor sim.
Basic parameter files for setting up a multirotor or fixedwing UAV have been provided, under the
rosflight/rosflight_sim/params
directory. Use
ros2 service call /param_load_from_file rosflight_msgs/srv/ParamFile "{filename: "/path_to_rosflight/rosflight_sim/params/fixedwing_firmware.yaml"}"
for fixedwings and
ros2 service call /param_load_from_file rosflight_msgs/srv/ParamFile "{filename:"/path_to_rosflight/rosflight_sim/params/multirotor_firmware.yaml"}"
for multirotors.
To make setting up the firmware with initial calibrations and parameters easier, launch files have been provided to
automate this process. Use ros2 launch rosflight_sim fixedwing_init_firmware.launch.py
for fixedwings and ros2 launch rosflight_sim multirotor_init_firmware.launch.py
for multirotors. These launch files reference the parameter
files found in the rosflight_sim/params
directory mentioned above.
- Before installing any new packages, update your system with
sudo apt update
andsudo apt upgrade
. - Install ROS2 Humble. Follow the directions on
the ROS2 documentation, making sure to
install both the
ros-humble-desktop
and theros-dev-tools
packages. - Before ROS can be used, the setup file will need to be sourced in every terminal that you want to use ROS in. This
can be done with
source /opt/ros/humble/setup.bash
, or you can set bash to source it automatically when opened withecho "source /opt/ros/humble/setup.bash" >> ~/.bashrc
. Re-open your terminal so that this echo command can take effect. - Create a rosflight workspace folder and cd into it with
mkdir rosflight_ws && cd rosflight_ws
. - Clone the rosflight repository and its submodules
with
git clone --recursive https://github.com/rosflight/rosflight.git
. - Install all required dependencies with rosdep. To do so, initialize rosdep with
sudo rosdep init
, update withrosdep update
, and install the dependencies withrosdep install -i --from-path ./ -y --ignore-src
. - Rosdep will install Gazebo for the rosflight_sim packaged, which has a setup file that will need to be sourced. Set
it to be sourced automatically with
echo "source /usr/share/gazebo/setup.sh" >> ~/.bashrc
. - Build the repository with
colcon build
. Once built, set the rosflight setup file to be sourced automatically withecho "source ~/rosflight_ws/install/setup.bash" >> ~/.bashrc
. If your workspace folder is in a different location than your home directory, updated the path in the command to reflect its location.
To run the rosflight_io node when connected to real hardware, use the
command ros2 run rosflight_io rosflight_io --ros-args -p port:=/dev/ttyACM0
, replacing /dev/ttyACM0
with the location
of serial port connected to the flight controller. This will launch a ROS2 node on your computer that will publish all
sensor topics and create all command subscriptions needed to communicated with the firmware.
All instructions in this section are for a fixedwing simulation, but a multirotor simulation can be launched by
replacing all occurrences of fixedwing
with multirotor
.
To run the ROSflight firmware in the Gazebo simulator, launch Gazebo and the rosflight_sil node
with ros2 launch rosflight_sim fixedwing.launch.py
. This will launch a rosflight_sil node that contains the full
ROSflight firmware as if it was running on an actual flight computer, the only difference being that instead of calling
real sensors it calls Gazebo sensors.
To run the rosflight_io node with the simulator, use the
command ros2 run rosflight_io rosflight_io --ros-args -p udp:=true
.
To connect an RC controller to the simulator, plug a controller into your computer and launch the rc_joy node
with ros2 run rosflight_sim rc_joy.py --ros-args --remap /RC:=/fixedwing/RC
. This will launch a node that receives
RC controller commands and publishes them to be received by rosflight_sil. It currently only has support for the
following: Xbox controllers, Taranis QX7 transmitters, RadioMaster TX16s transmitters, and RealFlight controllers. To
add more, edit rosflight_sim/src/rc_joy.py and rebuild the workspace.
To launch the rosflight_sil, rosflight_io node, and rc_joy nodes all at once rather than individually, use the
command ros2 launch rosflight_sim fixedwing_sim_io_joy.launch.py
.
Note that in order to actually arm and fly the UAV in the simulator, you still need to set the proper parameters on the
flight controller. To do so, launch both the rosflight_sil and rosflight_io nodes. Set all necessary parameters
with ros2 launch rosflight_sim fixedwing_init_firmware.launch.py
. Wait until launch file completes.
This package contains utilities that will be used to support the ground control station experience. Currently this is under development and only contains a couple of former rosflight_utils packages.
This utility uses RViz and the viz node to allow easy visualization of the attitude of flight controller (as determined by the firmware's onboard estimator) and the magnetometer data. These can be launched with ros2 launch rosflight_utils viz_att.launch.py
and ros2 launch rosflight_utils viz_mag.launch.py
.