The following steps are provided for a ROSbot 2R with ROS 1 installed and for which, as consequence, it is necessary the ROS 1 bridge.
- Install the ROS 1 bridge choosing the branch corresponding to your ROS 2 version.
- Go into the mynmpc folder and change branch:
git checkout rosbot
- Go into the root folder of your ROS 2 workspace and re-build it:
colcon build --packages-select mynmpc
After having connected to your ROSbot through the same wifi connection, open 4 different shells and respectively follow these instructions:
- First shell:
- Source ROS 1 installation:
source /opt/ros/$ROS_1_DISTRO$/setup.bash
- Run the core:
roscore
- Source ROS 1 installation:
- Start the ROSbot.
- Second shell:
- Source ROS 1 installation:
source /opt/ros/$ROS_1_DISTRO$/setup.bash
- Source ROS 2 workspace:
source ~/$ROS_2_WS_WITH_BRIDGE$/install/setup.bash
- Run the ROS 1 bridge:
ros2 run ros1_bridge dynamic_bridge
- Source ROS 1 installation:
- Third shell:
- Source ROS 2 installation:
source /opt/ros/$ROS_2_DISTRO$/setup.bash
- Source ROS 2 workspace:
source ~/$ROS_2_WS$/install/setup.bash
- Launch the simulation:
ros2 launch mynmpc simulation.launch.py
- Source ROS 2 installation:
- Fourth shell:
- Source ROS 2 installation:
source /opt/ros/$ROS_2_DISTRO$/setup.bash
- Source ROS 2 workspace:
source ~/$ROS_2_WS$/install/setup.bash
- Run the controller:
ros2 run mynmpc controller
- Source ROS 2 installation:
- Since you will need to source different shells with different ROS distributions, make sure of not having an automatic source command in your .bashrc file, and (personal suggestion) create and alias to run commands faster.
- If the dynamic bridge does not correctly map all the needed ROS 1 topics to ROS 2, run it with this additional option:
This will map all the ROS 1 topics to ROS 2.
ros2 run ros1_bridge dynamic_bridge --bridge-all-1to2-topics