yayaneath / GeoGrasp

Fast geometry-based method for computing grasping points on 3D point clouds.
BSD 2-Clause "Simplified" License
28 stars 13 forks source link

How to add code in pointcloud_listener.cpp to publish #12

Open chappyp opened 2 months ago

chappyp commented 2 months ago

hello,I'm try to use ur5 with a robotiq to grasp objects.Could you tell me the specific steps,like how to add code in pointcloud_listener.cpp to publish message?Are the message bestGrasp and bestPoint?how to publish.Thank you in advance!

yayaneath commented 2 months ago

Hi, I would suggest following this tutorial on how to create ROS publishers: http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29

What you want to publish is the points and the pose found here: https://github.com/yayaneath/GeoGrasp/blob/master/geograsp/src/cloud_processor.cpp#L139-L140 You want the points to know the 3D points in the cloud space where you want to position your RobotiQ gripper fingers. You want the pose to know the orientation of the object, so you find your hand approximation orientation (usually this is a perpendicular vector to the object).

Those two data types are defined here: https://github.com/yayaneath/GeoGrasp/blob/master/geograsp/include/geograsp/GeoGrasp.h#L33-L42

You will need your custom ROS message type. This is just an example:

float32 first_point_x
float32 first_point_y
float32 first_point_z
float32 second_point_x
float32 second_point_y
float32 second_point_z
float32 obj_axis_coeff_0
float32 obj_axis_coeff_1
float32 obj_axis_coeff_2
float32 obj_axis_coeff_3
float32 obj_axis_coeff_4
float32 obj_axis_coeff_5
sensor_msgs/PointCloud2 object_cloud

I can't give more support because the way you translate the grasping points to your robot positions depends on your robot specifically. It was a design decision to keep the library agnostic to robot setups.

chappyp commented 2 months ago

hello,thank you for your reply again!Because I haven‘t learn ROS for so long,there are a lot of things that I don‘t know. I saw the result in the cloud viewer,there include two points and a axis (like the object position message).I also saw your article about the code communication.Your mean is if I publish the two message,it is other way to make the robot to grasp object that don't like your another cpp(the all name called point_cloud_listener.cpp) ?It seems true.The messages you publish are p1,p2,c ....
I also saw the another issue that one person enquire the point_cloud_listener,your answer is use the cloud_processor.cpp instead of point_cloud_listener.cpp and add publish message in cloud_processor.cpp.I saw the cpp include callback function and have the cloud subscribe node(main function),if I add publish node in,what should I edit the code?And I am a little vague about the object message.Are the pulish message write like this? first_point_x = firstPoint.x first_point_y = firstPoint.y first_point_z = firstPoint.z second_point_x = secondPoint.x second_point_y = secondPoint.y second_point_z = secondPoint.z obj_axis_coeff_0 = midPointPose Is this use midPointpose? obj_axis_coeff_1 = obj_axis_coeff_2 obj_axis_coeff_3 obj_axis_coeff_4 obj_axis_coeff_5

yayaneath commented 2 months ago

The answer in this ROS Answers is quite clear on how to write your own message and publish it using C++: https://answers.ros.org/question/31779/how-to-use-a-message-that-i-made/

You will need to add something like that to cloud_processor.cpp right after the lines I mentioned (https://github.com/yayaneath/GeoGrasp/blob/master/geograsp/src/cloud_processor.cpp#L139-L140) so instead of visualizing the result, you publish them to some topic in ROS.