The target object to grasp

In this case, the target object to grasp is the can of Coke. It is a cylindrical object that we can approximate as a box, which is one of the basic primitives in the MoveIt! planning scene API:

# Retrieve params: 
self._grasp_object_name = rospy.get_param('~grasp_object_name', 
'coke_can') # Clean the scene: self._scene.remove_world_object(self._grasp_object_name) # Add table and Coke can objects to the planning scene: self._pose_coke_can = self._add_coke_can(self._grasp_object_name)

The objects in the planning scene receive a unique identifier, which is a string. In this case, coke_can is the identifier for the can of Coke. We remove it from the scene to avoid having duplicate objects, and then we add to the scene. The _add_coke_can method does that by defining the pose and shape dimensions:

def _add_coke_can(self, name): 
    p = PoseStamped() 
    p.header.frame_id = self._robot.get_planning_frame() 
    p.header.stamp = rospy.Time.now() 
 
    p.pose.position.x = 0.75 - 0.01 
    p.pose.position.y = 0.25 - 0.01 
    p.pose.position.z = 1.00 + (0.3 + 0.03) / 2.0 
 
    q = quaternion_from_euler(0.0, 0.0, 0.0) 
    p.pose.orientation = Quaternion(*q) 
 
    self._scene.add_box(name, p, (0.15, 0.15, 0.3)) 
 
    returnp.pose 

The important part here is the add_box method that adds a box object to the planning scene we created earlier. The box is given a name, its pose, and dimensions, which in this case are set to match the ones in the Gazebo world shown earlier, with the table and the can of Coke. We also have to set frame_id to the planning frame ID and the timestamp to now. In order to use the planning frame, we need RobotCommander, which is the MoveIt! interface to command the manipulator programmatically:

self._robot = RobotCommander() 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.116.20