load_scene_example.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 import roslib; roslib.load_manifest('cob_moveit_interface')
00003 import rospy
00004 
00005 from tf.transformations import *
00006 from simple_moveit_interface import *
00007 
00008 
00009 def gen_pose(frame_id="/odom_combined", pos=[0,0,0], euler=[0,0,0]):
00010         pose = PoseStamped()
00011         pose.header.frame_id = frame_id
00012         pose.header.stamp = rospy.Time.now()
00013         pose.pose.position.x, pose.pose.position.y, pose.pose.position.z = pos
00014         pose.pose.orientation.x, pose.pose.orientation.y, pose.pose.orientation.z, pose.pose.orientation.w = quaternion_from_euler(*euler)
00015         return pose
00016 
00017 if __name__ == '__main__':
00018         rospy.init_node('load_scene')
00019         while rospy.get_time() == 0.0: pass
00020         
00021         psi = get_planning_scene_interface()
00022         rospy.sleep(1.0)
00023         
00024         ### Add a floor
00025         add_ground()
00026         
00027         ### Add primitives (box, sphere, cylinder)
00028         pose = gen_pose(pos=[-0.9, 0.8, 0.5])
00029         psi.add_box("box", pose, size=(0.3, 0.5, 0.7))
00030         
00031         pose = gen_pose(pos=[0.0, 0.0, 2.5])
00032         psi.add_sphere("sphere", pose, radius=(0.3))
00033         
00034         # CollisionChecking with cylinder primitives does not work correctly, thus this is not supported! Use a mesh instead!
00035         
00036         
00037         ### ADDING A MESH
00038         #ToDo: use rospack to find package
00039         #ToDo: meshes cannot be scaled yet
00040         pose = gen_pose(pos=[0.6, 0.0, 0.9], euler=[-1.57, 0, 3.14])
00041         filename = '/opt/ros/groovy/stacks/simulator_gazebo/gazebo_worlds/Media/models/mug-test.stl'
00042         psi.add_mesh("mug", pose, filename)
00043         
00044         
00045         rospy.sleep(1.0)
00046         
00047         ### ADDING DETECT and URDF not supported anymore
00048         #ToDo: Add if needed
00049         
00050         
00051         ### ATTACHING AN OBJECT
00052         #ToDo: attach without creating objects again
00053         pose = gen_pose(pos=[0.4, 0.1, 1.0])
00054         psi.attach_box("tray_link", "box2", pose, (0.1,0.1,0.1))
00055         
00056         pose = gen_pose(pos=[0.5, -0.9, 0.9], euler=[-1.57, 0, 3.14])
00057         filename = '/opt/ros/groovy/stacks/simulator_gazebo/gazebo_worlds/Media/models/mug-test.stl'
00058         touch_links = ["sdh_grasp_link", "sdh_palm_link", "sdh_finger_11_link", "sdh_finger_12_link", "sdh_finger_13_link", "sdh_finger_21_link", "sdh_finger_22_link", "sdh_finger_23_link", "sdh_thumb_1_link", "sdh_thumb_2_link", "sdh_thumb_3_link"]
00059         psi.attach_mesh("arm_7_link", "mug", pose, filename, touch_links)
00060         
00061         
00062         rospy.sleep(1.0)
00063         
00064         ### DETACHING AN OBJECT
00065         #ToDo: detach without stating link?
00066         psi.remove_attached_object("arm_7_link", "mug")
00067         
00068         
00069         rospy.sleep(1.0)
00070         
00071         ### REMOVING AN OBJECT
00072         psi.remove_world_object("sphere")
00073         
00074         
00075         ### CLEAR ALL OBJECTS
00076         #ToDo: attached objects are not removed
00077         clear_objects()
00078         
00079         


cob_moveit_interface
Author(s): Felix Messmer
autogenerated on Wed Aug 26 2015 11:01:06