Skip to content

Commit 721ff35

Browse files
authored
provide a fmt wrapper (moveit#615)
for special eigen formatter, which is not available in fmt9 fmtlib/fmt#3465 https://stackoverflow.com/a/73755864/21260084
1 parent d50c846 commit 721ff35

File tree

10 files changed

+58
-11
lines changed

10 files changed

+58
-11
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*********************************************************************
2+
* Software License Agreement (BSD License)
3+
*
4+
* Copyright (c) 2024, University of Hamburg
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions
9+
* are met:
10+
*
11+
* * Redistributions of source code must retain the above copyright
12+
* notice, this list of conditions and the following disclaimer.
13+
* * Redistributions in binary form must reproduce the above
14+
* copyright notice, this list of conditions and the following
15+
* disclaimer in the documentation and/or other materials provided
16+
* with the distribution.
17+
* * Neither the name of the copyright holder nor the names of its
18+
* contributors may be used to endorse or promote products derived
19+
* from this software without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31+
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
* POSSIBILITY OF SUCH DAMAGE.
33+
*********************************************************************/
34+
35+
/* Authors: Michael Goerner
36+
Desc: Thin wrapper around fmt includes to provide Eigen formatters for fmt9
37+
*/
38+
39+
#pragma once
40+
41+
#include <Eigen/Core>
42+
#include <fmt/core.h>
43+
#include <fmt/ostream.h>
44+
45+
#if FMT_VERSION >= 90000
46+
template <typename T>
47+
struct fmt::formatter<T, std::enable_if_t<std::is_base_of_v<Eigen::DenseBase<T>, T>, char>> : ostream_formatter
48+
{};
49+
#endif

core/python/bindings/src/solvers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
#include <moveit/task_constructor/solvers/pipeline_planner.h>
3838
#include <moveit/task_constructor/solvers/joint_interpolation.h>
3939
#include <moveit/task_constructor/solvers/multi_planner.h>
40+
#include <moveit/task_constructor/fmt_p.h>
4041
#include <moveit_msgs/WorkspaceParameters.h>
41-
#include <fmt/core.h>
4242
#include "utils.h"
4343

4444
namespace py = pybind11;

core/src/container.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <moveit/task_constructor/container_p.h>
3838
#include <moveit/task_constructor/introspection.h>
3939
#include <moveit/task_constructor/merge.h>
40+
#include <moveit/task_constructor/fmt_p.h>
4041
#include <moveit/planning_scene/planning_scene.h>
4142
#include <moveit/trajectory_processing/time_optimal_trajectory_generation.h>
4243

@@ -46,7 +47,6 @@
4647
#include <iostream>
4748
#include <algorithm>
4849
#include <boost/range/adaptor/reversed.hpp>
49-
#include <fmt/core.h>
5050
#include <functional>
5151

5252
using namespace std::placeholders;

core/src/cost_terms.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#include <moveit/task_constructor/cost_terms.h>
3838
#include <moveit/task_constructor/stage.h>
39+
#include <moveit/task_constructor/fmt_p.h>
3940

4041
#include <moveit/collision_detection/collision_common.h>
4142
#include <moveit/robot_trajectory/robot_trajectory.h>
@@ -44,7 +45,6 @@
4445

4546
#include <Eigen/Geometry>
4647

47-
#include <fmt/core.h>
4848
#include <utility>
4949

5050
namespace moveit {

core/src/properties.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
*/
3838

3939
#include <moveit/task_constructor/properties.h>
40-
#include <fmt/core.h>
41-
#include <fmt/ostream.h>
40+
#include <moveit/task_constructor/fmt_p.h>
4241
#include <functional>
4342
#include <ros/console.h>
4443

core/src/stage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
#include <moveit/task_constructor/stage_p.h>
3939
#include <moveit/task_constructor/container_p.h>
4040
#include <moveit/task_constructor/introspection.h>
41+
#include <moveit/task_constructor/fmt_p.h>
4142

4243
#include <moveit/planning_scene/planning_scene.h>
4344

4445
#include <ros/console.h>
45-
#include <fmt/core.h>
4646

4747
#include <iostream>
4848
#include <iomanip>

core/src/stages/compute_ik.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <moveit/task_constructor/stages/compute_ik.h>
3838
#include <moveit/task_constructor/storage.h>
3939
#include <moveit/task_constructor/marker_tools.h>
40+
#include <moveit/task_constructor/fmt_p.h>
4041

4142
#include <moveit/planning_scene/planning_scene.h>
4243
#include <moveit/robot_state/conversions.h>
@@ -48,7 +49,6 @@
4849
#include <functional>
4950
#include <iterator>
5051
#include <ros/console.h>
51-
#include <fmt/core.h>
5252

5353
namespace moveit {
5454
namespace task_constructor {

core/src/stages/connect.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,10 @@
3939
#include <moveit/task_constructor/stages/connect.h>
4040
#include <moveit/task_constructor/merge.h>
4141
#include <moveit/task_constructor/cost_terms.h>
42+
#include <moveit/task_constructor/fmt_p.h>
4243

4344
#include <moveit/planning_scene/planning_scene.h>
4445
#include <moveit/trajectory_processing/time_optimal_trajectory_generation.h>
45-
#include <fmt/core.h>
46-
#include <fmt/ostream.h>
4746

4847
using namespace trajectory_processing;
4948

core/src/stages/fix_collision_objects.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
#include <moveit/task_constructor/stages/fix_collision_objects.h>
4040
#include <moveit/task_constructor/storage.h>
41+
#include <moveit/task_constructor/fmt_p.h>
4142

4243
#include <moveit/planning_scene/planning_scene.h>
4344
#include <moveit/task_constructor/cost_terms.h>
@@ -46,7 +47,6 @@
4647
#include <Eigen/Geometry>
4748
#include <tf2_eigen/tf2_eigen.h>
4849
#include <ros/console.h>
49-
#include <fmt/core.h>
5050

5151
namespace vm = visualization_msgs;
5252
namespace cd = collision_detection;

core/src/stages/modify_planning_scene.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
#include <moveit/task_constructor/stages/modify_planning_scene.h>
4040
#include <moveit/task_constructor/storage.h>
4141
#include <moveit/task_constructor/cost_terms.h>
42+
#include <moveit/task_constructor/fmt_p.h>
4243

4344
#include <moveit/planning_scene/planning_scene.h>
44-
#include <fmt/core.h>
4545

4646
namespace moveit {
4747
namespace task_constructor {

0 commit comments

Comments
 (0)