Apollo 11.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.h 第 59 行定义.

构造及析构函数说明

◆ 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.cc 第 56 行定义.

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.cc 第 57 行定义.

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.h 第 87 行定义.

87{ return last_pushed_adc_timestamp_sec_; }

◆ LastAdcTimestampSec() [2/2]

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

在文件 simulation_world_updater.h 第 91 行定义.

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.cc 第 1142 行定义.

1142 {
1143 if (!sim_world_service_.ReadyToPush()) {
1145 return;
1146 }
1147 std::string to_send;
1148 {
1149 boost::shared_lock<boost::shared_mutex> writer_lock(mutex_);
1150 to_send = simulation_world_with_planning_data_;
1151 }
1152 StreamData stream_data;
1153 std::string stream_data_string;
1154 stream_data.set_action("stream");
1155 stream_data.set_data_name("simworld");
1156 std::vector<uint8_t> byte_data(to_send.begin(), to_send.end());
1157 stream_data.set_data(&(byte_data[0]), byte_data.size());
1158 stream_data.set_type("simworld");
1159 stream_data.SerializeToString(&stream_data_string);
1160 sim_world_ws_->BroadcastBinaryData(stream_data_string);
1161}
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.cc 第 709 行定义.

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.cc 第 1106 行定义.

1108 {
1109 AINFO << "Start SimulationWorld updater with data sending frequency: "
1110 << time_interval_ms;
1111 time_interval_ms_ = time_interval_ms;
1112 if (time_interval_ms_ > 0) {
1113 timer_.reset(new cyber::Timer(
1114 time_interval_ms, [this]() { this->OnTimer(); }, false));
1115 timer_->Start();
1116 } else {
1117 this->OnTimer();
1118 }
1119}
#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.cc 第 1121 行定义.

1121 {
1122 AINFO << "SimulationWorld updater has been stopped";
1123 if (timer_) {
1124 timer_->Stop();
1125 }
1126}

类成员变量说明

◆ kSimWorldTimeIntervalMs

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

在文件 simulation_world_updater.h 第 85 行定义.

◆ time_interval_ms_

double apollo::dreamview::SimulationWorldUpdater::time_interval_ms_

在文件 simulation_world_updater.h 第 89 行定义.


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