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

bugfix for chomp fixed base joint bug #870

Merged
merged 2 commits into from
Apr 30, 2018
Merged

bugfix for chomp fixed base joint bug #870

merged 2 commits into from
Apr 30, 2018

Conversation

mlautman
Copy link
Contributor

@mlautman mlautman commented Apr 27, 2018

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

  • Required: Code is auto formatted using clang-format
  • Extended the tutorials / documentation, if necessary reference
  • Include a screenshot if changing a GUI
  • Optional: Created tests, which fail without this PR reference
  • Optional: Decide if this should be cherry-picked to other current ROS branches (Indigo, Jade, Kinetic)

Copy link
Contributor

@rhaschke rhaschke left a 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];
Copy link
Contributor

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())
Copy link
Contributor

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.

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 it's better to avoid goto-derivatives in general.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Member

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

Copy link
Member

@bmagyar bmagyar left a 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.

@rhaschke rhaschke merged commit 5579c9c into moveit:kinetic-devel Apr 30, 2018
@mlautman mlautman deleted the kinetic-chomp-bugfix branch May 30, 2018 19:15
dg-shadow pushed a commit to shadow-robot/moveit that referenced this pull request Jul 30, 2018
Gracefully handle active root joint, which doesn't have a parent.
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

5 participants