Apollo 11.0
自动驾驶开放平台
simulation_world_updater.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
21#pragma once
22
23#include <memory>
24#include <string>
25#include <vector>
26
27#include <boost/thread/locks.hpp>
28#include <boost/thread/shared_mutex.hpp>
29
30#include "absl/strings/str_cat.h"
31
32#include "modules/common_msgs/task_manager_msgs/task_manager.pb.h"
33#include "modules/common_msgs/external_command_msgs/lane_follow_command.pb.h"
34#include "modules/common_msgs/external_command_msgs/valet_parking_command.pb.h"
35#include "modules/common_msgs/external_command_msgs/action_command.pb.h"
36
37#include "cyber/common/log.h"
38#include "cyber/cyber.h"
43#include "modules/common_msgs/localization_msgs/localization.pb.h"
45
50namespace apollo {
51namespace dreamview {
52
60 public:
71 WebSocketHandler *camera_ws,
72 WebSocketHandler *plugin_ws,
73 const MapService *map_service,
74 PerceptionCameraUpdater *perception_camera_updater,
75 PluginManager *plugin_manager,
76 bool routing_from_file = false);
77
81 void Start();
82
83 // Time interval, in milliseconds, between pushing SimulationWorld to
84 // frontend.
85 static constexpr double kSimWorldTimeIntervalMs = 100;
86
87 double LastAdcTimestampSec() { return last_pushed_adc_timestamp_sec_; }
88
89 private:
94 void OnTimer();
95
102 bool ConstructLaneFollowCommand(
103 const nlohmann::json &json,
105
112 bool ConstructValetParkingCommand(
113 const nlohmann::json &json,
114 apollo::external_command::ValetParkingCommand *valet_parking_command);
115
121 nlohmann::json GetConstructRoutingRequestJson(const nlohmann::json &start,
122 const nlohmann::json &end);
123
130 bool ConstructLaneWayPoint(const nlohmann::json &point,
131 apollo::routing::LaneWaypoint *laneWayPoint,
132 std::string description);
138 bool isProcessRunning(const std::string &process_name);
139
140 bool ValidateCoordinate(const nlohmann::json &json);
141
147 nlohmann::json CheckRoutingPoint(const nlohmann::json &json);
148
155 bool LoadPOI();
161 nlohmann::json GetPointJsonFromLaneWaypoint(
162 const apollo::routing::LaneWaypoint &waypoint);
163
169 bool LoadUserDefinedRoutings(const std::string &file_name,
170 google::protobuf::Message *message);
171
178 bool AddDefaultRouting(const nlohmann::json &json);
179
180 void RegisterMessageHandlers();
181
182 SimulationWorldService sim_world_service_;
183 const MapService *map_service_ = nullptr;
184 WebSocketHandler *websocket_ = nullptr;
185 WebSocketHandler *map_ws_ = nullptr;
186 WebSocketHandler *camera_ws_ = nullptr;
187 WebSocketHandler *plugin_ws_ = nullptr;
188 PerceptionCameraUpdater *perception_camera_updater_ = nullptr;
189
190 // End point for requesting default route
192
193 // default routings
194 apollo::routing::POI default_routings_;
195 apollo::routing::Landmark *default_routing_;
196
197 // park and go
198 apollo::routing::POI park_go_routings_;
199
200 // The simulation_world in wire format to be pushed to frontend, which is
201 // updated by timer.
202 std::string simulation_world_;
203 std::string simulation_world_with_planning_data_;
204
205 // Received relative map data in wire format.
206 std::string relative_map_string_;
207
208 // Mutex to protect concurrent access to simulation_world_json_.
209 // NOTE: Use boost until we have std version of rwlock support.
210 boost::shared_mutex mutex_;
211
212 std::unique_ptr<cyber::Timer> timer_;
213
214 volatile double last_pushed_adc_timestamp_sec_ = 0.0f;
215
216 std::unique_ptr<PluginManager> plugin_manager_;
217
218 uint64_t command_id_;
219};
220
221} // namespace dreamview
222} // namespace apollo
This is a major component of the Simulation backend, which maintains a SimulationWorld object and kee...
A wrapper around SimulationWorldService and WebSocketHandler to keep pushing SimulationWorld to front...
void Start()
Starts to push simulation_world to frontend.
The WebSocketHandler, built on top of CivetWebSocketHandler, is a websocket handler that handles diff...
class register implement
Definition arena_queue.h:37