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