Skip to content

Commit 0566886

Browse files
committed
fix(dreamview): fix compilation issues
Signed-off-by: Pride Leong <[email protected]>
1 parent b62c3f3 commit 0566886

File tree

7 files changed

+82
-40
lines changed

7 files changed

+82
-40
lines changed

modules/common/adapters/adapter_gflags.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,6 @@ DEFINE_string(lidar_model_version, "",
270270

271271
DEFINE_string(collision_warning_topic, "/apollo/perception/collision_warning",
272272
"Collision warning topic.");
273+
274+
DEFINE_string(mission_request_topic, "/apollo/mission_request",
275+
"mission request topic name");

modules/common/adapters/adapter_gflags.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,5 @@ DECLARE_string(latency_reporting_topic);
145145
DECLARE_string(lidar_model_version);
146146

147147
DECLARE_string(collision_warning_topic);
148+
149+
DECLARE_string(mission_request_topic);

modules/common_msgs/mission_msgs/mission_request.proto

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ package apollo.mission;
55
import "modules/common_msgs/basic_msgs/header.proto";
66
import "modules/common_msgs/basic_msgs/geometry.proto";
77

8-
// Mission parameters: Used to inject data into the Behavior Tree (BT) Blackboard
8+
// Mission parameters: Used to inject data into the Behavior Tree (BT)
9+
// Blackboard
910
message MissionParam {
1011
// Parameter key, e.g., "duration", "target_name"
1112
optional string key = 1;
@@ -14,8 +15,8 @@ message MissionParam {
1415
oneof value {
1516
string string_value = 2;
1617
double double_value = 3;
17-
bool bool_value = 4;
18-
int32 int_value = 5;
18+
bool bool_value = 4;
19+
int32 int_value = 5;
1920
}
2021
}
2122

@@ -39,7 +40,9 @@ message MissionRequest {
3940

4041
optional string task_name = 3;
4142

42-
repeated MissionParam parameters = 4;
43+
optional bool enable_loop = 4;
4344

44-
repeated MissionWaypoint waypoints = 5;
45+
repeated MissionParam parameters = 5;
46+
47+
repeated MissionWaypoint waypoints = 6;
4548
}

modules/dreamview/backend/simulation_world/BUILD

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,30 @@ cc_library(
1212
copts = DREAMVIEW_COPTS,
1313
deps = [
1414
"//cyber",
15-
"//modules/common_msgs/audio_msgs:audio_cc_proto",
16-
"//modules/common_msgs/audio_msgs:audio_event_cc_proto",
17-
"//modules/common_msgs/chassis_msgs:chassis_cc_proto",
1815
"//modules/common/adapters:adapter_gflags",
1916
"//modules/common/configs:vehicle_config_helper",
2017
"//modules/common/math",
2118
"//modules/common/monitor_log",
22-
"//modules/common_msgs/basic_msgs:drive_event_cc_proto",
23-
"//modules/common_msgs/basic_msgs:geometry_cc_proto",
2419
"//modules/common/util",
2520
"//modules/common/util:util_tool",
21+
"//modules/common_msgs/audio_msgs:audio_cc_proto",
22+
"//modules/common_msgs/audio_msgs:audio_event_cc_proto",
23+
"//modules/common_msgs/basic_msgs:drive_event_cc_proto",
24+
"//modules/common_msgs/basic_msgs:geometry_cc_proto",
25+
"//modules/common_msgs/chassis_msgs:chassis_cc_proto",
2626
"//modules/common_msgs/control_msgs:control_cmd_cc_proto",
27-
"//modules/dreamview/backend/common:dreamview_gflags",
28-
"//modules/dreamview/backend/map:map_service",
29-
"//modules/dreamview/proto:simulation_world_cc_proto",
3027
"//modules/common_msgs/localization_msgs:gps_cc_proto",
3128
"//modules/common_msgs/localization_msgs:localization_cc_proto",
32-
"//modules/map/hdmap:hdmap_util",
29+
"//modules/common_msgs/mission_msgs:mission_request_cc_proto",
3330
"//modules/common_msgs/perception_msgs:perception_obstacle_cc_proto",
3431
"//modules/common_msgs/planning_msgs:planning_cc_proto",
3532
"//modules/common_msgs/prediction_msgs:prediction_obstacle_cc_proto",
3633
"//modules/common_msgs/storytelling_msgs:story_cc_proto",
3734
"//modules/common_msgs/task_manager_msgs:task_manager_cc_proto",
35+
"//modules/dreamview/backend/common:dreamview_gflags",
36+
"//modules/dreamview/backend/map:map_service",
37+
"//modules/dreamview/proto:simulation_world_cc_proto",
38+
"//modules/map/hdmap:hdmap_util",
3839
"@com_github_nlohmann_json//:json",
3940
"@com_google_absl//absl/strings",
4041
],
@@ -47,34 +48,35 @@ cc_test(
4748
data = [
4849
"//modules/dreamview/backend/testdata",
4950
],
51+
linkstatic = True,
5052
deps = [
5153
":simulation_world_service",
5254
"//modules/common/math",
5355
"@com_google_googletest//:gtest_main",
5456
],
55-
linkstatic = True,
5657
)
5758

5859
cc_library(
5960
name = "simulation_world_updater",
6061
srcs = ["simulation_world_updater.cc"],
6162
hdrs = ["simulation_world_updater.h"],
6263
copts = DREAMVIEW_COPTS,
63-
alwayslink = True,
6464
deps = [
6565
":simulation_world_service",
6666
"//modules/common/util:util_tool",
67+
"//modules/common_msgs/mission_msgs:mission_request_cc_proto",
68+
"//modules/common_msgs/routing_msgs:poi_cc_proto",
69+
"//modules/common_msgs/task_manager_msgs:task_manager_cc_proto",
6770
"//modules/dreamview/backend/common:dreamview_gflags",
6871
"//modules/dreamview/backend/fuel_monitor:fuel_monitor_manager",
6972
"//modules/dreamview/backend/handlers:websocket_handler",
7073
"//modules/dreamview/backend/map:map_service",
7174
"//modules/dreamview/backend/perception_camera_updater",
72-
"//modules/common_msgs/routing_msgs:poi_cc_proto",
73-
"//modules/common_msgs/task_manager_msgs:task_manager_cc_proto",
7475
"//modules/dreamview/backend/plugins:plugin_manager",
75-
"//modules/dreamview/backend/sim_control_manager:sim_control_manager",
76+
"//modules/dreamview/backend/sim_control_manager",
7677
"@boost.thread",
7778
],
79+
alwayslink = True,
7880
)
7981

8082
cpplint()

modules/dreamview/backend/simulation_world/simulation_world_service.cc

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ using apollo::hdmap::Map;
6161
using apollo::hdmap::Path;
6262
using apollo::localization::Gps;
6363
using apollo::localization::LocalizationEstimate;
64+
using apollo::mission::MissionRequest;
6465
using apollo::perception::PerceptionObstacle;
6566
using apollo::perception::PerceptionObstacles;
6667
using apollo::perception::SensorMeasurement;
@@ -343,6 +344,21 @@ void SimulationWorldService::InitWriters() {
343344
routing_request_writer_ =
344345
node_->CreateWriter<RoutingRequest>(routing_request_attr);
345346
}
347+
{
348+
apollo::cyber::proto::RoleAttributes mission_request_attr;
349+
mission_request_attr.set_channel_name(FLAGS_mission_request_topic);
350+
auto qos = mission_request_attr.mutable_qos_profile();
351+
// only keeps the last message in history
352+
qos->set_history(apollo::cyber::proto::QosHistoryPolicy::HISTORY_KEEP_LAST);
353+
// reliable transfer
354+
qos->set_reliability(
355+
apollo::cyber::proto::QosReliabilityPolicy::RELIABILITY_RELIABLE);
356+
// Don't send the history message when new readers are found.
357+
qos->set_durability(
358+
apollo::cyber::proto::QosDurabilityPolicy::DURABILITY_SYSTEM_DEFAULT);
359+
mission_request_writer_ =
360+
node_->CreateWriter<MissionRequest>(mission_request_attr);
361+
}
346362

347363
routing_response_writer_ =
348364
node_->CreateWriter<RoutingResponse>(FLAGS_routing_response_topic);
@@ -723,8 +739,8 @@ void SimulationWorldService::SetObstacleDistanceToAdc(
723739
world_object->clear_distance_to_adc();
724740
if (obstacle_points.size() > 2 && adc_polygon_points.size() > 2) {
725741
world_object->set_distance_to_adc(std::fabs(
726-
apollo::common::math::Polygon2d(obstacle_points)
727-
.DistanceTo(apollo::common::math::Polygon2d(adc_polygon_points))));
742+
apollo::common::math::Polygon2d(obstacle_points)
743+
.DistanceTo(apollo::common::math::Polygon2d(adc_polygon_points))));
728744
}
729745
}
730746

@@ -1441,5 +1457,12 @@ void SimulationWorldService::PublishMonitorMessage(
14411457
monitor_logger_buffer_.AddMonitorMsgItem(log_level, msg);
14421458
monitor_logger_buffer_.Publish();
14431459
}
1460+
1461+
void SimulationWorldService::PublishMissionRequest(
1462+
const std::shared_ptr<MissionRequest> &mission_request) {
1463+
FillHeader(FLAGS_dreamview_module_name, mission_request.get());
1464+
mission_request_writer_->Write(mission_request);
1465+
}
1466+
14441467
} // namespace dreamview
14451468
} // namespace apollo

modules/dreamview/backend/simulation_world/simulation_world_service.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "modules/common_msgs/control_msgs/control_cmd.pb.h"
4343
#include "modules/common_msgs/localization_msgs/gps.pb.h"
4444
#include "modules/common_msgs/localization_msgs/localization.pb.h"
45+
#include "modules/common_msgs/mission_msgs/mission_request.pb.h"
4546
#include "modules/common_msgs/perception_msgs/traffic_light_detection.pb.h"
4647
#include "modules/common_msgs/planning_msgs/planning.pb.h"
4748
#include "modules/common_msgs/planning_msgs/planning_internal.pb.h"
@@ -151,6 +152,9 @@ class SimulationWorldService {
151152

152153
void PublishTask(const std::shared_ptr<apollo::task_manager::Task> &);
153154

155+
void PublishMissionRequest(
156+
const std::shared_ptr<apollo::mission::MissionRequest> &);
157+
154158
void GetMapElementIds(double radius, MapElementIds *ids) const;
155159

156160
const apollo::hdmap::Map &GetRelativeMap() const;
@@ -188,8 +192,9 @@ class SimulationWorldService {
188192
void SetObstacleSource(const apollo::perception::PerceptionObstacle &obstacle,
189193
Object *world_object);
190194
/**
191-
* @brief Set the distance beetween the auto driving car polygon and the obstacle polygon.
192-
*/
195+
* @brief Set the distance beetween the auto driving car polygon and the
196+
* obstacle polygon.
197+
*/
193198
void SetObstacleDistanceToAdc(
194199
const apollo::perception::PerceptionObstacle &obstacle,
195200
Object *world_object);
@@ -416,6 +421,8 @@ class SimulationWorldService {
416421
std::shared_ptr<cyber::Writer<apollo::routing::RoutingResponse>>
417422
routing_response_writer_;
418423
std::shared_ptr<cyber::Writer<apollo::task_manager::Task>> task_writer_;
424+
std::shared_ptr<cyber::Writer<apollo::mission::MissionRequest>>
425+
mission_request_writer_;
419426

420427
FRIEND_TEST(SimulationWorldServiceTest, UpdateMonitorSuccess);
421428
FRIEND_TEST(SimulationWorldServiceTest, UpdateMonitorRemove);

modules/dreamview/backend/simulation_world/simulation_world_updater.cc

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#include "google/protobuf/util/json_util.h"
2020

21+
#include "modules/common_msgs/mission_msgs/mission_request.pb.h"
22+
2123
#include "cyber/common/file.h"
2224
#include "modules/common/util/json_util.h"
2325
#include "modules/common/util/map_util.h"
@@ -173,7 +175,7 @@ void SimulationWorldUpdater::RegisterMessageHandlers() {
173175

174176
websocket_->RegisterMessageHandler(
175177
"SendMissionRequest",
176-
[this](constJson &json, WebSocketHandler::Connection *conn) {
178+
[this](const Json &json, WebSocketHandler::Connection *conn) {
177179
auto mission_request =
178180
std::make_shared<apollo::mission::MissionRequest>();
179181

@@ -188,30 +190,30 @@ void SimulationWorldUpdater::RegisterMessageHandlers() {
188190
// Analyzing key points (Waypoints)
189191
if (ContainsKey(json, "waypoints")) {
190192
for (const auto &wp_json : json["waypoints"]) {
191-
auto *wp = mission_request->add_global_waypoints();
193+
auto *wp = mission_request->add_waypoints();
192194
wp->set_name(wp_json["name"]);
193195
wp->mutable_pose()->set_x(wp_json["x"]);
194196
wp->mutable_pose()->set_y(wp_json["y"]);
195197
}
196198
}
197199

198-
// Parse the command queue.
199-
if (ContainsKey(json, "commands")) {
200-
for (const auto &cmd_json : json["commands"]) {
201-
auto *cmd = mission_request->add_command_queue();
202-
cmd->set_command_name(cmd_json["command"]);
200+
// // Parse the command queue.
201+
// if (ContainsKey(json, "commands")) {
202+
// for (const auto &cmd_json : json["commands"]) {
203+
// auto *cmd = mission_request->add_command_queue();
204+
// cmd->set_command_name(cmd_json["command"]);
203205

204-
// Automatically convert the params dictionary in JSON to Proto
205-
// param
206-
if (cmd_json.contains("params")) {
207-
for (auto &element : cmd_json["params"].items()) {
208-
SetMissionParam(element.key(), element.value(), cmd);
209-
}
210-
}
211-
}
212-
}
206+
// // Automatically convert the params dictionary in JSON to Proto
207+
// // param
208+
// if (cmd_json.contains("params")) {
209+
// for (auto &element : cmd_json["params"].items()) {
210+
// SetMissionParam(element.key(), element.value(), cmd);
211+
// }
212+
// }
213+
// }
214+
// }
213215

214-
mission_writer_->Write(mission_request);
216+
sim_world_service_.PublishMissionRequest(mission_request);
215217
});
216218

217219
websocket_->RegisterMessageHandler(

0 commit comments

Comments
 (0)