6. Building a robot development environment in docker6.1. Use jupyter lab to access docker6.2. Use vscode to access docker6.2.1. Remote configuration6.2.2, vscode configuration6.2.2.1. Download and install vscode6.2.2.2, vscode configures ssh to remotely log in to the host machine6.2.2.3. Enter the robot container6.2.2.4, vscode remote host configuration docker environment6.2.2.5. Configure password-free login
The operating environment and software and hardware reference configuration are as follows:
Reference model: ROSMASTER X3
Robot hardware configuration: Arm series main control, Silan A1 lidar, AstraPro Plus depth camera
Robot system: Ubuntu (no version required) + docker (version 20.10.21 and above)
PC virtual machine: Ubuntu (18.04) + ROS (Melodic)
Usage scenario: Use on a relatively clean 2D plane
Enter the container, see [5. Enter the robot’s docker container], and execute the following command:
Note: When using jupyter lab in a docker container, you must run the docker container in host networking mode: add the "--net=host" parameter when running the container.
xxxxxxxxxx
root@ubuntu:/# jupyter lab --allow-root
[I 2023-04-24 09:27:45.265 ServerApp] Package jupyterlab took 0.0001s to import
[I 2023-04-24 09:27:45.277 ServerApp] Package jupyter_server_fileid took 0.0096s to import
[I 2023-04-24 09:27:45.297 ServerApp] Package jupyter_server_terminals took 0.0190s to import
[I 2023-04-24 09:27:45.429 ServerApp] Package jupyter_server_ydoc took 0.1301s to import
[I 2023-04-24 09:27:45.431 ServerApp] Package nbclassic took 0.0001s to import
.....................
To view on other devices, open it in a windows or ubuntu browser (must be on the same LAN, 192.168.2.102 is the IP address in the docker container)
xxxxxxxxxx
http://192.168.2.102:8889/lab
Enter the password: yahboom to enter jupyter lab
The following directory is the project path of the robot:
/root/yahboomcar_ws
Here we take configuring vscode to access the docker container in windows as an example to explain. The steps to access docker in ubuntu are basically the same.
See Chapter [6. Linux Operating System ---- 3. Remote Control]
Make sure that windows can remotely log in to the docker host [car]:
xxxxxxxxxx
Open cmd in windows and enter the ssh command to test: ssh jetson@192.168.2.102 (change the username and ip to your own)
Or use remote tools: putty, xshell, securecrt, winscp, mobaxterm, finalshell, etc.
vscode official website: https://code.visualstudio.com/, just download and install the windows version
Open vscode, click the icon with the arrow below on the left, then enter remote in the search box, select the Remote Development plug-in, and click Install to install the plug-in.
After vscode is installed by default, it is the English version. You can install the Chinese plug-in to localize it:
Press the shortcut key [ctrl + shift + p] in vscode to open the command input window, enter: remote, and then follow the instructions in the figure below to log in to the remote host [car].
If you see the screen above, it means you have successfully logged in to the host computer remotely.
See the tutorial in the chapter [5. Entering the robot’s docker container] to enter.
Install the docker plug-in on the remote host [car]
After the installation is complete, a docker icon will appear in the left navigation bar.
Click the docker icon
Right-click the running container and operate as shown below:
A new window will open. When you see the following, you have entered the container.
Open the folder
xxxxxxxxxx
/root/yahboomcar_ws # This is the project path of the robot
Similarly, the plug-ins we need can also be installed in the container to facilitate our development.
In addition to ros, the recommended plug-ins to install here are:
After completing the above steps, you can operate the code files in the container to develop and learn.
Some of the above steps may require you to enter the host's password. Let's optimize it again and configure password-free login.
First test using ssh to log in to the host [car] in Windows. The instructions are as follows:
xxxxxxxxxx
ssh jetson@192.168.2.102 (change the username and IP to your own)
At this time you will find that you need to enter the host password
Next configure password-free login
(1) Add environment variables
Open the environment variable properties page and click New in the user variable section. The variable is HOME and the value is C:\Users\name, where name is the user name. You can check the user name of your computer by yourself. The key pair generated will be saved by default in under this directory.
(2) Generate key pair
Open the cmd command line and run it in the directory where the ssh program is located, or after adding the system environment, run [ssh-keygen -t rsa] anywhere. This command is used to generate the key, and then press Enter all the way. When you see a rectangular diagram generated, Then the key generation is successful. At this time, there will be two more files in the .ssh folder in the user directory, namely id_rsa (private key) and id_rsa.pub (public key)
(3) Add the public key to the host machine
Open the cmd command line similarly and enter
ssh username@host "cat >> ~/.ssh/authorized_keys" < C:\Users\name\.ssh\id_rsa.pub
#For example: modify according to your own situation
ssh jetson@192.168.2.102 "cat >> ~/.ssh/authorized_keys" < C:\Users\Admin\.ssh\id_rsa.pub
This command first logs in to the host machine, and then adds the public key of the local machine, that is, win, to the personal directory of the host account, thereby achieving password-free login. Note that this step requires entering the password for the host account.
(4) Verification
Test again and use SSH to log in to the host [car] in Windows. The instructions are as follows:
xxxxxxxxxx
ssh jetson@192.168.2.102 (change the username and IP to your own)
At this time, you will find that you no longer need to enter a password.
Restart vscode, and you no longer need to enter a password where you need to enter a password.