6. Building a robot development environment in docker

 

The operating environment and software and hardware reference configuration are as follows:

6.1. Use jupyter lab to access docker

  1. 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.

  1. 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)

image-20230424173324001

 

The following directory is the project path of the robot:

/root/yahboomcar_ws

image-20230425101243048

 

 

6.2. Use vscode to access docker

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.

 

6.2.1. Remote configuration

See Chapter [6. Linux Operating System ---- 3. Remote Control]

Make sure that windows can remotely log in to the docker host [car]:

 

6.2.2, vscode configuration

 

6.2.2.1. Download and install vscode

vscode official website: https://code.visualstudio.com/, just download and install the windows version

 

6.2.2.2, vscode configures ssh to remotely log in to the host machine

  1. 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.

image-20230424183009372

After vscode is installed by default, it is the English version. You can install the Chinese plug-in to localize it:

image-20230424182205246

 

  1. 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].

image-20230425091020733

image-20230425091230849

image-20230425091248247

image-20230425091304318

image-20230425091323608

image-20230425091358042

image-20230425091415820

If you see the screen above, it means you have successfully logged in to the host computer remotely.

 

6.2.2.3. Enter the robot container

See the tutorial in the chapter [5. Entering the robot’s docker container] to enter.

 

6.2.2.4, vscode remote host configuration docker environment

  1. Install the docker plug-in on the remote host [car]

image-20230425091515978

 

  1. After the installation is complete, a docker icon will appear in the left navigation bar.

image-20230425091532747

 

  1. Click the docker icon

image-20230425093400792

 

  1. Right-click the running container and operate as shown below:

image-20230425093448428

image-20230425093609630

 

  1. A new window will open. When you see the following, you have entered the container.

image-20230425093643476

 

  1. Open the folder

image-20230425093748086

image-20230425093730162

image-20230425093808074

image-20230425093900096

 

  1. Similarly, the plug-ins we need can also be installed in the container to facilitate our development.

image-20230425102200355

In addition to ros, the recommended plug-ins to install here are:

img

After completing the above steps, you can operate the code files in the container to develop and learn.

 

6.2.2.5. Configure password-free login

Some of the above steps may require you to enter the host's password. Let's optimize it again and configure password-free login.

  1. First test using ssh to log in to the host [car] in Windows. The instructions are as follows:

At this time you will find that you need to enter the host password

 

  1. 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. Insert image description here

 

(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)

img

 

(3) Add the public key to the host machine

Open the cmd command line similarly and enter

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:

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.