Strategy Module Box-Carrying Case
- Strategy Module Box-Carrying Case
⚠️⚠️⚠️ Note: The comprehensive case is a reference case with relatively high complexity. Using this case requires foundational knowledge in the relevant field.
⚠️⚠️⚠️ Note: The comprehensive case is not a standard delivered feature and is provided for reference only.
(I) Case Introduction
Case Features
-
Precise localization of the box and shelf based on AprilTag recognition
-
Completion of the entire workflow of grasping, transporting, and placing the box
Case Workflow Logic
-
The robot autonomously moves to the preset box position
-
The robot rotates its head to scan the box's AprilTag → precise localization → approaches the operating position
-
Controls the robotic arm with a combination of position control and force control to grasp the box
-
Autonomously moves to the preset shelf position
-
Rotates its head to scan the shelf's AprilTag → precise localization → approaches the placement position
-
Completes box placement → returns to the starting point
Note: Testing has shown that carrying boxes with a clamp plate is more stable, so users are advised to replace the end effector with a clamp plate.
Clamp Plate Replacement Instructions
Preparing the Clamp Plate Materials
-
Users need to contact a 3D printing vendor to print the clamp plate themselves; metal machining is recommended for better results
- Model file location in the Gitee repository:
https://gitee.com/leju-robot/kuavo-ros-opensource/tree/master/docs/models 3D printing filelocation:~/kuavo-ros-opensource/docs/models/手掌板.STEP2D machining drawinglocation:~/kuavo-ros-opensource/docs/models/手掌板.pdf
- Model file location in the Gitee repository:
-
For the material and related machining requirements, please refer to the content in the
2D machining drawing
Replacing the Dexterous Hand with a Clamp Plate
-
If the end effector of your robot is a dexterous hand, follow the steps below to replace the dexterous hand with a clamp plate
-
The right-hand dexterous hand is used as an example here; follow the same steps for the left hand
-
Remove the screws in the red circles (there is one more on the back, three in total), and detach the housing as shown in the figure

-
Remove the screws in the red circles (there are two more on the back, four in total), and detach the dexterous hand (be sure to support it to prevent it from falling)

-
Unplug the cable on the dexterous hand; press the point indicated by the arrow and pull it out

-
Insert the clamp plate into the structural part shown in the figure from below, tighten the screws (there are two more on the back, four in total), and secure the clamp plate (pay attention to the installation orientation of the clamp plate)

-
Reinstall the arm housing removed in the first step; the final result is shown in the figure

-
Replacing the Self-Developed Gripper with a Clamp Plate
-
If the end effector of your robot is the Leju self-developed gripper, first print the replacement bracket and perform the replacement
-
Material file location of the replacement bracket:
- Model file location in the Gitee repository:
https://gitee.com/leju-robot/kuavo-ros-opensource/tree/master/docs/models 3D printing filelocation:~/kuavo-ros-opensource/docs/models/手掌连接主支架.STEP2D machining drawinglocation:~/kuavo-ros-opensource/docs/models/手掌连接主支架.pdf
- Model file location in the Gitee repository:
-
For the material and related machining requirements, please refer to the content in the
2D machining drawing
-
-
Replacement steps (the left-arm gripper is used as an example here):
-
Remove the screws in the red circles (five in total, across the two images)

-
Use a flathead screwdriver or a similar tool to pry the structural part open little by little at the point indicated by the arrow

-
After prying the structural part open, remove the screws in the red circles (four in total)

-
Press the point indicated by the arrow to detach the gripper communication cable, and the gripper can then be removed

-
After removing the gripper, install the replacement bracket; the remaining steps are the same as those in Replacing the Dexterous Hand with a Clamp Plate
-
Case Materials
-
The box must be purchased by the user; the plastic folding box shown in the figure is recommended (box dimensions: outer 400 * 300 * 230 mm)

-
The shelf must be purchased by the user; the shelf shown in the figure is recommended (at least three tiers are required; shelf dimensions: 1500 * 400 * 2000 mm)

-
Bill of materials for setting up the box-carrying scenario

Video Demonstration
(II) Code Repository Configuration
Note: The code repository configuration only needs to be performed once. After that, simply re-run the program after modifying parameters.
Compiling the Host Computer Code
- Compile the relevant packages:
cd ~/kuavo_ros_application
git checkout opensource/navigation_demo
catkin build apriltag_ros
catkin build kuavo_camera dynamic_biped kuavo_tf2_web_republisher Compiling the Onboard Computer Code
- Install the dependency environment
# 更新软件源
sudo apt-get update
# grab_box功能包相关依赖
sudo apt-get install ros-noetic-behaviortree-cpp-v3 ros-noetic-roslint ros-noetic-eigen-conversions -y
sudo apt-get install libgeographic-dev ros-noetic-geographic* -y- Compile the relevant packages:
cd ~/kuavo-ros-opensource
git checkout opensource/kuavo4pro_course_code
sudo su
catkin clean -y
catkin config -DCMAKE_ASM_COMPILER=/usr/bin/as -DCMAKE_BUILD_TYPE=Release
source installed/setup.bash
catkin build humanoid_controllers kuavo_msgs gazebo_sim ar_control grab_box Installing kuavo-humanoid-sdk on the Onboard Computer
cd ~/kuavo-ros-opensource/src/kuavo_humanoid_sdk/
./install.shResolving Errors
-
If the previous configuration steps completed normally without errors, you can skip this section
-
If
git checkoutreportsPlease commit your changes or stash them before you switch branches.- Cause: code from another branch has been compiled locally, or there are locally modified files
- Solution: manually back up the code you need, then run
git reset --hard; after that, you can rungit checkoutto switch branches
-
If
git checkoutreportsPermission Denied- Cause: git operations were previously performed locally under the sudo user
- Solution: on the onboard computer, run
sudo chmod 777 /home/lab/kuavo-ros-opensource -R; after that, you can rungit checkoutto switch branches
-
If
sudo apt updatereports an error- You need to manually update the ROS repository by following the steps below
# 删除现有 ROS 密钥 sudo apt-key del F42ED6FBAB17C654 # 重新导入 ROS 官方密钥 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys F42ED6FBAB17C654 # 更新密钥环 sudo apt update- After that, run
sudo apt updateagain
(III) Preset Parameter Adjustment
⚠️⚠️⚠️ Note: After adjusting parameters, it is recommended to test in the Gazebo simulation first, and only run on the real robot after confirming the results are correct.
File location: src/kuavo_humanoid_sdk/examples/strategies/grasp_box_example.py
Distance Configuration
- The stopping distance between the robot and the AprilTag during grasping/placement (must not be negative):
GRASP_DISTANCE = 0.28 # 抓取时与AprilTag的距离(米)
PLACE_DISTANCE = 0.53 # 放置时与AprilTag的距离(米)Intermediate Position Configuration
- When the AprilTag at the placement position is behind the robot, the robot needs to first move to the intermediate position before turning to recognize it:
MID_POSITION = (-0.5, 0.0) # 中间位置坐标 (odom坐标系)Box and Shelf AprilTag Configuration
-
AprilTag information attached to the box: AprilTag ID, tag size (in meters), and the approximate pose in the odom coordinate frame
- When using it, users need to modify the AprilTag ID and tag size to match the actual setup
target_april_tag = AprilTagData( id=[1], # AprilTag ID size=[0.1], # AprilTag 标签尺寸 pose=[PoseQuaternion( # TODO: 需要根据实际情况调整 position=(1.0, 0.0, 0.8), # 基于odom坐标系下的大致位置, 查找时会对齐到这个方向 orientation=(0.0, 0.0, 0.0, 1.0) # 四元数方向 )] ) -
AprilTag information attached at the placement position (shelf): AprilTag ID, tag size (in meters), and the approximate pose in the odom coordinate frame
- When using it, users need to modify the AprilTag ID and tag size to match the actual setup
placement_april_tag = AprilTagData( id=[2], # 放置位置的AprilTag ID size=[0.1], # AprilTag 标签尺寸 pose=[PoseQuaternion( # TODO: 需要根据实际情况调整 position=(-1.0, 0.0, 0.8), # 放置位置的大致坐标 orientation=(0.0, 0.0, 1.0, 0.0) # 四元数方向 - 旋转180度 )] )
Box Information Settings
- Describes the box information: width, length, height (in meters) and box weight (in kg)
- The box parameters in the example are used here; when using it, users need to fill in values according to the actual situation
box_size = (0.3, 0.4, 0.22) # xyz(宽, 长, 高) 单位是米
box_mass = 1.5 # 箱子重量 (单位是kg)Grasp Point Offset Configuration
xyz_offsetis the offset relative to the AprilTag center, used to shift the coordinates from the tag plane to the box center:
box_info = BoxInfo.from_apriltag(
box_tag_data,
xyz_offset=(box_size[0]/2 + 0.03, 0.0, -0.06), # tag粘贴在箱子正面,偏移到箱子中心
size=box_size,
mass=box_mass
)Preset Arm Poses (Adjustable via the Arm Software)
- Preset joint angles (in degrees) that the arm passes through in sequence before grasping; each set contains 14 joints: 7 for the left arm + 7 for the right arm:
ARM_POSES = {
# 安全收起姿态
"side": [
20, 90.8, 0.0, -30, 0.0, 0.0, 0.0, # 左臂
20, -90.8, 0.0, -30, -0.0, 0.0, 0.0 # 右臂
],
"safe": [
7.6, 68.8, 0.0, -90.8, 77.1, 0.0, 0.0, # 左臂
7.6, -68.8, 0.0, -90.8, -77.1, 0.0, 0.0 # 右臂
],
# 手臂抬高准备姿态(避免撞到桌子)
"prepare_high": [
7.6, 68.8, -25.0, -90.8, 77.1, 0.0, 0.0, # 左臂
7.6, -68.8, 25.0, -90.8, -77.1, 0.0, 0.0 # 右臂
],
}Fallback Placement Position
- When the AprilTag at the placement position cannot be recognized, a fixed coordinate is used as a fallback:
placement_pose = KuavoPose(
position=(0.5, 0.0, 0.8), # 目标放置位置坐标(机器人正前方0.5m)
orientation=(0.0, 0.0, 0.0, 1.0) # 目标放置方向(四元数)yaw=0°
)(IV) Running on the Real Robot
⚠️⚠️⚠️ Note: Make sure the robot joints have been calibrated with the zero-point fixture. See: Robot Joint Calibration
⚠️⚠️⚠️ Note: Make sure the robot's head zero point and arm zero points are correct
⚠️⚠️⚠️ Note: After the robot stands up, it is recommended to step in place first and observe the robot's state. Proceed with subsequent operations only after confirming the robot is in a normal state
⚠️⚠️⚠️ Note: In the current version, the robot does not squat when grasping the box. The platform where the box is located must be between 0.7 m and 0.9 m high; outside this range, the arm may not be able to reach the grasp position
Environment Configuration
- On the host computer, first modify the
~/kuavo_ros_application/src/ros_vision/detection_apriltag/apriltag_ros/config/tags.yamlfile and change the tagsizeto the actual size, for example 0.1 meters
standalone_tags:
[
{id: 0, size: 0.1, name: 'tag_0'},
{id: 1, size: 0.1, name: 'tag_1'},
{id: 2, size: 0.1, name: 'tag_2'},
{id: 3, size: 0.1, name: 'tag_3'},
{id: 4, size: 0.1, name: 'tag_4'},
{id: 5, size: 0.1, name: 'tag_5'},
{id: 6, size: 0.1, name: 'tag_6'},
{id: 7, size: 0.1, name: 'tag_7'},
{id: 8, size: 0.1, name: 'tag_8'},
{id: 9, size: 0.1, name: 'tag_9'}
]- The robot uses its standing position as the origin of its coordinate frame; the box is directly in front of the origin (positive x direction), and the shelf is directly behind the origin (negative x direction)
Startup Scene Description
-
The robot uses its standing position as the origin of its coordinate frame and stands facing the positive x-axis
-
The box is directly in front of the robot (positive x direction), and the shelf (placement position) is directly behind the robot (negative x direction)
-
When the robot stands, its standing position must be on the line connecting the box and the shelf, facing the box
-
Detailed position parameters for placing the box and shelf
-
Relative to the robot's standing position, the box should be about 150 cm directly in front of the robot. The box must be placed on a platform 0.7 m to 0.9 m high (the current version of the robot does not squat; outside this range, the arm cannot reach it). The center of the AprilTag on the box is about 80 cm above the ground.
-
Relative to the robot's standing position, the shelf should be about 150 cm directly behind the robot; the placement tier is about 70 cm high, and the center of the AprilTag on the shelf is about 180 cm above the ground.
-
-
If your usage scenario is exactly the same as the one in this case, you can first adjust the parameters in advance according to Real-Robot Operation Parameter Tuning, and then run on the real robot.
Running on the Host Computer
- Open a terminal on the host computer and run:
cd ~/kuavo_ros_application
source devel/setup.bash
# 根据您的机器人版本运行不同的命令
# 旧版4代, 4Pro
roslaunch dynamic_biped load_robot_head.launch
# 标准版, 进阶版, 展厅版, 展厅算力版
roslaunch dynamic_biped load_robot_head.launch use_orbbec:=true
# Max版
roslaunch dynamic_biped load_robot_head.launch use_orbbec:=true enable_wrist_camera:=true- Open another new terminal and run:
cd ~/kuavo_ros_application
source devel/setup.bash
roslaunch kuavo_tf2_web_republisher start_websocket_server.launchRunning on the Onboard Computer
Note:
⚠️⚠️⚠️ Make sure you have read (III) Preset Parameter Adjustment and completed the checks of the corresponding configuration items
⚠️⚠️⚠️ Due to IMU drift and the robot's condition, if continuous carrying is required, it is recommended to shut down the program and let the robot stand up again after three carries; under good robot conditions this can achieve a box-carrying success rate of over 90%
- Open terminal 1 on the onboard computer and make the robot stand up (a tmux terminal is recommended to prevent the terminal from disconnecting due to network issues):
cd ~/kuavo-ros-opensource
sudo su
source devel/setup.bash
roslaunch humanoid_controllers load_kuavo_real.launch joystick_type:=bt2pro- Open terminal 2 on the onboard computer and start the Tag Tracker node:
cd ~/kuavo-ros-opensource
sudo su
source devel/setup.bash
roslaunch ar_control robot_strategies.launch real:=true- Open terminal 3 on the onboard computer and run the box-carrying example:
Command-line parameter description:
| Parameter | Description |
|---|---|
--sim | Simulation mode (not required for real-robot operation) |
--velocity-control | Use velocity control mode (smoother motion, recommended) |
--wait-for-bottle | Wait for the bottle-grasping task completion signal before starting (for continuous tasks) |
cd ~/kuavo-ros-opensource
sudo su
source devel/setup.bash
cd src/kuavo_humanoid_sdk/examples/strategies
# 基本运行(默认单步控制模式)
python3 grasp_box_example.py
# 使用速度控制模式(推荐,运动更平滑)
python3 grasp_box_example.py --velocity-controlParameter Adjustment for Real-Robot Operation
-
Because the condition of each robot differs and the boxes may also differ, users may need to adjust the grasping or placement parameters according to the actual situation
-
Adjust the grasping/placement distance (
GRASP_DISTANCE/PLACE_DISTANCE)- If the distance between the robot's stop position and the box or shelf is not appropriate, adjust the distance configuration at the top of the file:
GRASP_DISTANCE = 0.28 # 抓取时与AprilTag的距离(米) PLACE_DISTANCE = 0.53 # 放置时与AprilTag的距离(米) -
Adjust the intermediate position (
MID_POSITION)- If the robot's carrying path needs to pass through a different intermediate point, adjust:
MID_POSITION = (-0.5, 0.0) # 中间位置坐标 (odom坐标系) -
If the box grasp point is too far forward (positive x direction of the robot)
- You need to adjust the first parameter of
xyz_offset:
# 调整前 box_info = BoxInfo.from_apriltag( box_tag_data, xyz_offset=(box_size[0]/2 + 0.03, 0.0, -0.06), size=box_size, mass=box_mass ) # 调整示例:x方向减小0.05m box_info = BoxInfo.from_apriltag( box_tag_data, xyz_offset=(box_size[0]/2 + 0.03 - 0.05, 0.0, -0.06), size=box_size, mass=box_mass ) - You need to adjust the first parameter of
-
Adjust the arm preset poses
- If you need to adjust the preset points the arm passes through, modify the joint angles (in degrees) of the corresponding pose in the
ARM_POSESdictionary:
ARM_POSES = { "safe": [ 7.6, 68.8, 0.0, -90.8, 77.1, 0.0, 0.0, # 左臂7个关节角度 7.6, -68.8, 0.0, -90.8, -77.1, 0.0, 0.0 # 右臂7个关节角度 ], } - If you need to adjust the preset points the arm passes through, modify the joint angles (in degrees) of the corresponding pose in the
Troubleshooting
| Issue | Solution |
|---|---|
| AprilTag not found | Check the tag ID configuration (box ID = 1, placement position ID = 2), and check the size configuration and lighting conditions |
| Grasping failed | Adjust the GRASP_DISTANCE parameter or the xyz_offset offset |
| Placement failed | Adjust the PLACE_DISTANCE parameter |
| Unstable walking | Use the --velocity-control parameter, or check the box weight and arm pose configuration |
| Placement position not recognized | Check the MID_POSITION intermediate position setting to ensure the robot can turn to recognize the AprilTag |
| WebSocket connection failed | Confirm that the kuavo_tf2_web_republisher service is running |
| basePitch limit warning | The program automatically disables the limit; if the problem persists, check the robot status |