微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决使用来自异步传感器的数据创建图

我正在尝试使用从车辆中的传感器收集的数据来创建绘图(我正在使用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 举报,一经查实,本站将立刻删除。