Before running the script, you must first start the load_robot_head.launch file on the upper-level computer
# Run on the upper-level computercd ~/kuavo_ros_applicationsource devel/setup.bash # Make sure compilation has succeeded# Start the program according to the actual robot version:# Old 4th generation, 4Proroslaunch dynamic_biped load_robot_head.launch# Standard version, Advanced version, Showroom version, Showroom Compute versionroslaunch dynamic_biped load_robot_head.launch use_orbbec:=true# Max versionroslaunch dynamic_biped load_robot_head.launch use_orbbec:=true enable_wrist_camera:=true
Visualize the QR code detection preview image
# Run on the upper-level computercd ~/kuavo_ros_applicationsource devel/setup.bashpython3 src/ros_vision/detection_apriltag/detection_show/tag_detection_show.py
Observe the detection result with rqt
Open a new terminal and enter:
rqt_image_view
Select the /tag_detections_image topic
Example program to obtain the detection results
# Run on the lower-level computercd ~/kuavo-ros-opensourcesource devel/setup.bashpython3 src/demo/examples_code/tag_detect/get_tag_info.py
⚠️ Because /robot_tag_info depends on the tf tree, you need to make the robot stand up on the lower-level computer for this topic to take effect
Based on the camera coordinate system: /tag_detections; based on the robot base coordinate system: /robot_tag_info
Modify the topic subscribed to in the example program to obtain the different pose information of the QR code in the camera coordinate system and in the robot base coordinate system
AprilTagProcessor class: Handles AprilTag detection data, including initializing the ROS node, converting quaternions to Euler angles, retrieving AprilTag data, looking up AprilTags by ID, and calculating averaged AprilTag data.
quaternion_to_euler function: Converts a quaternion to the yaw angle in Euler angles, used to represent rotation.
get_apriltag_data function: Retrieves AprilTag detection data from a ROS topic and extracts the ID, position, and orientation of each tag.
get_apriltag_by_id function: Looks up AprilTag data by the specified ID.
get_averaged_apriltag_data function: Retrieves multiple detection results for the AprilTag with the specified ID and calculates its average position and orientation.
Main program: Creates an AprilTagProcessor instance, initializes the ROS node, and obtains the averaged data of the AprilTag with the specified ID.