|
18 | 18 | #include "lanelet2_extension/utility/query.hpp"
|
19 | 19 | #include "lanelet2_extension/utility/utilities.hpp"
|
20 | 20 | #include "map_loader/lanelet2_map_loader_node.hpp"
|
21 |
| -#include "map_projection_loader/map_projection_loader.hpp" |
22 | 21 | #include "motion_utils/trajectory/tmp_conversion.hpp"
|
23 | 22 | #include "static_centerline_optimizer/msg/points_with_lane_id.hpp"
|
24 | 23 | #include "static_centerline_optimizer/successive_trajectory_optimizer_node.hpp"
|
|
30 | 29 | #include <pluginlib/class_loader.hpp>
|
31 | 30 | #include <tier4_autoware_utils/ros/marker_helper.hpp>
|
32 | 31 |
|
33 |
| -#include <nav_msgs/msg/odometry.hpp> |
34 | 32 | #include <tier4_map_msgs/msg/map_projector_info.hpp>
|
35 | 33 |
|
36 | 34 | #include <boost/geometry/algorithms/correct.hpp>
|
@@ -234,97 +232,26 @@ void StaticCenterlineOptimizerNode::run()
|
234 | 232 | {
|
235 | 233 | // declare planning setting parameters
|
236 | 234 | const auto lanelet2_input_file_path = declare_parameter<std::string>("lanelet2_input_file_path");
|
237 |
| - // const auto lanelet2_input_file_path = |
238 |
| - // // "/home/takayuki/AutonomousDrivingScenarios/map/odaiba_beta/lanelet2_map.osm"; |
239 |
| - // "/home/takayuki/AutonomousDrivingScenarios/map/kashiwanoha/lanelet2_map.osm"; |
240 | 235 | const auto lanelet2_output_file_path =
|
241 | 236 | declare_parameter<std::string>("lanelet2_output_file_path");
|
242 |
| - /* |
243 | 237 | const lanelet::Id start_lanelet_id = declare_parameter<int64_t>("start_lanelet_id");
|
244 | 238 | const lanelet::Id end_lanelet_id = declare_parameter<int64_t>("end_lanelet_id");
|
245 |
| - */ |
246 | 239 |
|
247 | 240 | // process
|
248 | 241 | load_map(lanelet2_input_file_path);
|
249 |
| - // const auto optimized_traj_points = plan_path(route_lane_ids); |
250 |
| - const auto centerline_traj_points = generateCenterlineFromBag(); |
251 |
| - auto centerline_traj = motion_utils::convertToTrajectory(centerline_traj_points); |
252 |
| - centerline_traj.header.frame_id = "map"; |
253 |
| - pub_optimized_centerline_->publish(centerline_traj); |
254 |
| - |
255 |
| - const auto start_lanelets = |
256 |
| - route_handler_ptr_->getClosestLanelets(centerline_traj_points.front().pose); |
257 |
| - const auto end_lanelets = |
258 |
| - route_handler_ptr_->getClosestLanelets(centerline_traj_points.back().pose); |
259 |
| - if (start_lanelets.empty() || end_lanelets.empty()) { |
260 |
| - RCLCPP_ERROR(get_logger(), "Nearest lanelets to the bag's centerline are not found."); |
261 |
| - return; |
262 |
| - } |
263 |
| - const lanelet::Id start_lanelet_id = start_lanelets.front().id(); |
264 |
| - const lanelet::Id end_lanelet_id = end_lanelets.front().id(); |
265 |
| - |
266 | 242 | const auto route_lane_ids = plan_route(start_lanelet_id, end_lanelet_id);
|
267 |
| - save_map(lanelet2_output_file_path, route_lane_ids, centerline_traj_points); |
268 |
| -} |
269 |
| - |
270 |
| -std::vector<TrajectoryPoint> StaticCenterlineOptimizerNode::generateCenterlineFromBag() |
271 |
| -{ |
272 |
| - const std::string bag_filename{ |
273 |
| - "/home/takayuki/bag/kashiwanoha/" |
274 |
| - "d4d1adc7-4fdf-4613-86b3-0daa2d945b9e_2023-12-22-13-35-13_p0900_0.db3"}; |
275 |
| - // "/home/takayuki/bag/1128/left-route-LC1_with-LC/" |
276 |
| - // "211130ae-8a64-4311-95ab-1b8406c4499b_2023-11-28-13-28-23_p0900_4.db3"}; |
277 |
| - |
278 |
| - rosbag2_cpp::Reader bag_reader; |
279 |
| - bag_reader.open(bag_filename); |
280 |
| - |
281 |
| - rclcpp::Serialization<nav_msgs::msg::Odometry> bag_serialization; |
282 |
| - std::vector<TrajectoryPoint> centerline_traj_points; |
283 |
| - while (bag_reader.has_next()) { |
284 |
| - const rosbag2_storage::SerializedBagMessageSharedPtr msg = bag_reader.read_next(); |
285 |
| - |
286 |
| - if (msg->topic_name != "/localization/kinematic_state") { |
287 |
| - continue; |
288 |
| - } |
289 |
| - |
290 |
| - rclcpp::SerializedMessage serialized_msg(*msg->serialized_data); |
291 |
| - const auto ros_msg = std::make_shared<nav_msgs::msg::Odometry>(); |
292 |
| - |
293 |
| - bag_serialization.deserialize_message(&serialized_msg, ros_msg.get()); |
294 |
| - |
295 |
| - if (!centerline_traj_points.empty()) { |
296 |
| - constexpr double epsilon = 1e-1; |
297 |
| - if ( |
298 |
| - std::abs(centerline_traj_points.back().pose.position.x - ros_msg->pose.pose.position.x) < |
299 |
| - epsilon && |
300 |
| - std::abs(centerline_traj_points.back().pose.position.y - ros_msg->pose.pose.position.y) < |
301 |
| - epsilon) { |
302 |
| - continue; |
303 |
| - } |
304 |
| - } |
305 |
| - TrajectoryPoint centerline_traj_point; |
306 |
| - centerline_traj_point.pose.position = ros_msg->pose.pose.position; |
307 |
| - std::cerr << centerline_traj_point.pose.position.x << " " |
308 |
| - << centerline_traj_point.pose.position.y << std::endl; |
309 |
| - centerline_traj_points.push_back(centerline_traj_point); |
310 |
| - } |
311 |
| - |
312 |
| - RCLCPP_INFO(get_logger(), "Extracted centerline from the bag."); |
313 |
| - |
314 |
| - return centerline_traj_points; |
| 243 | + const auto optimized_traj_points = plan_path(route_lane_ids); |
| 244 | + save_map(lanelet2_output_file_path, route_lane_ids, optimized_traj_points); |
315 | 245 | }
|
316 | 246 |
|
317 | 247 | void StaticCenterlineOptimizerNode::load_map(const std::string & lanelet2_input_file_path)
|
318 | 248 | {
|
319 |
| - const auto map_projector_info = load_info_from_yaml( |
320 |
| - "/home/takayuki/AutonomousDrivingScenarios/map/odaiba_beta/map_projector_info.yaml"); |
321 |
| - |
322 | 249 | // load map by the map_loader package
|
323 | 250 | map_bin_ptr_ = [&]() -> HADMapBin::ConstSharedPtr {
|
324 | 251 | // load map
|
325 | 252 | lanelet::LaneletMapPtr map_ptr;
|
326 |
| - // tier4_map_msgs::msg::MapProjectorInfo map_projector_info; |
327 |
| - // map_projector_info.projector_type = tier4_map_msgs::msg::MapProjectorInfo::MGRS; |
| 253 | + tier4_map_msgs::msg::MapProjectorInfo map_projector_info; |
| 254 | + map_projector_info.projector_type = tier4_map_msgs::msg::MapProjectorInfo::MGRS; |
328 | 255 | map_ptr = Lanelet2MapLoaderNode::load_map(lanelet2_input_file_path, map_projector_info);
|
329 | 256 | if (!map_ptr) {
|
330 | 257 | return nullptr;
|
|
0 commit comments