CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
client
WorldSnapshot.h
Go to the documentation of this file.
1
// Copyright (c) 2026 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/client/Timestamp.h
"
10
#include "
carla/client/ActorSnapshot.h
"
11
#include "
carla/client/detail/EpisodeState.h
"
12
13
#include <optional>
14
15
namespace
carla
{
16
namespace
client
{
17
18
class
WorldSnapshot
{
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
std::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
ActorSnapshot.h
EpisodeState.h
Timestamp.h
carla::client::Timestamp
Definition
Timestamp.h:14
carla::client::Timestamp::frame
std::size_t frame
Number of frames elapsed since the simulator was launched.
Definition
Timestamp.h:30
carla::client::WorldSnapshot::size
size_t size() const
Return number of ActorSnapshots present in this WorldSnapshot.
Definition
WorldSnapshot.h:49
carla::client::WorldSnapshot::Contains
bool Contains(ActorId actor_id) const
Check if an actor is present in this snapshot.
Definition
WorldSnapshot.h:39
carla::client::WorldSnapshot::_state
std::shared_ptr< const detail::EpisodeState > _state
Definition
WorldSnapshot.h:73
carla::client::WorldSnapshot::begin
auto begin() const
Return a begin iterator to the list of ActorSnapshots.
Definition
WorldSnapshot.h:54
carla::client::WorldSnapshot::GetTimestamp
const Timestamp & GetTimestamp() const
Get timestamp of this snapshot.
Definition
WorldSnapshot.h:34
carla::client::WorldSnapshot::GetId
uint64_t GetId() const
Get the id of the episode associated with this world.
Definition
WorldSnapshot.h:25
carla::client::WorldSnapshot::GetFrame
size_t GetFrame() const
Definition
WorldSnapshot.h:29
carla::client::WorldSnapshot::operator!=
bool operator!=(const WorldSnapshot &rhs) const
Definition
WorldSnapshot.h:67
carla::client::WorldSnapshot::Find
std::optional< ActorSnapshot > Find(ActorId actor_id) const
Find an ActorSnapshot by id.
Definition
WorldSnapshot.h:44
carla::client::WorldSnapshot::end
auto end() const
Return a past-the-end iterator to the list of ActorSnapshots.
Definition
WorldSnapshot.h:59
carla::client::WorldSnapshot::operator==
bool operator==(const WorldSnapshot &rhs) const
Definition
WorldSnapshot.h:63
carla::client::WorldSnapshot::WorldSnapshot
WorldSnapshot(std::shared_ptr< const detail::EpisodeState > state)
Definition
WorldSnapshot.h:21
carla::client
Definition
BasicAgent.h:24
carla::traffic_manager::ActorId
carla::ActorId ActorId
Definition
AtomicActorSet.h:21
carla
This file contains definitions of common data structures used in traffic manager.
Definition
SignComponent.h:21
std
Definition
CarlaRecorderCollision.h:31
Generated by
1.18.0