27#include <SimoxUtility/algorithm/string/string_tools.h>
28#include <VirtualRobot/Visualization/CoinVisualization/CoinVisualization.h>
29#include <VirtualRobot/Visualization/CoinVisualization/CoinVisualizationFactory.h>
31#include <Inventor/nodes/SoCube.h>
32#include <Inventor/nodes/SoMaterial.h>
33#include <Inventor/nodes/SoUnits.h>
41 static const std::string DEBUG_LAYER_NAME{
"debug"};
105 SoSeparator* sep = layer.addedCustomVisualizations[d.
name];
107 if (!sep || sep->getNumChildren() < 2)
113 SoMaterial* m =
dynamic_cast<SoMaterial*
>(sep->getChild(0));
121 if (d.
color.isNone())
123 m->setOverride(
false);
130 if (d.
color.transparency == 1)
132 m->diffuseColor.setIgnored(FALSE);
133 m->setOverride(FALSE);
137 m->transparency = d.
color.transparency;
138 m->diffuseColor.setIgnored(TRUE);
139 m->setOverride(TRUE);
146 m->ambientColor = SbColor(0, 0, 0);
147 m->transparency = std::max(0.0f, d.
color.transparency);
148 m->setOverride(
true);
160 std::string entryName =
"__" + layerName +
"__" + name +
"__";
173 auto& layer =
layers.at(layerName);
175 if (layer.addedCustomVisualizations.find(name) == layer.addedCustomVisualizations.end())
180 layer.mainNode->removeChild(layer.addedCustomVisualizations[name]);
181 layer.addedCustomVisualizations.erase(name);
187 DebugDrawerComponent::onInitComponent();
199 DebugDrawerComponent::onConnectComponent();
202 CommonStorageInterfacePrx commonStoragePrx =
205 if (commonStoragePrx)
215 ARMARX_INFO <<
"Connecting to prior knowldege with name:" << priorKnowledgeName;
223 DebugDrawerComponent::onDisconnectComponent();
229 DebugDrawerComponent::onExitComponent();
234 const std::string& objectName,
235 const Ice::Current&
c)
238 std::string entryName =
"__" + layerName +
"__" + objectName +
"__";
247 const std::string& objectName,
248 const armarx::DrawColor& color,
249 const Ice::Current&
c)
252 std::string entryName =
"__" + layerName +
"__" + objectName +
"__";
261 if (color.a == 0 && color.b == 0 && color.r == 0 && color.g == 0)
263 d.
color = VirtualRobot::VisualizationFactory::Color::None();
268 VirtualRobot::VisualizationFactory::Color(color.r, color.g, color.b, 1 - color.a);
276 const std::string& objectName,
278 const Ice::Current&
c)
281 std::string entryName =
"__" + layerName +
"__" + objectName +
"__";
298 d.
color = VirtualRobot::VisualizationFactory::Color(-1, -1, -1, 1 - alpha);
304 const std::string& objectName,
305 const armarx::PoseBasePtr& globalPose,
306 const Ice::Current&
c)
309 std::string entryName =
"__" + layerName +
"__" + objectName +
"__";
315 d.
globalPose = armarx::PosePtr::dynamicCast(globalPose)->toEigen();
324 const std::string& objectName,
325 const ObjectClassBasePtr& objectClassBase,
326 const armarx::PoseBasePtr& globalPose,
327 const Ice::Current&
c)
330 std::string entryName =
"__" + layerName +
"__" + objectName +
"__";
333 d.
objectClass = ObjectClassPtr::dynamicCast(objectClassBase);
334 d.
globalPose = armarx::PosePtr::dynamicCast(globalPose)->toEigen();
344 const std::string& customObjectName,
345 const std::string& objectClassName,
346 const armarx::PoseBasePtr& globalPose,
347 const Ice::Current&
c)
350 if (!objectClassBase)
352 ARMARX_WARNING <<
"An object with class name '" << objectClassName
353 <<
"' does not exist!";
357 std::string entryName =
"__" + layerName +
"__" + customObjectName +
"__";
360 d.
objectClass = ObjectClassPtr::dynamicCast(objectClassBase);
361 d.
globalPose = armarx::PosePtr::dynamicCast(globalPose)->toEigen();
363 d.
name = customObjectName;
369 VirtualRobot::SceneObjectPtr
375 std::string entryName =
"__" + d.
layerName +
"__" + d.
name +
"__";
382 VirtualRobot::SceneObjectPtr result;
391 ARMARX_ERROR <<
"Invalid object class; could not create object with instance name "
400 VirtualRobot::ManipulationObjectPtr mo = sw->getManipulationObject();
404 ARMARX_ERROR <<
"Could not retrieve manipulation object of object class "
405 << objectClass->getName();
415 ARMARX_LOG <<
"Loaded manipulation object " << mo->getName() <<
" of class "
416 << objectClass->getName();
421 ARMARX_LOG <<
"Using manipulation object " << result->getName() <<
" of class "
422 << objectClass->getName() <<
" from cache";
434 SoSeparator* sep =
new SoSeparator;
435 layer.mainNode->addChild(sep);
437 SoMaterial* m =
new SoMaterial;
438 m->setOverride(
false);
441 auto objVisu = result->getVisualization<CoinVisualization>(VirtualRobot::SceneObject::Full);
442 SoNode* sepo = objVisu->getCoinVisualization();
446 layer.addedCustomVisualizations[d.
name] = sep;
455 std::string entryName =
"__" + layerName +
"__";
461 if (simox::alg::starts_with(i1->first, entryName))
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
Property< PropertyType > getProperty(const std::string &name)
DebugDrawerComponent()
DebugDrawerComponent Constructs a debug drawer.
RecursiveMutexLockPtr getScopedVisuLock()
getScopedLock If using the coin visualization it must be ensured that all rendering calls are protect...
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...
bool hasLayer(const std::string &layerName, const ::Ice::Current &=Ice::emptyCurrent) override
RecursiveMutexLockPtr getScopedAccumulatedDataLock()
std::map< const std::string, Layer > layers
All existing layers.
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
std::map< std::string, VirtualRobot::SceneObjectPtr > activeObjects
memoryx::PersistentObjectClassSegmentBasePrx objectClassSegment
void onInitComponent() override
Pure virtual hook for the subclass.
void updateObjectColor(const std::string &layerName, const std::string &objectName, const armarx::DrawColor &color, const Ice::Current &c=Ice::emptyCurrent) override
updateObjectColor Colorizes the object visualization
void updateObjectPose(const std::string &layerName, const std::string &objectName, const armarx::PoseBasePtr &globalPose, const Ice::Current &c=Ice::emptyCurrent) override
VirtualRobot::SceneObjectPtr requestEntity(const EntityData &d)
void setObjectVisuByName(const std::string &layerName, const std::string &customObjectName, const std::string &objectClassName, const armarx::PoseBasePtr &globalPose, const Ice::Current &c=Ice::emptyCurrent) override
void setObjectVisu(const std::string &layerName, const std::string &objectName, const memoryx::ObjectClassBasePtr &objectClassBase, const armarx::PoseBasePtr &globalPose, const Ice::Current &c=Ice::emptyCurrent) override
void onDisconnectComponent() override
Hook for subclass.
void removeObjectVisu(const std::string &layerName, const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
memoryx::PriorKnowledgeInterfacePrx priorKnowledgePrx
EntityUpdateData accumulatedCustomUpdateData
~EntityDrawerComponent() override
void removeEntity(const std::string &layerName, const std::string &name)
void removeCustomVisu(const std::string &layerName, const std::string &name) override
GridFileManagerPtr fileManager
std::map< std::string, VirtualRobot::ManipulationObjectPtr > objectCache
void onConnectComponent() override
Pure virtual hook for the subclass.
EntityDrawerComponent()
EntityDrawerComponent Constructs a debug drawer.
void onRemoveAccumulatedData(const std::string &layerName) override
void onExitComponent() override
Hook for subclass.
void drawEntity(const EntityData &d)
void updateObjectTransparency(const std::string &layerName, const std::string &objectName, float alpha, const Ice::Current &c=Ice::emptyCurrent) override
void onUpdateVisualization() override
onUpdateVisualization derived methods can overwrite this method to update custom visualizations.
SimoxObjectWrapper offers a simplified access to the Simox ManipulationObject (i.e visualization,...
GridFileManager provides utility functions for working with files in Mongo GridFS and links to them s...
#define ARMARX_INFO
The normal logging level.
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
IceInternal::Handle< SimoxObjectWrapper > SimoxObjectWrapperPtr
IceInternal::Handle< ObjectClass > ObjectClassPtr
bool update
Whether an existing visu should be updated.
memoryx::ObjectClassPtr objectClass
Eigen::Matrix4f globalPose
VirtualRobot::VisualizationFactory::Color color