-
Notifications
You must be signed in to change notification settings - Fork 0
/
boxcaster.py
98 lines (48 loc) · 1.5 KB
/
boxcaster.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env python
from sensor_msgs import point_cloud2
from sensor_msgs.msg import PointCloud2, PointField
from std_msgs.msg import Header
import rospy
import numpy as np
import cv2
import open3d
from libs import *
import time
import struct
from scipy import spatial
#mat_contents = sio.loadmat('octave_a.mat')
import time
def main():
halfedge=2.0
dist = 3.0
#vertices for the boundaries, it can be any shape, a cube is used for simplicity
vertexhull=np.asarray([
[-halfedge,-halfedge,0.3],
[-halfedge,halfedge,0.3],
[halfedge,-halfedge,0.3],
[halfedge,halfedge,0.3],
[-halfedge,-halfedge,dist],
[-halfedge,halfedge,dist],
[halfedge,-halfedge,dist],
[halfedge,halfedge,dist]
])
print(vertexhull)
rospy.init_node('seven_page_muda', anonymous=True)
#publisher box cast
pub = rospy.Publisher("boxcast", PointCloud2, queue_size=2)
print("Vertices loader")
#configure header
fields = [PointField('x', 0, PointField.FLOAT32, 1),
PointField('y', 4, PointField.FLOAT32, 1),
PointField('z', 8, PointField.FLOAT32, 1),
]
#create point
header = Header()
header.frame_id = "/killerqueen"
pc2 = point_cloud2.create_cloud(header, fields, vertexhull)
while not rospy.is_shutdown():
pc2.header.stamp = rospy.Time.now()
pub.publish(pc2)
rospy.sleep(1.0)
if __name__ == '__main__':
main()