Apollo 10.0
自动驾驶开放平台
apollo::dreamview::SimulationWorldUpdater类 参考

A wrapper around SimulationWorldService and WebSocketHandler to keep pushing SimulationWorld to frontend via websocket while handling the response from frontend. 更多...

#include <simulation_world_updater.h>

类 apollo::dreamview::SimulationWorldUpdater 继承关系图:
apollo::dreamview::SimulationWorldUpdater 的协作图:

Public 成员函数

 SimulationWorldUpdater (WebSocketHandler *websocket, WebSocketHandler *map_ws, WebSocketHandler *camera_ws, WebSocketHandler *plugin_ws, const MapService *map_service, PerceptionCameraUpdater *perception_camera_updater, PluginManager *plugin_manager, bool routing_from_file=false)
 Constructor with the websocket handler.
 
void Start ()
 Starts to push simulation_world to frontend.
 
double LastAdcTimestampSec ()
 
 SimulationWorldUpdater (WebSocketHandler *websocket, WebSocketHandler *map_ws, WebSocketHandler *plugin_ws, const MapService *map_service, PluginManager *plugin_manager, WebSocketHandler *sim_world_ws, HMI *hmi, bool routing_from_file=false)
 Constructor with the websocket handler.
 
void StartStream (const double &time_interval_ms, const std::string &channel_name="", nlohmann::json *subscribe_param=nullptr) override
 Starts to push simulation_world to frontend.
 
void StopStream (const std::string &channel_name="") override
 Stop data flow.
 
void PublishMessage (const std::string &channel_name="") override
 Publish Message to dreamview frontend.
 
double LastAdcTimestampSec ()
 
- Public 成员函数 继承自 apollo::dreamview::UpdaterBase
 UpdaterBase ()
 Updaterbase
 
virtual ~UpdaterBase ()
 

Public 属性

double time_interval_ms_
 

静态 Public 属性

static constexpr double kSimWorldTimeIntervalMs = 100
 

详细描述

A wrapper around SimulationWorldService and WebSocketHandler to keep pushing SimulationWorld to frontend via websocket while handling the response from frontend.

在文件 simulation_world_updater.h59 行定义.

构造及析构函数说明

◆ SimulationWorldUpdater() [1/2]

apollo::dreamview::SimulationWorldUpdater::SimulationWorldUpdater ( WebSocketHandler websocket,
WebSocketHandler map_ws,
WebSocketHandler camera_ws,
WebSocketHandler plugin_ws,
const MapService map_service,
PerceptionCameraUpdater perception_camera_updater,
PluginManager plugin_manager,
bool  routing_from_file = false 
)

Constructor with the websocket handler.

参数
websocketPointer of the websocket handler that has been attached to the server.
sim_controlPointer of sim control.
map_servicePointer of the map service to provide a high-level API of hdmap.
routing_from_filewhether to read initial routing from file.

在文件 simulation_world_updater.cc56 行定义.

62 : sim_world_service_(map_service, routing_from_file),
63 map_service_(map_service),
64 websocket_(websocket),
65 map_ws_(map_ws),
66 camera_ws_(camera_ws),
67 plugin_ws_(plugin_ws),
68 perception_camera_updater_(perception_camera_updater),
69 plugin_manager_(plugin_manager),
70 command_id_(0) {
71 RegisterMessageHandlers();
72}

◆ SimulationWorldUpdater() [2/2]

apollo::dreamview::SimulationWorldUpdater::SimulationWorldUpdater ( WebSocketHandler websocket,
WebSocketHandler map_ws,
WebSocketHandler plugin_ws,
const MapService map_service,
PluginManager plugin_manager,
WebSocketHandler sim_world_ws,
HMI hmi,
bool  routing_from_file = false 
)

Constructor with the websocket handler.

参数
websocketPointer of the websocket handler that has been attached to the server.
sim_controlPointer of sim control.
map_servicePointer of the map service to provide a high-level API of hdmap.
routing_from_filewhether to read initial routing from file.

在文件 simulation_world_updater.cc57 行定义.

62 : sim_world_service_(map_service, routing_from_file),
63 map_service_(map_service),
64 websocket_(websocket),
65 map_ws_(map_ws),
66 plugin_ws_(plugin_ws),
67 // perception_camera_updater_(perception_camera_updater),
68 plugin_manager_(plugin_manager),
69 sim_world_ws_(sim_world_ws),
70 hmi_(hmi),
71 command_id_(0) {
72 RegisterRoutingMessageHandlers();
73 RegisterMessageHandlers();
74}

成员函数说明

◆ LastAdcTimestampSec() [1/2]

double apollo::dreamview::SimulationWorldUpdater::LastAdcTimestampSec ( )
inline

在文件 simulation_world_updater.h87 行定义.

87{ return last_pushed_adc_timestamp_sec_; }

◆ LastAdcTimestampSec() [2/2]

double apollo::dreamview::SimulationWorldUpdater::LastAdcTimestampSec ( )
inline

在文件 simulation_world_updater.h91 行定义.

91{ return last_pushed_adc_timestamp_sec_; }

◆ PublishMessage()

void apollo::dreamview::SimulationWorldUpdater::PublishMessage ( const std::string &  channel_name = "")
overridevirtual

Publish Message to dreamview frontend.

实现了 apollo::dreamview::UpdaterBase.

在文件 simulation_world_updater.cc1117 行定义.

1117 {
1118 if (!sim_world_service_.ReadyToPush()) {
1120 return;
1121 }
1122 std::string to_send;
1123 {
1124 boost::shared_lock<boost::shared_mutex> writer_lock(mutex_);
1125 to_send = simulation_world_with_planning_data_;
1126 }
1127 StreamData stream_data;
1128 std::string stream_data_string;
1129 stream_data.set_action("stream");
1130 stream_data.set_data_name("simworld");
1131 std::vector<uint8_t> byte_data(to_send.begin(), to_send.end());
1132 stream_data.set_data(&(byte_data[0]), byte_data.size());
1133 stream_data.set_type("simworld");
1134 stream_data.SerializeToString(&stream_data_string);
1135 sim_world_ws_->BroadcastBinaryData(stream_data_string);
1136}
bool ReadyToPush() const
Check whether the SimulationWorld object has enough information.
bool BroadcastBinaryData(const std::string &data, bool skippable=false)
Sends the provided binary data to all the connected clients.
#define AWARN_EVERY(freq)
Definition log.h:84

◆ Start()

void apollo::dreamview::SimulationWorldUpdater::Start ( )

Starts to push simulation_world to frontend.

在文件 simulation_world_updater.cc709 行定义.

709 {
710 timer_.reset(new cyber::Timer(
711 kSimWorldTimeIntervalMs, [this]() { this->OnTimer(); }, false));
712 timer_->Start();
713}

◆ StartStream()

void apollo::dreamview::SimulationWorldUpdater::StartStream ( const double &  time_interval_ms,
const std::string &  channel_name = "",
nlohmann::json *  subscribe_param = nullptr 
)
overridevirtual

Starts to push simulation_world to frontend.

实现了 apollo::dreamview::UpdaterBase.

在文件 simulation_world_updater.cc1081 行定义.

1083 {
1084 AINFO << "Start SimulationWorld updater with data sending frequency: "
1085 << time_interval_ms;
1086 time_interval_ms_ = time_interval_ms;
1087 if (time_interval_ms_ > 0) {
1088 timer_.reset(new cyber::Timer(
1089 time_interval_ms, [this]() { this->OnTimer(); }, false));
1090 timer_->Start();
1091 } else {
1092 this->OnTimer();
1093 }
1094}
#define AINFO
Definition log.h:42

◆ StopStream()

void apollo::dreamview::SimulationWorldUpdater::StopStream ( const std::string &  channel_name = "")
overridevirtual

Stop data flow.

实现了 apollo::dreamview::UpdaterBase.

在文件 simulation_world_updater.cc1096 行定义.

1096 {
1097 AINFO << "SimulationWorld updater has been stopped";
1098 if (timer_) {
1099 timer_->Stop();
1100 }
1101}

类成员变量说明

◆ kSimWorldTimeIntervalMs

constexpr double apollo::dreamview::SimulationWorldUpdater::kSimWorldTimeIntervalMs = 100
staticconstexpr

在文件 simulation_world_updater.h85 行定义.

◆ time_interval_ms_

double apollo::dreamview::SimulationWorldUpdater::time_interval_ms_

在文件 simulation_world_updater.h89 行定义.


该类的文档由以下文件生成: