CARLA
Loading...
Searching...
No Matches
client/detail/ActorState.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/NonCopyable.h"
10#include "carla/client/World.h"
13#include "carla/rpc/Actor.h"
14
15#include <optional>
16
17namespace carla {
18namespace client {
19namespace detail {
20
21 class ActorFactory;
22
23 /// Internal state of an Actor.
25 public:
26
27 ActorId GetId() const {
28 return _description.id;
29 }
30
31 const std::string &GetTypeId() const {
33 }
34
35 const std::string &GetDisplayId() const {
36 return _display_id;
37 }
38
41 }
42
43 const std::vector<uint8_t> &GetSemanticTags() const {
45 }
46
48
49 World GetWorld() const {
50 return World{_episode};
51 }
52
53 const std::vector<ActorAttributeValue> &GetAttributes() const
54 {
55 return _attributes;
56 }
57
58 /// Whether this handle was returned by a spawn call of this client, as
59 /// opposed to being looked up (get_actor, get_actors, parent, spectator).
60 /// Only a spawn handle knows that the actor exists without having seen it
61 /// in a snapshot; see Simulator::GetActorState.
63 return _spawn_frame.has_value();
64 }
65
66 /// Frame of the last world snapshot this client had received when the
67 /// spawn of this actor was acknowledged by the server; unset for looked-up
68 /// handles. No snapshot up to this frame can contain the actor yet.
69 uint64_t GetSpawnFrame() const {
70 return _spawn_frame.value_or(0u);
71 }
72
73 protected:
74
75 explicit ActorState(rpc::Actor description, EpisodeProxy episode);
76
80
82 return _description;
83 }
84
86 return _episode;
87 }
88
89 const EpisodeProxy &GetEpisode() const {
90 return _episode;
91 }
92
93 private:
94
95 friend class Simulator;
96
98
100
101 std::string _display_id;
102
103 std::vector<ActorAttributeValue> _attributes;
104
105 std::optional<uint64_t> _spawn_frame;
106 };
107
108} // namespace detail
109
110 /// Used to initialize Actor classes. Only the ActorFactory can create this
111 /// object, thus only the ActorFactory can create actors.
113 public:
115 private:
118 };
119
120} // namespace client
121} // namespace carla
Inherit (privately) to suppress copy construction and assignment.
Used to initialize Actor classes.
ActorInitializer(ActorInitializer &&)=default
const std::vector< uint8_t > & GetSemanticTags() const
std::vector< ActorAttributeValue > _attributes
const geom::BoundingBox & GetBoundingBox() const
SharedPtr< Actor > GetParent() const
const std::vector< ActorAttributeValue > & GetAttributes() const
const rpc::Actor & GetActorDescription() const
ActorState(rpc::Actor description, EpisodeProxy episode)
const std::string & GetDisplayId() const
uint64_t GetSpawnFrame() const
Frame of the last world snapshot this client had received when the spawn of this actor was acknowledg...
bool WasSpawnedByThisClient() const
Whether this handle was returned by a spawn call of this client, as opposed to being looked up (get_a...
const EpisodeProxy & GetEpisode() const
Connects and controls a CARLA Simulator.
Definition Simulator.h:55
std::vector< uint8_t > semantic_tags
Definition rpc/Actor.h:33
ActorId parent_id
Definition rpc/Actor.h:27
ActorDescription description
Definition rpc/Actor.h:29
geom::BoundingBox bounding_box
Definition rpc/Actor.h:31
This file contains definitions of common data structures used in traffic manager.
std::shared_ptr< T > SharedPtr
Definition Memory.h:15