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

Holds the current episode, and the current episode state. More...

#include <Episode.h>

+ Inheritance diagram for carla::client::detail::Episode:

Public Member Functions

void AddPendingException (std::string e)
 
std::shared_ptr< WalkerNavigation > CreateNavigationIfMissing ()
 
 Episode (Client &client, std::weak_ptr< Simulator > simulator)
 
std::optional< rpc::Actor > GetActorById (ActorId id)
 
std::vector< rpc::Actor > GetActors ()
 
std::vector< rpc::Actor > GetActorsById (const std::vector< ActorId > &actor_ids)
 
auto GetId () const
 
std::shared_ptr< const EpisodeState > GetState () const
 
bool HasMapChangedSinceLastCall ()
 
bool IsEpisodeChangeHandled () const
 Whether OnEpisodeChanged has finished for the episode GetId() returns.
 
void Listen ()
 
void RegisterActor (rpc::Actor actor)
 
size_t RegisterLightUpdateChangeEvent (std::function< void(WorldSnapshot)> callback)
 
size_t RegisterOnMapChangeEvent (std::function< void(WorldSnapshot)> callback)
 
size_t RegisterOnTickEvent (std::function< void(WorldSnapshot)> callback)
 
void RemoveLightUpdateChangeEvent (size_t id)
 
void RemoveOnMapChangeEvent (size_t id)
 
void RemoveOnTickEvent (size_t id)
 
void SetPedestriansCrossFactor (float percentage)
 
void SetPedestriansSeed (unsigned int seed)
 
std::optional< WorldSnapshot > WaitForState (time_duration timeout)
 
 ~Episode ()
 

Private Member Functions

 Episode (Client &client, const rpc::EpisodeInfo &info, std::weak_ptr< Simulator > simulator)
 
void OnEpisodeChanged (uint64_t episode_id)
 
void OnEpisodeStarted ()
 
- Private Member Functions inherited from carla::NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
 NonCopyable (NonCopyable &&)=delete
 
NonCopyable & operator= (const NonCopyable &)=delete
 
NonCopyable & operator= (NonCopyable &&)=delete
 

Private Attributes

CachedActorList _actors
 
Client & _client
 
std::atomic< uint64_t > _handled_episode_id
 
CallbackList< WorldSnapshot > _on_light_update_callbacks
 
CallbackList< WorldSnapshot > _on_map_change_callbacks
 
CallbackList< WorldSnapshot > _on_tick_callbacks
 
bool _pending_exceptions = false
 
std::string _pending_exceptions_msg
 
bool _should_update_map = true
 
std::weak_ptr< Simulator > _simulator
 
RecurrentSharedFuture< WorldSnapshot > _snapshot
 
AtomicSharedPtr< const EpisodeState > _state
 
std::thread _tm_reset_thread
 
const streaming::Token _token
 
AtomicSharedPtr< WalkerNavigation > _walker_navigation
 

Detailed Description

Holds the current episode, and the current episode state.

The episode state changes in the background each time a world tick is received. The episode may change with any background update if the simulator has loaded a new episode.

Definition at line 36 of file Episode.h.

Constructor & Destructor Documentation

◆ Episode() [1/2]

carla::client::detail::Episode::Episode ( Client &  client,
std::weak_ptr< Simulator >  simulator 
)
explicit

Definition at line 39 of file Episode.cpp.

◆ ~Episode()

carla::client::detail::Episode::~Episode ( )

◆ Episode() [2/2]

carla::client::detail::Episode::Episode ( Client &  client,
const rpc::EpisodeInfo &  info,
std::weak_ptr< Simulator >  simulator 
)
private

Definition at line 42 of file Episode.cpp.

Member Function Documentation

◆ AddPendingException()

void carla::client::detail::Episode::AddPendingException ( std::string  e)
inline

Definition at line 102 of file Episode.h.

References _pending_exceptions, and _pending_exceptions_msg.

◆ CreateNavigationIfMissing()

std::shared_ptr< WalkerNavigation > carla::client::detail::Episode::CreateNavigationIfMissing ( )

◆ GetActorById()

std::optional< rpc::Actor > carla::client::detail::Episode::GetActorById ( ActorId  id)

◆ GetActors()

std::vector< rpc::Actor > carla::client::detail::Episode::GetActors ( )

Definition at line 156 of file Episode.cpp.

References _actors, _client, carla::client::detail::GetActorsById_Impl(), and GetState().

◆ GetActorsById()

std::vector< rpc::Actor > carla::client::detail::Episode::GetActorsById ( const std::vector< ActorId > &  actor_ids)

Definition at line 152 of file Episode.cpp.

References _actors, _client, and carla::client::detail::GetActorsById_Impl().

◆ GetId()

auto carla::client::detail::Episode::GetId ( ) const
inline

Definition at line 47 of file Episode.h.

References GetState().

Referenced by IsEpisodeChangeHandled().

◆ GetState()

std::shared_ptr< const EpisodeState > carla::client::detail::Episode::GetState ( ) const
inline

Definition at line 56 of file Episode.h.

References _state.

Referenced by GetActors(), GetId(), and carla::client::detail::SynchronizeFrame().

◆ HasMapChangedSinceLastCall()

bool carla::client::detail::Episode::HasMapChangedSinceLastCall ( )

Definition at line 182 of file Episode.cpp.

References _should_update_map.

◆ IsEpisodeChangeHandled()

bool carla::client::detail::Episode::IsEpisodeChangeHandled ( ) const
inline

Whether OnEpisodeChanged has finished for the episode GetId() returns.

Definition at line 52 of file Episode.h.

References _handled_episode_id, and GetId().

◆ Listen()

void carla::client::detail::Episode::Listen ( )

Check for pending exceptions (Mainly TM server closed)

Mark pending exception false

Create exception for the error message

Sensor case: inconsistent data

Episode change

Definition at line 60 of file Episode.cpp.

References _client, _token, carla::client::detail::CastData(), carla::sensor::Deserializer::Deserialize(), carla::log_error(), and carla::client::detail::Client::SubscribeToStream().

◆ OnEpisodeChanged()

void carla::client::detail::Episode::OnEpisodeChanged ( uint64_t  episode_id)
private

◆ OnEpisodeStarted()

void carla::client::detail::Episode::OnEpisodeStarted ( )
private

◆ RegisterActor()

void carla::client::detail::Episode::RegisterActor ( rpc::Actor  actor)
inline

Definition at line 60 of file Episode.h.

References _actors, and carla::client::detail::CachedActorList::Insert().

◆ RegisterLightUpdateChangeEvent()

size_t carla::client::detail::Episode::RegisterLightUpdateChangeEvent ( std::function< void(WorldSnapshot)>  callback)
inline

Definition at line 90 of file Episode.h.

References _on_light_update_callbacks.

◆ RegisterOnMapChangeEvent()

size_t carla::client::detail::Episode::RegisterOnMapChangeEvent ( std::function< void(WorldSnapshot)>  callback)
inline

Definition at line 82 of file Episode.h.

References _on_map_change_callbacks.

◆ RegisterOnTickEvent()

size_t carla::client::detail::Episode::RegisterOnTickEvent ( std::function< void(WorldSnapshot)>  callback)
inline

Definition at line 74 of file Episode.h.

References _on_tick_callbacks.

◆ RemoveLightUpdateChangeEvent()

void carla::client::detail::Episode::RemoveLightUpdateChangeEvent ( size_t  id)
inline

Definition at line 94 of file Episode.h.

References _on_light_update_callbacks.

◆ RemoveOnMapChangeEvent()

void carla::client::detail::Episode::RemoveOnMapChangeEvent ( size_t  id)
inline

Definition at line 86 of file Episode.h.

References _on_map_change_callbacks.

◆ RemoveOnTickEvent()

void carla::client::detail::Episode::RemoveOnTickEvent ( size_t  id)
inline

Definition at line 78 of file Episode.h.

References _on_tick_callbacks.

◆ SetPedestriansCrossFactor()

void carla::client::detail::Episode::SetPedestriansCrossFactor ( float  percentage)

◆ SetPedestriansSeed()

void carla::client::detail::Episode::SetPedestriansSeed ( unsigned int  seed)

◆ WaitForState()

std::optional< WorldSnapshot > carla::client::detail::Episode::WaitForState ( time_duration  timeout)
inline

Definition at line 70 of file Episode.h.

References _snapshot.

Member Data Documentation

◆ _actors

CachedActorList carla::client::detail::Episode::_actors
private

Definition at line 125 of file Episode.h.

Referenced by GetActorById(), GetActors(), GetActorsById(), OnEpisodeStarted(), and RegisterActor().

◆ _client

Client& carla::client::detail::Episode::_client
private

◆ _handled_episode_id

std::atomic<uint64_t> carla::client::detail::Episode::_handled_episode_id
private

Definition at line 145 of file Episode.h.

Referenced by IsEpisodeChangeHandled(), and OnEpisodeChanged().

◆ _on_light_update_callbacks

CallbackList<WorldSnapshot> carla::client::detail::Episode::_on_light_update_callbacks
private

Definition at line 131 of file Episode.h.

Referenced by RegisterLightUpdateChangeEvent(), and RemoveLightUpdateChangeEvent().

◆ _on_map_change_callbacks

CallbackList<WorldSnapshot> carla::client::detail::Episode::_on_map_change_callbacks
private

Definition at line 129 of file Episode.h.

Referenced by RegisterOnMapChangeEvent(), and RemoveOnMapChangeEvent().

◆ _on_tick_callbacks

CallbackList<WorldSnapshot> carla::client::detail::Episode::_on_tick_callbacks
private

Definition at line 127 of file Episode.h.

Referenced by OnEpisodeStarted(), RegisterOnTickEvent(), and RemoveOnTickEvent().

◆ _pending_exceptions

bool carla::client::detail::Episode::_pending_exceptions = false
private

Definition at line 139 of file Episode.h.

Referenced by AddPendingException().

◆ _pending_exceptions_msg

std::string carla::client::detail::Episode::_pending_exceptions_msg
private

Definition at line 123 of file Episode.h.

Referenced by AddPendingException().

◆ _should_update_map

bool carla::client::detail::Episode::_should_update_map = true
private

Definition at line 141 of file Episode.h.

Referenced by HasMapChangedSinceLastCall().

◆ _simulator

std::weak_ptr<Simulator> carla::client::detail::Episode::_simulator
private

Definition at line 143 of file Episode.h.

Referenced by CreateNavigationIfMissing().

◆ _snapshot

RecurrentSharedFuture<WorldSnapshot> carla::client::detail::Episode::_snapshot
private

Definition at line 133 of file Episode.h.

Referenced by WaitForState().

◆ _state

AtomicSharedPtr<const EpisodeState> carla::client::detail::Episode::_state
private

Definition at line 121 of file Episode.h.

Referenced by GetState().

◆ _tm_reset_thread

std::thread carla::client::detail::Episode::_tm_reset_thread
private

Definition at line 147 of file Episode.h.

Referenced by OnEpisodeChanged(), and ~Episode().

◆ _token

const streaming::Token carla::client::detail::Episode::_token
private

Definition at line 137 of file Episode.h.

Referenced by Listen(), and ~Episode().

◆ _walker_navigation

AtomicSharedPtr<WalkerNavigation> carla::client::detail::Episode::_walker_navigation
private

Definition at line 135 of file Episode.h.

Referenced by CreateNavigationIfMissing(), and OnEpisodeStarted().


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