Set up Docker & Install the MuSHR stack
We will work directly on TX2. Here are the essential steps for us.
Setup Docker
1. Install the Compose plugin
never install the docker engine already installed on Jetson TX2 default.
Step 1: Set up the repository. Find distro-specific instructions in the link below for your system. Perform the steps at Set up the repository.
Do not continue to Install Docker Engine!
Back to the Install the Compose plugin and continue with step 2.
Step 2: run the commands depending on your system.
Step 3: Verify that docker-compose is installed correctly. You can always check with this command if needed.
2. Manage docker as a non-root user
Following the tutorial - Linux post-installation steps for Docker Engine. Reboot TX2 after this. Otherwise, before you reboot, you need to run
$ newgrp docker
every time when you launch a new terminal, otherwise, you won’t run docker commands without sudo.
Install MuSHR stack
1. Clone mushr stack
Suggest cloning it to your SD card because TX2 doesn’t have too many memories.
$ mkdir -p [your_path]/catkin_ws/src
$ cd catkin_ws/src
$ git clone --branch noetic https://github.com/prl-mushr/mushr.git
You can also download it from our GitHub
2. Docker setting
a. Suggest using our docker image
Go to the file [your_path]/catkin_ws/src/mushr/mushr_utils/install/docker-compose-robot.yml, modify the parameter image:
...
services:
mushr_noetic:
image: pdaelm/imredd_mushr:02_2023 # mushr/mushr:${MUSHR_OS_TYPE}
...
b. Attaches the catkin_ws volume so you can edit code outside or inside the docker container
Got to the file [your_path]/catkin_ws/src/mushr/mushr_utils/install/docker-compose-robot.yml, add below to the Volumes parameter:
...
volumes:
...
- ${MUSHR_WS_PATH}/catkin_ws:/root/catkin_ws
...
c. Run the installation script
$ [path]/catkin_ws/src/mushr/mushr_utils/install/mushr_install.bash
It will prompt you with two questions. For running the MuSHR robot, the answer should be [yes] and [no]. This will install a series of necessary packages, and create a script mushr_noetic in /usr/local/bin which initializes a docker container with all of the mushr configs installed.
Watch out for the log:
Warnings of git are ok because you may already have the directories and don’t need to update them.
Failure is not ok: “failure to make file /usr/local/bin/mushr_noetic” may cause the failure to run the command $ mushr_noetic
. Normally it becaus there is already a mushr_noetic file exit. You should:
- delete it with root authority
$ sudo rm /usr/local/bin/mushr_noetic
- And run the install .bash file again
$ [path]/catkin_ws/src/mushr/mushr_utils/install/mushr_install.bash
d. Launch mushr_noetic docker continar
Close the terminal and open a new one, start a container:
$ mushr_noetic
(The first time running this command will take some time to download the Docker image.)
if you run the mushr_noetic before and you want to start the same container, try:$ docker start [container_ID] && docker exec -it [container_ID] bash
.
e. catkin build
In the container(same terminal), run catkin build:
$ cd catkin_ws && catkin build
$ cd && source .bashrc
(you only do it for the first time when you start a new container or you add new files in catkin_ws)
f. Modify the parameters of ros_ip in .bashrc:
$ export ROS_HOSTNAME=localhost
[sugesst]
or
$ export ROS_IP=[IP]
when your IP is static, otherwise you need to modify it every time when your IP changes, you can check it with $ ifconfig
and wlan0:…inet:[IP]…
To check the .bashrc file in the container, you have two ways:
- In the container bash terminal:
$ vim .bashr
- In the VS code attached to the container: Directly click the file .bashrc under the /root/
You can also use these two ways above to modify the .bashrc file.
.bashrc
is a file in the docker container, you have to commit to persist it. But sometimes it may doesn’t work. If you wait too long and you see the error below when you launch a .launch
file, most probably the IP address is incorrect, run the $ export ROS_HOSTNAME=localhost
again.
g. Launch ROS teleop
$ roslaunch mushr_base teleop.launch
Make sure no errors are reported. [control + c] to stop it.
More sensors(cameras) setting:
- Depth image data: set the parameters: depth from false to true in [path]/catkin_ws/src/mushr/mushr_hardware/mushr_hardware/launch/racecar-uw-tx2/sensor.launch or [path]/catkin_ws/src/mushr/mushr_hardware/realsense/realsense2_camera/launch/rs_camera.launch
- Set the parameters of fisheyes from false to true in rs_camera.launch
Now you can control the robot with a PS4 controller.
h. Exit the container bash Just run:
$ exit
Supplements:
Check container ID and image_name:
$ docker ps -a (to check the container info)
[do it every time you make changes in the container] The files made inside the docker container will only persist if you commit. Re-open a new terminal:
$ docker commit [container_ID] [image_name]
If you need more terminal windows in the container, there are three ways to reach it:
i. Open a new terminal, check the container ID, and go to its bash:
$ docker exec -it [container ID] bash
ii. Tmux: Getting Started · tmux/tmux Wiki · GitHub
iii. VS code [suggestion]:
a. (if on another PC) connect vs code to remote: ssh robot@[IP address] b. Launch the container if you don’t have one, and connect vs code to the container c. Open the terminal in VS code as much as you want
We suggest using this on your own PC because launching VS code also costs the memories of TX2 which is not too much.