28#include <SimoxUtility/algorithm/string/string_tools.h>
29#include <VirtualRobot/Robot.h>
30#include <VirtualRobot/VirtualRobot.h>
31#include <VirtualRobot/Visualization/CoinVisualization/CoinVisualization.h>
32#include <VirtualRobot/Visualization/CoinVisualization/CoinVisualizationFactory.h>
33#include <VirtualRobot/Visualization/CoinVisualization/CoinVisualizationNode.h>
34#include <VirtualRobot/Visualization/TriMeshModel.h>
35#include <VirtualRobot/Visualization/VisualizationFactory.h>
36#include <VirtualRobot/XML/RobotIO.h>
43#include <Inventor/SbVec3f.h>
44#include <Inventor/actions/SoWriteAction.h>
45#include <Inventor/fields/SoMFColor.h>
46#include <Inventor/fields/SoMFVec3f.h>
47#include <Inventor/nodes/SoAnnotation.h>
48#include <Inventor/nodes/SoComplexity.h>
49#include <Inventor/nodes/SoCoordinate3.h>
50#include <Inventor/nodes/SoCube.h>
51#include <Inventor/nodes/SoCylinder.h>
52#include <Inventor/nodes/SoDrawStyle.h>
53#include <Inventor/nodes/SoFont.h>
54#include <Inventor/nodes/SoLineSet.h>
55#include <Inventor/nodes/SoMaterial.h>
56#include <Inventor/nodes/SoMaterialBinding.h>
57#include <Inventor/nodes/SoMatrixTransform.h>
58#include <Inventor/nodes/SoPointSet.h>
59#include <Inventor/nodes/SoShapeHints.h>
60#include <Inventor/nodes/SoSphere.h>
61#include <Inventor/nodes/SoText2.h>
62#include <Inventor/nodes/SoTransform.h>
63#include <Inventor/nodes/SoTranslation.h>
64#include <Inventor/nodes/SoUnits.h>
68#define SELECTION_NAME_PREFIX \
69 ("selection_" + std::to_string(reinterpret_cast<std::uintptr_t>(this)))
70#define SELECTION_NAME_SPLITTER "____"
71#define SELECTION_NAME(layerName, elementName) \
72 simox::alg::replace_all(std::string(SELECTION_NAME_PREFIX + "_" + layerName + \
73 SELECTION_NAME_SPLITTER + elementName), \
100 static const std::string DEBUG_LAYER_NAME{
"debug"};
123 SoUnits* u =
new SoUnits();
124 u->units = SoUnits::MILLIMETERS;
134 ARMARX_INFO <<
"Enabling selections for layer " << layerName;
143 ARMARX_INFO <<
"Disabling selections for layer " << layerName;
162 ARMARX_INFO <<
"Clearing selections on layer " << layerName;
172 if (path->containsNode(
layers.at(layerName).mainNode))
184 const std::string& elementName,
192 ARMARX_DEBUG <<
"Selecting element '" << elementName <<
"' on layer '" << layerName
193 <<
"' (internal name: " <<
SELECTION_NAME(layerName, elementName) <<
")";
195 SoNode* n = SoSelection::getByName(
SELECTION_NAME(layerName, elementName));
213 const std::string& elementName,
221 ARMARX_DEBUG <<
"Deselecting element '" << elementName <<
"' on layer '" << layerName
222 <<
"' (internal name: " <<
SELECTION_NAME(layerName, elementName) <<
")";
224 SoNode* n = SoSelection::getByName(
SELECTION_NAME(layerName, elementName));
280 for (
auto& e : selectedElements)
282 SoNode* n = SoSelection::getByName(
SELECTION_NAME(e.layerName, e.elementName));
295 DebugDrawerSelectionList
300 DebugDrawerSelectionList selectedElements;
306 for (
int j = 0; j < path->getLength(); j++)
308 SoNode* node = path->getNodeFromTail(j);
314 std::string name = node->getName().getString();
323 std::string layer = l.first;
324 if (
layers[layer].addedBoxVisualizations.find(name) !=
325 layers[layer].addedBoxVisualizations.end() ||
326 layers[layer].addedTextVisualizations.find(name) !=
327 layers[layer].addedTextVisualizations.end() ||
328 layers[layer].addedSphereVisualizations.find(name) !=
329 layers[layer].addedSphereVisualizations.end() ||
330 layers[layer].addedCylinderVisualizations.find(name) !=
331 layers[layer].addedCylinderVisualizations.end() ||
332 layers[layer].addedPolygonVisualizations.find(name) !=
333 layers[layer].addedPolygonVisualizations.end())
335 DebugDrawerSelectionElement e;
337 e.elementName = name;
339 selectedElements.push_back(e);
350 return selectedElements;
358 ARMARX_ERROR <<
"Cannot change the cycle time, once the thread has been started...";
362 if (visuUpdatesPerSec <= 0)
394 SoSensorManager* sensor_mgr = SoDB::getSensorManager();
436 std::cout <<
"onDisconnectComponent debug drawer" << std::endl;
462 SoSensorManager* sensor_mgr = SoDB::getSensorManager();
469 while (
layers.size() > 0 && counter < 2 *
c)
490 ARMARX_INFO <<
"Exporting scene to '" << filename <<
"'";
492 SoSeparator* sep =
new SoSeparator;
493 SoUnits* u =
new SoUnits;
494 u->units = SoUnits::MILLIMETERS;
498 SoWriteAction writeAction;
499 writeAction.getOutput()->openFile(filename.c_str());
500 writeAction.getOutput()->setBinary(
false);
501 writeAction.apply(sep);
502 writeAction.getOutput()->closeFile();
509 const std::string& layerName,
514 ARMARX_INFO <<
"Exporting layer '" << layerName <<
"' to '" << filename <<
"'";
522 SoSeparator* sep =
new SoSeparator;
523 SoUnits* u =
new SoUnits;
524 u->units = SoUnits::MILLIMETERS;
526 sep->addChild(
layers[layerName].mainNode);
528 SoWriteAction writeAction;
529 writeAction.getOutput()->openFile(filename.c_str());
530 writeAction.getOutput()->setBinary(
false);
531 writeAction.apply(sep);
532 writeAction.getOutput()->closeFile();
554 SoSeparator* newS =
new SoSeparator;
555 SoMatrixTransform* newM =
new SoMatrixTransform;
556 newS->addChild(newM);
557 std::string n = d.
name;
558 newS->addChild(CoinVisualizationFactory::CreateCoordSystemVisualization(d.
scale, &n));
559 layer.addedCoordVisualizations[d.
name] = newS;
560 layer.mainNode->addChild(newS);
562 SoSeparator* s = layer.addedCoordVisualizations[d.
name];
563 SoMatrixTransform* m = (SoMatrixTransform*)(s->getChild(0));
564 SbMatrix mNew = CoinVisualizationFactory::getSbMatrix(d.
globalPose);
565 m->matrix.setValue(mNew);
585 SoSeparator* newS =
new SoSeparator;
586 newS->addChild(CoinVisualizationFactory::createCoinLine(d.
p1, d.
p2, d.
scale, d.
color));
587 layer.addedLineVisualizations[d.
name] = newS;
588 layer.mainNode->addChild(newS);
607 if (d.
lineSet.points.size() % 2 != 0)
616 <<
"Amount of intensities has to be half the amount of points for a line set";
620 for (
const DebugDrawerPointCloudElement& e : d.
lineSet.points)
626 <<
" is not finite! this set will not be drawn!";
632 std::vector<VirtualRobot::VisualizationFactory::Color> colors;
633 colors.push_back(VirtualRobot::VisualizationFactory::Color(d.
lineSet.colorNoIntensity.r,
635 d.
lineSet.colorNoIntensity.b));
636 colors.push_back(VirtualRobot::VisualizationFactory::Color(d.
lineSet.colorFullIntensity.r,
637 d.
lineSet.colorFullIntensity.g,
638 d.
lineSet.colorFullIntensity.b));
639 VirtualRobot::ColorMap visualizationColorMap =
640 VirtualRobot::ColorMap::customColorMap(colors);
643 SoSeparator* sep =
new SoSeparator;
645 SoMaterialBinding* binding =
new SoMaterialBinding;
646 binding->value = SoMaterialBinding::PER_PART;
647 sep->addChild(binding);
649 SoDrawStyle* lineStyle =
new SoDrawStyle;
650 lineStyle->lineWidth.setValue(d.
lineSet.lineWidth);
651 sep->addChild(lineStyle);
653 SoCoordinate3* coordinateNode =
new SoCoordinate3;
654 sep->addChild(coordinateNode);
656 SoMaterial* materialNode =
new SoMaterial;
657 sep->addChild(materialNode);
659 SoLineSet* lineSetNode =
new SoLineSet;
660 lineSetNode->startIndex.setValue(0);
661 sep->addChild(lineSetNode);
665 SbVec3f* coordinateValues =
new SbVec3f[d.
lineSet.points.size()];
666 int32_t* lineSetValues =
new int32_t[d.
lineSet.intensities.size()];
667 SbColor* colorValues =
new SbColor[d.
lineSet.intensities.size()];
669 for (
unsigned int i = 0; i < d.
lineSet.intensities.size(); i++)
671 lineSetValues[i] = 2;
673 coordinateValues[2 * i].setValue(
675 coordinateValues[2 * i + 1].setValue(d.
lineSet.points[2 * i + 1].x,
677 d.
lineSet.points[2 * i + 1].z);
682 colorValues[i].setValue(
c.r,
c.g,
c.b);
686 VirtualRobot::VisualizationFactory::Color
c =
687 visualizationColorMap.getColor(d.
lineSet.intensities[i]);
688 colorValues[i].setValue(
c.r,
c.g,
c.b);
692 coordinateNode->point.setValuesPointer(d.
lineSet.points.size(), coordinateValues);
693 lineSetNode->numVertices.setValuesPointer(d.
lineSet.intensities.size(), lineSetValues);
694 materialNode->ambientColor.setValuesPointer(d.
lineSet.intensities.size(), colorValues);
695 materialNode->diffuseColor.setValuesPointer(d.
lineSet.intensities.size(), colorValues);
697 layer.addedLineSetVisualizations[d.
name] = sep;
698 layer.mainNode->addChild(sep);
716 SoSeparator* newS =
new SoSeparator;
718 newS->addChild(CoinVisualizationFactory::getMatrixTransform(m));
720 SoMaterial* material =
new SoMaterial;
723 material->transparency.setValue(d.
color.transparency);
724 newS->addChild(material);
726 SoCube* cube =
new SoCube;
728 cube->width = d.
width;
730 cube->depth = d.
depth;
731 newS->addChild(cube);
733 layer.addedBoxVisualizations[d.
name] = newS;
734 layer.mainNode->addChild(newS);
752 SoSeparator* sep =
new SoSeparator;
753 SoAnnotation* ann =
new SoAnnotation;
756 SoMaterial* mat =
new SoMaterial;
759 mat->transparency.setValue(d.
color.transparency);
762 SoTransform* tr =
new SoTransform;
766 SoFont* font =
new SoFont;
767 font->name.setValue(
"TGS_Triplex_Roman");
772 SoText2* te =
new SoText2;
774 te->string = d.
text.c_str();
775 te->justification = SoText2::CENTER;
778 layer.addedTextVisualizations[d.
name] = sep;
779 layer.mainNode->addChild(sep);
803 <<
" is not finite! this sphere will not be drawn!";
807 SoSeparator* sep =
new SoSeparator;
808 SoMaterial* mat =
new SoMaterial;
811 mat->transparency.setValue(d.
color.transparency);
814 SoTransform* tr =
new SoTransform;
818 SoSphere* sphere =
new SoSphere;
820 sphere->radius = d.
radius;
821 sep->addChild(sphere);
823 layer.addedSphereVisualizations[d.
name] = sep;
824 layer.mainNode->addChild(sep);
842 SoSeparator* sep =
new SoSeparator;
843 SoMaterial* mat =
new SoMaterial;
846 mat->transparency.setValue(d.
color.transparency);
850 SoTransform* tr =
new SoTransform;
852 tr->rotation.setValue(SbRotation(
856 SoCylinder* cylinder =
new SoCylinder;
858 cylinder->height = d.
length;
859 cylinder->radius = d.
radius;
860 sep->addChild(cylinder);
862 layer.addedCylinderVisualizations[d.
name] = sep;
863 layer.mainNode->addChild(sep);
870 vec = vec.normalized();
872 dir1 = vec.cross(Eigen::Vector3f(0, 0, 1));
874 if (dir1.norm() < 0.1f)
878 dir1 = vec.cross(Eigen::Vector3f(0, 1, 0));
881 dir1 = -dir1.normalized();
883 dir2 = vec.cross(dir1).normalized();
903 SoSeparator* sep =
new SoSeparator;
904 SoMaterial* mat =
new SoMaterial;
907 mat->transparency.setValue(d.
color.transparency);
911 SoTransform* tr =
new SoTransform;
913 Eigen::Vector3f xDir, yDir;
915 Eigen::Matrix3f rotGoal;
916 rotGoal << xDir, yDir, zDir;
919 Eigen::AngleAxisf rotAA(rotGoal);
920 tr->rotation.setValue(SbVec3f(rotAA.axis().x(), rotAA.axis().y(), rotAA.axis().z()),
923 auto node = CoinVisualizationFactory().createCircleArrow(
925 SoNode* circle =
dynamic_cast<CoinVisualizationNode&
>(*node).getCoinVisualization();
927 sep->addChild(circle);
929 layer.addedCircleVisualizations[d.
name] = sep;
930 layer.mainNode->addChild(sep);
949 SoSeparator* pclSep =
new SoSeparator;
951 SoMaterial* pclMat =
new SoMaterial;
952 pclMat->diffuseColor.setValue(0.2, 0.2, 0.2);
953 pclMat->diffuseColor.setValue(0.2, 0.2, 0.2);
954 pclSep->addChild(pclMat);
956 SoMaterialBinding* pclMatBind =
new SoMaterialBinding;
957 pclMatBind->value = SoMaterialBinding::OVERALL;
958 pclSep->addChild(pclMatBind);
960 SoCoordinate3* pclCoords =
new SoCoordinate3;
961 std::vector<SbVec3f> coords;
962 coords.reserve(
pcl.size());
963 std::transform(
pcl.begin(),
965 std::back_inserter(coords),
966 [](
const DebugDrawerPointCloudElement& elem) {
967 return SbVec3f{elem.x, elem.y, elem.z};
969 pclCoords->point.setValues(0, coords.size(), coords.data());
970 pclSep->addChild(pclCoords);
972 SoDrawStyle* pclStye =
new SoDrawStyle;
973 pclStye->pointSize = d.pointCloud.pointSize;
974 pclSep->addChild(pclStye);
976 pclSep->addChild(
new SoPointSet);
978 layer.addedPointCloudVisualizations[d.name] = pclSep;
979 layer.mainNode->addChild(pclSep);
996 SoSeparator* sep =
new SoSeparator;
998 SoShapeHints* hints =
new SoShapeHints;
999 hints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
1000 hints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
1001 hints->faceType = SoShapeHints::UNKNOWN_FACE_TYPE;
1002 sep->addChild(hints);
1004 sep->addChild(VirtualRobot::CoinVisualizationFactory::CreatePolygonVisualization(
1007 layer.addedPolygonVisualizations[d.
name] = sep;
1008 layer.mainNode->addChild(sep);
1025 TriMeshModelPtr triMesh = TriMeshModelPtr(
new TriMeshModel());
1027 for (DrawColor color : d.
triMesh.colors)
1030 VirtualRobot::VisualizationFactory::Color(color.r, color.g, color.b, color.a));
1033 for (DebugDrawerVertex v : d.
triMesh.vertices)
1035 triMesh->addVertex(Eigen::Vector3f(v.x, v.y, v.z));
1038 for (DebugDrawerFace f : d.
triMesh.faces)
1040 MathTools::TriangleFace face;
1042 face.id1 = f.vertex1.vertexID;
1043 face.idNormal1 = f.vertex1.normalID;
1044 face.idColor1 = f.vertex1.colorID;
1046 face.id2 = f.vertex2.vertexID;
1047 face.idNormal2 = f.vertex2.normalID;
1048 face.idColor2 = f.vertex2.colorID;
1050 face.id3 = f.vertex3.vertexID;
1051 face.idNormal3 = f.vertex3.normalID;
1052 face.idColor3 = f.vertex3.colorID;
1054 face.normal = Eigen::Vector3f(f.normal.x, f.normal.y, f.normal.z);
1056 triMesh->addFace(face);
1059 SoSeparator* sep =
new SoSeparator();
1060 SoNode*
c = CoinVisualizationFactory::getCoinVisualization(triMesh);
1062 layer.addedTriMeshVisualizations[d.
name] = sep;
1063 layer.mainNode->addChild(sep);
1080 SoSeparator* sep =
new SoSeparator;
1082 SoTransform* tr =
new SoTransform;
1086 SoSeparator* sepArrow = VirtualRobot::CoinVisualizationFactory::CreateArrow(
1088 sep->addChild(sepArrow);
1089 layer.addedArrowVisualizations[d.
name] = sep;
1090 layer.mainNode->addChild(sep);
1113 std::map<std::string, float>::iterator i = d.
configuration.begin();
1116 if (!rob->hasRobotNode(i->first))
1119 <<
" does not know RobotNode " << i->first;
1164 if (layer.addedRobotVisualizations.find(d.
name) == layer.addedRobotVisualizations.end())
1170 SoSeparator* sep = layer.addedRobotVisualizations[d.
name];
1172 for (
int i = 0; i < sep->getNumChildren(); i++)
1174 SoSeparator* nodeSep =
dynamic_cast<SoSeparator*
>(sep->getChild(i));
1175 SoMaterial* m =
dynamic_cast<SoMaterial*
>(nodeSep->getChild(0));
1183 if (d.
color.isNone())
1185 m->setOverride(
false);
1194 m->ambientColor = SbColor(0, 0, 0);
1195 m->transparency = std::max(0.0f, d.
color.transparency);
1196 m->setOverride(
true);
1204 if (layer.addedRobotVisualizations.find(d.
name) == layer.addedRobotVisualizations.end())
1210 SoSeparator* sep = layer.addedRobotVisualizations[d.
name];
1212 if (!sep || sep->getNumChildren() < 2)
1218 std::string entryName = simox::alg::replace_all(
1219 std::string(
"__" + d.
layerName +
"__" + d.
name +
"__"),
" ",
"_");
1222 std::vector<std::string> nodeNameList;
1224 for (
size_t i = 0; i < robot->getRobotNodes().size(); ++i)
1226 nodeNameList.push_back(robot->getRobotNodes()[i]->getName());
1229 for (std::map<std::string,
1230 VirtualRobot::VisualizationFactory::Color>::const_iterator it =
1236 std::string nodeName = it->first;
1237 VirtualRobot::VisualizationFactory::Color nodeColor = it->second;
1239 std::vector<std::string>::iterator strit;
1240 strit = std::find(nodeNameList.begin(), nodeNameList.end(), nodeName);
1242 if (strit == nodeNameList.end())
1244 ARMARX_WARNING <<
"Cannot find correct robot node name " + nodeName +
1245 " for DebugDrawer node color update !!!";
1249 size_t ind = strit - nodeNameList.begin();
1250 SoSeparator* nodeSep =
dynamic_cast<SoSeparator*
>(sep->getChild(ind));
1258 SoMaterial* nodeMat =
dynamic_cast<SoMaterial*
>(nodeSep->getChild(0));
1266 if (nodeColor.isNone())
1268 nodeMat->setOverride(
false);
1272 if (nodeColor.r < 0 || nodeColor.g < 0 || nodeColor.b < 0)
1274 ARMARX_ERROR <<
"Internal robot layer node color error";
1278 nodeMat->diffuseColor = SbColor(nodeColor.r, nodeColor.g, nodeColor.b);
1279 nodeMat->ambientColor = SbColor(0, 0, 0);
1280 nodeMat->transparency = std::max(0.0f, nodeColor.transparency);
1281 nodeMat->setOverride(
true);
1294 std::string entryName = simox::alg::replace_all(
1295 std::string(
"__" + d.
layerName +
"__" + d.
name +
"__"),
" ",
"_");
1311 <<
", with name " << d.
name;
1335 VirtualRobot::SceneObject::VisualizationType visuType = VirtualRobot::SceneObject::Full;
1336 VirtualRobot::RobotIO::RobotDescription loadMode = VirtualRobot::RobotIO::eFull;
1338 if (d.
drawStyle == DrawStyle::CollisionModel)
1340 visuType = VirtualRobot::SceneObject::Collision;
1341 loadMode = VirtualRobot::RobotIO::eCollisionModel;
1350 loadedRobots[filename] = RobotIO::loadRobot(filename, loadMode);
1365 SoSeparator* sep =
new SoSeparator;
1366 layer.mainNode->addChild(sep);
1368 for (
size_t i = 0; i < result->getRobotNodes().size(); ++i)
1370 VirtualRobot::RobotNodePtr robNode = result->getRobotNodes()[i];
1371 SoSeparator* nodeSep =
new SoSeparator;
1373 SoMaterial* nodeMat =
new SoMaterial;
1374 nodeMat->setOverride(
false);
1375 nodeSep->addChild(nodeMat);
1378 robNode->getVisualization<CoinVisualization>(visuType);
1382 SoNode* sepRobNode = robNodeVisu->getCoinVisualization();
1386 nodeSep->addChild(sepRobNode);
1390 sep->addChild(nodeSep);
1394 ARMARX_DEBUG <<
"setting robot to activeRobots, entryName:" << entryName
1396 layer.addedRobotVisualizations[d.
name] = sep;
1397 ARMARX_DEBUG <<
"adding sep to layer.addedRobotVisualizations, d.name:" << d.
name
1398 <<
", layer:" << d.
layerName <<
", layer.addedRobotVisualizations.size():"
1399 << layer.addedRobotVisualizations.size();
1414 auto& layer =
layers.at(layerName);
1416 if (layer.addedLineVisualizations.find(name) == layer.addedLineVisualizations.end())
1421 layer.mainNode->removeChild(layer.addedLineVisualizations[name]);
1422 layer.addedLineVisualizations.erase(name);
1435 auto& layer =
layers.at(layerName);
1437 if (layer.addedLineSetVisualizations.find(name) == layer.addedLineSetVisualizations.end())
1442 layer.mainNode->removeChild(layer.addedLineSetVisualizations[name]);
1443 layer.addedLineSetVisualizations.erase(name);
1456 auto& layer =
layers.at(layerName);
1458 if (layer.addedBoxVisualizations.find(name) == layer.addedBoxVisualizations.end())
1463 layer.mainNode->removeChild(layer.addedBoxVisualizations[name]);
1464 layer.addedBoxVisualizations.erase(name);
1477 auto& layer =
layers.at(layerName);
1479 if (layer.addedTextVisualizations.find(name) == layer.addedTextVisualizations.end())
1484 layer.mainNode->removeChild(layer.addedTextVisualizations[name]);
1485 layer.addedTextVisualizations.erase(name);
1498 auto& layer =
layers.at(layerName);
1500 if (layer.addedSphereVisualizations.find(name) == layer.addedSphereVisualizations.end())
1505 layer.mainNode->removeChild(layer.addedSphereVisualizations[name]);
1506 layer.addedSphereVisualizations.erase(name);
1519 auto& layer =
layers.at(layerName);
1521 if (layer.addedCylinderVisualizations.find(name) == layer.addedCylinderVisualizations.end())
1526 layer.mainNode->removeChild(layer.addedCylinderVisualizations[name]);
1527 layer.addedCylinderVisualizations.erase(name);
1540 auto& layer =
layers.at(layerName);
1542 if (layer.addedCircleVisualizations.find(name) == layer.addedCircleVisualizations.end())
1547 layer.mainNode->removeChild(layer.addedCircleVisualizations[name]);
1548 layer.addedCircleVisualizations.erase(name);
1561 auto& layer =
layers.at(layerName);
1563 if (layer.addedPointCloudVisualizations.find(name) ==
1564 layer.addedPointCloudVisualizations.end())
1569 layer.mainNode->removeChild(layer.addedPointCloudVisualizations[name]);
1570 layer.addedPointCloudVisualizations.erase(name);
1583 auto& layer =
layers.at(layerName);
1585 if (layer.addedPolygonVisualizations.find(name) == layer.addedPolygonVisualizations.end())
1590 layer.mainNode->removeChild(layer.addedPolygonVisualizations[name]);
1591 layer.addedPolygonVisualizations.erase(name);
1604 auto& layer =
layers.at(layerName);
1606 if (layer.addedTriMeshVisualizations.find(name) == layer.addedTriMeshVisualizations.end())
1611 layer.mainNode->removeChild(layer.addedTriMeshVisualizations[name]);
1612 layer.addedTriMeshVisualizations.erase(name);
1625 auto& layer =
layers.at(layerName);
1627 if (layer.addedArrowVisualizations.find(name) == layer.addedArrowVisualizations.end())
1632 layer.mainNode->removeChild(layer.addedArrowVisualizations[name]);
1633 layer.addedArrowVisualizations.erase(name);
1642 std::string entryName =
1643 simox::alg::replace_all(std::string(
"__" + layerName +
"__" + name +
"__"),
" ",
"_");
1650 ARMARX_DEBUG <<
"after Found robot to remove, activeRobots.size() = "
1661 auto& layer =
layers.at(layerName);
1663 if (layer.addedRobotVisualizations.find(name) == layer.addedRobotVisualizations.end())
1665 ARMARX_INFO <<
"Could not find robot with name " << name;
1669 ARMARX_DEBUG <<
"Removing visualization for " << entryName;
1671 ARMARX_DEBUG <<
"removing sep from layer.addedRobotVisualizations, d.name:" << name
1672 <<
", layer:" << layerName <<
", layer.addedRobotVisualizations.size():"
1673 << layer.addedRobotVisualizations.size();
1675 if (layer.addedRobotVisualizations.find(name) == layer.addedRobotVisualizations.end())
1681 ARMARX_DEBUG <<
"removing from layer.mainNode, layer.mainNode->getNumChildren()="
1682 << layer.mainNode->getNumChildren();
1684 if (layer.mainNode->findChild(layer.addedRobotVisualizations[name]) < 0)
1690 layer.mainNode->removeChild(layer.addedRobotVisualizations[name]);
1691 layer.addedRobotVisualizations.erase(name);
1692 ARMARX_DEBUG <<
"after removing from layer.mainNode, layer.mainNode->getNumChildren()="
1693 << layer.mainNode->getNumChildren();
1694 ARMARX_DEBUG <<
"after removing sep from layer.addedRobotVisualizations, d.name:" << name
1695 <<
", layer:" << layerName <<
", layer.addedRobotVisualizations.size():"
1696 << layer.addedRobotVisualizations.size();
1709 auto& layer =
layers.at(layerName);
1711 if (layer.addedCoordVisualizations.find(name) == layer.addedCoordVisualizations.end())
1716 layer.mainNode->removeChild(layer.addedCoordVisualizations[name]);
1717 layer.addedCoordVisualizations.erase(name);
1730 auto& layer =
layers.at(layerName);
1731 layer.visible = visible;
1773 const std::string& poseName,
1774 const ::armarx::PoseBasePtr& globalPose,
1775 const ::Ice::Float scale,
1776 const ::Ice::Current&)
1779 Eigen::Matrix4f gp = PosePtr::dynamicCast(globalPose)->toEigen();
1782 std::string entryName = simox::alg::replace_all(
1783 std::string(
"__" + layerName +
"__" + poseName +
"__"),
" ",
"_");
1795 const ::armarx::PoseBasePtr& globalPose,
1796 const ::Ice::Float scale,
1797 const ::Ice::Current&)
1804 const std::string& poseName,
1805 const PoseBasePtr& globalPose,
1806 const Ice::Current&)
1813 const PoseBasePtr& globalPose,
1814 const Ice::Current&)
1821 const std::string& poseName,
1822 const Ice::Current&)
1826 std::string entryName = simox::alg::replace_all(
1827 std::string(
"__" + layerName +
"__" + poseName +
"__"),
" ",
"_");
1843 const std::string& lineName,
1844 const Vector3BasePtr& globalPosition1,
1845 const Vector3BasePtr& globalPosition2,
1847 const DrawColor& color,
1848 const Ice::Current&)
1850 Eigen::Vector3f p1 = Vector3Ptr::dynamicCast(globalPosition1)->toEigen();
1851 Eigen::Vector3f p2 = Vector3Ptr::dynamicCast(globalPosition2)->toEigen();
1852 VirtualRobot::VisualizationFactory::Color
c(color.r, color.g, color.b, 1 - color.a);
1855 std::string entryName = simox::alg::replace_all(
1856 std::string(
"__" + layerName +
"__" + lineName +
"__"),
" ",
"_");
1863 d.
scale = lineWidth;
1870 const Vector3BasePtr& globalPosition1,
1871 const Vector3BasePtr& globalPosition2,
1873 const DrawColor& color,
1874 const Ice::Current&)
1876 setLineVisu(DEBUG_LAYER_NAME, lineName, globalPosition1, globalPosition2, lineWidth, color);
1881 const std::string& lineName,
1882 const Ice::Current&)
1886 std::string entryName = simox::alg::replace_all(
1887 std::string(
"__" + layerName +
"__" + lineName +
"__"),
" ",
"_");
1903 const std::string& lineSetName,
1904 const DebugDrawerLineSet& lineSet,
1905 const Ice::Current&)
1910 std::string entryName = simox::alg::replace_all(
1911 std::string(
"__" + layerName +
"__" + lineSetName +
"__"),
" ",
"_");
1915 d.
name = lineSetName;
1922 const DebugDrawerLineSet& lineSet,
1923 const Ice::Current&)
1930 const std::string& lineSetName,
1931 const Ice::Current&)
1935 std::string entryName = simox::alg::replace_all(
1936 std::string(
"__" + layerName +
"__" + lineSetName +
"__"),
" ",
"_");
1939 d.
name = lineSetName;
1946 const Ice::Current&)
1953 const std::string& boxName,
1954 const PoseBasePtr& globalPose,
1955 const Vector3BasePtr& dimensions,
1956 const DrawColor& color,
1957 const Ice::Current&)
1959 Eigen::Matrix4f gp = PosePtr::dynamicCast(globalPose)->toEigen();
1960 VirtualRobot::VisualizationFactory::Color
c(color.r, color.g, color.b, 1 - color.a);
1963 std::string entryName = simox::alg::replace_all(
1964 std::string(
"__" + layerName +
"__" + boxName +
"__"),
" ",
"_");
1966 d.
width = dimensions->x;
1967 d.
height = dimensions->y;
1968 d.
depth = dimensions->z;
1979 const PoseBasePtr& globalPose,
1980 const Vector3BasePtr& dimensions,
1981 const DrawColor& color,
1982 const Ice::Current&)
1984 setBoxVisu(DEBUG_LAYER_NAME, boxName, globalPose, dimensions, color);
1989 const std::string& boxName,
1990 const Ice::Current&)
1994 std::string entryName = simox::alg::replace_all(
1995 std::string(
"__" + layerName +
"__" + boxName +
"__"),
" ",
"_");
2011 const std::string& textName,
2012 const std::string& text,
2013 const Vector3BasePtr& globalPosition,
2014 const DrawColor& color,
2016 const Ice::Current&)
2021 std::string entryName = simox::alg::replace_all(
2022 std::string(
"__" + layerName +
"__" + textName +
"__"),
" ",
"_");
2025 d.
position = Vector3Ptr::dynamicCast(globalPosition)->toEigen();
2029 VirtualRobot::VisualizationFactory::Color(color.r, color.g, color.b, 1 - color.a);
2037 const std::string& text,
2038 const Vector3BasePtr& globalPosition,
2039 const DrawColor& color,
2041 const Ice::Current&)
2043 setTextVisu(DEBUG_LAYER_NAME, textName, text, globalPosition, color, size);
2048 const std::string& textName,
2049 const Ice::Current&)
2053 std::string entryName = simox::alg::replace_all(
2054 std::string(
"__" + layerName +
"__" + textName +
"__"),
" ",
"_");
2070 const std::string& sphereName,
2071 const Vector3BasePtr& globalPosition,
2072 const DrawColor& color,
2074 const Ice::Current&)
2079 std::string entryName = simox::alg::replace_all(
2080 std::string(
"__" + layerName +
"__" + sphereName +
"__"),
" ",
"_");
2083 d.
position = Vector3Ptr::dynamicCast(globalPosition)->toEigen();
2085 d.
name = sphereName;
2087 VirtualRobot::VisualizationFactory::Color(color.r, color.g, color.b, 1 - color.a);
2094 const Vector3BasePtr& globalPosition,
2095 const DrawColor& color,
2097 const Ice::Current&)
2099 setSphereVisu(DEBUG_LAYER_NAME, sphereName, globalPosition, color, radius);
2104 const std::string& sphereName,
2105 const Ice::Current&)
2109 std::string entryName = simox::alg::replace_all(
2110 std::string(
"__" + layerName +
"__" + sphereName +
"__"),
" ",
"_");
2113 d.
name = sphereName;
2120 const Ice::Current&)
2127 const std::string& cylinderName,
2128 const Vector3BasePtr& globalPosition,
2129 const Vector3BasePtr& direction,
2132 const DrawColor& color,
2133 const Ice::Current&)
2138 std::string entryName = simox::alg::replace_all(
2139 std::string(
"__" + layerName +
"__" + cylinderName +
"__"),
" ",
"_");
2141 d.
position = Vector3Ptr::dynamicCast(globalPosition)->toEigen();
2142 d.
direction = Vector3Ptr::dynamicCast(direction)->toEigen();
2146 d.
name = cylinderName;
2148 VirtualRobot::VisualizationFactory::Color(color.r, color.g, color.b, 1 - color.a);
2155 const Vector3BasePtr& globalPosition,
2156 const Vector3BasePtr& direction,
2159 const DrawColor& color,
2160 const Ice::Current&)
2163 DEBUG_LAYER_NAME, cylinderName, globalPosition, direction, length, radius, color);
2168 const std::string& cylinderName,
2169 const Ice::Current&)
2173 std::string entryName = simox::alg::replace_all(
2174 std::string(
"__" + layerName +
"__" + cylinderName +
"__"),
" ",
"_");
2177 d.
name = cylinderName;
2184 const Ice::Current&)
2191 const std::string& pointCloudName,
2192 const DebugDrawerPointCloud& pointCloud,
2193 const Ice::Current&)
2198 std::string entryName = simox::alg::replace_all(
2199 std::string(
"__" + layerName +
"__" + pointCloudName +
"__"),
" ",
"_");
2203 d.
name = pointCloudName;
2210 const DebugDrawerPointCloud& pointCloud,
2211 const Ice::Current&)
2218 const std::string& pointCloudName,
2219 const Ice::Current&)
2223 std::string entryName = simox::alg::replace_all(
2224 std::string(
"__" + layerName +
"__" + pointCloudName +
"__"),
" ",
"_");
2227 d.
name = pointCloudName;
2234 const Ice::Current&)
2241 const std::string& polygonName,
2242 const std::vector<Vector3BasePtr>& polygonPoints,
2243 const DrawColor& colorInner,
2244 const DrawColor& colorBorder,
2246 const Ice::Current&)
2250 std::string entryName = simox::alg::replace_all(
2251 std::string(
"__" + layerName +
"__" + polygonName +
"__"),
" ",
"_");
2254 std::vector<Eigen::Vector3f> points;
2256 for (
size_t i = 0; i < polygonPoints.size(); i++)
2258 Eigen::Vector3f p = Vector3Ptr::dynamicCast(polygonPoints.at(i))->toEigen();
2260 points.push_back(p);
2264 d.
colorInner = VirtualRobot::VisualizationFactory::Color(
2265 colorInner.r, colorInner.g, colorInner.b, 1 - colorInner.a);
2267 d.
colorBorder = VirtualRobot::VisualizationFactory::Color(
2268 colorBorder.r, colorBorder.g, colorBorder.b, 1 - colorBorder.a);
2273 d.
name = polygonName;
2280 const std::vector<Vector3BasePtr>& polygonPoints,
2281 const DrawColor& colorInner,
2282 const DrawColor& colorBorder,
2284 const Ice::Current&)
2287 DEBUG_LAYER_NAME, polygonName, polygonPoints, colorInner, colorBorder, lineWidth);
2292 const std::string& polygonName,
2293 const Ice::Current&)
2297 std::string entryName = simox::alg::replace_all(
2298 std::string(
"__" + layerName +
"__" + polygonName +
"__"),
" ",
"_");
2301 d.
name = polygonName;
2308 const Ice::Current&)
2315 const std::string& triMeshName,
2316 const DebugDrawerTriMesh& triMesh,
2317 const Ice::Current&)
2321 std::string entryName = simox::alg::replace_all(
2322 std::string(
"__" + layerName +
"__" + triMeshName +
"__"),
" ",
"_");
2326 d.
name = triMeshName;
2333 const DebugDrawerTriMesh& triMesh,
2334 const Ice::Current&)
2341 const std::string& triMeshName,
2342 const Ice::Current&)
2346 std::string entryName = simox::alg::replace_all(
2347 std::string(
"__" + layerName +
"__" + triMeshName +
"__"),
" ",
"_");
2350 d.
name = triMeshName;
2357 const Ice::Current&)
2364 const std::string& arrowName,
2365 const Vector3BasePtr& position,
2366 const Vector3BasePtr& direction,
2367 const DrawColor& color,
2370 const Ice::Current&)
2374 std::string entryName = simox::alg::replace_all(
2375 std::string(
"__" + layerName +
"__" + arrowName +
"__"),
" ",
"_");
2377 d.
position = Vector3Ptr::dynamicCast(position)->toEigen();
2378 d.
direction = Vector3Ptr::dynamicCast(direction)->toEigen();
2380 VirtualRobot::VisualizationFactory::Color(color.r, color.g, color.b, 1 - color.a);
2392 const Vector3BasePtr& position,
2393 const Vector3BasePtr& direction,
2394 const DrawColor& color,
2397 const Ice::Current&)
2399 setArrowVisu(DEBUG_LAYER_NAME, arrowName, position, direction, color, length, width);
2404 const std::string& arrowName,
2405 const Ice::Current&)
2409 std::string entryName = simox::alg::replace_all(
2410 std::string(
"__" + layerName +
"__" + arrowName +
"__"),
" ",
"_");
2420 const Ice::Current&)
2427 const std::string& robotName,
2428 const std::string& robotFile,
2429 const std::string& armarxProject,
2430 DrawStyle drawStyle,
2431 const Ice::Current&)
2434 std::string entryName = simox::alg::replace_all(
2435 std::string(
"__" + layerName +
"__" + robotName +
"__"),
" ",
"_");
2436 ARMARX_DEBUG <<
"setting robot visualization for " << entryName;
2450 const std::string& robotName,
2451 const PoseBasePtr& globalPose,
2452 const Ice::Current&)
2455 std::string entryName = simox::alg::replace_all(
2456 std::string(
"__" + layerName +
"__" + robotName +
"__"),
" ",
"_");
2457 ARMARX_DEBUG <<
"updating robot pose for " << entryName;
2463 d.
globalPose = PosePtr::dynamicCast(globalPose)->toEigen();
2472 const std::string& robotName,
2473 const std::map<std::string, float>& configuration,
2474 const Ice::Current&)
2477 std::string entryName = simox::alg::replace_all(
2478 std::string(
"__" + layerName +
"__" + robotName +
"__"),
" ",
"_");
2479 ARMARX_DEBUG <<
"updating robot config for " << entryName;
2488 for (
auto& it : configuration)
2498 const std::string& robotName,
2500 const Ice::Current&)
2503 std::string entryName = simox::alg::replace_all(
2504 std::string(
"__" + layerName +
"__" + robotName +
"__"),
" ",
"_");
2505 ARMARX_DEBUG <<
"updating robot color for " << entryName;
2514 if (
c.a == 0 &&
c.b == 0 &&
c.r == 0 &&
c.g == 0)
2516 d.
color = VirtualRobot::VisualizationFactory::Color::None();
2520 d.
color = VirtualRobot::VisualizationFactory::Color(
c.r,
c.g,
c.b, 1 -
c.a);
2528 const std::string& robotName,
2529 const std::string& robotNodeName,
2531 const Ice::Current&)
2534 std::string entryName = simox::alg::replace_all(
2535 std::string(
"__" + layerName +
"__" + robotName +
"__"),
" ",
"_");
2536 ARMARX_DEBUG <<
"updating robot color for " << entryName;
2544 if (
c.a == 0 &&
c.b == 0 &&
c.r == 0 &&
c.g == 0)
2546 d.
nodeColors[robotNodeName] = VirtualRobot::VisualizationFactory::Color::None();
2551 VirtualRobot::VisualizationFactory::Color(
c.r,
c.g,
c.b, 1 -
c.a);
2559 const std::string& robotName,
2560 const Ice::Current&)
2563 std::string entryName = simox::alg::replace_all(
2564 std::string(
"__" + layerName +
"__" + robotName +
"__"),
" ",
"_");
2565 ARMARX_DEBUG <<
"removing robot visu for " << entryName;
2606 <<
" can't be cleared, because it does not exist.";
2752 return layers.at(layerName);
2757 SoSeparator* mainNode =
new SoSeparator{};
2760 layers.at(layerName).mainNode = mainNode;
2762 if (
layers.at(layerName).visible)
2766 return layers.at(layerName);
2864 ARMARX_DEBUG <<
"update visu / drawRobot for robot " << e.first;
2868 e.second.nodeColors.clear();
2915 <<
" can't be removed, because it does not exist.";
2928 auto& layer =
layers.at(layerName);
2930 layer.mainNode->unref();
2935 template <
class UpdateDataType>
2938 std::map<std::string, UpdateDataType>& map)
2940 auto it = map.begin();
2941 while (it != map.end())
2944 if (curr->second.layerName == layerName)
2977 const ::Ice::Current&)
2992 Ice::StringSeq seq{};
2994 for (
const auto& layer :
layers)
2996 seq.push_back(layer.first);
3002 ::armarx::LayerInformationSequence
3005 ::armarx::LayerInformationSequence seq{};
3008 for (
const auto& layer :
layers)
3010 int count = layer.second.addedCoordVisualizations.size() +
3011 layer.second.addedLineVisualizations.size() +
3012 layer.second.addedLineSetVisualizations.size() +
3013 layer.second.addedBoxVisualizations.size() +
3014 layer.second.addedTextVisualizations.size() +
3015 layer.second.addedSphereVisualizations.size() +
3016 layer.second.addedCylinderVisualizations.size() +
3017 layer.second.addedCircleVisualizations.size() +
3018 layer.second.addedPointCloudVisualizations.size() +
3019 layer.second.addedColoredPointCloudVisualizations.size() +
3020 layer.second.added24BitColoredPointCloudVisualizations.size() +
3021 layer.second.addedPolygonVisualizations.size() +
3022 layer.second.addedTriMeshVisualizations.size() +
3023 layer.second.addedArrowVisualizations.size() +
3024 layer.second.addedRobotVisualizations.size() +
3025 layer.second.addedCustomVisualizations.size();
3026 ::armarx::LayerInformation info = {layer.first, layer.second.visible, count};
3027 seq.push_back(info);
3049 SoSeparator* pclSep =
new SoSeparator;
3051 SoMaterial* pclMat =
new SoMaterial;
3052 std::vector<SbColor> colors;
3053 colors.reserve(
pcl.size());
3054 std::transform(
pcl.begin(),
3056 std::back_inserter(colors),
3057 [](
const DebugDrawerColoredPointCloudElement& elem) {
3058 return SbColor{elem.color.r, elem.color.g, elem.color.b};
3060 pclMat->diffuseColor.setValues(0, colors.size(), colors.data());
3061 pclMat->ambientColor.setValues(0, colors.size(), colors.data());
3062 pclSep->addChild(pclMat);
3064 SoMaterialBinding* pclMatBind =
new SoMaterialBinding;
3065 pclMatBind->value = SoMaterialBinding::PER_PART;
3066 pclSep->addChild(pclMatBind);
3068 SoCoordinate3* pclCoords =
new SoCoordinate3;
3069 std::vector<SbVec3f> coords;
3070 coords.reserve(
pcl.size());
3071 std::transform(
pcl.begin(),
3073 std::back_inserter(coords),
3074 [](
const DebugDrawerColoredPointCloudElement& elem) {
3075 return SbVec3f{elem.x, elem.y, elem.z};
3077 pclCoords->point.setValues(0, coords.size(), coords.data());
3078 pclSep->addChild(pclCoords);
3080 SoDrawStyle* pclStye =
new SoDrawStyle;
3081 pclStye->pointSize = d.pointCloud.pointSize;
3082 pclSep->addChild(pclStye);
3084 pclSep->addChild(
new SoPointSet);
3088 layer.addedColoredPointCloudVisualizations[d.name] = pclSep;
3089 layer.mainNode->addChild(pclSep);
3094 const std::string& name)
3103 auto& layer =
layers.at(layerName);
3105 if (layer.addedColoredPointCloudVisualizations.find(name) ==
3106 layer.addedColoredPointCloudVisualizations.end())
3111 layer.mainNode->removeChild(layer.addedColoredPointCloudVisualizations[name]);
3112 layer.addedColoredPointCloudVisualizations.erase(name);
3117 const std::string& pointCloudName,
3118 const DebugDrawerColoredPointCloud& pointCloud,
3119 const Ice::Current&)
3123 std::string entryName = simox::alg::replace_all(
3124 std::string(
"__" + layerName +
"__" + pointCloudName +
"__"),
" ",
"_");
3128 d.
name = pointCloudName;
3135 const std::string& pointCloudName,
3136 const DebugDrawerColoredPointCloud& pointCloud,
3137 const Ice::Current&)
3144 const std::string& pointCloudName,
3145 const Ice::Current&)
3149 std::string entryName = simox::alg::replace_all(
3150 std::string(
"__" + layerName +
"__" + pointCloudName +
"__"),
" ",
"_");
3153 d.
name = pointCloudName;
3160 const Ice::Current&)
3181 SoSeparator* pclSep =
new SoSeparator;
3183 SoMaterial* pclMat =
new SoMaterial;
3184 std::vector<SbColor> colors;
3185 colors.reserve(
pcl.size());
3186 std::transform(
pcl.begin(),
3188 std::back_inserter(colors),
3189 [](
const DebugDrawer24BitColoredPointCloudElement& elem)
3191 return SbColor{static_cast<float>(elem.color.r) / 255.f,
3192 static_cast<float>(elem.color.g) / 255.f,
3193 static_cast<float>(elem.color.b) / 255.f};
3195 pclMat->diffuseColor.setValues(0, colors.size(), colors.data());
3196 pclMat->ambientColor.setValues(0, colors.size(), colors.data());
3197 pclMat->transparency = d.pointCloud.transparency;
3198 pclSep->addChild(pclMat);
3200 SoMaterialBinding* pclMatBind =
new SoMaterialBinding;
3201 pclMatBind->value = SoMaterialBinding::PER_PART;
3202 pclSep->addChild(pclMatBind);
3204 SoCoordinate3* pclCoords =
new SoCoordinate3;
3205 std::vector<SbVec3f> coords;
3206 coords.reserve(
pcl.size());
3207 std::transform(
pcl.begin(),
3209 std::back_inserter(coords),
3210 [](
const DebugDrawer24BitColoredPointCloudElement& elem) {
3211 return SbVec3f{elem.x, elem.y, elem.z};
3213 pclCoords->point.setValues(0, coords.size(), coords.data());
3214 pclSep->addChild(pclCoords);
3216 SoDrawStyle* pclStye =
new SoDrawStyle;
3217 pclStye->pointSize = d.pointCloud.pointSize;
3218 pclSep->addChild(pclStye);
3220 pclSep->addChild(
new SoPointSet);
3224 layer.added24BitColoredPointCloudVisualizations[d.name] = pclSep;
3225 layer.mainNode->addChild(pclSep);
3230 const std::string& name)
3239 auto& layer =
layers.at(layerName);
3241 if (layer.added24BitColoredPointCloudVisualizations.find(name) ==
3242 layer.added24BitColoredPointCloudVisualizations.end())
3247 layer.mainNode->removeChild(layer.added24BitColoredPointCloudVisualizations[name]);
3248 layer.added24BitColoredPointCloudVisualizations.erase(name);
3253 const std::string& layerName,
3254 const std::string& pointCloudName,
3255 const DebugDrawer24BitColoredPointCloud& pointCloud,
3256 const Ice::Current&)
3260 std::string entryName = simox::alg::replace_all(
3261 std::string(
"__" + layerName +
"__" + pointCloudName +
"__"),
" ",
"_");
3265 d.
name = pointCloudName;
3272 const std::string& pointCloudName,
3273 const DebugDrawer24BitColoredPointCloud& pointCloud,
3274 const Ice::Current&)
3281 const std::string& pointCloudName,
3282 const Ice::Current&)
3286 std::string entryName = simox::alg::replace_all(
3287 std::string(
"__" + layerName +
"__" + pointCloudName +
"__"),
" ",
"_");
3290 d.
name = pointCloudName;
3297 const std::string& pointCloudName,
3298 const Ice::Current&)
3305 const std::string& circleName,
3306 const Vector3BasePtr& globalPosition,
3307 const Vector3BasePtr& directionVec,
3309 Ice::Float circleCompletion,
3311 const DrawColor& color,
3312 const Ice::Current&)
3316 std::string entryName = simox::alg::replace_all(
3317 std::string(
"__" + layerName +
"__" + circleName +
"__"),
" ",
"_");
3319 d.
position = Vector3Ptr::dynamicCast(globalPosition)->toEigen();
3320 d.
direction = Vector3Ptr::dynamicCast(directionVec)->toEigen();
3325 d.
name = circleName;
3326 d.
color = VirtualRobot::VisualizationFactory::Color(color.r, color.g, color.b, 1 - color.a);
3332 const Vector3BasePtr& globalPosition,
3333 const Vector3BasePtr& directionVec,
3335 Ice::Float circleCompletion,
3337 const DrawColor& color,
3338 const Ice::Current&
c)
3353 const std::string& circleName,
3354 const Ice::Current&)
3358 std::string entryName = simox::alg::replace_all(
3359 std::string(
"__" + layerName +
"__" + circleName +
"__"),
" ",
"_");
3362 d.
name = circleName;
3368 const Ice::Current&
c)
#define SELECTION_NAME_PREFIX
#define SELECTION_NAME_SPLITTER
#define SELECTION_NAME(layerName, elementName)
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
static bool getAbsolutePath(const std::string &relativeFilename, std::string &storeAbsoluteFilename, const std::vector< std::string > &additionalSearchPaths={}, bool verbose=true)
static void addDataPaths(const std::string &dataPathList)
The CMakePackageFinder class provides an interface to the CMake Package finder capabilities.
std::string getDataDir() const
bool packageFound() const
Returns whether or not this package was found with cmake.
Property< PropertyType > getProperty(const std::string &name)
The DebugDrawerComponent class.
void removeCylinderVisu(const std::string &layerName, const std::string &cylinderName, const ::Ice::Current &=Ice::emptyCurrent) override
DebugDrawerComponent()
DebugDrawerComponent Constructs a debug drawer.
RecursiveMutexPtr topicMutex
void setLineSetVisu(const std::string &layerName, const std::string &lineSetName, const DebugDrawerLineSet &lineSet, const ::Ice::Current &=Ice::emptyCurrent) override
void setLineDebugLayerVisu(const std::string &lineName, const ::armarx::Vector3BasePtr &globalPosition1, const ::armarx::Vector3BasePtr &globalPosition2, float lineWidth, const ::armarx::DrawColor &color, const ::Ice::Current &=Ice::emptyCurrent) override
void removeSphere(const std::string &layerName, const std::string &name)
void onInitComponent() override
Pure virtual hook for the subclass.
void setPointCloudVisu(const std::string &layerName, const std::string &pointCloudName, const DebugDrawerPointCloud &pointCloud, const ::Ice::Current &=Ice::emptyCurrent) override
void setArrowDebugLayerVisu(const std::string &arrowName, const ::armarx::Vector3BasePtr &position, const ::armarx::Vector3BasePtr &direction, const DrawColor &color, float length, float width, const ::Ice::Current &=Ice::emptyCurrent) override
void removePointCloud(const std::string &layerName, const std::string &name)
void setPointCloudDebugLayerVisu(const std::string &pointCloudName, const DebugDrawerPointCloud &pointCloud, const ::Ice::Current &=Ice::emptyCurrent) override
void removeTextDebugLayerVisu(const std::string &textName, const ::Ice::Current &=Ice::emptyCurrent) override
void drawLineSet(const LineSetData &d)
void setTextVisu(const std::string &layerName, const std::string &textName, const std::string &text, const ::armarx::Vector3BasePtr &globalPosition, const DrawColor &color, int size, const ::Ice::Current &=Ice::emptyCurrent) override
void removePolygonDebugLayerVisu(const std::string &polygonName, const ::Ice::Current &=Ice::emptyCurrent) override
std::recursive_mutex RecursiveMutex
void removePolygon(const std::string &layerName, const std::string &name)
void setBoxDebugLayerVisu(const std::string &boxName, const ::armarx::PoseBasePtr &globalPose, const ::armarx::Vector3BasePtr &dimensions, const DrawColor &color, const ::Ice::Current &=Ice::emptyCurrent) override
void clearDebugLayer(const ::Ice::Current &=Ice::emptyCurrent) override
void removeRobotVisu(const std::string &layerName, const std::string &robotName, const ::Ice::Current &=Ice::emptyCurrent) override
void removeBox(const std::string &layerName, const std::string &name)
bool getDefaultLayerVisibility() const
void setVisuUpdateTime(float visuUpdatesPerSec)
setVisuUpdateTime Specifies how often the accumulated draw commands should be applied to the visualiz...
void removeTriMeshVisu(const std::string &layerName, const std::string &triMeshName, const ::Ice::Current &=Ice::emptyCurrent) override
void setSphereDebugLayerVisu(const std::string &sphereName, const ::armarx::Vector3BasePtr &globalPosition, const DrawColor &color, float radius, const ::Ice::Current &=Ice::emptyCurrent) override
void reportSelectionChanged(const DebugDrawerSelectionList &selectedElements, const ::Ice::Current &=Ice::emptyCurrent) override
bool defaultLayerVisibility
void updateRobotNodeColor(const std::string &layerName, const std::string &robotName, const std::string &robotNodeName, const armarx::DrawColor &c, const ::Ice::Current &=Ice::emptyCurrent) override
void removeLineSetVisu(const std::string &layerName, const std::string &lineSetName, const ::Ice::Current &=Ice::emptyCurrent) override
void removeLineVisu(const std::string &layerName, const std::string &lineName, const ::Ice::Current &=Ice::emptyCurrent) override
void removeLineDebugLayerVisu(const std::string &lineName, const ::Ice::Current &=Ice::emptyCurrent) override
void removeBoxVisu(const std::string &layerName, const std::string &boxName, const ::Ice::Current &=Ice::emptyCurrent) override
void updateRobotPose(const std::string &layerName, const std::string &robotName, const ::armarx::PoseBasePtr &globalPose, const ::Ice::Current &=Ice::emptyCurrent) override
void setCircleArrowVisu(const std::string &layerName, const std::string &circleName, 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 enableLayerVisu(const std::string &layerName, bool visible, const ::Ice::Current &=Ice::emptyCurrent) override
void onDisconnectComponent() override
Hook for subclass.
void removeTextVisu(const std::string &layerName, const std::string &textName, const ::Ice::Current &=Ice::emptyCurrent) override
std::shared_ptr< RecursiveMutexLock > RecursiveMutexLockPtr
void removeCircleVisu(const std::string &layerName, const std::string &circleName, const Ice::Current &=Ice::emptyCurrent) override
void removePolygonVisu(const std::string &layerName, const std::string &polygonName, const ::Ice::Current &=Ice::emptyCurrent) override
virtual void onUpdateVisualization()
onUpdateVisualization derived methods can overwrite this method to update custom visualizations.
RecursiveMutexLockPtr getScopedVisuLock()
getScopedLock If using the coin visualization it must be ensured that all rendering calls are protect...
void drawBox(const BoxData &d)
void removeBoxDebugLayerVisu(const std::string &boxName, const ::Ice::Current &=Ice::emptyCurrent) override
void updateRobotColor(const std::string &layerName, const std::string &robotName, const armarx::DrawColor &c, const ::Ice::Current &=Ice::emptyCurrent) override
updateRobotColor Colorizes the robot visualization
void removeSelectionCallbacks()
virtual void setColoredPointCloudDebugLayerVisu(const std::string &pointCloudName, const DebugDrawerColoredPointCloud &pointCloud, const ::Ice::Current &=Ice::emptyCurrent)
void setTriMeshDebugLayerVisu(const std::string &triMeshName, const DebugDrawerTriMesh &triMesh, const ::Ice::Current &=Ice::emptyCurrent) override
void setBoxVisu(const std::string &layerName, const std::string &boxName, const ::armarx::PoseBasePtr &globalPose, const ::armarx::Vector3BasePtr &dimensions, const DrawColor &color, const ::Ice::Current &=Ice::emptyCurrent) override
void remove24BitColoredPointCloud(const std::string &layerName, const std::string &name)
std::shared_ptr< RecursiveMutex > RecursiveMutexPtr
void removeLine(const std::string &layerName, const std::string &name)
void removeCylinder(const std::string &layerName, const std::string &name)
void drawText(const TextData &d)
SoSeparator * getVisualization()
getVisualization Ensure that all access to this node is protected with the scoped lock mutex.
void enableSelections(const std::string &layerName, const ::Ice::Current &=Ice::emptyCurrent) override
void removeCoordSystem(const std::string &layerName, const std::string &name)
void set24BitColoredPointCloudDebugLayerVisu(const std::string &pointCloudName, const DebugDrawer24BitColoredPointCloud &pointCloud, const ::Ice::Current &=Ice::emptyCurrent) override
void setPoseDebugLayerVisu(const std::string &poseName, const ::armarx::PoseBasePtr &globalPose, const ::Ice::Current &=Ice::emptyCurrent) override
void drawCoordSystem(const CoordData &d)
::armarx::LayerInformationSequence layerInformation(const ::Ice::Current &=Ice::emptyCurrent) override
void removeSphereVisu(const std::string &layerName, const std::string &sphereName, const ::Ice::Current &=Ice::emptyCurrent) override
void setLineSetDebugLayerVisu(const std::string &lineSetName, const DebugDrawerLineSet &lineSet, const ::Ice::Current &=Ice::emptyCurrent) override
SoSeparator * layerMainNode
Main node for all layers.
void exportScene(const std::string &filename, const ::Ice::Current &=Ice::emptyCurrent) override
void removeTriMeshDebugLayerVisu(const std::string &triMeshName, const ::Ice::Current &=Ice::emptyCurrent) override
void drawPointCloud(const PointCloudData &d)
void removeArrowDebugLayerVisu(const std::string &arrowName, const ::Ice::Current &=Ice::emptyCurrent) override
void select(const std::string &layerName, const std::string &elementName, const ::Ice::Current &=Ice::emptyCurrent) override
std::unique_lock< RecursiveMutex > RecursiveMutexLock
void removePoseDebugLayerVisu(const std::string &poseName, const ::Ice::Current &=Ice::emptyCurrent) override
void setSphereVisu(const std::string &layerName, const std::string &sphereName, const ::armarx::Vector3BasePtr &globalPosition, const DrawColor &color, float radius, const ::Ice::Current &=Ice::emptyCurrent) override
void setRobotVisu(const std::string &layerName, const std::string &robotName, const std::string &robotFile, const std::string &armarxProject, DrawStyle drawStyle, const ::Ice::Current &=Ice::emptyCurrent) override
setRobotVisu Initializes a robot visualization
void clearLayerQt(const std::string &layerName)
void removeArrowVisu(const std::string &layerName, const std::string &arrowName, const ::Ice::Current &=Ice::emptyCurrent) override
void drawCylinder(const CylinderData &d)
SoSelection * selectionNode
void removeColoredPointCloudVisu(const std::string &layerName, const std::string &pointCloudName, const ::Ice::Current &=Ice::emptyCurrent) override
void deselect(const std::string &layerName, const std::string &elementName, const ::Ice::Current &=Ice::emptyCurrent) override
void remove24BitColoredPointCloudDebugLayerVisu(const std::string &pointCloudName, const ::Ice::Current &=Ice::emptyCurrent) override
void setPolygonVisu(const std::string &layerName, const std::string &polygonName, const std::vector<::armarx::Vector3BasePtr > &polygonPoints, const DrawColor &colorInner, const DrawColor &colorBorder, float lineWidth, const ::Ice::Current &=Ice::emptyCurrent) override
void updateRobotConfig(const std::string &layerName, const std::string &robotName, const std::map< std::string, float > &configuration, const ::Ice::Current &=Ice::emptyCurrent) override
DebugDrawerListenerPrx listenerPrx
void setTextDebugLayerVisu(const std::string &textName, const std::string &text, const ::armarx::Vector3BasePtr &globalPosition, const DrawColor &color, int size, const ::Ice::Current &=Ice::emptyCurrent) override
void setPolygonDebugLayerVisu(const std::string &polygonName, const std::vector<::armarx::Vector3BasePtr > &polygonPoints, const DrawColor &colorInner, const DrawColor &colorBorder, float lineWidth, const ::Ice::Current &=Ice::emptyCurrent) override
void removePointCloudDebugLayerVisu(const std::string &pointCloudName, const ::Ice::Current &=Ice::emptyCurrent) override
Layer & requestLayer(const std::string &layerName)
If a layer with layerName exists it is returned. Otherwise a new layer with given name is created and...
void removeCircle(const std::string &layerName, const std::string &name)
void removeCylinderDebugLayerVisu(const std::string &cylinderName, const ::Ice::Current &=Ice::emptyCurrent) override
RecursiveMutexPtr dataUpdateMutex
The data update mutex.
std::map< std::string, VirtualRobot::RobotPtr > activeRobots
void enableAllLayers(const ::Ice::Current &=Ice::emptyCurrent) override
void setLineVisu(const std::string &layerName, const std::string &lineName, const ::armarx::Vector3BasePtr &globalPosition1, const ::armarx::Vector3BasePtr &globalPosition2, float lineWidth, const ::armarx::DrawColor &color, const ::Ice::Current &=Ice::emptyCurrent) override
void removePointCloudVisu(const std::string &layerName, const std::string &pointCloudName, const ::Ice::Current &=Ice::emptyCurrent) override
bool hasLayer(const std::string &layerName, const ::Ice::Current &=Ice::emptyCurrent) override
void exportLayer(const std::string &filename, const std::string &layerName, const ::Ice::Current &=Ice::emptyCurrent) override
void removeColoredPointCloud(const std::string &layerName, const std::string &name)
void set24BitColoredPointCloudVisu(const std::string &layerName, const std::string &pointCloudName, const DebugDrawer24BitColoredPointCloud &pointCloud, const ::Ice::Current &=Ice::emptyCurrent) override
void removeRobot(const std::string &layerName, const std::string &name)
void draw24BitColoredPointCloud(const Colored24BitPointCloudData &d)
void onConnectComponent() override
Pure virtual hook for the subclass.
void setCylinderDebugLayerVisu(const std::string &cylinderName, const ::armarx::Vector3BasePtr &globalPosition, const ::armarx::Vector3BasePtr &direction, float length, float radius, const DrawColor &color, const ::Ice::Current &=Ice::emptyCurrent) override
::Ice::StringSeq layerNames(const ::Ice::Current &=Ice::emptyCurrent) override
RecursiveMutexLockPtr getScopedAccumulatedDataLock()
static std::recursive_mutex selectionMutex
VirtualRobot::RobotPtr requestRobot(const RobotData &d)
void drawLine(const LineData &d)
virtual void removeCustomVisu(const std::string &layerName, const std::string &name)
void removeTriMesh(const std::string &layerName, const std::string &name)
void setColoredPointCloudVisu(const std::string &layerName, const std::string &pointCloudName, const DebugDrawerColoredPointCloud &pointCloud, const ::Ice::Current &=Ice::emptyCurrent) override
void removeSphereDebugLayerVisu(const std::string &sphereName, const ::Ice::Current &=Ice::emptyCurrent) override
void setMutex(RecursiveMutexPtr const &m)
void remove24BitColoredPointCloudVisu(const std::string &layerName, const std::string &pointCloudName, const ::Ice::Current &=Ice::emptyCurrent) override
void installSelectionCallbacks()
void removeCircleDebugLayerVisu(const std::string &circleName, const Ice::Current &=Ice::emptyCurrent) override
DebugDrawerSelectionList getSelections(const ::Ice::Current &=Ice::emptyCurrent) override
void clearSelections(const std::string &layerName, const ::Ice::Current &=Ice::emptyCurrent) override
void removeColoredPointCloudDebugLayerVisu(const std::string &pointCloudName, const ::Ice::Current &=Ice::emptyCurrent) override
void setTriMeshVisu(const std::string &layerName, const std::string &triMeshName, const DebugDrawerTriMesh &triMesh, const ::Ice::Current &=Ice::emptyCurrent) override
void removePoseVisu(const std::string &layerName, const std::string &poseName, const ::Ice::Current &=Ice::emptyCurrent) override
static void updateVisualizationCB(void *data, SoSensor *sensor)
void setScaledPoseVisu(const std::string &layerName, const std::string &poseName, const ::armarx::PoseBasePtr &globalPose, const ::Ice::Float scale, const ::Ice::Current &=Ice::emptyCurrent) override
void clearLayer(const std::string &layerName, const ::Ice::Current &=Ice::emptyCurrent) override
void enableDebugLayerVisu(bool visible, const ::Ice::Current &=Ice::emptyCurrent) override
void removeArrow(const std::string &layerName, const std::string &name)
void setPoseVisu(const std::string &layerName, const std::string &poseName, const ::armarx::PoseBasePtr &globalPose, const ::Ice::Current &=Ice::emptyCurrent) override
void deselectionCallback()
~DebugDrawerComponent() override
void updateVisualization()
std::mutex timerSensorMutex
void onExitComponent() override
Hook for subclass.
std::map< const std::string, Layer > layers
All existing layers.
void drawRobot(const RobotData &d)
std::map< std::string, VirtualRobot::RobotPtr > loadedRobots
void setArrowVisu(const std::string &layerName, const std::string &arrowName, const ::armarx::Vector3BasePtr &position, const ::armarx::Vector3BasePtr &direction, const DrawColor &color, float length, float width, const ::Ice::Current &=Ice::emptyCurrent) override
void setLayerVisibility(const std::string &layerName, bool visible)
void removeLayer(const std::string &layerName, const ::Ice::Current &=Ice::emptyCurrent) override
SoTimerSensor * timerSensor
virtual void onRemoveAccumulatedData(const std::string &layerName)
void drawColoredPointCloud(const ColoredPointCloudData &d)
UpdateData accumulatedUpdateData
void disableAllLayers(const ::Ice::Current &=Ice::emptyCurrent) override
void drawCircle(const DebugDrawerComponent::CircleData &d)
void setCircleDebugLayerVisu(const std::string &circleName, 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 removeLineSetDebugLayerVisu(const std::string &lineSetName, const ::Ice::Current &=Ice::emptyCurrent) override
void clearAll(const ::Ice::Current &=Ice::emptyCurrent) override
RecursiveMutexPtr mutex
The coin mutex.
void drawSphere(const SphereData &d)
std::set< std::string > selectableLayers
void disableSelections(const std::string &layerName, const ::Ice::Current &=Ice::emptyCurrent) override
void drawPolygon(const PolygonData &d)
void drawArrow(const ArrowData &d)
void ensureExistingRobotNodes(DebugDrawerComponent::RobotData &d)
ensureExistingRobotNodes Checks if all robotnodes of configuration exist in robot....
void removeAccumulatedData(const std::string &layerName)
void removeLineSet(const std::string &layerName, const std::string &name)
void setCylinderVisu(const std::string &layerName, const std::string &cylinderName, const ::armarx::Vector3BasePtr &globalPosition, const ::armarx::Vector3BasePtr &direction, float length, float radius, const DrawColor &color, const ::Ice::Current &=Ice::emptyCurrent) override
void setScaledPoseDebugLayerVisu(const std::string &poseName, const ::armarx::PoseBasePtr &globalPose, const ::Ice::Float scale, const ::Ice::Current &=Ice::emptyCurrent) override
void removeText(const std::string &layerName, const std::string &name)
void drawTriMesh(const TriMeshData &d)
void removeLayerQt(const std::string &layerName)
SpamFilterDataPtr deactivateSpam(float deactivationDurationSec=10.0f, const std::string &identifier="", bool deactivate=true) const
disables the logging for the current line for the given amount of seconds.
void offeringTopic(const std::string &name)
Registers a topic for retrival after initialization.
TopicProxyType getTopic(const std::string &name)
Returns a proxy of the specified topic.
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
#define ARMARX_INFO
The normal logging level.
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
#define ARMARX_VERBOSE
The logging level for verbose information.
std::shared_ptr< class Robot > RobotPtr
DrawColor HeatMapRGBAColor(float percentage)
This file offers overloads of toIce() and fromIce() functions for STL container types.
void deselection_callback(void *userdata, SoPath *path)
void selection_callback(void *userdata, SoPath *path)
const LogSender::manipulator flush
Eigen::Vector3f GetOrthonormalVectors(Eigen::Vector3f vec, Eigen::Vector3f &dir1, Eigen::Vector3f &dir2)
boost::shared_ptr< VirtualRobot::CoinVisualization > CoinVisualizationPtr
void removeUpdateDataFromMap(const std::string &layerName, std::map< std::string, UpdateDataType > &map)
bool isfinite(const std::vector< T, Ts... > &v)
Eigen::Vector3f direction
VirtualRobot::VisualizationFactory::Color color
Eigen::Matrix4f globalPose
VirtualRobot::VisualizationFactory::Color color
Eigen::Vector3f direction
VirtualRobot::VisualizationFactory::Color color
DebugDrawer24BitColoredPointCloud pointCloud
DebugDrawerColoredPointCloud pointCloud
Eigen::Matrix4f globalPose
Eigen::Vector3f direction
VirtualRobot::VisualizationFactory::Color color
bool update
Whether an existing visu should be updated.
Contains data for a layer.
std::map< std::string, SoSeparator * > addedTextVisualizations
std::map< std::string, SoSeparator * > addedTriMeshVisualizations
std::map< std::string, SoSeparator * > addedCylinderVisualizations
std::map< std::string, SoSeparator * > addedCoordVisualizations
std::map< std::string, SoSeparator * > addedArrowVisualizations
std::map< std::string, SoSeparator * > addedColoredPointCloudVisualizations
std::map< std::string, SoSeparator * > addedBoxVisualizations
std::map< std::string, SoSeparator * > addedLineSetVisualizations
std::map< std::string, SoSeparator * > addedRobotVisualizations
std::map< std::string, SoSeparator * > addedCircleVisualizations
std::map< std::string, SoSeparator * > addedLineVisualizations
std::map< std::string, SoSeparator * > addedSphereVisualizations
std::map< std::string, SoSeparator * > added24BitColoredPointCloudVisualizations
std::map< std::string, SoSeparator * > addedPolygonVisualizations
std::map< std::string, SoSeparator * > addedPointCloudVisualizations
std::map< std::string, SoSeparator * > addedCustomVisualizations
VirtualRobot::VisualizationFactory::Color color
DebugDrawerLineSet lineSet
DebugDrawerPointCloud pointCloud
VirtualRobot::VisualizationFactory::Color colorInner
std::vector< Eigen::Vector3f > points
VirtualRobot::VisualizationFactory::Color colorBorder
std::map< std::string, float > configuration
armarx::DrawStyle drawStyle
std::string armarxProject
std::map< std::string, VirtualRobot::VisualizationFactory::Color > nodeColors
Eigen::Matrix4f globalPose
VirtualRobot::VisualizationFactory::Color color
VirtualRobot::VisualizationFactory::Color color
VirtualRobot::VisualizationFactory::Color color
DebugDrawerTriMesh triMesh