Skip to content

clang-tidy and C++11 modernization of moveit_planners_ompl - #990

Merged
davetcoleman merged 11 commits into
moveit:melodic-develfrom
KavrakiLab:feature/ompl_modernization
Aug 1, 2018
Merged

davetcoleman merged 11 commits into
moveit:melodic-develfrom
KavrakiLab:feature/ompl_modernization

Conversation

@zkingston

Copy link
Copy Markdown
Contributor

Description

This PR is the first chunk in part of a broader effort to merge #897 into MoveIt! by splitting the contribution across multiple PRs in coordination with @davetcoleman.

For this PR, clang-tidy was run using the configuration in .clang-tidy and boost constructs (particularly function, bind, thread, and mutex) have been replaced by their counterparts in C++11.

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)

@davetcoleman davetcoleman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry for the delay. Now we need a second reviewer

@davetcoleman

Copy link
Copy Markdown
Member

@BryceStevenWilley can you review this?

@BryceStevenWilley

Copy link
Copy Markdown
Contributor

Sure, I'll try to have it done by tomorrow.

@BryceStevenWilley BryceStevenWilley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In addition to the comments, two main things that I think should be changed:

  • auto in for loops (linked to previous discussion in one of the comments).
  • std::move instead of const T& (discussed here and here. I think it was up for debate at the time though, so I'll defer to Dave for this decision.

{
for (std::map<std::string, ConstraintApproximationPtr>::const_iterator it = constraint_approximations_.begin();
it != constraint_approximations_.end(); ++it)
for (const auto& constraint_approximation : constraint_approximations_)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Avoid auto in cases like this, just use std::map<std::string, ConstraintApproximationPtr>. See #880 (comment) for previous discussion.

return ompl::base::SpaceInformationPtr();
for (std::size_t i = 0; i < goals.size(); ++i)
if (!goals[i]->hasType(ompl::base::GOAL_SAMPLEABLE_REGION))
for (const auto& goal : goals)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same comment as above: avoid auto in for loops.

planning_context_->getPlanningScene()->checkCollision(
verbose ? collision_request_simple_verbose_ : collision_request_simple_, res, *kstate);
return res.collision == false;
return !res.collision;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this clang-tidy or you? If it's not clang-tidy, personally I still think == false is more readable. Up for debate though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

}

for (std::size_t j = 0; j < config_names.size(); ++j)
for (auto j = 0; j < config_names.size(); ++j)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might want to run clang-tidy again, I don't think it converts nested for loops, this one looks like it should be converted.

unsigned int d = 0;
for (std::size_t i = 0; i < joint_model_vector_.size(); ++i)
d += joint_model_vector_[i]->getStateSpaceDimension();
for (auto i : joint_model_vector_)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Change this name, clang-tidy chooses very poorly sometimes.

{
for (std::size_t i = 0; i < cc->second.size(); ++i)
if (cc->second[i].unique())
for (const auto& i : cc->second)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as above: choose a better name.

@BryceStevenWilley

Copy link
Copy Markdown
Contributor

LGTM.

@davetcoleman
davetcoleman merged commit 81a4ff9 into moveit:melodic-devel Aug 1, 2018
@davetcoleman

Copy link
Copy Markdown
Member

Thanks! Looking forward to next PR in this series

@RoboticsYY RoboticsYY mentioned this pull request Feb 18, 2019
1 task done
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.

3 participants