Setting Up ROSflight Sim¶
The purpose of this tutorial is to walk users through launching the default ROSflight simulator.
Prerequisites¶
- Install the ROSflight software (
rosflight_ros_pkgs
) by following the Installation for sim guide. - Ensure you have the
-desktop
version of ROS2 installed, not the-ros-base
version, as GUI tools are required for visualization.
ROSflight Sim Overview¶
A simulator includes many different modules, such as dynamic propagation, sensor creation, forces and moments computation, etc. One of these modules is the visualization module, that provides the graphical element to the simulator.
While ROSflight is designed to support different visualizers, we focus on the most basic one in these tutorials, the standalone_sim
, which uses the ROS2 RViz tool.
The ROSflight simulator is organized as a collection of ROS2 nodes that each provide different functionality. As we work through launching the sim, we'll look at some of those modules and discuss what they do.
Simulation Architecture¶
The ROSflight standalone simulator consists of several key components:
- SIL Manager: Manages the execution and timing of the firmware
- SIL Board: Instantiates the ROSflight firmware in software
- Dynamics: Simulates aircraft physics and dynamics
- Sensors: Simulates IMU, barometer, and other sensor data
- Forces and Moments: Computes aerodynamic forces based on control inputs
- RViz: Provides 3D visualization of the aircraft and flight path
Launching standalone_sim
¶
Warning
Make sure you installed the -desktop
version of ROS2, not the -ros-base
version, or the GUI tools will not work.
-
Source your workspace:
First, ensure your ROS2 environment and ROSflight workspace are properly sourced:
source /opt/ros/humble/setup.bash source /path/to/rosflight_ws/install/setup.bash
-
Launch the simulator:
ROSflight provides launch files for different aircraft types. Choose the appropriate command based on your needs:
Multirotor Simulation¶
ros2 launch rosflight_sim multirotor_standalone.launch.py
Fixed-Wing Simulation¶
ros2 launch rosflight_sim fixedwing_standalone.launch.py
With Keyboard Control (VimFly)¶
For manual control using keyboard input, add the
use_vimfly:=true
parameter:# Multirotor with keyboard control ros2 launch rosflight_sim multirotor_standalone.launch.py use_vimfly:=true # Fixed-wing with keyboard control ros2 launch rosflight_sim fixedwing_standalone.launch.py use_vimfly:=true
Understanding the Simulation Environment¶
Let's look at what just happened when we launched.
RViz Visualization¶
Once launched, RViz will open displaying:
- 3D Aircraft Model: Visual representation of your aircraft
- Coordinate Frames: Shows the aircraft's orientation and position
- Flight Path: Trace of the aircraft's trajectory (though you might not be able to see this until you start flying)
If you used the launch command use_vimfly:=true
, you should also see VimFly open up:
Running Nodes¶
You can verify the simulation is running by checking the active nodes:
ros2 node list
You should see the following nodes:
/rosflight_sil_manager
/sil_board
/standalone_sensors
/standalone_dynamics
/multirotor_forces_and_moments
or/fixedwing_forces_and_moments
/rosflight_io
Each of these nodes performs a different role in the sim. Detailed information about these nodes and what they do can be found in the simulation architecture description.
You can also see a representation of the data flow by running rqt_graph
in a new terminal.
If you don't see a similar view to what is below, click the refresh icon in the upper left.
![]() |
---|
RQT Graph is great, but it is not very configurable in terms of viewing options (sorry for the small image). |
The main data flow through the simulator starts with the /rosflight_sil_manager
node, which sends iteration requests to the /sil_board
.
The /sil_board
is the instantiation of the rosflight_firmware
in sim--in hardware, this would be the flight controller.
The /sil_board
listens to the /standalone_sensors
to "read" data from the "sensors", as close as possible to how the hardware board would read the sensor data.
The /sil_board
then computes motor commands and sends them over the /sim/pwm_output
topic to the fixedwing_forces_and_moments
node.
This node is responsible for computing the aerodynamic forces and moments (not gravity or collisions) given the motor commands.
The /forces_and_moments
node then sends the computed forces and moments to the /dynamics node
, which handles integration of the dynamics (i.e. solves \dot{x} = f(x)) and publishes the true state.
The /dynamics
node handles gravity and other collision forces.
This concludes a simulation "tick", and the simulation starts again with the /rosflight_sim_manager
.
For more information, see the detailed simulation architecture description.
Topics¶
View the available topics to see the data flow:
# List the topics
ros2 topic list
# Echo data sent through topics
ros2 topic echo <topic_name>
Key topics include:
/rc_raw
- RC commands/imu/data
- IMU sensor data/attitude
- Aircraft attitude estimated by the firmware's estimator/command
- Control command inputs to the firmware controller (or mixer)
Troubleshooting¶
Common Issues¶
RViz Not Opening
- Ensure you installed
ros-humble-desktop
, notros-humble-ros-base
- Check that you have a display environment (not running in headless mode)
Simulation Crashes
- Check parameter files for syntax errors
- Verify all dependencies are installed:
rosdep install --from-path . -y --ignore-src
- Read the error messages on the launch script :)
Review¶
In this tutorial, you learned how to:
- Launch the ROSflight standalone simulator for multirotor and fixed-wing aircraft
- Discover some of the simulation architecture and key components
- Troubleshoot common issues
Next Steps¶
Once you have the simulator running, you can:
- Firmware configuration and manual flight: Configure the firmware with the necessary parameters and fly in sim with a supported controller
- Autonomous flight: Integrate with the ROScopter or ROSplane autonomy stacks
- Custom applications: Use your own ROS2 nodes with ROSflight
- Parameter/Gain tuning: Use the RQT plugins to tune PID controllers and other parameters