|
| 1 | +# Running Simulations with ROSflight |
| 2 | + |
| 3 | +ROSflight a modular simulation package allowing it to perform software-in-the-loop (SIL) simulations of the ROSflight firmware. |
| 4 | + |
| 5 | +!!! TODO |
| 6 | + add a good image of the sim here. |
| 7 | + |
| 8 | +## Motivation |
| 9 | +The goals of the ROSflight simulation module (called `rosflight_sim`) are to |
| 10 | + |
| 11 | +- Enable **easy and extensive SIL** testing of an aircraft, |
| 12 | +- Provide to the sim the **exact same software** that flies the physical aircraft, |
| 13 | +- Support a **variety of simulators** out of the box -- from photorealistic to bare-bones, and |
| 14 | +- Enable users to plug in their own simulators if needed. |
| 15 | + |
| 16 | +See the [quick start](#quick-start) guide below or see the [detailed launching guide](detailed-launching-guide.md). |
| 17 | + |
| 18 | +See the [simulator architecture](simulator-architecture.md) description page for more information on adding your own simulator to `rosflight_sim`. |
| 19 | + |
| 20 | +## Quick-Start |
| 21 | +### Installation |
| 22 | +```bash |
| 23 | +// Clone from GitHub |
| 24 | +cd /path/to/rosflight_ws/src |
| 25 | +git clone --recursive https://github.com/rosflight/rosflight_ros_pkgs.git |
| 26 | + |
| 27 | +// Install dependencies |
| 28 | +cd rosflight_ros_pkgs |
| 29 | +sudo rosdep init |
| 30 | +rosdep update |
| 31 | +rosdep install --from-path . -y --ignore-src |
| 32 | + |
| 33 | +// Build the workspace |
| 34 | +cd /path/to/rosflight_ws |
| 35 | +colcon build |
| 36 | + |
| 37 | +// Source the workspace |
| 38 | +source install/setup.bash |
| 39 | + |
| 40 | +// Add the source to the .bashrc (optional) |
| 41 | +echo "source /path/to/rosflight_ws/install/setup.bash" >> ~/.bashrc |
| 42 | +``` |
| 43 | + |
| 44 | +### Launching |
| 45 | +```bash |
| 46 | +// Ensure the `rosflight_ws` workspace is sourced (see installation instructions above) |
| 47 | + |
| 48 | +// Launch a fixedwing simulation with VimFly (or connected joystick -- see detailed instructions) |
| 49 | +ros2 launch rosflight_sim fixedwing_standalone.launch.py use_vimfly:=true |
| 50 | + |
| 51 | +// Launch a multirotor simulation with VimFly (or connected joystick -- see detailed instructions) |
| 52 | +ros2 launch rosflight_sim multirotor_standalone.launch.py use_vimfly:=true |
| 53 | +``` |
| 54 | + |
| 55 | +This quick-start guide will launch the `standalone_sim` visualization engine (using RViz). |
| 56 | +For other out-of-the box supported visualizers, see the detailed launching instructions below. |
| 57 | + |
| 58 | +If you run into errors or problems when launching, please see the detailed launching instructions. |
| 59 | + |
| 60 | +!!! TODO |
| 61 | + Continue on the detailed launching guide. Certainly put the architecture on a separate page. There you can run through how everything is working. |
| 62 | + Add a page in the developer guide explaining how to add your own sim interfaces / dynamics / etc. to the sim. |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | +## Architecture of the SIL Simulation |
| 72 | + |
| 73 | +!!! TODO |
| 74 | + Make a figure of the new architecture. Maybe make it be a GIF? We could replace the table below |
| 75 | + |
| 76 | +To best mimic the hardware experience of ROSflight, the SIL plugin for Gazebo actually implements the firmware source code as a library. |
| 77 | +We just implemented a different "board layer" which uses gazebo instead of hardware calls for things like `imu_read()` and `pwm_write()`. |
| 78 | +Instead of a serial link over USB to the flight controller, we use a UDP connection bouncing off of localhost to communicate between `rosflight_io` and the firmware. |
| 79 | +This means the interface to the SIL plugin is identical to that of hardware. |
| 80 | +The `rosflight_io` node is the main gateway to the firmware in simulation, just as it is in hardware. |
| 81 | + |
| 82 | +The following table summarizes the correlation between connections in hardware and simulation: |
| 83 | + |
| 84 | +| Connection Type | Hardware | Simulation | |
| 85 | +|-----------------------------------------|--------------|------------------------------------------| |
| 86 | +| Serial communications to `rosflight_io` | USB / UART | UDP | |
| 87 | +| RC | PPM Receiver | ROS2 `RC` topic (`rosflight_msgs/RCRaw`) | |
| 88 | +| Motors | PWM | Gazebo Plugin | |
| 89 | +| Sensors | SPI/I2C | Gazebo Plugin | |
| 90 | + |
| 91 | +## Troubleshooting |
| 92 | +### Installation and Building |
| 93 | +#### It doesn't build. |
| 94 | +- Ensure git submodules are checked out at: |
| 95 | + - rosflight_ros_pkgs/rosflight_firmware |
| 96 | + - rosflight_ros_pkgs/rosflight_firmware/lib/eigen |
| 97 | + |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | + |
| 122 | + |
| 123 | + |
| 124 | + |
| 125 | + |
| 126 | + |
| 127 | + |
| 128 | + |
| 129 | + |
0 commit comments