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

Replaced C-Style Cast with C++ Style Cast. #935

Merged
merged 21 commits into from
Dec 22, 2021
Merged

Conversation

kausmeows
Copy link
Contributor

@kausmeows kausmeows commented Dec 22, 2021

Description

Please explain the changes you made, including a reference to the related issue if applicable

Checklist

  • Required by CI: Code is auto formatted using clang-format
  • Extend the tutorials / documentation reference
  • Document API changes relevant to the user in the MIGRATION.md notes
  • Create tests, which fail without this PR reference
  • Include a screenshot if changing a GUI
  • While waiting for someone to review your request, please help review another open pull request to support the maintainers

@kausmeows
Copy link
Contributor Author

Hey !! I just changed the C style casts to C++ style. Please review and see if it works fine :)

Copy link
Member

@tylerjw tylerjw left a comment

Choose a reason for hiding this comment

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

I found a few minor things. Thank you for this change! 🚀

Copy link
Member

@tylerjw tylerjw left a comment

Choose a reason for hiding this comment

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

I'm sorry to be so nit-picky. Thank you for helping with this. I'm just trying to avoid accidentally changing the existing behavior by moving what is cast to include more than just what would have been cast in with the c-style cast.

kausmeows and others added 13 commits December 22, 2021 23:50
Co-authored-by: Tyler Weaver <tylerjw@gmail.com>
…e/environment_chain3d_types.h

Co-authored-by: Tyler Weaver <tylerjw@gmail.com>
…e/environment_chain3d_types.h

Co-authored-by: Tyler Weaver <tylerjw@gmail.com>
…3d.cpp

Co-authored-by: Tyler Weaver <tylerjw@gmail.com>
…age_octomap_updater.cpp

Co-authored-by: Tyler Weaver <tylerjw@gmail.com>
Co-authored-by: Tyler Weaver <tylerjw@gmail.com>
Co-authored-by: Tyler Weaver <tylerjw@gmail.com>
Co-authored-by: Tyler Weaver <tylerjw@gmail.com>
…render.cpp

Co-authored-by: Tyler Weaver <tylerjw@gmail.com>
…render.cpp

Co-authored-by: Tyler Weaver <tylerjw@gmail.com>
Co-authored-by: Tyler Weaver <tylerjw@gmail.com>
Comment on lines 159 to 171
if (x_index >= (int)cache_size_x_ || x_index < 0)
if (x_index >= static_cast<int>(cache_size_x_ || x_index < 0))
{
ROS_DEBUG_NAMED("kinematics_cache", "X position %f,%d lies outside grid: %d %d", pose.position.x, x_index, 0,
cache_size_x_);
return false;
}
if (y_index >= (int)cache_size_y_ || y_index < 0)
if (y_index >= static_cast<int>(cache_size_y_ || y_index < 0))
{
ROS_DEBUG_NAMED("kinematics_cache", "Y position %f,%d lies outside grid: %d %d", pose.position.y, y_index, 0,
cache_size_y_);
return false;
}
if (z_index >= (int)cache_size_z_ || z_index < 0)
if (z_index >= static_cast<int>(cache_size_z_ || z_index < 0))
Copy link
Member

Choose a reason for hiding this comment

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

Here are a few more where the parentheses change what is being cast.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On to it. In a sec.

Comment on lines 328 to 335
ROS_DEBUG_NAMED("kinematics_cache", "Read %d total points from file: %s", (int)num_solutions_vector_.size(),
ROS_DEBUG_NAMED("kinematics_cache", "Read %d total points from file: %s", static_cast<int>num_solutions_vector_.size(),
filename.c_str());
return true;
}

bool KinematicsCache::writeToFile(const std::string& filename)
{
ROS_DEBUG_NAMED("kinematics_cache", "Writing %d total points to file: %s", (int)num_solutions_vector_.size(),
ROS_DEBUG_NAMED("kinematics_cache", "Writing %d total points to file: %s", static_cast<int>num_solutions_vector_.size(),
Copy link
Member

Choose a reason for hiding this comment

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

These are missing the parentheses.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@kausmeows
Copy link
Contributor Author

Did the changes where it wasn't really a cast 😵‍💫.

@tylerjw
Copy link
Member

tylerjw commented Dec 22, 2021

Did the changes where it wasn't really a cast face_with_spiral_eyes.

Only a couple more that I found and then this needs clang-tidy-10 ran on it to fix the formatting. We typically use a tool called pre-commit to do that. To install clang-tidy-10 and pre-commit use these commands:

sudo apt install clang-format-10
pip3 install -U pre-commit

Then to run pre-commit to fix the formatting (do this in your checkout of the repo):

pre-commit run --all

Then add the changes and push it. That will probably adjust a couple of small things.

Copy link
Member

@tylerjw tylerjw left a comment

Choose a reason for hiding this comment

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

This is ready to go after you run pre-commit and fix the formatting so the formatting test will pass. Thank you for this improvement. 😄

@codecov
Copy link

codecov bot commented Dec 22, 2021

Codecov Report

Merging #935 (a714586) into main (bb87521) will increase coverage by 0.01%.
The diff coverage is 47.06%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #935      +/-   ##
==========================================
+ Coverage   57.91%   57.91%   +0.01%     
==========================================
  Files         310      310              
  Lines       26067    26069       +2     
==========================================
+ Hits        15093    15095       +2     
  Misses      10974    10974              
Impacted Files Coverage Δ
...e/collision_detection_fcl/src/collision_common.cpp 74.89% <0.00%> (ø)
moveit_core/robot_model/src/robot_model.cpp 74.82% <0.00%> (ø)
...ccupancy_map_monitor/src/occupancy_map_updater.cpp 0.00% <ø> (ø)
...ution_manager/src/trajectory_execution_manager.cpp 6.77% <0.00%> (ø)
...nning_scene_monitor/src/planning_scene_monitor.cpp 53.31% <50.00%> (ø)
...istance_field/src/collision_env_distance_field.cpp 54.16% <100.00%> (+0.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bb87521...a714586. Read the comment docs.

@kausmeows
Copy link
Contributor Author

I'm on a Mac and am facing issue installing clang-format 10. I ran pre-commit run --all and that's working fine. The only thing it says is command format 10 not found and I tried installing it using homebrew but no luck. What should I do ?

@tylerjw
Copy link
Member

tylerjw commented Dec 22, 2021

I'm on a Mac and am facing issue installing clang-format 10. I ran pre-commit run --all and that's working fine. The only thing it says is command format 10 not found and I tried installing it using homebrew but no luck. What should I do ?

For this PR, I can run it for you and update this PR. I don't know how to install clang-format-10 on a mac. The best idea I have is that you could maybe do that inside docker. You'd have to create a docker image and mount your directory and then you could use the apt command it installs it and then run it.

@kausmeows
Copy link
Contributor Author

I'm on a Mac and am facing issue installing clang-format 10. I ran pre-commit run --all and that's working fine. The only thing it says is command format 10 not found and I tried installing it using homebrew but no luck. What should I do ?

For this PR, I can run it for you and update this PR. I don't know how to install clang-format-10 on a mac. The best idea I have is that you could maybe do that inside docker. You'd have to create a docker image and mount your directory and then you could use the apt command it installs it and then run it.

Thank you @tylerjw 😃.

@tylerjw tylerjw merged commit b41a741 into moveit:main Dec 22, 2021
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

2 participants