From 9ec4ddbd6d94932766ff714d86cb2c9c299685b1 Mon Sep 17 00:00:00 2001 From: Zhihao Ruan Date: Thu, 11 Apr 2024 00:29:49 -0700 Subject: [PATCH] update or-tools, add fmt dependency for glog --- ortools_ros/ortools | 2 +- ortools_ros_examples/package.xml | 1 + ortools_ros_examples/src/vrp.cpp | 13 +++++++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ortools_ros/ortools b/ortools_ros/ortools index ed8db90..3c5c99c 160000 --- a/ortools_ros/ortools +++ b/ortools_ros/ortools @@ -1 +1 @@ -Subproject commit ed8db9097cdbaa06b40384d3a86164744a606043 +Subproject commit 3c5c99c278ef3d0ac85cdbd4f008f8c0fd2f3f94 diff --git a/ortools_ros_examples/package.xml b/ortools_ros_examples/package.xml index e4ea57a..b6bee3b 100644 --- a/ortools_ros_examples/package.xml +++ b/ortools_ros_examples/package.xml @@ -10,6 +10,7 @@ ament_cmake_auto ortools_ros + fmt ament_lint_auto ament_lint_common diff --git a/ortools_ros_examples/src/vrp.cpp b/ortools_ros_examples/src/vrp.cpp index 275ad84..28baa33 100644 --- a/ortools_ros_examples/src/vrp.cpp +++ b/ortools_ros_examples/src/vrp.cpp @@ -5,6 +5,9 @@ * https://developers.google.com/optimization/routing/vrp#entire_program1 */ +#define FMT_HEADER_ONLY +#include + #include #include #include @@ -67,7 +70,7 @@ void PrintSolution(const DataModel &data, const RoutingIndexManager &manager, int64_t max_route_distance{0}; for (int vehicle_id = 0; vehicle_id < data.num_vehicles; ++vehicle_id) { int64_t index = routing.Start(vehicle_id); - LOG(INFO) << "Route for Vehicle " << vehicle_id << ":"; + LOG(INFO) << fmt::format("Route for Vehicle {}:", vehicle_id); int64_t route_distance{0}; std::stringstream route; while (routing.IsEnd(index) == false) { @@ -78,12 +81,14 @@ void PrintSolution(const DataModel &data, const RoutingIndexManager &manager, int64_t{vehicle_id}); } LOG(INFO) << route.str() << manager.IndexToNode(index).value(); - LOG(INFO) << "Distance of the route: " << route_distance << "m"; + LOG(INFO) << fmt::format("Distance of the route: {}m", route_distance); max_route_distance = std::max(route_distance, max_route_distance); } - LOG(INFO) << "Maximum of the route distances: " << max_route_distance << "m"; + LOG(INFO) << fmt::format("Maximum of the route distances: {}m", + max_route_distance); LOG(INFO) << ""; - LOG(INFO) << "Problem solved in " << routing.solver()->wall_time() << "ms"; + LOG(INFO) << fmt::format("Problem solved in {}ms", + routing.solver()->wall_time()); } void VrpGlobalSpan() {