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

Parse URDF joint hard limits into the HardwareInfo structure #1472

Conversation

saikishor
Copy link
Member

This PR allows to parse the joint_limits into the HardwareInfo structure, so that this can be later reused by the ResourceManager to enforce the limits on the JointCommandInterfaces.

The joint limits that are available in the HardwareInfo structure are basically parsed from the URDF joint limits, and these joint limits range can be reduced with the <min> and <max> tag of each command interface, the idea is to be able to always be able to conservative.

There will be a following PR on parsing the SoftLimits as well

Copy link

codecov bot commented Apr 17, 2024

Codecov Report

Attention: Patch coverage is 94.19355% with 9 lines in your changes are missing coverage. Please review.

Project coverage is 88.53%. Comparing base (7fdf472) to head (8e0d86e).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1472      +/-   ##
==========================================
+ Coverage   88.42%   88.53%   +0.10%     
==========================================
  Files         101      101              
  Lines        8349     8502     +153     
  Branches      728      759      +31     
==========================================
+ Hits         7383     7527     +144     
- Misses        703      706       +3     
- Partials      263      269       +6     
Flag Coverage Δ
unittests 88.53% <94.19%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
hardware_interface/test/test_component_parser.cpp 100.00% <100.00%> (ø)
hardware_interface/src/component_parser.cpp 92.74% <91.34%> (-0.60%) ⬇️

Copy link
Contributor

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is clear and the implementation looks fine. However, a couple of lines miss coverage, especially in the update_interface_limits lambda

hardware_interface/src/component_parser.cpp Outdated Show resolved Hide resolved
hardware_interface/src/component_parser.cpp Outdated Show resolved Hide resolved
hardware_interface/src/component_parser.cpp Outdated Show resolved Hide resolved
hardware_interface/src/component_parser.cpp Outdated Show resolved Hide resolved
hardware_interface/src/component_parser.cpp Outdated Show resolved Hide resolved
hardware_interface/src/component_parser.cpp Outdated Show resolved Hide resolved
@saikishor
Copy link
Member Author

saikishor commented Apr 22, 2024

10 lines are still not covered, and total coverage will decrease. should I try to add tests to run into this failure cases?

Sure. if you can, it would be really helpful. Thanks @christophfroehlich

max_vel = std::min(std::abs(min_vel), max_vel);
limits.max_velocity = std::min(max_vel, limits.max_velocity);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity why you do not do a default initialization of the max_velocity ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean by default initialization? limits will be filled from the URDF tag, which is mandatory for REVOLUTE and PRISMATIC joints -> max_velocity is already populated

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, moreover, there might be a joint without velocity limits, so it doesn't make sense

max_eff = std::min(std::abs(min_eff), max_eff);
limits.max_effort = std::min(max_eff, limits.max_effort);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here wrt to max_effort

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well same as above

{
limits.max_jerk = std::abs(max_jerk);
limits.has_jerk_limits = true && itr.enable_limits;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here for max_jerk

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jerk limits are very familiar as the support in ROS is little, so I think it is better to leave it up to the user

@saikishor
Copy link
Member Author

@christophfroehlich Thanks for helping out and adding very nice tests

Copy link
Contributor

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just let us add some notes about this once #1477 is merged.

@saikishor
Copy link
Member Author

Just let us add some notes about this once #1477 is merged.

Sure. I will do that :)

{
limits.max_acceleration = std::fabs(limits.max_deceleration);
}
limits.has_deceleration_limits = true && itr.enable_limits;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this pattern of true && in a couple of places. Why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, it can be simply itr.enable_limits. I will make the modifications soon and let you know

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. This is fixed now. 👍

@bmagyar bmagyar merged commit 607755e into ros-controls:master May 7, 2024
10 of 12 checks passed
@saikishor saikishor deleted the parse_limits_from_urdf_to_hw_info branch August 17, 2024 08:22
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.

4 participants