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

improve RobotState::updateStateWithLinkAt() #765

Merged
merged 5 commits into from
Feb 21, 2018

Conversation

rhaschke
Copy link
Contributor

Improve documentation for RobotState::updateStateWithLinkAt(). For me it was unclear, which transforms were updated and which were marked dirty.

If argument backward = true is passed, mark all collision body transforms as dirty.

Provide utility function RobotModel::getRigidlyConnectedParentLinkModel() to find the top-most parent link that is ridigly linked to the given link. Usually, when placing a link with RobotState::updateStateWithLinkAt(), this parent link should be used.

@rhaschke
Copy link
Contributor Author

@davetcoleman I accidentally pushed this as a PR branch to ros-planning first. The failed build only exists, because I immediately removed this branch again and Travis could find the branch anymore...
The PR build passed smoothly.

@@ -239,6 +239,9 @@ class RobotModel
/** \brief Get a link by its name. Output error and return NULL when the link is missing. */
LinkModel* getLinkModel(const std::string& link);

/** \brief Get earliest link model that is rigidly connected to the given link */
Copy link
Member

Choose a reason for hiding this comment

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

define "earliest" - is this the parent link? the root link? i guess with the term rigidly it means:

joint1 - linkA - fixedJoint1 - linkB
getRigidlyConnectedParentLinkModel(linkB)

return linkA correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, obviously comment was too brief. I added more explanation.

return it->second;
logError("Link '%s' not found in model '%s'", name.c_str(), model_name_.c_str());
return NULL;
return const_cast<RobotModel*>(this)->getLinkModel(name);
Copy link
Member

Choose a reason for hiding this comment

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

i don't understand - wouldn't this be recursive and not work?

why remove the helpful logError message?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This simply relays the call to the otherwise fully identical non-const version of the function.
Removing the constness via const_cast ensures that it is not recursive.
The log message is retained from the non-const version.

Copy link
Contributor

Choose a reason for hiding this comment

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

For aesthetic reasons I prefer to cast the other way around (make the non-const function call the const version) so that you don't have to cast const-ness away.

Apart from that this method is perfectly valid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case you would have to cast constness away for the result type: const LinkModel* -> LinkModel*, which then requires two const_casts. In my opinion that's even harder to read, although it better matches the semantics. However, this is cosmetics.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, that explains why you chose to do it this way around.
I agree that this is cosmetics. No need to get out the eye liner :)

Copy link
Member

Choose a reason for hiding this comment

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

+1

The link transforms of link and all its descendants are updated, but not marked as dirty,
although they do not match the joint values anymore!
Collision body transforms are not yet updated, but marked dirty only.
Use update(false) or updateCollisionBodyTransforms() to update them as well.
Copy link
Member

Choose a reason for hiding this comment

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

great documentation!

// position_ +
// parent_link->getParentJointModel()->getFirstVariableIndex());
// all collision body transforms are invalid now
dirty_collision_body_transforms_ = parent_link->getParentJointModel();
Copy link
Member

Choose a reason for hiding this comment

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

i think this could adversely impact existing MoveIt! setups so we should not backport to Indigo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This indeed changes behavior: It allows to update and subsequently use the warped collision transforms.
However, I don't see why this bug fix shouldn't be worth backporting.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that this causes more computational load when someone uses this (rather unusual) function with the backward parameter, but I don't see why we shouldn't backport it: without it the outdated transforms go unmarked.

Copy link
Member

Choose a reason for hiding this comment

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

because it changes behavior on existing systems in ways we can't predict, and indigo is old and is suppose to be stable

Copy link
Contributor

Choose a reason for hiding this comment

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

To clarify (please confirm @rhaschke) if you currently use updateStateWithLinkAt(... backward=true) in indigo, the code will use invalid transforms for collision checking (or it asserts and quits in debug build).
This is the only behavior these lines change by requiring an update of the invalid transforms.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't use Indigo, and I didn't use updateStateWithLinkAt(... backward=true) either. I just discovered that the collision transforms are not (and cannot be) updated without this change.

* what you went for. Instead, updateStateWithLinkAt(getRigidlyConnectedParentLinkModel(grasp_frame), ...)
* will actually warp wrist (and all its descendants).
*/
static const moveit::core::LinkModel* getRigidlyConnectedParentLinkModel(const LinkModel* link);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

My main question with this function is where to put it.

  1. Leave it here in RobotModel as a static function?
  2. Define it as a member of LinkModel?
  3. Put it (as a static function again) into RobotState. i.e. the vicinity of updateStateWithLinkAt()?

The order resembles my preference. @davetcoleman @v4hn Any other opinions?

Copy link
Contributor

Choose a reason for hiding this comment

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

Personally I think you picked the best spot already. I vote to keep it in RobotModel together with all the getLink functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@davetcoleman If you agree too, I think this is ready for merging.

Copy link
Member

Choose a reason for hiding this comment

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

+1 LinkModel. Def not RobotState but option 2 works also for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So then we agree on this. Could anybody of you finally accept / merge this PR?

@v4hn v4hn merged commit 61e2e30 into moveit:kinetic-devel Feb 21, 2018
@rhaschke rhaschke deleted the warp-link branch February 21, 2018 22:45
JafarAbdi pushed a commit to JafarAbdi/moveit that referenced this pull request Mar 24, 2022
Co-authored-by: Tyler Weaver <tyler@picknik.ai>
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.

None yet

3 participants