Skip to content

Commit 98ced78

Browse files
ROS 2 Migration (#170)
2 parents ed45970 + 71a604c commit 98ced78

File tree

144 files changed

+2922
-1803
lines changed

Some content is hidden

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

144 files changed

+2922
-1803
lines changed

.github/workflows/ci.yaml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,36 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
env:
17-
- IMAGE: melodic-source
17+
# TODO: We have to use -Wno-redundant-decls since rosidl_generator_c is generating broken headers
18+
- IMAGE: galactic-source
1819
NAME: ccov
1920
TARGET_CMAKE_ARGS: -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="--coverage"
20-
- IMAGE: master-source
21+
- IMAGE: rolling-source
2122
CXXFLAGS: >-
22-
-Werror -Wall -Wextra -Wwrite-strings -Wunreachable-code -Wpointer-arith -Wredundant-decls
23+
-Werror -Wall -Wextra -Wwrite-strings -Wunreachable-code -Wpointer-arith -Wno-redundant-decls
2324
-Wno-unused-parameter -Wno-unused-function -Wno-deprecated-copy -Wno-unused-but-set-parameter
24-
- IMAGE: noetic-source
25+
- IMAGE: rolling-source
2526
CXX: clang++
2627
CLANG_TIDY: true
2728
CXXFLAGS: >-
28-
-Werror -Wall -Wextra -Wwrite-strings -Wunreachable-code -Wpointer-arith -Wredundant-decls
29+
-Werror -Wall -Wextra -Wwrite-strings -Wunreachable-code -Wpointer-arith -Wno-redundant-decls
2930
-Wno-unused-parameter -Wno-unused-function -Wno-deprecated-copy
30-
- IMAGE: noetic-source
31+
# Add fast_unwind_on_malloc=0 to fix stacktraces being too short or do not make sense
32+
# see https://github.com/google/sanitizers/wiki/AddressSanitizer
33+
- IMAGE: rolling-source
3134
NAME: asan
3235
DOCKER_RUN_OPTS: >-
3336
-e PRELOAD=libasan.so.5
34-
-e LSAN_OPTIONS="suppressions=$PWD/.github/workflows/lsan.suppressions"
37+
-e LSAN_OPTIONS="suppressions=$PWD/.github/workflows/lsan.suppressions,fast_unwind_on_malloc=0"
3538
TARGET_CMAKE_ARGS: -DCMAKE_CXX_FLAGS="-fsanitize=address -fno-omit-frame-pointer -O1"
3639

3740
env:
38-
CATKIN_LINT: true
3941
CLANG_TIDY_ARGS: --fix --fix-errors --format-style=file
40-
DOCKER_IMAGE: moveit/moveit:${{ matrix.env.IMAGE }}
42+
DOCKER_IMAGE: ghcr.io/ros-planning/moveit2:${{ matrix.env.IMAGE }}
4143
UNDERLAY: /root/ws_moveit/install
42-
DOWNSTREAM_WORKSPACE: "github:ubi-agni/mtc_demos#master github:TAMS-Group/mtc_pour#master"
44+
# TODO: Port to ROS2
45+
# DOWNSTREAM_WORKSPACE: "github:ubi-agni/mtc_demos#master github:TAMS-Group/mtc_pour#master"
46+
UPSTREAM_WORKSPACE: .repos
4347
CCACHE_DIR: ${{ github.workspace }}/.ccache
4448
BASEDIR: ${{ github.workspace }}/.work
4549
CACHE_PREFIX: "${{ matrix.env.IMAGE }}${{ contains(matrix.env.TARGET_CMAKE_ARGS, '--coverage') && '-ccov' || '' }}"
@@ -48,7 +52,7 @@ jobs:
4852
CC: ${{ matrix.env.CLANG_TIDY && 'clang' }}
4953
CXX: ${{ matrix.env.CLANG_TIDY && 'clang++' }}
5054

51-
name: "${{ matrix.env.IMAGE }}${{ matrix.env.NAME && ' • ' || ''}}${{ matrix.env.NAME }}${{ matrix.env.CATKIN_LINT && ' • catkin_lint' || ''}}${{ matrix.env.CLANG_TIDY && ' • clang-tidy' || '' }}"
55+
name: "${{ matrix.env.IMAGE }}${{ matrix.env.NAME && ' • ' || ''}}${{ matrix.env.NAME }}${{ matrix.env.CLANG_TIDY && ' • clang-tidy' || '' }}"
5256
runs-on: ubuntu-latest
5357
steps:
5458
- uses: actions/checkout@v2

.github/workflows/format.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ jobs:
1717
- uses: actions/setup-python@v2
1818
- name: Install clang-format-10
1919
run: sudo apt-get install clang-format-10
20-
- uses: rhaschke/[email protected]
21-
with:
22-
distro: noetic
2320
- uses: pre-commit/[email protected]
2421
id: precommit
2522
- name: Upload pre-commit changes

.pre-commit-config.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,3 @@ repos:
4242
language: system
4343
files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|proto|vert)$
4444
args: ['-fallback-style=none', '-i']
45-
- id: catkin_lint
46-
name: catkin_lint
47-
description: Check package.xml and cmake files
48-
entry: catkin_lint .
49-
language: system
50-
always_run: true
51-
pass_filenames: false

.repos

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
repositories:
2+
rosparam_shortcuts:
3+
type: git
4+
url: https://github.com/PickNikRobotics/rosparam_shortcuts
5+
version: ros2

capabilities/CMakeLists.txt

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,38 @@
1-
cmake_minimum_required(VERSION 3.1.3)
1+
cmake_minimum_required(VERSION 3.5)
22
project(moveit_task_constructor_capabilities)
33

4-
add_compile_options(-std=c++14)
4+
add_compile_options(-std=c++17)
55

6-
find_package(catkin REQUIRED COMPONENTS
7-
actionlib
8-
moveit_core
9-
moveit_ros_move_group
10-
moveit_task_constructor_core
11-
moveit_task_constructor_msgs
12-
pluginlib
13-
std_msgs
14-
)
15-
16-
catkin_package(
17-
LIBRARIES $PROJECT_NAME}
18-
CATKIN_DEPENDS
19-
actionlib
20-
moveit_task_constructor_msgs
21-
std_msgs
22-
)
6+
find_package(ament_cmake REQUIRED)
237

24-
include_directories(
25-
${catkin_INCLUDE_DIRS}
26-
)
8+
find_package(Boost REQUIRED)
9+
find_package(rclcpp_action REQUIRED)
10+
find_package(moveit_core REQUIRED)
11+
find_package(moveit_ros_move_group REQUIRED)
12+
find_package(moveit_task_constructor_msgs REQUIRED)
13+
find_package(pluginlib REQUIRED)
14+
find_package(std_msgs REQUIRED)
2715

28-
add_library(${PROJECT_NAME}
16+
add_library(${PROJECT_NAME} SHARED
2917
src/execute_task_solution_capability.cpp
3018
)
31-
add_dependencies(${PROJECT_NAME} ${catkin_EXPORTED_TARGETS})
32-
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES})
19+
ament_target_dependencies(${PROJECT_NAME}
20+
Boost
21+
rclcpp_action
22+
moveit_core
23+
moveit_ros_move_group
24+
moveit_task_constructor_msgs
25+
)
3326

3427
install(TARGETS ${PROJECT_NAME}
35-
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
28+
LIBRARY DESTINATION lib
3629
)
3730

38-
install(FILES capabilities_plugin_description.xml
39-
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
40-
)
31+
pluginlib_export_plugin_description_file(moveit_ros_move_group capabilities_plugin_description.xml)
32+
ament_export_dependencies(rclcpp_action)
33+
ament_export_dependencies(moveit_core)
34+
ament_export_dependencies(moveit_ros_move_group)
35+
ament_export_dependencies(moveit_task_constructor_msgs)
36+
ament_export_dependencies(pluginlib)
37+
ament_export_dependencies(std_msgs)
38+
ament_package()

capabilities/capabilities_plugin_description.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<library path="libmoveit_task_constructor_capabilities">
1+
<library path="moveit_task_constructor_capabilities">
22
<class name="move_group/ExecuteTaskSolutionCapability" type="move_group::ExecuteTaskSolutionCapability" base_class_type="move_group::MoveGroupCapability">
33
<description>
44
Action server to execute solutions generated through the MoveIt Task Constructor.

capabilities/package.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@
1010

1111
<license>BSD</license>
1212

13-
<buildtool_depend>catkin</buildtool_depend>
13+
<buildtool_depend>ament_cmake</buildtool_depend>
1414

1515
<depend>moveit_core</depend>
1616
<depend>moveit_ros_move_group</depend>
17-
<depend>actionlib</depend>
17+
<depend>moveit_ros_planning</depend>
18+
<depend>rclcpp_action</depend>
1819
<depend>pluginlib</depend>
1920
<depend>std_msgs</depend>
2021
<depend>moveit_task_constructor_core</depend>
2122
<depend>moveit_task_constructor_msgs</depend>
2223

2324
<export>
24-
<moveit_ros_move_group plugin="${prefix}/capabilities_plugin_description.xml"/>
25+
<build_type>ament_cmake</build_type>
2526
</export>
2627
</package>

capabilities/src/execute_task_solution_capability.cpp

Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@
3636

3737
#include "execute_task_solution_capability.h"
3838

39-
#include <moveit/task_constructor/moveit_compat.h>
40-
39+
#include <moveit/moveit_cpp/moveit_cpp.h>
4140
#include <moveit/plan_execution/plan_execution.h>
4241
#include <moveit/trajectory_processing/trajectory_tools.h>
4342
#include <moveit/kinematic_constraints/utils.h>
4443
#include <moveit/move_group/capability_names.h>
4544
#include <moveit/robot_state/conversions.h>
46-
#if MOVEIT_HAS_MESSAGE_CHECKS
4745
#include <moveit/utils/message_checks.h>
48-
#endif
46+
#include <moveit/moveit_cpp/moveit_cpp.h>
47+
48+
#include <boost/algorithm/string/join.hpp>
4949

5050
namespace {
5151

@@ -80,66 +80,71 @@ const moveit::core::JointModelGroup* findJointModelGroup(const moveit::core::Rob
8080
}
8181
} // namespace
8282

83+
static const rclcpp::Logger LOGGER = rclcpp::get_logger("moveit_task_constructor_visualization.execute_task_solution");
84+
8385
namespace move_group {
8486

8587
ExecuteTaskSolutionCapability::ExecuteTaskSolutionCapability() : MoveGroupCapability("ExecuteTaskSolution") {}
8688

8789
void ExecuteTaskSolutionCapability::initialize() {
8890
// configure the action server
89-
as_.reset(new actionlib::SimpleActionServer<moveit_task_constructor_msgs::ExecuteTaskSolutionAction>(
90-
root_node_handle_, "execute_task_solution",
91-
std::bind(&ExecuteTaskSolutionCapability::goalCallback, this, std::placeholders::_1), false));
92-
as_->registerPreemptCallback(std::bind(&ExecuteTaskSolutionCapability::preemptCallback, this));
93-
as_->start();
91+
as_ = rclcpp_action::create_server<moveit_task_constructor_msgs::action::ExecuteTaskSolution>(
92+
context_->moveit_cpp_->getNode(), "execute_task_solution",
93+
ActionServerType::GoalCallback(std::bind(&ExecuteTaskSolutionCapability::handleNewGoal, this,
94+
std::placeholders::_1, std::placeholders::_2)),
95+
ActionServerType::CancelCallback(
96+
std::bind(&ExecuteTaskSolutionCapability::preemptCallback, this, std::placeholders::_1)),
97+
ActionServerType::AcceptedCallback(
98+
std::bind(&ExecuteTaskSolutionCapability::goalCallback, this, std::placeholders::_1)));
9499
}
95100

96101
void ExecuteTaskSolutionCapability::goalCallback(
97-
const moveit_task_constructor_msgs::ExecuteTaskSolutionGoalConstPtr& goal) {
98-
moveit_task_constructor_msgs::ExecuteTaskSolutionResult result;
102+
const std::shared_ptr<rclcpp_action::ServerGoalHandle<ExecuteTaskSolutionAction>> goal_handle) {
103+
auto result = std::make_shared<moveit_task_constructor_msgs::action::ExecuteTaskSolution::Result>();
99104

105+
const auto& goal = goal_handle->get_goal();
100106
if (!context_->plan_execution_) {
101-
const std::string response = "Cannot execute solution. ~allow_trajectory_execution was set to false";
102-
result.error_code.val = moveit_msgs::MoveItErrorCodes::CONTROL_FAILED;
103-
as_->setAborted(result, response);
107+
result->error_code.val = moveit_msgs::msg::MoveItErrorCodes::CONTROL_FAILED;
108+
goal_handle->abort(result);
104109
return;
105110
}
106111

107112
plan_execution::ExecutableMotionPlan plan;
108113
if (!constructMotionPlan(goal->solution, plan))
109-
result.error_code.val = moveit_msgs::MoveItErrorCodes::INVALID_MOTION_PLAN;
114+
result->error_code.val = moveit_msgs::msg::MoveItErrorCodes::INVALID_MOTION_PLAN;
110115
else {
111-
ROS_INFO_NAMED("ExecuteTaskSolution", "Executing TaskSolution");
112-
result.error_code = context_->plan_execution_->executeAndMonitor(plan);
116+
RCLCPP_INFO(LOGGER, "Executing TaskSolution");
117+
result->error_code = context_->plan_execution_->executeAndMonitor(plan);
113118
}
114119

115-
const std::string response = context_->plan_execution_->getErrorCodeString(result.error_code);
116-
117-
if (result.error_code.val == moveit_msgs::MoveItErrorCodes::SUCCESS)
118-
as_->setSucceeded(result, response);
119-
else if (result.error_code.val == moveit_msgs::MoveItErrorCodes::PREEMPTED)
120-
as_->setPreempted(result, response);
120+
if (result->error_code.val == moveit_msgs::msg::MoveItErrorCodes::SUCCESS)
121+
goal_handle->succeed(result);
122+
else if (result->error_code.val == moveit_msgs::msg::MoveItErrorCodes::PREEMPTED)
123+
goal_handle->canceled(result);
121124
else
122-
as_->setAborted(result, response);
125+
goal_handle->abort(result);
123126
}
124127

125-
void ExecuteTaskSolutionCapability::preemptCallback() {
128+
rclcpp_action::CancelResponse ExecuteTaskSolutionCapability::preemptCallback(
129+
const std::shared_ptr<rclcpp_action::ServerGoalHandle<ExecuteTaskSolutionAction>> goal_handle) {
126130
if (context_->plan_execution_)
127131
context_->plan_execution_->stop();
132+
return rclcpp_action::CancelResponse::ACCEPT;
128133
}
129134

130-
bool ExecuteTaskSolutionCapability::constructMotionPlan(const moveit_task_constructor_msgs::Solution& solution,
135+
bool ExecuteTaskSolutionCapability::constructMotionPlan(const moveit_task_constructor_msgs::msg::Solution& solution,
131136
plan_execution::ExecutableMotionPlan& plan) {
132-
robot_model::RobotModelConstPtr model = context_->planning_scene_monitor_->getRobotModel();
137+
moveit::core::RobotModelConstPtr model = context_->planning_scene_monitor_->getRobotModel();
133138

134-
robot_state::RobotState state(model);
139+
moveit::core::RobotState state(model);
135140
{
136141
planning_scene_monitor::LockedPlanningSceneRO scene(context_->planning_scene_monitor_);
137142
state = scene->getCurrentState();
138143
}
139144

140145
plan.plan_components_.reserve(solution.sub_trajectory.size());
141146
for (size_t i = 0; i < solution.sub_trajectory.size(); ++i) {
142-
const moveit_task_constructor_msgs::SubTrajectory& sub_traj = solution.sub_trajectory[i];
147+
const moveit_task_constructor_msgs::msg::SubTrajectory& sub_traj = solution.sub_trajectory[i];
143148

144149
plan.plan_components_.emplace_back();
145150
plan_execution::ExecutableTrajectory& exec_traj = plan.plan_components_.back();
@@ -156,12 +161,11 @@ bool ExecuteTaskSolutionCapability::constructMotionPlan(const moveit_task_constr
156161
if (!joint_names.empty()) {
157162
group = findJointModelGroup(*model, joint_names);
158163
if (!group) {
159-
ROS_ERROR_STREAM_NAMED("ExecuteTaskSolution", "Could not find JointModelGroup that actuates {"
160-
<< boost::algorithm::join(joint_names, ", ") << "}");
164+
RCLCPP_ERROR_STREAM(LOGGER, "Could not find JointModelGroup that actuates {"
165+
<< boost::algorithm::join(joint_names, ", ") << "}");
161166
return false;
162167
}
163-
ROS_DEBUG_NAMED("ExecuteTaskSolution", "Using JointModelGroup '%s' for execution",
164-
group->getName().c_str());
168+
RCLCPP_DEBUG(LOGGER, "Using JointModelGroup '%s' for execution", group->getName().c_str());
165169
}
166170
}
167171
exec_traj.trajectory_ = std::make_shared<robot_trajectory::RobotTrajectory>(model, group);
@@ -170,25 +174,16 @@ bool ExecuteTaskSolutionCapability::constructMotionPlan(const moveit_task_constr
170174
/* TODO add action feedback and markers */
171175
exec_traj.effect_on_success_ = [this, sub_traj,
172176
description](const plan_execution::ExecutableMotionPlan* /*plan*/) {
173-
#if MOVEIT_HAS_MESSAGE_CHECKS
174177
if (!moveit::core::isEmpty(sub_traj.scene_diff)) {
175-
#else
176-
if (!planning_scene::PlanningScene::isEmpty(sub_traj.scene_diff)) {
177-
#endif
178-
ROS_DEBUG_STREAM_NAMED("ExecuteTaskSolution", "apply effect of " << description);
178+
RCLCPP_DEBUG_STREAM(LOGGER, "apply effect of " << description);
179179
return context_->planning_scene_monitor_->newPlanningSceneMessage(sub_traj.scene_diff);
180180
}
181181
return true;
182182
};
183183

184-
#if MOVEIT_HAS_MESSAGE_CHECKS
185184
if (!moveit::core::isEmpty(sub_traj.scene_diff.robot_state) &&
186-
#else
187-
if (!planning_scene::PlanningScene::isEmpty(sub_traj.scene_diff.robot_state) &&
188-
#endif
189185
!moveit::core::robotStateMsgToRobotState(sub_traj.scene_diff.robot_state, state, true)) {
190-
ROS_ERROR_STREAM_NAMED("ExecuteTaskSolution",
191-
"invalid intermediate robot state in scene diff of SubTrajectory " << description);
186+
RCLCPP_ERROR_STREAM(LOGGER, "invalid intermediate robot state in scene diff of SubTrajectory " << description);
192187
return false;
193188
}
194189
}

capabilities/src/execute_task_solution_capability.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
#pragma once
4343

4444
#include <moveit/move_group/move_group_capability.h>
45-
#include <actionlib/server/simple_action_server.h>
45+
#include <rclcpp_action/rclcpp_action.hpp>
4646

47-
#include <moveit_task_constructor_msgs/ExecuteTaskSolutionAction.h>
47+
#include <moveit_task_constructor_msgs/action/execute_task_solution.hpp>
4848

4949
#include <memory>
5050

@@ -58,13 +58,23 @@ class ExecuteTaskSolutionCapability : public MoveGroupCapability
5858
void initialize() override;
5959

6060
private:
61-
bool constructMotionPlan(const moveit_task_constructor_msgs::Solution& solution,
61+
using ExecuteTaskSolutionAction = moveit_task_constructor_msgs::action::ExecuteTaskSolution;
62+
using ActionServerType = rclcpp_action::Server<ExecuteTaskSolutionAction>;
63+
bool constructMotionPlan(const moveit_task_constructor_msgs::msg::Solution& solution,
6264
plan_execution::ExecutableMotionPlan& plan);
6365

64-
void goalCallback(const moveit_task_constructor_msgs::ExecuteTaskSolutionGoalConstPtr& goal);
65-
void preemptCallback();
66+
void goalCallback(const std::shared_ptr<rclcpp_action::ServerGoalHandle<ExecuteTaskSolutionAction>> goal_handle);
6667

67-
std::unique_ptr<actionlib::SimpleActionServer<moveit_task_constructor_msgs::ExecuteTaskSolutionAction>> as_;
68+
rclcpp_action::CancelResponse
69+
preemptCallback(const std::shared_ptr<rclcpp_action::ServerGoalHandle<ExecuteTaskSolutionAction>> goal_handle);
70+
71+
/** Always accept the goal */
72+
rclcpp_action::GoalResponse handleNewGoal(const rclcpp_action::GoalUUID& uuid,
73+
const ExecuteTaskSolutionAction::Goal::ConstSharedPtr goal) const {
74+
return rclcpp_action::GoalResponse::ACCEPT_AND_EXECUTE;
75+
}
76+
77+
ActionServerType::SharedPtr as_;
6878
};
6979

7080
} // namespace move_group

0 commit comments

Comments
 (0)