6. Bind the device ID

When the robot uses two or more USB serial devices, the corresponding relationship between the device name and the device is not fixed, but is allocated according to the order in which the devices are connected to the system. Inserting one device first and then another device can determine the relationship between the device and the device name, but it is very troublesome to plug and unplug the device every time the system starts. The serial port can be mapped to a fixed device name. No matter what the insertion order is, the device will be mapped to the new device name. We only need to use the new device name to read and write the device.

6.1. Device view command

View camera device parameters

Enter the following command in the terminal to check the correspondence between the pixel size of the camera and the frame rate.

image-20220215110456637

Device ID view

As can be seen from the figure below, the ID number of each device, Astra has the official file for binding the device, the handle generally does not need to be bound, and the main binding is PCB and radar.

image-20220215111840056

Device number view

image-20220214200740623

6.2. Establish port mapping relationship

6.2.1. Device binding

There is a create_udev_rules file in the scripts folder under the astra_camera function package, which is automatically bound by running the file. Run the command as follows

Go to the rules.d directory

You can find the 56-orbbec-usb.rules file, which is the Astra camera device binding file.

Go to the rules.d directory

Create a new rplidar.rules file

Open the rplidar.rules file

write the following

Exit to make the rules take effect

Replug the USB device and you're done.

6.2.2. Introduction to rule file syntax

Parse

From [6.1], it is easy to see that the device number of the PCB is [ttyUSB0], and the ID number is [1a86, 7523], which is fixed. 0, 1, 2, 3, 4, ...] are all bound to [myserial]; the same is true for radar device [ttyUSB1]; the same is true for other devices that need to be bound.

Note: When taking an alias, do not take some device names that already exist in the system, otherwise it will fail.

6.3. Verify View

Device number view

PCB

image-20220214200850110

laser

image-20220214200912909

6.4. Binding the USB port

The above situations are all different ID numbers. If the ID numbers of the radar and the PCB are the same, or there are two or more PCBs (radars) with the same ID, the above binding will be confused.

Then, we need to bind the USB port. After binding, the cannot be changed at will , and each device can only be linked to a fixed USB port.

Binding method, take [ttyUSB0] as an example, check the port of the device at this time

image-20220214200632653

What we need is to modify in the rules file