-
Notifications
You must be signed in to change notification settings - Fork 688
Perception tutorial update #178
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
Changes from all commits
5a6e1f1
dbfa3f7
bc009b0
812e80f
6b74c1b
988432d
3e96e8b
417f620
dfcf581
59db088
47bcb6b
63e8849
980d0bd
50b07e5
8fc3d80
e5c22a8
bb6a59f
d5f7045
22b1015
a346982
cf003cb
ca3466c
12d2298
1e9a50b
514912a
9401d53
f52457b
3073ad6
fa10a7e
9f4ba07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| add_executable(cylinder_segment src/cylinder_segment.cpp) | ||
| target_link_libraries(cylinder_segment ${catkin_LIBRARIES}) | ||
|
|
||
| add_executable(bag_publisher_maintain_time src/bag_publisher_maintain_time.cpp) | ||
| target_link_libraries(bag_publisher_maintain_time ${catkin_LIBRARIES} ${Boost_LIBRARIES}) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <launch> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems rather redundant. Is there a reason you didn't
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess I started testing that way and didnt change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please refactor when you get a chance
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ya did that |
||
| <include file="$(find moveit_tutorials)/doc/perception_pipeline/launch/obstacle_avoidance_demo.launch" /> | ||
|
|
||
| <!-- Run the detection and adding cylinder node --> | ||
| <node pkg="moveit_tutorials" type="cylinder_segment" name="point_cloud_preprocessor" /> | ||
|
|
||
| </launch> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <launch> | ||
| <include file="$(find panda_moveit_config)/launch/demo.launch" /> | ||
|
|
||
| <!-- Play the rosbag that contains the pointcloud data --> | ||
| <node pkg="moveit_tutorials" type="bag_publisher_maintain_time" name="point_clouds" /> | ||
|
|
||
| <!-- If needed, broadcast static tf for robot root --> | ||
| <node pkg="tf" type="static_transform_publisher" name="to_temp_link" args="0 0.4 -0.6 0 0 0 temp_link panda_link0 10" /> | ||
| <node pkg="tf" type="static_transform_publisher" name="to_panda_base" args="0 0 0 0 0.2 1.92 camera_rgb_optical_frame temp_link 10" /> | ||
|
|
||
| </launch> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,18 @@ | ||
| Perception/Configuration | ||
| ================================= | ||
| Perception Pipeline Tutorial | ||
| ============================ | ||
|
|
||
| MoveIt! allows for seamless integration of 3D sensors using `Octomap <http://octomap.github.io/>`_. | ||
| Once properly configured, you should see something like this in rviz: | ||
|
|
||
| .. image:: perception_configuration_demo.png | ||
| :width: 700px | ||
|
|
||
| Getting Started | ||
| --------------- | ||
| If you haven't already done so, make sure you've completed the steps in `Getting Started <../getting_started/getting_started.html>`_. | ||
|
|
||
| Configuration | ||
| ------------- | ||
|
|
||
| In this section, we will walk through configuring the 3D sensors on your robot with MoveIt!. The primary component in MoveIt! that deals with 3D perception is the Occupancy Map Updater. The updater uses a plugin architecture to process different types of input. The currently available plugins in MoveIt! are: | ||
|
|
||
|
|
@@ -8,13 +21,14 @@ In this section, we will walk through configuring the 3D sensors on your robot w | |
| * The Depth Image Occupancy Map Updater: which can take as input Depth Images (``sensor_msgs/Image``) | ||
|
|
||
| YAML Configuration file (Point Cloud) | ||
| ------------------------------------- | ||
| +++++++++++++++++++++++++++++++++++++ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Ridhwanluthra are you aware of @mohmadAyman's work relating to setting up 3D sensors moveit/moveit#969 Can both of cross-review these PRs to ensure there is no duplicate or contradictory effort? Thanks!
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure! |
||
|
|
||
| We will have to generate a YAML configuration file for configuring the 3D sensors. Please see `this example file <https://github.com/ros-planning/panda_moveit_config/blob/master/config/sensors_kinect_pointcloud.yaml>`_ for processing point clouds, located in the `panda_moveit_config repository for Kinetic <https://github.com/ros-planning/panda_moveit_config>`_: :: | ||
| We will have to generate a YAML configuration file for configuring the 3D sensors. Please see `this example file <https://github.com/ros-planning/panda_moveit_config/blob/master/config/sensors_kinect_pointcloud.yaml>`_ for processing point clouds, located in the `panda_moveit_config repository for Kinetic <https://github.com/ros-planning/panda_moveit_config>`_. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer we use the examples that are almost available in the moveit setup assistant: moveit_setup_assistant/resources/default_config/sensors_3d.yaml
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The challenge with including that would be that it won't work out of the box as we can't directly add that.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From a naming stand point, would
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 to sensors_3d.yaml for the name
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Ridhwanluthra Ping
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As of now it matches the files in panda_moveit_config. Also, If the name is same the user will have to delete 1 ffile and then use it. or if its all included in a single file they will have to comment out one of the plugins. Which would lead to unnecessary confusion for a newcomer. |
||
| Save this file in the config folder in the robot's moveit_config package with name "sensors_kinect_pointcloud.yaml": :: | ||
|
|
||
| sensors: | ||
| - sensor_plugin: occupancy_map_monitor/PointCloudOctomapUpdater | ||
| point_cloud_topic: /head_mount_kinect/depth_registered/points | ||
| point_cloud_topic: /camera/depth_registered/points | ||
| max_range: 5.0 | ||
| point_subsample: 1 | ||
| padding_offset: 0.1 | ||
|
|
@@ -43,13 +57,14 @@ We will have to generate a YAML configuration file for configuring the 3D sensor | |
|
|
||
|
|
||
| YAML Configuration file (Depth Map) | ||
| ----------------------------------- | ||
| +++++++++++++++++++++++++++++++++++ | ||
|
|
||
| We will have to generate a YAML configuration file for configuring the 3D sensors. An `example file for processing depth images <https://github.com/ros-planning/panda_moveit_config/blob/master/config/sensors_kinect_depthmap.yaml>`_ can be found in the `panda_moveit_config repository <https://github.com/ros-planning/panda_moveit_config>`_ as well: :: | ||
| We will have to generate a YAML configuration file for configuring the 3D sensors. An `example file for processing depth images <https://github.com/ros-planning/panda_moveit_config/blob/master/config/sensors_kinect_depthmap.yaml>`_ can be found in the `panda_moveit_config repository <https://github.com/ros-planning/panda_moveit_config>`_ as well. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is something I want to ask about since I'm not sure, is it possible to have both plugins working at the same time?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i don't think so but im not 100% on that |
||
| Save this file in the config folder in the robot's moveit_config package with name "sensors_kinect_depthmap.yaml": :: | ||
|
|
||
| sensors: | ||
| - sensor_plugin: occupancy_map_monitor/DepthImageOctomapUpdater | ||
| image_topic: /head_mount_kinect/depth_registered/image_raw | ||
| image_topic: /camera/depth_registered/image_raw | ||
| queue_size: 5 | ||
| near_clipping_plane_distance: 0.3 | ||
| far_clipping_plane_distance: 5.0 | ||
|
|
@@ -84,14 +99,15 @@ We will have to generate a YAML configuration file for configuring the 3D sensor | |
|
|
||
|
|
||
| Update the launch file | ||
| ---------------------- | ||
| ++++++++++++++++++++++ | ||
|
|
||
| Add the YAML file to the launch script | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, I think that
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. at least in panda it is sensor_manager.launch |
||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| You will now need to update the *sensor_manager.launch* file in the "launch" directory of your panda_moveit_config directory with this sensor information (this file is auto-generated by the Setup Assistant but is empty). You will need to add the following line into that file to configure the set of sensor sources for MoveIt! to use: :: | ||
|
|
||
| <rosparam command="load" file="$(find panda_moveit_config)/config/sensors_kinect.yaml" /> | ||
| <rosparam command="load" file="$(find panda_moveit_config)/config/sensors_kinect_pointcloud.yaml" /> | ||
|
|
||
| If you are using depthmap change the name of the yaml file to ``sensors_kinect_depthmap.yaml``. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Depending if the perception screen was to be merged first, adding this line would be automated.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed. this tutorial can be simplified by relying on the perception screen |
||
| Note that you will need to input the path to the right file you have created above. | ||
|
|
||
| Octomap Configuration | ||
|
|
@@ -106,3 +122,64 @@ MoveIt! uses an octree-based framework to represent the world around it. The *Oc | |
| * *octomap_frame*: specifies the coordinate frame in which this representation will be stored. If you are working with a mobile robot, this frame should be a fixed frame in the world. | ||
| * *octomap_resolution*: specifies the resolution at which this representation is maintained (in meters). | ||
| * *max_range*: specifies the maximum range value to be applied for any sensor input to this node. | ||
|
|
||
| Obstacle Avoidance | ||
| ------------------ | ||
|
|
||
| If you set the initial and the final location of the robot in a way that there is no straight path between them, then the planner will automatically avoid the octomap and plan around it. | ||
|
|
||
| .. image:: obstacle_avoidance.gif | ||
| :width: 700px | ||
|
|
||
| Running the Interface | ||
| +++++++++++++++++++++ | ||
| Roslaunch the launch file to run the code directly from moveit_tutorials: :: | ||
|
|
||
| roslaunch moveit_tutorials obstacle_avoidance_demo.launch | ||
|
|
||
| you should see something like the image shown at the beginning of this tutorial. | ||
|
|
||
| You can test obstacle avoidance for yourself by setting the goal state manually and then planning and executing. To learn how to do that look at `MoveIt! Quickstart in RViz <../quickstart_in_rviz/quickstart_in_rviz_tutorial.html>`_ | ||
|
|
||
| Detecting and Adding Object as Collision Object | ||
| ----------------------------------------------- | ||
|
|
||
| In this section, we will demonstrate an example of extracting a cylinder from a pointcloud, computing relevant values and adding it as a collision object to the planning scene. | ||
| We will be working with point clouds but it can be implemented similarly with depth maps. | ||
|
|
||
| After running the code, you should be able to see something like this in rviz: | ||
|
|
||
| .. image:: cylinder_collision_object.png | ||
| :width: 700px | ||
|
|
||
| Running the Code | ||
| ++++++++++++++++ | ||
| Roslaunch the launch file to run the code directly from moveit_tutorials: :: | ||
|
|
||
| roslaunch moveit_tutorials detect_and_add_cylinder_collision_object_demo.launch | ||
|
|
||
| KNOWN ISSUE - You may see the following error when running the demo :: | ||
|
|
||
| ros.moveit_ros_planning.planning_scene_monitor: Transform error: Lookup would require extrapolation into the future. Requested time 1527473962.793050157 but the latest data is at time 1527473962.776993978, when looking up transform from frame [panda_link2] to frame [camera_rgb_optical_frame] | ||
| ros.moveit_ros_perception: Transform cache was not updated. Self-filtering may fail. | ||
|
|
||
| We are working on fixing it, it should not break the working of the demo. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a Github issue tracking the progress of this problem? Please link to it (and create it if needed)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| You can follow its status in the `issue tracker <https://github.com/ros-planning/moveit_tutorials/issues/192>`_ | ||
|
|
||
| Relevant Code | ||
| +++++++++++++ | ||
| The entire code can be seen :codedir:`here <perception_pipeline>` in the moveit_tutorials GitHub project. The details regarding the implementation of each of the perception pipeline function have been omitted in this tutorial as they are well documented `here. <http://wiki.ros.org/pcl/Tutorials>`_ | ||
|
|
||
| .. |br| raw:: html | ||
|
|
||
| <br /> | ||
|
|
||
| .. |code_start| raw:: html | ||
|
|
||
| <code> | ||
|
|
||
| .. |code_end| raw:: html | ||
|
|
||
| </code> | ||
|
|
||
| .. tutorial-formatter:: ./src/cylinder_segment.cpp | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| /********************************************************************* | ||
| * Software License Agreement (BSD License) | ||
| * | ||
| * Copyright (c) 2018, Ridhwan Luthra. | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions | ||
| * are met: | ||
| * | ||
| * * Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * * Redistributions in binary form must reproduce the above | ||
| * copyright notice, this list of conditions and the following | ||
| * disclaimer in the documentation and/or other materials provided | ||
| * with the distribution. | ||
| * * Neither the name of Ridhwan Luthra nor the names of its | ||
| * contributors may be used to endorse or promote products derived | ||
| * from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
| * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
| * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
| * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
| * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| * POSSIBILITY OF SUCH DAMAGE. | ||
| *********************************************************************/ | ||
|
|
||
| /* Author: Ridhwan Luthra */ | ||
|
|
||
| #include "ros/ros.h" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add license |
||
| #include <ros/package.h> | ||
| #include <rosbag/bag.h> | ||
| #include <rosbag/view.h> | ||
| #include <sensor_msgs/PointCloud2.h> | ||
|
|
||
| int main(int argc, char** argv) | ||
| { | ||
| ros::init(argc, argv, "bag_publisher_maintain_time"); | ||
| ros::NodeHandle nh; | ||
|
|
||
| ros::Publisher point_cloud_publisher = nh.advertise<sensor_msgs::PointCloud2>("/camera/depth_registered/points", 1); | ||
| ros::Rate loop_rate(0.1); | ||
|
|
||
| // Variable holding the rosbag containing point cloud data. | ||
| rosbag::Bag bagfile; | ||
| std::string path = ros::package::getPath("moveit_tutorials"); | ||
| path += "/doc/perception_pipeline/bags/perception_tutorial.bag"; | ||
| bagfile.open(path, rosbag::bagmode::Read); | ||
|
|
||
| std::vector<std::string> topics; | ||
| topics.push_back("/camera/depth_registered/points"); | ||
|
|
||
| // Iterator for topics in bag. | ||
| rosbag::View bagtopics_iter(bagfile, rosbag::TopicQuery(topics)); | ||
|
|
||
| for (auto const msg : bagtopics_iter) | ||
| { | ||
| sensor_msgs::PointCloud2::Ptr point_cloud_ptr = msg.instantiate<sensor_msgs::PointCloud2>(); | ||
| if (point_cloud_ptr == NULL) | ||
| { | ||
| std::cout << "error" << std::endl; | ||
| break; | ||
| } | ||
|
|
||
| while (ros::ok()) | ||
| { | ||
| point_cloud_ptr->header.stamp = ros::Time::now(); | ||
| point_cloud_publisher.publish(*point_cloud_ptr); | ||
| ros::spinOnce(); | ||
| loop_rate.sleep(); | ||
| } | ||
| } | ||
| bagfile.close(); | ||
| return 0; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@v4hn Is adding this dependency going to be an issue?