26namespace relative_map {
38 vehicle_state_provider_(nullptr) {}
41 vehicle_state_provider_ = vehicle_state_provider;
42 if (!FLAGS_use_navigation_mode) {
43 AERROR <<
"FLAGS_use_navigation_mode is false, system is not configured "
44 "for relative map mode";
45 return Status(ErrorCode::RELATIVE_MAP_ERROR,
46 "FLAGS_use_navigation_mode is not true.");
51 return Status(ErrorCode::RELATIVE_MAP_ERROR,
52 "Unable to load relative map conf file: " +
53 FLAGS_relative_map_config_filename);
58 const auto& map_param = config_.
map_param();
60 map_param.default_right_width());
66 auto* status = map_msg->mutable_header()->mutable_status();
67 status->set_msg(error_msg);
68 status->set_error_code(ErrorCode::RELATIVE_MAP_ERROR);
72 monitor_logger_buffer_.INFO(
"RelativeMap started");
78 std::lock_guard<std::mutex> lock(navigation_lane_mutex_);
79 CreateMapFromNavigationLane(map_msg);
86 std::lock_guard<std::mutex> lock(navigation_lane_mutex_);
94 std::lock_guard<std::mutex> lock(navigation_lane_mutex_);
95 perception_obstacles_.CopyFrom(perception_obstacles);
101 std::lock_guard<std::mutex> lock(navigation_lane_mutex_);
102 chassis_.CopyFrom(chassis);
108 std::lock_guard<std::mutex> lock(navigation_lane_mutex_);
109 localization_.CopyFrom(localization);
113bool RelativeMap::CreateMapFromNavigationLane(
MapMsg* map_msg) {
114 CHECK_NOTNULL(map_msg);
119 Chassis const& chassis = chassis_;
120 vehicle_state_provider_->
Update(localization, chassis);
121 map_msg->mutable_localization()->CopyFrom(localization_);
126 map_msg->mutable_lane_marker()->CopyFrom(perception_obstacles_.
lane_marker());
135 "There is no path point in currnet navigation path.");
142 "Failed to create map from current navigation path.");
143 AERROR <<
"Failed to create map from navigation path.";
148 <<
" navigation path(s) in the current reltative map.";
A general class to denote the return status of an API call.
static Status OK()
generate a success status.
The class of vehicle state.
Status Update(const localization::LocalizationEstimate &localization, const canbus::Chassis &chassis)
Constructor by information of localization and chassis.
void SetConfig(const NavigationLaneConfig &config)
Set the configuration information required by the NavigationLane.
bool GeneratePath()
Generate a suitable path (i.e.
void SetDefaultWidth(const double left_width, const double right_width)
Set the default width of a lane.
void UpdatePerception(const perception::PerceptionObstacles &perception_obstacles)
Update perceived lane line information.
void SetVehicleStateProvider(common::VehicleStateProvider *vehicle_state_provider)
NavigationPath Path() const
Get the generated lane segment where the vehicle is currently located.
bool CreateMap(const MapGenerationParam &map_config, MapMsg *const map_msg) const
Generate a real-time relative map of approximately 250 m in length based on several navigation line s...
void UpdateNavigationInfo(const NavigationInfo &navigation_info)
Update navigation line information.
void OnNavigationInfo(const NavigationInfo &navigation_info)
void OnLocalization(const localization::LocalizationEstimate &localization)
void OnChassis(const canbus::Chassis &chassis)
apollo::common::Status Start()
module start function
void Stop()
module stop function
bool Process(MapMsg *const map_msg)
main logic of the relative_map module, runs periodically triggered by timer.
apollo::common::Status Init(common::VehicleStateProvider *vehicle_state_provider)
module initialization function
void OnPerception(const perception::PerceptionObstacles &perception_obstacles)
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...
void LogErrorStatus(MapMsg *map_msg, const std::string &error_msg)
repeated PathPoint path_point
optional LaneMarkers lane_marker
map< string, NavigationPath > navigation_path
optional apollo::common::Path path
optional MapGenerationParam map_param
optional NavigationLaneConfig navigation_lane