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("simple_obstacle_pub")
00028 root_frame = "/odom_combined"
00029
00030 pub = rospy.Publisher("obstacle_distance/registerObstacle", CollisionObject, queue_size = 1)
00031
00032 while pub.get_num_connections() < 1:
00033 if rospy.is_shutdown():
00034 exit(0)
00035 rospy.logwarn("Please create a subscriber to 'obstacle_distance/registerObstacle' topic (Type: moveit_msgs/CollisionObject)")
00036 time.sleep(1.0)
00037
00038 rospy.loginfo("Continue ...")
00039
00040
00041 x = CollisionObject()
00042 x.id = "Funny Sphere"
00043 x.header.frame_id = root_frame
00044 x.operation = CollisionObject.ADD
00045
00046 sphere = SolidPrimitive()
00047 sphere.type = SolidPrimitive.SPHERE
00048 sphere.dimensions.append(0.1)
00049 x.primitives.append(sphere)
00050
00051 pose = Pose()
00052 pose.position.x = 0.35
00053 pose.position.y = -0.45
00054 pose.position.z = 0.8
00055 pose.orientation.x = 0.0;
00056 pose.orientation.y = 0.0;
00057 pose.orientation.z = 0.0;
00058 pose.orientation.w = 1.0;
00059 x.primitive_poses.append(pose)
00060
00061 time.sleep(1.0)
00062
00063
00064 y = CollisionObject()
00065 y.id = "Funny Mesh"
00066 y.header.frame_id = root_frame
00067
00068 y.type.db = "package://cob_gazebo_objects/Media/models/cabinet_ikea_kallax_4x2.stl"
00069
00070 y.operation = CollisionObject.ADD
00071
00072
00073 pose = Pose()
00074 pose.position.x = 0.5
00075 pose.position.y = 0.5
00076 pose.position.z = 0.0
00077 pose.orientation.x = 0.0
00078 pose.orientation.y = 0.0
00079 pose.orientation.z = 0.0
00080 pose.orientation.w = 1.0
00081 y.mesh_poses.append(pose)
00082 pub.publish(y)
00083 time.sleep(1.0)
00084
00085 rospy.loginfo("Done!")