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

Port occupancy_map_monitor to ROS2 #148

Merged
merged 5 commits into from
Jan 17, 2020

Conversation

RoboticsYY
Copy link
Contributor

#112 is blocked by occupancy_map_monitor, please see https://github.com/ros-planning/moveit2/blob/fa81678b965eafcb1e8c72018ba4d99ab2593255/moveit_ros/planning/planning_scene_monitor/include/moveit/planning_scene_monitor/planning_scene_monitor.h#L45

This work followed AcutronicRobotics' porting, but didn't use the original commits. Because occupancy_map_monitor was moved from moveit_ros to moveit_ros_perception(ref), the original commits are very difficult to directly use.

@RoboticsYY RoboticsYY force-pushed the pr-occupancy_map_monitor branch from ea8e8bb to 955e367 Compare December 20, 2019 10:26
Copy link
Member

@JafarAbdi JafarAbdi left a comment

Choose a reason for hiding this comment

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

Thank you @RoboticsYY for porting occupancy_map_monitor

src/occupancy_map_monitor.cpp
src/occupancy_map_updater.cpp
)
set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}")
target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES})
ament_target_dependencies(${MOVEIT_LIB_NAME} rclcpp moveit_core moveit_msgs pluginlib octomap geometric_shapes)
target_link_libraries(${MOVEIT_LIB_NAME} ${Boost_LIBRARIES})
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
target_link_libraries(${MOVEIT_LIB_NAME} ${Boost_LIBRARIES})

Please add Boost in ament_target_dependencies

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

src/occupancy_map_monitor.cpp
src/occupancy_map_updater.cpp
)
set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}")
target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES})
ament_target_dependencies(${MOVEIT_LIB_NAME} rclcpp moveit_core moveit_msgs pluginlib octomap geometric_shapes)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ament_target_dependencies(${MOVEIT_LIB_NAME} rclcpp moveit_core moveit_msgs pluginlib octomap geometric_shapes)
ament_target_dependencies(${MOVEIT_LIB_NAME}
rclcpp
moveit_core
moveit_msgs
pluginlib
octomap
geometric_shapes
Boost)

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


add_executable(moveit_ros_occupancy_map_server src/occupancy_map_server.cpp)
target_link_libraries(moveit_ros_occupancy_map_server ${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES})
ament_target_dependencies(moveit_ros_occupancy_map_server rclcpp moveit_core moveit_msgs pluginlib octomap geometric_shapes)
target_link_libraries(moveit_ros_occupancy_map_server ${MOVEIT_LIB_NAME} ${Boost_LIBRARIES})
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
target_link_libraries(moveit_ros_occupancy_map_server ${MOVEIT_LIB_NAME} ${Boost_LIBRARIES})
target_link_libraries(moveit_ros_occupancy_map_server ${MOVEIT_LIB_NAME})

Same

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 adding Boost to ament_target_dependencies.

ament_export_dependencies(pluginlib)
ament_export_dependencies(octomap)
ament_export_dependencies(geometric_shapes)

Copy link
Member

Choose a reason for hiding this comment

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

Please add ament_export_dependencies(Boost)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added Boost to ament_export_dependencies.

)

install(TARGETS moveit_ros_occupancy_map_server
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
RUNTIME DESTINATION share/${PROJECT_NAME}/
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be lib/${PROJECT_NAME} .?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has been corrected.

double map_resolution = 0.0);
OccupancyMapMonitor(double map_resolution = 0.0);
OccupancyMapMonitor(const std::shared_ptr<tf2_ros::Buffer>& tf_buffer, ros::NodeHandle& nh,
OccupancyMapMonitor(const std::shared_ptr<tf2_ros::Buffer>& tf_buffer, const rclcpp::Node::SharedPtr& node,
Copy link
Member

Choose a reason for hiding this comment

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

For consistency node should be the first parameter

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

{
initialize();
}
static const rclcpp::Logger LOGGER = rclcpp::get_logger("moveit_ros.occupancy_map_monitor");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
static const rclcpp::Logger LOGGER = rclcpp::get_logger("moveit_ros.occupancy_map_monitor");
static const rclcpp::Logger LOGGER = rclcpp::get_logger("moveit_ros_occupancy_map_monitor");

Nit: @henningkayser Which one should we use .?

Copy link
Member

Choose a reason for hiding this comment

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

Both are fine, I would stick with the full lib name as we decided to do so and follow this rule in other packages.
My general concern is that this won't scale with added files and also the namespaces are less explicit (i.e. for scoping moveit, moveit_ros, etc).


static void publishOctomap(ros::Publisher* octree_binary_pub, occupancy_map_monitor::OccupancyMapMonitor* server)
static const rclcpp::Logger LOGGER = rclcpp::get_logger("moveit_ros.occupancy_map_server");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
static const rclcpp::Logger LOGGER = rclcpp::get_logger("moveit_ros.occupancy_map_server");
static const rclcpp::Logger LOGGER = rclcpp::get_logger("moveit_ros_occupancy_map_server");

Nit: @henningkayser Which one should we use .?

Copy link
Member

Choose a reason for hiding this comment

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

Ok, now that we have multiple files in this package I would strongly prefer lib_name.file_name for all files. It's better to be more explicit about this and makes scoping logger levels easier

@@ -39,6 +39,8 @@

namespace occupancy_map_monitor
{
static const rclcpp::Logger LOGGER = rclcpp::get_logger("moveit_ros.occupancy_map_updater");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
static const rclcpp::Logger LOGGER = rclcpp::get_logger("moveit_ros.occupancy_map_updater");
static const rclcpp::Logger LOGGER = rclcpp::get_logger("moveit_ros_occupancy_map_updater");

Nit: @henningkayser Which one should we use .?

{
transform_cache_.clear();
if (transform_provider_callback_)
return transform_provider_callback_(target_frame, target_time, transform_cache_);
else
{
ROS_WARN_THROTTLE(1, "No callback provided for updating the transform cache for octomap updaters");
RCUTILS_LOG_ERROR_THROTTLE(rcutils_steady_time_now, 1,
Copy link
Member

Choose a reason for hiding this comment

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

Should we use RCUTILS* directly .?

Copy link
Member

Choose a reason for hiding this comment

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

No, we should use RCLCPP_WARN_THROTTLE which becomes available with Eloquent. So this is on me ;)

project(moveit_ros_occupancy_map_monitor)
set(MOVEIT_LIB_NAME ${PROJECT_NAME})

set(CMAKE_CXX_STANDARD 14)
# Default to C++14
Copy link
Member

Choose a reason for hiding this comment

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

I think we should keep the original cmake flags and warnings and modify them globally if necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed back to the original setting.


include_directories(include
${Boost_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
${rclcpp_INCLUDE_DIRS}
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be necessary with ament_target_dependencies

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed ${rclcpp_INCLUDE_DIRS} from include_directories.

{
initialize();
}
static const rclcpp::Logger LOGGER = rclcpp::get_logger("moveit_ros.occupancy_map_monitor");
Copy link
Member

Choose a reason for hiding this comment

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

Both are fine, I would stick with the full lib name as we decided to do so and follow this rule in other packages.
My general concern is that this won't scale with added files and also the namespaces are less explicit (i.e. for scoping moveit, moveit_ros, etc).

}
}
// TODO rework this in ROS2
// XmlRpc::XmlRpcValue sensor_list;
Copy link
Member

Choose a reason for hiding this comment

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

@JafarAbdi Didn't you have a code snippet where you already replaced XmlRPC ?

Copy link
Member

Choose a reason for hiding this comment

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

It's a work-around the way we specify the current parameters, for example for sensor_3d.yaml it'll be

/**:
    ros__parameters:
        sensors:  ["sensor1", "sensor2"]
        sensor1:
            sensor_plugin: occupancy_map_monitor/PointCloudOctomapUpdater
            point_cloud_topic: /head_mount_kinect/depth_registered/points
            max_range: 5.0
            point_subsample: 1
            padding_offset: 0.1
            padding_scale: 1.0
            max_update_rate: 1.0
            filtered_cloud_topic: filtered_cloud
        sensor2:
            sensor_plugin: occupancy_map_monitor/DepthImageOctomapUpdater
            image_topic: /head_mount_kinect/depth_registered/image_raw
            queue_size: 5
            near_clipping_plane_distance: 0.3
            far_clipping_plane_distance: 5.0
            shadow_threshold: 0.2
            padding_scale: 4.0
            padding_offset: 0.03
            max_update_rate: 1.0
            filtered_cloud_topic: filtered_cloud

This link inspired me to do so

Copy link
Member

Choose a reason for hiding this comment

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

@henningkayser Does this method makes sense .? if you agree with this method I'll open PR fixes it targeting this branch

Copy link
Member

Choose a reason for hiding this comment

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

I think it seems a little redundant to have the sensor names extra, but if it makes things easier I agree with this approach.

Copy link
Member

Choose a reason for hiding this comment

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

However, I think this belongs to a system wide launch/parameter refactoring, so I would suggest we merge this right away to continue with PSM

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I agree with the codebase wide refactoring for XmlRpc


static void publishOctomap(ros::Publisher* octree_binary_pub, occupancy_map_monitor::OccupancyMapMonitor* server)
static const rclcpp::Logger LOGGER = rclcpp::get_logger("moveit_ros.occupancy_map_server");
Copy link
Member

Choose a reason for hiding this comment

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

Ok, now that we have multiple files in this package I would strongly prefer lib_name.file_name for all files. It's better to be more explicit about this and makes scoping logger levels easier

{
transform_cache_.clear();
if (transform_provider_callback_)
return transform_provider_callback_(target_frame, target_time, transform_cache_);
else
{
ROS_WARN_THROTTLE(1, "No callback provided for updating the transform cache for octomap updaters");
RCUTILS_LOG_ERROR_THROTTLE(rcutils_steady_time_now, 1,
Copy link
Member

Choose a reason for hiding this comment

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

No, we should use RCLCPP_WARN_THROTTLE which becomes available with Eloquent. So this is on me ;)

@JafarAbdi JafarAbdi mentioned this pull request Dec 20, 2019
6 tasks
@RoboticsYY RoboticsYY force-pushed the pr-occupancy_map_monitor branch 5 times, most recently from 14b53c1 to 6aed2b3 Compare December 24, 2019 10:39
@RoboticsYY
Copy link
Contributor Author

@JafarAbdi @henningkayser All the issues are addressed except replacing XmlRPC and changing ROS_WARN_THROTTLE to RCLCPP_WARN_THROTTLE.

@RoboticsYY RoboticsYY force-pushed the pr-occupancy_map_monitor branch from 6aed2b3 to c4a7c93 Compare December 25, 2019 03:01
@RoboticsYY RoboticsYY force-pushed the pr-occupancy_map_monitor branch from c4a7c93 to 982ece5 Compare January 15, 2020 02:42
@RoboticsYY RoboticsYY force-pushed the pr-occupancy_map_monitor branch from 352e4b7 to 1ff5ead Compare January 15, 2020 07:26
}
}
// TODO rework this in ROS2
// XmlRpc::XmlRpcValue sensor_list;
Copy link
Member

Choose a reason for hiding this comment

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

However, I think this belongs to a system wide launch/parameter refactoring, so I would suggest we merge this right away to continue with PSM

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.

3 participants