Case Study: Looking into robot_lab
Last updated
Was this helpful?
Last updated
Was this helpful?
robot_lab provides both the normal training pipeline and also the AMP version. In this article, we will focuse on the AMP training pipeline.
First, we need to define the robot dimensions and mocap data attributes
These FK chains are used for solving the foot local positions
first, we create pybullet simulation
we iterate through all the mocap data specified in config.MOCAP_MOTIONS
for each mocap data, we need to reset the pybullet simulation, re-add the ground and robot urdf, and then set the robot pose to be the init pose.
For following section, we will use example reference motiondog_walk00_joint_pos.txt
Then, we load the reference motion txt.
81 floating point numbers on each line, which corresponds to 27 marker positions (x, y, z)
mapping is as follows
then, we clip out the unused frames, after concat
reshape to each position tracker's position
We then know that there are 27 mocap markers used in this motion sequence
process_ref_joint_pos_data
The purpose of these transformations is to match the frame between robot and mocap data by:
Convert from the motion capture coordinate system to the simulation coordinate system (first rotation)
Orient the motion in the desired direction (second rotation)
Scale and offset the positions to match the robot's size and starting position
the main magic happens in the retarget_pose() function, which takes in the robot URDF, the default joint pose, and the reference marker positions
first, it gets the joint limit from the URDF
then, to do the motion retargeting, it will
get ref_hip_pos and ref_toe_pos, calculate the distance between these two points as ref_hip_toe_delta
ref_hip_toe_delta = ref_toe_pos - ref_hip_pos
get hip position in sim as sim_hip_pos
the target toe position in sim should be sim_tar_toe_pos = sim_hip_pos + ref_hip_toe_delta
however, override the toe height (z) to be directly the mocap height, as we have already calibrated this in the previous step, and we want to maintain the same contact
so far everything is in local frame, now we convert it to world frame by sim_tar_toe_pos += toe_offset_world