Hi @Anant_Rai, good question! Each of the roll/pitch/yaw Dex Wrist joints have offset parameters you can use to correct any misalignment. Here’s a manual procedure you could use to fix the offsets:
Command small increments, less than 0.1 rad, through move_by() while checking the bubble. Note: you may find the pitch joint won’t perfectly get the bubble centered vertically because it keeps slipping a small amount. This happens because there’s a sentry in Stretch Body dedicated to preventing the Dynamixel joints from “overloading”, i.e. a soft failure state where the Dxl motor uses more current to hold a position than is safe. The sentry asks the pitch joint to back off a small amount, which greatly reduces the current used, while remaining close to the commanded position (source code for the sentry here). You can temporarily turn off the sentry in iPython using the code below, or turn it off permanently if you don’t want that behavior to affect your experiments (keeping in mind that if a Dxl motor overloads, it will drop its position and become uncommand-able until reset) by setting the robot_sentry.wrist_<pitch/roll/yaw>_overload parameter in your “stretch_user_params.yaml”.
The offset parameter for Dxl joints is defined in “ticks”, which is the smallest unit of motion for the motor. We can read the joint’s current position in ticks using the status dictionary:
In [30]: r.end_of_arm.get_joint('wrist_pitch').status['pos_ticks']
Out[30]: 993
In [31]: r.end_of_arm.get_joint('wrist_roll').status['pos_ticks']
Out[31]: 2080
The output above tells me that my Dex Wrist is leveled at pitch position 993 ticks and roll position 2080 ticks.
Since the yaw joint doesn’t affect the level tool’s reading, you can visually calibrate it by using step 4-5 until the wrist is pointed out and away from the robot.
You can now close the Robot class using r.stop() and exit out of iPython.
The offset parameter for a Dxl joint is called zero_t. We can query the current offsets for the roll/pitch/yaw joints using: