🤖
Hardware-in-the-loop
  • About the project
  • Getting started
  • Setup
  • Simulation world
  • Husarion ROSbot 2 urdf model
  • ROSbot control
  • Navigation
  • Launching the system
  • Additional resources
Powered by GitBook
On this page
  • 1. Connect to network
  • 2. IP address
  • 3. Starting container
  • 4. Accessing ROSbot
  • 5. ROS setup

Setup

In this page you will find the information on how to set up your system for this HIL project. For this step you need the Husarion ROSBot 2, your computer and access to an active network.

PreviousGetting startedNextSimulation world

Last updated 1 year ago

1. Connect to network

To get started, first you need to create a connection between the Husarion ROSbot 2 and your computer, so they can both access the same running ROS system.

1.a) Connect through WiFi

Connect both your computer and your robot to the same WiFi network.

For more information about how to connect to a WiFi network with an Ubuntu system, visit:

For more information about how to connect to a wifi network with the Husarion ROSbot 2, visit:

1.b) Connect with UTP cables

In case you don't have an available WiFi network, or the connection speed is too slow, you can use UTP cables to connect the robot and your computer to the same network.

The Husarion ROSbot 2 does not have an Ethernet port. To be able to connect to the network with an UTP cable, you need to use an USB-Ethernet converter, for example like the one below:

2. IP address

For the next steps, you will need to know the IP address of both your computer and your robot. You can check the IP address for example by typing the following command in a terminal window:

hostname -I

The Husarion ROSbot has an HDMI port as well as two USB ports. You can use these to connect an external display, a mouse and a keyboard. If you do so, you will see a desktop environment on the display, where you can open and use a terminal the same as you would normally do so with your computer. You can use this terminal to obtain the IP address of the robot.

The command above usually gives you a list of multiple IP addresses. You can use the ip a command to check which IP address belongs to which network interface. Make sure to choose the IP address for both your computer and your robot that have the same CIDR.

For example if you see the following two IP addresses for your computer: 192.168.103.85, 172.17.0.1, and the following two for your robot: 192.168.103.76,172.17.0.3, either choose for both the ones that belong to the 192.168.103.xxx or the other, but don't mix them.

Note: At this step it is important to have a correctly set-up network. If not done so there could be significant problems when trying to access the robot or with the ROS communication.

3. Starting container

You can start this container directly on your computer or you can start it using the Asimovo platform. In case of the former, make sure you have docker with GPU support set up on your computer.

3a) Start container in your local workstation

What this Dockerfile contains

This Dockerfile extends the Asimovo base image ROS2 Foxy | Gazebo Citadel. Besides the contents of the Dockerfile of this image, it installs ROS1 Noetic, a couple of useful tools like git, net-tools and netcat, and the libuvc package. Moreover, it installs the ros2/ros1 bridge, and as the visualization and the headless mode was more efficient with it, Gazebo Fortress.

To build the container image, download the file linked above, go to the folder where this file is located, then use the command docker build . -t hil_setup_noetic_foxy. This builds a container image with the name hil_setup_noetic_foxy.

What the run.sh file contains

In short, the command in this file creates a container instance from the image that has been built before based on the Dockerfile. This command contains all the necessary options for the container instance to function as needed.

With this command multiple folders are mounted as well, including the ros2_pkgs_ws and the husarion_ws_two, with the options

-v <route_to_project>/husarion_ws_two:/husarion_ws_two

and

-v <route_to_project>/ros2_pkgs_ws:/ros2_pkgs_ws .

Make sure to substitute <route_to_project> with the path where you downloaded your project!

The following options are needed with regards to using the Nvidia GPU inside the container. If these are not set, Gazebo will not use GPU, but CPU, which might greatly affect performance.

--env="NVIDIA_DRIVER_CAPABILITIES=all" \
--gpus all \
--runtime=nvidia \

Further in this tutorial it will be assumed that you are working inside this container. To access a running container from other terminal windows you can use the command docker exec -it hil_setup_noetic_foxy /bin/bash.

Tip: You will need to have many terminal windows (or tabs) opened parallel for your work. In any new terminal you open you have enter the running container with the command above.

3b) Using the Asimovo platform

This feature is under development. Please come back later for more information.

4. Accessing ROSbot

You can use SSH to access the ROSbot from the container.

Enter the following command in a terminal of your running container to connect: ssh husarion@<ROSbot IP address>

For example if the IP address of your ROSbot is 192.168.103.76 then the connection command will look like: ssh husarion@192.168.103.76

After connecting, the system will ask you for a password. For the Husarion ROSbot 2 used in this project the password is husarion.

The user should be the same in both the container and in the husarion rosbot's ssh-d terminals. For simplicity, in this tutorial the root user is used in both. You can use the sudo su command to switch to the sudo user in th Husarion ROSbot ssh'd terminals. In the container by default the root the user is set.

5. ROS setup

For the ROS1 specific elements to work, you will need to set the following environmental variables:

ROS_MASTER_URI, ROS_HOSTNAME, ROS_IP

You can do so by using the following commands:

export ROS_MASTER_URI=http://<hostanme>:<port>/
export ROS_HOSTNAME=<hostname>
export ROS_IP=<IP address>

For example if the IP address of your ROSbot is 192.168.103.76 and the IP address of your running container (in case of using the --net=host option the P address of your computer) is 192.168.103.85, furthermore, we want to run ROS master on the ROSbot with the port 46335, then the commands above will look like:

On Husarion ROSbot 2:

export ROS_MASTER_URI=http://husarion:46335/
export ROS_HOSTNAME=husarion
export ROS_IP=192.168.103.76

On your locally running container :

export ROS_MASTER_URI=http://husarion:46335/
export ROS_HOSTNAME=workstation
export ROS_IP=192.168.103.85

You have to set these variables in every terminal window where you would like to use any ROS1 specific command.

You can make these settings permanent by for example adding the commands above to a .bashrc file like ~/.bashrc.

Additionally you also need to modify the /etc/hosts file in both the ROSbot and in the container, by adding the IP address and hostname of the computer (provided if the --net=host setting is on when launching the container) and the ROSbot. This means adding the following lines:

<IP address ROSbot>       <hostname ROSbot>
<IP address container>    <hostname container>

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:

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're all set up. Now you can start with the HIL project of your choosing.

The Asimovo platform utilizes a container based setup. In this tutorial one of the simulation images of Asimovo will be used. The Dockerfile describing this image is available .

For more information about how to do so, visit: and for Nvidia GPU: .

For more information about Dockerfiles, visit:

After the build is complete you can use the run.sh script that is available to start a container instance.

For more information about ssh connections visit: .

As mentioned before, the Husarion ROSbot 2 has ROS1 Noetic installed, while the container has both ROS2 Foxy and ROS1 Noetic. To create a connection between the two ROS versions, the will be used, that is also installed in the container.

For more information about bashrc visit:

For more information about network setup with multiple machines for ROS1, visit:

here
https://docs.docker.com/engine/install/ubuntu/
https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html
https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
here
https://www.digitalocean.com/community/tutorials/how-to-use-ssh-to-connect-to-a-remote-server
ros2/ros1_bridge
https://phoenixnap.com/kb/bashrc
http://wiki.ros.org/ROS/NetworkSetup
https://help.ubuntu.com/stable/ubuntu-help/net-wireless-connect.html.en
https://husarion.com/manuals/rosbot/#connect-rosbot-to-your-wi-fi-network
Page cover image