-
Notifications
You must be signed in to change notification settings - Fork 36
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
Apply Torque Constraints from URDF in Controller #455
Comments
Hi @gergondet, @arntanguy, @mmurooka, @antodld, I am following up on the issue I opened earlier and was hoping someone from your team could respond. As an update, in the meantime, I have tried to apply this tutorial, which suggests that torque constraints can be applied by simply changing
However, the output is unsatisfactory, as it shows a strange motion of the robot attempting to walk without the contacts being properly updated. Could someone provide guidance on resolving this issue? |
Hello, @Ahmadreza-Shahrokhshahi, Regarding the torque limits, they are linked to the "effort" limit in the URDF. After running a few tests on my end, I didn't notice any limit violations. However, it's possible that the logger isn't displaying the proper limit. To verify this, could you please add the following lines to the controller constructor function: for (int i = 0 ; i < robot().mb().nrJoints() ; i++)
{
for (int j = 0 ; j < robot().mb().joint(i).dof() ; j++)
{
const std::string name = robot().mb().joints()[i].name();
logger().addLogEntry("tau_qp_" + name + "_" + std::to_string(j),[this,i,j] () -> const double {return robot().mbc().jointTorque[i][j];});
logger().addLogEntry("tau_lim_up_"+name + "_" + std::to_string(j),[this,i,j] () -> const double {return robot().tu()[i][j];});
logger().addLogEntry("tau_lim_low_"+name + "_" + std::to_string(j),[this,i,j] () -> const double {return robot().tl()[i][j];});
}
} It should log the current value used in the controller (including the floating base where all values should be at 0).
By modifying this line, it is possible that you have set an infinite forces limit to the floating base free-joint which discard the real dynamic of the robot. Concerning the contact declared, in case of walking, it is necessary to remove them and add periodically depending on the support phase |
@antodld
I am working on a custom biped robot, and the controller is similar to this one.
I already have that part of the code you provided. It’s actually available in mc_rtc as I have analyzed the difference between them based on this issue. I can confirm that It seems that
I would appreciate any insights from other contributors as well@arntanguy @gergondet @mehdi-benallegue |
The QP is formulated having the joint accelerations as the decision variables. Those variables are then integrated twice and fed to the simulation environment. Choreonoid then simulate a PD behavior on each joints. This is why you have no guarantee to obtain similar torque as choreonoid does not directly use the joints torques information. Moreover, if your controller is similar to lipm_walking controller, it means that you are using a stabilizer. The stabilizer computes a wrench distribution on the contacts that is not linked to the one computed by the QP. This discrepancy can then be seen in the torque measurements. Keep in mind that in a position control loop, the QP state is open loop which means that any discrepancies in the robot state such as oscillation are not considered. The stabilizer is an exception but the desired forces being applied through admittance tasks, the discrepancies remains.
|
Dear @gergondet and @arntanguy,
I am currently working on applying torque constraints to the robot joints using the
effort
limits specified in the URDF file. Initially, I expected that theeffort
limits would be automatically applied by the system, similar to position and velocity limits. However, it appears that a dynamics constraint needs to be explicitly added to the controller to enforce the torque constraints.To address this, I declared an object of the
DynamicsConstraint
class in the controller header as follows:mc_solver::DynamicsConstraint robotTorqueConstraint = mc_solver::DynamicsConstraint(this->robots(), 0, this->timeStep, {0.01, 0.001, 0.05}, 1.0, false);
In declaration, I used the one with the
damper
andvelocityPercent
since the other one would cause a QP failure once it is called.Then, I added this constraint to the solver in the controller:
robotTorqueConstraint.addToSolver(solver());
Additionally, I adjusted the default minimum and maximum torque values in
Robot.cpp
from zero to infinity to allow the robot to walk:fill_bound(mb, "lower torque", bounds.at(4), &rbd::Joint::dof, -INFINITY, -INFINITY),
fill_bound(mb, "upper torque", bounds.at(5), &rbd::Joint::dof, INFINITY, INFINITY)
Without these adjustments, the robot exhibits sudden, erratic movements and is unable to walk.
At this point, the robot walks without any issues, but it seems that the torque constraints specified in the URDF file are not being applied to the system.
The above image shows that the robot walked a few steps with the
effort
limit set to 100 for all joints. The joint torques and limits are shown only forL_HIP_R
andR_HIP_R
for clarity, but the same issue is observed for the other joints. Despite this, it is evident that the joint torques exceed these limits. I have double-checked the torque limits in the controller, and they match the URDF.Could you please advise if there are any additional modifications or steps required to ensure that the torque constraints are correctly enforced?
Thank you for your assistance.
The text was updated successfully, but these errors were encountered: