Ejemplo n.º 1
0
def process(control_analyzer, planning_analyzer, lidar_endtoend_analyzer,
            is_simulation, plot_planning_path, plot_planning_refpath, all_data):
    is_auto_drive = False

    for msg in reader.read_messages():
        if msg.topic == "/apollo/canbus/chassis":
            chassis = chassis_pb2.Chassis()
            chassis.ParseFromString(msg.message)
            if chassis.driving_mode == \
                    chassis_pb2.Chassis.COMPLETE_AUTO_DRIVE:
                is_auto_drive = True
            else:
                is_auto_drive = False

        if msg.topic == "/apollo/control":
            if (not is_auto_drive and not all_data) or \
                    is_simulation or plot_planning_path or plot_planning_refpath:
                continue
            control_cmd = control_cmd_pb2.ControlCommand()
            control_cmd.ParseFromString(msg.message)
            control_analyzer.put(control_cmd)
            lidar_endtoend_analyzer.put_pb('control', control_cmd)

        if msg.topic == "/apollo/planning":
            if (not is_auto_drive) and (not all_data):
                continue
            adc_trajectory = planning_pb2.ADCTrajectory()
            adc_trajectory.ParseFromString(msg.message)
            planning_analyzer.put(adc_trajectory)
            lidar_endtoend_analyzer.put_pb('planning', adc_trajectory)

            if plot_planning_path:
                planning_analyzer.plot_path(plt, adc_trajectory)
            if plot_planning_refpath:
                planning_analyzer.plot_refpath(plt, adc_trajectory)

        if msg.topic == "/apollo/sensor/velodyne64/compensator/PointCloud2" or \
                msg.topic == "/apollo/sensor/lidar128/compensator/PointCloud2":
            if ((not is_auto_drive) and (not all_data)) or is_simulation or \
                    plot_planning_path or plot_planning_refpath:
                continue
            point_cloud = pointcloud_pb2.PointCloud()
            point_cloud.ParseFromString(msg.message)
            lidar_endtoend_analyzer.put_lidar(point_cloud)

        if msg.topic == "/apollo/perception/obstacles":
            if ((not is_auto_drive) and (not all_data)) or is_simulation or \
                    plot_planning_path or plot_planning_refpath:
                continue
            perception = perception_obstacle_pb2.PerceptionObstacles()
            perception.ParseFromString(msg.message)
            lidar_endtoend_analyzer.put_pb('perception', perception)

        if msg.topic == "/apollo/prediction":
            if ((not is_auto_drive) and (not all_data)) or is_simulation or \
                    plot_planning_path or plot_planning_refpath:
                continue
            prediction = prediction_obstacle_pb2.PredictionObstacles()
            prediction.ParseFromString(msg.message)
            lidar_endtoend_analyzer.put_pb('prediction', prediction)
Ejemplo n.º 2
0
def generate_message(topic, filename):
    """generate message from file"""
    message = None
    if topic == "/apollo/planning":
        message = planning_pb2.ADCTrajectory()
    elif topic == "/apollo/localization/pose":
        message = localization_pb2.LocalizationEstimate()
    elif topic == "/apollo/perception/obstacles":
        message = perception_obstacle_pb2.PerceptionObstacles()
    elif topic == "/apollo/prediction":
        message = prediction_obstacle_pb2.PredictionObstacles()
    elif topic == "/apollo/routing_response":
        message = routing_pb2.RoutingResponse()
    if not message:
        print "Unknown topic:", topic
        sys.exit(0)
    if not os.path.exists(filename):
        return None
    f_handle = file(filename, 'r')
    text_format.Merge(f_handle.read(), message)
    f_handle.close()
    return message