Skip to content

Clang Tidy to collision_detection and collision_detection_fcl - #693

Closed
BryceStevenWilley wants to merge 16 commits into
moveit:kinetic-develfrom
BryceStevenWilley:clang-tidy
Closed

BryceStevenWilley wants to merge 16 commits into
moveit:kinetic-develfrom
BryceStevenWilley:clang-tidy

Conversation

@BryceStevenWilley

Copy link
Copy Markdown
Contributor

Description

As per #28, I setup and documented how to run clang-tidy on the codebase, and tested it on the collision_detection and collision_detection_fcl folders. I chose these two because they were small, so I could get feedback on what to change before applying to the entire repo.

The clang-tidy config file is based on https://github.com/davetcoleman/rviz_visual_tools/blob/kinetic-devel/.clang-tidy and adds some more checks to the code.

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.

I'm exited about this upgrade!

res.collision = false;
if (req.verbose)
logInform("Using AllValid collision detection. No collision checking is performed.");
CONSOLE_BRIDGE_logInform("Using AllValid collision detection. No collision checking is performed.");

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.

why is this change necessary? we weren't getting deprecated / compatibility warnings were we? I see this file but would like to understand the backstory. This change reduces code readability.

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.

We were getting deprecated warnings, actually. The exact warning that clang gives is this:

/home/brycew/Desktop/moveit_ws/src/moveit/moveit_core/collision_detection/src/allvalid/collision_robot_allvalid.cpp:54:5: warning: 'log_deprecated' is deprecated [clang-diagnostic-deprecated-declarations]
    logInform("Using AllValid collision detection. No collision checking is performed.");
    ^
/usr/include/console_bridge/console.h:96:19: note: expanded from macro 'logInform'
  console_bridge::log_deprecated(__FILE__, __LINE__, console_bridge::CONSOLE_BRIDGE_LOG_INFO,  fmt, ##__VA_ARGS__)
                  ^
/usr/include/console_bridge/console.h:202:54: note: 'log_deprecated' has been explicitly marked deprecated here
CONSOLE_BRIDGE_DEPRECATED CONSOLE_BRIDGE_DLLAPI void log_deprecated(const char *file, int line, LogLevel level, const char* m, ...);

And looks like this file does deprecate the current version we're using unfortunately.

And from this pull request, it looks like logInform et al. are about to be removed soon.

Comment thread moveit_core/README.md Outdated
```
run-clang-tidy-3.8.py -fix -p=/home/brycew/Desktop/moveit_ws/build/moveit_core/ collision_detection
```

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.

Thanks for writing this up! I believe this documentation belongs on this page instead

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.

Thanks! I had a feeling there was a better place, but couldn't find where.
This has been moved to https://github.com/ros-planning/moveit.ros.org/pull/146

@davetcoleman

Copy link
Copy Markdown
Member

Just need one more reviewer

@davetcoleman

Copy link
Copy Markdown
Member

Actually we should probably merge #662 otherwise there will undoubtably be major conflicts.

@BryceStevenWilley

Copy link
Copy Markdown
Contributor Author

Merged! Was surprisingly easy, only 3 or 4 clear-cut conflicts.

@rhaschke rhaschke 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.

If merging was that easy, I suggest to leave this PR separate from #662. For the latter one, I added some more remarks to be fixed before merging, which will delay this one unnecessarily.
Otherwise +1.

@BryceStevenWilley

Copy link
Copy Markdown
Contributor Author

That sounds good @rhaschke, went ahead and reverted that merge.

@rhaschke rhaschke 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.

It's much better to have this huge PR separated from another. Some variable choices of clang tidy are suboptimal and I ask you, to please check them an replace by more appropriate variables where suitable.
I marked some of those locations, but there are more probably.

* @scale scale A common scaling to use for all objects/links on the robot
*/
CollisionRobot(const robot_model::RobotModelConstPtr& model, double padding = 0.0, double scale = 1.0);
CollisionRobot(robot_model::RobotModelConstPtr model, double padding = 0.0, double scale = 1.0);

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.

Replacing const-ref by value argument is a suggestion of clang tidy??
This shouldn't be replaced.

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.

The reasons for the replacement are on this page: https://clang.llvm.org/extra/clang-tidy/checks/modernize-pass-by-value.html. Looks like it only does so for constructors at the moment.

Easy enough to turn off though, I will do so.

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.

Explanation makes sense in general. However, for shared ptrs, move-construction doesn't make sense. Usually you want to keep the pointer afterwards. So, no need to turn this feature off, but asking for manual validation of all changes (and reverting unnecessary ones).

{
std::vector<std::string> u;
for (std::map<std::string, double>::const_iterator it = padding.begin(); it != padding.end(); ++it)
for (const auto& it : padding)

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.

here the loop variable should be renamed to e.g. pair (it is misleading).

{
std::vector<std::string> u;
for (std::map<std::string, double>::const_iterator it = scale.begin(); it != scale.end(); ++it)
for (const auto& it : scale)

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.

dito: it -> pair

{
std::vector<std::string> u;
for (std::size_t i = 0; i < padding.size(); ++i)
for (const auto& i : padding)

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.

i -> p

@rhaschke

Copy link
Copy Markdown
Contributor

Closing in favor of #731, which is a rebase of this PR completely removing the reverted merge.

@rhaschke rhaschke closed this Dec 29, 2017
@BryceStevenWilley BryceStevenWilley mentioned this pull request Jan 21, 2018
5 tasks done
@BryceStevenWilley BryceStevenWilley mentioned this pull request May 2, 2018
5 tasks done
JafarAbdi pushed a commit to JafarAbdi/moveit that referenced this pull request Mar 24, 2022
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.

4 participants