Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplement computeTorque() for Accurate B1 Motor Simulation #89

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

paulblum
Copy link

Description:

This pull request addresses issue #66, which identifies the clamping of joint torque commands to ±55 Nm by UnitreeJointController. This limitation hinders the accurate simulation of B1 motors, which have ±140 Nm capability.

The impact is evident in the following visualizations, where B1 is commanded to trot in place:

b1_default b1_default
B1 attempting to trot in Gazebo Torque clamping to 55 Nm

Problem:

The issue lies in UnitreeJointController's usage (line 180, below) of the computeTorque() function from unitree_ros/unitree_legged_control/lib, which inadvertently clamps its output to ±55 Nm.

currentPos = joint.getPosition();
currentVel = computeVel(currentPos, (double)lastState.q, (double)lastState.dq, period.toSec());
calcTorque = computeTorque(currentPos, currentVel, servoCmd);
effortLimits(calcTorque);

Notably, this clamping is redundant, as the joint torque computation is already clamped to URDF specifications (line 181, above) by the effortLimits() function.

Solution:

This pull request proposes the removal of the ±55 Nm clamp from computeTorque(), introducing the following implementation:

calcTorque = servoCmd.torque + servoCmd.posStiffness*(servoCmd.pos - currentPos)
    + servoCmd.velStiffness*(servoCmd.vel - currentVel);

Rationale:

This modification allows for the utilization of UnitreeJointController to accurately simulate B1 control, while preserving its original functionality for smaller quadrupeds.

b1_updated b1_updated
B1 trotting in Gazebo via updated code Update enables accurate B1 torque computation
a1_updated a1_updated
A1 trotting in Gazebo via updated code Update maintains identical torque computation in the [-55,55] Nm range

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant