|
CARLA
|
#include <primaryCommands.h>
Classes | |
| struct | Route |
Public Member Functions | |
| void | DisableForROS (stream_id sensor_id) |
| bool | EnableForROS (stream_id sensor_id, actor_id sensor_actor_id) |
| Returns false if no secondary accepted this sensor or the secondary holding it did not reply; ROS enablement has not happened in that case. | |
| void | ForgetSensor (stream_id sensor_id) |
| Drops the routing of a destroyed sensor so it is never routed again. | |
| std::optional< token_type > | GetToken (stream_id sensor_id, actor_id sensor_actor_id) |
| Returns std::nullopt if no secondary could provide the token (e.g. | |
| bool | IsEnabledForROS (stream_id sensor_id) |
| PrimaryCommands () | |
| PrimaryCommands (std::shared_ptr< Router > router) | |
| std::size_t | RerouteLostSensors () |
| Routes every sensor whose secondary disconnected to the secondaries connected since the previous call, under the same primary stream id, so clients already subscribed reconnect to it without a new listen(). | |
| void | SendFrameData (carla::Buffer buffer) |
| void | SendIsAlive () |
| void | SendLoadMap (std::string map, const LoadMapExtras &extras={}) |
| void | set_router (std::shared_ptr< Router > router) |
Private Types | |
| enum class | TokenError { None , NoReply , Refused } |
Private Member Functions | |
| bool | IsRoutedToLiveSecondary (stream_id sensor_id) |
| Whether sensor_id is routed to a secondary that is still connected. | |
| void | RestoreRosAfterReroute (stream_id sensor_id) |
| Enables ROS again on the new secondary of a re-routed sensor if it was enabled before. | |
| void | SendDisableForROS (stream_id sensor_id) |
| bool | SendEnableForROS (stream_id sensor_id) |
| std::optional< token_type > | SendGetToken (stream_id sensor_id, actor_id sensor_actor_id, const std::weak_ptr< Primary > *target, std::weak_ptr< Primary > &out_session, TokenError &error) |
| bool | SendIsEnabledForROS (stream_id sensor_id) |
Static Private Member Functions | |
| static bool | ReadBoolReply (const carla::Buffer &buffer) |
| Reads a one-bool reply; buffer must not be empty. | |
Private Attributes | |
| std::mutex | _mutex |
| std::shared_ptr< Router > | _router |
| std::unordered_map< stream_id, Route > | _servers |
| std::unordered_map< stream_id, token_type > | _tokens |
Definition at line 32 of file primaryCommands.h.
|
strongprivate |
| Enumerator | |
|---|---|
| None | |
| NoReply | |
| Refused | |
Definition at line 90 of file primaryCommands.h.
| carla::multigpu::PrimaryCommands::PrimaryCommands | ( | ) |
Definition at line 25 of file primaryCommands.cpp.
| carla::multigpu::PrimaryCommands::PrimaryCommands | ( | std::shared_ptr< Router > | router | ) |
Definition at line 28 of file primaryCommands.cpp.
| void carla::multigpu::PrimaryCommands::DisableForROS | ( | stream_id | sensor_id | ) |
Definition at line 235 of file primaryCommands.cpp.
References _mutex, _router, _servers, and SendDisableForROS().
| bool carla::multigpu::PrimaryCommands::EnableForROS | ( | stream_id | sensor_id, |
| actor_id | sensor_actor_id | ||
| ) |
Returns false if no secondary accepted this sensor or the secondary holding it did not reply; ROS enablement has not happened in that case.
Definition at line 213 of file primaryCommands.cpp.
References _mutex, _servers, EnableForROS(), GetToken(), IsRoutedToLiveSecondary(), carla::log_error(), and SendEnableForROS().
Referenced by EnableForROS(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
| void carla::multigpu::PrimaryCommands::ForgetSensor | ( | stream_id | sensor_id | ) |
| std::optional< token_type > carla::multigpu::PrimaryCommands::GetToken | ( | stream_id | sensor_id, |
| actor_id | sensor_actor_id | ||
| ) |
Returns std::nullopt if no secondary could provide the token (e.g.
the selected secondary disconnected with the request in flight, or has no episode loaded). Nothing is cached on failure, so a later call for the same sensor retries. A sensor whose secondary disconnected is routed again here. sensor_actor_id is the primary's id of the sensor actor, which the secondary resolves to its own sensor stream.
Definition at line 175 of file primaryCommands.cpp.
References _mutex, _servers, _tokens, first, IsRoutedToLiveSecondary(), carla::log_debug(), carla::log_warning(), None, Refused, RestoreRosAfterReroute(), and SendGetToken().
Referenced by EnableForROS(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
| bool carla::multigpu::PrimaryCommands::IsEnabledForROS | ( | stream_id | sensor_id | ) |
Definition at line 247 of file primaryCommands.cpp.
References _mutex, IsRoutedToLiveSecondary(), and SendIsEnabledForROS().
|
private |
Whether sensor_id is routed to a secondary that is still connected.
Caller must hold _mutex.
Definition at line 306 of file primaryCommands.cpp.
References _router, and _servers.
Referenced by EnableForROS(), GetToken(), and IsEnabledForROS().
|
staticprivate |
Reads a one-bool reply; buffer must not be empty.
Definition at line 321 of file primaryCommands.cpp.
References carla::Buffer::data().
Referenced by SendDisableForROS(), SendEnableForROS(), and SendIsEnabledForROS().
| std::size_t carla::multigpu::PrimaryCommands::RerouteLostSensors | ( | ) |
Routes every sensor whose secondary disconnected to the secondaries connected since the previous call, under the same primary stream id, so clients already subscribed reconnect to it without a new listen().
The first new secondary that stays connected takes every lost sensor. A sensor the new secondary refuses is forgotten and routed lazily later; if it disconnects instead, the sensor stays lost for the next one. ROS publishing enabled through EnableForROS() is enabled again. Blocks on round trips; never call it from a Router callback. Returns how many sensors were routed again.
Definition at line 255 of file primaryCommands.cpp.
References _mutex, _router, _servers, _tokens, carla::log_info(), carla::log_warning(), None, NoReply, RestoreRosAfterReroute(), and SendGetToken().
Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
|
private |
Enables ROS again on the new secondary of a re-routed sensor if it was enabled before.
Caller must hold _mutex.
Definition at line 311 of file primaryCommands.cpp.
References _servers, carla::log_warning(), and SendEnableForROS().
Referenced by GetToken(), and RerouteLostSensors().
|
private |
Definition at line 136 of file primaryCommands.cpp.
References _router, _servers, carla::multigpu::DISABLE_ROS, carla::log_error(), and ReadBoolReply().
Referenced by DisableForROS().
|
private |
Definition at line 112 of file primaryCommands.cpp.
References _router, _servers, carla::multigpu::ENABLE_ROS, carla::log_error(), and ReadBoolReply().
Referenced by EnableForROS(), and RestoreRosAfterReroute().
| void carla::multigpu::PrimaryCommands::SendFrameData | ( | carla::Buffer | buffer | ) |
Definition at line 37 of file primaryCommands.cpp.
References _router, and carla::multigpu::SEND_FRAME.
|
private |
Definition at line 53 of file primaryCommands.cpp.
References _router, carla::streaming::detail::token_type::get_port(), carla::streaming::detail::token_type::get_stream_id(), carla::multigpu::GET_TOKEN, carla::multigpu::kTokenNotReadyMarker, carla::log_error(), carla::log_info(), carla::log_warning(), None, NoReply, Refused, and carla::streaming::detail::token_type::set_stream_id().
Referenced by GetToken(), and RerouteLostSensors().
| void carla::multigpu::PrimaryCommands::SendIsAlive | ( | ) |
Definition at line 98 of file primaryCommands.cpp.
References _mutex, _router, carla::log_error(), carla::log_info(), and carla::multigpu::YOU_ALIVE.
|
private |
Definition at line 155 of file primaryCommands.cpp.
References _router, _servers, carla::multigpu::IS_ENABLED_ROS, carla::log_error(), and ReadBoolReply().
Referenced by IsEnabledForROS().
| void carla::multigpu::PrimaryCommands::SendLoadMap | ( | std::string | map, |
| const LoadMapExtras & | extras = {} |
||
| ) |
| void carla::multigpu::PrimaryCommands::set_router | ( | std::shared_ptr< Router > | router | ) |
Definition at line 32 of file primaryCommands.cpp.
References _router.
Referenced by carla::multigpu::Router::SetCallbacks(), and TEST().
|
private |
Definition at line 130 of file primaryCommands.h.
Referenced by DisableForROS(), EnableForROS(), ForgetSensor(), GetToken(), IsEnabledForROS(), RerouteLostSensors(), SendIsAlive(), and SendLoadMap().
|
private |
Definition at line 120 of file primaryCommands.h.
Referenced by DisableForROS(), IsRoutedToLiveSecondary(), RerouteLostSensors(), SendDisableForROS(), SendEnableForROS(), SendFrameData(), SendGetToken(), SendIsAlive(), SendIsEnabledForROS(), SendLoadMap(), and set_router().
Definition at line 124 of file primaryCommands.h.
Referenced by DisableForROS(), EnableForROS(), ForgetSensor(), GetToken(), IsRoutedToLiveSecondary(), RerouteLostSensors(), RestoreRosAfterReroute(), SendDisableForROS(), SendEnableForROS(), SendIsEnabledForROS(), and SendLoadMap().
|
private |
Definition at line 121 of file primaryCommands.h.
Referenced by ForgetSensor(), GetToken(), RerouteLostSensors(), and SendLoadMap().