Skip to content

Commit 98000f3

Browse files
committed
Merge branch 'master' into ros2
2 parents bbc34d2 + 8d2baf2 commit 98000f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+627
-445
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This repository provides the following branches:
2424

2525
## Tutorial
2626

27-
We provide a tutorial for a pick-and-place pipeline without bells & whistles [as part of the MoveIt tutorials](https://ros-planning.github.io/moveit_tutorials/doc/moveit_task_constructor/moveit_task_constructor_tutorial.html).
27+
We provide a tutorial for a pick-and-place pipeline without bells & whistles [as part of the MoveIt tutorials](https://moveit.github.io/moveit_tutorials/doc/moveit_task_constructor/moveit_task_constructor_tutorial.html).
2828

2929
## Roadmap
3030

Diff for: capabilities/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ project(moveit_task_constructor_capabilities)
33

44
find_package(ament_cmake REQUIRED)
55

6+
find_package(fmt REQUIRED)
67
find_package(Boost REQUIRED)
78
find_package(moveit_common REQUIRED)
89
moveit_package()
@@ -20,6 +21,7 @@ add_library(${PROJECT_NAME} SHARED
2021
)
2122
ament_target_dependencies(${PROJECT_NAME}
2223
Boost
24+
fmt
2325
rclcpp_action
2426
moveit_core
2527
moveit_ros_move_group

Diff for: capabilities/package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
<buildtool_depend>ament_cmake</buildtool_depend>
1414

15+
<depend>fmt</depend>
1516
<depend>moveit_core</depend>
1617
<depend>moveit_ros_move_group</depend>
1718
<depend>moveit_ros_planning</depend>

Diff for: capabilities/src/execute_task_solution_capability.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@
4343
#include <moveit/move_group/capability_names.h>
4444
#include <moveit/robot_state/conversions.h>
4545
#include <moveit/utils/message_checks.h>
46-
#include <moveit/moveit_cpp/moveit_cpp.h>
47-
48-
#include <boost/algorithm/string/join.hpp>
46+
#include <fmt/format.h>
4947

5048
namespace {
5149

@@ -164,8 +162,8 @@ bool ExecuteTaskSolutionCapability::constructMotionPlan(const moveit_task_constr
164162
if (!joint_names.empty()) {
165163
group = findJointModelGroup(*model, joint_names);
166164
if (!group) {
167-
RCLCPP_ERROR_STREAM(LOGGER, "Could not find JointModelGroup that actuates {"
168-
<< boost::algorithm::join(joint_names, ", ") << "}");
165+
RCLCPP_ERROR_STREAM(LOGGER, fmt::format("Could not find JointModelGroup that actuates {{{}}}",
166+
fmt::join(joint_names, ", ")));
169167
return false;
170168
}
171169
RCLCPP_DEBUG(LOGGER, "Using JointModelGroup '%s' for execution", group->getName().c_str());

Diff for: core/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ project(moveit_task_constructor_core)
44
find_package(ament_cmake REQUIRED)
55

66
find_package(Boost REQUIRED)
7+
find_package(fmt REQUIRED)
78
find_package(geometry_msgs REQUIRED)
89
find_package(moveit_common REQUIRED)
910
moveit_package()

Diff for: core/doc/tutorials/properties.rst

-5
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,6 @@ You can obtain a reference to the the PropertyMap of a stage like so
9797
:start-after: [propertyTut10]
9898
:end-before: [propertyTut10]
9999

100-
.. literalinclude:: ../../../demo/scripts/properties.py
101-
:language: python
102-
:start-after: [propertyTut11]
103-
:end-before: [propertyTut11]
104-
105100

106101
As mentioned, each stage contains a PropertyMap.
107102
Stages communicate to each other via their interfaces.

Diff for: core/include/moveit/task_constructor/container.h

+4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ class ContainerBase : public Stage
5151
PRIVATE_CLASS(ContainerBase)
5252
using pointer = std::unique_ptr<ContainerBase>;
5353

54+
/// Explicitly enable/disable pruning
55+
void setPruning(bool pruning) { setProperty("pruning", pruning); }
56+
bool pruning() const { return properties().get<bool>("pruning"); }
57+
5458
size_t numChildren() const;
5559
Stage* findChild(const std::string& name) const;
5660
Stage* operator[](int index) const;

Diff for: core/include/moveit/task_constructor/cost_terms.h

+8
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class LambdaCostTerm : public TrajectoryCostTerm
9595
LambdaCostTerm(const SubTrajectorySignature& term);
9696
LambdaCostTerm(const SubTrajectoryShortSignature& term);
9797

98+
using TrajectoryCostTerm::operator();
9899
double operator()(const SubTrajectory& s, std::string& comment) const override;
99100

100101
protected:
@@ -132,6 +133,8 @@ class PathLength : public TrajectoryCostTerm
132133
PathLength(std::vector<std::string> joints);
133134
/// Limit measurements to given joints and use given weighting
134135
PathLength(std::map<std::string, double> j) : joints(std::move(j)) {}
136+
137+
using TrajectoryCostTerm::operator();
135138
double operator()(const SubTrajectory& s, std::string& comment) const override;
136139

137140
std::map<std::string, double> joints; //< joint weights
@@ -145,6 +148,8 @@ class DistanceToReference : public TrajectoryCostTerm
145148
std::map<std::string, double> w = std::map<std::string, double>());
146149
DistanceToReference(const std::map<std::string, double>& ref, Mode m = Mode::AUTO,
147150
std::map<std::string, double> w = std::map<std::string, double>());
151+
152+
using TrajectoryCostTerm::operator();
148153
double operator()(const SubTrajectory& s, std::string& comment) const override;
149154

150155
moveit_msgs::msg::RobotState reference;
@@ -156,6 +161,7 @@ class DistanceToReference : public TrajectoryCostTerm
156161
class TrajectoryDuration : public TrajectoryCostTerm
157162
{
158163
public:
164+
using TrajectoryCostTerm::operator();
159165
double operator()(const SubTrajectory& s, std::string& comment) const override;
160166
};
161167

@@ -167,6 +173,7 @@ class LinkMotion : public TrajectoryCostTerm
167173

168174
std::string link_name;
169175

176+
using TrajectoryCostTerm::operator();
170177
double operator()(const SubTrajectory& s, std::string& comment) const override;
171178
};
172179

@@ -191,6 +198,7 @@ class Clearance : public TrajectoryCostTerm
191198

192199
std::function<double(double)> distance_to_cost;
193200

201+
using TrajectoryCostTerm::operator();
194202
double operator()(const SubTrajectory& s, std::string& comment) const override;
195203
};
196204

Diff for: core/include/moveit/task_constructor/solvers/cartesian_path.h

+4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ class CartesianPath : public PlannerInterface
5252
public:
5353
CartesianPath();
5454

55+
void setIKFrame(const geometry_msgs::msg::PoseStamped& pose) { setProperty("ik_frame", pose); }
56+
void setIKFrame(const Eigen::Isometry3d& pose, const std::string& link);
57+
void setIKFrame(const std::string& link) { setIKFrame(Eigen::Isometry3d::Identity(), link); }
58+
5559
void setStepSize(double step_size) { setProperty("step_size", step_size); }
5660
void setJumpThreshold(double jump_threshold) { setProperty("jump_threshold", jump_threshold); }
5761
void setMinFraction(double min_fraction) { setProperty("min_fraction", min_fraction); }

Diff for: core/include/moveit/task_constructor/solvers/multi_planner.h

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ class MultiPlanner : public PlannerInterface, public std::vector<solvers::Planne
7171
const Eigen::Isometry3d& offset, const Eigen::Isometry3d& target,
7272
const moveit::core::JointModelGroup* jmg, double timeout, robot_trajectory::RobotTrajectoryPtr& result,
7373
const moveit_msgs::msg::Constraints& path_constraints = moveit_msgs::msg::Constraints()) override;
74+
75+
std::string getPlannerId() const override { return "MultiPlanner"; }
7476
};
7577
} // namespace solvers
7678
} // namespace task_constructor

Diff for: core/include/moveit/task_constructor/stage_p.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include <moveit/task_constructor/cost_queue.h>
4545

4646
#include <rclcpp/rclcpp.hpp>
47+
#include <fmt/core.h>
4748

4849
#include <ostream>
4950
#include <chrono>
@@ -144,7 +145,7 @@ class StagePrivate
144145
void newSolution(const SolutionBasePtr& solution);
145146
bool storeFailures() const { return introspection_ != nullptr; }
146147
void runCompute() {
147-
RCLCPP_DEBUG_STREAM(LOGGER, "Computing stage '" << name() << "'");
148+
RCLCPP_DEBUG_STREAM(LOGGER, fmt::format("Computing stage '{}'", name()));
148149
auto compute_start_time = std::chrono::steady_clock::now();
149150
try {
150151
compute();

Diff for: core/include/moveit/task_constructor/stages/passthrough.h

-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@
3636
#pragma once
3737

3838
#include <moveit/task_constructor/container.h>
39-
#include <moveit/task_constructor/cost_queue.h>
40-
#include <geometry_msgs/msg/pose_stamped.hpp>
41-
#include <Eigen/Geometry>
4239

4340
namespace moveit {
4441
namespace task_constructor {

Diff for: core/include/moveit/task_constructor/task.h

+3
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ class Task : protected WrapperBase
119119
using WrapperBase::setTimeout;
120120
using WrapperBase::timeout;
121121

122+
using WrapperBase::pruning;
123+
using WrapperBase::setPruning;
124+
122125
/// reset all stages
123126
void reset() final;
124127
/// initialize all stages with given scene

Diff for: core/include/moveit/task_constructor/utils.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ MOVEIT_CLASS_FORWARD(RobotState);
6060

6161
namespace task_constructor {
6262
MOVEIT_CLASS_FORWARD(Property);
63-
MOVEIT_CLASS_FORWARD(SolutionBase);
6463

6564
namespace utils {
6665

@@ -141,7 +140,7 @@ class Flags
141140
};
142141

143142
bool getRobotTipForFrame(const Property& property, const planning_scene::PlanningScene& scene,
144-
const moveit::core::JointModelGroup* jmg, SolutionBase& solution,
143+
const moveit::core::JointModelGroup* jmg, std::string& error_msg,
145144
const moveit::core::LinkModel*& robot_link, Eigen::Isometry3d& tip_in_global_frame);
146145
} // namespace utils
147146
} // namespace task_constructor

Diff for: core/package.xml

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<version>0.1.3</version>
44
<description>MoveIt Task Pipeline</description>
55

6-
<url type="website">https://github.com/ros-planning/moveit_task_constructor</url>
7-
<url type="repository">https://github.com/ros-planning/moveit_task_constructor</url>
8-
<url type="bugtracker">https://github.com/ros-planning/moveit_task_constructor/issues</url>
6+
<url type="website">https://github.com/moveit/moveit_task_constructor</url>
7+
<url type="repository">https://github.com/moveit/moveit_task_constructor</url>
8+
<url type="bugtracker">https://github.com/moveit/moveit_task_constructor/issues</url>
99

1010
<license>BSD</license>
1111
<maintainer email="[email protected]">Michael Goerner</maintainer>
@@ -14,6 +14,7 @@
1414
<buildtool_depend>ament_cmake</buildtool_depend>
1515
<buildtool_depend>ament_cmake_python</buildtool_depend>
1616

17+
<depend>fmt</depend>
1718
<depend>geometry_msgs</depend>
1819
<depend>moveit_core</depend>
1920
<depend>moveit_ros_planning</depend>

Diff for: core/python/bindings/src/core.cpp

+5-19
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
*********************************************************************/
3434

3535
#include "core.h"
36+
#include "utils.h"
3637
#include <pybind11/stl.h>
3738
#include <pybind11/functional.h>
3839
#include <moveit/python/task_constructor/properties.h>
@@ -52,23 +53,6 @@ namespace python {
5253

5354
namespace {
5455

55-
// utility function to normalize index: negative indeces reference from the end
56-
size_t normalize_index(size_t size, long index) {
57-
if (index < 0)
58-
index += size;
59-
if (index >= long(size) || index < 0)
60-
throw pybind11::index_error("Index out of range");
61-
return index;
62-
}
63-
64-
// implement operator[](index)
65-
template <typename T>
66-
typename T::value_type get_item(const T& container, long index) {
67-
auto it = container.begin();
68-
std::advance(it, normalize_index(container.size(), index));
69-
return *it;
70-
}
71-
7256
py::list getForwardedProperties(const Stage& self) {
7357
py::list l;
7458
for (const std::string& value : self.forwardedProperties())
@@ -96,7 +80,9 @@ void setForwardedProperties(Stage& self, const py::object& names) {
9680

9781
void export_core(pybind11::module& m) {
9882
/// translate InitStageException into InitStageError
99-
static py::exception<InitStageException> init_stage_error(m, "InitStageError");
83+
PYBIND11_CONSTINIT static py::gil_safe_call_once_and_store<py::object> exc_storage;
84+
exc_storage.call_once_and_store_result([&]() { return py::exception<InitStageException>(m, "InitStageError"); });
85+
10086
/// provide extended error description for InitStageException
10187
py::register_exception_translator([](std::exception_ptr p) { // NOLINT(performance-unnecessary-value-param)
10288
try {
@@ -105,7 +91,7 @@ void export_core(pybind11::module& m) {
10591
} catch (const InitStageException& e) {
10692
std::stringstream message;
10793
message << e;
108-
init_stage_error(message.str().c_str());
94+
py::set_error(exc_storage.get_stored(), message.str().c_str());
10995
}
11096
});
11197

Diff for: core/python/bindings/src/solvers.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
#include <moveit/task_constructor/solvers/cartesian_path.h>
3737
#include <moveit/task_constructor/solvers/pipeline_planner.h>
3838
#include <moveit/task_constructor/solvers/joint_interpolation.h>
39+
#include <moveit/task_constructor/solvers/multi_planner.h>
3940
#include <moveit_msgs/WorkspaceParameters.h>
41+
#include "utils.h"
4042

4143
namespace py = pybind11;
4244
using namespace py::literals;
@@ -47,6 +49,7 @@ PYBIND11_SMART_HOLDER_TYPE_CASTERS(PlannerInterface)
4749
PYBIND11_SMART_HOLDER_TYPE_CASTERS(PipelinePlanner)
4850
PYBIND11_SMART_HOLDER_TYPE_CASTERS(JointInterpolationPlanner)
4951
PYBIND11_SMART_HOLDER_TYPE_CASTERS(CartesianPath)
52+
PYBIND11_SMART_HOLDER_TYPE_CASTERS(MultiPlanner)
5053

5154
namespace moveit {
5255
namespace python {
@@ -114,6 +117,27 @@ void export_solvers(py::module& m) {
114117
"This values specifies the fraction of mean acceptable joint motion per step.")
115118
.property<double>("min_fraction", "float: Fraction of overall distance required to succeed.")
116119
.def(py::init<>());
120+
121+
properties::class_<MultiPlanner, PlannerInterface>(m, "MultiPlanner", R"(
122+
A meta planner that runs multiple alternative planners in sequence and returns the first found solution. ::
123+
124+
from moveit.task_constructor import core
125+
126+
# Instantiate MultiPlanner
127+
multiPlanner = core.MultiPlanner()
128+
)")
129+
.def("__len__", &MultiPlanner::size)
130+
.def("__getitem__", &get_item<MultiPlanner>)
131+
.def(
132+
"add",
133+
[](MultiPlanner& self, const py::args& args) {
134+
for (auto it = args.begin(), end = args.end(); it != end; ++it)
135+
self.push_back(it->cast<PlannerInterfacePtr>());
136+
},
137+
"Insert one or more planners")
138+
.def(
139+
"clear", [](MultiPlanner& self) { self.clear(); }, "Remove all planners")
140+
.def(py::init<>());
117141
}
118142
} // namespace python
119143
} // namespace moveit

Diff for: core/python/bindings/src/stages.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,13 @@ void export_stages(pybind11::module& m) {
191191
int: Set the maximum number of inverse
192192
kinematic solutions thats should be generated.
193193
)")
194+
.property<uint32_t>("max_ik_solutions", "uint: max number of solutions to return")
194195
.property<bool>("ignore_collisions", R"(
195196
bool: Specify if collisions with other members of
196197
the planning scene are allowed.
197198
)")
199+
.property<double>("min_solution_distance", "reject solution that are closer than this to previously found solutions")
200+
.property<moveit_msgs::msg::Constraints>("constraints", "additional constraints to obey")
198201
.property<geometry_msgs::msg::PoseStamped>("ik_frame", R"(
199202
PoseStamped_: Specify the frame with respect
200203
to which the inverse kinematics

Diff for: core/python/bindings/src/utils.h

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <pybind11/pybind11.h>
2+
3+
namespace moveit {
4+
namespace python {
5+
namespace {
6+
7+
// utility function to normalize index: negative indeces reference from the end
8+
size_t normalize_index(size_t size, long index) {
9+
if (index < 0)
10+
index += size;
11+
if (index >= long(size) || index < 0)
12+
throw pybind11::index_error("Index out of range");
13+
return index;
14+
}
15+
16+
// implement operator[](index)
17+
template <typename T>
18+
typename T::value_type get_item(const T& container, long index) {
19+
auto it = container.begin();
20+
std::advance(it, normalize_index(container.size(), index));
21+
return *it;
22+
}
23+
24+
} // namespace
25+
} // namespace python
26+
} // namespace moveit

Diff for: core/python/pybind11

Submodule pybind11 updated 292 files

Diff for: core/python/test/rostest_mps.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#! /usr/bin/env python
1+
#! /usr/bin/env python3
22

3-
from __future__ import print_function
43
import unittest
54
import rostest
65
from py_binding_tools import roscpp_init
@@ -9,6 +8,10 @@
98
from geometry_msgs.msg import PoseStamped
109

1110

11+
def setUpModule():
12+
roscpp_init("test_mtc")
13+
14+
1215
def make_pose(x, y, z):
1316
pose = PoseStamped()
1417
pose.header.frame_id = "base_link"
@@ -113,5 +116,4 @@ def test_bw_remove_object(self):
113116

114117

115118
if __name__ == "__main__":
116-
roscpp_init("test_mtc")
117119
rostest.rosrun("mtc", "mps", TestModifyPlanningScene)

0 commit comments

Comments
 (0)