32#include <boost/optional.hpp>
40 class BlueprintLibrary;
43 class WalkerAIController;
44 class WalkerNavigation;
50 :
public std::enable_shared_from_this<Simulator>,
61 const std::string &host,
63 size_t worker_threads = 0u,
64 bool enable_garbage_collection =
false);
87 std::string opendrive,
89 bool reset_settings =
true);
148 std::vector<std::string>
GetRequiredFiles(
const std::string &folder =
"",
const bool download =
true)
const;
152 std::vector<uint8_t>
GetCacheFile(
const std::string &name,
const bool request_otherwise)
const;
196 return _episode->RegisterOnTickEvent(std::move(callback));
279 std::vector<geom::BoundingBox>
GetLevelBBs(uint8_t queried_tag)
const {
288 std::vector<uint64_t> env_objects_ids,
334 std::vector<rpc::Actor>
GetActorsById(
const std::vector<ActorId> &actor_ids)
const {
336 return _episode->GetActorsById(actor_ids);
366 Actor *parent =
nullptr,
369 const std::string& socket_name =
"");
380 return _episode->GetState()->GetActorSnapshot(actor_id);
609 uint64_t MaxSubsteps,
610 float MaxSubstepDeltaTime,
611 std::string VehicleJSON,
612 std::string PowertrainJSON,
613 std::string TireJSON,
614 std::string BaseJSONPath) {
654 std::string
ReplayFile(std::string name,
double start,
double duration,
655 uint32_t follow_id,
bool replay_sensors) {
656 return _client.
ReplayFile(std::move(name), start, duration, follow_id, replay_sensors);
700 uint32_t gbuffer_id);
702 void Send(
const Sensor &sensor, std::string message);
762 void ApplyBatch(std::vector<rpc::Command> commands,
bool do_tick_cue) {
785 std::vector<rpc::LightState>& lights,
786 bool discard_client =
false)
const {
796 return _episode->RegisterLightUpdateChangeEvent(std::move(callback));
801 _episode->RemoveLightUpdateChangeEvent(
id);
813 const std::vector<std::string> &objects_name,
818 const std::vector<std::string> &objects_name,
#define DEBUG_ASSERT(predicate)
#define RELEASE_ASSERT(pred)
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.
Provides communication with the rpc and streaming servers of a CARLA simulator.
void SetReplayerIgnoreHero(bool ignore_hero)
geom::Transform GetActorComponentRelativeTransform(rpc::ActorId actor, const std::string componentName)
void SetTrafficLightRedTime(rpc::ActorId traffic_light, float red_time)
void ApplyControlToWalker(rpc::ActorId walker, const rpc::WalkerControl &control)
std::string GetClientVersion()
void OpenVehicleDoor(rpc::ActorId vehicle, const rpc::VehicleDoor door_idx)
const std::string GetEndpoint() const
rpc::WeatherParameters GetWeatherParameters()
std::vector< std::string > GetActorBoneNames(rpc::ActorId actor)
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)
std::vector< std::string > GetAvailableMaps()
rpc::VehicleLightState GetVehicleLightState(rpc::ActorId vehicle) const
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)
std::string ShowRecorderActorsBlocked(std::string name, double min_time, double min_distance)
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 ResetAllTrafficLights()
void SetActorAutopilot(rpc::ActorId vehicle, bool enabled)
void ResetTrafficLightGroup(rpc::ActorId traffic_light)
float GetIMUISensorGravity() const
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 StopReplayer(bool keep_actors)
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 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::string StartRecorder(std::string name, bool additional_data)
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::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 EnableCarSim(rpc::ActorId vehicle, std::string simfile_path)
void SetTimeout(time_duration timeout)
geom::Transform GetActorComponentWorldTransform(rpc::ActorId actor, const std::string componentName)
std::vector< geom::Transform > GetActorBoneRelativeTransforms(rpc::ActorId actor)
void SetActorEnableGravity(rpc::ActorId actor, bool enabled)
void SetActorSimulatePhysics(rpc::ActorId actor, bool enabled)
void RestorePhysXPhysics(rpc::ActorId vehicle)
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 ReplayFile(std::string name, double start, double duration, uint32_t follow_id, bool replay_sensors)
std::vector< std::string > GetActorSocketNames(rpc::ActorId actor)
rpc::WalkerBoneControlOut GetBonesTransform(rpc::ActorId walker)
std::string GetServerVersion()
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
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 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()
time_duration GetTimeout() const
void SetIMUISensorGravity(float NewIMUISensorGravity)
Connects and controls a CARLA Simulator.
WorldSnapshot WaitForTick(time_duration timeout)
rpc::WalkerBoneControlOut GetBonesTransform(Walker &walker)
void SetActorCollisions(Actor &actor, bool enabled)
float GetWheelSteerAngle(Vehicle &vehicle, rpc::VehicleWheelLocation wheel_location)
std::shared_ptr< Episode > _episode
void SetActorTargetAngularVelocity(const Actor &actor, const geom::Vector3D &vector)
void CloseVehicleDoor(Vehicle &vehicle, const rpc::VehicleDoor door_idx)
rpc::ActorState GetActorState(const Actor &actor) const
rpc::VehicleLightState GetVehicleLightState(const Vehicle &vehicle) const
std::vector< rpc::Actor > GetAllTheActorsInTheEpisode() const
void AddActorAngularImpulse(const Actor &actor, const geom::Vector3D &vector)
void DestroyTrafficManager(uint16_t port) const
bool ShouldUpdateMap(rpc::MapInfo &map_info)
void ApplyControlToWalker(Walker &walker, const rpc::WalkerControl &control)
void AddPendingException(std::string e)
void DisableForROS(const Sensor &sensor)
void SetVehicleAutopilot(Vehicle &vehicle, bool enabled=true)
std::vector< geom::Transform > GetActorSocketRelativeTransforms(const Actor &actor)
void SetTrafficLightState(TrafficLight &trafficLight, const rpc::TrafficLightState trafficLightState)
geom::Transform GetActorComponentWorldTransform(const Actor &actor, const std::string componentName)
std::string GetClientVersion()
void AddActorTorque(const Actor &actor, const geom::Vector3D &torque)
std::string ReplayFile(std::string name, double start, double duration, uint32_t follow_id, bool replay_sensors)
std::vector< rpc::EnvironmentObject > GetEnvironmentObjects(uint8_t queried_tag) const
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
void EnableChronoPhysics(Vehicle &vehicle, uint64_t MaxSubsteps, float MaxSubstepDeltaTime, std::string VehicleJSON, std::string PowertrainJSON, std::string TireJSON, std::string BaseJSONPath)
std::string _open_drive_file
void SetTrafficLightYellowTime(TrafficLight &trafficLight, float yellowTime)
void UseCarSimRoad(Vehicle &vehicle, bool enabled)
std::string StartRecorder(std::string name, bool additional_data)
time_duration GetNetworkingTimeout()
rpc::WeatherParameters GetWeatherParameters()
std::vector< geom::Transform > GetActorBoneRelativeTransforms(const Actor &actor)
void ApplyPhysicsControlToVehicle(Vehicle &vehicle, const rpc::VehiclePhysicsControl &physicsControl)
std::vector< std::string > GetActorSocketNames(const Actor &actor)
void OpenVehicleDoor(Vehicle &vehicle, const rpc::VehicleDoor door_idx)
void UnloadLevelLayer(rpc::MapLayer map_layers) const
geom::Location GetActorLocation(const Actor &actor) const
void SetActorTransform(Actor &actor, const geom::Transform &transform)
void EnableActorConstantVelocity(const Actor &actor, const geom::Vector3D &vector)
EpisodeProxy ReloadEpisode(bool reset_settings=true)
void EnableForROS(const Sensor &sensor)
geom::Transform GetActorTransform(const Actor &actor) const
boost::optional< rpc::Actor > GetActorById(ActorId id) const
void LoadLevelLayer(rpc::MapLayer map_layers) const
void RegisterAIController(const WalkerAIController &controller)
void ApplyControlToVehicle(Vehicle &vehicle, const rpc::VehicleControl &control)
void SetIMUISensorGravity(float NewIMUISensorGravity)
void ApplyBatch(std::vector< rpc::Command > commands, bool do_tick_cue)
SharedPtr< LightManager > _light_manager
void RemoveOnTickEvent(size_t id)
SharedPtr< Actor > SpawnActor(const ActorBlueprint &blueprint, const geom::Transform &transform, Actor *parent=nullptr, rpc::AttachmentType attachment_type=rpc::AttachmentType::Rigid, GarbageCollectionPolicy gc=GarbageCollectionPolicy::Inherit, const std::string &socket_name="")
Spawns an actor into the simulation.
std::vector< std::string > GetRequiredFiles(const std::string &folder="", const bool download=true) const
void ApplyAckermannControllerSettings(Vehicle &vehicle, const rpc::AckermannControllerSettings &settings)
SharedPtr< Actor > MakeActor(rpc::Actor actor_description, GarbageCollectionPolicy gc=GarbageCollectionPolicy::Disabled)
Creates an actor instance out of a description of an existing actor.
void UpdateDayNightCycle(const bool active) const
bool IsEnabledForROS(const Sensor &sensor)
void SetBonesTransform(Walker &walker, const rpc::WalkerBoneControlIn &bones)
size_t RegisterOnTickEvent(std::function< void(WorldSnapshot)> callback)
SharedPtr< BlueprintLibrary > GetBlueprintLibrary()
void GetReadyCurrentEpisode()
void UpdateServerLightsState(std::vector< rpc::LightState > &lights, bool discard_client=false) const
std::vector< std::string > GetActorBoneNames(const Actor &actor)
std::vector< geom::Transform > GetActorBoneWorldTransforms(const Actor &actor)
Simulator(const std::string &host, uint16_t port, size_t worker_threads=0u, bool enable_garbage_collection=false)
void EnableEnvironmentObjects(std::vector< uint64_t > env_objects_ids, bool enable) const
const GarbageCollectionPolicy _gc_policy
void SetActorSimulatePhysics(Actor &actor, bool enabled)
std::vector< std::string > GetAvailableMaps()
void SetActorEnableGravity(Actor &actor, bool enabled)
void SetLightsToVehicle(Vehicle &vehicle, const rpc::VehicleControl &control)
void SetWeatherParameters(const rpc::WeatherParameters &weather)
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)
void UnSubscribeFromGBuffer(Actor &sensor, uint32_t gbuffer_id)
void SubscribeToSensor(const Sensor &sensor, std::function< void(SharedPtr< sensor::SensorData >)> callback)
void GetPoseFromAnimation(Walker &walker)
float GetIMUISensorGravity() const
std::string ShowRecorderCollisions(std::string name, char type1, char type2)
auto ApplyBatchSync(std::vector< rpc::Command > commands, bool do_tick_cue)
void UnregisterAIController(const WalkerAIController &controller)
void BlendPose(Walker &walker, float blend)
void SetLightStateToVehicle(Vehicle &vehicle, const rpc::VehicleLightState light_state)
void SetActorDead(Actor &actor)
void ResetTrafficLightGroup(TrafficLight &trafficLight)
void SetReplayerIgnoreHero(bool ignore_hero)
std::vector< uint8_t > GetCacheFile(const std::string &name, const bool request_otherwise) const
SharedPtr< Map > _cached_map
void ApplyColorTextureToObjects(const std::vector< std::string > &objects_name, const rpc::MaterialParameter ¶meter, const rpc::TextureColor &Texture)
– Texture updating operations
void DrawDebugShape(const rpc::DebugShape &shape)
std::vector< std::string > GetActorComponentNames(const Actor &actor)
std::shared_ptr< WalkerNavigation > GetNavigation()
geom::Vector3D GetActorAcceleration(const Actor &actor) const
bool SetFilesBaseFolder(const std::string &path)
SharedPtr< Actor > GetSpectator()
std::vector< rpc::LightState > QueryLightsStateToServer() const
geom::Vector3D GetActorVelocity(const Actor &actor) const
EpisodeProxy LoadOpenDriveEpisode(std::string opendrive, const rpc::OpendriveGenerationParameters ¶ms, bool reset_settings=true)
void SetPedestriansCrossFactor(float percentage)
void FreezeAllTrafficLights(bool frozen)
rpc::VehicleTelemetryData GetVehicleTelemetryData(const Vehicle &vehicle) const
uint64_t SetEpisodeSettings(const rpc::EpisodeSettings &settings)
void EnableCarSim(Vehicle &vehicle, std::string simfile_path)
size_t RegisterLightUpdateChangeEvent(std::function< void(WorldSnapshot)> callback)
bool IsTrafficManagerRunning(uint16_t port) const
Query to know if a Traffic Manager is running on port
void SetWheelSteerDirection(Vehicle &vehicle, rpc::VehicleWheelLocation wheel_location, float angle_in_deg)
void SetNetworkingTimeout(time_duration timeout)
auto GetCurrentEpisodeId()
void SetActorLocation(Actor &actor, const geom::Location &location)
SharedPtr< LightManager > GetLightManager() 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.
std::vector< rpc::Actor > GetActorsById(const std::vector< ActorId > &actor_ids) const
std::string GetServerVersion()
std::string ShowRecorderActorsBlocked(std::string name, double min_time, double min_distance)
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
void ApplyAckermannControlToVehicle(Vehicle &vehicle, const rpc::VehicleAckermannControl &control)
void SetTrafficLightRedTime(TrafficLight &trafficLight, float redTime)
void RemoveLightUpdateChangeEvent(size_t id)
void RestorePhysXPhysics(Vehicle &vehicle)
WorldSnapshot GetWorldSnapshot() const
std::string GetEndpoint()
void FreezeTrafficLight(TrafficLight &trafficLight, bool freeze)
uint64_t Tick(time_duration timeout)
void SetActorTargetVelocity(const Actor &actor, const geom::Vector3D &vector)
std::vector< rpc::LabelledPoint > CastRay(geom::Location start_location, geom::Location end_location) const
void AddActorImpulse(const Actor &actor, const geom::Vector3D &impulse)
void AddActorForce(const Actor &actor, const geom::Vector3D &force, const geom::Vector3D &location)
void AddActorImpulse(const Actor &actor, const geom::Vector3D &impulse, const geom::Vector3D &location)
void SubscribeToGBuffer(Actor &sensor, uint32_t gbuffer_id, std::function< void(SharedPtr< sensor::SensorData >)> callback)
void SetTrafficLightGreenTime(TrafficLight &trafficLight, float greenTime)
ActorSnapshot GetActorSnapshot(ActorId actor_id) const
void StopReplayer(bool keep_actors)
void AddActorForce(const Actor &actor, const geom::Vector3D &force)
geom::Vector3D GetActorAngularVelocity(const Actor &actor) const
std::pair< bool, rpc::LabelledPoint > ProjectPoint(geom::Location location, geom::Vector3D direction, float search_distance) const
GarbageCollectionPolicy GetGarbageCollectionPolicy() const
void SetActorCollisions(ActorId actor_id, bool enabled)
std::vector< std::string > GetNamesOfAllObjects() const
void SetReplayerTimeFactor(double time_factor)
SharedPtr< Map > GetCurrentMap()
bool AddTrafficManagerRunning(std::pair< std::string, uint16_t > trafficManagerInfo) const
Informs that a Traffic Manager is running on <IP, port>
geom::Transform GetActorComponentRelativeTransform(const Actor &actor, std::string componentName)
rpc::VehiclePhysicsControl GetVehiclePhysicsControl(const Vehicle &vehicle) const
void ShowVehicleDebugTelemetry(Vehicle &vehicle, bool enabled=true)
void ResetAllTrafficLights()
rpc::EpisodeSettings GetEpisodeSettings()
ActorSnapshot GetActorSnapshot(const Actor &actor) const
bool DestroyActor(Actor &actor)
std::vector< geom::Transform > GetActorSocketWorldTransforms(const Actor &actor)
void SetPedestriansSeed(unsigned int seed)
void DisableActorConstantVelocity(const Actor &actor)
std::vector< geom::BoundingBox > GetLightBoxes(const TrafficLight &trafficLight) const
boost::optional< geom::Location > GetRandomLocationFromNavigation()
EpisodeProxy GetCurrentEpisode()
void Send(const Sensor &sensor, std::string message)
void SetActorDead(ActorId actor_id)
std::string ShowRecorderFileInfo(std::string name, bool show_all)
std::vector< ActorId > GetGroupTrafficLights(TrafficLight &trafficLight)
void SetReplayerIgnoreSpectator(bool ignore_spectator)
Defines the physical appearance of a vehicle whitch is obtained by the sensors.
Positive time duration up to milliseconds resolution.
std::vector< std::pair< ActorId, VehicleLightState::flag_type > > VehicleLightStateList
This file contains definitions of common data structures used in traffic manager.
boost::shared_ptr< T > SharedPtr
Use this SharedPtr (boost::shared_ptr) to keep compatibility with boost::python, but it would be nice...
geom::Vector3D angular_velocity
geom::Vector3D acceleration
rpc::ActorState actor_state
geom::Transform transform
Seting for map generation from opendrive without additional geometry