Robowflex  v0.1
Making MoveIt Easy
tsr_helper.cpp
Go to the documentation of this file.
1 /* Author: Zachary Kingston */
2 
3 #include <chrono>
4 #include <thread>
5 
7 
8 #include <robowflex_dart/gui.h>
9 #include <robowflex_dart/io.h>
10 #include <robowflex_dart/robot.h>
11 #include <robowflex_dart/space.h>
12 #include <robowflex_dart/tsr.h>
13 #include <robowflex_dart/world.h>
14 
15 using namespace robowflex;
16 
17 int main(int argc, char **argv)
18 {
19  int n = 1;
20  if (argc > 1)
21  n = std::atoi(argv[1]);
22 
23  if (n < 3)
24  {
25  auto world = std::make_shared<darts::World>();
26 
27  auto fetch1 = darts::loadMoveItRobot("fetch1", //
28  "package://fetch_description/robots/fetch.urdf", //
29  "package://fetch_moveit_config/config/fetch.srdf");
30  auto start = fetch1->getSkeleton()->getState();
31  world->addRobot(fetch1);
32 
33  darts::Window window(world);
34 
35  if (n == 2)
36  {
38  spec1.setFrame("fetch1", "wrist_roll_link", "base_link");
39  spec1.pose = fetch1->getFrame("wrist_roll_link")->getWorldTransform();
40  spec1.setXPosTolerance(0.05);
41  spec1.setYPosTolerance(0.05);
42  spec1.setZPosTolerance(0.05);
43  // spec1.setNoRotTolerance();
44  auto ew1 = std::make_shared<darts::TSREditWidget>("EE", spec1);
45  window.addWidget(ew1);
46 
48  spec2.setFrame("fetch1", "elbow_flex_link", "base_link");
49  spec2.pose = fetch1->getFrame("elbow_flex_link")->getWorldTransform();
50  // spec2.setNoRotTolerance();
51  spec2.setXPosTolerance(0.05);
52  spec2.setYPosTolerance(0.05);
53  spec2.setZPosTolerance(0.05);
54  auto ew2 = std::make_shared<darts::TSREditWidget>("Elbow", spec2);
55  window.addWidget(ew2);
56 
57  std::vector<darts::TSRPtr> tsrs{ew1->getTSR(), ew2->getTSR()};
58  auto sw = std::make_shared<darts::TSRSolveWidget>(world, tsrs);
59  window.addWidget(sw);
60  }
61  else
62  {
64  spec.setFrame("fetch1", "wrist_roll_link", "base_link");
65  spec.pose = fetch1->getFrame("wrist_roll_link")->getWorldTransform();
66  auto ew = std::make_shared<darts::TSREditWidget>("EE", spec);
67  window.addWidget(ew);
68 
69  std::vector<darts::TSRPtr> tsrs{ew->getTSR()};
70  auto sw = std::make_shared<darts::TSRSolveWidget>(world, tsrs);
71  window.addWidget(sw);
72  }
73 
74  window.run();
75  }
76 
77  return 0;
78 }
T atoi(T... args)
The specification of a TSR.
Definition: tsr.h:70
void setFrame(const std::string &structure, const std::string &target, const std::string &base=magic::ROOT_FRAME)
Set the base and target frame.
Definition: tsr.cpp:48
void setYPosTolerance(double bound)
Set the Y position tolerance to (-bound, bound).
Definition: tsr.cpp:133
RobotPose pose
Pose of TSR.
Definition: tsr.h:86
void setXPosTolerance(double bound)
Setting Position Tolerances.
Definition: tsr.cpp:128
void setZPosTolerance(double bound)
Set the Z position tolerance to (-bound, bound).
Definition: tsr.cpp:138
Open Scene Graph GUI for DART visualization.
Definition: gui.h:67
void run(std::function< void()> thread={})
Run the GUI. Blocks.
Definition: gui.cpp:231
void addWidget(const WidgetPtr &widget)
Add a new IMGUI widget.
Definition: gui.cpp:106
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).
Main namespace. Contains all library classes and functions.
Definition: scene.cpp:25
int main(int argc, char **argv)
Definition: tsr_helper.cpp:17