-
Notifications
You must be signed in to change notification settings - Fork 337
Use previous command to enforce the joint limits on position interfaces #2183
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
Use previous command to enforce the joint limits on position interfaces #2183
Conversation
… always within hard limits
With the ur_robot_driver the problem with limits mostly seems to be arising from the tracking error. Since the hardware needs a couple of cycles to reach a command and report it through its state interfaces, the value read from the state interfaces as "actual" might be lacking behind what we want to command to the robot. As the soft limiter checks the "actual" position with a maximum step size given the maximum joint velocity multiplied by the cycle time. This effectively reduces the velocity with which a joint can move along. See below screenshot for details: The joint speed is limited (much below the actual joint limit) due to that. I had success with effectively swapping saving the last command or the "actual" position into the ros2_control/joint_limits/src/joint_soft_limiter.cpp Lines 100 to 107 in 65340a4
Specifically: if ( prev_command_.has_data() && prev_command_.has_position() && std::isfinite(prev_command_.position.value()))
{
position = prev_command_.position.value();
}
else if (actual.has_position() && std::isfinite(actual.position.value()))
{
position = actual.position.value();
} |
Tested things with the latest version of this and that definitively resolves our issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all seems to make sense to me and fixes things when running with a UR.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2183 +/- ##
==========================================
- Coverage 89.18% 89.10% -0.09%
==========================================
Files 139 139
Lines 16096 16105 +9
Branches 1382 1388 +6
==========================================
- Hits 14356 14350 -6
- Misses 1216 1225 +9
- Partials 524 530 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good, I just have one question:
What exactly is the mutex for? As I understand, it should avoid that limiting and resetting can happen at the same time.
In reality this should not happen, since ResourceManager::perform_command_mode_switch
and on_enforce
happen in the same thread, right?
If they would be running in separate threads, the two lock guards would potentially block each other either reset_internals
or on_enforce
taking longer that it should running on its own. This would be potentially violating cycle-time constraints.
@fmauch I've added this because when you run a controller or a hardware component as asynchronous. This case might happen, where enforce might be called in parallel. This is to protect these cases especially. The good thing is both the threads are on high priority, so there should be less likely chance or only minimal time blockage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea makes sense for me, and the changes LGTM
495d2b7
into
ros-controls:master
This PR partially reverts the changes proposed in the PR : #1988 and the corresponding changes introduced into the JointLimits integration PR : 7846f6a
Additionally, if the actual position is outside the joint limits completely, then it will throw an exception to avoid controlling the joint and probably causing self collision