Kuavo Docs
Development Interfaces

Arm Collision Prevention Function User Guide

Package Description

  • Used to detect collisions of the robot's arms. It only supports collision detection between the robot's two arms and between the robot's arms and the robot body. It has no perception of or collision protection against the external environment (such as obstacles, operators, external equipment, etc.), so make sure there is no additional interference in the surrounding environment when using it.

  • When the "auto-return after arm collision" function is enabled, upon detecting a collision within the above scope, the arm will automatically be controlled to move to the pose it held 3 seconds before the collision occurred, preventing the collision from worsening.

    • After the auto-return motion is completed, the system automatically switches the arm control mode to "1-Hold Pose". At this point the arm is fixed at the returned pose and cannot be driven directly by external commands.

    • After the auto-return motion is completed, if you need to control the arm again, you must switch the arm control mode back to "2-External Control". Only after the switch is complete can external control commands be accepted.

Precautions

  • Before use, it is recommended to perform calibration by referring to the "Automatic Zero-Point Calibration of Head and Arms" section in the Robot Joint Calibration document to ensure accurate detection.

  • Collision detection has no "predictive function" and has a certain lag, so users are advised not to move the arms too fast when using it.

  • If you use this package on your own and want to enable the collision return function, you need to change the original target topics kuavo_arm_traj and kuavo_arm_target_poses to /arm_collision/kuavo_arm_traj and /arm_collision/kuavo_arm_target_poses; otherwise conflicts will occur when sending collision return commands.

Launch Instructions

step 1: Build the package

cd /home/lab/kuavo-ros-opensource
sudo su
catkin build kuavo_arm_collision_check

step 2: Modify the configuration file

  • If your robot has no wrist cameras, you can modify the configuration file to make detection more accurate.
  • The file locations are as follows; choose according to your robot version: (if unsure, you can check by entering echo $ROBOT_VERSION in the lower-level controller terminal)
    • Version 45: /home/lab/kuavo-ros-opensource/src/kuavo_arm_collision_check/config/s45_collision_config.yaml
    • Version 49: /home/lab/kuavo-ros-opensource/src/kuavo_arm_collision_check/config/s49_collision_config.yaml
  • Edit the file and add the following content at the end of the file:
ignore_links:
  - l_hand_tripod
  - r_hand_tripod

step 3: Launch the arm collision detection program (and enable collision auto-return)

cd /home/lab/kuavo-ros-opensource
sudo su
source devel/setup.bash
roslaunch kuavo_arm_collision_check arm_collision_check.launch arm_collision_enable_arm_moving:=true

step 4. Launch VR teleoperation (and enable collision detection return)

Make sure the arm collision detection program has been launched as in step 3

cd /home/lab/kuavo-ros-opensource
sudo su
source devel/setup.bash
roslaunch noitom_hi5_hand_udp_python launch_quest3_ik.launch use_arm_collision:=true use_cpp_ik:=false

If the VR program is launched in this way, then:

  • When a collision occurs while the VR is controlling the arm, the arm position will automatically be restored to the state it was in 3 seconds earlier.
  • After the arm position is restored to the state it was in 3 seconds earlier, the arm will stay in that position, and the VR controller must press X+A to resume arm tracking.

Model File Description

After the node starts, it reads the URDF file according to the ROBOT_VERSION environment variable and loads the corresponding STL models. The model loading priority is as follows:

  1. cache folder: Cached models (processed models) are used first.
  2. kuavo_assets: If there are no STL files in the above folder, the original STL files in kuavo_assets are inflated, and the processed model files are imported into the cache folder.

Note: Currently only ROBOT_VERSION=45 and ROBOT_VERSION=49 are supported; other versions may cause joint mismatch issues.

Configuration File Description

  • The configuration file path is: $(find kuavo_arm_collision_check)/config/s$(arg robot_version)_collision_config.yaml
    • Version 45: src/kuavo_arm_collision_check/config/s45_collision_config.yaml
    • Version 49: src/kuavo_arm_collision_check/config/s49_collision_config.yaml
  • The configuration file mentioned in the following content all refers to this file.

1. Inflation Coefficient (Inflation)

  • Description: The inflation coefficient for each joint or STL model (unit: meters). The inflation coefficient is used to slightly enlarge the model during collision detection to improve safety and robustness.
inflation:
  torso_STL: 0.020
  camera_STL: 0.020
  ...
  r_hand_pitch_STL: 0.020
  head_yaw_STL: 0.020
  head_pitch_STL: 0.020
  • Notes:
    • To avoid invalid ROS parameter names, . or - in the original file names have been replaced with _.
    • Different inflation coefficients can be set for different joints; for example, arm joints can be slightly larger than leg joints to increase the collision safety margin.
    • When modifying the inflation coefficient, make sure the value is within a reasonable range (generally 0.01–0.05 m). Too large a value may cause false collisions, while too small a value may miss detections.
    • If you change the inflation coefficient of a model, you need to delete the corresponding model file in the cache folder so that the model is reloaded with the new inflation coefficient.
    • Example: delete all cache files as the sudo user: sudo rm -rf src/kuavo_arm_collision_check/cache/*

2. Collision Filter Rules (Collision Filter)

  • Description: Defines joint pairs that are excluded from collision detection, used to mask collision detection between adjacent joints or specific joints of the robotic arm itself.
collision_filter:
  - [r_hand_tripod, zarm_r5_link]
  - [l_hand_tripod, zarm_l5_link]
  • Notes:
    • Each item in the list is a joint pair [linkA, linkB].
    • Joint names must match the names used when the robot model is loaded.
    • When linkA and linkB are detected, this collision pair is skipped.
    • New masking rules can be added for different robot versions or hand types.
    • The default masking rules are correct; there is no need to change this section unless the user needs to add extra physical structural components to the robot.
  • Description: ignore_links specifies links that are completely ignored in collision detection. Once a link is added to this list, it will not participate in any collision detection. This is suitable for some non-critical structural parts, auxiliary brackets, sensor models, etc.
ignore_links:
  - l_hand_tripod
  - r_hand_tripod
  • Notes:
    • Each item in the list is a link name.
    • Ignored links will not be checked for collisions with any other links (including the robot itself and the environment).
    • If ignore_links: is empty (for example, written only as ignore_links:), it means no links are ignored, and normal operation is not affected.

Detailed Package Description

This section provides a detailed description of the arm collision detection package

Cache Mechanism

When the program loads for the first time, it uses the OpenMesh library to process the STL models and stores the processed files in the cache folder. Subsequent startups will directly use the cached models to improve performance.

Note: The cache folder is cleared during compilation to prevent cached models from becoming invalid due to code changes.

Workflow

  1. Load STL files
  2. Add the models in the STL files as FCL collision bodies
  3. Subscribe to TF and update the poses of the collision bodies in real time
  4. Compute collision detection at the set frequency (default 5Hz)
  5. Publish collision information when a collision occurs
  6. Continuously record sensor data (default 3 seconds)

Published Topics

  • /arm_collision/info: Collision information, including the names of the joints involved in the collision
    • Message type: kuavo_msgs/armCollisionCheckInfo
  • /arm_collision/check_duration: Collision detection duration (milliseconds)
  • /arm_collision/markers: Collision markers for RViz display (optional; enabling increases processing time)
    • Message type: kuavo_msgs/sensorsData
  • /kuavo_arm_target_poses: Arm target poses
    • Message type: kuavo_msgs/armTargetPoses
  • /kuavo_arm_traj: Arm trajectory data
    • Message type: sensor_msgs/JointState

Subscribed Topics

  • /arm_collision/kuavo_arm_traj: Arm trajectory data
    • Message type: sensor_msgs/JointState
  • /arm_collision/kuavo_arm_target_poses: Arm target poses
    • Message type: kuavo_msgs/armTargetPoses
  • /sensors_data_raw: Raw sensor data
    • Message type: kuavo_msgs/sensorsData

Services

  • /arm_collision/wait_complete: Wait for collision return to complete
    • Service type: std_srvs/SetBool
    • Used for synchronous operations, waiting for the current operation to complete
  • /arm_collision/set_arm_moving_enable: Set the enable state of arm movement detection
    • Service type: std_srvs/SetBool
    • Dynamically enable or disable the move-return function when the arm collides

Node Parameters

Parameter NameTypeDefaultDescription
/arm_collision/check_freqdouble5.0Collision detection frequency (Hz)
/arm_collision/publish_collision_markersboolfalseWhether to publish collision markers for RViz display
/arm_collision/enable_arm_movingboolfalseWhether to enable automatic return after arm collision
/arm_collision/arm_move_diffdouble0.1Arm movement difference threshold

Dependencies

  • ROS
  • FCL (Flexible Collision Library)
  • OpenMesh
  • kuavo_msgs
  • kuavo_common
  • tf2_ros
  • sensor_msgs
  • visualization_msgs

Usage Examples

  1. Launch the collision detection node:

    roslaunch kuavo_arm_collision_check arm_collision_check.launch
  2. View collision information:

    rostopic echo /arm_collision/info
  3. Display collision markers in RViz:

    roslaunch kuavo_arm_collision_check arm_collision_check.launch arm_collision_publish_collision_markers:=true

    (Disabled by default; must be enabled manually)

  4. Adjust the detection frequency:

    roslaunch kuavo_arm_collision_check arm_collision_check.launch arm_collision_check_freq:=10.0
  5. Disable arm movement detection:

    roslaunch kuavo_arm_collision_check arm_collision_check.launch arm_collision_enable_arm_moving:=false

Troubleshooting

  • If the collision detection frequency is too low, you can adjust the arm_collision_check_freq parameter.
  • If model loading fails, check whether the URDF file path and the STL files exist.
  • If there is a problem with the cache, you can manually delete the cache folder to regenerate it.
  • If arm movement detection does not work, check whether the enable_arm_moving_check_ parameter is set correctly.
  • Make sure the ROBOT_VERSION environment variable is set correctly (currently supported versions: 45, 49).
  • If sensor data recording is abnormal, check whether the /sensors_data_raw topic is published normally.
  • If a service call fails, check whether the service has started normally and whether the parameters are correct.