4 from scipy.spatial
import ConvexHull
9 from geometry_msgs.msg
import Point
13 rospy.init_node(
'segment_array_sample')
15 pub = rospy.Publisher(
'~output', SegmentArray, queue_size=1)
16 r = rospy.Rate(rospy.get_param(
'~rate', 1.0))
18 segment_array = SegmentArray()
19 segment_array.header.frame_id = rospy.get_param(
'~frame_id',
'map')
22 while not rospy.is_shutdown():
23 points = np.random.rand(N, 3)
24 hull = ConvexHull(points)
25 segment_array.header.stamp = rospy.Time.now()
26 segment_array.segments = []
27 for i
in hull.simplices:
29 segment_array.segments.extend(
30 [Segment(start_point=Point(a[0], a[1], a[2]),
31 end_point=Point(b[0], b[1], b[2])),
32 Segment(start_point=Point(b[0], b[1], b[2]),
33 end_point=Point(c[0], c[1], c[2])),
34 Segment(start_point=Point(a[0], a[1], a[2]),
35 end_point=Point(c[0], c[1], c[2])),
37 pub.publish(segment_array)
41 if __name__ ==
'__main__':