diff --git a/core/src/cost_terms.cpp b/core/src/cost_terms.cpp index 9ddb94ff2..8cf628537 100644 --- a/core/src/cost_terms.cpp +++ b/core/src/cost_terms.cpp @@ -1,4 +1,4 @@ -/********************************************************************* +/********************************************************************* * Software License Agreement (BSD License) * * Copyright (c) 2020, Hamburg University @@ -253,7 +253,7 @@ Clearance::Clearance(bool with_world, bool cumulative, std::string group_propert , distance_to_cost{ [](double d) { return 1.0 / (d + 1e-5); } } {} double Clearance::operator()(const SubTrajectory& s, std::string& comment) const { - static const std::string PREFIX{ "Clearance: " }; + constexpr std::string_view PREFIX{ "Clearance: " }; collision_detection::DistanceRequest request; request.type = @@ -298,8 +298,8 @@ double Clearance::operator()(const SubTrajectory& s, std::string& comment) const } }; auto collision_comment = [=](const auto& distance) { - return fmt::format(PREFIX + "allegedly valid solution collides between '{}' and '{}'", distance.link_names[0], - distance.link_names[1]); + return fmt::format("{}allegedly valid solution collides between '{}' and '{}'", PREFIX, + distance.link_names[0], distance.link_names[1]); }; double distance{ 0.0 }; @@ -313,10 +313,10 @@ double Clearance::operator()(const SubTrajectory& s, std::string& comment) const } distance = distance_data.distance; if (!cumulative) - comment = fmt::format(PREFIX + "distance {} between '{}' and '{}'", distance, distance_data.link_names[0], - distance_data.link_names[1]); + comment = fmt::format("{}distance {} between '{}' and '{}'", PREFIX, distance, + distance_data.link_names[0], distance_data.link_names[1]); else - comment = fmt::format(PREFIX + "cumulative distance {}", distance); + comment = fmt::format("{}cumulative distance {}", PREFIX, distance); } else { // check trajectory for (size_t i = 0; i < s.trajectory()->getWayPointCount(); ++i) { auto distance_data = check_distance(state, s.trajectory()->getWayPoint(i)); @@ -327,7 +327,8 @@ double Clearance::operator()(const SubTrajectory& s, std::string& comment) const distance += distance_data.distance; } distance /= s.trajectory()->getWayPointCount(); - comment = fmt::format(PREFIX + "average{} distance: {}", (cumulative ? " cumulative" : ""), distance); + comment = fmt::format("{}average{} distance: {}", PREFIX, (cumulative ? " cumulative" : ""), + distance); } return distance_to_cost(distance); diff --git a/core/src/stage.cpp b/core/src/stage.cpp index b64ce0ab3..6c8ec5c3e 100644 --- a/core/src/stage.cpp +++ b/core/src/stage.cpp @@ -909,8 +909,9 @@ bool Connecting::compatible(const InterfaceState& from_state, const InterfaceSta const planning_scene::PlanningSceneConstPtr& from = from_state.scene(); const planning_scene::PlanningSceneConstPtr& to = to_state.scene(); - auto false_with_debug = [](auto... args) { - RCLCPP_DEBUG_STREAM(rclcpp::get_logger("Connecting"), fmt::format(args...)); + auto false_with_debug = [](const char* format_str, auto&&... args) { + RCLCPP_DEBUG_STREAM(rclcpp::get_logger("Connecting"), + fmt::format(fmt::runtime(format_str), std::forward(args)...)); return false; };