6、Robot development environment construction in Docker6.1、Using 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 configuration ssh remote login to the host6.2.2.3、enter the robot container6.2.2.4、Vscode remote host configuration docker environment6.2.2.5、Configure passwordless login
The operating environment and software and hardware reference configurations are as follows:
Reference model: ROSMASTER X3
Robot hardware configuration: Arm series main control, Silan A1 lidar, AstraPro Plus depth camera
Robot system: Ubuntu (version not required) + docker (version 20.10.21 and above)
PC Virtual Machine: Ubuntu (20.04) + ROS2 (Foxy)
Usage scenario: Use on a relatively clean 2D plane
Enter the container, see [5. Enter the docker container of the robot], and execute the following command:
Note: When using Jupyter Lab in a docker container, you must run the docker container as host: add the "--net=host" parameter when running the container
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
..................
Other devices view, open in Windows or Ubuntu browser (must be under the same LAN, 192.168.2.102 is the IP address in the docker container)
xxxxxxxxxx
http://192.168.2.102:8888/lab
Enter the password: Yahboom enter Jupyter Lab
The following directory is the project path of the bot:
Let's take the example of configuring VSCODE to access the Docker container in Windows, and the steps to access Docker in Ubuntu are basically the same.
See [VI. Linux Operating System---- 3. Remote Control] chapter
Make sure Windows can telnet to the Docker host [car]:
xOpen cmd in windows enter ssh command test: ssh jetson@192.168.2.102 (username and ip modified to own)
Or use remote tools: putty, xshell, securecrt, winscp, mobaxterm, finalshell, etc
VSCODE official website: https://code.visualstudio.com/, download the installation of the Windows version
Open vscode, click the icon of the arrow at the bottom left, then enter remote in the search box, select the Remote Development plugin, and click Install to install the plugin
vscode is installed by default and then in English, and you can install Chinese plugins to localize:
Press the shortcut key [Ctrl + Shift + P] in VSCODE to open the command input window, type: remote, and then log in to the remote host [car] according to the instructions shown below.
How to see the screen shown above, indicating that you have successfully logged in to the host computer.
See the tutorial in the [5. Enter the docker container of the robot] chapter.
Install the docker plug-in on the remote host [car].
After the installation is completed, 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 and see the following indicates that it has entered the container
Open the folder
xxxxxxxxxx
/root/yahboomcar_ros2_ws # This is the project path for the bot
Similarly, we can also install the plug-ins we need in the container to facilitate our development
In addition to ROS, the recommended plugins to install here are:
After completing the above steps, you can manipulate the code files in the container to develop and learn.
In the above steps, some steps may require entering the password of the host, here is another optimization, configure passwordless 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 (username and IP modified to 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, click New in the user variables section, the variable is HOME, the value is C:Usersname, where name is the user name, you can view the user name of your own computer, and then the generated key pair is saved in this directory by default.
(2) Generate a key pair
Open the cmd command line, run it in the directory where the ssh program is located, or run [ssh-keygen -t rsa] anywhere after adding the system environment to generate the key, and then enter all the way, when you see a histogram generated, then the key is generated successfully. At this time, there will be two more files under the .ssh folder of the user directory, namely id_rsa (private key) and id_rsa.pub (public key)
(3) Add the public key to the host
Similarly, open the cmd command line, enter
xxxxxxxxxx
ssh username@host "cat >> ~/.ssh/authorized_keys" < C:Usersname.sshid_rsa.pub
#For example: Modify ssh jetson@192.168.2.102 "cat >> ~/.ssh/authorized_keys" < C:UsersAdmin.sshid_rsa.pub
This command first logs in to the host, and then adds the public key under the local computer, i.e. win, to the personal directory of the host account to achieve password-free login. Note that this step requires the password of the host account.
(4) Verification
Test again using ssh in Windows to log in to the host [trolley], the command is as follows:
xxxxxxxxxx
ssh jetson@192.168.2.102 (username and IP modified to own)
At this time, you will find that you no longer need to enter the password.
Restart VSCODE, and where you need to enter a password, you don't need to enter a password.