diff --git a/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.cpp b/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.cpp index e43eec00e493cf3072e62a0d00f7f31637209a6b..0e2ae813fbef99c1ce24e35c8be0be63deeeff8b 100644 --- a/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.cpp +++ b/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.cpp @@ -136,26 +136,33 @@ namespace armarx::viz::coin if (loadedDrawStyle & data::ModelDrawStyle::OVERRIDE_COLOR) { - int numChildren = node->getNumChildren(); - for (int i = 0; i < numChildren; i++) + if (loadedColor.r != element.color.r + || loadedColor.g != element.color.g + || loadedColor.b != element.color.b + || loadedColor.a != element.color.a) { - SoSeparator* nodeSep = static_cast<SoSeparator*>(node->getChild(i)); - // The first entry must be a SoMaterial (see recreateVisualizationNodes) - SoMaterial* m = dynamic_cast<SoMaterial*>(nodeSep->getChild(0)); - if (!m) + int numChildren = node->getNumChildren(); + for (int i = 0; i < numChildren; i++) { - ARMARX_WARNING << "Error at node with index: " << i; - continue; + SoSeparator* nodeSep = static_cast<SoSeparator*>(node->getChild(i)); + // The first entry must be a SoMaterial (see recreateVisualizationNodes) + SoMaterial* m = dynamic_cast<SoMaterial*>(nodeSep->getChild(0)); + if (!m) + { + ARMARX_WARNING << "Error at node with index: " << i; + continue; + } + + auto color = element.color; + const float conv = 1.0f / 255.0f; + float a = color.a * conv; + SbColor coinColor(conv * color.r, conv * color.g, conv * color.b); + m->diffuseColor = coinColor; + m->ambientColor = coinColor; + m->transparency = 1.0f - a; + m->setOverride(true); } - - auto color = element.color; - const float conv = 1.0f / 255.0f; - float a = color.a * conv; - SbColor coinColor(conv * color.r, conv * color.g, conv * color.b); - m->diffuseColor = coinColor; - m->ambientColor = coinColor; - m->transparency = 1.0f - a; - m->setOverride(true); + loadedColor = element.color; } } //IceUtil::Time time_color = IceUtil::Time::now(); diff --git a/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.h b/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.h index cb6699735a40b1783bb0e09270891910514278da..63aa3f1f8cabf92029b1d1b763d808f9b2123d77 100644 --- a/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.h +++ b/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.h @@ -25,6 +25,7 @@ namespace armarx::viz::coin LoadedRobot loaded; int loadedDrawStyle = data::ModelDrawStyle::ORIGINAL; + armarx::viz::data::Color loadedColor{0, 0, 0, 0}; }; void clearRobotCache(); diff --git a/source/RobotAPI/components/DSObstacleAvoidance/DSObstacleAvoidance.cpp b/source/RobotAPI/components/DSObstacleAvoidance/DSObstacleAvoidance.cpp index 4a83bdedaabbabcc2f46bc4e2815a826ee661156..a1be9a1ff18a6d9c86a570b75d5b9079f9ae8b68 100644 --- a/source/RobotAPI/components/DSObstacleAvoidance/DSObstacleAvoidance.cpp +++ b/source/RobotAPI/components/DSObstacleAvoidance/DSObstacleAvoidance.cpp @@ -549,17 +549,23 @@ armarx::DSObstacleAvoidance::run_visualization() Layer layer_sms = arviz.layer("safety_margins"); Layer layer_rps = arviz.layer("reference_points"); Layer layer_bbs = arviz.layer("bounding_boxes"); - Color color = Color::red(255, 128); - Color color_m = Color::red(255, 64); - - if (not m_doa.cfg.only_2d) - { - color = Color::blue(255, 128); - color_m = Color::blue(255, 64); - } for (const obstacledetection::Obstacle& obstacle : getObstacles()) { + Color color = Color::orange(255, 128); + Color color_m = Color::orange(255, 64); + + if (obstacle.name == "human") + { + color = Color::red(255, 128); + color_m = Color::red(255, 64); + } + else if (not m_doa.cfg.only_2d) + { + color = Color::blue(255, 128); + color_m = Color::blue(255, 64); + } + const double safetyMarginZ = m_doa.cfg.only_2d ? 1 : obstacle.safetyMarginZ; const double posZ = m_doa.cfg.only_2d ? 1 : obstacle.posZ; const double refPosZ = m_doa.cfg.only_2d ? 1 : obstacle.refPosZ; @@ -574,6 +580,7 @@ armarx::DSObstacleAvoidance::run_visualization() if (m_doa.cfg.only_2d) { + layer_obs.add(Cylindroid{obstacle.name} .pose(pose) .axisLengths(dim.head<2>()) diff --git a/source/RobotAPI/components/DynamicObstacleManager/DynamicObstacleManager.cpp b/source/RobotAPI/components/DynamicObstacleManager/DynamicObstacleManager.cpp index 46515a2c2f9a61acbaf63c186920478dab82cb1c..e712e30ccb2978fdc7caa0210b919773b7dce46b 100644 --- a/source/RobotAPI/components/DynamicObstacleManager/DynamicObstacleManager.cpp +++ b/source/RobotAPI/components/DynamicObstacleManager/DynamicObstacleManager.cpp @@ -234,7 +234,9 @@ namespace armarx void DynamicObstacleManager::wait_unitl_obstacles_are_ready(const Ice::Current&) { - usleep(m_min_value_for_accepting); + ARMARX_INFO << "Waiting for obstacles to get ready"; + usleep(2.0 * m_min_value_for_accepting); + ARMARX_INFO << "Finished waiting for obstacles"; }