CARLA
 
载入中...
搜索中...
未找到
ObstacleDetectionEvent.h
浏览该文件的文档.
1// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
9#include "carla/Debug.h" // 包含carla的调试功能
11#include "carla/sensor/SensorData.h" //包含carla传感器数据基类
12#include "carla/sensor/s11n/ObstacleDetectionEventSerializer.h" // 包含障碍物检测事件的序列化器
13
14
15namespace carla {
16namespace sensor {
17namespace data {
18
19 // 定义一个注册的检测事件类
20 class ObstacleDetectionEvent : public SensorData { // 继承自SensorData基类
21 using Super = SensorData; // 使用Super作为SensorData的别名,方便引用基类成员
22 protected:
23
24 using Serializer = s11n::ObstacleDetectionEventSerializer; // 使用Serializer作为ObstacleDetectionEventSerializer的别名
25
26 friend Serializer; // 声明Serializer为友元类,允许访问私有成员
27
28 explicit ObstacleDetectionEvent(const RawData &data) // 构造函数,从原始数据中反序列化ObstacleDetectionEvent对象
29 : Super(data), // 调用基类构造函数
30 _self_actor(nullptr), // 初始化_self_actor为nullptr
31 _other_actor(nullptr) { // 初始化_other_actor为nullptr
32 auto ddata = Serializer::DeserializeRawData(data); // 反序列化原始数据
33 _self_actor = std::move(ddata.self_actor); // 移动self_actor数据
34 _other_actor = std::move(ddata.other_actor); // 移动other_actor数据
35 _distance = ddata.distance; // 赋值distance
36 }
37
38 public:
39
40 // 获取检测到碰撞的“自身”actor
42 return _self_actor.Get(GetEpisode()); // 使用GetEpisode获取当前剧集,并获取actor
43 }
44
45 // 获取发生碰撞的“其他”actor
47 return _other_actor.Get(GetEpisode()); // 使用GetEpisode获取当前剧集,并获取actor
48 }
49
50 // 获取障碍物距离
51 float GetDistance() const {
52 return _distance; // 返回距离值
53 }
54
55 private:
56
57 client::detail::ActorVariant _self_actor; // 存储自身actor的变体类型
58
59 client::detail::ActorVariant _other_actor; // 存储其他actor的变体类型
60
61 float _distance; // 存储障碍物检测到的距离
62 };
63
64} // namespace data
65} // namespace sensor
66} // namespace carla
创建一个执行者, 只在需要的时候实例化.
SharedPtr< client::Actor > Get(EpisodeProxy episode) const
包装一个传感器生成的原始数据以及一些有用的元信息。
Definition RawData.h:20
所有传感器生成数据的对象的基类
Definition SensorData.h:22
const auto & GetEpisode() const
Definition SensorData.h:57
SensorData(size_t frame, double timestamp, const rpc::Transform &sensor_transform)
Definition SensorData.h:26
SharedPtr< client::Actor > GetActor() const
SharedPtr< client::Actor > GetOtherActor() const
Serializes the current state of the whole episode.
CARLA模拟器的主命名空间。
Definition Carla.cpp:139
boost::shared_ptr< T > SharedPtr
使用这个SharedPtr(boost::shared_ptr)以保持与boost::python的兼容性, 但未来如果可能的话,我们希望能为std::shared_ptr制作一个Python适配器。
Definition Memory.h:19