16 #include <ompl/geometric/SimpleSetup.h>
17 #include <ompl/geometric/planners/rrt/RRTConnect.h>
30 auto world = std::make_shared<darts::World>();
32 "package://fetch_description/robots/fetch.urdf",
33 "package://fetch_moveit_config/config/fetch.srdf");
34 auto fetch2 = fetch1->cloneRobot(
"fetch2");
35 fetch2->setDof(2, -1.57);
36 fetch2->setDof(3, radius);
37 fetch2->setDof(4, radius);
42 auto scene = std::make_shared<darts::Structure>(
"object");
44 dart::dynamics::FreeJoint::Properties joint;
46 joint.mT_ParentBodyToJoint.translation() = Eigen::Vector3d(radius, 0, height);
50 world->addRobot(fetch1);
51 world->addRobot(fetch2);
52 world->addStructure(
scene);
59 const auto &touch = [&] {
61 builder.
addGroup(
"fetch1",
"arm_with_torso");
62 builder.
addGroup(
"fetch2",
"arm_with_torso");
65 0.05, 1.32, 1.40, -0.2, 1.72, 0.0, 1.66, 0.0,
66 0.05, 1.32, 1.40, -0.2, 1.72, 0.0, 1.66, 0.0,
72 goal1_spec.
setFrame(
"fetch1",
"wrist_roll_link",
"base_link");
73 goal1_spec.
setPose(0.5, 0, height - 0.1,
77 goal2_spec.
setFrame(
"fetch2",
"wrist_roll_link",
"base_link");
78 goal2_spec.
setPose(0.5, 0, height - 0.1,
81 auto goal1_tsr = std::make_shared<darts::TSR>(world, goal1_spec);
82 auto goal2_tsr = std::make_shared<darts::TSR>(world, goal2_spec);
83 auto goal = builder.
getGoalTSR({goal1_tsr, goal2_tsr});
86 auto rrt = std::make_shared<ompl::geometric::RRTConnect>(builder.
info,
true);
88 builder.
ss->setPlanner(rrt);
92 goal->options.max_samples = 1;
93 goal->startSampling();
94 ompl::base::PlannerStatus solved = builder.
ss->solve(60.0);
105 return solved == ompl::base::PlannerStatus::EXACT_SOLUTION;
111 const auto &lift = [&] {
113 builder.
addGroup(
"fetch1",
"arm_with_torso");
114 builder.
addGroup(
"fetch2",
"arm_with_torso");
119 con1_spec.
setTarget(
"fetch2",
"wrist_roll_link");
120 con1_spec.
setBase(
"fetch1",
"wrist_roll_link");
122 auto con1_tsr = std::make_shared<darts::TSR>(world, con1_spec);
126 con2_spec.
setFrame(
"fetch1",
"wrist_roll_link",
"base_link");
133 auto con2_tsr = std::make_shared<darts::TSR>(world, con2_spec);
139 goal_spec.
setFrame(
"fetch1",
"wrist_roll_link",
"base_link");
140 goal_spec.
setPose(0.5, 0, height +
raise,
141 0.707, 0, -0.707, 0);
142 auto goal_tsr = std::make_shared<darts::TSR>(world, goal_spec);
146 auto rrt = std::make_shared<ompl::geometric::RRTConnect>(builder.
info,
true);
148 builder.
ss->setPlanner(rrt);
152 goal->options.max_samples = 100;
153 goal->startSampling();
154 ompl::base::PlannerStatus solved = builder.
ss->solve(240.0);
155 goal->stopSampling();
165 return solved == ompl::base::PlannerStatus::EXACT_SOLUTION;
171 const auto &lower = [&] {
173 builder.
addGroup(
"fetch1",
"arm_with_torso");
174 builder.
addGroup(
"fetch2",
"arm_with_torso");
179 con1_spec.
setTarget(
"fetch2",
"wrist_roll_link");
180 con1_spec.
setBase(
"fetch1",
"wrist_roll_link");
182 auto con1_tsr = std::make_shared<darts::TSR>(world, con1_spec);
186 con2_spec.
setFrame(
"fetch1",
"wrist_roll_link",
"base_link");
193 auto con2_tsr = std::make_shared<darts::TSR>(world, con2_spec);
199 goal_spec.
setFrame(
"fetch1",
"wrist_roll_link",
"base_link");
200 goal_spec.
setPose(0.5, 0, height - 0.1,
201 0.707, 0, -0.707, 0);
202 auto goal_tsr = std::make_shared<darts::TSR>(world, goal_spec);
206 auto rrt = std::make_shared<ompl::geometric::RRTConnect>(builder.
info,
true);
208 builder.
ss->setPlanner(rrt);
212 goal->options.max_samples = 100;
213 goal->startSampling();
214 ompl::base::PlannerStatus solved = builder.
ss->solve(240.0);
215 goal->stopSampling();
225 return solved == ompl::base::PlannerStatus::EXACT_SOLUTION;
231 const auto &tuck = [&] {
233 builder.
addGroup(
"fetch1",
"arm_with_torso");
234 builder.
addGroup(
"fetch2",
"arm_with_torso");
241 0.05, 1.32, 1.40, -0.2, 1.72, 0.0, 1.66, 0.0,
242 0.05, 1.32, 1.40, -0.2, 1.72, 0.0, 1.66, 0.0,
246 auto rrt = std::make_shared<ompl::geometric::RRTConnect>(builder.
info,
true);
248 builder.
ss->setPlanner(rrt);
252 ompl::base::PlannerStatus solved = builder.
ss->solve(60.0);
262 return solved == ompl::base::PlannerStatus::EXACT_SOLUTION;
276 fetch1->reparentFreeFrame(
cube,
"wrist_roll_link");
A helper class to setup common OMPL structures for planning.
void setGoal(const ompl::base::GoalPtr &goal)
Set the goal for the problem.
void setStartConfigurationFromWorld()
Set the start configuration from the current state of the world.
void addConstraint(const TSRPtr &tsr)
Adds a TSR as a path constraint to the problem.
void setup()
Calls setup routines on OMPL structures. Call after all setup is done and builder is initialized.
void setStartConfiguration(const Eigen::Ref< const Eigen::VectorXd > &q)
Set the start configuration from a configuration.
void initialize()
Initialize OMPL structures. Only call this once all constraints, groups, and other parameters have be...
ompl::base::SpaceInformationPtr info
Actual Space Information.
TSRGoalPtr getGoalTSR(const TSRPtr &tsr)
Set a TSR as the goal for the planning problem (will create a TSRGoal)
ompl::geometric::PathGeometric getSolutionPath(bool simplify=true, bool interpolate=true) const
Get the solution path from a successful plan.
ompl::geometric::SimpleSetupPtr ss
Simple Setup.
void addGroup(const std::string &robot, const std::string &name, std::size_t cyclic=0)
Add a robot's planning group to the controlled DoF in the state space.
std::shared_ptr< ompl::base::GoalStates > getGoalConfiguration(const Eigen::Ref< const Eigen::VectorXd > &q)
Set the goal configuration from a configuration.
The specification of a TSR.
void setTarget(const std::string &structure, const std::string &frame)
Setting TSR Frame.
void setBase(const std::string &structure, const std::string &frame)
Set the base frame.
void setPose(const RobotPose &other)
Set the pose of the TSR.
void setFrame(const std::string &structure, const std::string &target, const std::string &base=magic::ROOT_FRAME)
Set the base and target frame.
void setNoPosTolerance()
Set no position tolerance at all.
void setYRotTolerance(double bound)
Set the Y orientation tolerance to (-bound, bound).
void setNoZRotTolerance()
Set no orientation tolerance on the Z-axis.
void setXRotTolerance(double bound)
Setting Orientation Tolerances.
void setPoseFromWorld(const WorldPtr &world)
Set the pose of the TSR for the desired frame in a provided world. Uses world's current configuration...
Open Scene Graph GUI for DART visualization.
void run(std::function< void()> thread={})
Run the GUI. Blocks.
void animatePath(const StateSpacePtr &space, const ompl::geometric::PathGeometric &path, std::size_t times=1, double fps=60, bool block=true)
Animate a motion plan using the world.
#define RBX_WARN(fmt,...)
Output a warning logging message.
#define RBX_INFO(fmt,...)
Output a info logging message.
RobotPtr loadMoveItRobot(const std::string &name, const std::string &urdf, const std::string &srdf)
Load a robot from a URDF and SRDF (i.e., a MoveIt enabled robot).
std::shared_ptr< dart::dynamics::BoxShape > makeBox(const Eigen::Ref< const Eigen::Vector3d > &v)
Create a box.
Main namespace. Contains all library classes and functions.
Functions for loading and animating scenes in Blender.