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

collision_distance_field, port to ROS 2 #65

Merged
merged 17 commits into from
Jun 25, 2019

Conversation

vmayoral
Copy link
Contributor

No description provided.

@vmayoral
Copy link
Contributor Author

I've left the logger at the collision_distance_field_types.h file which is then imported by all cpp other cpp files. Let me know if you'd prefer an individual instance of a logger per cpp file instead.

@vmayoral
Copy link
Contributor Author

vmayoral commented Apr 8, 2019

See #62 (comment)

@ahcorde ahcorde mentioned this pull request May 24, 2019
14 tasks

if(CATKIN_ENABLE_TESTING)
ament_target_dependencies(${MOVEIT_LIB_NAME}
Copy link
Contributor

Choose a reason for hiding this comment

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

please fix white space.

Copy link
Contributor

Choose a reason for hiding this comment

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

if(WIN32)
# TODO add windows paths
else()
set(append_library_dirs "${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_BINARY_DIR}/../planning_scene;${CMAKE_CURRENT_BINARY_DIR}/../distance_field;${CMAKE_CURRENT_BINARY_DIR}/../collision_detection;${CMAKE_CURRENT_BINARY_DIR}/../robot_state;${CMAKE_CURRENT_BINARY_DIR}/../robot_model;${CMAKE_CURRENT_BINARY_DIR}/../utils")
Copy link
Contributor

Choose a reason for hiding this comment

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

Using hardcoded paths is a bad idea. Is this really necessary?

Copy link
Contributor

@mlautman mlautman May 29, 2019

Choose a reason for hiding this comment

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

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

#include "rclcpp/time.hpp"
#include "rclcpp/utilities.hpp"

static rclcpp::Logger LOGGER_COLLISION_DISTANCE_FIELD = rclcpp::get_logger("moveit").get_child("collision_distance_field");
Copy link
Contributor

Choose a reason for hiding this comment

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

place inside namespace.

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -102,37 +103,37 @@ class CollisionRobotDistanceField : public CollisionRobot
void checkSelfCollision(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res,
const moveit::core::RobotState& state1, const moveit::core::RobotState& state2) const override
{
ROS_ERROR_NAMED("collision_distance_field", "Not implemented");
RCLCPP_ERROR(LOGGER_COLLISION_DISTANCE_FIELD, "Not implemented");
Copy link
Contributor

Choose a reason for hiding this comment

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

This class should have it's own logger. Perhaps
static rclcpp::Logger LOGGER_COLLISION_ROBOT_DISTANCE_FIELD = LOGGER_COLLISION_DISTANCE_FIELD.get_child("collision_robot_distance_field")

Copy link
Contributor

Choose a reason for hiding this comment

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

Changed both, for collision_robot_distance_field and collision_world_distance_field

86c82b3
6fc6693
2449e1e

@anasarrak
Copy link
Contributor

Please @mlautman review the changes


namespace collision_detection
{
static rclcpp::Logger LOGGER_COLLISION_DISTANCE_FIELD = rclcpp::get_logger("moveit").get_child("collision_distance_field");
Copy link
Contributor

Choose a reason for hiding this comment

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

clang

Copy link
Contributor

Choose a reason for hiding this comment

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

ROS_DEBUG_STREAM("BodyDecomposition generated " << collision_spheres_.size() << " collision spheres out of "
<< shapes.size() << " shapes");
RCLCPP_DEBUG(LOGGER_COLLISION_DISTANCE_FIELD, "BodyDecomposition generated %i collision spheres out of %i shapes",
collision_spheres_.size(), shapes.size());
Copy link
Contributor

Choose a reason for hiding this comment

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

clang

Copy link
Contributor

Choose a reason for hiding this comment

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

arrow_mark.header.frame_id = frame_id;
arrow_mark.header.stamp = ros::Time::now();
arrow_mark.header.stamp = ros_clock.now();
Copy link
Contributor

Choose a reason for hiding this comment

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

http://docs.ros2.org/bouncy/api/rclcpp/classrclcpp_1_1_clock.html

This needs to be RCL_ROS_TIME not RCL_SYSTEM_TIME which is the default

Copy link
Contributor

Choose a reason for hiding this comment

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

sphere_mark.header.frame_id = frame_id;
sphere_mark.header.stamp = ros::Time::now();
sphere_mark.header.stamp = ros_clock.now();
Copy link
Contributor

Choose a reason for hiding this comment

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

http://docs.ros2.org/bouncy/api/rclcpp/classrclcpp_1_1_clock.html

This needs to be RCL_ROS_TIME not RCL_SYSTEM_TIME which is the default

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -1065,7 +1075,8 @@ void CollisionRobotDistanceField::addLinkBodyDecompositions(
link_body_decomposition_vector_.push_back(bd);
link_body_decomposition_index_map_[link_models[i]->getName()] = link_body_decomposition_vector_.size() - 1;
}
ROS_DEBUG_STREAM(__FUNCTION__ << " Finished ");
// RCLCPP_DEBUG_FUNCTION(LOGGER_COLLISION_ROBOT_DISTANCE_FIELD, __FUNCTION__," Finished ");
Copy link
Contributor

Choose a reason for hiding this comment

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

remove dead code

Copy link
Contributor

Choose a reason for hiding this comment

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

ros::WallTime n = ros::WallTime::now();

// WallTime
auto n = std::chrono::system_clock::now();
Copy link
Contributor

Choose a reason for hiding this comment

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

http://docs.ros2.org/bouncy/api/rclcpp/classrclcpp_1_1_clock.html

You can use ros::Clock with RCL_SYSTEM_TIME

Copy link
Contributor

Choose a reason for hiding this comment

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

ROS_DEBUG_NAMED("collision_distance_field", "Modifying object %s took %lf s", obj->id_.c_str(),
(ros::WallTime::now() - n).toSec());
RCLCPP_DEBUG(LOGGER_COLLISION_WORLD_DISTANCE_FIELD, "Modifying object %s took %lf s", obj->id_.c_str(),
std::chrono::system_clock::now() - n);
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@anasarrak
Copy link
Contributor

@mlautman your suggestion has been addressed, you can review them

@anasarrak
Copy link
Contributor

Ping @mlautman

@ahcorde
Copy link
Contributor

ahcorde commented Jun 24, 2019

friendly ping @mlautman @henningkayser @davetcoleman

@@ -1,10 +1,5 @@
set(MOVEIT_LIB_NAME moveit_collision_distance_field)

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we removing this. It is only a warning. Rather than remove, we should mark the overloaded functions as virtual and the overloading functions as override

if(WIN32)
# TODO add windows paths
else()
set(append_library_dirs "${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_BINARY_DIR}/../planning_scene;${CMAKE_CURRENT_BINARY_DIR}/../distance_field;${CMAKE_CURRENT_BINARY_DIR}/../collision_detection;${CMAKE_CURRENT_BINARY_DIR}/../robot_state;${CMAKE_CURRENT_BINARY_DIR}/../robot_model;${CMAKE_CURRENT_BINARY_DIR}/../utils")
Copy link
Contributor

Choose a reason for hiding this comment

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

Add TODO for fixing this and assign to yourself. Otherwise, we will likely forget to get back to this

@mlautman mlautman merged commit e29b6cd into moveit:master Jun 25, 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
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.

None yet

4 participants