kitti数据显示

画出track_id

publish_utils.py中

def publish_3dbox(box3d_pub, corners_3d_velos, types, track_ids):marker_array = MarkerArray()for i, corners_3d_velo in enumerate(corners_3d_velos):marker = Marker()marker.header.frame_id = FRAME_IDmarker.header.stamp = rospy.Time.now()marker.id = imarker.action = Marker.ADDmarker.lifetime = rospy.Duration(LIFETIME)marker.type = Marker.LINE_LISTb, g, r = DETECTION_COLOR_DICT[types[i]]marker.color.r = r/255.0marker.color.g = g/255.0marker.color.b = b/255.0marker.color.a = 1.0marker.scale.x = 0.1marker.points = []for l in LINES:p1 = corners_3d_velo[l[0]]marker.points.append(Point(p1[0], p1[1], p1[2]))p2 = corners_3d_velo[l[1]]marker.points.append(Point(p2[0], p2[1], p2[2]))marker_array.markers.append(marker)# 添加track_idtext_marker = Marker()text_marker.header.frame_id = FRAME_IDtext_marker.header.stamp = rospy.Time.now()text_marker.id = i + 1000text_marker.action = Marker.ADDtext_marker.lifetime = rospy.Duration(LIFETIME)text_marker.type = Marker.TEXT_VIEW_FACING# 计算中心点的位置p = np.mean(corners_3d_velo, axis=0) # upper front left cornertext_marker.pose.position.x = p[0]text_marker.pose.position.y = p[1]text_marker.pose.position.z = p[2] + 1text_marker.text = str(track_ids[i])text_marker.scale.x = 1text_marker.scale.y = 1text_marker.scale.z = 1b, g, r = DETECTION_COLOR_DICT[types[i]]text_marker.color.r = r/255.0text_marker.color.g = g/255.0text_marker.color.b = b/255.0text_marker.color.a = 1.0marker_array.markers.append(text_marker)box3d_pub.publish(marker_array)

kitti.py

#!/usr/bin/env python
#  -*-coding:utf8 -*-
import numpy as npimport rospyfrom data_utils import *
from publish_utils import *
from kitti_util import *
import osDATA_PATH = "/home/d501/kitti_data/2011_09_26/2011_09_26_drive_0005_sync/2011_09_26/2011_09_26_drive_0005_sync"def compute_3d_box_cam2(h, w, l, x, y, z, yaw):# 计算旋转矩阵R = np.array([[np.cos(yaw), 0, np.sin(yaw)], [0, 1, 0], [-np.sin(yaw), 0, np.cos(yaw)]])# 8个顶点的xyzx_corners = [l/2,l/2,-l/2,-l/2,l/2,l/2,-l/2,-l/2]y_corners = [0,0,0,0,-h,-h,-h,-h]z_corners = [w/2,-w/2,-w/2,w/2,w/2,-w/2,-w/2,w/2]# 旋转矩阵点乘(3,8)顶点矩阵corners_3d_cam2 = np.dot(R, np.vstack([x_corners,y_corners,z_corners]))# 加上location中心点,得出8个顶点旋转后的坐标corners_3d_cam2 += np.vstack([x,y,z])return corners_3d_cam2if __name__ == "__main__":frame = 0rospy.init_node("kitti_node", anonymous=True)cam_pub = rospy.Publisher('kitti_cam', Image, queue_size=10)pcl_pub = rospy.Publisher('kitti_point_cloud', PointCloud2, queue_size=10)ego_pub = rospy.Publisher('kitti_ego_car', MarkerArray, queue_size=10)imu_pub = rospy.Publisher('kitti_imu', Imu, queue_size=10)gps_pub = rospy.Publisher('kitti_gps', NavSatFix, queue_size=10)box3d_pub = rospy.Publisher('kitti_3d', MarkerArray, queue_size=10)bridge = CvBridge()df_tracking = read_labelfile('/home/d501//kitti_data/2011_09_26/data_tracking_label_2/training/label_02/0000.txt')calib = Calibration("/home/d501//kitti_data/2011_09_26/2011_09_26_drive_0005_sync/2011_09_26", from_video=True)rate = rospy.Rate(10)while not rospy.is_shutdown():df_tracking_frame = df_tracking[df_tracking.frame==frame]boxes_2d = np.array(df_tracking[df_tracking.frame==frame][['bbox_left','bbox_top','bbox_right','bbox_bottom']])types = np.array(df_tracking[df_tracking.frame==frame]['type'])boxes_3d = np.array(df_tracking_frame[['dimensions_height','dimensions_width','dimensions_length','location_x','location_y','location_z','rotation_y']])track_ids = np.array(df_tracking_frame['track id'])corners_3d_velos = []for box_3d in boxes_3d:corners_3d_cam2 = compute_3d_box_cam2(*box_3d)corners_3d_velo = calib.project_rect_to_velo(corners_3d_cam2.T)corners_3d_velos += [corners_3d_velo]image = read_camera(os.path.join(DATA_PATH, 'image_02/data/%010d.png'%frame))point_cloud = read_point_cloud(os.path.join(DATA_PATH, 'velodyne_points/data/%010d.bin'%frame))imu_data = read_imu(os.path.join(DATA_PATH, 'oxts/data/%010d.txt'%frame))publish_camera(cam_pub, bridge, image, boxes_2d, types)publish_point_cloud(pcl_pub, point_cloud)publish_ego_car(ego_pub)publish_imu(imu_pub, imu_data)publish_gps(gps_pub, imu_data)publish_3dbox(box3d_pub, corners_3d_velos, types, track_ids)rospy.loginfo("published")rate.sleep()frame += 1frame %= 154

 运行结果截图:

 画出历史轨迹

画出所有物体历史轨迹

kitti.py

#!/usr/bin/env python
#  -*-coding:utf8 -*-
import numpy as np
from collections import dequeimport rospyfrom data_utils import *
from publish_utils import *
from kitti_util import *
import osDATA_PATH = "/home/d501/kitti_data/2011_09_26/2011_09_26_drive_0005_sync/2011_09_26/2011_09_26_drive_0005_sync"def compute_3d_box_cam2(h, w, l, x, y, z, yaw):# 计算旋转矩阵R = np.array([[np.cos(yaw), 0, np.sin(yaw)], [0, 1, 0], [-np.sin(yaw), 0, np.cos(yaw)]])# 8个顶点的xyzx_corners = [l/2,l/2,-l/2,-l/2,l/2,l/2,-l/2,-l/2]y_corners = [0,0,0,0,-h,-h,-h,-h]z_corners = [w/2,-w/2,-w/2,w/2,w/2,-w/2,-w/2,w/2]# 旋转矩阵点乘(3,8)顶点矩阵corners_3d_cam2 = np.dot(R, np.vstack([x_corners,y_corners,z_corners]))# 加上location中心点,得出8个顶点旋转后的坐标corners_3d_cam2 += np.vstack([x,y,z])return corners_3d_cam2# 记录一个物体的历轨迹
class Object():def __init__(self, center):self.locations = deque(maxlen=20)self.locations.appendleft(center)def update(self, center, displacement, yaw_change):for i in range(len(self.locations)):x0, y0 = self.locations[i]x1 = x0 * np.cos(yaw_change) + y0 * np.sin(yaw_change) - displacementy1 = -x0 * np.sin(yaw_change) + y0 * np.cos(yaw_change)self.locations[i] = np.array([x1, y1])if center is not None:self.locations.appendleft(center)def reset(self):self.locations = deque(maxlen=20)if __name__ == "__main__":frame = 0rospy.init_node("kitti_node", anonymous=True)cam_pub = rospy.Publisher('kitti_cam', Image, queue_size=10)pcl_pub = rospy.Publisher('kitti_point_cloud', PointCloud2, queue_size=10)ego_pub = rospy.Publisher('kitti_ego_car', MarkerArray, queue_size=10)imu_pub = rospy.Publisher('kitti_imu', Imu, queue_size=10)gps_pub = rospy.Publisher('kitti_gps', NavSatFix, queue_size=10)box3d_pub = rospy.Publisher('kitti_3d', MarkerArray, queue_size=10)loc_pub = rospy.Publisher('kitti_loc', MarkerArray, queue_size=10)bridge = CvBridge()df_tracking = read_labelfile('/home/d501//kitti_data/2011_09_26/data_tracking_label_2/training/label_02/0000.txt')calib = Calibration("/home/d501//kitti_data/2011_09_26/2011_09_26_drive_0005_sync/2011_09_26", from_video=True)rate = rospy.Rate(10)tracker = {} # track_id : Objectprev_imu_data = Nonewhile not rospy.is_shutdown():df_tracking_frame = df_tracking[df_tracking.frame==frame]boxes_2d = np.array(df_tracking[df_tracking.frame==frame][['bbox_left','bbox_top','bbox_right','bbox_bottom']])types = np.array(df_tracking[df_tracking.frame==frame]['type'])boxes_3d = np.array(df_tracking_frame[['dimensions_height','dimensions_width','dimensions_length','location_x','location_y','location_z','rotation_y']])track_ids = np.array(df_tracking_frame['track id'])corners_3d_velos = []# 表示当前帧所有检测到物体的中心centers = {} # track_id : centerfor track_id, box_3d in zip(track_ids, boxes_3d):corners_3d_cam2 = compute_3d_box_cam2(*box_3d)corners_3d_velo = calib.project_rect_to_velo(corners_3d_cam2.T)corners_3d_velos += [corners_3d_velo]centers[track_id] = np.mean(corners_3d_velo, axis=0)[:2]image = read_camera(os.path.join(DATA_PATH, 'image_02/data/%010d.png'%frame))point_cloud = read_point_cloud(os.path.join(DATA_PATH, 'velodyne_points/data/%010d.bin'%frame))imu_data = read_imu(os.path.join(DATA_PATH, 'oxts/data/%010d.txt'%frame))if prev_imu_data is None:# 之前没有过数据,则表示第一帧for track_id in centers:tracker[track_id] = Object(centers[track_id])else:displacement = 0.1 * np.linalg.norm(imu_data[['vf', 'vl']])yaw_change = float(imu_data.yaw - prev_imu_data.yaw)# 将当前帧检测到的物体历史轨迹进行更新for track_id in centers:# 如果当前帧检测的物体之前就检测到过if track_id in tracker:tracker[track_id].update(centers[track_id], displacement, yaw_change)else:# 当前帧物体第一次被检测到tracker[track_id] = Object(centers[track_id])# 更新当前帧没有检测到,但是之前检测到过的物体for track_id in tracker:if track_id not in centers:tracker[track_id].update(None, displacement, yaw_change)prev_imu_data = imu_datapublish_camera(cam_pub, bridge, image, boxes_2d, types)publish_point_cloud(pcl_pub, point_cloud)publish_ego_car(ego_pub)publish_imu(imu_pub, imu_data)publish_gps(gps_pub, imu_data)publish_3dbox(box3d_pub, corners_3d_velos, types, track_ids)# 发布历史轨迹publish_loc(loc_pub, tracker, centers)rospy.loginfo("published")rate.sleep()frame += 1if frame == 154:frame = 0for track_id in tracker:tracker[track_id].reset()

 publish_utils.py

#!/usr/bin/env python
#  -*-coding:utf8 -*-
import cv2import rospy
from geometry_msgs.msg import Point
from std_msgs.msg import Header
from sensor_msgs.msg import Image, PointCloud2, Imu, NavSatFix
import sensor_msgs.point_cloud2 as pcl2
from cv_bridge import CvBridge
from tf import transformations
from visualization_msgs.msg import Marker, MarkerArray
import numpy as np
import pandas as pd
import os
FRAME_ID = 'map'DETECTION_COLOR_DICT = {'Car': (255, 255, 0), 'Pedestrian': (0, 226, 255), 'Cyclist': (141, 40, 255)}
LIFETIME = 0.1
LINES = [[0, 1], [1, 2], [2, 3], [3, 0]]  # Lower plane parallel to Z=0 plane
LINES += [[4, 5], [5, 6], [6, 7], [7, 4]]  # Upper plane parallel to Z=0 plane
LINES += [[0, 4], [1, 5], [2, 6], [3, 7]]  # Connections between upper and lower planes
LINES += [[4,1], [5,0]]def publish_camera(cam_pub, bridge, image, boxes, types):for type, box in zip(types, boxes):top_left = int(box[0]), int(box[1])bottom_right = int(box[2]), int(box[3])cv2.rectangle(image, top_left, bottom_right, DETECTION_COLOR_DICT[type], 2)cam_pub.publish(bridge.cv2_to_imgmsg(image, 'bgr8'))def publish_point_cloud(pcl_pub, point_cloud):header = Header()header.stamp = rospy.Time.now()header.frame_id = FRAME_IDpcl_pub.publish(pcl2.create_cloud_xyz32(header, point_cloud[:, :3]))def publish_ego_car(ego_car_pub):"""publish left and right 45 degree FOV lines and ego car model mesh:param ego_car_pub::return:"""marker_array = MarkerArray()marker = Marker()marker.header.frame_id = FRAME_IDmarker.header.stamp = rospy.Time.now()marker.id = 0marker.action = Marker.ADDmarker.lifetime = rospy.Duration()marker.type = Marker.LINE_STRIPmarker.color.r = 0.0marker.color.g = 1.0marker.color.b = 0.0marker.color.a = 1.0marker.scale.x = 0.2marker.points = []marker.points.append(Point(10, -10, 0))marker.points.append(Point(0, 0, 0))marker.points.append(Point(10, 10, 0))marker_array.markers.append(marker)mech_marker = Marker()mech_marker.header.frame_id = "map"mech_marker.header.stamp = rospy.Time.now()mech_marker.id = -1mech_marker.type = Marker.MESH_RESOURCEmech_marker.action = Marker.ADDmech_marker.lifetime = rospy.Duration()mech_marker.mesh_resource = "package://kitti_tutorial/meshes/Car.dae"mech_marker.pose.position.x = 0.0mech_marker.pose.position.y = 0.0mech_marker.pose.position.z = -1.73q = transformations.quaternion_from_euler(np.pi, np.pi, -np.pi / 2.0)mech_marker.pose.orientation.x = q[0]mech_marker.pose.orientation.y = q[1]mech_marker.pose.orientation.z = q[2]mech_marker.pose.orientation.w = q[3]mech_marker.color.r = 1.0mech_marker.color.g = 1.0mech_marker.color.b = 1.0mech_marker.color.a = 1.0mech_marker.scale.x = 1.0mech_marker.scale.y = 1.0mech_marker.scale.z = 1.0marker_array.markers.append(mech_marker)ego_car_pub.publish(marker_array)def publish_imu(imu_pub, imu_data):imu = Imu()imu.header.frame_id = "map"imu.header.stamp = rospy.Time.now()q = transformations.quaternion_from_euler(float(imu_data.roll), float(imu_data.pitch), float(imu_data.yaw))imu.orientation.x = q[0]imu.orientation.y = q[1]imu.orientation.z = q[2]imu.orientation.w = q[3]imu.linear_acceleration.x = imu_data.afimu.linear_acceleration.y = imu_data.alimu.linear_acceleration.z = imu_data.auimu.angular_velocity.x = imu_data.wximu.angular_velocity.y = imu_data.wyimu.angular_velocity.z = imu_data.wzimu_pub.publish(imu)def publish_gps(gps_pub, gps_data):gps = NavSatFix()gps.header.frame_id = "map"gps.header.stamp = rospy.Time.now()gps.latitude = gps_data.latgps.longitude = gps_data.longps.altitude = gps_data.altgps_pub.publish(gps)def publish_3dbox(box3d_pub, corners_3d_velos, types, track_ids):marker_array = MarkerArray()for i, corners_3d_velo in enumerate(corners_3d_velos):marker = Marker()marker.header.frame_id = FRAME_IDmarker.header.stamp = rospy.Time.now()marker.id = imarker.action = Marker.ADDmarker.lifetime = rospy.Duration(LIFETIME)marker.type = Marker.LINE_LISTb, g, r = DETECTION_COLOR_DICT[types[i]]marker.color.r = r/255.0marker.color.g = g/255.0marker.color.b = b/255.0marker.color.a = 1.0marker.scale.x = 0.1marker.points = []for l in LINES:p1 = corners_3d_velo[l[0]]marker.points.append(Point(p1[0], p1[1], p1[2]))p2 = corners_3d_velo[l[1]]marker.points.append(Point(p2[0], p2[1], p2[2]))marker_array.markers.append(marker)# 添加track_idtext_marker = Marker()text_marker.header.frame_id = FRAME_IDtext_marker.header.stamp = rospy.Time.now()text_marker.id = i + 1000text_marker.action = Marker.ADDtext_marker.lifetime = rospy.Duration(LIFETIME)text_marker.type = Marker.TEXT_VIEW_FACING# 计算中心点的位置p = np.mean(corners_3d_velo, axis=0) # upper front left cornertext_marker.pose.position.x = p[0]text_marker.pose.position.y = p[1]text_marker.pose.position.z = p[2] + 1text_marker.text = str(track_ids[i])text_marker.scale.x = 1text_marker.scale.y = 1text_marker.scale.z = 1b, g, r = DETECTION_COLOR_DICT[types[i]]text_marker.color.r = r/255.0text_marker.color.g = g/255.0text_marker.color.b = b/255.0text_marker.color.a = 1.0marker_array.markers.append(text_marker)box3d_pub.publish(marker_array)# 发布历史轨迹
def publish_loc(loc_pub, tracker, centers):marker_array = MarkerArray()for track_id in centers:marker = Marker()marker.header.frame_id = FRAME_IDmarker.header.stamp = rospy.Time.now()marker.action = Marker.ADDmarker.lifetime = rospy.Duration(LIFETIME)marker.type = Marker.LINE_STRIPmarker.id = track_idmarker.color.r = 1.0marker.color.g = 0.0marker.color.b = 0.0marker.color.a = 1.0marker.scale.x = 0.2marker.points = []for p in tracker[track_id].locations:marker.points.append(Point(p[0], p[1], 0))marker_array.markers.append(marker)loc_pub.publish(marker_array)

 

 显示所有物体到汽车最近的距离

添加两个函数:

def distance_point_to_segment(P, A, B):"""Calculate the min distance of a point P to a segment AB.Return the point Q in AB on which the min distance is reached.:param P::param A::param B::return:"""AP = P - ABP = P - BAB = B - A# 如果是锐角三角形if np.dot(AB, AP) >= 0 and np.dot(-AB, BP) >= 0:return np.abs(np.cross(AP, AB))/np.linalg.norm(AB), np.dot(AP, AB)/np.dot(AB, AB) * AB + A# 如果是钝角三角形d_PA = np.linalg.norm(AP)d_PB = np.linalg.norm(BP)if d_PA < d_PB:return d_PA, Areturn d_PB, Bdef min_distance_cuboids(cub1, cub2):"""Computes the minimum distance between two non-overlapping cuboids (3D) of shape (8, 3)They are projected to BEV and the minium distance of the two rectangles are returned:param cub1::param cub2::return:"""minD = 1e5for i in range(4):for j in range(4):d, Q = distance_point_to_segment(cub1[i, :2], cub2[j, :2], cub2[j+1, :2])if d < minD:minD = dminP = cub1[i, :2]minQ = Qfor i in range(4):for j in range(4):d, Q = distance_point_to_segment(cub2[i, :2], cub1[j, :2], cub1[j+1, :2])if d < minD:minD = dminP = cub2[i, :2]minQ = Qreturn minP, minQ, minD

 修改kitti.py

#!/usr/bin/env python
#  -*-coding:utf8 -*-
import numpy as np
from collections import dequeimport rospyfrom data_utils import *
from publish_utils import *
from kitti_util import *
import osDATA_PATH = "/home/d501/kitti_data/2011_09_26/2011_09_26_drive_0005_sync/2011_09_26/2011_09_26_drive_0005_sync"
EGOCAR = np.array([[2.15, 0.9, -1.73], [2.15, -0.9, -1.73], [-1.95, -0.9, -1.73], [-1.95, 0.9, -1.73],[2.15, 0.9, -0.23], [2.15, -0.9, -0.23], [-1.95, -0.9, -0.23], [-1.95, 0.9, -0.23]])def compute_3d_box_cam2(h, w, l, x, y, z, yaw):# 计算旋转矩阵R = np.array([[np.cos(yaw), 0, np.sin(yaw)], [0, 1, 0], [-np.sin(yaw), 0, np.cos(yaw)]])# 8个顶点的xyzx_corners = [l/2,l/2,-l/2,-l/2,l/2,l/2,-l/2,-l/2]y_corners = [0,0,0,0,-h,-h,-h,-h]z_corners = [w/2,-w/2,-w/2,w/2,w/2,-w/2,-w/2,w/2]# 旋转矩阵点乘(3,8)顶点矩阵corners_3d_cam2 = np.dot(R, np.vstack([x_corners,y_corners,z_corners]))# 加上location中心点,得出8个顶点旋转后的坐标corners_3d_cam2 += np.vstack([x,y,z])return corners_3d_cam2# 记录一个物体的历轨迹
class Object():def __init__(self, center):self.locations = deque(maxlen=20)self.locations.appendleft(center)def update(self, center, displacement, yaw_change):for i in range(len(self.locations)):x0, y0 = self.locations[i]x1 = x0 * np.cos(yaw_change) + y0 * np.sin(yaw_change) - displacementy1 = -x0 * np.sin(yaw_change) + y0 * np.cos(yaw_change)self.locations[i] = np.array([x1, y1])if center is not None:self.locations.appendleft(center)def reset(self):self.locations = deque(maxlen=20)if __name__ == "__main__":frame = 0rospy.init_node("kitti_node", anonymous=True)cam_pub = rospy.Publisher('kitti_cam', Image, queue_size=10)pcl_pub = rospy.Publisher('kitti_point_cloud', PointCloud2, queue_size=10)ego_pub = rospy.Publisher('kitti_ego_car', MarkerArray, queue_size=10)imu_pub = rospy.Publisher('kitti_imu', Imu, queue_size=10)gps_pub = rospy.Publisher('kitti_gps', NavSatFix, queue_size=10)box3d_pub = rospy.Publisher('kitti_3d', MarkerArray, queue_size=10)loc_pub = rospy.Publisher('kitti_loc', MarkerArray, queue_size=10)# 显示车距dist_pub = rospy.Publisher('kitti_dist', MarkerArray, queue_size=10)bridge = CvBridge()df_tracking = read_labelfile('/home/d501//kitti_data/2011_09_26/data_tracking_label_2/training/label_02/0000.txt')calib = Calibration("/home/d501//kitti_data/2011_09_26/2011_09_26_drive_0005_sync/2011_09_26", from_video=True)rate = rospy.Rate(10)# 所有物体tracker = {} # track_id : Objectprev_imu_data = Nonewhile not rospy.is_shutdown():df_tracking_frame = df_tracking[df_tracking.frame==frame]boxes_2d = np.array(df_tracking[df_tracking.frame==frame][['bbox_left','bbox_top','bbox_right','bbox_bottom']])types = np.array(df_tracking[df_tracking.frame==frame]['type'])boxes_3d = np.array(df_tracking_frame[['dimensions_height','dimensions_width','dimensions_length','location_x','location_y','location_z','rotation_y']])track_ids = np.array(df_tracking_frame['track id'])corners_3d_velos = []# 表示当前帧所有检测到物体的中心centers = {} # track_id : center# 最短距离和点minPQDs = []for track_id, box_3d in zip(track_ids, boxes_3d):corners_3d_cam2 = compute_3d_box_cam2(*box_3d)corners_3d_velo = calib.project_rect_to_velo(corners_3d_cam2.T)minPQDs.append(min_distance_cuboids(EGOCAR, corners_3d_velo))corners_3d_velos += [corners_3d_velo]centers[track_id] = np.mean(corners_3d_velo, axis=0)[:2]corners_3d_velos.append(EGOCAR)types = np.append(types, 'Car')track_ids = np.append(track_ids, -1)# 表示汽车本身centers[-1] = np.array([0, 0])image = read_camera(os.path.join(DATA_PATH, 'image_02/data/%010d.png'%frame))point_cloud = read_point_cloud(os.path.join(DATA_PATH, 'velodyne_points/data/%010d.bin'%frame))imu_data = read_imu(os.path.join(DATA_PATH, 'oxts/data/%010d.txt'%frame))if prev_imu_data is None:# 之前没有过数据,则表示第一帧for track_id in centers:tracker[track_id] = Object(centers[track_id])else:displacement = 0.1 * np.linalg.norm(imu_data[['vf', 'vl']])yaw_change = float(imu_data.yaw - prev_imu_data.yaw)# 将当前帧检测到的物体历史轨迹进行更新for track_id in centers:# 如果当前帧检测的物体之前就检测到过if track_id in tracker:tracker[track_id].update(centers[track_id], displacement, yaw_change)else:# 当前帧物体第一次被检测到tracker[track_id] = Object(centers[track_id])# 更新当前帧没有检测到,但是之前检测到过的物体for track_id in tracker:if track_id not in centers:tracker[track_id].update(None, displacement, yaw_change)prev_imu_data = imu_datapublish_camera(cam_pub, bridge, image, boxes_2d, types)publish_point_cloud(pcl_pub, point_cloud)publish_ego_car(ego_pub)publish_imu(imu_pub, imu_data)publish_gps(gps_pub, imu_data)publish_3dbox(box3d_pub, corners_3d_velos, types, track_ids)# 发布历史轨迹publish_loc(loc_pub, tracker, centers)publish_dist(dist_pub, minPQDs)rospy.loginfo("published")rate.sleep()frame += 1if frame == 154:frame = 0for track_id in tracker:tracker[track_id].reset()

 publish_utils.py添加函数

def publish_dist(dist_pub, minPQDs):marker_array = MarkerArray()for i, (minP, minQ, minD) in enumerate(minPQDs):marker = Marker()marker.header.frame_id = FRAME_IDmarker.header.stamp = rospy.Time.now()marker.action = Marker.ADDmarker.lifetime = rospy.Duration(LIFETIME)marker.type = Marker.LINE_STRIPmarker.id = imarker.color.r = 1.0marker.color.g = 0.0marker.color.b = 1.0marker.color.a = 0.5marker.scale.x = 0.1marker.points = []marker.points.append(Point(minP[0], minP[1], 0))marker.points.append(Point(minQ[0], minQ[1], 0))marker_array.markers.append(marker)text_marker = Marker()text_marker.header.frame_id = FRAME_IDtext_marker.header.stamp = rospy.Time.now()text_marker.id = i + 1000text_marker.action = Marker.ADDtext_marker.lifetime = rospy.Duration(LIFETIME)text_marker.type = Marker.TEXT_VIEW_FACINGp = (minP + minQ) / 2.0text_marker.pose.position.x = p[0]text_marker.pose.position.y = p[1]text_marker.pose.position.z = 0text_marker.text = '%.2f'%minDtext_marker.scale.x = 1text_marker.scale.y = 1text_marker.scale.z = 1text_marker.color.r = 1.0text_marker.color.g = 1.0text_marker.color.b = 1.0text_marker.color.r = 0.0marker_array.markers.append(text_marker)dist_pub.publish(marker_array)

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/704059.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Pytorch训练RCAN QAT超分模型

Pytorch训练RCAN QAT超分模型 版本信息测试步骤准备数据集创建容器生成文件列表创建文件列表的代码执行脚本,生成文件列表训练RCAN模型准备工作修改开源代码编写训练代码执行训练脚本可视化本文以RCAN超分模型为例,演示了QAT的训练过程,步骤如下: 先训练FP32模型再加载FP32训练…

【随笔】固态硬盘数据删除无法恢复(开启TRIM),注意数据备份

文章目录 一、序二、机械硬盘和固态硬盘的物理结构与工作原理2.1 机械硬盘2.11 基本结构2.12 工作原理 2.2 固态硬盘2.21 基本结构2.22 工作原理 三、机械硬盘和固态硬盘的垃圾回收机制3.1 机械硬盘GC3.2 固态硬盘GC3.3 TRIM指令开启和关闭 四、做好数据备份 一、序 周末电脑突…

【Qt学习】QLineEdit 控件 属性与实例(登录界面,验证密码,正则表达式)

文章目录 1. 介绍2. 实例使用2.1 登录界面2.2 对比两次密码是否相同2.3 通过按钮显示当前输入的密码&#xff08;并对2.2进行优化&#xff09;2.4 结语 3. 正则表达式3.1 QRegExp3.2 验证输入内容 4. 资源代码 1. 介绍 关于 QLineEdit 的详细介绍&#xff0c;可以去查阅官方文…

[计算机网络]--IP协议

前言 作者&#xff1a;小蜗牛向前冲 名言&#xff1a;我可以接受失败&#xff0c;但我不能接受放弃 如果觉的博主的文章还不错的话&#xff0c;还请点赞&#xff0c;收藏&#xff0c;关注&#x1f440;支持博主。如果发现有问题的地方欢迎❀大家在评论区指正 目录 一、IP协议…

202432读书笔记|《泰戈尔的诗》——什么事让你大笑,我生命的小蓓蕾

202432读书笔记|《泰戈尔的诗》——什么事让你大笑&#xff0c;我生命的小蓓蕾 《泰戈尔写给孩子的诗&#xff08;中英双语版&#xff09;》作者拉宾德拉纳特泰戈尔文 张王哲图&#xff0c;图文并茂的一本书&#xff0c;文字与图画都很美&#xff0c;相得益彰&#xff01;很值得…

【Memory协议栈】EEPROM Abstraction模块详细介绍

目录 前言 正文 1.功能简介 2.关键概念 3.功能详解 3.1 Addressing scheme and segmentation 3.2 Address calculation 3.3 Limitation of erase / write cycles 3.4 Handling of “immediate” data 3.5 Managing block consistency information 4.关键API定义 4.…

学习磁盘管理

文章目录 一、磁盘接口类型二、磁盘设备的命名三、fdisk分区四、自动挂载五、扩容swap六、GPT分区七、逻辑卷管理八、磁盘配额九、RAID十、软硬链接 一、磁盘接口类型 IDE、SATA、SCSI、SAS、FC&#xff08;光纤通道&#xff09; IDE, 该接口是并口。SATA, 该接口是串口。SCS…

golang学习2,golang开发配置国内镜像

go env -w GO111MODULEon go env -w GOPROXYhttps://goproxy.cn,direct

K8S部署Java项目(Gitlab CI/CD自动化部署终极版)

天行健&#xff0c;君子以自强不息&#xff1b;地势坤&#xff0c;君子以厚德载物。 每个人都有惰性&#xff0c;但不断学习是好好生活的根本&#xff0c;共勉&#xff01; 文章均为学习整理笔记&#xff0c;分享记录为主&#xff0c;如有错误请指正&#xff0c;共同学习进步。…

websocket入门及应用

websocket When to use a HTTP call instead of a WebSocket (or HTTP 2.0) WebSocket 是基于TCP/IP协议&#xff0c;独立于HTTP协议的通信协议。WebSocket 是双向通讯&#xff0c;有状态&#xff0c;客户端一&#xff08;多&#xff09;个与服务端一&#xff08;多&#xff09…

代码随想录刷题第43天

第一题是最后一块石头的重量IIhttps://leetcode.cn/problems/last-stone-weight-ii/&#xff0c;没啥思路&#xff0c;直接上题解了。本题可以看作将一堆石头尽可能分成两份重量相似的石头&#xff0c;于是问题转化为如何合理取石头&#xff0c;使其装满容量为石头总重量一半的…

【AI Agent系列】【MetaGPT多智能体学习】0. 环境准备 - 升级MetaGPT 0.7.2版本及遇到的坑

之前跟着《MetaGPT智能体开发入门课程》学了一些MetaGPT的知识和实践&#xff0c;主要关注在MetaGPT入门和单智能体部分&#xff08;系列文章附在文末&#xff0c;感兴趣的可以看下&#xff09;。现在新的教程来了&#xff0c;新教程主要关注多智能体部分。 本系列文章跟随《M…

Wagtail安装运行并结合内网穿透实现公网访问本地网站界面

文章目录 前言1. 安装并运行Wagtail1.1 创建并激活虚拟环境 2. 安装cpolar内网穿透工具3. 实现Wagtail公网访问4. 固定的Wagtail公网地址 正文开始前给大家推荐个网站&#xff0c;前些天发现了一个巨牛的 人工智能学习网站&#xff0c; 通俗易懂&#xff0c;风趣幽默&#xf…

C++Lambda表达式介绍

C11中引入了Lambda表达式&#xff0c;Lambda表达式是一种匿名函数&#xff0c;它可以在需要函数的地方直接定义和使用&#xff0c;而无需显式地定义一个函数。 lambda表达式 Lambda表达式语法定义 [capture-list](parameters) -> return-type { statement } capture-lis…

SQL Developer 小贴士:PL/SQL语法分析

对于SQL或PL/SQL中的语法错误和警告&#xff0c;SQL Developer可以用不同颜色的下划波浪线显示。 启用语法分析&#xff0c;可以用菜单Tool>Preferences>Code Editor>Completion Insight>Enable Semantic Analysis Info Tips 例如&#xff0c;以下的代码中&…

blender bvh显示关节名称

导入bvh&#xff0c;菜单选择布局&#xff0c;右边出现属性窗口&#xff0c; 在下图红色框依次点击选中&#xff0c;就可以查看bvh关节名称了。

自考《计算机网络原理》考前冲刺

常考选择填空 1、计算机网络的定义&#xff1a;计算机网络是互连的、自治的计算机的集合。 2、协议的定义&#xff1a;协议是网络通信实体之间在数据交换过程中需要遵循的规则或约定 3、协议的3个要素 (1) 语法&#xff1a;定义实体之间交换信息的格式与结构&#xff0c;或…

设计模式六:策略模式

1、策略模式 策略模式定义了一系列的算法&#xff0c;并将每一个算法封装起来&#xff0c;使每个算法可以相互替代&#xff0c;使算法本身和使用算法的客户端分割开来&#xff0c;相互独立。 策略模式的角色&#xff1a; 策略接口角色IStrategy&#xff1a;用来约束一系列具体…

第一次开机开机动画结束后闪白屏

开机动画结束会闪下白屏&#xff0c;再进入launcher 思路 : 分析下从开机动画结束到launcher起来之间的流程步骤 从ZygoteInit.java开始分析 &#xff1a; SystemServer起来后会启动一些核心服务 attachApplication方法中主要创建了Application和Activity 接下里RootActivityC…

快速搭建网站原型!8款网站原型软件推荐

现在&#xff0c;基于云的软件已经逐渐成为主流&#xff0c;网站原型设计工具也不例外。与桌面版本相比&#xff0c;在线原型工具具有独特的优势&#xff0c;无论您使用Linux&#xff0c;Mac 或者Windows&#xff0c;都不需要安装就可以使用这些工具。下面小编就为大家推荐8款非…