Repository navigation
Constraint samplers - #60
Conversation
vmayoral
commented
Mar 30, 2019
- Unit tests (pending on addressing Unit tests in moveit2 failing AcutronicRobotics/moveit2#13)
henningkayser
left a comment
There was a problem hiding this comment.
Looks good in general, just some minor changes.
| std::stringstream ss; | ||
| ss << constr; | ||
| ROS_DEBUG_NAMED("constraint_samplers", | ||
| ss << constr.name; |
There was a problem hiding this comment.
Isn't there a way to print the whole message as a string anymore?
There was a problem hiding this comment.
I still think that the full constraint should be printed here instead of only the name.
There was a problem hiding this comment.
There is no such implementation for ROS2. I have asked that on the following issue : ros2/common_interfaces#69 (comment) redirected to ros2/rosidl#259
| ros::WallTime end = ros::WallTime::now() + ros::WallDuration(1.0); | ||
| //TODO RCLCPP::WallTimer has not a .now() function, and there is no wallDuration (they use std::chrono::nanoseconds) | ||
| // I'll use rclcpp::time, but this is something to fix. | ||
| rclcpp::Duration duration(1,0); |
There was a problem hiding this comment.
I think this solution is good. We could instantiate rclcpp::Duration inline, though.
| visualization_msgs::Marker mk; | ||
| mk.header.stamp = ros::Time::now(); | ||
| visualization_msgs::msg::Marker mk; | ||
| mk.header.stamp = stamp; |
There was a problem hiding this comment.
This could be set directly from rclcpp::Clock().now()
| ROS_ERROR_NAMED("constraint_samplers", "IK solver failed with error %d", error.val); | ||
| else if (verbose_) | ||
| ROS_INFO_NAMED("constraint_samplers", "IK failed"); | ||
| error.val != moveit_msgs::msg::MoveItErrorCodes::TIMED_OUT){ |
| loop_time = (ros::Time::now() - start_time).toSec(); | ||
| RCLCPP_WARN(LOGGER, "%d, %f", count, q_init(free_angle_)); | ||
| time = rclcpp::Clock().now(); | ||
| loop_time = time.seconds() - start_time.seconds(); |
There was a problem hiding this comment.
| loop_time = time.seconds() - start_time.seconds(); | |
| loop_time = (rclcpp::Clock().now() - start_time).seconds(); |
Then we don't need to introduce time.
| void updateInternalDataStructures(); | ||
| #else | ||
| void updateInternalDataStructures() override; | ||
| void updateInternalDataStructures(); |
There was a problem hiding this comment.
Why should override be removed? This condition shouldn't be broken by the port and we should try to avoid loosening these kind of checks. Also, the if/else block is redundant with this change.
There was a problem hiding this comment.
updateInternalDataStructures depends from orocos_kdl, we can see it on melodic here http://docs.ros.org/melodic/api/orocos_kdl/html/classKDL_1_1ChainJntToJacSolver.html#a8c6fe8ec5cd73c65699143e4a5df9bef, the problem is, that this function is not implemented on ros2, looking into https://github.com/ros2/orocos_kinematics_dynamics/tree/ros2/orocos_kdl it seems like is no more needed. This function is used only on the tests, and it seems like the function is empty.
I removed the entire function and the define here: 02f0eb3
| ${urdfdom_headers_LIBRARIES} | ||
| ) | ||
| endif() | ||
| # if(BUILD_TESTING) |
There was a problem hiding this comment.
I think it's fine to uncomment tests and just let them fail for now so we can fix them later.
There was a problem hiding this comment.
@vmayoral Let's get the test fixes cherry picked in
There was a problem hiding this comment.
|
@mlautman Done! |
| if(WIN32) | ||
| # set(append_library_dirs "$<TARGET_FILE_DIR:${PROJECT_NAME}>;$<TARGET_FILE_DIR:${PROJECT_NAME}_TestPlugins1>") | ||
| else() | ||
| set(append_library_dirs "${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_BINARY_DIR}/../utils;${CMAKE_CURRENT_BINARY_DIR}/../robot_state;${CMAKE_CURRENT_BINARY_DIR}/../planning_scene;${CMAKE_CURRENT_BINARY_DIR}/../robot_model;${CMAKE_CURRENT_BINARY_DIR}/../kinematics_constraint") |
There was a problem hiding this comment.
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 should work just as well with ament_add_gtest
There was a problem hiding this comment.
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.
| test/pr2_arm_ik.cpp | ||
| ) | ||
|
|
||
| target_include_directories(test_constraint_samplers PUBLIC |
|
|
||
| #include <moveit/constraint_samplers/constraint_sampler.h> | ||
|
|
||
| rclcpp::Logger LOGGER_CONSTRAINT_SAMPLERS = rclcpp::get_logger("moveit").get_child("constraint_samplers"); |
There was a problem hiding this comment.
Refactor to put this inside namespace. the methods themselves could be put in a single large namespace block as well
| #include <cassert> | ||
| #include <boost/bind.hpp> | ||
|
|
||
| rclcpp::Logger LOGGER_DEFAULT_CONTRAINT_SAMPLERS = rclcpp::get_logger("moveit").get_child("constraint_samplers"); |
On ROS2 is not implemented, for melodic we can get it on http://docs.ros.org/melodic/api/orocos_kdl/html/classKDL_1_1ChainJntToJacSolver.html#a8c6fe8ec5cd73c65699143e4a5df9bef, looking into ros2 code, there is not similar function https://github.com/ros2/orocos_kinematics_dynamics/tree/ros2/orocos_kdl
|
@mlautman and @henningkayser review the changes please |
henningkayser
left a comment
There was a problem hiding this comment.
@anasarrak Just some small changes left, then +1 from me
| } | ||
| KDL::Frame pose_desired; | ||
| tf2::fromMsg(ik_pose, pose_desired); | ||
| KDL::Frame pose_desired = KDL::Frame(KDL::Rotation::Quaternion(ik_pose.orientation.x, ik_pose.orientation.y, |
There was a problem hiding this comment.
This should use fromMsg() from tf2_kdl.h once geometry2 is ported to ROS2. Please add a TODO
There was a problem hiding this comment.
There is actually an implementation for such transformation on
https://github.com/ros2/geometry2/blob/234725f30ade83caa4bcf019ee854199aa31bef5/tf2_kdl/include/tf2_kdl/tf2_kdl.h#L273-L282, you have to pass a PoseStamped instead of a pose, so I suggest the following changes.
| KDL::Frame pose_desired = KDL::Frame(KDL::Rotation::Quaternion(ik_pose.orientation.x, ik_pose.orientation.y, | |
| geometry_msgs::msg::PoseStamped ik_pose_stamped; | |
| ik_pose_stamped.pose = ik_pose; | |
| tf2::Stamped<KDL::Frame> pose_desired; | |
| tf2::fromMsg(ik_pose_stamped, pose_desired); |
There was a problem hiding this comment.
@anasarrak I'm going to merge this but I would like to see this in a follow up PR
| } | ||
| ROS_INFO("Success rate for IK Constraint Sampler with position & orientation constraints for one arm: %lf", | ||
| (double)succ / (double)NT); | ||
| // ROS_INFO("Success rate for IK Constraint Sampler with position & orientation constraints for one arm: %lf", |
There was a problem hiding this comment.
This info should be printed, either by a logger or using std::cout.
There was a problem hiding this comment.
| std::stringstream ss; | ||
| ss << constr; | ||
| ROS_DEBUG_NAMED("constraint_samplers", | ||
| ss << constr.name; |
There was a problem hiding this comment.
I still think that the full constraint should be printed here instead of only the name.
|
@mlautman look at the changes |
|
Ping @mlautman @henningkayser |
|
friendly ping @mlautman @henningkayser @davetcoleman |
…r_manager_loader Port constraint_sampler_manager_loader to ROS2