CARLA
Loading...
Searching...
No Matches
Command.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/MsgPack.h"
13#include "carla/rpc/ActorId.h"
20
21#ifdef _MSC_VER
22#pragma warning(push)
23#pragma warning(disable:4583)
24#pragma warning(disable:4582)
25#include <variant>
26#pragma warning(pop)
27#else
28#include <variant>
29#endif
30
31namespace carla {
32
33namespace traffic_manager {
34 class TrafficManager;
35}
36
37namespace ctm = carla::traffic_manager;
38
39namespace rpc {
40
41 class Command {
42 private:
43
44 template <typename T>
45 struct CommandBase {
46 operator Command() const {
47 return Command{*static_cast<const T *>(this)};
48 }
49 };
50
51 public:
52
68
69 struct DestroyActor : CommandBase<DestroyActor> {
70 DestroyActor() = default;
72 : actor(id) {}
75 };
76
86
96
106
116
126
136
145
155
165
175
176 struct ApplyForce : CommandBase<ApplyForce> {
177 ApplyForce() = default;
179 : actor(id),
180 force(value) {}
184 };
185
195
205
206 struct SetSimulatePhysics : CommandBase<SetSimulatePhysics> {
209 : actor(id),
210 enabled(value) {}
214 };
215
216 struct SetEnableGravity : CommandBase<SetEnableGravity> {
217 SetEnableGravity() = default;
218 SetEnableGravity(ActorId id, bool value)
219 : actor(id),
220 enabled(value) {}
224 };
225
226 struct SetAutopilot : CommandBase<SetAutopilot> {
227 SetAutopilot() = default;
229 ActorId id,
230 bool value,
231 uint16_t tm_port)
232 : actor(id),
233 enabled(value),
234 tm_port(tm_port) {}
237 uint16_t tm_port;
239 };
240
241 struct ShowDebugTelemetry : CommandBase<ShowDebugTelemetry> {
244 ActorId id,
245 bool value)
246 : actor(id),
247 enabled(value) {}
251 };
252
264
265 struct ConsoleCommand : CommandBase<ConsoleCommand> {
266 ConsoleCommand() = default;
267 ConsoleCommand(std::string cmd) : cmd(cmd) {}
268 std::string cmd;
270 };
271
283
284 using CommandType = std::variant<
307
309
311 };
312
313} // namespace rpc
314} // namespace carla
A rigid transform in CARLA's / Unreal's left-handed frame: x forward, y right, z up,...
MSGPACK_DEFINE_ARRAY(command)
std::variant< SpawnActor, DestroyActor, ApplyVehicleControl, ApplyVehicleAckermannControl, ApplyWalkerControl, ApplyVehiclePhysicsControl, ApplyTransform, ApplyWalkerState, ApplyTargetVelocity, ApplyTargetAngularVelocity, ApplyImpulse, ApplyForce, ApplyAngularImpulse, ApplyTorque, SetSimulatePhysics, SetEnableGravity, SetAutopilot, ShowDebugTelemetry, SetVehicleLightState, ApplyLocation, ConsoleCommand, SetTrafficLightState > CommandType
Definition Command.h:306
CommandType command
Definition Command.h:308
uint32_t ActorId
Definition ActorId.h:14
This file contains definitions of common data structures used in traffic manager.
ApplyAngularImpulse(ActorId id, const geom::Vector3D &value)
Definition Command.h:188
ApplyForce(ActorId id, const geom::Vector3D &value)
Definition Command.h:178
ApplyImpulse(ActorId id, const geom::Vector3D &value)
Definition Command.h:168
ApplyLocation(ActorId id, const geom::Location &value)
Definition Command.h:129
ApplyTargetAngularVelocity(ActorId id, const geom::Vector3D &value)
Definition Command.h:158
ApplyTargetVelocity(ActorId id, const geom::Vector3D &value)
Definition Command.h:148
ApplyTorque(ActorId id, const geom::Vector3D &value)
Definition Command.h:198
ApplyTransform(ActorId id, const geom::Transform &value)
Definition Command.h:119
MSGPACK_DEFINE_ARRAY(actor, transform)
ApplyVehicleAckermannControl(ActorId id, const VehicleAckermannControl &value)
Definition Command.h:89
ApplyVehicleControl(ActorId id, const VehicleControl &value)
Definition Command.h:79
ApplyVehiclePhysicsControl(ActorId id, const VehiclePhysicsControl &value)
Definition Command.h:109
ApplyWalkerControl(ActorId id, const WalkerControl &value)
Definition Command.h:99
ApplyWalkerState(ActorId id, const geom::Transform &value, const float speed)
Definition Command.h:139
MSGPACK_DEFINE_ARRAY(actor, transform, speed)
SetAutopilot(ActorId id, bool value, uint16_t tm_port)
Definition Command.h:228
SetEnableGravity(ActorId id, bool value)
Definition Command.h:218
SetSimulatePhysics(ActorId id, bool value)
Definition Command.h:208
MSGPACK_DEFINE_ARRAY(actor, traffic_light_state)
rpc::TrafficLightState traffic_light_state
Definition Command.h:280
SetTrafficLightState(ActorId id, rpc::TrafficLightState state)
Definition Command.h:274
VehicleLightState::flag_type light_state
Definition Command.h:261
SetVehicleLightState(ActorId id, VehicleLightState::flag_type value)
Definition Command.h:255
ShowDebugTelemetry(ActorId id, bool value)
Definition Command.h:243
std::optional< ActorId > parent
Definition Command.h:64
geom::Transform transform
Definition Command.h:63
MSGPACK_DEFINE_ARRAY(description, transform, parent, do_after)
SpawnActor(ActorDescription description, const geom::Transform &transform, ActorId parent)
Definition Command.h:58
ActorDescription description
Definition Command.h:62
SpawnActor(ActorDescription description, const geom::Transform &transform)
Definition Command.h:55
std::vector< Command > do_after
Definition Command.h:65