-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathconvert_to_radardetectionlist.py
More file actions
executable file
·37 lines (28 loc) · 1.46 KB
/
convert_to_radardetectionlist.py
File metadata and controls
executable file
·37 lines (28 loc) · 1.46 KB
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
#!/usr/bin/env python
import rospy
from ars_40X.msg import Object, ObjectList, Cluster, ClusterList
from radar_msgs.msg import RadarDetection, RadarDetectionArray
def convert_to_detection(obj):
radar_detection = RadarDetection()
radar_detection.detection_id = obj.id
radar_detection.position = obj.position.pose.position
radar_detection.velocity = obj.relative_velocity.twist.linear
radar_detection.amplitude = obj.rcs
return radar_detection
def object_list_callback(object_list, detection_array_publisher):
radar_detection_array = RadarDetectionArray()
radar_detection_array.header = object_list.header
try:
objects = getattr(object_list, 'objects')
except AttributeError:
objects = getattr(object_list, 'clusters')
radar_detection_array.detections = [convert_to_detection(obj) for obj in objects]
detection_array_publisher.publish(radar_detection_array)
if __name__ == '__main__':
rospy.init_node('object_list_converter')
publisher = rospy.Publisher("/radar_converter/detections123", RadarDetectionArray, queue_size=10)
object_list_callback_closure = lambda object_list: object_list_callback(object_list, publisher)
rospy.Subscriber('/ars_40X/objects', ObjectList, object_list_callback_closure)
cluster_list_callback_closure = lambda cluster_list: object_list_callback(cluster_list, publisher)
rospy.Subscriber('/ars_40X/clusters', ClusterList, cluster_list_callback_closure)
rospy.spin()