Robowflex  v0.1
Making MoveIt Easy
gui.h
Go to the documentation of this file.
1 /* Author: Zachary Kingston */
2 
3 #ifndef ROBOWFLEX_DART_GUI_
4 #define ROBOWFLEX_DART_GUI_
5 
6 #include <mutex>
7 
8 #include <dart/external/imgui/imgui.h>
9 #include <dart/gui/osg/ImGuiWidget.hpp>
10 #include <dart/gui/osg/osg.hpp>
11 
14 
15 #include <robowflex_dart/world.h>
16 #include <robowflex_dart/space.h>
17 #include <robowflex_dart/tsr.h>
19 
20 namespace robowflex
21 {
22  namespace darts
23  {
24  /** \cond IGNORE */
27  ROBOWFLEX_CLASS_FORWARD(WindowWidget)
28  ROBOWFLEX_CLASS_FORWARD(TSREditWidget)
29  /** \endcond */
30 
31  /** \class robowflex::darts::WindowPtr
32  \brief A shared pointer wrapper for robowflex::darts::Window. */
33 
34  /** \class robowflex::darts::WindowConstPtr
35  \brief A const shared pointer wrapper for robowflex::darts::Window. */
36 
37  /** \class robowflex::darts::WindowWidgetPtr
38  \brief A shared pointer wrapper for robowflex::darts::WindowWidget. */
39 
40  /** \class robowflex::darts::WindowWidgetConstPtr
41  \brief A const shared pointer wrapper for robowflex::darts::WindowWidget. */
42 
43  /** \brief Generate a unique identifier.
44  * \return A random unique ID.
45  */
46  std::string generateUUID();
47 
48  /** \brief Viewer class.
49  */
50  class Viewer : public dart::gui::osg::ImGuiViewer
51  {
52  public:
53  /** \brief Constructor.
54  * \param[in] world World viewed.
55  */
56  Viewer(const WorldPtr &world);
57 
58  void updateTraversal() override;
59 
60  private:
61  WorldPtr world_; ///< World.
62  };
63 
64  /** \brief Open Scene Graph GUI for DART visualization.
65  */
66  class Window : public dart::gui::osg::WorldNode
67  {
68  friend TSREditWidget;
69 
70  public:
71  /** \brief Constructor.
72  * \param[in] world World to visualize.
73  */
74  Window(const WorldPtr &world);
75  void customPreRefresh() override;
76  void customPostRefresh() override;
77 
78  /** \name GUI Interaction
79  \{ */
80 
81  /** \brief Callback function on an interactive frame moving.
82  */
83  using InteractiveCallback = std::function<void(const dart::gui::osg::InteractiveFrame *)>;
84 
85  /** \brief Options for creating an interactive marker.
86  */
88  {
89  std::string name{"interactive_marker"}; ///< Name of marker.
90  Eigen::Isometry3d pose{Eigen::Isometry3d::Identity()}; ///< Relative pose of marker.
91  InteractiveCallback callback{}; ///< Callback function on motion.
92  dart::dynamics::Frame *parent{dart::dynamics::Frame::World()}; ///< Parent frame.
93  double size{0.2}; ///< Size of marker.
94  double thickness{2.}; ///< Thickness of marker arrows.
95  bool obstructable{false}; ///< Is this frame obstructable?
96 
97  bool linear[3]{true, true, true}; ///< Linear position controls enabled.
98  bool rotation[3]{true, true, true}; ///< Rotation ring controls enabled.
99  bool planar[3]{true, true, true}; ///< Planar translation controls enabled.
100 
101  /** \brief Disables all linear controls.
102  */
103  void disableLinearControls();
104 
105  /** \brief Disables all rotation controls.
106  */
108 
109  /** \brief Disables all planar controls.
110  */
111  void disablePlanarControls();
112 
113  /** \brief Disables all controls.
114  */
115  void disableControls();
116  };
117 
118  /** \brief Return from creating an interactive marker.
119  */
121  {
122  dart::gui::osg::InteractiveFramePtr target; ///< Interactive Frame generated.
123  dart::gui::osg::InteractiveFrameDnD *dnd; ///< Drag 'n Drop object.
124  dart::common::Connection signal; ///< Connection from motion to callback.
125  };
126 
127  /** \brief Create a new interactive marker in the GUI.
128  * \param[in] options Options for creating marker.
129  * \return The new marker.
130  */
132 
133  /** \brief Callback function on a drag 'n drop frame moving.
134  */
135  using DnDCallback = std::function<void(const dart::dynamics::BodyNode *)>;
136 
137  /** \brief Return from creating a movable frame.
138  */
139  struct DnDReturn
140  {
141  dart::gui::osg::BodyNodeDnD *dnd; ///< Drag 'n Drop object.
142  dart::common::Connection signal; ///< Connection from motion to callback.
143  };
144 
145  /** \brief Enable drag 'n drop functionality on a body node being visualized.
146  * With DnD, the body node will automatically use IK to move wherever dragged.
147  * \param[in] node Node to enable Drag 'n Drop on.
148  * \param[in] callback Callback function to call when node is dragged.
149  * \return The new drag 'n drop node.
150  */
151  DnDReturn enableNodeDragNDrop(dart::dynamics::BodyNode *node, const DnDCallback &callback = {});
152 
153  /** \} */
154 
155  /** \name Animation
156  \{ */
157 
158  /** \brief Animate a motion plan using the world.
159  * \param[in] space State space of the plan.
160  * \param[in] path The plan to visualize.
161  * \param[in] times Number of times to loop through animation.
162  * \param[in] fps Update rate.
163  * \param[in] block If true, blocks until animation is done. Otherwise, immediately returns.
164  */
165  void animatePath(const StateSpacePtr &space, const ompl::geometric::PathGeometric &path,
166  std::size_t times = 1, double fps = 60, bool block = true);
167 
168  /** \brief Animate a motion plan using the world.
169  * This version of the call will automatically visualize either constrained or unconstrained
170  * paths.
171  * \param[in] builder Plan builder structure. \param[in] path The plan to visualize.
172  * \param[in] times Number of times to loop through animation.
173  * \param[in] fps Update rate.
174  * \param[in] block If true, blocks until animation is done. Otherwise, immediately returns.
175  */
176  void animatePath(const PlanBuilder &builder, const ompl::geometric::PathGeometric &path,
177  std::size_t times = 1, double fps = 60, bool block = true);
178 
179  /** \} */
180 
181  /** \brief Run the GUI. Blocks.
182  * \param[in] thread Function to run in a separate thread from the GUI's visualization.
183  */
184  void run(std::function<void()> thread = {});
185 
186  /** \brief Get the IMGUI configurable widget.
187  */
189 
190  /** \brief Add a new IMGUI widget.
191  * \param[in] widget Widget to add.
192  */
193  void addWidget(const WidgetPtr &widget);
194 
195  /** \brief Get world used for visualization.
196  * \return World used by window.
197  */
198  WorldPtr getWorld();
199 
200  /** \brief Get world used for visualization.
201  * \return World used by window.
202  */
203  const WorldPtr &getWorldConst() const;
204 
205  private:
206  WorldPtr world_; ///< World to visualize.
207  WindowWidgetPtr widget_; ///< IMGUI widget.
208  std::vector<WidgetPtr> widgets_; ///< Other widgets;
209 
210  std::shared_ptr<std::thread> animation_{nullptr}; ///< Animation thread.
211 
212  ::osg::ref_ptr<Window> node_; ///< OSG Node.
213  Viewer viewer_; ///< Viewer
214  };
215 
216  /** \brief Abstract class for IMGUI Widget.
217  */
218  class Widget : public dart::gui::osg::ImGuiWidget
219  {
220  public:
221  /** \brief Initialization with window context.
222  * \param[in] window GUI window.
223  */
224  virtual void initialize(Window *window);
225 
226  /** \brief Called before window refresh.
227  */
228  virtual void prerefresh();
229  };
230 
231  /** \cond IGNORE */
233  /** \endcond */
234 
235  /** \class robowflex::darts::ImGuiElementPtr
236  \brief A shared pointer wrapper for robowflex::darts::WindowWidget::Element. */
237 
238  /** \class robowflex::darts::ImGuiElementConstPtr
239  \brief A const shared pointer wrapper for robowflex::darts::WindowWidget::Element. */
240 
241  /** \brief Abstract GUI element.
242  */
244  {
245  public:
246  /** \brief Render method. Renders IMGUI contents.
247  */
248  virtual void render() const = 0;
249  };
250 
251  /** \brief A basic text element.
252  */
253  class TextElement : public ImGuiElement
254  {
255  public:
256  /** \brief Constructor.
257  * \param[in] text Text to display.
258  */
259  TextElement(const std::string &text);
260  void render() const override;
261 
262  private:
263  const std::string text; ///< Text to display.
264  };
265 
266  /** \brief A checkbox element that modifies a boolean.
267  */
269  {
270  public:
271  /** \brief Constructor.
272  * \param[in] text Text to display.
273  * \param[in] boolean Boolean to modify.
274  */
275  CheckboxElement(const std::string &text, bool &boolean);
276  void render() const override;
277 
278  private:
279  const std::string text; ///< Display text.
280  bool &boolean; ///< Associated boolean.
281  };
282 
283  /** \brief Callback function upon a button press.
284  */
285  using ButtonCallback = std::function<void()>;
286 
287  /** \brief A basic push-button element.
288  */
290  {
291  public:
292  /** \brief Constructor.
293  * \param[in] text Text to display on button.
294  * \param[in] callback Callback upon press.
295  */
297  void render() const override;
298 
299  private:
300  const std::string text; ///< Display text.
301  const ButtonCallback callback; ///< Callback.
302  };
303 
304  /** \brief Callback upon a render call.
305  */
306  using RenderCallback = std::function<void()>;
307 
308  /** \brief Generic rendered element. Use callback to display whatever GUI elements needed.
309  */
311  {
312  public:
313  /** \brief Constructor.
314  * \param[in] callback Callback to render.
315  */
317  void render() const override;
318 
319  private:
320  const RenderCallback callback; ///< Callback.
321  };
322 
323  /** \brief Line plot element. Displays an updated line graph of data.
324  */
326  {
327  public:
328  std::string id{"##" + generateUUID()}; ///< Unique ID.
329  std::string label{""}; ///< Plot Label.
330  std::string units{""}; ///< Plot Units.
331  bool show_min{false}; ///< Display minimum value under plot.
332  bool show_max{false}; ///< Display maximum value under plot.
333  bool show_avg{false}; ///< Display average value under plot.
334  bool recent{true}; ///< Display most recent value on plot.
335  std::size_t max_size{100}; ///< Maximum size of plot data.
336  Eigen::Vector3d color{1., 1., 1.}; ///< Color of plot.
337 
338  /** \brief Add a point to the plot data.
339  * \param[in] x Point to add.
340  */
341  void addPoint(float x);
342  void render() const override;
343 
344  private:
345  std::size_t index{0}; ///< Index in data.
346  std::size_t total_elements{0}; ///< Total elements inserted in data.
347  std::vector<float> elements; ///< All data points.
348  float latest; ///< Last input data point.
349 
350  /** \brief Compute the average over the data.
351  * \return The average.
352  */
353  float average() const;
354 
355  /** \brief Compute the minimum over the data.
356  * \return The minimum.
357  */
358  float minimum() const;
359 
360  /** \brief Compute the maximum over the data.
361  * \return The maximum.
362  */
363  float maximum() const;
364  };
365 
366  /** \brief IMGUI widget to add interactive GUI elements programmatically.
367  */
368  class WindowWidget : public Widget
369  {
370  public:
371  /** \brief Constructor.
372  */
373  WindowWidget();
374 
375  /** \brief Render GUI.
376  */
377  void render() override;
378 
379  /** \name Element Addition
380  \{ */
381 
382  /** \brief Add a new text element to the GUI.
383  * \param[in] text Text to display.
384  */
385  void addText(const std::string &text);
386 
387  /** \brief Add a new checkbox element to the GUI.
388  * \param[in] text Text to display on checkbox.
389  * \param[in] boolean Boolean to modify upon checkbox change.
390  */
391  void addCheckbox(const std::string &text, bool &boolean);
392 
393  /** \brief Add a new button element to the GUI.
394  * \param[in] text Text to display on the button.
395  * \param[in] callback Callback upon button press.
396  */
397  void addButton(const std::string &text, const ButtonCallback &callback);
398 
399  /** \brief Add a generic render callback for the GUI.
400  * \param[in] callback Callback to render.
401  */
402  void addCallback(const RenderCallback &callback);
403 
404  /** \brief Add a generic element to the GUI.
405  * \param[in] element Element to render.
406  */
407  void addElement(const ImGuiElementPtr &element);
408 
409  /** \} */
410 
411  private:
413  };
414 
415  /** \brief IMGUI widget to design TSRs.
416  */
417  class TSREditWidget : public Widget
418  {
419  public:
420  /** \brief Constructor.
421  * \param[in] name Name of TSR.
422  * \param[in] spec Base specification of the TSR
423  */
424  TSREditWidget(const std::string &name = "TSR", const TSR::Specification &spec = {});
425  void initialize(Window *window) override;
426  void prerefresh() override;
427 
428  /** \brief Render GUI.
429  */
430  void render() override;
431 
432  /** \brief Get current TSR specification.
433  * \return The current TSR specification.
434  */
435  const TSR::Specification &getSpecification() const;
436 
437  /** \brief Get the current TSR.
438  * \return The current TSR.
439  */
440  const TSRPtr &getTSR() const;
441 
442  private:
443  /** \name Element Synchronization
444  \{ */
445 
446  /** \brief Frame update callback on moving the main interactive frame.
447  * \param[in] frame The interactive frame.
448  */
449  void updateFrameCB(const dart::gui::osg::InteractiveFrame *frame);
450 
451  /** \brief Frame update callback on moving the lower bound control.
452  * \param[in] frame The interactive frame.
453  */
454  void updateLLCB(const dart::gui::osg::InteractiveFrame *frame);
455 
456  /** \brief Frame update callback on moving the upper bound control.
457  * \param[in] frame The interactive frame.
458  */
459  void updateUUCB(const dart::gui::osg::InteractiveFrame *frame);
460 
461  /** \brief If synchronizing bounds, mirrors updates on other bound.
462  */
463  void updateMirror();
464 
465  /** \brief Updates the TSR to the specification.
466  */
467  void syncTSR();
468 
469  /** \brief Updates the specification to the GUI.
470  */
471  void syncSpec();
472 
473  /** \brief Updates the GUI to the specification.
474  */
475  void syncGUI();
476 
477  /** \brief Updates the display frames to the specification.
478  */
479  void syncFrame();
480 
481  bool gui_{false}; ///< True if a synchronize call is coming from the GUI update loop.
482 
483  /** \} */
484 
485  /** \name Interactive/Display Frames
486  \{ */
487 
488  /** \brief Get the volume for the bounds.
489  * \return The volume of bounds.
490  */
491  Eigen::Vector3d getVolume() const;
492 
493  /** \brief Updates the displayed shape volume for the bounds.
494  */
495  void updateShape();
496 
497  dart::dynamics::SimpleFramePtr offset_; ///< Offset frame for bounds.
498  dart::dynamics::SimpleFramePtr shape_; ///< Display boundary shape frame.
499  dart::dynamics::SimpleFramePtr rbounds_[3]; ///< Display rotation bounds.
500  Window::InteractiveReturn frame_; ///< Main interactive frame.
501  Window::InteractiveReturn ll_frame_; ///< Lower bound interactive frame.
502  Window::InteractiveReturn uu_frame_; ///< Upper bound interactive frame.
503 
504  /** \} */
505 
506  /** \name TSR Specification
507  \{ */
508 
509  const std::string name_; ///< Name of this window.
510  const TSR::Specification original_; ///< Original specification provided to the window.
511  TSR::Specification spec_; ///< Current specification.
512  TSR::Specification prev_; ///< Prior iteration specification.
513  TSRPtr tsr_; ///< Corresponding TSR.
514  std::mutex mutex_; ///< Solving mutex.
515 
516  /** \} */
517 
518  /** \name GUI Options
519  \{ */
520 
521  bool sync_bounds_{true}; ///< Synchronize changes in volume on other bound.
522  bool show_volume_{true}; ///< Show TSR volume.
523  bool show_bounds_{true}; ///< Show TSR rotation bounds.
524 
525  /** \} */
526 
527  /** \name GUI Values
528  \{ */
529 
530  const double volume_alpha_{0.2}; ///< Volume alpha.
531  const double rotation_alpha_{0.6}; ///< Rotation bound alpha.
532  const double rotation_width_{0.05}; ///< Rotation bound width.
533 
534  const float max_position_{5.0f}; ///< Max position value.
535  const float drag_step_{0.01f}; ///< Slider drag amount.
536 
537  float position_[3]; ///< GUI frame position.
538  float rotation_[3]; ///< GUI frame rotation.
539 
540  float xp_[2]; ///< GUI X position bounds.
541  float yp_[2]; ///< GUI Y position bounds.
542  float zp_[2]; ///< GUI Z position bounds.
543 
544  float xr_[2]; ///< GUI X orientation bounds.
545  float yr_[2]; ///< GUI Y orientation bounds.
546  float zr_[2]; ///< GUI Z orientation bounds.
547 
548  float inner_radius{0.2}; ///< GUI Rotation bound inner radius.
549 
550  /** \} */
551  };
552 
553  /** \brief Class for solving a set of TSRs.
554  */
555  class TSRSolveWidget : public Widget
556  {
557  public:
558  /** \brief Constructor.
559  * \param[in] world World to use.
560  * \param[in] tsrs Set of TSRs to consider.
561  */
562  TSRSolveWidget(const WorldPtr &world, const std::vector<TSRPtr> &tsrs);
563 
564  /** \brief Constructor.
565  * \param[in] tsrs Set of TSRs to consider.
566  */
567  TSRSolveWidget(const TSRSetPtr &tsrs);
568 
569  void initialize(Window *window) override;
570  void prerefresh() override;
571 
572  /** \brief Render GUI.
573  */
574  void render() override;
575 
576  /** \brief Solve for a solution to the current TSR.
577  */
578  void solve();
579 
580  private:
581  TSRSetPtr tsrs_; ///< TSR set.
582 
583  /** \name GUI Values
584  \{ */
585 
586  const float max_tolerance_{0.1f}; ///< Max tolerance value.
587  const int max_iteration_{200}; ///< Max iteration value.
588  const float drag_tolerance_{0.01f}; ///< Slider drag for tolerance.
589 
590  bool track_tsr_{false}; ///< Track the TSR by solving IK.
591  bool use_gradient_{false}; ///< Use gradient solving instead of built-in.
592  bool need_solve_{false}; ///< A solve is requested.
593 
594  float step_; ///< GUI gradient step size.
595  float limit_; ///< GUI gradient limit.
596  float damping_; ///< GUI SVD damping.
597  float tolerance_; ///< GUI solver tolerance
598  int maxIter_; ///< GUI maximum allowed iterations.
599  int item_{0}; ///< GUI solver.
600 
601  /** \} */
602 
603  /** \name GUI Plots
604  \{ */
605 
606  bool last_solve_{false}; ///< Result of last TSR solve.
607  LinePlotElement solve_time_; ///< Plot of TSR solve times.
608 
609  /** \brief Error plots for TSRs.
610  */
611  struct ErrorLines
612  {
613  LinePlotElement xpd; ///< X position error.
614  LinePlotElement ypd; ///< Y position error.
615  LinePlotElement zpd; ///< Z position error.
616  LinePlotElement xrd; ///< X orientation error.
617  LinePlotElement yrd; ///< Y orientation error.
618  LinePlotElement zrd; ///< Z orientation error.
619  };
620 
622 
623  /** \} */
624  };
625  } // namespace darts
626 } // namespace robowflex
627 
628 #endif
#define ROBOWFLEX_CLASS_FORWARD(C)
Macro that forward declares a class and defines two shared ptrs types:
Definition: class_forward.h:16
A basic push-button element.
Definition: gui.h:290
const ButtonCallback callback
Callback.
Definition: gui.h:301
ButtonElement(const std::string &text, const ButtonCallback &callback)
Constructor.
Definition: gui.cpp:276
const std::string text
Display text.
Definition: gui.h:300
void render() const override
Render method. Renders IMGUI contents.
Definition: gui.cpp:281
A checkbox element that modifies a boolean.
Definition: gui.h:269
bool & boolean
Associated boolean.
Definition: gui.h:280
CheckboxElement(const std::string &text, bool &boolean)
Constructor.
Definition: gui.cpp:267
const std::string text
Display text.
Definition: gui.h:279
void render() const override
Render method. Renders IMGUI contents.
Definition: gui.cpp:271
A shared pointer wrapper for robowflex::darts::WindowWidget::Element.
Abstract GUI element.
Definition: gui.h:244
virtual void render() const =0
Render method. Renders IMGUI contents.
Line plot element. Displays an updated line graph of data.
Definition: gui.h:326
float minimum() const
Compute the minimum over the data.
Definition: gui.cpp:307
bool show_avg
Display average value under plot.
Definition: gui.h:333
std::vector< float > elements
All data points.
Definition: gui.h:347
std::string units
Plot Units.
Definition: gui.h:330
Eigen::Vector3d color
Color of plot.
Definition: gui.h:336
std::size_t index
Index in data.
Definition: gui.h:345
float latest
Last input data point.
Definition: gui.h:348
float average() const
Compute the average over the data.
Definition: gui.cpp:298
float maximum() const
Compute the maximum over the data.
Definition: gui.cpp:315
void render() const override
Render method. Renders IMGUI contents.
Definition: gui.cpp:339
bool recent
Display most recent value on plot.
Definition: gui.h:334
bool show_min
Display minimum value under plot.
Definition: gui.h:331
void addPoint(float x)
Add a point to the plot data.
Definition: gui.cpp:323
std::size_t total_elements
Total elements inserted in data.
Definition: gui.h:346
std::size_t max_size
Maximum size of plot data.
Definition: gui.h:335
std::string label
Plot Label.
Definition: gui.h:329
bool show_max
Display maximum value under plot.
Definition: gui.h:332
A helper class to setup common OMPL structures for planning.
Generic rendered element. Use callback to display whatever GUI elements needed.
Definition: gui.h:311
RenderElement(const RenderCallback &callback)
Constructor.
Definition: gui.cpp:288
const RenderCallback callback
Callback.
Definition: gui.h:320
void render() const override
Render method. Renders IMGUI contents.
Definition: gui.cpp:292
A shared pointer wrapper for robowflex::darts::StateSpace.
IMGUI widget to design TSRs.
Definition: gui.h:418
float xr_[2]
GUI X orientation bounds.
Definition: gui.h:544
TSREditWidget(const std::string &name="TSR", const TSR::Specification &spec={})
Constructor.
Definition: gui.cpp:411
void syncFrame()
Updates the display frames to the specification.
Definition: gui.cpp:495
void syncTSR()
Updates the TSR to the specification.
Definition: gui.cpp:503
void syncSpec()
Updates the specification to the GUI.
Definition: gui.cpp:511
void syncGUI()
Updates the GUI to the specification.
Definition: gui.cpp:528
float yr_[2]
GUI Y orientation bounds.
Definition: gui.h:545
const float drag_step_
Slider drag amount.
Definition: gui.h:535
float yp_[2]
GUI Y position bounds.
Definition: gui.h:541
Eigen::Vector3d getVolume() const
Get the volume for the bounds.
Definition: gui.cpp:625
dart::dynamics::SimpleFramePtr rbounds_[3]
Display rotation bounds.
Definition: gui.h:499
const TSR::Specification original_
Original specification provided to the window.
Definition: gui.h:510
void updateMirror()
If synchronizing bounds, mirrors updates on other bound.
Definition: gui.cpp:603
float zr_[2]
GUI Z orientation bounds.
Definition: gui.h:546
void initialize(Window *window) override
Initialization with window context.
Definition: gui.cpp:416
TSR::Specification prev_
Prior iteration specification.
Definition: gui.h:512
const double volume_alpha_
Volume alpha.
Definition: gui.h:530
TSR::Specification spec_
Current specification.
Definition: gui.h:511
bool show_bounds_
Show TSR rotation bounds.
Definition: gui.h:523
void updateUUCB(const dart::gui::osg::InteractiveFrame *frame)
Frame update callback on moving the upper bound control.
Definition: gui.cpp:586
bool gui_
True if a synchronize call is coming from the GUI update loop.
Definition: gui.h:481
const TSR::Specification & getSpecification() const
Get current TSR specification.
Definition: gui.cpp:751
float inner_radius
GUI Rotation bound inner radius.
Definition: gui.h:548
float zp_[2]
GUI Z position bounds.
Definition: gui.h:542
Window::InteractiveReturn ll_frame_
Lower bound interactive frame.
Definition: gui.h:501
void prerefresh() override
Called before window refresh.
Definition: gui.cpp:746
float xp_[2]
GUI X position bounds.
Definition: gui.h:540
Window::InteractiveReturn frame_
Main interactive frame.
Definition: gui.h:500
TSRPtr tsr_
Corresponding TSR.
Definition: gui.h:513
void updateFrameCB(const dart::gui::osg::InteractiveFrame *frame)
Frame update callback on moving the main interactive frame.
Definition: gui.cpp:555
dart::dynamics::SimpleFramePtr shape_
Display boundary shape frame.
Definition: gui.h:498
void render() override
Render GUI.
Definition: gui.cpp:663
float position_[3]
GUI frame position.
Definition: gui.h:537
const double rotation_alpha_
Rotation bound alpha.
Definition: gui.h:531
float rotation_[3]
GUI frame rotation.
Definition: gui.h:538
void updateShape()
Updates the displayed shape volume for the bounds.
Definition: gui.cpp:630
bool sync_bounds_
Synchronize changes in volume on other bound.
Definition: gui.h:521
void updateLLCB(const dart::gui::osg::InteractiveFrame *frame)
Frame update callback on moving the lower bound control.
Definition: gui.cpp:569
const TSRPtr & getTSR() const
Get the current TSR.
Definition: gui.cpp:756
const std::string name_
Name of this window.
Definition: gui.h:509
bool show_volume_
Show TSR volume.
Definition: gui.h:522
const float max_position_
Max position value.
Definition: gui.h:534
dart::dynamics::SimpleFramePtr offset_
Offset frame for bounds.
Definition: gui.h:497
std::mutex mutex_
Solving mutex.
Definition: gui.h:514
const double rotation_width_
Rotation bound width.
Definition: gui.h:532
Window::InteractiveReturn uu_frame_
Upper bound interactive frame.
Definition: gui.h:502
A shared pointer wrapper for robowflex::darts::TSR.
A shared pointer wrapper for robowflex::darts::TSRSet.
Class for solving a set of TSRs.
Definition: gui.h:556
bool need_solve_
A solve is requested.
Definition: gui.h:592
void solve()
Solve for a solution to the current TSR.
Definition: gui.cpp:883
TSRSetPtr tsrs_
TSR set.
Definition: gui.h:581
bool track_tsr_
Track the TSR by solving IK.
Definition: gui.h:590
bool use_gradient_
Use gradient solving instead of built-in.
Definition: gui.h:591
const float max_tolerance_
Max tolerance value.
Definition: gui.h:586
float step_
GUI gradient step size.
Definition: gui.h:594
float damping_
GUI SVD damping.
Definition: gui.h:596
void prerefresh() override
Called before window refresh.
Definition: gui.cpp:961
void initialize(Window *window) override
Initialization with window context.
Definition: gui.cpp:903
int item_
GUI solver.
Definition: gui.h:599
LinePlotElement solve_time_
Plot of TSR solve times.
Definition: gui.h:607
int maxIter_
GUI maximum allowed iterations.
Definition: gui.h:598
float limit_
GUI gradient limit.
Definition: gui.h:595
std::vector< ErrorLines > errors_
Definition: gui.h:621
float tolerance_
GUI solver tolerance.
Definition: gui.h:597
const int max_iteration_
Max iteration value.
Definition: gui.h:587
TSRSolveWidget(const WorldPtr &world, const std::vector< TSRPtr > &tsrs)
Constructor.
Definition: gui.cpp:765
bool last_solve_
Result of last TSR solve.
Definition: gui.h:606
const float drag_tolerance_
Slider drag for tolerance.
Definition: gui.h:588
void render() override
Render GUI.
Definition: gui.cpp:774
The specification of a TSR.
Definition: tsr.h:70
A basic text element.
Definition: gui.h:254
TextElement(const std::string &text)
Constructor.
Definition: gui.cpp:258
void render() const override
Render method. Renders IMGUI contents.
Definition: gui.cpp:262
const std::string text
Text to display.
Definition: gui.h:263
Viewer class.
Definition: gui.h:51
WorldPtr world_
World.
Definition: gui.h:61
Abstract class for IMGUI Widget.
Definition: gui.h:219
virtual void initialize(Window *window)
Initialization with window context.
Definition: gui.cpp:246
virtual void prerefresh()
Called before window refresh.
Definition: gui.cpp:250
A shared pointer wrapper for robowflex::darts::WindowWidget.
IMGUI widget to add interactive GUI elements programmatically.
Definition: gui.h:369
void addCheckbox(const std::string &text, bool &boolean)
Add a new checkbox element to the GUI.
Definition: gui.cpp:393
void addButton(const std::string &text, const ButtonCallback &callback)
Add a new button element to the GUI.
Definition: gui.cpp:388
std::vector< ImGuiElementPtr > elements_
GUI elements.
Definition: gui.h:412
void render() override
Render GUI.
Definition: gui.cpp:366
WindowWidget()
Constructor.
Definition: gui.cpp:362
void addElement(const ImGuiElementPtr &element)
Add a generic element to the GUI.
Definition: gui.cpp:403
void addText(const std::string &text)
Add a new text element to the GUI.
Definition: gui.cpp:383
void addCallback(const RenderCallback &callback)
Add a generic render callback for the GUI.
Definition: gui.cpp:398
Open Scene Graph GUI for DART visualization.
Definition: gui.h:67
Viewer viewer_
Viewer.
Definition: gui.h:213
WindowWidgetPtr widget_
IMGUI widget.
Definition: gui.h:207
WorldPtr getWorld()
Get world used for visualization.
Definition: gui.cpp:221
WindowWidgetPtr getWidget()
Get the IMGUI configurable widget.
Definition: gui.cpp:216
Window(const WorldPtr &world)
Constructor.
Definition: gui.cpp:76
void run(std::function< void()> thread={})
Run the GUI. Blocks.
Definition: gui.cpp:231
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.
Definition: gui.cpp:160
std::shared_ptr< std::thread > animation_
Animation thread.
Definition: gui.h:210
std::vector< WidgetPtr > widgets_
Other widgets;.
Definition: gui.h:208
::osg::ref_ptr< Window > node_
OSG Node.
Definition: gui.h:212
friend TSREditWidget
Definition: gui.h:68
void addWidget(const WidgetPtr &widget)
Add a new IMGUI widget.
Definition: gui.cpp:106
WorldPtr world_
World to visualize.
Definition: gui.h:206
InteractiveReturn createInteractiveMarker(const InteractiveOptions &options)
Create a new interactive marker in the GUI.
Definition: gui.cpp:113
void customPreRefresh() override
Definition: gui.cpp:94
const WorldPtr & getWorldConst() const
Get world used for visualization.
Definition: gui.cpp:226
void customPostRefresh() override
Definition: gui.cpp:101
DnDReturn enableNodeDragNDrop(dart::dynamics::BodyNode *node, const DnDCallback &callback={})
Enable drag 'n drop functionality on a body node being visualized. With DnD, the body node will autom...
Definition: gui.cpp:146
A shared pointer wrapper for robowflex::darts::World.
std::string generateUUID()
Generate a unique identifier.
Definition: gui.cpp:17
Main namespace. Contains all library classes and functions.
Definition: scene.cpp:25
LinePlotElement xpd
X position error.
Definition: gui.h:613
LinePlotElement zpd
Z position error.
Definition: gui.h:615
LinePlotElement yrd
Y orientation error.
Definition: gui.h:617
LinePlotElement zrd
Z orientation error.
Definition: gui.h:618
LinePlotElement xrd
X orientation error.
Definition: gui.h:616
LinePlotElement ypd
Y position error.
Definition: gui.h:614
Return from creating a movable frame.
Definition: gui.h:140
dart::gui::osg::BodyNodeDnD * dnd
Drag 'n Drop object.
Definition: gui.h:141
dart::common::Connection signal
Connection from motion to callback.
Definition: gui.h:142
Options for creating an interactive marker.
Definition: gui.h:88
void disableControls()
Disables all controls.
Definition: gui.cpp:65
std::string name
Name of marker.
Definition: gui.h:89
bool rotation[3]
Rotation ring controls enabled.
Definition: gui.h:98
void disableRotationControls()
Disables all rotation controls.
Definition: gui.cpp:51
bool obstructable
Is this frame obstructable?
Definition: gui.h:95
void disableLinearControls()
Disables all linear controls.
Definition: gui.cpp:44
Eigen::Isometry3d pose
Relative pose of marker.
Definition: gui.h:90
InteractiveCallback callback
Callback function on motion.
Definition: gui.h:91
double thickness
Thickness of marker arrows.
Definition: gui.h:94
bool linear[3]
Linear position controls enabled.
Definition: gui.h:97
bool planar[3]
Planar translation controls enabled.
Definition: gui.h:99
void disablePlanarControls()
Disables all planar controls.
Definition: gui.cpp:58
dart::dynamics::Frame * parent
Parent frame.
Definition: gui.h:92
Return from creating an interactive marker.
Definition: gui.h:121
dart::gui::osg::InteractiveFrameDnD * dnd
Drag 'n Drop object.
Definition: gui.h:123
dart::common::Connection signal
Connection from motion to callback.
Definition: gui.h:124
dart::gui::osg::InteractiveFramePtr target
Interactive Frame generated.
Definition: gui.h:122
void callback(movegroup::MoveGroupHelper::Action &action)
Definition: tapedeck.cpp:20