CARLA
 
载入中...
搜索中...
未找到
EpisodeState.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/Iterator.h"
10#include "carla/ListView.h"
11#include "carla/NonCopyable.h"
16
17#include <boost/optional.hpp>
18
19#include <memory>
20#include <unordered_map>
21
22namespace carla {
23namespace client {
24namespace detail {
25
26 /// Represents the state of all the actors of an episode at a given frame.
28 : public std::enable_shared_from_this<EpisodeState>,
29 private NonCopyable {
30
32
33 public:
34
35 explicit EpisodeState(uint64_t episode_id) : _episode_id(episode_id) {}
36
37 explicit EpisodeState(const sensor::data::RawEpisodeState &state);
38
39 auto GetEpisodeId() const {
40 return _episode_id;
41 }
42
43 auto GetFrame() const {
44 return _timestamp.frame;
45 }
46
47 const auto &GetTimestamp() const {
48 return _timestamp;
49 }
50
54
55 bool HasMapChanged() const {
56 return (_simulation_state & SimulationState::MapChange) != SimulationState::None;
57 }
58
59 bool IsLightUpdatePending() const {
60 return (_simulation_state & SimulationState::PendingLightUpdate) != 0;
61 }
62
63 bool ContainsActorSnapshot(ActorId actor_id) const {
64 return _actors.find(actor_id) != _actors.end();
65 }
66
68 ActorSnapshot state;
70 return state;
71 }
72
73 boost::optional<ActorSnapshot> GetActorSnapshotIfPresent(ActorId id) const {
74 boost::optional<ActorSnapshot> state;
76 return state;
77 }
78
84
85 size_t size() const {
86 return _actors.size();
87 }
88
89 auto begin() const {
91 }
92
93 auto end() const {
95 }
96
97 private:
98
99 template <typename T>
100 void CopyActorSnapshotIfPresent(ActorId id, T &value) const {
101 auto it = _actors.find(id);
102 if (it != _actors.end()) {
103 value = it->second;
104 }
105 }
106
107 const uint64_t _episode_id;
108
110
112
114
115 std::unordered_map<ActorId, ActorSnapshot> _actors;
116 };
117
118} // namespace detail
119} // namespace client
120} // namespace carla
Inherit (privately) to suppress copy/move construction and assignment.
std::size_t frame
Number of frames elapsed since the simulator was launched.
Definition Timestamp.h:30
Represents the state of all the actors of an episode at a given frame.
EpisodeState(uint64_t episode_id)
ActorSnapshot GetActorSnapshot(ActorId id) const
const auto & GetTimestamp() const
boost::optional< ActorSnapshot > GetActorSnapshotIfPresent(ActorId id) const
SimulationState GetsimulationState() const
std::unordered_map< ActorId, ActorSnapshot > _actors
void CopyActorSnapshotIfPresent(ActorId id, T &value) const
bool ContainsActorSnapshot(ActorId actor_id) const
State of the episode at a given frame.
static auto make_map_keys_const_iterator(It it)
Creates an iterator over const references to the keys of a map.
Definition Iterator.h:25
static auto make_map_values_const_iterator(It it)
Creates an iterator over const references to the values of a map.
Definition Iterator.h:43
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133
static auto MakeListView(Iterator begin, Iterator end)