@@ -234,6 +234,11 @@ def pose_to_matrix(pose):
234234 T [:3 , 3 ] = np .array ([x , y , z ])
235235 return T
236236
237+ def transform_lidar_points (lidar_points , transform ):
238+ ones_column = np .ones ((lidar_points .shape [0 ], 1 ))
239+ lidar_points_extended = np .hstack ((lidar_points , ones_column ))
240+ lidar_points_transformed = ((transform @ (lidar_points_extended .T )).T )
241+ return lidar_points_transformed [:, :3 ]
237242
238243def transform_points_l2c (lidar_points , T_l2c ):
239244 N = lidar_points .shape [0 ]
@@ -308,8 +313,10 @@ def initialize(self):
308313 self .sync .registerCallback (self .synchronized_callback )
309314
310315 # Publishers
316+ self .pub_lidar_top_vehicle_pc2 = rospy .Publisher ("point_cloud/lidar_top_vehicle" , PointCloud2 , queue_size = 10 )
311317 self .pub_cones_image_detection = rospy .Publisher ("cones/image_detection" , Image , queue_size = 1 )
312318 self .pub_cones_bboxes_markers = rospy .Publisher ("cones/markers/bboxes" , MarkerArray , queue_size = 10 )
319+ self .pub_vehicle_marker = rospy .Publisher ("vehicle/marker" , MarkerArray , queue_size = 10 )
313320
314321 # Detection model
315322 self .model_path = os .getcwd () + '/GEMstack/knowledge/detection/cone.pt'
@@ -342,19 +349,28 @@ def viz_object_states(self, cv_image, boxes):
342349 if agent .dimensions != None and agent .dimensions [0 ] != None and agent .dimensions [1 ] != None and agent .dimensions [2 ] != None :
343350 cone_3d_dims .append (agent .dimensions )
344351
352+ # Transform top lidar pointclouds to vehicle frame for visualization
353+ latest_lidar_vehicle = transform_lidar_points (self .latest_lidar , self .T_l2v )
354+ ros_lidar_top_vehicle_pc2 = create_point_cloud (latest_lidar_vehicle , (255 , 0 , 0 ), "lidar_top" )
355+ self .pub_lidar_top_vehicle_pc2 .publish (ros_lidar_top_vehicle_pc2 )
356+
345357 # Draw 2D bboxes
346358 for ind , bbox in enumerate (boxes ):
347359 xywh = bbox .xywh [0 ].tolist ()
348360 cv_image = vis_2d_bbox (cv_image , xywh , bbox )
349361 ros_img = self .bridge .cv2_to_imgmsg (cv_image , 'bgr8' )
350362 self .pub_cones_image_detection .publish (ros_img )
351363
364+ # Create vehicle marker
365+ ros_vehicle_marker = create_bbox_marker ([[0.0 , 0.0 , 0.0 ]], [[0.8 , 0.5 , 0.3 ]], (1.0 , 0.0 , 0.0 , 1 ), "lidar_top" )
366+ self .pub_vehicle_marker .publish (ros_vehicle_marker )
352367 # Draw 3D cone centers and dimensions
353368 if len (cone_3d_centers ) > 0 and len (cone_3d_dims ) > 0 :
354- # Create bbox markers from cone dimensions
369+ # Delete previous markers
355370 ros_delete_bboxes_markers = delete_bbox_marker ()
356371 self .pub_cones_bboxes_markers .publish (ros_delete_bboxes_markers )
357- ros_cones_bboxes_markers = create_bbox_marker (cone_3d_centers , cone_3d_dims , "lidar_top" )
372+ # Create bbox markers from cone dimensions
373+ ros_cones_bboxes_markers = create_bbox_marker (cone_3d_centers , cone_3d_dims , (0.0 , 1.0 , 15 , 0.2 ), "lidar_top" )
358374 self .pub_cones_bboxes_markers .publish (ros_cones_bboxes_markers )
359375
360376
@@ -468,7 +484,7 @@ def update(self, vehicle: VehicleState) -> Dict[str, AgentState]:
468484 yaw = yaw ,
469485 pitch = pitch ,
470486 roll = roll ,
471- frame = ObjectFrameEnum .START
487+ frame = ObjectFrameEnum .CURRENT
472488 )
473489
474490 existing_id = match_existing_cone (
0 commit comments