CARLA
Loading...
Searching...
No Matches
Simulator.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 <mutex>
10
11#include "carla/Debug.h"
12#include "carla/Logging.h"
13#include "carla/Memory.h"
14#include "carla/NonCopyable.h"
15#include "carla/client/Actor.h"
19#include "carla/client/Walker.h"
20#include "carla/client/World.h"
31#include "carla/rpc/Texture.h"
34
35#include <optional>
36
37#include <memory>
38
39namespace carla {
40namespace client {
41
42 class ActorBlueprint;
43 class BlueprintLibrary;
44 class Map;
45 class Sensor;
47 class WalkerNavigation;
48
49namespace detail {
50
51 /// Connects and controls a CARLA Simulator.
53 : public std::enable_shared_from_this<Simulator>,
55 private NonCopyable {
56 public:
57
58 // =========================================================================
59 /// @name Constructor
60 // =========================================================================
61 /// @{
62
63 explicit Simulator(
64 const std::string &host,
65 uint16_t port,
66 size_t worker_threads = 0u,
67 bool enable_garbage_collection = false);
68
69 ~Simulator();
70
71 /// Deleter: on a pool thread, destroy on a background thread (~Simulator joins the pools).
72 static void Delete(Simulator *simulator);
73
74 /// @}
75 // =========================================================================
76 /// @name Load a new episode
77 // =========================================================================
78 /// @{
79
80 EpisodeProxy ReloadEpisode(bool reset_settings = true) {
81 return LoadEpisode("", reset_settings);
82 }
83
84 EpisodeProxy LoadEpisode(std::string map_name, bool reset_settings = true, rpc::MapLayer map_layers = rpc::MapLayer::All);
85
86 void LoadLevelLayer(rpc::MapLayer map_layers) const {
87 _client.LoadLevelLayer(map_layers);
88 }
89
90 void UnloadLevelLayer(rpc::MapLayer map_layers) const {
91 _client.UnloadLevelLayer(map_layers);
92 }
93
95 std::string opendrive,
97 bool reset_settings = true);
98
99 /// @}
100 // =========================================================================
101 /// @name Access to current episode
102 // =========================================================================
103 /// @{
104
105 /// @pre Cannot be called previous to GetCurrentEpisode.
108 DEBUG_ASSERT(_episode != nullptr);
109 return _episode->GetId();
110 }
111
114
115 /// @}
116 // =========================================================================
117 /// @name World snapshot
118 // =========================================================================
119 /// @{
120
122 return World{GetCurrentEpisode()};
123 }
124
125 /// @}
126 // =========================================================================
127 /// @name World snapshot
128 // =========================================================================
129 /// @{
130
132 DEBUG_ASSERT(_episode != nullptr);
133 return WorldSnapshot{_episode->GetState()};
134 }
135
136 /// @}
137 // =========================================================================
138 /// @name Map related methods
139 // =========================================================================
140 /// @{
141
143
144 std::vector<std::string> GetAvailableMaps() {
145 return _client.GetAvailableMaps();
146 }
147
148 /// @}
149 // =========================================================================
150 /// @name Content packs
151 // =========================================================================
152 /// @{
153
154 std::vector<rpc::ContentPackInfo> GetContentPacks() {
155 return _client.GetContentPacks();
156 }
157
158 rpc::ContentPackInfo MountContentPack(const std::string &path) {
159 return _client.MountContentPack(path);
160 }
161
162 bool UnmountContentPack(const std::string &name) {
163 return _client.UnmountContentPack(name);
164 }
165
166 /// @}
167 // =========================================================================
168 /// @name Required files related methods
169 // =========================================================================
170 /// @{
171
172 bool SetFilesBaseFolder(const std::string &path);
173
174 std::vector<std::string> GetRequiredFiles(const std::string &folder = "", const bool download = true) const;
175
176 void RequestFile(const std::string &name) const;
177
178 std::vector<uint8_t> GetCacheFile(const std::string &name, const bool request_otherwise) const;
179
180 /// @}
181 // =========================================================================
182 /// @name Garbage collection policy
183 // =========================================================================
184 /// @{
185
189
190 /// @}
191 // =========================================================================
192 /// @name Pure networking operations
193 // =========================================================================
194 /// @{
195
197 _client.SetTimeout(timeout);
198 }
199
203
204 std::string GetClientVersion() {
205 return _client.GetClientVersion();
206 }
207
208 std::string GetServerVersion() {
209 return _client.GetServerVersion();
210 }
211
212 /// @}
213 // =========================================================================
214 /// @name Tick
215 // =========================================================================
216 /// @{
217
219
220 size_t RegisterOnTickEvent(std::function<void(WorldSnapshot)> callback) {
221 DEBUG_ASSERT(_episode != nullptr);
222 return _episode->RegisterOnTickEvent(std::move(callback));
223 }
224
225 void RemoveOnTickEvent(size_t id) {
226 DEBUG_ASSERT(_episode != nullptr);
227 _episode->RemoveOnTickEvent(id);
228 }
229
230 uint64_t Tick(time_duration timeout);
231
232 /// @}
233 // =========================================================================
234 /// @name Access to global objects in the episode
235 // =========================================================================
236 /// @{
237
238 std :: string GetEndpoint() {
239 return _client.GetEndpoint();
240 }
241
242 /// Query to know if a Traffic Manager is running on port
243 bool IsTrafficManagerRunning(uint16_t port) const {
244 return _client.IsTrafficManagerRunning(port);
245 }
246
247 /// Gets a pair filled with the <IP, port> of the Trafic Manager running on port.
248 /// If there is no Traffic Manager running the pair will be ("", 0)
249 std::pair<std::string, uint16_t> GetTrafficManagerRunning(uint16_t port) const {
251 }
252
253 /// Informs that a Traffic Manager is running on <IP, port>
254 bool AddTrafficManagerRunning(std::pair<std::string, uint16_t> trafficManagerInfo) const {
255 return _client.AddTrafficManagerRunning(trafficManagerInfo);
256 }
257
258 void DestroyTrafficManager(uint16_t port) const {
260 }
261
262 void AddPendingException(std::string e) {
263 _episode->AddPendingException(e);
264 }
265
267
268 /// Returns a list of pairs where the firts element is the vehicle ID
269 /// and the second one is the light state
271
273
277
278 uint64_t SetEpisodeSettings(const rpc::EpisodeSettings &settings);
279
283
287
290 }
291
292 void SetIMUSensorGravity(float gravity) {
294 }
295
297 return _client.IsWeatherEnabled();
298 }
299
300 void SetPublishTF(bool publish_tf) {
301 _client.SetPublishTF(publish_tf);
302 }
303
304 bool GetPublishTF() const {
305 return _client.GetPublishTF();
306 }
307
308 std::vector<geom::Transform> GetEgoSpawnPoints() const {
309 return _client.GetEgoSpawnPoints();
310 }
311
315
319
321 return _client.GetVehicleLightState(vehicle.GetId());
322 }
323
324 std::vector<geom::Transform> GetVehicleBoneWorldTransforms(const Vehicle &vehicle) {
326 }
327
328 /// Returns all the BBs of all the elements of the level
329 std::vector<geom::BoundingBox> GetLevelBBs(uint8_t queried_tag) const {
330 return _client.GetLevelBBs(queried_tag);
331 }
332
333 std::vector<rpc::EnvironmentObject> GetEnvironmentObjects(uint8_t queried_tag) const {
334 return _client.GetEnvironmentObjects(queried_tag);
335 }
336
338 std::vector<uint64_t> env_objects_ids,
339 bool enable) const {
340 _client.EnableEnvironmentObjects(env_objects_ids, enable);
341 }
342
343 std::pair<bool,rpc::LabelledPoint> ProjectPoint(
344 geom::Location location, geom::Vector3D direction, float search_distance) const {
345 return _client.ProjectPoint(location, direction, search_distance);
346 }
347
348 std::vector<rpc::LabelledPoint> CastRay(
349 geom::Location start_location, geom::Location end_location) const {
350 return _client.CastRay(start_location, end_location);
351 }
352
353 /// @}
354 // =========================================================================
355 /// @name AI
356 // =========================================================================
357 /// @{
358
359 std::shared_ptr<WalkerNavigation> GetNavigation();
360
361 void NavigationTick();
362
363 /// True when the current episode's navigation is hosted by the server
364 /// (World-Partitioned navmesh); walker AI then goes through the
365 /// walker_* RPCs instead of the client-side Detour crowd.
367
368 void RegisterAIController(const WalkerAIController &controller);
369
370 void UnregisterAIController(const WalkerAIController &controller);
371
372 std::optional<geom::Location> GetRandomLocationFromNavigation();
373
375 return _client.WalkerStartNavigation(walker_id);
376 }
377
378 bool WalkerGoToLocation(ActorId walker_id, const geom::Location &destination) {
379 return _client.WalkerGoToLocation(walker_id, destination);
380 }
381
382 bool WalkerSetMaxSpeed(ActorId walker_id, float max_speed) {
383 return _client.WalkerSetMaxSpeed(walker_id, max_speed);
384 }
385
387 return _client.WalkerStopNavigation(walker_id);
388 }
389
390 void SetPedestriansCrossFactor(float percentage);
391
392 void SetPedestriansSeed(unsigned int seed);
393
394 /// @}
395 // =========================================================================
396 /// @name General operations with actors
397 // =========================================================================
398 /// @{
399
400 std::optional<rpc::Actor> GetActorById(ActorId id) const {
401 DEBUG_ASSERT(_episode != nullptr);
402 return _episode->GetActorById(id);
403 }
404
405 std::vector<rpc::Actor> GetActorsById(const std::vector<ActorId> &actor_ids) const {
406 DEBUG_ASSERT(_episode != nullptr);
407 return _episode->GetActorsById(actor_ids);
408 }
409
410 std::vector<rpc::Actor> GetAllTheActorsInTheEpisode() const {
411 DEBUG_ASSERT(_episode != nullptr);
412 return _episode->GetActors();
413 }
414
415 /// Creates an actor instance out of a description of an existing actor.
416 /// Note that this does not spawn an actor.
417 ///
418 /// If @a gc is GarbageCollectionPolicy::Enabled, the shared pointer
419 /// returned is provided with a custom deleter that calls Destroy() on the
420 /// actor. This method does not support GarbageCollectionPolicy::Inherit.
427
428 /// Spawns an actor into the simulation.
429 ///
430 /// If @a gc is GarbageCollectionPolicy::Enabled, the shared pointer
431 /// returned is provided with a custom deleter that calls Destroy() on the
432 /// actor. If @gc is GarbageCollectionPolicy::Inherit, the default garbage
433 /// collection policy is used.
435 const ActorBlueprint &blueprint,
436 const geom::Transform &transform,
437 Actor *parent = nullptr,
440
441 bool DestroyActor(Actor &actor);
442
443 bool DestroyActor(ActorId actor_id)
444 {
445 return _client.DestroyActor(actor_id);
446 }
447
449 DEBUG_ASSERT(_episode != nullptr);
450 return _episode->GetState()->GetActorSnapshot(actor_id);
451 }
452
454 return GetActorSnapshot(actor.GetId());
455 }
456
457 /// State of @a actor according to the latest world snapshot.
458 ///
459 /// An actor spawned by this client is not part of any snapshot produced
460 /// before the spawn was processed (asynchronous mode: until the next frame
461 /// arrives; synchronous mode: until the next tick). Reporting such an actor
462 /// as Invalid made is_alive/is_active False right after spawn_actor(), so
463 /// while the latest snapshot is not newer than the frame recorded at spawn
464 /// time the actor is reported Active. Any snapshot newer than that frame
465 /// is authoritative: an actor missing from it is gone (Invalid). A handle
466 /// that did not come from a spawn call gets no such grace: it is only ever
467 /// as good as the snapshots, including before the first one arrives.
468 rpc::ActorState GetActorState(const Actor &actor) const {
469 DEBUG_ASSERT(_episode != nullptr);
470 const auto state = _episode->GetState();
471 const auto snapshot = state->GetActorSnapshotIfPresent(actor.GetId());
472 if (snapshot.has_value()) {
473 return snapshot->actor_state;
474 }
475 if (actor.WasSpawnedByThisClient() && state->GetFrame() <= actor.GetSpawnFrame()) {
477 }
479 }
480
482 return GetActorSnapshot(actor).transform.location;
483 }
484
486 return GetActorSnapshot(actor).transform;
487 }
488
490 return GetActorSnapshot(actor).velocity;
491 }
492
493 void SetActorTargetVelocity(const Actor &actor, const geom::Vector3D &vector) {
494 _client.SetActorTargetVelocity(actor.GetId(), vector);
495 }
496
499 }
500
501 void SetActorTargetAngularVelocity(const Actor &actor, const geom::Vector3D &vector) {
503 }
504 void EnableActorConstantVelocity(const Actor &actor, const geom::Vector3D &vector) {
506 }
507
511
512 void EnableActorConstantAcceleration(const Actor &actor, const geom::Vector3D &vector) {
514 }
515
519
520 void AddActorImpulse(const Actor &actor, const geom::Vector3D &impulse) {
521 _client.AddActorImpulse(actor.GetId(), impulse);
522 }
523
524 void AddActorImpulse(const Actor &actor, const geom::Vector3D &impulse, const geom::Vector3D &location) {
525 _client.AddActorImpulse(actor.GetId(), impulse, location);
526 }
527
528 void AddActorForce(const Actor &actor, const geom::Vector3D &force) {
529 _client.AddActorForce(actor.GetId(), force);
530 }
531
532 void AddActorForce(const Actor &actor, const geom::Vector3D &force, const geom::Vector3D &location) {
533 _client.AddActorForce(actor.GetId(), force, location);
534 }
535
536 void AddActorAngularImpulse(const Actor &actor, const geom::Vector3D &vector) {
537 _client.AddActorAngularImpulse(actor.GetId(), vector);
538 }
539
540 void AddActorTorque(const Actor &actor, const geom::Vector3D &torque) {
541 _client.AddActorAngularImpulse(actor.GetId(), torque);
542 }
543
544 geom::Transform GetActorComponentWorldTransform(const Actor &actor, const std::string &component_name) {
545 return _client.GetActorComponentWorldTransform(actor.GetId(), component_name);
546 }
547
548 geom::Transform GetActorComponentRelativeTransform(const Actor &actor, const std::string &component_name) {
549 return _client.GetActorComponentRelativeTransform(actor.GetId(), component_name);
550 }
551
552 std::vector<geom::Transform> GetActorBoneWorldTransforms(const Actor &actor) {
554 }
555
556 std::vector<geom::Transform> GetActorBoneRelativeTransforms(const Actor &actor) {
558 }
559
560 std::vector<std::string> GetActorComponentNames(const Actor &actor) {
561 return _client.GetActorComponentNames(actor.GetId());
562 }
563
564 std::vector<std::string> GetActorBoneNames(const Actor &actor) {
565 return _client.GetActorBoneNames(actor.GetId());
566 }
567
568 std::vector<geom::Transform> GetActorSocketWorldTransforms(const Actor &actor) {
570 }
571
572 std::vector<geom::Transform> GetActorSocketRelativeTransforms(const Actor &actor) {
574 }
575
576 std::vector<std::string> GetActorSocketNames(const Actor &actor) {
577 return _client.GetActorSocketNames(actor.GetId());
578 }
579
581 return GetActorSnapshot(actor).acceleration;
582 }
583
584 std::string GetActorName(const Actor& actor) const
585 {
586 return _client.GetActorName(actor.GetId());
587 }
588
589 std::string GetActorClassName(const Actor& actor) const
590 {
591 return _client.GetActorClassName(actor.GetId());
592 }
593
594 void SetActorLocation(Actor &actor, const geom::Location &location) {
595 _client.SetActorLocation(actor.GetId(), location);
596 }
597
598 void SetActorTransform(Actor &actor, const geom::Transform &transform) {
599 _client.SetActorTransform(actor.GetId(), transform);
600 }
601
602 void SetActorSimulatePhysics(Actor &actor, bool enabled) {
603 _client.SetActorSimulatePhysics(actor.GetId(), enabled);
604 }
605
606 void SetActorCollisions(Actor &actor, bool enabled) {
607 _client.SetActorCollisions(actor.GetId(), enabled);
608 }
609
610 void SetActorCollisions(ActorId actor_id, bool enabled) {
611 _client.SetActorCollisions(actor_id, enabled);
612 }
613
614 void SetActorDead(Actor &actor) {
615 _client.SetActorDead(actor.GetId());
616 }
617
618 void SetActorDead(ActorId actor_id) {
619 _client.SetActorDead(actor_id);
620 }
621
622 void SetActorEnableGravity(Actor &actor, bool enabled) {
623 _client.SetActorEnableGravity(actor.GetId(), enabled);
624 }
625
627 Actor& actor,
628 const rpc::MaterialParameter& MaterialParameter,
629 const rpc::TextureColor& Texture)
630 {
631 _client.ApplyTextureToActor(actor.GetId(), MaterialParameter, Texture);
632 }
633
635 Actor& actor,
636 const rpc::MaterialParameter& MaterialParameter,
637 const rpc::TextureFloatColor& Texture)
638 {
639 _client.ApplyTextureToActor(actor.GetId(), MaterialParameter, Texture);
640 }
641
642 /// @}
643 // =========================================================================
644 /// @name Operations with vehicles
645 // =========================================================================
646 /// @{
647
648 void SetVehicleAutopilot(Vehicle &vehicle, bool enabled = true) {
649 _client.SetActorAutopilot(vehicle.GetId(), enabled);
650 }
651
652 void ShowVehicleDebugTelemetry(Vehicle &vehicle, bool enabled = true) {
653 _client.ShowVehicleDebugTelemetry(vehicle.GetId(), enabled);
654 }
655
656 void SetLightsToVehicle(Vehicle &vehicle, const rpc::VehicleControl &control) {
657 _client.ApplyControlToVehicle(vehicle.GetId(), control);
658 }
659
660 void ApplyControlToVehicle(Vehicle &vehicle, const rpc::VehicleControl &control) {
661 _client.ApplyControlToVehicle(vehicle.GetId(), control);
662 }
663
667
671
675
676 void ApplyControlToWalker(Walker &walker, const rpc::WalkerControl &control) {
677 _client.ApplyControlToWalker(walker.GetId(), control);
678 }
679
683
685 return _client.SetBonesTransform(walker.GetId(), bones);
686 }
687
688 void BlendPose(Walker &walker, float blend) {
689 return _client.BlendPose(walker.GetId(), blend);
690 }
691
693 return _client.GetPoseFromAnimation(walker.GetId());
694 }
695
697 _client.ApplyPhysicsControlToVehicle(vehicle.GetId(), physicsControl);
698 }
699
700 void SetLightStateToVehicle(Vehicle &vehicle, const rpc::VehicleLightState light_state) {
701 _client.SetLightStateToVehicle(vehicle.GetId(), light_state);
702 }
703
704 void OpenVehicleDoor(Vehicle &vehicle, const rpc::VehicleDoor door_idx) {
705 _client.OpenVehicleDoor(vehicle.GetId(), door_idx);
706 }
707
708 void CloseVehicleDoor(Vehicle &vehicle, const rpc::VehicleDoor door_idx) {
709 _client.CloseVehicleDoor(vehicle.GetId(), door_idx);
710 }
711
712 void SetWheelSteerDirection(Vehicle &vehicle, rpc::VehicleWheelLocation wheel_location, float angle_in_deg) {
713 _client.SetWheelSteerDirection(vehicle.GetId(), wheel_location, angle_in_deg);
714 }
715
716 float GetWheelSteerAngle(Vehicle &vehicle, rpc::VehicleWheelLocation wheel_location) {
717 return _client.GetWheelSteerAngle(vehicle.GetId(), wheel_location);
718 }
719
720 void SetWheelPitchAngle(Vehicle &vehicle, rpc::VehicleWheelLocation wheel_location, float angle_in_deg) {
721 _client.SetWheelPitchAngle(vehicle.GetId(), wheel_location, angle_in_deg);
722 }
723
724 float GetWheelPitchAngle(Vehicle &vehicle, rpc::VehicleWheelLocation wheel_location) {
725 return _client.GetWheelPitchAngle(vehicle.GetId(), wheel_location);
726 }
727
728 void SetWheelSuspensionOffset(Vehicle &vehicle, rpc::VehicleWheelLocation wheel_location, float offset) {
729 _client.SetWheelSuspensionOffset(vehicle.GetId(), wheel_location, offset);
730 }
731
733 return _client.GetWheelSuspensionOffset(vehicle.GetId(), wheel_location);
734 }
735
736 void SetWheelAnimationOverride(Vehicle &vehicle, bool enabled) {
737 _client.SetWheelAnimationOverride(vehicle.GetId(), enabled);
738 }
739
740 void EnableCarSim(Vehicle &vehicle, std::string simfile_path) {
741 _client.EnableCarSim(vehicle.GetId(), simfile_path);
742 }
743
744 void UseCarSimRoad(Vehicle &vehicle, bool enabled) {
745 _client.UseCarSimRoad(vehicle.GetId(), enabled);
746 }
747
749 uint64_t MaxSubsteps,
750 float MaxSubstepDeltaTime,
751 std::string VehicleJSON,
752 std::string PowertrainJSON,
753 std::string TireJSON,
754 std::string BaseJSONPath) {
756 MaxSubsteps,
757 MaxSubstepDeltaTime,
758 VehicleJSON,
759 PowertrainJSON,
760 TireJSON,
761 BaseJSONPath);
762 }
763
764 /// @}
765 // =========================================================================
766 /// @name Operations with the recorder
767 // =========================================================================
768 /// @{
769
770 std::string StartRecorder(std::string name, bool additional_data, bool stop_replayer) {
771 return _client.StartRecorder(std::move(name), additional_data, stop_replayer);
772 }
773
774 void StopRecorder(void) {
776 }
777
778 std::string ShowRecorderFileInfo(std::string name, bool show_all) {
779 return _client.ShowRecorderFileInfo(std::move(name), show_all);
780 }
781
782 std::string ShowRecorderCollisions(std::string name, char type1, char type2) {
783 return _client.ShowRecorderCollisions(std::move(name), type1, type2);
784 }
785
786 std::string ShowRecorderActorsBlocked(std::string name, double min_time, double min_distance) {
787 return _client.ShowRecorderActorsBlocked(std::move(name), min_time, min_distance);
788 }
789
790 std::string ReplayFile(
791 std::string name, double start, double duration,
792 uint32_t follow_id, bool replay_sensors, bool replay_weather, const geom::Transform& offset,
793 std::string map_override) {
794 return _client.ReplayFile(std::move(name), start, duration, follow_id, replay_sensors, replay_weather, offset, map_override);
795 }
796
797 void SetReplayerTimeFactor(double time_factor) {
798 _client.SetReplayerTimeFactor(time_factor);
799 }
800
801 void SetReplayerIgnoreHero(bool ignore_hero) {
802 _client.SetReplayerIgnoreHero(ignore_hero);
803 }
804
805 void SetReplayerIgnoreSpectator(bool ignore_spectator) {
806 _client.SetReplayerIgnoreSpectator(ignore_spectator);
807 }
808
809 void StopReplayer(bool keep_actors) {
810 _client.StopReplayer(keep_actors);
811 }
812
813 /// @}
814 // =========================================================================
815 /// @name Operations with sensors
816 // =========================================================================
817 /// @{
818
820 const Sensor &sensor,
821 std::function<void(SharedPtr<sensor::SensorData>)> callback);
822
824
825 void EnableForROS(const Sensor &sensor);
826
827 void DisableForROS(const Sensor &sensor);
828
829 bool IsEnabledForROS(const Sensor &sensor);
830
832 Actor & sensor,
833 uint32_t gbuffer_id,
834 std::function<void(SharedPtr<sensor::SensorData>)> callback);
835
837 Actor & sensor,
838 uint32_t gbuffer_id);
839
840 void Send(const Sensor &sensor, const rpc::CustomV2XBytes &data);
841
842 /// @}
843 // =========================================================================
844 /// @name Operations with traffic lights
845 // =========================================================================
846 /// @{
847
848 void SetTrafficLightState(TrafficLight &trafficLight, const rpc::TrafficLightState trafficLightState) {
849 _client.SetTrafficLightState(trafficLight.GetId(), trafficLightState);
850 }
851
852 void SetTrafficLightGreenTime(TrafficLight &trafficLight, float greenTime) {
853 _client.SetTrafficLightGreenTime(trafficLight.GetId(), greenTime);
854 }
855
856 void SetTrafficLightYellowTime(TrafficLight &trafficLight, float yellowTime) {
857 _client.SetTrafficLightYellowTime(trafficLight.GetId(), yellowTime);
858 }
859
860 void SetTrafficLightRedTime(TrafficLight &trafficLight, float redTime) {
861 _client.SetTrafficLightRedTime(trafficLight.GetId(), redTime);
862 }
863
864 void FreezeTrafficLight(TrafficLight &trafficLight, bool freeze) {
865 _client.FreezeTrafficLight(trafficLight.GetId(), freeze);
866 }
867
869 _client.ResetTrafficLightGroup(trafficLight.GetId());
870 }
871
875
876 std::vector<geom::BoundingBox> GetLightBoxes(const TrafficLight &trafficLight) const {
877 return _client.GetLightBoxes(trafficLight.GetId());
878 }
879
880 std::vector<ActorId> GetGroupTrafficLights(TrafficLight &trafficLight) {
881 return _client.GetGroupTrafficLights(trafficLight.GetId());
882 }
883
884 /// @}
885 // =========================================================================
886 /// @name Debug
887 // =========================================================================
888 /// @{
889
890 void DrawDebugShape(const rpc::DebugShape &shape) {
891 _client.DrawDebugShape(shape);
892 }
893
897
901
902 /// Spawns a static procedural mesh in the world. Vertices are a flat
903 /// (x, y, z) triple list in metres (client/UE-handed coordinates);
904 /// triangles are vertex-index triples into that list.
906 const std::vector<float> &vertices,
907 const std::vector<uint32_t> &triangles,
908 const std::string &material) {
909 _client.SpawnCustomMesh(vertices, triangles, material);
910 }
911
912 /// @}
913 // =========================================================================
914 /// @name Apply commands in batch
915 // =========================================================================
916 /// @{
917
918 void ApplyBatch(std::vector<rpc::Command> commands, bool do_tick_cue) {
919 _client.ApplyBatch(std::move(commands), do_tick_cue);
920 }
921
922 auto ApplyBatchSync(std::vector<rpc::Command> commands, bool do_tick_cue) {
923 return _client.ApplyBatchSync(std::move(commands), do_tick_cue);
924 }
925
926 /// @}
927 // =========================================================================
928 /// @name Operations lights
929 // =========================================================================
930 /// @{
931
935
936 std::vector<rpc::LightState> QueryLightsStateToServer() const {
938 }
939
941 std::vector<rpc::LightState>& lights,
942 bool discard_client = false) const {
943 _client.UpdateServerLightsState(lights, discard_client);
944 }
945
946 void UpdateDayNightCycle(const bool active) const {
948 }
949
950 size_t RegisterLightUpdateChangeEvent(std::function<void(WorldSnapshot)> callback) {
951 DEBUG_ASSERT(_episode != nullptr);
952 return _episode->RegisterLightUpdateChangeEvent(std::move(callback));
953 }
954
956 DEBUG_ASSERT(_episode != nullptr);
957 _episode->RemoveLightUpdateChangeEvent(id);
958 }
959
960 void FreezeAllTrafficLights(bool frozen);
961
962 /// @}
963 // =========================================================================
964 /// @name Texture updating operations
965 // =========================================================================
966 /// @{
967
969 const std::vector<std::string> &objects_name,
970 const rpc::MaterialParameter& parameter,
971 const rpc::TextureColor& Texture);
972
974 const std::vector<std::string> &objects_name,
975 const rpc::MaterialParameter& parameter,
976 const rpc::TextureFloatColor& Texture);
977
978 void SetSkyLightMap(const rpc::TextureFloatColor& panorama, float intensity, int32_t face_size) {
979 _client.SetSkyLightMap(panorama, intensity, face_size);
980 }
981
985
986 bool HasSkyLightMap() const {
987 return _client.HasSkyLightMap();
988 }
989
990 std::vector<std::string> GetNamesOfAllObjects() const;
991
992 /// @}
993
994 private:
995
996 bool ShouldUpdateMap(rpc::MapInfo& map_info);
997
999
1001
1002 std::shared_ptr<Episode> _episode;
1003
1005
1007
1009
1011
1012 std::string _open_drive_file;
1013 };
1014
1015} // namespace detail
1016} // namespace client
1017} // namespace carla
#define DEBUG_ASSERT(predicate)
Definition Debug.h:66
#define RELEASE_ASSERT(pred)
Definition Debug.h:84
NonCopyable()=default
Contains all the necessary information for spawning an Actor.
Represents an actor in the simulation.
static SharedPtr< Actor > MakeActor(EpisodeProxy episode, rpc::Actor actor_description, GarbageCollectionPolicy garbage_collection_policy)
Create an Actor based on the provided actor_description.
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...
Provides communication with the rpc and streaming servers of a CARLA simulator.
void SetReplayerIgnoreHero(bool ignore_hero)
void SetTrafficLightRedTime(rpc::ActorId traffic_light, float red_time)
void ApplyControlToWalker(rpc::ActorId walker, const rpc::WalkerControl &control)
bool WalkerGoToLocation(rpc::ActorId walker, const geom::Location &destination) const
std::vector< geom::Transform > GetVehicleBoneWorldTransforms(rpc::ActorId actor)
void OpenVehicleDoor(rpc::ActorId vehicle, const rpc::VehicleDoor door_idx)
const std::string GetEndpoint() const
float GetWheelSuspensionOffset(rpc::ActorId vehicle, rpc::VehicleWheelLocation wheel_location)
std::string ReplayFile(std::string name, double start, double duration, uint32_t follow_id, bool replay_sensors, bool replay_weather, const geom::Transform &offset, std::string map_override)
std::vector< geom::Transform > GetEgoSpawnPoints() const
rpc::WeatherParameters GetWeatherParameters()
std::vector< std::string > GetActorBoneNames(rpc::ActorId actor)
void ApplyTextureToActor(rpc::ActorId ActorId, const rpc::MaterialParameter &MaterialParameter, const rpc::TextureColor &Texture)
void ApplyPhysicsControlToVehicle(rpc::ActorId vehicle, const rpc::VehiclePhysicsControl &physics_control)
void CloseVehicleDoor(rpc::ActorId vehicle, const rpc::VehicleDoor door_idx)
void LoadLevelLayer(rpc::MapLayer map_layer) const
void SetActorTargetVelocity(rpc::ActorId actor, const geom::Vector3D &vector)
geom::Transform GetActorComponentWorldTransform(rpc::ActorId actor, const std::string &component_name)
std::vector< std::string > GetAvailableMaps()
std::vector< rpc::ContentPackInfo > GetContentPacks()
rpc::VehicleLightState GetVehicleLightState(rpc::ActorId vehicle) const
void SetWheelAnimationOverride(rpc::ActorId vehicle, bool enabled)
rpc::VehicleTelemetryData GetVehicleTelemetryData(rpc::ActorId vehicle) const
void DisableActorConstantVelocity(rpc::ActorId actor)
void EnableActorConstantVelocity(rpc::ActorId actor, const geom::Vector3D &vector)
rpc::AckermannControllerSettings GetAckermannControllerSettings(rpc::ActorId vehicle) const
void EnableChronoPhysics(rpc::ActorId vehicle, uint64_t MaxSubsteps, float MaxSubstepDeltaTime, std::string VehicleJSON, std::string PowertrainJSON, std::string TireJSON, std::string BaseJSONPath)
bool WalkerStartNavigation(rpc::ActorId walker) const
std::string ShowRecorderActorsBlocked(std::string name, double min_time, double min_distance)
geom::Transform GetActorComponentRelativeTransform(rpc::ActorId actor, const std::string &component_name)
std::vector< rpc::CommandResponse > ApplyBatchSync(std::vector< rpc::Command > commands, bool do_tick_cue)
std::vector< ActorId > GetGroupTrafficLights(rpc::ActorId traffic_light)
void SetActorCollisions(rpc::ActorId actor, bool enabled)
void ApplyAckermannControllerSettings(rpc::ActorId vehicle, const rpc::AckermannControllerSettings &settings)
void SetActorAutopilot(rpc::ActorId vehicle, bool enabled)
float GetWheelPitchAngle(rpc::ActorId vehicle, rpc::VehicleWheelLocation wheel_location)
void ResetTrafficLightGroup(rpc::ActorId traffic_light)
std::vector< std::string > GetActorComponentNames(rpc::ActorId actor)
void SetActorLocation(rpc::ActorId actor, const geom::Location &location)
void ShowVehicleDebugTelemetry(rpc::ActorId vehicle, bool enabled)
void SetTrafficLightYellowTime(rpc::ActorId traffic_light, float yellow_time)
void BlendPose(rpc::ActorId walker, float blend)
void SpawnCustomMesh(const std::vector< float > &vertices, const std::vector< uint32_t > &triangles, const std::string &material)
rpc::VehiclePhysicsControl GetVehiclePhysicsControl(rpc::ActorId vehicle) const
std::pair< std::string, uint16_t > GetTrafficManagerRunning(uint16_t port) const
Gets a pair filled with the <IP, port> of the Trafic Manager running on port.
void EnableActorConstantAcceleration(rpc::ActorId actor, const geom::Vector3D &vector)
void AddActorImpulse(rpc::ActorId actor, const geom::Vector3D &impulse)
void DrawDebugShape(const rpc::DebugShape &shape)
void SetActorTransform(rpc::ActorId actor, const geom::Transform &transform)
void SetActorDead(rpc::ActorId actor)
void ApplyBatch(std::vector< rpc::Command > commands, bool do_tick_cue)
void SetTrafficLightGreenTime(rpc::ActorId traffic_light, float green_time)
void SetWeatherParameters(const rpc::WeatherParameters &weather)
void FreezeTrafficLight(rpc::ActorId traffic_light, bool freeze)
void AddActorAngularImpulse(rpc::ActorId actor, const geom::Vector3D &vector)
std::vector< geom::Transform > GetActorSocketWorldTransforms(rpc::ActorId actor)
bool DestroyActor(rpc::ActorId actor)
bool AddTrafficManagerRunning(std::pair< std::string, uint16_t > trafficManagerInfo) const
Informs the server that a Traffic Manager is running on <IP, port>.
std::vector< geom::Transform > GetActorBoneWorldTransforms(rpc::ActorId actor)
bool IsTrafficManagerRunning(uint16_t port) const
Querry to know if a Traffic Manager is running on port.
void SetReplayerIgnoreSpectator(bool ignore_spectator)
std::string StartRecorder(std::string name, bool additional_data, bool stop_replayer)
std::vector< geom::BoundingBox > GetLightBoxes(rpc::ActorId traffic_light) const
float GetWheelSteerAngle(rpc::ActorId vehicle, rpc::VehicleWheelLocation wheel_location)
void AddActorForce(rpc::ActorId actor, const geom::Vector3D &force)
std::string ShowRecorderCollisions(std::string name, char type1, char type2)
void SetLightStateToVehicle(rpc::ActorId vehicle, const rpc::VehicleLightState &light_state)
std::vector< geom::BoundingBox > GetLevelBBs(uint8_t queried_tag) const
Returns all the BBs of all the elements of the level.
std::vector< rpc::LabelledPoint > CastRay(geom::Location start_location, geom::Location end_location) const
void SetSkyLightMap(const rpc::TextureFloatColor &panorama, float intensity, int32_t face_size)
void EnableCarSim(rpc::ActorId vehicle, std::string simfile_path)
std::string GetActorClassName(rpc::ActorId actor) const
void SetTimeout(time_duration timeout)
std::vector< geom::Transform > GetActorBoneRelativeTransforms(rpc::ActorId actor)
bool WalkerStopNavigation(rpc::ActorId walker) const
void SetActorEnableGravity(rpc::ActorId actor, bool enabled)
void SetActorSimulatePhysics(rpc::ActorId actor, bool enabled)
bool UnmountContentPack(const std::string &name)
void ApplyAckermannControlToVehicle(rpc::ActorId vehicle, const rpc::VehicleAckermannControl &control)
std::string ShowRecorderFileInfo(std::string name, bool show_all)
void SetReplayerTimeFactor(double time_factor)
void SetTrafficLightState(rpc::ActorId traffic_light, const rpc::TrafficLightState trafficLightState)
std::string GetActorName(rpc::ActorId actor) const
std::vector< std::string > GetActorSocketNames(rpc::ActorId actor)
rpc::WalkerBoneControlOut GetBonesTransform(rpc::ActorId walker)
void SetWheelSuspensionOffset(rpc::ActorId vehicle, rpc::VehicleWheelLocation wheel_location, float offset)
void UnloadLevelLayer(rpc::MapLayer map_layer) const
void SetWheelSteerDirection(rpc::ActorId vehicle, rpc::VehicleWheelLocation vehicle_wheel, float angle_in_deg)
void SetBonesTransform(rpc::ActorId walker, const rpc::WalkerBoneControlIn &bones)
void SetActorTargetAngularVelocity(rpc::ActorId actor, const geom::Vector3D &vector)
void UseCarSimRoad(rpc::ActorId vehicle, bool enabled)
std::pair< bool, rpc::LabelledPoint > ProjectPoint(geom::Location location, geom::Vector3D direction, float search_distance) const
std::vector< rpc::EnvironmentObject > GetEnvironmentObjects(uint8_t queried_tag) const
bool WalkerSetMaxSpeed(rpc::ActorId walker, float max_speed) const
void UpdateServerLightsState(std::vector< rpc::LightState > &lights, bool discard_client=false) const
std::vector< geom::Transform > GetActorSocketRelativeTransforms(rpc::ActorId actor)
std::vector< rpc::LightState > QueryLightsStateToServer() const
void GetPoseFromAnimation(rpc::ActorId walker)
void DestroyTrafficManager(uint16_t port) const
void DisableActorConstantAcceleration(rpc::ActorId actor)
void ApplyControlToVehicle(rpc::ActorId vehicle, const rpc::VehicleControl &control)
void UpdateDayNightCycle(const bool active) const
void EnableEnvironmentObjects(std::vector< uint64_t > env_objects_ids, bool enable) const
rpc::EpisodeSettings GetEpisodeSettings()
void SetWheelPitchAngle(rpc::ActorId vehicle, rpc::VehicleWheelLocation wheel_location, float angle_in_deg)
rpc::ContentPackInfo MountContentPack(const std::string &path)
WorldSnapshot WaitForTick(time_duration timeout)
rpc::WalkerBoneControlOut GetBonesTransform(Walker &walker)
Definition Simulator.h:680
void SetActorCollisions(Actor &actor, bool enabled)
Definition Simulator.h:606
float GetWheelSteerAngle(Vehicle &vehicle, rpc::VehicleWheelLocation wheel_location)
Definition Simulator.h:716
std::shared_ptr< Episode > _episode
Definition Simulator.h:1002
void SetActorTargetAngularVelocity(const Actor &actor, const geom::Vector3D &vector)
Definition Simulator.h:501
void CloseVehicleDoor(Vehicle &vehicle, const rpc::VehicleDoor door_idx)
Definition Simulator.h:708
rpc::ActorState GetActorState(const Actor &actor) const
State of actor according to the latest world snapshot.
Definition Simulator.h:468
rpc::VehicleLightState GetVehicleLightState(const Vehicle &vehicle) const
Definition Simulator.h:320
std::vector< rpc::Actor > GetAllTheActorsInTheEpisode() const
Definition Simulator.h:410
void SetSkyLightMap(const rpc::TextureFloatColor &panorama, float intensity, int32_t face_size)
Definition Simulator.h:978
void AddActorAngularImpulse(const Actor &actor, const geom::Vector3D &vector)
Definition Simulator.h:536
void DestroyTrafficManager(uint16_t port) const
Definition Simulator.h:258
bool ShouldUpdateMap(rpc::MapInfo &map_info)
void ApplyControlToWalker(Walker &walker, const rpc::WalkerControl &control)
Definition Simulator.h:676
std::vector< geom::Transform > GetEgoSpawnPoints() const
Definition Simulator.h:308
void AddPendingException(std::string e)
Definition Simulator.h:262
void DisableForROS(const Sensor &sensor)
void SetVehicleAutopilot(Vehicle &vehicle, bool enabled=true)
Definition Simulator.h:648
std::vector< geom::Transform > GetActorSocketRelativeTransforms(const Actor &actor)
Definition Simulator.h:572
void SetTrafficLightState(TrafficLight &trafficLight, const rpc::TrafficLightState trafficLightState)
Definition Simulator.h:848
bool UnmountContentPack(const std::string &name)
Definition Simulator.h:162
float GetWheelPitchAngle(Vehicle &vehicle, rpc::VehicleWheelLocation wheel_location)
Definition Simulator.h:724
void AddActorTorque(const Actor &actor, const geom::Vector3D &torque)
Definition Simulator.h:540
std::vector< rpc::EnvironmentObject > GetEnvironmentObjects(uint8_t queried_tag) const
Definition Simulator.h:333
void RequestFile(const std::string &name) const
std::vector< geom::BoundingBox > GetLevelBBs(uint8_t queried_tag) const
Returns all the BBs of all the elements of the level.
Definition Simulator.h:329
void EnableChronoPhysics(Vehicle &vehicle, uint64_t MaxSubsteps, float MaxSubstepDeltaTime, std::string VehicleJSON, std::string PowertrainJSON, std::string TireJSON, std::string BaseJSONPath)
Definition Simulator.h:748
geom::Transform GetActorComponentWorldTransform(const Actor &actor, const std::string &component_name)
Definition Simulator.h:544
void SetTrafficLightYellowTime(TrafficLight &trafficLight, float yellowTime)
Definition Simulator.h:856
void UseCarSimRoad(Vehicle &vehicle, bool enabled)
Definition Simulator.h:744
time_duration GetNetworkingTimeout()
Definition Simulator.h:200
rpc::WeatherParameters GetWeatherParameters()
Definition Simulator.h:280
bool WalkerSetMaxSpeed(ActorId walker_id, float max_speed)
Definition Simulator.h:382
std::vector< geom::Transform > GetActorBoneRelativeTransforms(const Actor &actor)
Definition Simulator.h:556
void ApplyPhysicsControlToVehicle(Vehicle &vehicle, const rpc::VehiclePhysicsControl &physicsControl)
Definition Simulator.h:696
std::vector< std::string > GetActorSocketNames(const Actor &actor)
Definition Simulator.h:576
void OpenVehicleDoor(Vehicle &vehicle, const rpc::VehicleDoor door_idx)
Definition Simulator.h:704
void UnloadLevelLayer(rpc::MapLayer map_layers) const
Definition Simulator.h:90
void ApplyTextureToActor(Actor &actor, const rpc::MaterialParameter &MaterialParameter, const rpc::TextureFloatColor &Texture)
Definition Simulator.h:634
geom::Location GetActorLocation(const Actor &actor) const
Definition Simulator.h:481
void ApplyTextureToActor(Actor &actor, const rpc::MaterialParameter &MaterialParameter, const rpc::TextureColor &Texture)
Definition Simulator.h:626
void SetActorTransform(Actor &actor, const geom::Transform &transform)
Definition Simulator.h:598
void EnableActorConstantVelocity(const Actor &actor, const geom::Vector3D &vector)
Definition Simulator.h:504
EpisodeProxy ReloadEpisode(bool reset_settings=true)
Definition Simulator.h:80
void SetIMUSensorGravity(float gravity)
Definition Simulator.h:292
void EnableForROS(const Sensor &sensor)
void SpawnCustomMesh(const std::vector< float > &vertices, const std::vector< uint32_t > &triangles, const std::string &material)
Spawns a static procedural mesh in the world.
Definition Simulator.h:905
geom::Transform GetActorTransform(const Actor &actor) const
Definition Simulator.h:485
void LoadLevelLayer(rpc::MapLayer map_layers) const
Definition Simulator.h:86
void RegisterAIController(const WalkerAIController &controller)
void ApplyControlToVehicle(Vehicle &vehicle, const rpc::VehicleControl &control)
Definition Simulator.h:660
bool WalkerGoToLocation(ActorId walker_id, const geom::Location &destination)
Definition Simulator.h:378
void ApplyBatch(std::vector< rpc::Command > commands, bool do_tick_cue)
Definition Simulator.h:918
std::optional< rpc::Actor > GetActorById(ActorId id) const
Definition Simulator.h:400
SharedPtr< LightManager > _light_manager
Definition Simulator.h:1000
void RemoveOnTickEvent(size_t id)
Definition Simulator.h:225
std::vector< std::string > GetRequiredFiles(const std::string &folder="", const bool download=true) const
void ApplyAckermannControllerSettings(Vehicle &vehicle, const rpc::AckermannControllerSettings &settings)
Definition Simulator.h:672
SharedPtr< Actor > MakeActor(rpc::Actor actor_description, GarbageCollectionPolicy gc=GarbageCollectionPolicy::Disabled)
Creates an actor instance out of a description of an existing actor.
Definition Simulator.h:421
void UpdateDayNightCycle(const bool active) const
Definition Simulator.h:946
bool IsEnabledForROS(const Sensor &sensor)
void SetBonesTransform(Walker &walker, const rpc::WalkerBoneControlIn &bones)
Definition Simulator.h:684
size_t RegisterOnTickEvent(std::function< void(WorldSnapshot)> callback)
Definition Simulator.h:220
SharedPtr< BlueprintLibrary > GetBlueprintLibrary()
SharedPtr< Actor > SpawnActor(const ActorBlueprint &blueprint, const geom::Transform &transform, Actor *parent=nullptr, rpc::AttachmentType attachment_type=rpc::AttachmentType::Rigid, GarbageCollectionPolicy gc=GarbageCollectionPolicy::Inherit)
Spawns an actor into the simulation.
void UpdateServerLightsState(std::vector< rpc::LightState > &lights, bool discard_client=false) const
Definition Simulator.h:940
std::vector< std::string > GetActorBoneNames(const Actor &actor)
Definition Simulator.h:564
std::vector< geom::Transform > GetActorBoneWorldTransforms(const Actor &actor)
Definition Simulator.h:552
Simulator(const std::string &host, uint16_t port, size_t worker_threads=0u, bool enable_garbage_collection=false)
Definition Simulator.cpp:84
void EnableEnvironmentObjects(std::vector< uint64_t > env_objects_ids, bool enable) const
Definition Simulator.h:337
rpc::ContentPackInfo MountContentPack(const std::string &path)
Definition Simulator.h:158
const GarbageCollectionPolicy _gc_policy
Definition Simulator.h:1004
void SetActorSimulatePhysics(Actor &actor, bool enabled)
Definition Simulator.h:602
std::vector< std::string > GetAvailableMaps()
Definition Simulator.h:144
void SetWheelAnimationOverride(Vehicle &vehicle, bool enabled)
Definition Simulator.h:736
void SetWheelSuspensionOffset(Vehicle &vehicle, rpc::VehicleWheelLocation wheel_location, float offset)
Definition Simulator.h:728
void SetActorEnableGravity(Actor &actor, bool enabled)
Definition Simulator.h:622
void SetLightsToVehicle(Vehicle &vehicle, const rpc::VehicleControl &control)
Definition Simulator.h:656
void SetWeatherParameters(const rpc::WeatherParameters &weather)
Definition Simulator.h:284
bool WalkerStopNavigation(ActorId walker_id)
Definition Simulator.h:386
rpc::VehicleLightStateList GetVehiclesLightStates()
Returns a list of pairs where the firts element is the vehicle ID and the second one is the light sta...
bool DestroyActor(ActorId actor_id)
Definition Simulator.h:443
void UnSubscribeFromGBuffer(Actor &sensor, uint32_t gbuffer_id)
std::vector< geom::Transform > GetVehicleBoneWorldTransforms(const Vehicle &vehicle)
Definition Simulator.h:324
void SubscribeToSensor(const Sensor &sensor, std::function< void(SharedPtr< sensor::SensorData >)> callback)
void GetPoseFromAnimation(Walker &walker)
Definition Simulator.h:692
std::string ShowRecorderCollisions(std::string name, char type1, char type2)
Definition Simulator.h:782
auto ApplyBatchSync(std::vector< rpc::Command > commands, bool do_tick_cue)
Definition Simulator.h:922
std::vector< rpc::ContentPackInfo > GetContentPacks()
Definition Simulator.h:154
void UnregisterAIController(const WalkerAIController &controller)
void BlendPose(Walker &walker, float blend)
Definition Simulator.h:688
void SetLightStateToVehicle(Vehicle &vehicle, const rpc::VehicleLightState light_state)
Definition Simulator.h:700
void SetActorDead(Actor &actor)
Definition Simulator.h:614
void ResetTrafficLightGroup(TrafficLight &trafficLight)
Definition Simulator.h:868
void SetReplayerIgnoreHero(bool ignore_hero)
Definition Simulator.h:801
std::vector< uint8_t > GetCacheFile(const std::string &name, const bool request_otherwise) const
void ApplyColorTextureToObjects(const std::vector< std::string > &objects_name, const rpc::MaterialParameter &parameter, const rpc::TextureColor &Texture)
– Texture updating operations
void DrawDebugShape(const rpc::DebugShape &shape)
Definition Simulator.h:890
std::vector< std::string > GetActorComponentNames(const Actor &actor)
Definition Simulator.h:560
std::shared_ptr< WalkerNavigation > GetNavigation()
geom::Vector3D GetActorAcceleration(const Actor &actor) const
Definition Simulator.h:580
bool SetFilesBaseFolder(const std::string &path)
SharedPtr< Actor > GetSpectator()
std::vector< rpc::LightState > QueryLightsStateToServer() const
Definition Simulator.h:936
geom::Vector3D GetActorVelocity(const Actor &actor) const
Definition Simulator.h:489
EpisodeProxy LoadOpenDriveEpisode(std::string opendrive, const rpc::OpendriveGenerationParameters &params, bool reset_settings=true)
void Send(const Sensor &sensor, const rpc::CustomV2XBytes &data)
void SetPedestriansCrossFactor(float percentage)
void FreezeAllTrafficLights(bool frozen)
rpc::VehicleTelemetryData GetVehicleTelemetryData(const Vehicle &vehicle) const
Definition Simulator.h:316
uint64_t SetEpisodeSettings(const rpc::EpisodeSettings &settings)
void EnableCarSim(Vehicle &vehicle, std::string simfile_path)
Definition Simulator.h:740
std::string GetActorName(const Actor &actor) const
Definition Simulator.h:584
size_t RegisterLightUpdateChangeEvent(std::function< void(WorldSnapshot)> callback)
Definition Simulator.h:950
bool IsTrafficManagerRunning(uint16_t port) const
Query to know if a Traffic Manager is running on port.
Definition Simulator.h:243
void SetWheelSteerDirection(Vehicle &vehicle, rpc::VehicleWheelLocation wheel_location, float angle_in_deg)
Definition Simulator.h:712
void DisableActorConstantAcceleration(const Actor &actor)
Definition Simulator.h:516
void SetNetworkingTimeout(time_duration timeout)
Definition Simulator.h:196
void SetActorLocation(Actor &actor, const geom::Location &location)
Definition Simulator.h:594
SharedPtr< LightManager > GetLightManager() const
Definition Simulator.h:932
std::pair< std::string, uint16_t > GetTrafficManagerRunning(uint16_t port) const
Gets a pair filled with the <IP, port> of the Trafic Manager running on port.
Definition Simulator.h:249
std::vector< rpc::Actor > GetActorsById(const std::vector< ActorId > &actor_ids) const
Definition Simulator.h:405
std::string ShowRecorderActorsBlocked(std::string name, double min_time, double min_distance)
Definition Simulator.h:786
void UnSubscribeFromSensor(Actor &sensor)
EpisodeProxy LoadEpisode(std::string map_name, bool reset_settings=true, rpc::MapLayer map_layers=rpc::MapLayer::All)
rpc::AckermannControllerSettings GetAckermannControllerSettings(const Vehicle &vehicle) const
Definition Simulator.h:668
void ApplyAckermannControlToVehicle(Vehicle &vehicle, const rpc::VehicleAckermannControl &control)
Definition Simulator.h:664
void SetTrafficLightRedTime(TrafficLight &trafficLight, float redTime)
Definition Simulator.h:860
void RemoveLightUpdateChangeEvent(size_t id)
Definition Simulator.h:955
WorldSnapshot GetWorldSnapshot() const
Definition Simulator.h:131
std::string ReplayFile(std::string name, double start, double duration, uint32_t follow_id, bool replay_sensors, bool replay_weather, const geom::Transform &offset, std::string map_override)
Definition Simulator.h:790
std::string GetActorClassName(const Actor &actor) const
Definition Simulator.h:589
void FreezeTrafficLight(TrafficLight &trafficLight, bool freeze)
Definition Simulator.h:864
uint64_t Tick(time_duration timeout)
void SetActorTargetVelocity(const Actor &actor, const geom::Vector3D &vector)
Definition Simulator.h:493
std::vector< rpc::LabelledPoint > CastRay(geom::Location start_location, geom::Location end_location) const
Definition Simulator.h:348
void EnableActorConstantAcceleration(const Actor &actor, const geom::Vector3D &vector)
Definition Simulator.h:512
void AddActorImpulse(const Actor &actor, const geom::Vector3D &impulse)
Definition Simulator.h:520
void AddActorForce(const Actor &actor, const geom::Vector3D &force, const geom::Vector3D &location)
Definition Simulator.h:532
void AddActorImpulse(const Actor &actor, const geom::Vector3D &impulse, const geom::Vector3D &location)
Definition Simulator.h:524
void SubscribeToGBuffer(Actor &sensor, uint32_t gbuffer_id, std::function< void(SharedPtr< sensor::SensorData >)> callback)
void SetTrafficLightGreenTime(TrafficLight &trafficLight, float greenTime)
Definition Simulator.h:852
ActorSnapshot GetActorSnapshot(ActorId actor_id) const
Definition Simulator.h:448
void StopReplayer(bool keep_actors)
Definition Simulator.h:809
void AddActorForce(const Actor &actor, const geom::Vector3D &force)
Definition Simulator.h:528
geom::Vector3D GetActorAngularVelocity(const Actor &actor) const
Definition Simulator.h:497
std::pair< bool, rpc::LabelledPoint > ProjectPoint(geom::Location location, geom::Vector3D direction, float search_distance) const
Definition Simulator.h:343
GarbageCollectionPolicy GetGarbageCollectionPolicy() const
Definition Simulator.h:186
void SetActorCollisions(ActorId actor_id, bool enabled)
Definition Simulator.h:610
std::string StartRecorder(std::string name, bool additional_data, bool stop_replayer)
Definition Simulator.h:770
static void Delete(Simulator *simulator)
Deleter: on a pool thread, destroy on a background thread (~Simulator joins the pools).
std::vector< std::string > GetNamesOfAllObjects() const
void SetReplayerTimeFactor(double time_factor)
Definition Simulator.h:797
SharedPtr< Map > GetCurrentMap()
bool AddTrafficManagerRunning(std::pair< std::string, uint16_t > trafficManagerInfo) const
Informs that a Traffic Manager is running on <IP, port>.
Definition Simulator.h:254
void SetPublishTF(bool publish_tf)
Definition Simulator.h:300
float GetWheelSuspensionOffset(Vehicle &vehicle, rpc::VehicleWheelLocation wheel_location)
Definition Simulator.h:732
rpc::VehiclePhysicsControl GetVehiclePhysicsControl(const Vehicle &vehicle) const
Definition Simulator.h:312
void ShowVehicleDebugTelemetry(Vehicle &vehicle, bool enabled=true)
Definition Simulator.h:652
void SetWheelPitchAngle(Vehicle &vehicle, rpc::VehicleWheelLocation wheel_location, float angle_in_deg)
Definition Simulator.h:720
std::optional< geom::Location > GetRandomLocationFromNavigation()
bool WalkerStartNavigation(ActorId walker_id)
Definition Simulator.h:374
rpc::EpisodeSettings GetEpisodeSettings()
Definition Simulator.h:274
geom::Transform GetActorComponentRelativeTransform(const Actor &actor, const std::string &component_name)
Definition Simulator.h:548
ActorSnapshot GetActorSnapshot(const Actor &actor) const
Definition Simulator.h:453
bool DestroyActor(Actor &actor)
std::vector< geom::Transform > GetActorSocketWorldTransforms(const Actor &actor)
Definition Simulator.h:568
void SetPedestriansSeed(unsigned int seed)
void DisableActorConstantVelocity(const Actor &actor)
Definition Simulator.h:508
std::vector< geom::BoundingBox > GetLightBoxes(const TrafficLight &trafficLight) const
Definition Simulator.h:876
bool IsNavigationServerSide()
True when the current episode's navigation is hosted by the server (World-Partitioned navmesh); walke...
void SetActorDead(ActorId actor_id)
Definition Simulator.h:618
std::string ShowRecorderFileInfo(std::string name, bool show_all)
Definition Simulator.h:778
std::vector< ActorId > GetGroupTrafficLights(TrafficLight &trafficLight)
Definition Simulator.h:880
void SetReplayerIgnoreSpectator(bool ignore_spectator)
Definition Simulator.h:805
A rigid transform in CARLA's / Unreal's left-handed frame: x forward, y right, z up,...
Description of a CARLA content pack known to the server (see UCarlaContentPackManager).
Fixed-size binary payload carried by the custom V2X sensor (sensor.other.v2x_custom).
Defines the physical appearance of a vehicle whitch is obtained by the sensors.
Positive time duration up to milliseconds resolution.
Definition Time.h:20
EpisodeProxyImpl< EpisodeProxyPointerType::Strong > EpisodeProxy
Texture< sensor::data::Color > TextureColor
Definition Texture.h:66
Texture< FloatColor > TextureFloatColor
Definition Texture.h:67
std::vector< std::pair< ActorId, VehicleLightState::flag_type > > VehicleLightStateList
This file contains definitions of common data structures used in traffic manager.
std::shared_ptr< T > SharedPtr
Definition Memory.h:15
Seting for map generation from opendrive without additional geometry.