ArVizExample.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package RobotAPI::ArmarXObjects::ArVizExample
17  * @author Fabian Paus ( fabian dot paus at kit dot edu )
18  * @date 2019
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #include "ArVizExample.h"
24 
25 #include <Eigen/Eigen>
26 
27 #include <SimoxUtility/color/cmaps.h>
28 
32 
34 
35 
36 namespace armarx
37 {
38 
40  {
42 
43  // In this example, this is automatically done by deriving the component
44  // from armarx::ArVizComponentPluginUser.
45  if (false)
46  {
47  defs->defineOptionalProperty<std::string>("ArVizTopicName", "ArVizTopic", "Layer updates are sent over this topic.");
48  }
49 
50  defs->optional(properties.manyLayers, "layers.ManyElements",
51  "Show a layer with a lot of elements (used for testing, may impact performance).");
52 
53  return defs;
54  }
55 
56 
57  std::string ArVizExample::getDefaultName() const
58  {
59  return "ArVizExample";
60  }
61 
62 
64  {
65  // In this example, this is automatically done by deriving the component
66  // from armarx::ArVizComponentPluginUser.
67  if (false)
68  {
69  offeringTopicFromProperty("ArVizTopicName");
70  }
71  }
72 
73 
75  {
76  task = new RunningTask<ArVizExample>(this, &ArVizExample::run);
77  task->start();
78  }
79 
80 
82  {
83  const bool join = true;
84  task->stop(join);
85  task = nullptr;
86  }
87 
88 
90  {
91  }
92 
93 
94  void fillTestLayer(viz::Layer& layer, double timeInSeconds)
95  {
96  {
97  Eigen::Vector3f pos = Eigen::Vector3f::Zero();
98  pos.x() = 100.0f * std::sin(timeInSeconds);
99 
100  viz::Box box = viz::Box("box")
101  .position(pos)
103  .size(Eigen::Vector3f(100.0f, 100.0f, 100.0f));
104 
105  bool toggleVisibility = (static_cast<int>(timeInSeconds) % 2 == 0);
106  box.visible(toggleVisibility);
107 
108  layer.add(box);
109  }
110  {
111  const float delta = 20. * std::sin(timeInSeconds);
112  layer.add(viz::Ellipsoid{"ellipsoid"}
113  .position(Eigen::Vector3f{0, 100, 150})
114  .color(viz::Color::blue())
115  .axisLengths(Eigen::Vector3f{70.f + delta, 70.f - delta, 30.f}));
116  }
117  {
118  Eigen::Vector3f pos = Eigen::Vector3f::Zero();
119  pos.y() = 100.0f * std::sin(timeInSeconds);
120  pos.x() = 150.0f;
121 
122  viz::Cylinder cyl = viz::Cylinder("cylinder")
123  .position(pos)
125  .radius(50.0f)
126  .height(100.0f);
127 
128  layer.add(cyl);
129  }
130 
131  {
132  Eigen::Vector3f pos = Eigen::Vector3f::Zero();
133  pos.z() = 100.0f * std::sin(timeInSeconds);
134  pos.x() = -150.0f;
135 
136  viz::Pose pose = viz::Pose("pose")
137  .position(pos)
138  .scale(1.0f);
139 
140  layer.add(pose);
141  }
142  {
143  Eigen::Vector3f pos = Eigen::Vector3f::Zero();
144  pos.z() = +300.0f;
145 
146  viz::Text text = viz::Text("text")
147  .text("Test Text")
148  .scale(4.0f)
149  .position(pos)
151 
152  layer.add(text);
153  }
154  {
155  viz::Arrow arrow = viz::Arrow("arrow");
156 
157  float modTime = std::fmod(timeInSeconds, 2.0 * M_PI);
158  arrow.length(200.0f + 100.0f * std::sin(modTime));
159 
160  Eigen::AngleAxisf dirRot(modTime, Eigen::Vector3f::UnitZ());
161  Eigen::Vector3f direction = dirRot * Eigen::Vector3f::UnitX();
162  arrow.direction(direction);
163 
164  Eigen::Vector3f pos = Eigen::Vector3f::Zero();
165  pos.z() = +300.0f;
166  pos.x() = -500.0f;
167  arrow.position(pos);
168  arrow.color(viz::Color::blue());
169 
170  layer.add(arrow);
171  }
172  }
173 
174 
176  {
177  Eigen::Vector3f offset = {-800, 0, 500};
178  std::vector<Eigen::Vector3f> pathPoints {
179  { 0, 0, 0 },
180  { -200, 0, 0 },
181  { -200, 200, 0 },
182  };
183  Eigen::Vector3f additionalPoint = {-200, 200, 200};
184 
185  // Path: Connected sequence of lines.
186  {
187  viz::Path path = viz::Path("path")
188  .position(offset)
189  .points(pathPoints)
190  .color(simox::Color::magenta()).width(10)
191  ;
192 
193  path.addPoint(additionalPoint);
194 
195  layer.add(path);
196  }
197 
198  pathPoints.push_back(additionalPoint);
199 
200  // Line: Single line segments between 2 points.
201  {
202  offset = offset - 300 * Eigen::Vector3f::UnitX();
203 
204  for (size_t i = 0; i < pathPoints.size() - 1; i += 2)
205  {
206  viz::Line line = viz::Line("line " + std::to_string(i) + " -> " + std::to_string(i+1))
207  .fromTo(pathPoints.at(i) + offset, pathPoints.at(i+1) + offset)
208  .color(simox::Color::lime()).lineWidth(10)
209  ;
210 
211  layer.add(line);
212  }
213  }
214 
215  // Line and Path are drawn in pixel space. For a more consistent 3D look, use cylinders:
216  {
217  offset = offset - 300 * Eigen::Vector3f::UnitX();
218 
219  for (size_t i = 0; i < pathPoints.size() - 1; ++i)
220  {
221  layer.add(viz::Cylinder("path cylinder " + std::to_string(i) + " -> " + std::to_string(i+1))
222  .fromTo(pathPoints.at(i) + offset, pathPoints.at(i+1) + offset)
223  .color(simox::Color::cyan()).radius(10)
224  );
225  }
226  }
227 
228  // Optional: Add spheres for an even nicer look.
229  {
230  offset = offset - 300 * Eigen::Vector3f::UnitX();
231 
232  for (size_t i = 0; i < pathPoints.size(); ++i)
233  {
234  float radius = 10;
235  simox::Color color = simox::Color::azure();
236 
237  if (i < pathPoints.size() - 1)
238  {
239  layer.add(viz::Cylinder("path cylinder with spheres " + std::to_string(i) + " -> " + std::to_string(i+1))
240  .fromTo(pathPoints.at(i) + offset, pathPoints.at(i+1) + offset)
241  .color(color).radius(radius)
242  );
243  }
244 
245  layer.add(viz::Sphere("path sphere " + std::to_string(i))
246  .position(pathPoints.at(i) + offset)
247  .color(color).radius(radius)
248  );
249  }
250  }
251  }
252 
253 
255  {
256  Eigen::Vector3f pos = Eigen::Vector3f::Zero();
257 
258  for (int i = 0; i < 10; ++i)
259  {
260  // Always generate a new name, so the robot needs to be cached through the instance pool
261  int randomIndex = std::rand();
262  std::string name = "Hand_" + std::to_string(randomIndex);
263 
264  pos.x() = 1500.0f;
265  pos.y() = i * 200.0f;
266  viz::Robot robot = viz::Robot(name)
267  .position(pos)
268  .file("armar6_rt", "armar6_rt/robotmodel/Armar6-SH/Armar6-RightHand-v3.xml")
269  .overrideColor(simox::Color::green(64 + i * 8));
270 
271  layer.add(robot);
272  }
273  }
274 
275 
276  void fillExampleLayer(viz::Layer& layer, double timeInSeconds)
277  {
278  for (int i = 0; i < 6; ++i)
279  {
280  Eigen::Vector3f pos = Eigen::Vector3f(-200.0, 200.0, 300);
281  pos.x() += -300 * i;
282 
283  Eigen::Vector3f normal = Eigen::Vector3f::Zero();
284  normal(i / 2) = (i % 2 == 0 ? 1.0 : -1.0);
285 
286  viz::ArrowCircle circle = viz::ArrowCircle("circle " + std::to_string(i))
287  .position(pos)
288  .radius(100.0f)
289  .normal(normal)
290  .width(10.0f)
291  .color(viz::Color::fromRGBA(255, 0, 255));
292 
293  float modTime = std::fmod(timeInSeconds, 2.0 * M_PI);
294  circle.completion(std::sin(modTime));
295 
296  layer.add(circle);
297  }
298  {
299  Eigen::Vector3f pos = Eigen::Vector3f::Zero();
300  pos.z() = +1000.0f;
301 
302  viz::Polygon poly = viz::Polygon("poly")
303  .position(pos)
304  .color(viz::Color::fromRGBA(0, 128, 255, 128))
305  .lineColor(viz::Color::fromRGBA(0, 0, 255))
306  .lineWidth(1.0f);
307 
308  float t = 1.0f + std::sin(timeInSeconds);
309  float offset = 50.0f * t;
310  poly.addPoint(Eigen::Vector3f{-200.0f - offset, -200.0f - offset, 0.0f});
311  poly.addPoint(Eigen::Vector3f{-200.0f, +200.0f, 0.0f});
312  poly.addPoint(Eigen::Vector3f{+200.0f + offset, +200.0f + offset, 0.0f});
313  poly.addPoint(Eigen::Vector3f{+200.0f, -200.0f, 0.0f});
314 
315  layer.add(poly);
316  }
317  {
318  Eigen::Vector3f pos = Eigen::Vector3f::Zero();
319  pos.z() = +1500.0f;
320 
321  viz::Polygon poly = viz::Polygon("poly2")
322  .position(pos)
323  .color(viz::Color::fromRGBA(255, 128, 0, 128))
324  .lineWidth(0.0f);
325 
326  float t = 1.0f + std::sin(timeInSeconds);
327  float offset = 20.0f * t;
328  poly.addPoint(Eigen::Vector3f{-100.0f - offset, -100.0f - offset, 0.0f});
329  poly.addPoint(Eigen::Vector3f{-100.0f, +100.0f, 0.0f});
330  poly.addPoint(Eigen::Vector3f{+100.0f + offset, +100.0f + offset, 0.0f});
331  poly.addPoint(Eigen::Vector3f{+100.0f, -100.0f, 0.0f});
332 
333  layer.add(poly);
334  }
335  {
336  armarx::Vector3f vertices[] =
337  {
338  {-100.0f, -100.0f, 0.0f},
339  {-100.0f, +100.0f, 0.0f},
340  {+100.0f, +100.0f, 0.0f},
341  {+100.0f, +100.0f, 200.0f},
342  };
343  std::size_t verticesSize = sizeof(vertices) / sizeof(vertices[0]);
344 
345  armarx::viz::data::Color colors[] =
346  {
347  {255, 255, 0, 0},
348  {255, 0, 255, 0},
349  {255, 0, 0, 255},
350  };
351  std::size_t colorsSize = sizeof(colors) / sizeof(colors[0]);
352 
353  viz::data::Face faces[] =
354  {
355  {
356  0, 1, 2,
357  0, 1, 2,
358  },
359  {
360  1, 2, 3,
361  0, 1, 2,
362  },
363  };
364  std::size_t facesSize = sizeof(faces) / sizeof(faces[0]);
365 
366  Eigen::Vector3f pos = Eigen::Vector3f::Zero();
367  pos.z() = +1000.0f;
368  pos.x() = -500.0f;
369 
370  viz::Mesh mesh = viz::Mesh("mesh")
371  .position(pos)
372  .vertices(vertices, verticesSize)
373  .colors(colors, colorsSize)
374  .faces(faces, facesSize);
375 
376  layer.add(mesh);
377  }
378  {
379  Eigen::Vector3f pos = Eigen::Vector3f::Zero();
380  pos.x() = 500.0f;
381 
382  viz::Robot robot = viz::Robot("robot")
383  .position(pos)
384  .file("armar6_rt", "armar6_rt/robotmodel/Armar6-SH/Armar6-SH.xml");
385 
386  // Full model
387  if (true)
388  {
389  robot.useFullModel();
390  }
391  else
392  {
393  robot.useCollisionModel()
394  .overrideColor(viz::Color::fromRGBA(0, 255, 128, 128));
395  }
396 
397  float value = 0.5f * (1.0f + std::sin(timeInSeconds));
398  robot.joint("ArmR2_Sho1", value);
399  robot.joint("ArmR3_Sho2", value);
400 
401  layer.add(robot);
402  }
403  }
404 
405 
407  {
408  viz::Box box = viz::Box("permBox")
409  .position(Eigen::Vector3f(2000.0f, 0.0f, 0.0f))
410  .size(Eigen::Vector3f(200.0f, 200.0f, 200.0f))
411  .color(viz::Color::fromRGBA(255, 165, 0));
412 
413  layer.add(box);
414  }
415 
416 
417  void fillPointsLayer(viz::Layer& layer, double timeInSeconds)
418  {
420  .position(Eigen::Vector3f(2000.0f, 0.0f, 400.0f))
421  .transparency(0.0f);
422  pc.enable(viz::interaction().selection());
423 
424  viz::ColoredPoint p;
425  p.color = viz::Color::fromRGBA(255, 255, 0, 255);
426  for (int x = -200; x <= 200; ++x)
427  {
428  p.x = 2.0f * x;
429  double phase = timeInSeconds + x / 50.0;
430  double heightT = std::max(0.0, std::min(0.5 * (1.0 + std::sin(phase)), 1.0));
431  for (int y = -200; y <= 200; ++y)
432  {
433  p.y = 2.0f * y;
434  p.z = 100.0 * heightT;
435 
436  p.color.g = 255.0 * heightT;
437  p.color.b = 255.0 * (1.0 - heightT);
438  pc.addPointUnchecked(p);
439  }
440  }
441 
442  layer.add(pc);
443  }
444 
445 
446  void fillObjectsLayer(viz::Layer& layer, double timeInSeconds)
447  {
448  {
449  Eigen::Vector3f pos = Eigen::Vector3f::Zero();
450  pos.x() = 100.0f * std::sin(timeInSeconds);
451  pos.y() = 1000.0f;
452 
453  viz::Object sponge =
454  viz::Object("screwbox")
455  .position(pos)
456  .file("PriorKnowledgeData",
457  "PriorKnowledgeData/objects/Maintenance/bauhaus-screwbox-large/bauhaus-screwbox-large.xml");
458 
459  layer.add(sponge);
460  layer.add(viz::Pose("screwbox pose").position(pos));
461  }
462  {
463  Eigen::Vector3f pos = Eigen::Vector3f::Zero();
464  pos.x() = 300.0f + 100.0f * std::sin(timeInSeconds);
465  pos.y() = 1000.0f;
466 
467  Eigen::AngleAxisf orientation(M_PI_2, Eigen::Vector3f::UnitX());
468 
469  viz::Object spraybottle =
470  viz::Object("spraybottle")
471  .position(pos)
472  .orientation(Eigen::Quaternionf(orientation))
473  .file("PriorKnowledgeData",
474  "PriorKnowledgeData/objects/Maintenance/cable-ties/cable-ties.wrl");
475 
476  layer.add(spraybottle);
477  layer.add(viz::Pose("spraybottle pose").pose(pos, orientation.toRotationMatrix()));
478  }
479  }
480 
481 
482  void fillDisAppearingLayer(viz::Layer& layer, double timeInSeconds)
483  {
484  int time = int(timeInSeconds);
485 
486  const Eigen::Vector3f at = {-400, 0, 100};
487  const Eigen::Vector3f dir = {-150, 0, 0};
488 
489  layer.add(viz::Box("box_always")
490  .position(at).size(100)
491  .color(simox::Color::azure())
492  );
493  layer.add(viz::Text("text_seconds")
494  .position(at + Eigen::Vector3f(0, 0, 100))
495  .orientation(Eigen::AngleAxisf(float(M_PI), Eigen::Vector3f::UnitZ())
496  * Eigen::Quaternionf::FromTwoVectors(Eigen::Vector3f::UnitZ(), - Eigen::Vector3f::UnitY()))
497  .text(std::to_string(time % 3))
498  .scale(5)
499  .color(simox::Color::black())
500  );
501 
502  switch (time % 3)
503  {
504  case 0:
505  layer.add(viz::Sphere("sphere_0_1").position(at + 1.0 * dir).radius(50)
506  .color(simox::Color::purple()));
507  // fallthrough
508  case 1:
509  layer.add(viz::Sphere("sphere_1").position(at + 2.0 * dir).radius(50)
510  .color(simox::Color::pink()));
511  break;
512  case 2:
513  layer.add(viz::Cylinder("cylinder_2").position(at + 3.0 * dir).radius(50).height(100)
514  .color(simox::Color::turquoise()));
515  break;
516  }
517  }
518 
519 
520  void fillManyElementsLayer(viz::Layer& layer, double timeInSeconds)
521  {
522  const Eigen::Vector3f at = {-800, 0, 500};
523  const float size = 5;
524  const float dist = 10;
525 
526  const double period = 10;
527  const float angle = float(2 * M_PI * std::fmod(timeInSeconds, period) / period);
528 
529  const int num = 10;
530  float cf = 1.f / num; // Color factor
531  for (int x = 0; x < num; ++x)
532  {
533  for (int y = 0; y < num; ++y)
534  {
535  for (int z = 0; z < num; ++z)
536  {
537  std::stringstream ss;
538  ss << "box_" << x << "_" << y << "_" << z;
539  layer.add(viz::Box(ss.str())
540  .position(at + dist * Eigen::Vector3f(x, y, z))
541  .orientation(Eigen::AngleAxisf(angle, Eigen::Vector3f::UnitZ()).toRotationMatrix())
542  .size(size)
543  .color(simox::Color(cf * x, cf * y, cf * z)));
544  }
545  }
546  }
547  }
548 
549 
550  void fillColorMapsLayer(viz::Layer& layer, double timeInSeconds)
551  {
552  (void) timeInSeconds;
553  namespace E = Eigen;
554 
555  const E::Vector3f at(-500, -500, 1500);
556  const E::Quaternionf ori = E::Quaternionf::FromTwoVectors(E::Vector3f::UnitZ(), - E::Vector3f::UnitY());
557  const E::Vector2f size(200, 20);
558  const E::Vector2i num(64, 2);
559 
560  int index = 0;
561  for (const auto& pair : simox::color::cmaps::Named::all())
562  {
563  std::string const& name = pair.first;
564  const simox::color::ColorMap& cmap = pair.second;
565 
566  Eigen::Vector3f shift(0, 0, - 1.5f * index * size.y());
567  viz::Mesh mesh = viz::Mesh(name + "_mesh")
568  .position(at + shift)
569  .orientation(ori)
570  .grid2D(size, num, [&cmap](size_t, size_t, const E::Vector3f & p)
571  {
572  return viz::Color(cmap((p.x() + 100.f) / 200.f));
573  });
574 
575  layer.add(mesh);
576 
577  layer.add(viz::Text(name + "_text").text(name)
578  .position(at + shift + E::Vector3f(2 + size.x() / 2, -2, 2 - size.y() / 2))
579  .orientation(ori).scale(1.5).color(simox::Color::black()));
580 
581  index++;
582  }
583 
584  }
585 
587  {
588  // Make box selectable
589  viz::Box box = viz::Box("box")
590  .position(Eigen::Vector3f(2000.0f, 0.0f, 2000.0f))
591  .size(Eigen::Vector3f(200.0f, 200.0f, 200.0f))
592  .color(viz::Color::fromRGBA(0, 165, 255))
593  .scale(2.0f);
594  // Enable some interaction possibilities
596  .selection()
597  .contextMenu({"First Option", "Second Option", "Third Option"})
598  .rotation()
599  .translation(viz::AXES_XY)
600  .scaling(viz::AXES_XYZ));
601 
602  layer.add(box);
603 
604  viz::Cylinder cyl = viz::Cylinder("cylinder")
605  .position(Eigen::Vector3f(1000.0f, 0.0f, 2000.0f))
606  .direction(Eigen::Vector3f::UnitZ())
607  .height(200.0f)
608  .radius(50.0f)
609  .color(viz::Color::fromRGBA(255, 165, 0));
610  // Enable some interaction possibilities
612  .selection()
613  .contextMenu({"Cyl Option 1", "Cyl Option 2"})
614  .rotation()
615  .translation(viz::AXES_YZ)
616  .scaling());
617 
618  layer.add(cyl);
619  }
620 
621 
622  void ArVizExample::run()
623  {
624  // This example uses the member `arviz` provided by armarx::ArVizComponentPluginUser.
625  {
626  // Alternatively, you can instantiate a new client in a component like this: */
627  viz::Client arviz(*this);
628  // The plugin also offers a helper function if you need to create new clients:
630  }
631 
632  /*
633  * General Usage Scheme:
634  * 1. Create a layer (using the client).
635  * 2. Create elements and add them to the layer.
636  * 3. Commit layers (using the client). This is the only network call.
637  */
638 
639  viz::Layer testLayer = arviz.layer("Test");
640  viz::Layer exampleLayer = arviz.layer("Example");
641  viz::Layer pathsAndLinesLayer = arviz.layer("Paths and Lines");
642  viz::Layer pointsLayer = arviz.layer("Points");
643  viz::Layer objectsLayer = arviz.layer("Objects");
644  viz::Layer disAppearingLayer = arviz.layer("DisAppearing");
645  viz::Layer robotHandsLayer = arviz.layer("RobotHands");
646  viz::Layer interactionLayer = arviz.layer("Interaction");
647 
648  viz::StagedCommit stage = arviz.stage();
649 
650  // These layers are not updated in the loop.
651  {
652  viz::Layer permanentLayer = arviz.layer("Permanent");
653  fillPermanentLayer(permanentLayer);
654  stage.add(permanentLayer);
655  }
656  bool manyElements = getProperty<bool>("layers.ManyElements");
657  if (manyElements)
658  {
659  viz::Layer manyElementsLayer = arviz.layer("ManyElements");
660  fillManyElementsLayer(manyElementsLayer, 0);
661  stage.add(manyElementsLayer);
662  }
663  {
664  viz::Layer colorMapsLayer = arviz.layer("ColorMaps");
665  fillColorMapsLayer(colorMapsLayer, 0);
666  stage.add(colorMapsLayer);
667  }
668 
669  fillInteractionLayer(interactionLayer);
670  stage.add(interactionLayer);
671 
672  // Apply the staged commits in a single network call
673  viz::CommitResult result = arviz.commit(stage);
674  ARMARX_INFO << "Permanent layers committed in revision: "
675  << result.revision();
676 
677 
678  CycleUtil c(25);
679  while (!task->isStopped())
680  {
681  double timeInSeconds = TimeUtil::GetTime().toSecondsDouble();
682 
683  testLayer.clear();
684  fillTestLayer(testLayer, timeInSeconds);
685  exampleLayer.clear();
686  fillExampleLayer(exampleLayer, timeInSeconds);
687  pathsAndLinesLayer.clear();
688  fillPathsAndLinesLayer(pathsAndLinesLayer);
689  pointsLayer.clear();
690  fillPointsLayer(pointsLayer, timeInSeconds);
691  objectsLayer.clear();
692  fillObjectsLayer(objectsLayer, timeInSeconds);
693  disAppearingLayer.clear();
694  fillDisAppearingLayer(disAppearingLayer, timeInSeconds);
695 
696  if (manyElements)
697  {
698  robotHandsLayer.clear();
699  fillRobotHandsLayer(robotHandsLayer);
700  }
701 
702  // We can reuse a staged commit
703  stage.reset();
704  // We can stage multiple layers at once.
705  // This is equivalent to calling add(layer) multiple times.
706  stage.add({testLayer,
707  exampleLayer,
708  pathsAndLinesLayer,
709  pointsLayer,
710  objectsLayer,
711  disAppearingLayer,
712  robotHandsLayer
713  });
714  // We can request interaction feedback for specific layers
715  stage.requestInteraction(interactionLayer);
716 
717  // This sends the layer updates and receives interaction feedback in a single network call
718  result = arviz.commit(stage);
719  // Be careful: The interactions are stored in the CommitResult
720  // So the range is only valid as long as result is in scope and not overriden.
721  viz::InteractionFeedbackRange interactions = result.interactions();
722  if (interactions.size() > 0)
723  {
724  ARMARX_INFO << "We got some interactions: " << interactions.size();
725  for (viz::InteractionFeedback const& interaction: interactions)
726  {
728  {
729  ARMARX_INFO << "[" << interaction.layer()
730  << "/" << interaction.element()
731  << "] Chosen context menu: "
732  << interaction.chosenContextMenuEntry();
733  }
735  {
736  std::string transformState;
737  if (interaction.isTransformBegin())
738  {
739  transformState = "Begin";
740  }
741  else if (interaction.isTransformDuring())
742  {
743  transformState = "During";
744  }
745  else if (interaction.isTransformEnd())
746  {
747  transformState = "End";
748  }
749  else
750  {
751  transformState = "<Unknwon>";
752  }
753  ARMARX_INFO << "[" << interaction.layer()
754  << "/" << interaction.element()
755  << "] Transformation " << transformState
756  << ": \n" << interaction.transformation()
757  << "\n scale: " << interaction.scale().transpose();
758  }
759  else
760  {
761  ARMARX_INFO << "[" << interaction.layer()
762  << "/" << interaction.element()
763  << "] " << toString(interaction.type());
764  }
765  }
766  }
767 
768  c.waitForCycleDuration();
769  }
770  }
771 
772 
774 
775 }
776 
armarx::viz::Color::black
static Color black(int a=255)
Definition: Color.h:62
Client.h
armarx::fillRobotHandsLayer
void fillRobotHandsLayer(viz::Layer &layer)
Definition: ArVizExample.cpp:254
armarx::viz::Client::commit
CommitResult commit(StagedCommit const &commit)
Definition: Client.cpp:80
armarx::viz::StagedCommit::add
void add(Layer const &layer)
Stage a layer to be committed later via client.apply(*this)
Definition: Client.h:37
armarx::viz::ArrowCircle::radius
ArrowCircle & radius(float r)
Definition: Elements.h:235
Eigen
Definition: Elements.h:36
armarx::viz::InteractionFeedbackType::ContextMenuChosen
@ ContextMenuChosen
A context menu entry was chosen.
armarx::viz::Arrow::length
Arrow & length(float l)
Definition: Elements.h:204
armarx::viz::Client::stage
StagedCommit stage()
Definition: Client.h:135
armarx::viz::Cylinder::radius
Cylinder & radius(float r)
Definition: Elements.h:78
armarx::viz::CommitResult::revision
long revision() const
Definition: Client.h:76
armarx::navigation::core::Pose
Eigen::Isometry3f Pose
Definition: basic_types.h:31
armarx::viz::interaction
InteractionDescription interaction()
Definition: ElementOps.h:101
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::viz::Layer::clear
void clear()
Definition: Layer.h:23
armarx::fillColorMapsLayer
void fillColorMapsLayer(viz::Layer &layer, double timeInSeconds)
Definition: ArVizExample.cpp:550
armarx::viz::Object::file
Object & file(std::string const &project, std::string const &filename)
Definition: Elements.h:328
armarx::viz::Path::addPoint
Path & addPoint(Eigen::Vector3f p)
Definition: Path.cpp:42
armarx::viz::Mesh
Definition: Mesh.h:28
armarx::viz::Color::fromRGBA
static Color fromRGBA(int r, int g, int b, int a=255)
Construct a byte color from R, G, B and optional alpha.
Definition: Color.h:42
armarx::viz::Color::blue
static Color blue(int b=255, int a=255)
Definition: Color.h:89
armarx::fillObjectsLayer
void fillObjectsLayer(viz::Layer &layer, double timeInSeconds)
Definition: ArVizExample.cpp:446
armarx::Component::offeringTopicFromProperty
void offeringTopicFromProperty(const std::string &propertyName)
Offer a topic whose name is specified by the given property.
Definition: Component.cpp:154
armarx::viz::Robot::joint
Robot & joint(std::string const &name, float value)
Definition: Robot.h:59
armarx::fillPathsAndLinesLayer
void fillPathsAndLinesLayer(viz::Layer &layer)
Definition: ArVizExample.cpp:175
armarx::viz::Arrow
Definition: Elements.h:198
armarx::ArVizExample::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: ArVizExample.cpp:39
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::viz::Cylinder::height
Cylinder & height(float h)
Definition: Elements.h:85
armarx::viz::Layer::add
void add(ElementT const &element)
Definition: Layer.h:29
armarx::viz::StagedCommit
A staged commit prepares multiple layers to be committed.
Definition: Client.h:31
armarx::viz::ArrowCircle::normal
ArrowCircle & normal(Eigen::Vector3f dir)
Definition: Elements.cpp:103
armarx::viz::Text::text
Text & text(std::string const &t)
Definition: Elements.h:189
armarx::RunningTask
Definition: ArmarXMultipleObjectsScheduler.h:35
armarx::viz::Sphere
Definition: Elements.h:134
armarx::viz::Robot::useFullModel
Robot & useFullModel()
Definition: Robot.h:38
armarx::viz::ElementOps::position
DerivedT & position(float x, float y, float z)
Definition: ElementOps.h:127
armarx::viz::StagedCommit::reset
void reset()
Reset all staged layers and interaction requests.
Definition: Client.h:64
armarx::viz::Cylinder::direction
Cylinder & direction(Eigen::Vector3f direction)
Definition: Elements.cpp:91
armarx::armem::client::query_fns::all
auto all()
Definition: query_fns.h:10
armarx::ARMARX_DECOUPLED_REGISTER_COMPONENT
ARMARX_DECOUPLED_REGISTER_COMPONENT(JsonStorage)
Color
uint32_t Color
RGBA color.
Definition: color.h:8
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::viz::Mesh::faces
Mesh & faces(const data::Face *fs, std::size_t size)
Definition: Mesh.h:73
armarx::viz::ArrowCircle::width
ArrowCircle & width(float w)
Definition: Elements.h:242
armarx::viz::Object
Definition: Elements.h:321
armarx::viz::Polygon::addPoint
Polygon & addPoint(Eigen::Vector3f p)
Definition: Elements.h:294
M_PI
#define M_PI
Definition: MathTools.h:17
armarx::ArVizExample::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: ArVizExample.cpp:57
armarx::fillPointsLayer
void fillPointsLayer(viz::Layer &layer, double timeInSeconds)
Definition: ArVizExample.cpp:417
armarx::fillManyElementsLayer
void fillManyElementsLayer(viz::Layer &layer, double timeInSeconds)
Definition: ArVizExample.cpp:520
armarx::fillExampleLayer
void fillExampleLayer(viz::Layer &layer, double timeInSeconds)
Definition: ArVizExample.cpp:276
armarx::viz::CommitResult::interactions
InteractionFeedbackRange interactions() const
Definition: Client.h:81
armarx::ArVizExample::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: ArVizExample.cpp:63
armarx::armem::human::Robot
@ Robot
Definition: util.h:14
armarx::viz::InteractionFeedbackType::Transform
@ Transform
The element was transformed (translated or rotated).
armarx::viz::Cylinder
Definition: Elements.h:74
armarx::viz::Sphere::radius
Sphere & radius(float r)
Definition: Elements.h:138
armarx::viz::StagedCommit::requestInteraction
void requestInteraction(Layer const &layer)
Request interaction feedback for a particular layer.
Definition: Client.h:55
armarx::viz::Mesh::colors
Mesh & colors(const data::Color *cs, std::size_t size)
Definition: Mesh.h:62
armarx::viz::ElementOps::orientation
DerivedT & orientation(Eigen::Quaternionf const &ori)
Definition: ElementOps.h:140
armarx::viz::Arrow::direction
Arrow & direction(Eigen::Vector3f dir)
Definition: Elements.cpp:98
armarx::viz::Polygon::lineWidth
Polygon & lineWidth(float w)
Definition: Elements.h:285
armarx::viz::Robot::useCollisionModel
Robot & useCollisionModel()
Definition: Robot.h:31
armarx::viz::Ellipsoid
Definition: Elements.h:147
armarx::viz::Robot::overrideColor
Robot & overrideColor(Color c)
Definition: Robot.h:45
armarx::viz::PointCloud
Definition: PointCloud.h:21
armarx::viz::Box
Definition: Elements.h:51
armarx::viz::Pose
Definition: Elements.h:179
armarx::viz::Robot
Definition: Robot.h:10
armarx::viz::InteractionFeedbackRange
Definition: Interaction.h:135
max
T max(T t1, T t2)
Definition: gdiam.h:48
Eigen::Quaternionf
Quaternion< float, 0 > Quaternionf
Definition: EigenForwardDeclarations.h:61
armarx::viz::CommitResult
Definition: Client.h:74
armarx::viz::InteractionFeedback
Definition: Interaction.h:57
armarx::viz::Polygon
Definition: Elements.h:258
armarx::viz::Color::red
static Color red(int r=255, int a=255)
Definition: Color.h:79
armarx::to_string
const std::string & to_string(const std::string &s)
Definition: StringHelpers.h:40
armarx::viz::Text
Definition: Elements.h:185
visionx::PointCloud
pcl::PointCloud< Point > PointCloud
Definition: RCPointCloudProvider.cpp:54
armarx::fillDisAppearingLayer
void fillDisAppearingLayer(viz::Layer &layer, double timeInSeconds)
Definition: ArVizExample.cpp:482
armarx::TimeUtil::GetTime
static IceUtil::Time GetTime(TimeMode timeMode=TimeMode::VirtualTime)
Get the current time.
Definition: TimeUtil.cpp:42
CycleUtil.h
ArVizExample.h
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:74
Decoupled.h
armarx::viz::Mesh::vertices
Mesh & vertices(const Eigen::Vector3f *vs, std::size_t size)
Definition: Mesh.h:33
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
TimeUtil.h
float
#define float
Definition: 16_Level.h:22
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::ArVizComponentPluginUser::arviz
armarx::viz::Client arviz
Definition: ArVizComponentPlugin.h:43
armarx::viz::ElementOps::scale
DerivedT & scale(Eigen::Vector3f scale)
Definition: ElementOps.h:227
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::viz::Box::size
Box & size(Eigen::Vector3f const &s)
Definition: Elements.h:55
armarx::viz::ElementOps::color
DerivedT & color(Color color)
Definition: ElementOps.h:195
armarx::viz::toString
const char * toString(InteractionFeedbackType type)
Definition: Interaction.h:27
armarx::viz::ArrowCircle::completion
ArrowCircle & completion(float c)
Definition: Elements.h:249
armarx::ArVizExample::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: ArVizExample.cpp:81
angle
double angle(const Point &a, const Point &b, const Point &c)
Definition: point.hpp:100
armarx::armem::server::ltm::detail::mixin::Path
std::filesystem::path Path
Definition: DiskStorageMixin.h:17
armarx::fillInteractionLayer
void fillInteractionLayer(viz::Layer &layer)
Definition: ArVizExample.cpp:586
armarx::viz::InteractionFeedbackRange::size
std::size_t size() const
Definition: Interaction.h:147
pc
Introduction Thank you for taking interest in our work and downloading this software This library implements the algorithm described in the paper R R R Klein Efficient RANSAC for Point Cloud Shape in Computer Graphics Blackwell June If you use this software you should cite the aforementioned paper in any resulting publication Please send comments or bug reports to Ruwen Roland BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY OR CONSEQUENTIAL WHETHER IN STRICT OR EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE Example usage This section shows how to use the library to detect the shapes in a point cloud PointCloud pc
Definition: ReadMe.txt:68
armarx::viz::Color::green
static Color green(int g=255, int a=255)
Definition: Color.h:84
min
T min(T t1, T t2)
Definition: gdiam.h:42
armarx::viz::Path
Definition: Path.h:31
armarx::viz::Client::layer
Layer layer(std::string const &name) const
Definition: Client.cpp:73
armarx::viz::Line
Definition: Line.h:29
armarx::viz::Client
Definition: Client.h:109
armarx::ArVizComponentPluginUser::createArVizClient
armarx::viz::Client createArVizClient()
Definition: ArVizComponentPlugin.cpp:79
armarx::viz::Layer
Definition: Layer.h:12
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::viz::Polygon::lineColor
Polygon & lineColor(Color color)
Definition: Elements.h:268
armarx::green
QColor green()
Definition: StyleSheets.h:72
Line
Eigen::ParametrizedLine< float, 2 > Line
Definition: LaserScannerSelfLocalisation.cpp:51
armarx::ArVizExample::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: ArVizExample.cpp:74
armarx::ArVizExample::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: ArVizExample.cpp:89
armarx::viz::ElementOps::enable
DerivedT & enable(InteractionDescription const &interactionDescription)
Definition: ElementOps.h:274
armarx::fillPermanentLayer
void fillPermanentLayer(viz::Layer &layer)
Definition: ArVizExample.cpp:406
armarx::viz::ElementOps::visible
DerivedT & visible(bool visible)
Definition: ElementOps.h:262
armarx::viz::Mesh::grid2D
Mesh & grid2D(Eigen::Vector2f extents, Eigen::Vector2i numPoints, std::function< viz::Color(size_t i, size_t j, const Eigen::Vector3f &p)> colorFunc)
Builds a regular 2D grid in the xy-plane.
armarx::fillTestLayer
void fillTestLayer(viz::Layer &layer, double timeInSeconds)
Definition: ArVizExample.cpp:94
armarx::viz::ArrowCircle
Definition: Elements.h:229