Object recognition and tracking

Note: The VM and ROS-wifi image transfer module must be consistent with the microROS control board ROS_DOMAIN_ID and set the value to 20. You can check [MicroROS control board Parameter configuration] to set the microROS control board ROS_DOMAIN_ID. Check the tutorial Connecting to MicroROS Agents to see if the ids are the same.

1、Program function specification

After the program starts, select the object that needs to be tracked by the mouse, press the space bar, and the PTZ steering gear of the car enters the tracking mode. The head of the car will follow the tracked object and always ensure that the tracked object remains in the center of the picture.

2、Operation procedure

2.1、activate

Enter docker, terminal type,

If the Angle of the camera is not at this Angle, please press CTRL+C to end the program and run again, this is because the network delay causes the Angle of sending the steering gear to lose packets

image-202405100001

If the camera picture image appears upside down, you need to see 3. Camera picture correction (must see) document itself correction, the experiment is no longer described.

 

2.2、recognize

After startup, enter the selection mode, select the location of the target with the mouse, as shown in the figure below, release it to start recognition.

image-20240201104412437

Keyboard key control:

[r]:To select the mode, use the mouse to select the area to identify the target, as shown in the figure above.

[q]:Exit procedure.

[Space bar]:Target tracking; Move the target slowly while following, moving too fast will lose the target.

Press the space to see the motion Angle calculated by the pid.

image-20240124144716493

You can also debug PID parameters using dynamic parameter adjuster, terminal input,

image-20240124144820485

The adjustable parameters include PID parameters of the car head. After modifying the parameters, click "refresh" to refresh the data.

2.3、View the node topic communication graph

You can view the topic communication between nodes by running the following command,

image-20240124145115184

3、Core code

The principle of functional implementation is similar to color tracking, which is to calculate the rotation Angle of s1 and s2 steering gear according to the central coordinates of the target, and then release it to the chassis, and part of the code is put under,