Skip to content

Commit cb19033

Browse files
author
AndyZe
authored
Do execution from moveit_cpp, add an explicit list of controllers (#563)
* Use MoveItCpp to execute trajectories, not PlanningComponents * API update * const
1 parent 625b283 commit cb19033

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

doc/examples/moveit_cpp/src/moveit_cpp_tutorial.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ int main(int argc, char** argv)
4040
//
4141
static const std::string PLANNING_GROUP = "panda_arm";
4242
static const std::string LOGNAME = "moveit_cpp_tutorial";
43+
// ros2_controllers
44+
static const std::vector<std::string> CONTROLLERS(1, "panda_arm_controller");
4345

4446
/* Otherwise robot with zeros joint_states */
4547
rclcpp::sleep_for(std::chrono::seconds(1));
@@ -95,7 +97,7 @@ int main(int argc, char** argv)
9597

9698
// Now, we call the PlanningComponents to compute the plan and visualize it.
9799
// Note that we are just planning
98-
auto plan_solution1 = planning_components->plan();
100+
const planning_interface::MotionPlanResponse plan_solution1 = planning_components->plan();
99101

100102
// Check if PlanningComponents succeeded in finding the plan
101103
if (plan_solution1)
@@ -110,7 +112,8 @@ int main(int argc, char** argv)
110112
visual_tools.trigger();
111113

112114
/* Uncomment if you want to execute the plan */
113-
/* planning_components->execute(); // Execute the plan */
115+
/* bool blocking = true; */
116+
/* moveit_controller_manager::ExecutionStatus result = moveit_cpp_ptr->execute(plan_solution1.trajectory_, blocking, CONTROLLERS); */
114117
}
115118

116119
// Plan #1 visualization:
@@ -154,7 +157,8 @@ int main(int argc, char** argv)
154157
visual_tools.trigger();
155158

156159
/* Uncomment if you want to execute the plan */
157-
/* planning_components->execute(); // Execute the plan */
160+
/* bool blocking = true; */
161+
/* moveit_cpp_ptr->execute(plan_solution2.trajectory_, blocking, CONTROLLERS); */
158162
}
159163

160164
// Plan #2 visualization:
@@ -198,7 +202,8 @@ int main(int argc, char** argv)
198202
visual_tools.trigger();
199203

200204
/* Uncomment if you want to execute the plan */
201-
/* planning_components->execute(); // Execute the plan */
205+
/* bool blocking = true; */
206+
/* moveit_cpp_ptr->execute(plan_solution3.trajectory_, blocking, CONTROLLERS); */
202207
}
203208

204209
// Plan #3 visualization:
@@ -240,7 +245,8 @@ int main(int argc, char** argv)
240245
visual_tools.trigger();
241246

242247
/* Uncomment if you want to execute the plan */
243-
/* planning_components->execute(); // Execute the plan */
248+
/* bool blocking = true; */
249+
/* moveit_cpp_ptr->execute(plan_solution4.trajectory_, blocking, CONTROLLERS); */
244250
}
245251

246252
// Plan #4 visualization:
@@ -293,7 +299,8 @@ int main(int argc, char** argv)
293299
visual_tools.trigger();
294300

295301
/* Uncomment if you want to execute the plan */
296-
/* planning_components->execute(); // Execute the plan */
302+
/* bool blocking = true; */
303+
/* moveit_cpp_ptr->execute(plan_solution5.trajectory_, blocking, CONTROLLERS); */
297304
}
298305

299306
// Plan #5 visualization:

doc/how_to_guides/parallel_planning/src/parallel_planning_main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace
2222
{
2323
const rclcpp::Logger LOGGER = rclcpp::get_logger("parallel_planning_example");
2424
const std::string PLANNING_GROUP = "panda_arm";
25+
static const std::vector<std::string> CONTROLLERS(1, "panda_arm_controller");
2526
} // namespace
2627
namespace parallel_planning_example
2728
{
@@ -241,7 +242,8 @@ class Demo
241242
visual_tools_.trigger();
242243
}
243244

244-
planning_component_->execute();
245+
// Execute the trajectory and block until it's finished
246+
moveit_cpp_->execute(plan_solution.trajectory_, true /* blocking*/, CONTROLLERS);
245247

246248
// Start the next plan
247249
visual_tools_.prompt("Press 'next' in the RvizVisualToolsGui window to continue the demo");

0 commit comments

Comments
 (0)