12#include <unordered_map>
13#include <unordered_set>
26 return GetEpisode().
Lock()->GetActorSnapshot(*this).state.traffic_light_data.state;
36 return GetEpisode().
Lock()->GetActorSnapshot(*this).state.traffic_light_data.green_time;
41 GetEpisode().
Lock()->SetTrafficLightYellowTime(*
this, yellow_time);
46 return GetEpisode().
Lock()->GetActorSnapshot(*this).state.traffic_light_data.yellow_time;
56 return GetEpisode().
Lock()->GetActorSnapshot(*this).state.traffic_light_data.red_time;
61 return GetEpisode().
Lock()->GetActorSnapshot(*this).state.traffic_light_data.elapsed_time;
72 return GetEpisode().
Lock()->GetActorSnapshot(*this).state.traffic_light_data.time_is_frozen;
78 return GetEpisode().
Lock()->GetActorSnapshot(*this).state.traffic_light_data.pole_index;
83 std::vector<SharedPtr<TrafficLight>> result;
89 result.push_back(boost::static_pointer_cast<TrafficLight>(actor));
102 std::vector<SharedPtr<Waypoint>> result;
104 std::vector<SharedPtr<Landmark>> landmarks = carla_map->GetLandmarksFromId(
GetOpenDRIVEID());
105 for (
auto& landmark : landmarks) {
109 if (validity._from_lane < validity._to_lane) {
110 for (
int lane_id = validity._from_lane; lane_id <= validity._to_lane; ++lane_id) {
111 if(lane_id == 0)
continue;
113 carla_map->GetWaypointXODR(
114 landmark->GetRoadId(), lane_id,
static_cast<float>(landmark->GetS())));
117 for (
int lane_id = validity._from_lane; lane_id >= validity._to_lane; --lane_id) {
118 if(lane_id == 0)
continue;
120 carla_map->GetWaypointXODR(
121 landmark->GetRoadId(), lane_id,
static_cast<float>(landmark->GetS())));
137 return GetEpisode().
Lock()->GetActorSnapshot(*this).state.traffic_light_data.sign_id;
142 std::vector<SharedPtr<Waypoint>> result;
156 float min_x = -0.9f*box.
extent.
x;
157 float max_x = 0.9f*box.
extent.
x;
158 float current_x = min_x;
160 std::unordered_map<road::RoadId, std::unordered_set<road::LaneId>> road_lanes_map;
162 while (current_x < max_x) {
168 if (road_lanes_map[waypoint->GetRoadId()].count(waypoint->GetLaneId()) == 0) {
170 road_lanes_map[waypoint->GetRoadId()].insert(waypoint->GetLaneId());
172 result.emplace_back(waypoint);
geom::Transform GetTransform() const
返回行为体的当前变换(位置和方向)。
void SetGreenTime(float green_time)
void SetYellowTime(float yellow_time)
float GetElapsedTime() const
rpc::TrafficLightState GetState() const
返回交通灯的当前状态。
road::SignId GetOpenDRIVEID() const
std::vector< SharedPtr< TrafficLight > > GetGroupTrafficLights()
返回该交通灯所属组中的所有交通灯。
void SetState(rpc::TrafficLightState state)
uint32_t GetPoleIndex()
返回交通信号灯组中灯杆的索引 // 获取交通信号灯组中灯杆的索引值的函数,返回一个uint32_t类型的索引值,用于标识交通灯在所属灯组中的具体位置等相关信息
std::vector< geom::BoundingBox > GetLightBoxes() const
std::vector< SharedPtr< Waypoint > > GetStopWaypoints() const
std::vector< SharedPtr< Waypoint > > GetAffectedLaneWaypoints() const
float GetGreenTime() const
void SetRedTime(float red_time)
float GetYellowTime() const
const geom::BoundingBox & GetTriggerVolume() const
SharedPtr< ActorList > GetActors() const
返回一个包含当前世界上所有存在的参与者(actor)的列表。 获取整个模拟世界中所有参与者的集合,便于进行批量操作、统计或者遍历所有实体执行某些通用的操作等。
EpisodeProxy & GetEpisode()
SharedPtrType Lock() const
与 TryLock 相同,但永远不会返回 nullptr。
Location location
边界框的中心位置(本地坐标系下)
Vector3D extent
边界框的半尺寸(本地坐标系下,表示在每个轴方向上的半宽、半高和半深)
boost::shared_ptr< T > SharedPtr
使用这个SharedPtr(boost::shared_ptr)以保持与boost::python的兼容性, 但未来如果可能的话,我们希望能为std::shared_ptr制作一个Python适配器。