|
| 1 | +--- |
| 2 | +title: ROS2 workspace installation |
| 3 | +pagination_label: Building the MRS ROS2 in workspace |
| 4 | +description: Building the MRS ROS2 in workspace |
| 5 | +--- |
| 6 | + |
| 7 | +# Workspace build of the ROS2 MRS UAV System |
| 8 | + |
| 9 | +This guide is meant mainly for developers of the ROS2 MRS UAV System. |
| 10 | +Users of the system that do not need to modify the core of the system can stick to the deb installation |
| 11 | + |
| 12 | +## Installation steps |
| 13 | + |
| 14 | +### 1. Install the Robot Operating System (Jazzy) |
| 15 | + |
| 16 | + Follow the [Installation](https://ctu-mrs.github.io/docs/prerequisities/ros2/installation) guide. |
| 17 | + |
| 18 | +### 2. Install necessary dependencies |
| 19 | + |
| 20 | +Add the Personal Package Archive (PPA) for unstable ROS2 MRS deb packages: |
| 21 | +```bash |
| 22 | +curl https://ctu-mrs.github.io/ppa2-unstable/add_ppa.sh | bash |
| 23 | +sudo apt update |
| 24 | +``` |
| 25 | + |
| 26 | +Install the dependencies: |
| 27 | +```bash |
| 28 | +sudo apt install mrs-uav-shell-additions ros-jazzy-nlopt ros-jazzy-rmw-zenoh-cpp |
| 29 | +``` |
| 30 | + * `mrs-uav-shell-additions` - installs tmux config file to `/etc/ctu-mrs/tmux.conf` (necessary for running simulation tmux sessions) |
| 31 | + * `ros-jazzy-rmw-zenoh-cpp` - the ROS MiddleWare (RMW) implementation of Zenoh communication protocol |
| 32 | + * `ros-jazzy-nlopt` - necessary for `mrs_uav_trajectory_generation` package |
| 33 | + |
| 34 | +Add to `~/.bashrc` (`~/.zshrc`): |
| 35 | +``` |
| 36 | +export RMW_IMPLEMENTATION="rmw_zenoh_cpp" |
| 37 | +``` |
| 38 | + |
| 39 | +### 3. Get aliases that make common ROS2 commands usable |
| 40 | + |
| 41 | +```bash |
| 42 | +cd ~/git |
| 43 | +git clone git@github.com:ctu-mrs/mrs_uav_development.git |
| 44 | +cd mrs_uav_development |
| 45 | +git checkout ros2 |
| 46 | +``` |
| 47 | + |
| 48 | +Add to `~/.bashrc` (`~/.zshrc`): |
| 49 | +```bash |
| 50 | +source $GIT_PATH/mrs_uav_development/shell_additions/shell_additions.sh |
| 51 | +``` |
| 52 | + |
| 53 | +### 4. Clone the MRS UAV Core repository |
| 54 | + |
| 55 | +```bash |
| 56 | +cd ~/git |
| 57 | +git clone git@github.com:ctu-mrs/mrs_uav_core.git |
| 58 | +cd mrs_uav_core |
| 59 | +git checkout ros2 |
| 60 | +gitman install |
| 61 | +``` |
| 62 | + |
| 63 | +### 5. Prepare the workspace |
| 64 | + |
| 65 | +```bash |
| 66 | +mkdir -p ~/ws_mrs_uav_core/src |
| 67 | +ln -s $GIT_PATH/mrs_uav_core $HOME/ws_mrs_uav_core/src/ |
| 68 | +``` |
| 69 | + |
| 70 | +Set the compilation flags to `rel-with-deb-info` using mixin according to: |
| 71 | +https://ctu-mrs.github.io/docs/prerequisities/ros2/ros1-ros2-patterns/workspace_profiles |
| 72 | + |
| 73 | +First, install mixin: |
| 74 | +```bash |
| 75 | +sudo apt install python3-colcon-mixin |
| 76 | +colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml |
| 77 | +colcon mixin update default |
| 78 | +``` |
| 79 | + |
| 80 | +Add the following config to `~/ws_mrs_uav_core/colcon_default.yaml`: |
| 81 | +```yaml |
| 82 | +build: |
| 83 | + parallel-workers: 8 |
| 84 | + mixin: |
| 85 | + - rel-with-deb-info |
| 86 | +``` |
| 87 | +
|
| 88 | +Add to `~/.bashrc` (`~/.zshrc`): |
| 89 | +```bash |
| 90 | +source /opt/ros/jazzy/setup.bash |
| 91 | +``` |
| 92 | + |
| 93 | +Source `~/.bashrc` (`~/.zshrc`): |
| 94 | +```bash |
| 95 | +source ~/.bashrc |
| 96 | +``` |
| 97 | + |
| 98 | +### 6. Build the workspace |
| 99 | +```bash |
| 100 | +cd ~/ws_mrs_uav_core/ |
| 101 | +colcon build |
| 102 | +``` |
| 103 | + |
| 104 | +Add to `~/.bashrc` (`~/.zshrc`): |
| 105 | +```bash |
| 106 | +source $HOME/ws_mrs_uav_core/install/setup.bash |
| 107 | +``` |
| 108 | + |
| 109 | +### 7. Run the multirotor simulation session to verify the installation |
| 110 | +```bash |
| 111 | +cd ~/ws_mrs_uav_core/src/mrs_uav_core/ros_packages/mrs_multirotor_simulator/tmux/mrs_one_drone/ |
| 112 | +./start.sh |
| 113 | +``` |
| 114 | + |
| 115 | +# Troubleshooting |
| 116 | + |
| 117 | +## Optimization flags |
| 118 | +* Issue: Estimation manager is outputting errors with `time since last msg too long` |
| 119 | +* Reason: Workspace is built without optimization flags. |
| 120 | +* Solution: See step 5. and make sure the workspace is built with `rel_with_deb_info` |
| 121 | + |
| 122 | +## Tmux config |
| 123 | +* Issue: After running the tmux session, the terminal looks weird and tmux bindings don't work |
| 124 | +* Reason: tmux config is missing in /etc/ctu-mrs/tmux.conf |
| 125 | +* Solution: `sudo apt install mrs-uav-shell-additions` |
| 126 | + |
| 127 | +## MRS UAV testing not building |
| 128 | +* Issue: The package `mrs_uav_testing` is not building |
| 129 | +* Reason: It hasn't been converted to ROS2 yet. |
| 130 | +* Solution: `touch ~/ws_mrs_uav_core/src/mrs_uav_core/ros_packages/mrs_uav_testing/COLCON_IGNORE` |
| 131 | + |
0 commit comments