Skip to content

Commit dc8399f

Browse files
committed
Merge branch 'master' into ros2
2 parents b3b5ee6 + 1acf72e commit dc8399f

File tree

14 files changed

+114
-26
lines changed

14 files changed

+114
-26
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@ jobs:
5959
submodules: recursive
6060

6161
- name: Cache ccache
62-
uses: actions/cache@v4
62+
uses: rhaschke/cache@main
6363
with:
64-
save-always: true
6564
path: ${{ env.CCACHE_DIR }}
6665
key: ccache-${{ env.CACHE_PREFIX }}-${{ github.sha }}-${{ github.run_id }}
6766
restore-keys: |
6867
ccache-${{ env.CACHE_PREFIX }}-${{ github.sha }}
6968
ccache-${{ env.CACHE_PREFIX }}
69+
env:
70+
GHA_CACHE_SAVE: always
7071

7172
- id: ici
7273
name: Run industrial_ci
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/msg/workspace_parameters.hpp>
41-
#include <fmt/core.h>
4242
#include "utils.h"
4343

4444
namespace py = pybind11;

core/python/bindings/src/stages.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,11 @@ void export_stages(pybind11::module& m) {
328328
)")
329329
.property<stages::Connect::MergeMode>("merge_mode", "Defines the merge strategy to use")
330330
.property<double>("max_distance", "maximally accepted distance between end and goal sate")
331+
.property<moveit_msgs::msg::Constraints>("path_constraints", R"(
332+
Constraints_: These are the path constraints.
333+
334+
.. _Constraints: https://docs.ros.org/en/api/moveit_msgs/html/msg/Constraints.html
335+
)")
331336
.def(py::init<const std::string&, const Connect::GroupPlannerVector&>(),
332337
"name"_a = std::string("connect"), "planners"_a);
333338

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

@@ -47,7 +48,6 @@
4748
#include <iostream>
4849
#include <algorithm>
4950
#include <boost/range/adaptor/reversed.hpp>
50-
#include <fmt/core.h>
5151
#include <functional>
5252

5353
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 <rclcpp/logging.hpp>
4443
#include <rclcpp/clock.hpp>

core/src/stage.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
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

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>
@@ -52,7 +53,6 @@
5253
#include <functional>
5354
#include <iterator>
5455
#include <rclcpp/logging.hpp>
55-
#include <fmt/core.h>
5656

5757
namespace moveit {
5858
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
#if FMT_VERSION >= 90000
4948
template <>

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>
@@ -50,7 +51,6 @@
5051
#endif
5152
#include <Eigen/Geometry>
5253
#include <rclcpp/logging.hpp>
53-
#include <fmt/core.h>
5454

5555
namespace vm = visualization_msgs;
5656
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 {

demo/scripts/constrained.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,35 @@
4040

4141
mps = stages.ModifyPlanningScene("modify planning scene")
4242
mps.addObject(co)
43+
44+
co.id = "object"
45+
co.primitives[0].type = SolidPrimitive.BOX
46+
co.primitives[0].dimensions = [0.1, 0.05, 0.03]
47+
pose = co.primitive_poses[0]
48+
pose.position.x = 0.30702
49+
pose.position.y = 0.0
50+
pose.position.z = 0.485
51+
pose.orientation.x = pose.orientation.w = 0.70711 # 90° about x
52+
mps.addObject(co)
53+
mps.attachObjects(["object"], "panda_hand")
54+
4355
task.add(mps)
4456

4557
move = stages.MoveRelative("y +0.4", planner)
58+
move.timeout = 5
4659
move.group = group
4760
header = Header(frame_id="world")
4861
move.setDirection(Vector3Stamped(header=header, vector=Vector3(x=0.0, y=0.4, z=0.0)))
4962

5063
constraints = Constraints()
5164
oc = OrientationConstraint()
65+
oc.parameterization = oc.ROTATION_VECTOR
5266
oc.header.frame_id = "world"
53-
oc.link_name = "panda_hand"
54-
oc.orientation.x = 1.0
55-
oc.orientation.w = 0.0
56-
oc.absolute_x_axis_tolerance = 0.01
57-
oc.absolute_y_axis_tolerance = 0.01
58-
oc.absolute_z_axis_tolerance = 0.01
67+
oc.link_name = "object"
68+
oc.orientation.x = oc.orientation.w = 0.70711 # 90° about x
69+
oc.absolute_x_axis_tolerance = 0.1
70+
oc.absolute_y_axis_tolerance = 0.1
71+
oc.absolute_z_axis_tolerance = 3.14
5972
oc.weight = 1.0
6073
constraints.orientation_constraints.append(oc)
6174
move.path_constraints = constraints

demo/scripts/pickplace.py

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from moveit.task_constructor import core, stages
66
from moveit_commander import PlanningSceneInterface
77
from geometry_msgs.msg import PoseStamped, TwistStamped
8-
import time
8+
from moveit_msgs.msg import Constraints, OrientationConstraint
9+
import math, time
910

1011
rclcpp.init()
1112
node = rclcpp.Node("mtc_tutorial")
@@ -18,7 +19,7 @@
1819

1920
# [pickAndPlaceTut2]
2021
# Specify object parameters
21-
object_name = "grasp_object"
22+
object_name = "object"
2223
object_radius = 0.02
2324

2425
# Start with a clear planning scene
@@ -29,7 +30,7 @@
2930
# Grasp object properties
3031
objectPose = PoseStamped()
3132
objectPose.header.frame_id = "world"
32-
objectPose.pose.orientation.x = 1.0
33+
objectPose.pose.orientation.w = 1.0
3334
objectPose.pose.position.x = 0.30702
3435
objectPose.pose.position.y = 0.0
3536
objectPose.pose.position.z = 0.285
@@ -56,15 +57,15 @@
5657
planners = [(arm, pipeline)]
5758

5859
# Connect the two stages
59-
task.add(stages.Connect("connect1", planners))
60+
task.add(stages.Connect("connect", planners))
6061
# [initAndConfigConnect]
6162
# [pickAndPlaceTut4]
6263

6364
# [pickAndPlaceTut5]
6465
# [initAndConfigGenerateGraspPose]
6566
# The grasp generator spawns a set of possible grasp poses around the object
6667
grasp_generator = stages.GenerateGraspPose("Generate Grasp Pose")
67-
grasp_generator.angle_delta = 0.2
68+
grasp_generator.angle_delta = math.pi / 2
6869
grasp_generator.pregrasp = "open"
6970
grasp_generator.grasp = "close"
7071
grasp_generator.setMonitoredStage(task["current"]) # Generate solutions for all initial states
@@ -78,7 +79,8 @@
7879
# Set frame for IK calculation in the center between the fingers
7980
ik_frame = PoseStamped()
8081
ik_frame.header.frame_id = "panda_hand"
81-
ik_frame.pose.position.z = 0.1034
82+
ik_frame.pose.position.z = 0.1034 # tcp between fingers
83+
ik_frame.pose.orientation.x = 1.0 # grasp from top
8284
simpleGrasp.setIKFrame(ik_frame)
8385
# [initAndConfigSimpleGrasp]
8486
# [pickAndPlaceTut6]
@@ -109,16 +111,35 @@
109111
# [initAndConfigPick]
110112
# [pickAndPlaceTut8]
111113

114+
# Define orientation constraint to keep the object upright
115+
oc = OrientationConstraint()
116+
oc.parameterization = oc.ROTATION_VECTOR
117+
oc.header.frame_id = "world"
118+
oc.link_name = "object"
119+
oc.orientation.w = 1
120+
oc.absolute_x_axis_tolerance = 0.1
121+
oc.absolute_y_axis_tolerance = 0.1
122+
oc.absolute_z_axis_tolerance = math.pi
123+
oc.weight = 1.0
124+
125+
constraints = Constraints()
126+
constraints.name = "object:upright"
127+
constraints.orientation_constraints.append(oc)
128+
112129
# [pickAndPlaceTut9]
113130
# Connect the Pick stage with the following Place stage
114-
task.add(stages.Connect("connect2", planners))
131+
con = stages.Connect("connect", planners)
132+
con.path_constraints = constraints
133+
task.add(con)
115134
# [pickAndPlaceTut9]
116135

117136
# [pickAndPlaceTut10]
118137
# [initAndConfigGeneratePlacePose]
119138
# Define the pose that the object should have after placing
120139
placePose = objectPose
121-
placePose.pose.position.y += 0.2 # shift object by 20cm along y axis
140+
placePose.pose.position.x = -0.2
141+
placePose.pose.position.y = -0.6
142+
placePose.pose.position.z = 0.0
122143

123144
# Generate Cartesian place poses for the object
124145
place_generator = stages.GeneratePlacePose("Generate Place Pose")

0 commit comments

Comments
 (0)