-
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
bugfix for chomp fixed base joint bug #870
bugfix for chomp fixed base joint bug #870
Conversation
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.
Generally approve this. However, touching this file anyway, I would like to ask you for a small cleanup too.
@@ -204,7 +204,11 @@ void ChompOptimizer::initialize() | |||
for (size_t i = 0; i < joint_model_group_->getFixedJointModels().size(); i++) | |||
{ | |||
const moveit::core::JointModel* model = joint_model_group_->getFixedJointModels()[i]; |
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.
Please take the chance and replace the for-loop by for (const moveit::core::JointModel* model : joint_model_group_->getFixedJointModels())
.
@@ -204,7 +204,11 @@ void ChompOptimizer::initialize() | |||
for (size_t i = 0; i < joint_model_group_->getFixedJointModels().size(); i++) | |||
{ | |||
const moveit::core::JointModel* model = joint_model_group_->getFixedJointModels()[i]; | |||
fixed_link_resolution_map[model->getName()] = model->getParentLinkModel()->getParentJointModel()->getName(); | |||
// In case this is the base joint (eg: a fixed virtual_joint) then we need to check for NULL | |||
if (model->getParentLinkModel()) |
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 would prefer a
if (!model->getParentLinkModel())
continue;
However, that's probably a matter of taste.
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 think it's better to avoid goto-derivatives in general.
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.
As I said, that's a matter of taste. Leave it like it is.
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.
Yes, this is a matter of taste here.
Please keep in mind though that multiple maintainers agreed some time ago to prefer continue
/early return
if the code would otherwise end up with many lines indented for no reason.
We have some cases in the source where after 50+ lines of indented code there is an else
branch that prints one ROS_ERROR
.
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.
+1 to using continue
or return
early
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 think the tutorial could even be copied over and set up as a test to keep it stable in the long run.
Gracefully handle active root joint, which doesn't have a parent.
Description
This fixes an issue where where the chomp optimizer was requesting the parent joint of a fixed base joint without checking for Null moveit_tutorials #164
Checklist