Skip to content

Commit

Permalink
provide a fmt wrapper (moveit#615)
Browse files Browse the repository at this point in the history
for special eigen formatter, which is not available in fmt9

fmtlib/fmt#3465
https://stackoverflow.com/a/73755864/21260084
  • Loading branch information
v4hn authored Sep 24, 2024
1 parent d50c846 commit 721ff35
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 11 deletions.
49 changes: 49 additions & 0 deletions core/include/moveit/task_constructor/fmt_p.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2024, University of Hamburg
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/

/* Authors: Michael Goerner
Desc: Thin wrapper around fmt includes to provide Eigen formatters for fmt9
*/

#pragma once

#include <Eigen/Core>
#include <fmt/core.h>
#include <fmt/ostream.h>

#if FMT_VERSION >= 90000
template <typename T>
struct fmt::formatter<T, std::enable_if_t<std::is_base_of_v<Eigen::DenseBase<T>, T>, char>> : ostream_formatter
{};
#endif
2 changes: 1 addition & 1 deletion core/python/bindings/src/solvers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
#include <moveit/task_constructor/solvers/pipeline_planner.h>
#include <moveit/task_constructor/solvers/joint_interpolation.h>
#include <moveit/task_constructor/solvers/multi_planner.h>
#include <moveit/task_constructor/fmt_p.h>
#include <moveit_msgs/WorkspaceParameters.h>
#include <fmt/core.h>
#include "utils.h"

namespace py = pybind11;
Expand Down
2 changes: 1 addition & 1 deletion core/src/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <moveit/task_constructor/container_p.h>
#include <moveit/task_constructor/introspection.h>
#include <moveit/task_constructor/merge.h>
#include <moveit/task_constructor/fmt_p.h>
#include <moveit/planning_scene/planning_scene.h>
#include <moveit/trajectory_processing/time_optimal_trajectory_generation.h>

Expand All @@ -46,7 +47,6 @@
#include <iostream>
#include <algorithm>
#include <boost/range/adaptor/reversed.hpp>
#include <fmt/core.h>
#include <functional>

using namespace std::placeholders;
Expand Down
2 changes: 1 addition & 1 deletion core/src/cost_terms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

#include <moveit/task_constructor/cost_terms.h>
#include <moveit/task_constructor/stage.h>
#include <moveit/task_constructor/fmt_p.h>

#include <moveit/collision_detection/collision_common.h>
#include <moveit/robot_trajectory/robot_trajectory.h>
Expand All @@ -44,7 +45,6 @@

#include <Eigen/Geometry>

#include <fmt/core.h>
#include <utility>

namespace moveit {
Expand Down
3 changes: 1 addition & 2 deletions core/src/properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
*/

#include <moveit/task_constructor/properties.h>
#include <fmt/core.h>
#include <fmt/ostream.h>
#include <moveit/task_constructor/fmt_p.h>
#include <functional>
#include <ros/console.h>

Expand Down
2 changes: 1 addition & 1 deletion core/src/stage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
#include <moveit/task_constructor/stage_p.h>
#include <moveit/task_constructor/container_p.h>
#include <moveit/task_constructor/introspection.h>
#include <moveit/task_constructor/fmt_p.h>

#include <moveit/planning_scene/planning_scene.h>

#include <ros/console.h>
#include <fmt/core.h>

#include <iostream>
#include <iomanip>
Expand Down
2 changes: 1 addition & 1 deletion core/src/stages/compute_ik.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <moveit/task_constructor/stages/compute_ik.h>
#include <moveit/task_constructor/storage.h>
#include <moveit/task_constructor/marker_tools.h>
#include <moveit/task_constructor/fmt_p.h>

#include <moveit/planning_scene/planning_scene.h>
#include <moveit/robot_state/conversions.h>
Expand All @@ -48,7 +49,6 @@
#include <functional>
#include <iterator>
#include <ros/console.h>
#include <fmt/core.h>

namespace moveit {
namespace task_constructor {
Expand Down
3 changes: 1 addition & 2 deletions core/src/stages/connect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@
#include <moveit/task_constructor/stages/connect.h>
#include <moveit/task_constructor/merge.h>
#include <moveit/task_constructor/cost_terms.h>
#include <moveit/task_constructor/fmt_p.h>

#include <moveit/planning_scene/planning_scene.h>
#include <moveit/trajectory_processing/time_optimal_trajectory_generation.h>
#include <fmt/core.h>
#include <fmt/ostream.h>

using namespace trajectory_processing;

Expand Down
2 changes: 1 addition & 1 deletion core/src/stages/fix_collision_objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

#include <moveit/task_constructor/stages/fix_collision_objects.h>
#include <moveit/task_constructor/storage.h>
#include <moveit/task_constructor/fmt_p.h>

#include <moveit/planning_scene/planning_scene.h>
#include <moveit/task_constructor/cost_terms.h>
Expand All @@ -46,7 +47,6 @@
#include <Eigen/Geometry>
#include <tf2_eigen/tf2_eigen.h>
#include <ros/console.h>
#include <fmt/core.h>

namespace vm = visualization_msgs;
namespace cd = collision_detection;
Expand Down
2 changes: 1 addition & 1 deletion core/src/stages/modify_planning_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
#include <moveit/task_constructor/stages/modify_planning_scene.h>
#include <moveit/task_constructor/storage.h>
#include <moveit/task_constructor/cost_terms.h>
#include <moveit/task_constructor/fmt_p.h>

#include <moveit/planning_scene/planning_scene.h>
#include <fmt/core.h>

namespace moveit {
namespace task_constructor {
Expand Down

0 comments on commit 721ff35

Please sign in to comment.