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

README clean up and integration of Kinematic limits from Robot Model #49

Merged
merged 9 commits into from
Oct 4, 2024

Conversation

kamiradi
Copy link
Member

@kamiradi kamiradi commented Sep 18, 2024

This PR addresses #45.

  • Adds Position, Velocity and Acceleration limits from moveit - variable bounds
  • Adds Jerk bounds from parameter header
  • Cleans up README.md

This commit adds upper/lower position/velocity bounds. Reads them from
the robot model VariableBound API and sets them up as Drake
PositionBund and VelocityBound constraints. Adds some additional docs on
readme
Copy link
Contributor

@sea-bass sea-bass left a comment

Choose a reason for hiding this comment

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

Might be easier to break this up task by task, so it's faster to review smaller things and get them in. Would recommend finishing up what you've got so far and then following this suggestion.

README.md Outdated
Comment on lines 14 to 15
- Exposes `KinematicTrajectoryOptimization` implementation in `drake`.
- Exposes `TOPPRA` implementation in `drake`.
Copy link
Contributor

Choose a reason for hiding this comment

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

consider links to Drake docs

Comment on lines 6 to 7
# validation: {
# gt_eq<>: [1]
Copy link
Contributor

Choose a reason for hiding this comment

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

remove

Comment on lines 66 to 69
// std::cout << "Joint " << joint_name << ": Position ["
// << bounds.min_position_ << ", " << bounds.max_position_
// << "], Velocity [-" << bounds.max_velocity_ << ", "
// << bounds.max_velocity_ << "]" << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

remove

Comment on lines 71 to 72
int num_positions = plant.num_positions();
int num_velocities = plant.num_velocities();
Copy link
Contributor

Choose a reason for hiding this comment

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

can be const

int num_velocities = plant.num_velocities();

// Ensure the bounds have the correct size
if (lower_position_bounds.size() != num_positions || upper_position_bounds.size() != num_positions)
Copy link
Contributor

Choose a reason for hiding this comment

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

you might get compiler warnings in comparing int with size_t, which requires a static_cast to resolve

@sjahr sjahr linked an issue Sep 24, 2024 that may be closed by this pull request
@kamiradi kamiradi requested a review from sea-bass October 4, 2024 08:17
Copy link
Contributor

@sea-bass sea-bass left a comment

Choose a reason for hiding this comment

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

Left some additional comments, but once addressed this is good for me, so approving.

README.md Outdated

`moveit_drake` brings together the vertical ROS integration of the
[MoveIt2](https://moveit.ai/) motion planning framework, with the Mathematical
Programming interface within [drake](https://drake.mit.edu/). This allows the
Copy link
Contributor

Choose a reason for hiding this comment

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

Capitalize Drake

README.md Outdated
release.

`moveit_drake` brings together the vertical ROS integration of the
[MoveIt2](https://moveit.ai/) motion planning framework, with the Mathematical
Copy link
Contributor

Choose a reason for hiding this comment

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

MoveIt 2 (with a space)

### Potential issues
- Assumes that planner managers initialize will set robot description before a
call to getPlanningContext.
- Use [pre-commit to format your
Copy link
Contributor

Choose a reason for hiding this comment

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

Might want to share the basic command

pre-commit run -a

@@ -48,6 +48,62 @@ void KTOptPlanningContext::solve(planning_interface::MotionPlanResponse& res)
const auto joint_model_group = getPlanningScene()->getRobotModel()->getJointModelGroup(getGroupName());
RCLCPP_INFO_STREAM(getLogger(), "Planning for group: " << getGroupName());

// extract position and velocity bounds
std::vector<double> lower_position_bounds;
Copy link
Contributor

Choose a reason for hiding this comment

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

Try initialize all of these with the known size (number of dofs) for efficiency.

If you initialize them, change the push_backs for modifying existing elements.

Or you can reserve() them in which case you do keep pushing back.

std::vector<double> upper_acceleration_bounds;
for (const auto& joint_model : joint_model_group->getActiveJointModels())
{
const std::string& joint_name = joint_model->getName();
Copy link
Contributor

Choose a reason for hiding this comment

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

This and the next line can just use auto& for the return type

lower_acceleration_bounds.push_back(-bounds.max_acceleration_);
upper_acceleration_bounds.push_back(bounds.max_acceleration_);
}
const int num_positions = plant.num_positions();
Copy link
Contributor

Choose a reason for hiding this comment

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

This and the next line can just be auto

// Ensure the bounds have the correct size
if (lower_position_bounds.size() != num_positions || upper_position_bounds.size() != num_positions)
{
lower_position_bounds.resize(num_positions, -1e6);
Copy link
Contributor

@sea-bass sea-bass Oct 4, 2024

Choose a reason for hiding this comment

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

Instead of using these hard-coded 1e6 magic numbers, consider defining them as constants in an anonymous namespace.

namespace {
constexpr double kDefaultJointMaxPosition = 1.0e6;
}  // namespace

But more importantly, did you find that you needed to pad these vectors? Is this because of the additional joints that are not part of the group?

If that's the case, then you possibly want these extra joints to have big position limits (as you did), but also to use zero vel/accel/jerk limits to ensure they do not move.

Or possibly the position limits just have their min/max set to the current state? Might be even better

Copy link
Member Author

Choose a reason for hiding this comment

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

This was a good catch. On closer inspection, I completely missed that the inactive joints were having their kinematics limits added to the end of each respective (position, vel, accel, jerk) bound vector, instead of being indexed. Corrected now!

@sea-bass
Copy link
Contributor

sea-bass commented Oct 4, 2024

And also, can you change the PR name to more precisely say what this ends up adding? Cleaned up README and kinematic limits from the robot model?

@kamiradi kamiradi changed the title Addresses roscon task list README clean up and integration of Kinematic limits from Robot Model Oct 4, 2024
@kamiradi kamiradi marked this pull request as ready for review October 4, 2024 14:58
@kamiradi kamiradi merged commit bf1bf0b into moveit:main Oct 4, 2024
2 checks passed
@kamiradi kamiradi deleted the roscon_issues branch October 4, 2024 15:06
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.

Remove dependency on hardcoded URDF
2 participants