7 from sensor_msgs.msg
import PointCloud2, PointField
12 from std_msgs.msg
import Header
17 PointField(name=
'x', offset=0, datatype=PointField.FLOAT32, count=1),
18 PointField(name=
'y', offset=4, datatype=PointField.FLOAT32, count=1),
19 PointField(name=
'z', offset=8, datatype=PointField.FLOAT32, count=1),
20 PointField(name=
'rgba', offset=16, datatype=PointField.UINT32, count=1),
22 return create_cloud(header, fields, xyzrgb)
27 self.
pub_plane = rospy.Publisher(
"~output/plane", PolygonArray, queue_size=10)
28 self.
pub_cloud = rospy.Publisher(
"~output/cloud", PointCloud2, queue_size=10)
38 p.polygon.points = [Point32(x=xmin, y=ymin),
39 Point32(x=xmax, y=ymin),
40 Point32(x=xmax, y=ymax),
41 Point32(x=xmin, y=ymax)]
42 msg.polygons.append(p)
47 ymin=-0.05, ymax=0.05,
51 for x
in np.arange(xmin, xmax, d):
52 for y
in np.arange(ymin, ymax, d):
53 pts.append([x, y, zmax] + np.random.normal(0.0, noise, 3))
55 for z
in np.arange(zmin, zmax, d):
56 for y
in np.arange(ymin, ymax, d):
57 pts.append([xmin, y, z] + np.random.normal(0.0, noise, 3))
63 rmin=np.pi/2., rmax=np.pi*3./2,
64 zmin=0.01, zmax=0.15):
67 for z
in np.arange(zmin, zmax, d):
68 for rad
in np.arange(rmin, rmax, d*2.):
69 pts.append([xpos + radius * np.cos(rad),
70 ypos + radius * np.sin(rad),
71 z] + np.random.normal(0.0, noise, 3))
73 for r
in np.arange(0, radius, d):
74 for rad
in np.arange(0, np.pi * 2., d*2.):
75 pts.append([xpos + r * np.cos(rad),
76 ypos + r * np.sin(rad),
77 zmax] + np.random.normal(0.0, noise, 3))
84 for x
in np.arange(xmin, xmax, d):
85 for y
in np.arange(ymin, ymax, d):
86 plane.append([x, y, 1.0])
90 header = Header(frame_id=
"camera_rgb_optical_frame", stamp=rospy.Time.now())
93 self.pub_plane.publish(plane)
98 self.pub_cloud.publish(cloud)
101 if __name__ ==
'__main__':
102 rospy.init_node(
"test_primitive_classifier")
def timer_cb(self, args=None)
def generate_circle_cloud(self, d=0.01, noise=0.0015, radius=0.05, xpos=0.2, ypos=0.2, rmin=np.pi/2., rmax=np.pi *3./2, zmin=0.01, zmax=0.15)
def generate_plane(self, header, xmin=-0.0, xmax=1.0, ymin=-1.0, ymax=1.0)
def create_cloud_xyzrgb(header, xyzrgb)
def generate_box_cloud(self, d=0.01, noise=0.0015, xmin=0.2, xmax=0.4, ymin=-0.05, ymax=0.05, zmin=0.01, zmax=0.1)
def generate_plane_cloud(self, xmin, xmax, ymin, ymax)