alternative_path_costs.cpp
Go to the documentation of this file.
1 #include <ros/ros.h>
2 
4 
7 
9 
12 
14 
15 using namespace moveit::task_constructor;
16 
17 /* FixedState - Connect - FixedState */
18 int main(int argc, char** argv) {
19  ros::init(argc, argv, "mtc_tutorial");
20 
21  Task t;
22  t.stages()->setName("alternative path costs");
23  t.loadRobotModel();
24 
25  assert(t.getRobotModel()->getName() == "panda");
26 
27  auto scene{ std::make_shared<planning_scene::PlanningScene>(t.getRobotModel()) };
28  auto& robot_state{ scene->getCurrentStateNonConst() };
29  robot_state.setToDefaultValues();
30  robot_state.setToDefaultValues(robot_state.getJointModelGroup("panda_arm"), "extended");
31 
32  auto initial{ std::make_unique<stages::FixedState>("start") };
33  initial->setState(scene);
34  t.add(std::move(initial));
35 
36  auto pipeline{ std::make_shared<solvers::PipelinePlanner>() };
37 
38  auto alternatives{ std::make_unique<Alternatives>("connect") };
39  {
40  auto connect{ std::make_unique<stages::Connect>(
41  "path length", stages::Connect::GroupPlannerVector{ { "panda_arm", pipeline } }) };
42  connect->setCostTerm(std::make_unique<cost::PathLength>()); // This is the default for Connect, specified for
43  // demonstration purposes
45  }
46  {
47  auto connect{ std::make_unique<stages::Connect>(
48  "trajectory duration", stages::Connect::GroupPlannerVector{ { "panda_arm", pipeline } }) };
49  connect->setCostTerm(std::make_unique<cost::TrajectoryDuration>());
51  }
52  {
53  auto connect{ std::make_unique<stages::Connect>(
54  "eef motion", stages::Connect::GroupPlannerVector{ { "panda_arm", pipeline } }) };
55  connect->setCostTerm(std::make_unique<cost::LinkMotion>("panda_hand"));
57  }
58  {
59  auto connect{ std::make_unique<stages::Connect>(
60  "elbow motion", stages::Connect::GroupPlannerVector{ { "panda_arm", pipeline } }) };
61  connect->setCostTerm(std::make_unique<cost::LinkMotion>("panda_link4"));
63  }
64 
65  t.add(std::move(alternatives));
66 
67  auto goal_scene{ scene->diff() };
68  goal_scene->getCurrentStateNonConst().setToDefaultValues(robot_state.getJointModelGroup("panda_arm"), "ready");
69  auto goal = std::make_unique<stages::FixedState>("goal");
70  goal->setState(goal_scene);
71  t.add(std::move(goal));
72 
73  try {
74  t.plan(0);
75  } catch (const InitStageException& e) {
76  std::cout << e << '\n';
77  }
78 
79  ros::spin();
80 
81  return 0;
82 }
main
int main(int argc, char **argv)
Definition: alternative_path_costs.cpp:18
pipeline_planner.h
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
ros.h
moveit::task_constructor::InitStageException
moveit::task_constructor::stages::Connect::GroupPlannerVector
std::vector< std::pair< std::string, solvers::PlannerInterfacePtr > > GroupPlannerVector
connect.h
moveit::task_constructor::Task
container.h
pickplace.pipeline
pipeline
Definition: pickplace.py:55
generate_pose.connect
connect
Definition: generate_pose.py:29
moveit::task_constructor
task.h
planning_scene.h
cartesian.move
move
Definition: cartesian.py:34
fixed_state.h
alternatives
Definition: alternatives.py:1
ros::spin
ROSCPP_DECL void spin()
cost_terms.h
t
dictionary t


demo
Author(s): Robert Haschke , Simon Goldstein , Henning Kayser
autogenerated on Sat May 3 2025 02:40:30