CARLA
 
载入中...
搜索中...
未找到
WorldSnapshot.h
浏览该文件的文档.
1// Copyright (c) 2019 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
12
13#include <boost/optional.hpp>
14
15namespace carla {
16namespace client {
17
19 public:
20
21 WorldSnapshot(std::shared_ptr<const detail::EpisodeState> state)
22 : _state(std::move(state)) {}
23
24 /// Get the id of the episode associated with this world.
25 uint64_t GetId() const {
26 return _state->GetEpisodeId();
27 }
28
29 size_t GetFrame() const {
30 return GetTimestamp().frame;
31 }
32
33 /// Get timestamp of this snapshot.
34 const Timestamp &GetTimestamp() const {
35 return _state->GetTimestamp();
36 }
37
38 /// Check if an actor is present in this snapshot.
39 bool Contains(ActorId actor_id) const {
40 return _state->ContainsActorSnapshot(actor_id);
41 }
42
43 /// Find an ActorSnapshot by id.
44 boost::optional<ActorSnapshot> Find(ActorId actor_id) const {
45 return _state->GetActorSnapshotIfPresent(actor_id);
46 }
47
48 /// Return number of ActorSnapshots present in this WorldSnapshot.
49 size_t size() const {
50 return _state->size();
51 }
52
53 /// Return a begin iterator to the list of ActorSnapshots.
54 auto begin() const {
55 return _state->begin();
56 }
57
58 /// Return a past-the-end iterator to the list of ActorSnapshots.
59 auto end() const {
60 return _state->end();
61 }
62
63 bool operator==(const WorldSnapshot &rhs) const {
64 return GetTimestamp() == rhs.GetTimestamp();
65 }
66
67 bool operator!=(const WorldSnapshot &rhs) const {
68 return !(*this == rhs);
69 }
70
71 private:
72
73 std::shared_ptr<const detail::EpisodeState> _state;
74 };
75
76} // namespace client
77} // namespace carla
std::size_t frame
Number of frames elapsed since the simulator was launched.
Definition Timestamp.h:30
size_t size() const
Return number of ActorSnapshots present in this WorldSnapshot.
bool Contains(ActorId actor_id) const
Check if an actor is present in this snapshot.
std::shared_ptr< const detail::EpisodeState > _state
auto begin() const
Return a begin iterator to the list of ActorSnapshots.
const Timestamp & GetTimestamp() const
Get timestamp of this snapshot.
uint64_t GetId() const
Get the id of the episode associated with this world.
bool operator!=(const WorldSnapshot &rhs) const
auto end() const
Return a past-the-end iterator to the list of ActorSnapshots.
bool operator==(const WorldSnapshot &rhs) const
WorldSnapshot(std::shared_ptr< const detail::EpisodeState > state)
boost::optional< ActorSnapshot > Find(ActorId actor_id) const
Find an ActorSnapshot by id.
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133