使用来自异步传感器的数据创建图

问题描述

我正在尝试使用从车辆中的传感器收集的数据来创建绘图(我正在使用Carla Simulator),而我所困扰的问题是数据是异步收集的,如果我尝试显示在收集每个数据之后的图表中,我已经看到控制台中对plt.show()的调用过多而产生了一些回溯。 收集数据的功能示例:

def collision_event_handler(event):
    actor_we_collide_against = event.other_actor
    impulse = event.normal_impulse 
    intensity = math.sqrt(impulse.x**2 + impulse.y**2 + impulse.z**2)
    print("Ego vehicle collided with " + actor_we_collide_against.type_id + 
        ". The collision has an intensity of " + str(intensity))
    actors_collisions.append(actor_we_collide_against)
    impacts_values.append(intensity)
    plt.plot(actors_collisions,impacts_values)
    plt.xlabel('Actors which collided with Ego vehicle')
    plt.ylabel('Collisions impact values')
    plt.show()

def get_data_sensor_collision(sensor,collision_sensor_on):
    if collision_sensor_on and 'collision' in sensor.type_id:
        print('\nCreated %s and it\'s running' % sensor.type_id)
        sensor.listen(lambda event: collision_event_handler(event))

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)