UGV Beast PI ROS2 1. Preparation

From Waveshare Wiki
Jump to: navigation, search
UGV Beast PI ROS2
UGV Beast

I2C, UART
TTL Serial Bus Servo Control Interface
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

1. Preparation

As the product will automatically run the Raspberry Pi main program by default when it is turned on, the main program will occupy the serial port and camera. In this case, ROS 2 cannot be used. You need to end the main program or disable the automatic operation of the main program. ROS 2 function packages all run in the Docker container in the Raspberry Pi system, so after shutting down the main program of Raspberry Pi, you need to start the Docker remote service in order to remotely log in to the Docker container to execute the ROS 2 function package.


1.1 End the main program

Real time display of tasks and process information currently running in the system on the terminal:

top

Wait a few seconds, and you will see the PID with COMMAND as python.

ROS2 top.png


Press Ctrl+C to exit the view, then enter the command to end the process.

Kill -9 Python process PID

Enter: kill -9 850 as shown in the figure above. This ends the running of the main Raspberry Pi program for that product. Note: After ending the running of the main program, the Raspberry Pi IP address: 5000 cannot be accessed successfully. However, the main program will still automatically run after the product is restarted. If you want the product not to run the main program automatically after powering on again, you can follow the content in the next section 1.2 Disable the main program from running automatically.


1.2 Disable the main program from running automatically

Every time the product is restarted, it will automatically run the main program by default. If you need to directly prohibit the product's main program from automatically running at startup, you need to cancel the main program configured by crontab to run automatically at startup. Enter the following command in the terminal:

crontab -e

If you are asked which editor to use, input 1 and then press Enter to choose nano.

When you open crontab's configuration file, you can see the following two lines:

@reboot ~/ugv_pt_rpi/ugv-env/bin/python ~/ugv_pt_rpi/app.py >> ~/ugv.log 2>&1
@reboot /bin/bash ~/ugv_pt_rpi/start_jupyter.sh >> ~/jupyter_log.log 2>&1

Add a "#" sign at the beginning of the line "...app.py >> ...." to comment out this line, as follows:

#@reboot ~/ugv_pt_rpi/ugv-env/bin/python ~/ugv_pt_rpi/app.py >> ~/ugv.log 2>&1
@reboot /bin/bash ~/ugv_pt_rpi/start_jupyter.sh >> ~/jupyter_log.log 2>&1

In the terminal page, press Ctrl + X to exit. It will ask you Save modified buffer? Enter "Y" and press Enter to save the changes.

Enter the restart command to restart the device (the green light of the Raspberry Pi will flash during the restart process. When the green light flashes less frequently or goes out, it means the startup has been successful):

sudo reboot

If you did not comment out the "...start_jupyter.sh >>..." line in the previous step, you can still use jupyter Lab normally after the robot restarts (JupyterLab and the robot's main program app.py run independently of each other).

It should be noted here that because the lower device continues to communicate with the upper device through the serial port, the upper device may not be able to boot normally due to the continuous change of the serial port level during the restart process. Take the case where the host device is a Raspberry Pi. When restarting, the Raspberry Pi will not turn on again after shutting down. The red light is always on and the green light is not on. At this time, you can turn off the robot's power switch and turn it on again, and the robot will restart normally.


1.3 Start Docker remote service

Go to the ugv_ws project directory in the Raspberry Pi and grant executable permissions to the ros2_humble.sh and remotessh.sh files:

cd /home/ws/ugv_ws
sudo chmod +x ros2_humble.sh remotessh.sh

Execute the script file ros2_humble.sh to start the Docker remote service:

./ros2_humble.sh

Enter 1 to enter the Docker container to start the SSH service.

ROS2 Dockerstart.png

1.4 Remote login to Docker container

After the Docker container has successfully started the SSH service, use MobaXterm to remotely log in to the Docker container.

Click Session → SSH, the host IP is the Docker container IP, enter the IP address of the Raspberry Pi in Remote host, the Port is the assigned port 23, and finally click OK.

ROS2 DockerSSH.png

After the connection is established, enter the username: root and password: ws. Note: It is normal for the screen to remain unchanged when entering the password, press enter to access the Docker container after the password is entered. The SSH remote connection to the Docker container has been successful since then.