Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 import time
00019
00020 import rospy
00021 from geometry_msgs.msg import Pose
00022 from moveit_msgs.msg import CollisionObject
00023 from shape_msgs.msg import SolidPrimitive, Mesh
00024
00025
00026 if __name__=="__main__":
00027 rospy.init_node("example_obstacle_publisher")
00028
00029
00030 frame_id = rospy.get_param('root_frame')
00031
00032 pub = rospy.Publisher("obstacle_distance/registerObstacle", CollisionObject, queue_size=1, latch=True)
00033
00034 while pub.get_num_connections() < 1:
00035 if rospy.is_shutdown():
00036 exit(0)
00037 rospy.logwarn("Please create a subscriber to '" + rospy.get_namespace() + "/obstacle_distance/registerObstacle' topic (Type: moveit_msgs/CollisionObject)")
00038 time.sleep(1.0)
00039
00040 rospy.loginfo("Continue ...")
00041
00042
00043 x = CollisionObject()
00044 x.id = "Funny Sphere"
00045 x.header.frame_id = frame_id
00046 x.operation = CollisionObject.ADD
00047 sphere = SolidPrimitive()
00048 sphere.type = SolidPrimitive.SPHERE
00049 sphere.dimensions.append(0.1)
00050 x.primitives.append(sphere)
00051
00052 pose = Pose()
00053 pose.position.x = 0.35
00054 pose.position.y = -0.35
00055 pose.position.z = 0.8
00056 pose.orientation.x = 0.0;
00057 pose.orientation.y = 0.0;
00058 pose.orientation.z = 0.0;
00059 pose.orientation.w = 1.0;
00060 x.primitive_poses.append(pose)
00061 pub.publish(x)
00062 time.sleep(1.0)
00063
00064
00065 y = CollisionObject()
00066 y.id = "Funny Mesh"
00067 y.header.frame_id = frame_id
00068 y.type.db = "package://cob_gazebo_objects/Media/models/milk.dae"
00069 y.operation = CollisionObject.ADD
00070
00071 pose = Pose()
00072 pose.position.x = -0.35
00073 pose.position.y = -0.35
00074 pose.position.z = 0.8
00075 pose.orientation.x = 0.0;
00076 pose.orientation.y = 0.0;
00077 pose.orientation.z = 0.0;
00078 pose.orientation.w = 1.0;
00079 y.mesh_poses.append(pose)
00080 pub.publish(y)
00081 time.sleep(1.0)
00082
00083 rospy.spin()