DebugDrawerToArViz.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::DebugDrawerToArViz
17 * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu )
18 * @date 2020
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#include "DebugDrawerToArViz.h"
24
25#include <SimoxUtility/color/interpolation.h>
26#include <SimoxUtility/math/pose/pose.h>
27
30
32
33
34#define FUNCTION_NOT_IMPLEMENTED_MESSAGE \
35 "Function DebugDrawerToArViz::" << __FUNCTION__ << "(): Not implemented."
36
37#define LOG_FUNCTION_NOT_IMPLEMENTED_MESSAGE() ARMARX_VERBOSE << FUNCTION_NOT_IMPLEMENTED_MESSAGE
38
39namespace armarx
40{
41
42 namespace
43 {
44 Eigen::Vector3f
45 toEigen(Vector3BasePtr v)
46 {
48 return {v->x, v->y, v->z};
49 }
50
51 Eigen::Vector3f
52 toEigen(DebugDrawerPointCloudElement e)
53 {
54 return {e.x, e.y, e.z};
55 }
56
58 toEigen(QuaternionBasePtr q)
59 {
61 return Eigen::Quaternionf(q->qw, q->qx, q->qy, q->qz);
62 }
63
64 Eigen::Matrix4f
65 toEigen(PoseBasePtr pose)
66 {
68 return simox::math::pose(toEigen(pose->position), toEigen(pose->orientation));
69 }
70
71 simox::Color
72 toSimox(DrawColor c)
73 {
74 return simox::Color(c.r, c.g, c.b, c.a);
75 }
76
78 toViz(DrawColor c)
79 {
80 return viz::Color(toSimox(c));
81 }
82 } // namespace
83
84 void
86 {
87 this->arviz = arviz;
88 }
89
90 void
91 DebugDrawerToArViz::updateBlackWhitelist(const BlackWhitelistUpdate& update,
92 const Ice::Current&)
93 {
94 std::scoped_lock lock(mutex);
95
97 ARMARX_VERBOSE << "Updated layer black-whitelist: \n" << layerBlackWhitelist;
98
99 // Remove all excluded layers.
100 std::vector<viz::Layer> cleared;
101 for (const auto& [name, layer] : layers)
102 {
103 if (layerBlackWhitelist.isExcluded(name))
104 {
105 cleared.push_back(arviz.layer(name));
106 }
107 }
108 if (!cleared.empty())
109 {
110 arviz.commit(cleared);
111 }
112 }
113
114 void
115 DebugDrawerToArViz::exportScene(const std::string&, const Ice::Current&)
116 {
118 }
119
120 void
121 DebugDrawerToArViz::exportLayer(const std::string&, const std::string&, const Ice::Current&)
122 {
124 }
125
126 void
127 DebugDrawerToArViz::setPoseVisu(const std::string& layer,
128 const std::string& name,
129 const PoseBasePtr& globalPose,
130 const Ice::Current&)
131 {
132 std::scoped_lock lock(mutex);
133 if (layerBlackWhitelist.isExcluded(layer))
134 {
135 return;
136 }
137 setAndCommit(layer, viz::Pose(name).pose(toEigen(globalPose)));
138 }
139
140 void
142 const std::string& name,
143 const PoseBasePtr& globalPose,
144 Ice::Float scale,
145 const Ice::Current&)
146 {
147 std::scoped_lock lock(mutex);
148 if (layerBlackWhitelist.isExcluded(layer))
149 {
150 return;
151 }
152 setAndCommit(layer, viz::Pose(name).pose(toEigen(globalPose)).scale(scale));
153 }
154
155 void
156 DebugDrawerToArViz::setLineVisu(const std::string& layer,
157 const std::string& name,
158 const Vector3BasePtr& globalPosition1,
159 const Vector3BasePtr& globalPosition2,
160 Ice::Float lineWidth,
161 const DrawColor& color,
162 const Ice::Current&)
163 {
164 std::scoped_lock lock(mutex);
165 if (layerBlackWhitelist.isExcluded(layer))
166 {
167 return;
168 }
169 setAndCommit(layer,
170 viz::Path(name)
171 .addPoint(toEigen(globalPosition1))
172 .addPoint(toEigen(globalPosition2))
173 .color(toViz(color))
174 .width(lineWidth)
175 .color(simox::Color::black(0)));
176 }
177
178 void
179 DebugDrawerToArViz::setLineSetVisu(const std::string& layerName,
180 const std::string& name,
181 const DebugDrawerLineSet& lineSet,
182 const Ice::Current&)
183 {
184 std::scoped_lock lock(mutex);
185 if (layerBlackWhitelist.isExcluded(layerName))
186 {
187 return;
188 }
189
190 viz::Layer& layer = getLayer(layerName);
191 ARMARX_CHECK_EQUAL(lineSet.points.size() % 2, 0) << VAROUT(lineSet.points.size());
192 ARMARX_CHECK_EQUAL(lineSet.intensities.size(), lineSet.points.size() / 2);
193
194 if (lineSet.useHeatMap)
195 {
196 ARMARX_VERBOSE << "DebugDrawerToArViz::" << __FUNCTION__ << "(): "
197 << "'useHeatMap' not supported.";
198 }
199
200 simox::Color color0 = toSimox(lineSet.colorNoIntensity);
201 simox::Color color1 = toSimox(lineSet.colorFullIntensity);
202
203 for (size_t i = 0; i + 1 < lineSet.points.size(); i += 2)
204 {
205 const auto& p1 = lineSet.points[i];
206 const auto& p2 = lineSet.points[i + 1];
207 float intensity = lineSet.intensities[i / 2];
208 simox::Color color = simox::color::interpol::linear(intensity, color0, color1);
209
210 std::stringstream ss;
211 ss << name << "/" << i << "_" << i + 1;
212 setLayerElement(layer,
213 viz::Polygon(ss.str())
214 .addPoint(toEigen(p1))
215 .addPoint(toEigen(p2))
216 .lineColor(color)
217 .lineWidth(lineSet.lineWidth)
218 .color(simox::Color::black(0)));
219 }
220 arviz.commit({layer});
221 }
222
223 void
224 DebugDrawerToArViz::setBoxVisu(const std::string& layer,
225 const std::string& name,
226 const PoseBasePtr& globalPose,
227 const Vector3BasePtr& dimensions,
228 const DrawColor& color,
229 const Ice::Current&)
230 {
231 std::scoped_lock lock(mutex);
232 if (layerBlackWhitelist.isExcluded(layer))
233 {
234 return;
235 }
236 setAndCommit(
237 layer,
238 viz::Box(name).pose(toEigen(globalPose)).size(toEigen(dimensions)).color(toViz(color)));
239 }
240
241 void
242 DebugDrawerToArViz::setTextVisu(const std::string& layer,
243 const std::string& name,
244 const std::string& text,
245 const Vector3BasePtr& globalPosition,
246 const DrawColor& color,
247 Ice::Int size,
248 const Ice::Current&)
249 {
250 std::scoped_lock lock(mutex);
251 if (layerBlackWhitelist.isExcluded(layer))
252 {
253 return;
254 }
255 setAndCommit(layer,
256 viz::Text(name)
257 .text(text)
258 .position(toEigen(globalPosition))
259 .scale(size)
260 .color(toViz(color)));
261 }
262
263 void
264 DebugDrawerToArViz::setSphereVisu(const std::string& layer,
265 const std::string& name,
266 const Vector3BasePtr& globalPosition,
267 const DrawColor& color,
268 Ice::Float radius,
269 const Ice::Current&)
270 {
271 std::scoped_lock lock(mutex);
272 if (layerBlackWhitelist.isExcluded(layer))
273 {
274 return;
275 }
276 setAndCommit(
277 layer,
278 viz::Sphere(name).position(toEigen(globalPosition)).radius(radius).color(toViz(color)));
279 }
280
281 void
283 const std::string& name,
284 const DebugDrawerPointCloud& pointCloud,
285 const Ice::Current&)
286 {
287 std::scoped_lock lock(mutex);
288 if (layerBlackWhitelist.isExcluded(layer))
289 {
290 return;
291 }
292
293 viz::PointCloud cloud(name);
294 for (const auto& p : pointCloud.points)
295 {
296 cloud.addPoint(p.x, p.y, p.z);
297 }
298 setAndCommit(layer, cloud.pointSizeInPixels(pointCloud.pointSize));
299 }
300
301 void
303 const std::string& name,
304 const DebugDrawerColoredPointCloud& pointCloud,
305 const Ice::Current&)
306 {
307 std::scoped_lock lock(mutex);
308 if (layerBlackWhitelist.isExcluded(layer))
309 {
310 return;
311 }
312
313 viz::PointCloud cloud(name);
314 for (const auto& p : pointCloud.points)
315 {
316 viz::ColoredPoint cp;
317 cp.x = p.x;
318 cp.y = p.y;
319 cp.z = p.z;
320 cp.color = toViz(p.color);
321 cloud.addPoint(cp);
322 }
323 setAndCommit(layer, cloud.pointSizeInPixels(pointCloud.pointSize));
324 }
325
326 void
328 const std::string& layer,
329 const std::string& name,
330 const DebugDrawer24BitColoredPointCloud& pointCloud,
331 const Ice::Current&)
332 {
333 std::scoped_lock lock(mutex);
334 if (layerBlackWhitelist.isExcluded(layer))
335 {
336 return;
337 }
338
339 viz::PointCloud cloud(name);
340 for (const auto& p : pointCloud.points)
341 {
342 viz::ColoredPoint cp;
343 cp.x = p.x;
344 cp.y = p.y;
345 cp.z = p.z;
346 cp.color = viz::Color(simox::Color(p.color.r, p.color.g, p.color.b));
347 cloud.addPoint(cp);
348 }
349 setAndCommit(layer, cloud.pointSizeInPixels(pointCloud.pointSize));
350 }
351
352 void
353 DebugDrawerToArViz::setPolygonVisu(const std::string& layer,
354 const std::string& name,
355 const PolygonPointList& polygonPoints,
356 const DrawColor& colorInner,
357 const DrawColor& colorBorder,
358 Ice::Float lineWidth,
359 const Ice::Current&)
360 {
361 std::scoped_lock lock(mutex);
362 if (layerBlackWhitelist.isExcluded(layer))
363 {
364 return;
365 }
366
367 viz::Polygon poly(name);
368 for (const auto& p : polygonPoints)
369 {
370 poly.addPoint(toEigen(p));
371 }
372 setAndCommit(
373 layer,
374 poly.color(toViz(colorInner)).lineColor(toViz(colorBorder)).lineWidth(lineWidth));
375 }
376
377 void
378 DebugDrawerToArViz::setTriMeshVisu(const std::string& layer,
379 const std::string& name,
380 const DebugDrawerTriMesh& triMesh,
381 const Ice::Current&)
382 {
383 std::scoped_lock lock(mutex);
384 if (layerBlackWhitelist.isExcluded(layer))
385 {
386 return;
387 }
388
389 std::vector<Eigen::Vector3f> vertices;
390 std::vector<viz::data::Color> colors;
391 std::vector<viz::data::Face> faces;
392 for (const auto& v : triMesh.vertices)
393 {
394 vertices.emplace_back(v.x, v.y, v.z);
395 }
396 for (const auto& c : triMesh.colors)
397 {
398 colors.emplace_back(toViz(c));
399 }
400 for (const auto& f : triMesh.faces)
401 {
402 viz::data::Face& face = faces.emplace_back();
403 face.v0 = f.vertex1.vertexID;
404 face.v1 = f.vertex2.vertexID;
405 face.v2 = f.vertex3.vertexID;
406 face.c0 = f.vertex1.colorID;
407 face.c1 = f.vertex2.colorID;
408 face.c2 = f.vertex3.colorID;
409 }
410 setAndCommit(layer, viz::Mesh(name).vertices(vertices).colors(colors).faces(faces));
411 }
412
413 void
414 DebugDrawerToArViz::setArrowVisu(const std::string& layer,
415 const std::string& name,
416 const Vector3BasePtr& position,
417 const Vector3BasePtr& direction,
418 const DrawColor& color,
419 Ice::Float length,
420 Ice::Float width,
421 const Ice::Current&)
422 {
423 std::scoped_lock lock(mutex);
424 if (layerBlackWhitelist.isExcluded(layer))
425 {
426 return;
427 }
428 setAndCommit(layer,
429 viz::Arrow(name)
430 .position(toEigen(position))
431 .direction(toEigen(direction))
432 .color(toViz(color))
433 .width(width)
434 .length(length));
435 }
436
437 void
438 DebugDrawerToArViz::setCylinderVisu(const std::string& layer,
439 const std::string& name,
440 const Vector3BasePtr& globalPosition,
441 const Vector3BasePtr& direction,
442 Ice::Float length,
443 Ice::Float radius,
444 const DrawColor& color,
445 const Ice::Current&)
446 {
447 std::scoped_lock lock(mutex);
448 if (layerBlackWhitelist.isExcluded(layer))
449 {
450 return;
451 }
452 setAndCommit(layer,
453 viz::Cylinder(name)
454 .fromTo(toEigen(globalPosition),
455 toEigen(globalPosition) + length * toEigen(direction))
456 .color(toViz(color))
457 .radius(radius));
458 }
459
460 void
462 const std::string& name,
463 const Vector3BasePtr& globalPosition,
464 const Vector3BasePtr& directionVec,
465 Ice::Float radius,
466 Ice::Float circleCompletion,
467 Ice::Float width,
468 const DrawColor& color,
469 const Ice::Current&)
470 {
471 std::scoped_lock lock(mutex);
472 if (layerBlackWhitelist.isExcluded(layer))
473 {
474 return;
475 }
476 setAndCommit(layer,
477 viz::ArrowCircle(name)
478 .position(toEigen(globalPosition))
479 .normal(toEigen(directionVec))
480 .radius(radius)
481 .completion(circleCompletion)
482 .color(toViz(color))
483 .width(width));
484 }
485
486 void
487 DebugDrawerToArViz::setRobotVisu(const std::string& layer,
488 const std::string& name,
489 const std::string& robotFile,
490 const std::string& armarxProject,
491 DrawStyle drawStyleType,
492 const Ice::Current&)
493 {
494 std::scoped_lock lock(mutex);
495 if (layerBlackWhitelist.isExcluded(layer))
496 {
497 return;
498 }
499
500 viz::Robot robot = viz::Robot(name).file(armarxProject, robotFile);
501 switch (drawStyleType)
502 {
503 case DrawStyle::CollisionModel:
504 robot.useCollisionModel();
505 break;
506 case DrawStyle::FullModel:
507 robot.useFullModel();
508 break;
509 }
510
511 robots.emplace(std::make_pair(layer, name), robot);
512 setAndCommit(layer, robot);
513 }
514
515 void
516 DebugDrawerToArViz::updateRobotPose(const std::string& layer,
517 const std::string& name,
518 const PoseBasePtr& globalPose,
519 const Ice::Current&)
520 {
521 std::scoped_lock lock(mutex);
522 if (layerBlackWhitelist.isExcluded(layer))
523 {
524 return;
525 }
526 if (auto it = robots.find(std::make_pair(layer, name)); it != robots.end())
527 {
528 viz::Robot& robot = it->second;
529 robot.pose(toEigen(globalPose));
530 }
531 arviz.commit({getLayer(layer)});
532 }
533
534 void
536 const std::string& name,
537 const NameValueMap& configuration,
538 const Ice::Current&)
539 {
540 std::scoped_lock lock(mutex);
541 if (layerBlackWhitelist.isExcluded(layer))
542 {
543 return;
544 }
545 if (auto it = robots.find(std::make_pair(layer, name)); it != robots.end())
546 {
547 viz::Robot& robot = it->second;
548 robot.joints(configuration);
549 }
550 arviz.commit({getLayer(layer)});
551 }
552
553 void
554 DebugDrawerToArViz::updateRobotColor(const std::string& layer,
555 const std::string& name,
556 const DrawColor& color,
557 const Ice::Current&)
558 {
559 std::scoped_lock lock(mutex);
560 if (layerBlackWhitelist.isExcluded(layer))
561 {
562 return;
563 }
564 if (auto it = robots.find(std::make_pair(layer, name)); it != robots.end())
565 {
566 viz::Robot& robot = it->second;
567 robot.overrideColor(toViz(color));
568 }
569 arviz.commit({getLayer(layer)});
570 }
571
572 void
574 const std::string& name,
575 const std::string& robotNodeName,
576 const DrawColor& color,
577 const Ice::Current&)
578 {
579 (void)layer, (void)name, (void)robotNodeName, (void)color;
581 }
582
583 void
584 DebugDrawerToArViz::removeRobotVisu(const std::string& layer,
585 const std::string& name,
586 const Ice::Current&)
587 {
588 std::scoped_lock lock(mutex);
589 if (layerBlackWhitelist.isExcluded(layer))
590 {
591 return;
592 }
593 robots.erase(std::make_pair(layer, name));
594 removeAndCommit(layer, name);
595 }
596
597 void
599 const PoseBasePtr& globalPose,
600 const Ice::Current& c)
601 {
602 setPoseVisu(DEBUG_LAYER_NAME, name, globalPose, c);
603 }
604
605 void
607 const PoseBasePtr& globalPose,
608 Ice::Float scale,
609 const Ice::Current& c)
610 {
611 setScaledPoseVisu(DEBUG_LAYER_NAME, name, globalPose, scale, c);
612 }
613
614 void
616 const Vector3BasePtr& globalPosition1,
617 const Vector3BasePtr& globalPosition2,
618 Ice::Float lineWidth,
619 const DrawColor& color,
620 const Ice::Current& c)
621 {
622 setLineVisu(DEBUG_LAYER_NAME, name, globalPosition1, globalPosition2, lineWidth, color, c);
623 }
624
625 void
627 const DebugDrawerLineSet& lineSet,
628 const Ice::Current& c)
629 {
630 setLineSetVisu(DEBUG_LAYER_NAME, name, lineSet, c);
631 }
632
633 void
635 const PoseBasePtr& globalPose,
636 const Vector3BasePtr& dimensions,
637 const DrawColor& color,
638 const Ice::Current& c)
639 {
640 setBoxVisu(DEBUG_LAYER_NAME, name, globalPose, dimensions, color, c);
641 }
642
643 void
645 const std::string& text,
646 const Vector3BasePtr& globalPosition,
647 const DrawColor& color,
648 Ice::Int size,
649 const Ice::Current& c)
650 {
651 setTextVisu(DEBUG_LAYER_NAME, name, text, globalPosition, color, size, c);
652 }
653
654 void
656 const Vector3BasePtr& globalPosition,
657 const DrawColor& color,
658 Ice::Float radius,
659 const Ice::Current& c)
660 {
661 setSphereVisu(DEBUG_LAYER_NAME, name, globalPosition, color, radius, c);
662 }
663
664 void
666 const DebugDrawerPointCloud& pointCloud,
667 const Ice::Current& c)
668 {
669 setPointCloudVisu(DEBUG_LAYER_NAME, name, pointCloud, c);
670 }
671
672 void
674 const std::string& name,
675 const DebugDrawer24BitColoredPointCloud& pointCloud,
676 const Ice::Current& c)
677 {
678 set24BitColoredPointCloudVisu(DEBUG_LAYER_NAME, name, pointCloud, c);
679 }
680
681 void
683 const PolygonPointList& polygonPoints,
684 const DrawColor& colorInner,
685 const DrawColor& colorBorder,
686 Ice::Float lineWidth,
687 const Ice::Current& c)
688 {
690 DEBUG_LAYER_NAME, name, polygonPoints, colorInner, colorBorder, lineWidth, c);
691 }
692
693 void
695 const DebugDrawerTriMesh& triMesh,
696 const Ice::Current& c)
697 {
698 setTriMeshVisu(DEBUG_LAYER_NAME, name, triMesh, c);
699 }
700
701 void
703 const Vector3BasePtr& position,
704 const Vector3BasePtr& direction,
705 const DrawColor& color,
706 Ice::Float length,
707 Ice::Float width,
708 const Ice::Current& c)
709 {
710 setArrowVisu(DEBUG_LAYER_NAME, name, position, direction, color, length, width, c);
711 }
712
713 void
715 const Vector3BasePtr& globalPosition,
716 const Vector3BasePtr& direction,
717 Ice::Float length,
718 Ice::Float radius,
719 const DrawColor& color,
720 const Ice::Current& c)
721 {
723 DEBUG_LAYER_NAME, name, globalPosition, direction, length, radius, color, c);
724 }
725
726 void
728 const Vector3BasePtr& globalPosition,
729 const Vector3BasePtr& directionVec,
730 Ice::Float radius,
731 Ice::Float circleCompletion,
732 Ice::Float width,
733 const DrawColor& color,
734 const Ice::Current&)
735 {
736 (void)name, (void)globalPosition, (void)directionVec, (void)radius, (void)circleCompletion,
737 (void)width, (void)color;
739 }
740
741 void
742 DebugDrawerToArViz::removePoseVisu(const std::string& layer,
743 const std::string& name,
744 const Ice::Current&)
745 {
746 std::scoped_lock lock(mutex);
747 if (layerBlackWhitelist.isIncluded(layer))
748 {
749 removeAndCommit(layer, name);
750 }
751 }
752
753 void
754 DebugDrawerToArViz::removeLineVisu(const std::string& layer,
755 const std::string& name,
756 const Ice::Current&)
757 {
758 std::scoped_lock lock(mutex);
759 if (layerBlackWhitelist.isIncluded(layer))
760 {
761 removeAndCommit(layer, name);
762 }
763 }
764
765 void
767 const std::string& name,
768 const Ice::Current&)
769 {
770 std::scoped_lock lock(mutex);
771 if (layerBlackWhitelist.isIncluded(layer))
772 {
773 removeAndCommit(layer, name);
774 }
775 }
776
777 void
778 DebugDrawerToArViz::removeBoxVisu(const std::string& layer,
779 const std::string& name,
780 const Ice::Current&)
781 {
782 std::scoped_lock lock(mutex);
783 if (layerBlackWhitelist.isIncluded(layer))
784 {
785 removeAndCommit(layer, name);
786 }
787 }
788
789 void
790 DebugDrawerToArViz::removeTextVisu(const std::string& layer,
791 const std::string& name,
792 const Ice::Current&)
793 {
794 std::scoped_lock lock(mutex);
795 if (layerBlackWhitelist.isIncluded(layer))
796 {
797 removeAndCommit(layer, name);
798 }
799 }
800
801 void
802 DebugDrawerToArViz::removeSphereVisu(const std::string& layer,
803 const std::string& name,
804 const Ice::Current&)
805 {
806 std::scoped_lock lock(mutex);
807 if (layerBlackWhitelist.isIncluded(layer))
808 {
809 removeAndCommit(layer, name);
810 }
811 }
812
813 void
815 const std::string& name,
816 const Ice::Current&)
817 {
818 std::scoped_lock lock(mutex);
819 if (layerBlackWhitelist.isIncluded(layer))
820 {
821 removeAndCommit(layer, name);
822 }
823 }
824
825 void
827 const std::string& name,
828 const Ice::Current&)
829 {
830 std::scoped_lock lock(mutex);
831 if (layerBlackWhitelist.isIncluded(layer))
832 {
833 removeAndCommit(layer, name);
834 }
835 }
836
837 void
839 const std::string& name,
840 const Ice::Current&)
841 {
842 std::scoped_lock lock(mutex);
843 if (layerBlackWhitelist.isIncluded(layer))
844 {
845 removeAndCommit(layer, name);
846 }
847 }
848
849 void
851 const std::string& name,
852 const Ice::Current&)
853 {
854 std::scoped_lock lock(mutex);
855 if (layerBlackWhitelist.isIncluded(layer))
856 {
857 removeAndCommit(layer, name);
858 }
859 }
860
861 void
863 const std::string& name,
864 const Ice::Current&)
865 {
866 std::scoped_lock lock(mutex);
867 if (layerBlackWhitelist.isIncluded(layer))
868 {
869 removeAndCommit(layer, name);
870 }
871 }
872
873 void
874 DebugDrawerToArViz::removeArrowVisu(const std::string& layer,
875 const std::string& name,
876 const Ice::Current&)
877 {
878 std::scoped_lock lock(mutex);
879 if (layerBlackWhitelist.isIncluded(layer))
880 {
881 removeAndCommit(layer, name);
882 }
883 }
884
885 void
887 const std::string& name,
888 const Ice::Current&)
889 {
890 std::scoped_lock lock(mutex);
891 if (layerBlackWhitelist.isIncluded(layer))
892 {
893 removeAndCommit(layer, name);
894 }
895 }
896
897 void
898 DebugDrawerToArViz::removeCircleVisu(const std::string& layer,
899 const std::string& name,
900 const Ice::Current&)
901 {
902 std::scoped_lock lock(mutex);
903 if (layerBlackWhitelist.isIncluded(layer))
904 {
905 removeAndCommit(layer, name);
906 }
907 }
908
909 void
910 DebugDrawerToArViz::removePoseDebugLayerVisu(const std::string& name, const Ice::Current&)
911 {
912 removePointCloudVisu(DEBUG_LAYER_NAME, name);
913 }
914
915 void
916 DebugDrawerToArViz::removeLineDebugLayerVisu(const std::string& name, const Ice::Current&)
917 {
918 removeLineVisu(DEBUG_LAYER_NAME, name);
919 }
920
921 void
922 DebugDrawerToArViz::removeLineSetDebugLayerVisu(const std::string& name, const Ice::Current&)
923 {
924 removeLineSetVisu(DEBUG_LAYER_NAME, name);
925 }
926
927 void
928 DebugDrawerToArViz::removeBoxDebugLayerVisu(const std::string& name, const Ice::Current&)
929 {
930 removeBoxVisu(DEBUG_LAYER_NAME, name);
931 }
932
933 void
934 DebugDrawerToArViz::removeTextDebugLayerVisu(const std::string& name, const Ice::Current&)
935 {
936 removeTextVisu(DEBUG_LAYER_NAME, name);
937 }
938
939 void
940 DebugDrawerToArViz::removeSphereDebugLayerVisu(const std::string& name, const Ice::Current&)
941 {
942 removeSphereVisu(DEBUG_LAYER_NAME, name);
943 }
944
945 void
946 DebugDrawerToArViz::removePointCloudDebugLayerVisu(const std::string& name, const Ice::Current&)
947 {
948 removePointCloudVisu(DEBUG_LAYER_NAME, name);
949 }
950
951 void
953 const Ice::Current&)
954 {
955 removeColoredPointCloudVisu(DEBUG_LAYER_NAME, name);
956 }
957
958 void
960 const Ice::Current&)
961 {
962 remove24BitColoredPointCloudVisu(DEBUG_LAYER_NAME, name);
963 }
964
965 void
966 DebugDrawerToArViz::removePolygonDebugLayerVisu(const std::string& name, const Ice::Current&)
967 {
968 removePolygonVisu(DEBUG_LAYER_NAME, name);
969 }
970
971 void
972 DebugDrawerToArViz::removeTriMeshDebugLayerVisu(const std::string& name, const Ice::Current&)
973 {
974 removeTriMeshVisu(DEBUG_LAYER_NAME, name);
975 }
976
977 void
978 DebugDrawerToArViz::removeArrowDebugLayerVisu(const std::string& name, const Ice::Current&)
979 {
980 removeArrowVisu(DEBUG_LAYER_NAME, name);
981 }
982
983 void
984 DebugDrawerToArViz::removeCylinderDebugLayerVisu(const std::string& name, const Ice::Current&)
985 {
986 removeCylinderVisu(DEBUG_LAYER_NAME, name);
987 }
988
989 void
990 DebugDrawerToArViz::removeCircleDebugLayerVisu(const std::string& name, const Ice::Current&)
991 {
992 removeCircleVisu(DEBUG_LAYER_NAME, name);
993 }
994
995 void
996 DebugDrawerToArViz::clearAll(const Ice::Current&)
997 {
998 std::scoped_lock lock(mutex);
999
1000 std::vector<viz::Layer> commit;
1001 commit.reserve(layers.size());
1002 for (auto& [name, layer] : layers)
1003 {
1004 layer.clear();
1005 commit.push_back(layer);
1006 }
1007 arviz.commit(commit);
1008 }
1009
1010 void
1011 DebugDrawerToArViz::clearLayer(const std::string& layerName, const Ice::Current&)
1012 {
1013 std::scoped_lock lock(mutex);
1014
1015 viz::Layer layer = getLayer(layerName);
1016 layer.clear();
1017 arviz.commit({layer});
1018 }
1019
1020 void
1022 {
1023 clearLayer(DEBUG_LAYER_NAME);
1024 }
1025
1026 void
1027 DebugDrawerToArViz::enableLayerVisu(const std::string& layer, bool visible, const Ice::Current&)
1028 {
1029 (void)layer, (void)visible;
1031 }
1032
1033 void
1034 DebugDrawerToArViz::enableDebugLayerVisu(bool visible, const Ice::Current&)
1035 {
1036 enableLayerVisu(DEBUG_LAYER_NAME, visible);
1037 }
1038
1039 Ice::StringSeq
1041 {
1043 return {};
1044 }
1045
1046 LayerInformationSequence
1048 {
1050 return {};
1051 }
1052
1053 bool
1054 DebugDrawerToArViz::hasLayer(const std::string&, const Ice::Current&)
1055 {
1057 return false;
1058 }
1059
1060 void
1061 DebugDrawerToArViz::removeLayer(const std::string&, const Ice::Current&)
1062 {
1064 }
1065
1066 void
1071
1072 void
1077
1078 void
1079 DebugDrawerToArViz::enableSelections(const std::string&, const Ice::Current&)
1080 {
1082 }
1083
1084 void
1085 DebugDrawerToArViz::disableSelections(const std::string&, const Ice::Current&)
1086 {
1088 }
1089
1090 void
1091 DebugDrawerToArViz::clearSelections(const std::string&, const Ice::Current&)
1092 {
1094 }
1095
1096 void
1097 DebugDrawerToArViz::select(const std::string& layer,
1098 const std::string& elementName,
1099 const Ice::Current&)
1100 {
1101 (void)layer, (void)elementName;
1103 }
1104
1105 void
1106 DebugDrawerToArViz::deselect(const std::string& layer,
1107 const std::string& elementName,
1108 const Ice::Current&)
1109 {
1110 (void)layer, (void)elementName;
1112 }
1113
1114 DebugDrawerSelectionList
1116 {
1118 return {};
1119 }
1120
1121 viz::Layer&
1122 DebugDrawerToArViz::getLayer(const std::string& layerName)
1123 {
1124 if (auto it = layers.find(layerName); it != layers.end())
1125 {
1126 return it->second;
1127 }
1128 else
1129 {
1130 return layers.emplace(layerName, arviz.layer(layerName)).first->second;
1131 }
1132 }
1133
1134 viz::data::ElementSeq::iterator
1135 DebugDrawerToArViz::findLayerElement(viz::Layer& layer, const std::string& elementName)
1136 {
1137 return std::find_if(layer.data_.elements.begin(),
1138 layer.data_.elements.end(),
1139 [&elementName](const viz::data::ElementPtr& e)
1140 { return e->id == elementName; });
1141 }
1142
1143 void
1144 DebugDrawerToArViz::removeLayerElement(viz::Layer& layer, const std::string& name)
1145 {
1146 auto it = findLayerElement(layer, name);
1147 if (it != layer.data_.elements.end())
1148 {
1149 layer.data_.elements.erase(it);
1150 }
1151 }
1152
1153 void
1154 DebugDrawerToArViz::removeAndCommit(const std::string& layerName, const std::string& name)
1155 {
1156 viz::Layer& layer = getLayer(layerName);
1157 removeLayerElement(layer, name);
1158 arviz.commit({layer});
1159 }
1160
1161} // namespace armarx
#define LOG_FUNCTION_NOT_IMPLEMENTED_MESSAGE()
#define VAROUT(x)
constexpr T c
void removeRobotVisu(const std::string &layer, const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void removeLayer(const std::string &, const Ice::Current &=Ice::emptyCurrent) override
void setCircleArrowVisu(const std::string &layer, const std::string &name, const Vector3BasePtr &globalPosition, const Vector3BasePtr &directionVec, Ice::Float radius, Ice::Float circleCompletion, Ice::Float width, const DrawColor &color, const Ice::Current &=Ice::emptyCurrent) override
void setSphereVisu(const std::string &layer, const std::string &name, const Vector3BasePtr &globalPosition, const DrawColor &color, Ice::Float radius, const Ice::Current &=Ice::emptyCurrent) override
void setCircleDebugLayerVisu(const std::string &name, const Vector3BasePtr &globalPosition, const Vector3BasePtr &directionVec, Ice::Float radius, Ice::Float circleCompletion, Ice::Float width, const DrawColor &color, const Ice::Current &=Ice::emptyCurrent) override
void removeColoredPointCloudDebugLayerVisu(const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void enableLayerVisu(const std::string &layer, bool visible, const Ice::Current &=Ice::emptyCurrent) override
void clearDebugLayer(const Ice::Current &=Ice::emptyCurrent) override
void removeCircleDebugLayerVisu(const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void removeCircleVisu(const std::string &layer, const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void removeSphereDebugLayerVisu(const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void removePointCloudDebugLayerVisu(const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void removeArrowDebugLayerVisu(const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void setArViz(viz::Client arviz)
void setTriMeshDebugLayerVisu(const std::string &name, const DebugDrawerTriMesh &triMesh, const Ice::Current &=Ice::emptyCurrent) override
void setBoxVisu(const std::string &layer, const std::string &name, const PoseBasePtr &globalPose, const Vector3BasePtr &dimensions, const DrawColor &color, const Ice::Current &=Ice::emptyCurrent) override
void removePolygonDebugLayerVisu(const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void setPointCloudDebugLayerVisu(const std::string &name, const DebugDrawerPointCloud &pointCloud, const Ice::Current &=Ice::emptyCurrent) override
void remove24BitColoredPointCloudDebugLayerVisu(const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void setCylinderVisu(const std::string &layer, const std::string &name, const Vector3BasePtr &globalPosition, const Vector3BasePtr &direction, Ice::Float length, Ice::Float radius, const DrawColor &color, const Ice::Current &=Ice::emptyCurrent) override
LayerInformationSequence layerInformation(const Ice::Current &=Ice::emptyCurrent) override
void set24BitColoredPointCloudDebugLayerVisu(const std::string &name, const DebugDrawer24BitColoredPointCloud &pointCloud, const Ice::Current &=Ice::emptyCurrent) override
void set24BitColoredPointCloudVisu(const std::string &layer, const std::string &name, const DebugDrawer24BitColoredPointCloud &pointCloud, const Ice::Current &=Ice::emptyCurrent) override
void removeSphereVisu(const std::string &layer, const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void setColoredPointCloudVisu(const std::string &layer, const std::string &name, const DebugDrawerColoredPointCloud &pointCloud, const Ice::Current &=Ice::emptyCurrent) override
void setLineDebugLayerVisu(const std::string &name, const Vector3BasePtr &globalPosition1, const Vector3BasePtr &globalPosition2, Ice::Float lineWidth, const DrawColor &color, const Ice::Current &=Ice::emptyCurrent) override
void removeTextVisu(const std::string &layer, const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void updateRobotConfig(const std::string &layer, const std::string &name, const NameValueMap &configuration, const Ice::Current &=Ice::emptyCurrent) override
void enableAllLayers(const Ice::Current &=Ice::emptyCurrent) override
void removeCylinderDebugLayerVisu(const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void setScaledPoseVisu(const std::string &layer, const std::string &name, const PoseBasePtr &globalPose, Ice::Float scale, const Ice::Current &=Ice::emptyCurrent) override
void setLineVisu(const std::string &layer, const std::string &name, const Vector3BasePtr &globalPosition1, const Vector3BasePtr &globalPosition2, Ice::Float lineWidth, const DrawColor &color, const Ice::Current &=Ice::emptyCurrent) override
void removeTriMeshVisu(const std::string &layer, const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void setArrowVisu(const std::string &layer, const std::string &name, const Vector3BasePtr &position, const Vector3BasePtr &direction, const DrawColor &color, Ice::Float length, Ice::Float width, const Ice::Current &=Ice::emptyCurrent) override
void removeLineDebugLayerVisu(const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void removeLineSetVisu(const std::string &layer, const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void enableDebugLayerVisu(bool visible, const Ice::Current &=Ice::emptyCurrent) override
void updateRobotNodeColor(const std::string &layer, const std::string &name, const std::string &robotNodeName, const DrawColor &color, const Ice::Current &=Ice::emptyCurrent) override
void removePoseDebugLayerVisu(const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void clearSelections(const std::string &, const Ice::Current &=Ice::emptyCurrent) override
void setLineSetDebugLayerVisu(const std::string &name, const DebugDrawerLineSet &lineSet, const Ice::Current &=Ice::emptyCurrent) override
void exportScene(const std::string &filename, const Ice::Current &=Ice::emptyCurrent) override
void removePointCloudVisu(const std::string &layer, const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void removeLineVisu(const std::string &layer, const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void disableAllLayers(const Ice::Current &=Ice::emptyCurrent) override
void setTextVisu(const std::string &layer, const std::string &name, const std::string &text, const Vector3BasePtr &globalPosition, const DrawColor &color, Ice::Int size, const Ice::Current &=Ice::emptyCurrent) override
void removeTextDebugLayerVisu(const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void setPolygonVisu(const std::string &layer, const std::string &name, const PolygonPointList &polygonPoints, const DrawColor &colorInner, const DrawColor &colorBorder, Ice::Float lineWidth, const Ice::Current &=Ice::emptyCurrent) override
void removePolygonVisu(const std::string &layer, const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
bool hasLayer(const std::string &, const Ice::Current &=Ice::emptyCurrent) override
void setBoxDebugLayerVisu(const std::string &name, const PoseBasePtr &globalPose, const Vector3BasePtr &dimensions, const DrawColor &color, const Ice::Current &=Ice::emptyCurrent) override
armarx::StringBlackWhitelist layerBlackWhitelist
DebugDrawerSelectionList getSelections(const Ice::Current &=Ice::emptyCurrent) override
void setCylinderDebugLayerVisu(const std::string &name, const Vector3BasePtr &globalPosition, const Vector3BasePtr &direction, Ice::Float length, Ice::Float radius, const DrawColor &color, const Ice::Current &=Ice::emptyCurrent) override
void setSphereDebugLayerVisu(const std::string &name, const Vector3BasePtr &globalPosition, const DrawColor &color, Ice::Float radius, const Ice::Current &=Ice::emptyCurrent) override
void setPoseDebugLayerVisu(const std::string &name, const PoseBasePtr &globalPose, const Ice::Current &=Ice::emptyCurrent) override
void updateRobotPose(const std::string &layer, const std::string &name, const PoseBasePtr &globalPose, const Ice::Current &=Ice::emptyCurrent) override
void select(const std::string &layer, const std::string &elementName, const Ice::Current &=Ice::emptyCurrent) override
void setTriMeshVisu(const std::string &layer, const std::string &name, const DebugDrawerTriMesh &triMesh, const Ice::Current &=Ice::emptyCurrent) override
void removeColoredPointCloudVisu(const std::string &layer, const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
Ice::StringSeq layerNames(const Ice::Current &=Ice::emptyCurrent) override
void removeCylinderVisu(const std::string &layer, const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void setScaledPoseDebugLayerVisu(const std::string &name, const PoseBasePtr &globalPose, Ice::Float scale, const Ice::Current &=Ice::emptyCurrent) override
void updateRobotColor(const std::string &layer, const std::string &name, const DrawColor &color, const Ice::Current &=Ice::emptyCurrent) override
void setPoseVisu(const std::string &layer, const std::string &name, const PoseBasePtr &globalPose, const Ice::Current &=Ice::emptyCurrent) override
void enableSelections(const std::string &, const Ice::Current &=Ice::emptyCurrent) override
void removePoseVisu(const std::string &layer, const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void removeLineSetDebugLayerVisu(const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void removeBoxVisu(const std::string &layer, const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void clearAll(const Ice::Current &=Ice::emptyCurrent) override
void setRobotVisu(const std::string &layer, const std::string &name, const std::string &robotFile, const std::string &armarxProject, DrawStyle drawStyleType, const Ice::Current &=Ice::emptyCurrent) override
void exportLayer(const std::string &filename, const std::string &layerName, const Ice::Current &=Ice::emptyCurrent) override
void setPolygonDebugLayerVisu(const std::string &name, const PolygonPointList &polygonPoints, const DrawColor &colorInner, const DrawColor &colorBorder, Ice::Float lineWidth, const Ice::Current &=Ice::emptyCurrent) override
void clearLayer(const std::string &layer, const Ice::Current &=Ice::emptyCurrent) override
void removeTriMeshDebugLayerVisu(const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void setPointCloudVisu(const std::string &layer, const std::string &name, const DebugDrawerPointCloud &pointCloud, const Ice::Current &=Ice::emptyCurrent) override
void updateBlackWhitelist(const BlackWhitelistUpdate &update, const Ice::Current &=Ice::emptyCurrent) override
void removeBoxDebugLayerVisu(const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void disableSelections(const std::string &, const Ice::Current &=Ice::emptyCurrent) override
void remove24BitColoredPointCloudVisu(const std::string &layer, const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void deselect(const std::string &layer, const std::string &elementName, const Ice::Current &=Ice::emptyCurrent) override
void setArrowDebugLayerVisu(const std::string &name, const Vector3BasePtr &position, const Vector3BasePtr &direction, const DrawColor &color, Ice::Float length, Ice::Float width, const Ice::Current &=Ice::emptyCurrent) override
void setTextDebugLayerVisu(const std::string &name, const std::string &text, const Vector3BasePtr &globalPosition, const DrawColor &color, Ice::Int size, const Ice::Current &=Ice::emptyCurrent) override
void removeArrowVisu(const std::string &layer, const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
void setLineSetVisu(const std::string &layer, const std::string &name, const DebugDrawerLineSet &lineSet, const Ice::Current &=Ice::emptyCurrent) override
virtual Layer layer(std::string const &name) const
Definition Client.cpp:80
DerivedT & pose(Eigen::Matrix4f const &pose)
Definition ElementOps.h:176
DerivedT & color(Color color)
Definition ElementOps.h:218
PointCloud & pointSizeInPixels(float s)
Definition PointCloud.h:53
PointCloud & addPoint(ColoredPoint const &p)
Definition PointCloud.h:81
Robot & useFullModel()
Definition Robot.h:42
Robot & joints(std::map< std::string, float > const &values)
Definition Robot.h:74
Robot & useCollisionModel()
Definition Robot.h:34
Robot & file(std::string const &project, std::string const &filename)
Definition Robot.h:16
Robot & overrideColor(Color c)
Definition Robot.h:50
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
#define ARMARX_CHECK_EQUAL(lhs, rhs)
This macro evaluates whether lhs is equal (==) rhs and if it turns out to be false it will throw an E...
#define ARMARX_VERBOSE
The logging level for verbose information.
Definition Logging.h:187
#define q
Quaternion< float, 0 > Quaternionf
This file offers overloads of toIce() and fromIce() functions for STL container types.
void updateBlackWhitelist(StringBlackWhitelist &bw, const armarx::BlackWhitelistUpdate &update)
Eigen::Vector3f toEigen(const pcl::PointXYZ &pt)
data::LayerUpdate data_
Definition Layer.h:57
Polygon & addPoint(Eigen::Vector3f p)
Definition Elements.h:302