CARLA
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
carla::client::Client Class Reference

#include <Client.h>

Public Member Functions

void ApplyBatch (std::vector< rpc::Command > commands, bool do_tick_cue=false) const
 
std::vector< rpc::CommandResponse > ApplyBatchSync (std::vector< rpc::Command > commands, bool do_tick_cue=false) const
 
 Client (const std::string &host, uint16_t port, size_t worker_threads=0u)
 Construct a carla client.
 
World GenerateOpenDriveWorld (std::string opendrive, const rpc::OpendriveGenerationParameters &params, bool reset_settings=true) const
 
std::vector< std::string > GetAvailableMaps () const
 
std::string GetClientVersion () const
 Return the version string of this client API.
 
std::vector< rpc::ContentPackInfo > GetContentPacks () const
 Content packs known to the server (discovered at startup or mounted through MountContentPack), mounted or not.
 
carla::client::detail::EpisodeProxy GetCurrentEpisode () const
 Return an instance of the Episode currently active in the simulator.
 
TrafficManager GetInstanceTM (uint16_t port=TM_DEFAULT_PORT) const
 Return an instance of the TrafficManager currently active in the simulator.
 
std::vector< std::string > GetRequiredFiles (const std::string &folder="", const bool download=true) const
 
std::string GetServerVersion () const
 Return the version string of the simulator we are connected to.
 
time_duration GetTimeout ()
 
World GetWorld () const
 Return an instance of the world currently active in the simulator.
 
World LoadWorld (std::string map_name, bool reset_settings=true, rpc::MapLayer map_layers=rpc::MapLayer::All) const
 
World LoadWorldIfDifferent (std::string map_name, bool reset_settings=true, rpc::MapLayer map_layers=rpc::MapLayer::All) const
 Return the current world, loading map_name first unless it is already the map in use.
 
rpc::ContentPackInfo MountContentPack (const std::string &path) const
 Mount a content pack from a directory on the server host (the pack directory or its carla-pack.json).
 
World ReloadWorld (bool reset_settings=true) const
 
std::string ReplayFile (std::string name, double start, double duration, uint32_t follow_id, bool replay_sensors, bool replay_weather=false, const geom::Transform &offset=geom::Transform(), std::string map_override="")
 
void RequestFile (const std::string &name) const
 
bool SetFilesBaseFolder (const std::string &path)
 
void SetReplayerIgnoreHero (bool ignore_hero)
 
void SetReplayerIgnoreSpectator (bool ignore_spectator)
 
void SetReplayerTimeFactor (double time_factor)
 
void SetTimeout (time_duration timeout)
 Set a timeout for networking operations.
 
std::string ShowRecorderActorsBlocked (std::string name, double min_time, double min_distance)
 
std::string ShowRecorderCollisions (std::string name, char type1, char type2)
 
std::string ShowRecorderFileInfo (std::string name, bool show_all)
 
std::string StartRecorder (std::string name, bool additional_data=false, bool stop_replayer=true)
 
void StopRecorder (void)
 
void StopReplayer (bool keep_actors)
 
bool UnmountContentPack (const std::string &name) const
 Unmount a content pack by name.
 

Private Attributes

std::shared_ptr< detail::Simulator > _simulator
 

Detailed Description

Definition at line 21 of file client/Client.h.

Constructor & Destructor Documentation

◆ Client()

carla::client::Client::Client ( const std::string &  host,
uint16_t  port,
size_t  worker_threads = 0u 
)
inlineexplicit

Construct a carla client.

Parameters
hostIP address of the host machine running the simulator.
portTCP port to connect with the simulator.
worker_threadsnumber of asynchronous threads to use, or 0 to use all available hardware concurrency.

Definition at line 206 of file client/Client.h.

Member Function Documentation

◆ ApplyBatch()

void carla::client::Client::ApplyBatch ( std::vector< rpc::Command >  commands,
bool  do_tick_cue = false 
) const
inline

Definition at line 185 of file client/Client.h.

References _simulator.

◆ ApplyBatchSync()

std::vector< rpc::CommandResponse > carla::client::Client::ApplyBatchSync ( std::vector< rpc::Command >  commands,
bool  do_tick_cue = false 
) const
inline

Definition at line 191 of file client/Client.h.

References _simulator.

◆ GenerateOpenDriveWorld()

World carla::client::Client::GenerateOpenDriveWorld ( std::string  opendrive,
const rpc::OpendriveGenerationParameters &  params,
bool  reset_settings = true 
) const
inline

Definition at line 115 of file client/Client.h.

References _simulator.

◆ GetAvailableMaps()

std::vector< std::string > carla::client::Client::GetAvailableMaps ( ) const
inline

Definition at line 55 of file client/Client.h.

References _simulator.

◆ GetClientVersion()

std::string carla::client::Client::GetClientVersion ( ) const
inline

Return the version string of this client API.

Definition at line 46 of file client/Client.h.

References _simulator.

◆ GetContentPacks()

std::vector< rpc::ContentPackInfo > carla::client::Client::GetContentPacks ( ) const
inline

Content packs known to the server (discovered at startup or mounted through MountContentPack), mounted or not.

Definition at line 61 of file client/Client.h.

References _simulator.

◆ GetCurrentEpisode()

carla::client::detail::EpisodeProxy carla::client::Client::GetCurrentEpisode ( ) const
inline

Return an instance of the Episode currently active in the simulator.

Definition at line 134 of file client/Client.h.

References _simulator.

◆ GetInstanceTM()

TrafficManager carla::client::Client::GetInstanceTM ( uint16_t  port = TM_DEFAULT_PORT) const
inline

Return an instance of the TrafficManager currently active in the simulator.

Definition at line 129 of file client/Client.h.

References _simulator.

◆ GetRequiredFiles()

std::vector< std::string > carla::client::Client::GetRequiredFiles ( const std::string &  folder = "",
const bool  download = true 
) const
inline

Definition at line 83 of file client/Client.h.

References _simulator.

◆ GetServerVersion()

std::string carla::client::Client::GetServerVersion ( ) const
inline

Return the version string of the simulator we are connected to.

Definition at line 51 of file client/Client.h.

References _simulator.

◆ GetTimeout()

time_duration carla::client::Client::GetTimeout ( )
inline

Definition at line 41 of file client/Client.h.

References _simulator.

◆ GetWorld()

World carla::client::Client::GetWorld ( ) const
inline

Return an instance of the world currently active in the simulator.

Definition at line 124 of file client/Client.h.

References _simulator.

Referenced by LoadWorldIfDifferent().

◆ LoadWorld()

World carla::client::Client::LoadWorld ( std::string  map_name,
bool  reset_settings = true,
rpc::MapLayer  map_layers = rpc::MapLayer::All 
) const
inline

Definition at line 95 of file client/Client.h.

References _simulator.

◆ LoadWorldIfDifferent()

World carla::client::Client::LoadWorldIfDifferent ( std::string  map_name,
bool  reset_settings = true,
rpc::MapLayer  map_layers = rpc::MapLayer::All 
) const
inline

Return the current world, loading map_name first unless it is already the map in use.

map_name has to match the running map exactly.

Definition at line 104 of file client/Client.h.

References _simulator, carla::client::World::GetMap(), and GetWorld().

◆ MountContentPack()

rpc::ContentPackInfo carla::client::Client::MountContentPack ( const std::string &  path) const
inline

Mount a content pack from a directory on the server host (the pack directory or its carla-pack.json).

Throws with the server's reason when the pack is invalid, incompatible with the base release or already mounted. Its maps show up in GetAvailableMaps afterwards.

Definition at line 69 of file client/Client.h.

References _simulator.

◆ ReloadWorld()

World carla::client::Client::ReloadWorld ( bool  reset_settings = true) const
inline

Definition at line 91 of file client/Client.h.

References _simulator.

◆ ReplayFile()

std::string carla::client::Client::ReplayFile ( std::string  name,
double  start,
double  duration,
uint32_t  follow_id,
bool  replay_sensors,
bool  replay_weather = false,
const geom::Transform &  offset = geom::Transform(),
std::string  map_override = "" 
)
inline

Definition at line 158 of file client/Client.h.

References _simulator.

◆ RequestFile()

void carla::client::Client::RequestFile ( const std::string &  name) const
inline

Definition at line 87 of file client/Client.h.

References _simulator.

◆ SetFilesBaseFolder()

bool carla::client::Client::SetFilesBaseFolder ( const std::string &  path)
inline

Definition at line 79 of file client/Client.h.

References _simulator.

◆ SetReplayerIgnoreHero()

void carla::client::Client::SetReplayerIgnoreHero ( bool  ignore_hero)
inline

Definition at line 177 of file client/Client.h.

References _simulator.

◆ SetReplayerIgnoreSpectator()

void carla::client::Client::SetReplayerIgnoreSpectator ( bool  ignore_spectator)
inline

Definition at line 181 of file client/Client.h.

References _simulator.

◆ SetReplayerTimeFactor()

void carla::client::Client::SetReplayerTimeFactor ( double  time_factor)
inline

Definition at line 173 of file client/Client.h.

References _simulator.

◆ SetTimeout()

void carla::client::Client::SetTimeout ( time_duration  timeout)
inline

Set a timeout for networking operations.

If set, any networking operation taking longer than timeout throws rpc::timeout.

Definition at line 37 of file client/Client.h.

References _simulator.

◆ ShowRecorderActorsBlocked()

std::string carla::client::Client::ShowRecorderActorsBlocked ( std::string  name,
double  min_time,
double  min_distance 
)
inline

Definition at line 154 of file client/Client.h.

References _simulator.

◆ ShowRecorderCollisions()

std::string carla::client::Client::ShowRecorderCollisions ( std::string  name,
char  type1,
char  type2 
)
inline

Definition at line 150 of file client/Client.h.

References _simulator.

◆ ShowRecorderFileInfo()

std::string carla::client::Client::ShowRecorderFileInfo ( std::string  name,
bool  show_all 
)
inline

Definition at line 146 of file client/Client.h.

References _simulator.

◆ StartRecorder()

std::string carla::client::Client::StartRecorder ( std::string  name,
bool  additional_data = false,
bool  stop_replayer = true 
)
inline

Definition at line 138 of file client/Client.h.

References _simulator.

◆ StopRecorder()

void carla::client::Client::StopRecorder ( void  )
inline

Definition at line 142 of file client/Client.h.

References _simulator.

◆ StopReplayer()

void carla::client::Client::StopReplayer ( bool  keep_actors)
inline

Definition at line 169 of file client/Client.h.

References _simulator.

◆ UnmountContentPack()

bool carla::client::Client::UnmountContentPack ( const std::string &  name) const
inline

Unmount a content pack by name.

Refused (throws) while a map of the pack is loaded or objects from it are still alive.

Definition at line 75 of file client/Client.h.

References _simulator.

Member Data Documentation

◆ _simulator

std::shared_ptr<detail::Simulator> carla::client::Client::_simulator
private

The documentation for this class was generated from the following file: