In this page you will be guided through the commands with which you can launch the project.
In this example we have used 8 terminal windows.
First, start the container with the command
cd <location of project>/docker_setup && ./run.sh
Then enter the container in all terminal windows with the command
docker exec -it hil_setup_noetic_foxy /bin/bash
Then, add the following two lines to the /etc/hosts file inside the container and in the robot, if you haven't done so already. You can do this with any text editor of your choice, in this example we've used vim. For this, you need to know the IP address of your computer and the robot.
For example if the IP address of your Rosbot is 192.168.103.76 and the IP address of your computer (provided if the --net=host setting is on when launching the container) is 192.168.103.85, then on the Husarion ROSbot 2 you need to add the following two lines to the file /etc/hosts (using vim, you would use the command vim /etc/hosts):
192.168.103.85 computer
192.168.103.76 husarion
and on your computer:
192.168.103.85 computer
192.168.103.76 husarion
You should also switch to the root user in the robot.
------- Terminal 1 -------
root@Minty:/ros2_ws# vim /etc/hosts
------- Terminal 6 -------
root@Minty:/ros2_ws# ssh husarion@192.168.0.101
husarion@husarion:~$ sudo su
------- Terminal 7 -------
root@Minty:/ros2_ws# ssh husarion@192.168.0.101
husarion@husarion:~$ sudo su
root@husarion:/home/husarion# vim /etc/hosts
As part of the setup, you should define the topics that you would like to bridge with the ros2/ros1 bridge. In this example we create a file and put the following content into it. You can do so with your preferred text editor.
------- Terminal 8 -------
root@Minty:/ros2_ws# vim bridge.yaml
bridge.yaml
topics:
-
topic: /odom # Topic name on both ROS 1 and ROS 2
type: nav_msgs/msg/Odometry # Type of topic to bridge
queue_size: 1 # Queue size
-
topic: /imu # Topic name on both ROS 1 and ROS 2
type: sensor_msgs/msg/Imu # Type of topic to bridge
queue_size: 1 # Queue size
-
topic: /cmd_vel # Topic name on both ROS 1 and ROS 2
type: geometry_msgs/msg/Twist # Type of topic to bridge
queue_size: 1 # Queue size
-
topic: /clock # Topic name on both ROS 1 and ROS 2
type: rosgraph_msgs/msg/Clock # Type of topic to bridge
queue_size: 1 # Queue size
-
topic: /tf # Topic name on both ROS 1 and ROS 2
type: tf2_msgs/msg/TFMessage # Type of topic to bridge
queue_size: 1 # Queue size
-
topic: /joint_states # Topic name on both ROS 1 and ROS 2
type: sensor_msgs/msg/JointState # Type of topic to bridge
queue_size: 1 # Queue size
Now, the appropriate environment variables need to be exported in the terminals that use ROS1. This means the two terminals in which we are connected to the robot, and the terminal where the ros2/ros1 bridge will be started.
Finally, start the project. First, start the ROS master on the robot. Then, start the ros2/ros1 bridge. Launch the gazebo world, spawn the robot and start the position update script. Finally, start the rosbot drivers launchfile on the robot, launch the navigation stack in the container and the nav2 bringup. In this step the order of the commands matter. Carry out the commands in the order you see them listed below.
Finally, set up RViz according to your preferences.
In the video below you can see the steps carried out and a movement command completed by the ROSbot.
The following section you can see all the necessary commands grouped by terminal windows (starting from the state when the user is already inside the container).