-
Notifications
You must be signed in to change notification settings - Fork 938
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
Fixed bugs in computation of AABB in LinkModel and RobotState. #699
Conversation
I prefer breaking ABI over breaking stuff! Good catch! |
@simonschmeisser I was more asking for investigation if the fix could be rewritten in a way not to break ABI :) Maybe people know some good tricks. The basic ABI breaker seems to be addition of |
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.
Thanks so much for these changes!
/********************************************************************* | ||
* Software License Agreement (BSD License) | ||
* | ||
* Copyright (c) 2013, Ioan A. Sucan |
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 non-standard - Ioan worked for Willow at this time so we don't need both Copyright names, just Willow's
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.
Ah, missed this one. Should I also update the year at Willow Garage?
/* Author: Martin Pecka */ | ||
|
||
#ifndef MOVEIT_CORE_AABB_H | ||
#define MOVEIT_CORE_AABB_H |
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.
should be moveit_robot_model_aabb in all caps
moveit_core/robot_model/src/aabb.cpp
Outdated
/********************************************************************* | ||
* Software License Agreement (BSD License) | ||
* | ||
* Copyright (c) 2013, Ioan A. Sucan |
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.
same
void robot_state::RobotState::computeAABB(std::vector<double>& aabb) const | ||
{ | ||
BOOST_VERIFY(checkLinkTransforms()); | ||
|
||
aabb.clear(); | ||
core::AABB _aabb; |
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.
no underscore before variable name
std::vector<const LinkModel*> links = robot_model_->getLinkModelsWithCollisionGeometry(); | ||
for (std::size_t i = 0; i < links.size(); ++i) | ||
{ | ||
const Eigen::Affine3d& t = getGlobalLinkTransform(links[i]); | ||
Eigen::Affine3d t = getGlobalLinkTransform(links[i]); // intentional copy, we will translate |
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.
can we use better variable names here besides one letter names? i know this was already here like this
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.
Glad! I just wanted the PR to be minimal, but if you think it's time to become more verbose, I'm in ;)
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.
you have a good point, you can do it in a separate PR if you want
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.
feel free to change it as part of this request too, if you like.
return file_string; | ||
} | ||
|
||
virtual void SetUp(){}; |
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.
lowercase first letter
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.
I don't think so...
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.
ROS style guide:
In general, function and class method names are camelCased, and arguments are under_scored
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.
It's overriding https://github.com/google/googletest/blob/master/googletest/include/gtest/gtest.h#L430 , which is SetUp
.
|
||
robot_state::RobotState loadModel(const std::string urdf, const std::string srdf) | ||
{ | ||
boost::shared_ptr<urdf::ModelInterface> parsed_urdf(urdf::parseURDF(urdf)); |
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.
i know we have mixed API, but is it possible to use std::shared_ptr here instead?
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 targeted at indigo-devel. Wouldn't that be a problem? The system gcc on Trusty doesn't know about C++11 (I think).
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.
Ah yes, it should be boost if you are on indigo. Preferably this would only target kinetic, but I understand you might have constraints for this. When we cherry-pick this to kinetic we'll have to switch to std::shared_ptr
int main(int argc, char** argv) | ||
{ | ||
testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); |
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.
these tests are awesome, good job!
Does the broken AABB computation actually break something for many users? I don't find references to
@peci1 Yes it's very inefficient to recompute on each access. I am in favor of merging this request almost as-is in kinetic - modulo @davetcoleman's usual nitpicks. Thank you so much for contributing! Given that the code is not much-used in the MoveIt code base and assuming it is not safety-critical, It would be great if we could find an enduser-friendly solution for indigo.
Both are sub-optimal, but would retain ABI. Would you be willing to adapt the changeset in a second request for indigo (or file the current state in a new patch for kinetic and update this one)? |
@v4hn you are probably right about this being used for visualization only. Actual collision stuff is handed over to fcl here https://github.com/ros-planning/moveit/blob/4bc43c56ca2a5293f3ef8d55796ec586cfde5f69/moveit_core/collision_detection_fcl/src/collision_robot_fcl.cpp#L39 and then the AABB seems to be computed here https://github.com/flexible-collision-library/fcl/blob/43048336c34a01156dc216e8534ffb2788675ddf/include/fcl/narrowphase/collision_object-inl.h#L118 @peci1 could you maybe check if the AABB is handled better in fcl? |
I did the little fixed that should make the changes eligible to be merged to kinetic-devel. I tested it there and it seemed to me all tests pass. Regarding indigo-devel, I'll start implementing the global map+mutex solution. |
Or, it would also be an option to completely get rid of this custom AABB computation and leave it to FCL. But I don't know if introducing dependency robot_state -> collision_detection_fcl would be possible/wanted. What do you think? |
De-facto we already have a hard dependency on FCL, although the user can replace the FCL collision checker on startup. |
Also added a way to visualize both AABBs and OBBs in RViz to verify.
The way I computed the AABB was still buggy - I first transformed the two extremal vertices and then permuted their vertices; but the correct way is to permute the untransformed vertices and the transform the permutations. Before the fix (notice the very thin darker thing - that's the AABB!): Anyways, I think FCL has nicer code for computing the AABB, so I adapted it to be used here. First I thought of just calling the I also finally added a piece of code that allows for easy visualization of the computed BBs directly from the test case. It's I'll cherry-pick this change to #703 and then I'll start adapting this indigo version to use the global map to retain ABI compatibility. |
Done. Let's see how the tests go :) |
Both indigo and kinetic PRs now pass the tests, and I've addressed the last set of comments from rhascke in them. So from my point of view, the PR is ready. |
I'm not sure how to proceed on this and #703. Both of them address the same issue, once in Indigo and once in Kinetic. We should ensure that both change sets are identical (except required adaptions). My suggestion is to continue with #703 only (as this addresses the current |
@rhaschke All changes to kinetic-devel were cherry-picked from this branch, so the changesets should be identical. |
@rhaschke So, do you think there is need to open a new PR for Indigo, now when the kinetic version was merged? |
Fixed bugs in computation of AABB in LinkModel and RobotState.
Discussion started here: #516 (comment)
If you visualize the bounding box computed for the PR2 robot, it is plainly wrong:
![snimek obrazovky porizeny 2017-11-22 18 24 50](https://user-images.githubusercontent.com/182533/33387056-9bc24580-d52c-11e7-8a89-23bd51c8f359.png)
This is the result with my fix:
![snimek obrazovky porizeny 2017-11-28 14 07 06](https://user-images.githubusercontent.com/182533/33387092-b273a198-d52c-11e7-8261-c21f04b38f6e.png)
I added tests that should check for most of the fail cases I've found. Here's a visualization of the "Complex" test:
![snimek obrazovky porizeny 2017-11-29 16 07 42](https://user-images.githubusercontent.com/182533/33387137-caf9ea56-d52c-11e7-8e06-e4fdbc833713.png)
There were 2 sources of wrong computations:
I'm almost sure the code is breaking ABI. Now the question is if there is a way (and will) to make it ABI compatible, or if this should just get cherry-picked to upstream. However, I think the consequences of these bugs can be pretty severe and it might be nice to have them fixed in all releases.
The code also might be optimized for performance, which I'm not good at.
Checklist