65 from radar_pa_msgs.msg
import radar_msg
66 from sensor_msgs.msg
import PointCloud
67 from sensor_msgs.msg
import ChannelFloat32
68 from geometry_msgs.msg
import Point32
74 rospy.init_node(
'radar2pcd_pa_node.py', anonymous=
True)
75 rospy.Subscriber(
'radar_messages', radar_msg, self.
callback)
77 self.
pcpub = rospy.Publisher(
'radar_pcd', PointCloud, queue_size=10)
81 self.out_Pc.header = std_msgs.msg.Header()
82 self.out_Pc.header.stamp = rospy.Time.now()
83 self.out_Pc.header.frame_id =
"radar" 87 self.out_Pc.points = [
None] * num_targets
90 self.out_Pc.channels = [ChannelFloat32(), ChannelFloat32(), \
91 ChannelFloat32(), ChannelFloat32(), ChannelFloat32(), \
92 ChannelFloat32(), ChannelFloat32(), ChannelFloat32(), \
93 ChannelFloat32(), ChannelFloat32()]
95 self.out_Pc.channels[0].values = [
None] * num_targets
96 self.out_Pc.channels[1].values = [
None] * num_targets
97 self.out_Pc.channels[2].values = [
None] * num_targets
98 self.out_Pc.channels[3].values = [
None] * num_targets
99 self.out_Pc.channels[4].values = [
None] * num_targets
100 self.out_Pc.channels[5].values = [
None] * num_targets
101 self.out_Pc.channels[6].values = [
None] * num_targets
102 self.out_Pc.channels[7].values = [
None] * num_targets
103 self.out_Pc.channels[8].values = [
None] * num_targets
104 self.out_Pc.channels[9].values = [
None] * num_targets
106 self.out_Pc.channels[0].name =
'ID' 107 self.out_Pc.channels[1].name =
'distance' 108 self.out_Pc.channels[2].name =
'velocity' 109 self.out_Pc.channels[3].name =
'power' 110 self.out_Pc.channels[4].name =
'angle' 111 self.out_Pc.channels[5].name =
'distance_deviation' 112 self.out_Pc.channels[6].name =
'angle_deviation' 113 self.out_Pc.channels[7].name =
'velocity_deviation' 114 self.out_Pc.channels[8].name =
'proability_target' 115 self.out_Pc.channels[9].name =
'is_target' 118 self.out_Pc.header.stamp = data.header.stamp
120 for i
in range(len(self.out_Pc.points)):
124 if (data.data_A[i].is_target == 1):
127 x = data.data_A[i].distance * (math.cos(data.data_A[i].angle))
128 y = data.data_A[i].distance * (math.sin(data.data_A[i].angle))
131 self.out_Pc.channels[0].values[i] = data.data_A[i].ID
132 self.out_Pc.channels[1].values[i] = data.data_A[i].distance
133 self.out_Pc.channels[2].values[i] = data.data_A[i].velocity
134 self.out_Pc.channels[3].values[i] = data.data_A[i].power
135 self.out_Pc.channels[4].values[i] = data.data_A[i].angle
136 self.out_Pc.channels[5].values[i] = data.data_B[i].distance_deviation
137 self.out_Pc.channels[6].values[i] = data.data_B[i].angle_deviation
138 self.out_Pc.channels[7].values[i] = data.data_B[i].velocity_deviation
139 self.out_Pc.channels[8].values[i] = data.data_B[i].proability_target
140 self.out_Pc.channels[9].values[i] = data.data_A[i].is_target
146 self.out_Pc.channels[0].values[i] = float(
'nan')
147 self.out_Pc.channels[1].values[i] = float(
'nan')
148 self.out_Pc.channels[2].values[i] = float(
'nan')
149 self.out_Pc.channels[3].values[i] = float(
'nan')
150 self.out_Pc.channels[4].values[i] = float(
'nan')
151 self.out_Pc.channels[5].values[i] = float(
'nan')
152 self.out_Pc.channels[6].values[i] = float(
'nan')
153 self.out_Pc.channels[7].values[i] = float(
'nan')
154 self.out_Pc.channels[8].values[i] = float(
'nan')
155 self.out_Pc.channels[9].values[i] = float(
'nan')
157 self.out_Pc.points[i] = Point32(x, y, 0)
159 self.pcpub.publish(self.
out_Pc)
163 if __name__ ==
'__main__':
168 except rospy.ROSInterruptException: