Skip to content

Port collision_detection to ROS2 - #40

Merged
mlautman merged 19 commits into
moveit:masterfrom
AcutronicRobotics:collision-detection
May 31, 2019
Merged

mlautman merged 19 commits into
moveit:masterfrom
AcutronicRobotics:collision-detection

Conversation

@vmayoral

Copy link
Copy Markdown
Contributor

No description provided.

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

Please address comments regarding 1) const, 2) logger, and 3) clang-format

@mlautman mlautman mentioned this pull request Mar 12, 2019
@vmayoral

Copy link
Copy Markdown
Contributor Author
/Users/victor/ros2_moveit_ws/src/moveit2/moveit_core/collision_detection/src/collision_tools.cpp:281:14: error: no viable overloaded '='
  msg.normal = tf2::toMsg(contact.normal);
  ~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/victor/ros2_ws/install/geometry_msgs/include/geometry_msgs/msg/vector3__struct.hpp:37:8: note: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'geometry_msgs::msg::Point' (aka 'Point_<std::allocator<void> >') to 'const geometry_msgs::msg::Vector3_<std::__1::allocator<void> >' for 1st argument
struct Vector3_
       ^
/Users/victor/ros2_ws/install/geometry_msgs/include/geometry_msgs/msg/vector3__struct.hpp:37:8: note: candidate function (the implicit move assignment operator) not viable: no known conversion from 'geometry_msgs::msg::Point' (aka 'Point_<std::allocator<void> >') to 'geometry_msgs::msg::Vector3_<std::__1::allocator<void> >' for 1st argument
2 warnings and 1 error generated.

Looking at the messages:

victor:~/ros2_ws/src/ros2/common_interfaces/geometry_msgs/msg ((HEAD detached at 0.6.1))$
| => cat Point.msg
# This contains the position of a point in free space
float64 x
float64 y
float64 z
________________________________________________________________________________
| victor:~/ros2_ws/src/ros2/common_interfaces/geometry_msgs/msg ((HEAD detached at 0.6.1))$
| => cat Vector3.msg
# This represents a vector in free space.

float64 x
float64 y
float64 z

Addressed with AcutronicRobotics/geometry2@a5dfb74. @wjwwood please advise if this is the desired way. Probably creating a toMsg2 isn't what you've got in mind?

With the changes above in geometry2, submodule now compiles. Ready for your review @mlautman.

Convert a Eigen::Vector3d type to a geometry_msgs::msg::Vector3
@wjwwood

wjwwood commented Mar 18, 2019

Copy link
Copy Markdown
Contributor

I have no idea, it would be a better question for @tfoote maybe.

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

Looks good to me. I would just replace the clock references by static rclcpp::Time::now() calls.

@tfoote

tfoote commented Mar 19, 2019

Copy link
Copy Markdown
Contributor

Addressed with AcutronicRobotics/geometry2@a5dfb74. @wjwwood please advise if this is the desired way. Probably creating a toMsg2 isn't what you've got in mind?

With the changes above in geometry2, submodule now compiles. Ready for your review @mlautman.

Point and Vector are definitely different types and shouldn't have implicit conversions. Can you specify which template arguments to use for the toMsg to resolve this?

@vmayoral

Copy link
Copy Markdown
Contributor Author

Point and Vector are definitely different types and shouldn't have implicit conversions. Can you specify which template arguments to use for the toMsg to resolve this?

@tfoote it's been a few days since I last looked at this so let me see if I remember everything:

Not sure if this answers your question though. Let me know if you require further changes on this PR or if you're fine with them and we can proceed here.

@vmayoral

Copy link
Copy Markdown
Contributor Author

Reworked the module according to the discussions held regarding logging. Unit tests are disabled due to linking issues, similar than the ones described at AcutronicRobotics#13

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

Reworked the module according to the discussions held regarding logging. Unit tests are disabled due to linking issues, similar than the ones described at AcutronicRobotics#13

Looks good in general. I would just suggest using const loggers and fixing the rclcpp::Duration constructors.

color.b = 0.0f;
color.a = 0.4f;
getCostMarkers(arr, frame_id, cost_sources, color, ros::Duration(60.0));
getCostMarkers(arr, frame_id, cost_sources, color, rclcpp::Duration(60.0));

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.

Suggested change
getCostMarkers(arr, frame_id, cost_sources, color, rclcpp::Duration(60.0));
getCostMarkers(arr, frame_id, cost_sources, color, rclcpp::Duration(60, 0));

rclcpp::Duration doesn't support the seconds constructor anymore.

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.

done

color.b = 0.0f;
color.a = 0.8f;
getCollisionMarkersFromContacts(arr, frame_id, con, color, ros::Duration(60.0));
getCollisionMarkersFromContacts(arr, frame_id, con, color, rclcpp::Duration(60.0));

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.

same

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.

done

{
visualization_msgs::Marker mk;
mk.header.stamp = ros::Time::now();
rclcpp::Clock ros_clock(RCL_ROS_TIME);

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.

For what do we need ros_clock here? It could probably be used to initialize mk.header.stamp below by calling ros_clock.now() like already implemented in the changes below.

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.

done

if(BUILD_TESTING)
find_package(resource_retriever REQUIRED)
if(WIN32)
# set(append_library_dirs "$<TARGET_FILE_DIR:${PROJECT_NAME}>;$<TARGET_FILE_DIR:${PROJECT_NAME}_TestPlugins1>")

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.

Add TODO comment about why this is not working, or remove

@ahcorde

ahcorde commented May 24, 2019

Copy link
Copy Markdown
Contributor

Fixed indentation in the CMakeLists.txt and removed duplicate ;

@ahcorde ahcorde mentioned this pull request May 24, 2019
14 tasks done
if(WIN32)
# TODO add window paths
else()
set(append_library_dirs "${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_BINARY_DIR}/../robot_model;${CMAKE_CURRENT_BINARY_DIR}/../utils")

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.

Hardcoding relative paths is a bad idea.

I would recommend that for every library in this package that is used else ware you set a <lib_name>_lib_dir environment variable that can then be used by the tests

A good example is the rcl_lib_dir I have taken the time to show how it is used below:

/home/mike/ws_ros2/src/ros2/rcl/rcl/CMakeLists.txt:
   78  
   79: # rcl_lib_dir is passed as APPEND_LIBRARY_DIRS for each ament_add_gtest call so
   80  # the librcl that they link against is on the library path.
   81  # This is especially important on Windows.
   82  # This is overwritten each loop, but which one it points to doesn't really matter.
   83: set(rcl_lib_dir "$<TARGET_FILE_DIR:${PROJECT_NAME}>")
   84  

/home/mike/ws_ros2/src/ros2/rcl/rcl/test/CMakeLists.txt:
   16  
   17: set(extra_lib_dirs "${rcl_lib_dir}")
   18  
   
/home/mike/ws_ros2/src/ros2/rcl/rcl/test/CMakeLists.txt:
   34    rcl_add_custom_gtest(test_client${target_suffix}
   35      SRCS rcl/test_client.cpp
   36:     INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
   37      ENV ${rmw_implementation_env_var}
   38      APPEND_LIBRARY_DIRS ${extra_lib_dirs}

The example uses rcl_add_custom_gtest but it works just as well with ament_add_gtest

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 you don't mind I prefer to merge this. And then I will fix them all together. Because we have other merged that use this style. I can open an issue to avoid forgetting it.

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.

Please open an issue

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.

Opened one #91

@mlautman

Copy link
Copy Markdown
Contributor

@ahcorde See remaining comments from Henning, Dave and myself

@ahcorde

ahcorde commented May 31, 2019

Copy link
Copy Markdown
Contributor

@mlautman @henningkayser @davetcoleman Ready to merge

@mlautman
mlautman merged commit 62ed45b into moveit:master May 31, 2019
JafarAbdi pushed a commit to JafarAbdi/moveit2 that referenced this pull request Oct 28, 2019
MikeWrock pushed a commit to MikeWrock/moveit2 that referenced this pull request Aug 15, 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.

8 participants