CARLA
primaryCommands.h
Go to the documentation of this file.
1 // Copyright (c) 2022 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 "carla/Logging.h"
11 #include "carla/multigpu/primary.h"
15 
16 namespace carla {
17 namespace multigpu {
18 
19 // using session = std::shared_ptr<Primary>;
20 // using callback_response = std::function<void(std::shared_ptr<Primary>, carla::Buffer)>;
23 
24 class Router;
25 
27  public:
28 
29 
31  PrimaryCommands(std::shared_ptr<Router> router);
32 
33  void set_router(std::shared_ptr<Router> router);
34 
35  // broadcast to all secondary servers the frame data
36  void SendFrameData(carla::Buffer buffer);
37 
38  // broadcast to all secondary servers the map to load
39  void SendLoadMap(std::string map);
40 
41  // send to know if a connection is alive
42  void SendIsAlive();
43 
44  token_type GetToken(stream_id sensor_id);
45 
46  void EnableForROS(stream_id sensor_id);
47 
48  void DisableForROS(stream_id sensor_id);
49 
50  bool IsEnabledForROS(stream_id sensor_id);
51 
52  private:
53 
54  // send to one secondary to get the token of a sensor
56 
57  // manage ROS enable/disable of sensor
58  void SendEnableForROS(stream_id sensor_id);
59  void SendDisableForROS(stream_id sensor_id);
60  bool SendIsEnabledForROS(stream_id sensor_id);
61 
62 
63  std::shared_ptr<Router> _router;
64  std::unordered_map<stream_id, token_type> _tokens;
65  std::unordered_map<stream_id, std::weak_ptr<Primary>> _servers;
66 };
67 
68 } // namespace multigpu
69 } // namespace carla
void DisableForROS(stream_id sensor_id)
std::unordered_map< stream_id, std::weak_ptr< Primary > > _servers
token_type SendGetToken(carla::streaming::detail::stream_id_type sensor_id)
void SendLoadMap(std::string map)
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
std::unordered_map< stream_id, token_type > _tokens
void SendEnableForROS(stream_id sensor_id)
uint32_t stream_id_type
Definition: Types.h:18
Serializes a stream endpoint.
Definition: detail/Token.h:61
carla::streaming::detail::stream_id_type stream_id
void EnableForROS(stream_id sensor_id)
token_type GetToken(stream_id sensor_id)
std::shared_ptr< Router > _router
bool IsEnabledForROS(stream_id sensor_id)
void SendFrameData(carla::Buffer buffer)
A piece of raw data.
Definition: carla/Buffer.h:42
void SendDisableForROS(stream_id sensor_id)
bool SendIsEnabledForROS(stream_id sensor_id)
carla::streaming::detail::token_type token_type
void set_router(std::shared_ptr< Router > router)