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