Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • sw/armarx/robot-api
  • uwkce_singer/robot-api
  • untcg_hofmann/robot-api
  • ulqba_korosakov/RobotAPI
4 results
Show changes
Showing
with 274 additions and 124 deletions
# GamepadUnit # GamepadUnit {#GamepadUnit}
This component is used to control the robot with a gamepad. This component is used to control the robot with a gamepad.
......
...@@ -1353,8 +1353,8 @@ namespace armarx ...@@ -1353,8 +1353,8 @@ namespace armarx
auto it = reportedJointStatuses.find(rn[i]->getName()); auto it = reportedJointStatuses.find(rn[i]->getName());
if (it == reportedJointStatuses.end()) if (it == reportedJointStatuses.end())
{ {
ARMARX_WARNING << deactivateSpam(5, rn[i]->getName()) << "Joint Status for " << rn[i]->getName() ARMARX_VERBOSE << deactivateSpam(5, rn[i]->getName()) << "Joint Status for "
<< " was not reported!"; << rn[i]->getName() << " was not reported!";
continue; continue;
} }
JointStatus currentStatus = it->second; JointStatus currentStatus = it->second;
......
...@@ -82,7 +82,6 @@ armarx_enable_aron_file_generation_for_target( ...@@ -82,7 +82,6 @@ armarx_enable_aron_file_generation_for_target(
"${LIB_NAME}" "${LIB_NAME}"
ARON_FILES ARON_FILES
aron/ObjectID.xml aron/ObjectID.xml
aron/ObjectNames.xml
aron/ObjectPose.xml aron/ObjectPose.xml
aron/ObjectType.xml aron/ObjectType.xml
aron/PoseManifoldGaussian.xml aron/PoseManifoldGaussian.xml
......
...@@ -8,7 +8,7 @@ Core segment type of Object/Class. ...@@ -8,7 +8,7 @@ Core segment type of Object/Class.
<PackagePath package="RobotAPI" path="libraries/aron/common/aron/OrientedBox.xml" /> <PackagePath package="RobotAPI" path="libraries/aron/common/aron/OrientedBox.xml" />
<PackagePath package="RobotAPI" path="libraries/aron/common/aron/PackagePath.xml" /> <PackagePath package="RobotAPI" path="libraries/aron/common/aron/PackagePath.xml" />
<PackagePath package="RobotAPI" path="libraries/ArmarXObjects/aron/ObjectID.xml" /> <PackagePath package="RobotAPI" path="libraries/ArmarXObjects/aron/ObjectID.xml" />
<PackagePath package="RobotAPI" path="libraries/ArmarXObjects/aron/ObjectNames.xml" /> <PackagePath package="RobotAPI" path="libraries/aron/common/aron/Names.xml" />
<PackagePath package="RobotAPI" path="libraries/armem/aron/MemoryID.xml" /> <PackagePath package="RobotAPI" path="libraries/armem/aron/MemoryID.xml" />
</AronIncludes> </AronIncludes>
<GenerateTypes> <GenerateTypes>
...@@ -83,7 +83,7 @@ Core segment type of Object/Class. ...@@ -83,7 +83,7 @@ Core segment type of Object/Class.
</ObjectChild> </ObjectChild>
<ObjectChild key="names"> <ObjectChild key="names">
<armarx::arondto::ObjectNames /> <armarx::arondto::Names />
</ObjectChild> </ObjectChild>
<ObjectChild key="ivtFeatures"> <ObjectChild key="ivtFeatures">
......
...@@ -4,50 +4,53 @@ ...@@ -4,50 +4,53 @@
#include <RobotAPI/libraries/armem/core/aron_conversions.h> #include <RobotAPI/libraries/armem/core/aron_conversions.h>
#include <RobotAPI/libraries/aron/common/aron_conversions.h> #include <RobotAPI/libraries/aron/common/aron_conversions.h>
namespace armarx::armem namespace armarx
{ {
void void
fromAron(const arondto::ObjectInstance& dto, objpose::arondto::ObjectPose& bo) armem::fromAron(const arondto::ObjectInstance& dto, objpose::arondto::ObjectPose& bo)
{ {
bo = dto.pose; bo = dto.pose;
} }
void void
toAron(arondto::ObjectInstance& dto, const objpose::arondto::ObjectPose& bo) armem::toAron(arondto::ObjectInstance& dto, const objpose::arondto::ObjectPose& bo)
{ {
dto.pose = bo; dto.pose = bo;
} }
void void
fromAron(const arondto::ObjectInstance& dto, objpose::ObjectPose& bo) armem::fromAron(const arondto::ObjectInstance& dto, objpose::ObjectPose& bo)
{ {
objpose::fromAron(dto.pose, bo); objpose::fromAron(dto.pose, bo);
} }
void void
toAron(arondto::ObjectInstance& dto, const objpose::ObjectPose& bo) armem::toAron(arondto::ObjectInstance& dto, const objpose::ObjectPose& bo)
{ {
objpose::toAron(dto.pose, bo); objpose::toAron(dto.pose, bo);
} }
/* Attachments */ /* Attachments */
void void
fromAron(const arondto::attachment::AgentDescription& dto, attachment::AgentDescription& bo) armem::fromAron(const arondto::attachment::AgentDescription& dto,
attachment::AgentDescription& bo)
{ {
fromAron(dto.id, bo.id); fromAron(dto.id, bo.id);
aron::fromAron(dto.frame, bo.frame); aron::fromAron(dto.frame, bo.frame);
} }
void void
toAron(arondto::attachment::AgentDescription& dto, const attachment::AgentDescription& bo) armem::toAron(arondto::attachment::AgentDescription& dto,
const attachment::AgentDescription& bo)
{ {
toAron(dto.id, bo.id); toAron(dto.id, bo.id);
aron::toAron(dto.frame, bo.frame); aron::toAron(dto.frame, bo.frame);
} }
void void
fromAron(const arondto::attachment::ObjectAttachment& dto, attachment::ObjectAttachment& bo) armem::fromAron(const arondto::attachment::ObjectAttachment& dto,
attachment::ObjectAttachment& bo)
{ {
fromAron(dto.agent, bo.agent); fromAron(dto.agent, bo.agent);
aron::fromAron(dto.transformation, bo.transformation); aron::fromAron(dto.transformation, bo.transformation);
...@@ -57,7 +60,8 @@ namespace armarx::armem ...@@ -57,7 +60,8 @@ namespace armarx::armem
} }
void void
toAron(arondto::attachment::ObjectAttachment& dto, const attachment::ObjectAttachment& bo) armem::toAron(arondto::attachment::ObjectAttachment& dto,
const attachment::ObjectAttachment& bo)
{ {
toAron(dto.agent, bo.agent); toAron(dto.agent, bo.agent);
aron::toAron(dto.transformation, bo.transformation); aron::toAron(dto.transformation, bo.transformation);
...@@ -67,8 +71,8 @@ namespace armarx::armem ...@@ -67,8 +71,8 @@ namespace armarx::armem
} }
void void
fromAron(const arondto::attachment::ArticulatedObjectAttachment& dto, armem::fromAron(const arondto::attachment::ArticulatedObjectAttachment& dto,
attachment::ArticulatedObjectAttachment& bo) attachment::ArticulatedObjectAttachment& bo)
{ {
fromAron(dto.agent, bo.agent); fromAron(dto.agent, bo.agent);
aron::fromAron(dto.transformation, bo.transformation); aron::fromAron(dto.transformation, bo.transformation);
...@@ -78,8 +82,8 @@ namespace armarx::armem ...@@ -78,8 +82,8 @@ namespace armarx::armem
} }
void void
toAron(arondto::attachment::ArticulatedObjectAttachment& dto, armem::toAron(arondto::attachment::ArticulatedObjectAttachment& dto,
const attachment::ArticulatedObjectAttachment& bo) const attachment::ArticulatedObjectAttachment& bo)
{ {
toAron(dto.agent, bo.agent); toAron(dto.agent, bo.agent);
aron::toAron(dto.transformation, bo.transformation); aron::toAron(dto.transformation, bo.transformation);
...@@ -89,7 +93,7 @@ namespace armarx::armem ...@@ -89,7 +93,7 @@ namespace armarx::armem
} }
void void
toAron(arondto::Marker& dto, const marker::Marker& bo) armem::toAron(arondto::Marker& dto, const marker::Marker& bo)
{ {
dto.name = bo.name; dto.name = bo.name;
armarx::toAron(dto.robotGlobal, bo.robotGlobal); armarx::toAron(dto.robotGlobal, bo.robotGlobal);
...@@ -100,7 +104,7 @@ namespace armarx::armem ...@@ -100,7 +104,7 @@ namespace armarx::armem
} }
void void
fromAron(const arondto::Marker& dto, marker::Marker& bo) armem::fromAron(const arondto::Marker& dto, marker::Marker& bo)
{ {
bo.name = dto.name; bo.name = dto.name;
armarx::fromAron(dto.robotGlobal, bo.robotGlobal); armarx::fromAron(dto.robotGlobal, bo.robotGlobal);
...@@ -109,13 +113,13 @@ namespace armarx::armem ...@@ -109,13 +113,13 @@ namespace armarx::armem
armarx::fromAron(dto.markerPose, bo.markerPose); armarx::fromAron(dto.markerPose, bo.markerPose);
} }
} // namespace armarx::armem } // namespace armarx
namespace armarx::armem::clazz namespace armarx::armem
{ {
void void
fromAron(const arondto::Feature& dto, Feature& bo) clazz::fromAron(const arondto::Feature& dto, Feature& bo)
{ {
bo.angle = dto.angle; bo.angle = dto.angle;
bo.scale = dto.scale; bo.scale = dto.scale;
...@@ -125,7 +129,7 @@ namespace armarx::armem::clazz ...@@ -125,7 +129,7 @@ namespace armarx::armem::clazz
} }
void void
toAron(arondto::Feature& dto, const Feature& bo) clazz::toAron(arondto::Feature& dto, const Feature& bo)
{ {
dto.angle = bo.angle; dto.angle = bo.angle;
dto.scale = bo.scale; dto.scale = bo.scale;
...@@ -135,7 +139,7 @@ namespace armarx::armem::clazz ...@@ -135,7 +139,7 @@ namespace armarx::armem::clazz
} }
void void
fromAron(const arondto::ObjectClass& dto, ObjectClass& bo) clazz::fromAron(const arondto::ObjectClass& dto, ObjectClass& bo)
{ {
armarx::fromAron(dto.id, bo.id); armarx::fromAron(dto.id, bo.id);
armarx::fromAron(dto.simoxXmlPath, bo.simoxXmlPath); armarx::fromAron(dto.simoxXmlPath, bo.simoxXmlPath);
...@@ -147,6 +151,7 @@ namespace armarx::armem::clazz ...@@ -147,6 +151,7 @@ namespace armarx::armem::clazz
armarx::fromAron(dto.meshObjPath, bo.meshObjPath); armarx::fromAron(dto.meshObjPath, bo.meshObjPath);
armarx::fromAron(dto.aabb, bo.aabb); armarx::fromAron(dto.aabb, bo.aabb);
armarx::fromAron(dto.oobb, bo.oobb); armarx::fromAron(dto.oobb, bo.oobb);
fromAron(dto.names, bo.names);
bo.ivtFeatures.clear(); bo.ivtFeatures.clear();
for (const auto& i : dto.ivtFeatures) for (const auto& i : dto.ivtFeatures)
{ {
...@@ -155,7 +160,7 @@ namespace armarx::armem::clazz ...@@ -155,7 +160,7 @@ namespace armarx::armem::clazz
} }
void void
toAron(arondto::ObjectClass& dto, const ObjectClass& bo) clazz::toAron(arondto::ObjectClass& dto, const ObjectClass& bo)
{ {
armarx::toAron(dto.id, bo.id); armarx::toAron(dto.id, bo.id);
armarx::toAron(dto.simoxXmlPath, bo.simoxXmlPath); armarx::toAron(dto.simoxXmlPath, bo.simoxXmlPath);
...@@ -167,6 +172,7 @@ namespace armarx::armem::clazz ...@@ -167,6 +172,7 @@ namespace armarx::armem::clazz
armarx::toAron(dto.meshObjPath, bo.meshObjPath); armarx::toAron(dto.meshObjPath, bo.meshObjPath);
armarx::toAron(dto.aabb, bo.aabb); armarx::toAron(dto.aabb, bo.aabb);
armarx::toAron(dto.oobb, bo.oobb); armarx::toAron(dto.oobb, bo.oobb);
toAron(dto.names, bo.names);
dto.ivtFeatures.clear(); dto.ivtFeatures.clear();
for (const auto& i : bo.ivtFeatures) for (const auto& i : bo.ivtFeatures)
{ {
...@@ -174,7 +180,7 @@ namespace armarx::armem::clazz ...@@ -174,7 +180,7 @@ namespace armarx::armem::clazz
} }
} }
} // namespace armarx::armem::clazz } // namespace armarx::armem
armarx::armem::MemoryID armarx::armem::MemoryID
armarx::armem::obj::makeObjectInstanceMemoryID(const objpose::ObjectPose& objectPose) armarx::armem::obj::makeObjectInstanceMemoryID(const objpose::ObjectPose& objectPose)
......
#pragma once #pragma once
#include <RobotAPI/libraries/ArmarXObjects/ObjectPose.h> #include <RobotAPI/libraries/ArmarXObjects/ObjectPose.h>
#include <RobotAPI/libraries/armem/core/MemoryID.h>
#include <RobotAPI/libraries/armem_objects/aron/Attachment.aron.generated.h> #include <RobotAPI/libraries/armem_objects/aron/Attachment.aron.generated.h>
#include <RobotAPI/libraries/armem_objects/aron/Marker.aron.generated.h> #include <RobotAPI/libraries/armem_objects/aron/Marker.aron.generated.h>
#include <RobotAPI/libraries/armem_objects/aron/ObjectClass.aron.generated.h> #include <RobotAPI/libraries/armem_objects/aron/ObjectClass.aron.generated.h>
...@@ -32,6 +33,7 @@ namespace armarx::armem ...@@ -32,6 +33,7 @@ namespace armarx::armem
void fromAron(const arondto::Marker& dto, marker::Marker& bo); void fromAron(const arondto::Marker& dto, marker::Marker& bo);
void toAron(arondto::Marker& dto, const marker::Marker& bo); void toAron(arondto::Marker& dto, const marker::Marker& bo);
} // namespace armarx::armem } // namespace armarx::armem
namespace armarx::armem::clazz namespace armarx::armem::clazz
...@@ -44,10 +46,9 @@ namespace armarx::armem::clazz ...@@ -44,10 +46,9 @@ namespace armarx::armem::clazz
} // namespace armarx::armem::clazz } // namespace armarx::armem::clazz
#include <RobotAPI/libraries/armem/core/MemoryID.h>
namespace armarx::armem::obj namespace armarx::armem::obj
{ {
/// Make a Memory ID for the object instance snapshot representing this pose. /// Make a Memory ID for the object instance snapshot representing this pose.
MemoryID makeObjectInstanceMemoryID(const objpose::ObjectPose& objectPose); MemoryID makeObjectInstanceMemoryID(const objpose::ObjectPose& objectPose);
} // namespace armarx::armem::obj } // namespace armarx::armem::obj
#include "ClassReader.h" #include "ClassReader.h"
#include <RobotAPI/libraries/armem/client/query.h>
#include <RobotAPI/libraries/armem_objects/aron_conversions.h>
#include <RobotAPI/libraries/armem_objects/types.h>
namespace armarx::armem::obj::clazz namespace armarx::armem::obj::clazz
{ {
std::optional<armem::clazz::ObjectClass> std::optional<armem::clazz::ObjectClass>
...@@ -27,6 +31,42 @@ namespace armarx::armem::obj::clazz ...@@ -27,6 +31,42 @@ namespace armarx::armem::obj::clazz
return std::nullopt; return std::nullopt;
} }
std::map<ObjectID, armem::clazz::ObjectClass>
ClassReader::getObjectClasses(const std::vector<ObjectID>& objectIDs)
{
armem::client::query::Builder builder;
auto& entities = builder.coreSegments()
.withName(properties().coreSegmentName)
.providerSegments()
.all()
.entities();
for (const ObjectID& objectID : objectIDs)
{
entities.withName(objectID.getClassID().str()).snapshots().latest();
}
const armem::client::QueryResult result = memoryReader().query(builder);
if (not result.success)
{
throw armem::error::QueryFailed(result.errorMessage);
}
std::map<ObjectID, armem::clazz::ObjectClass> objectClasses;
result.memory.forEachInstance(
[&objectClasses](const armem::wm::EntityInstance& instance) -> bool
{
const ObjectID classID = ObjectID::FromString(instance.id().entityName);
auto aron = instance.dataAs<armarx::armem::arondto::ObjectClass>();
armarx::armem::clazz::fromAron(aron, objectClasses[classID]);
return true;
});
return objectClasses;
}
std::string std::string
ClassReader::propertyPrefix() const ClassReader::propertyPrefix() const
{ {
......
...@@ -21,11 +21,10 @@ ...@@ -21,11 +21,10 @@
#pragma once #pragma once
#include <mutex> #include <map>
#include <optional> #include <optional>
#include <RobotAPI/libraries/armem/client/util/SimpleReaderBase.h> #include <RobotAPI/libraries/armem/client/util/SimpleReaderBase.h>
#include <RobotAPI/libraries/armem_objects/aron_conversions.h>
#include <RobotAPI/libraries/armem_objects/types.h> #include <RobotAPI/libraries/armem_objects/types.h>
namespace armarx::armem::obj::clazz namespace armarx::armem::obj::clazz
...@@ -38,11 +37,18 @@ namespace armarx::armem::obj::clazz ...@@ -38,11 +37,18 @@ namespace armarx::armem::obj::clazz
std::optional<armem::clazz::ObjectClass> getObjectClass(const std::string& providerName, std::optional<armem::clazz::ObjectClass> getObjectClass(const std::string& providerName,
const armarx::ObjectID& id); const armarx::ObjectID& id);
/**
* @brief Get object class information for object class IDs.
* @param objectIDs The object class IDs.
* @return The corresponding object classes.
* @throw armarx::armem::error::QueryFailed If the memory query failed.
*/
std::map<armarx::ObjectID, armem::clazz::ObjectClass>
getObjectClasses(const std::vector<armarx::ObjectID>& objectIDs);
protected: protected:
std::string propertyPrefix() const final; std::string propertyPrefix() const final;
Properties defaultProperties() const final; Properties defaultProperties() const final;
private:
}; };
......
#include "Segment.h" #include "Segment.h"
#include <RobotAPI/libraries/aron/core/Exception.h> #include <filesystem>
#include <RobotAPI/libraries/aron/common/aron_conversions.h>
#include <RobotAPI/libraries/ArmarXObjects/aron_conversions.h>
#include <RobotAPI/libraries/armem/server/MemoryToIceAdapter.h>
#include <RobotAPI/libraries/armem_objects/aron_conversions.h>
#include <RobotAPI/libraries/armem_objects/memory_ids.h>
#include <RobotAPI/libraries/armem_objects/aron/ObjectClass.aron.generated.h>
#include <ArmarXCore/core/application/properties/PropertyDefinitionContainer.h>
#include <ArmarXCore/core/time/TimeUtil.h>
#include <SimoxUtility/color/Color.h> #include <SimoxUtility/color/Color.h>
#include <SimoxUtility/math/pose/pose.h> #include <SimoxUtility/math/pose/pose.h>
#include <SimoxUtility/shapes/AxisAlignedBoundingBox.h> #include <SimoxUtility/shapes/AxisAlignedBoundingBox.h>
#include <SimoxUtility/shapes/OrientedBox.h> #include <SimoxUtility/shapes/OrientedBox.h>
#include <filesystem> #include <ArmarXCore/core/application/properties/PropertyDefinitionContainer.h>
#include <ArmarXCore/core/time/TimeUtil.h>
#include <RobotAPI/libraries/ArmarXObjects/aron_conversions.h>
#include <RobotAPI/libraries/armem/server/MemoryToIceAdapter.h>
#include <RobotAPI/libraries/armem_objects/aron/ObjectClass.aron.generated.h>
#include <RobotAPI/libraries/armem_objects/aron_conversions.h>
#include <RobotAPI/libraries/armem_objects/memory_ids.h>
#include <RobotAPI/libraries/aron/common/aron_conversions.h>
#include <RobotAPI/libraries/aron/core/Exception.h>
namespace armarx::armem::server::obj::clazz namespace armarx::armem::server::obj::clazz
{ {
Segment::Segment(armem::server::MemoryToIceAdapter& memoryToIceAdapter) : Segment::Segment(armem::server::MemoryToIceAdapter& memoryToIceAdapter) :
SpecializedCoreSegment(memoryToIceAdapter, objects::classSegmentID.coreSegmentName, arondto::ObjectClass::ToAronType(), -1) SpecializedCoreSegment(memoryToIceAdapter,
objects::classSegmentID.coreSegmentName,
arondto::ObjectClass::ToAronType(),
-1)
{ {
} }
Segment::~Segment() Segment::~Segment()
{ {
} }
void
void Segment::defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string& prefix) Segment::defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string& prefix)
{ {
SpecializedCoreSegment::defineProperties(defs, prefix); SpecializedCoreSegment::defineProperties(defs, prefix);
defs->optional(p.objectsPackage, prefix + "ObjectsPackage", "Name of the objects package to load from."); defs->optional(p.objectsPackage,
defs->optional(p.loadFromObjectsPackage, prefix + "LoadFromObjectsPackage", prefix + "ObjectsPackage",
"Name of the objects package to load from.");
defs->optional(p.loadFromObjectsPackage,
prefix + "LoadFromObjectsPackage",
"If true, load the objects from the objects package on startup."); "If true, load the objects from the objects package on startup.");
floorVis.defineProperties(defs, prefix + "Floor."); floorVis.defineProperties(defs, prefix + "Floor.");
} }
void
void Segment::init() Segment::init()
{ {
SpecializedCoreSegment::init(); SpecializedCoreSegment::init();
...@@ -55,8 +59,8 @@ namespace armarx::armem::server::obj::clazz ...@@ -55,8 +59,8 @@ namespace armarx::armem::server::obj::clazz
} }
} }
void
void Segment::connect(viz::Client arviz) Segment::connect(viz::Client arviz)
{ {
this->arviz = arviz; this->arviz = arviz;
...@@ -64,28 +68,29 @@ namespace armarx::armem::server::obj::clazz ...@@ -64,28 +68,29 @@ namespace armarx::armem::server::obj::clazz
floorVis.updateFloorObject(*segmentPtr); floorVis.updateFloorObject(*segmentPtr);
} }
void
void Segment::loadByObjectFinder(const std::string& objectsPackage) Segment::loadByObjectFinder(const std::string& objectsPackage)
{ {
loadByObjectFinder(ObjectFinder(objectsPackage)); loadByObjectFinder(ObjectFinder(objectsPackage));
} }
void
void Segment::loadByObjectFinder(const ObjectFinder& finder) Segment::loadByObjectFinder(const ObjectFinder& finder)
{ {
this->objectFinder = finder; this->objectFinder = finder;
loadByObjectFinder(); loadByObjectFinder();
} }
void
void Segment::loadByObjectFinder() Segment::loadByObjectFinder()
{ {
const Time now = Time::Now(); const Time now = Time::Now();
const bool checkPaths = false; const bool checkPaths = false;
std::vector<ObjectInfo> infos = objectFinder.findAllObjects(checkPaths); std::vector<ObjectInfo> infos = objectFinder.findAllObjects(checkPaths);
const MemoryID providerID = segmentPtr->id().withProviderSegmentName(objectFinder.getPackageName()); const MemoryID providerID =
segmentPtr->id().withProviderSegmentName(objectFinder.getPackageName());
ARMARX_INFO << "Loading up to " << infos.size() << " object classes from '" ARMARX_INFO << "Loading up to " << infos.size() << " object classes from '"
<< objectFinder.getPackageName() << "' ..."; << objectFinder.getPackageName() << "' ...";
Commit commit; Commit commit;
...@@ -98,18 +103,15 @@ namespace armarx::armem::server::obj::clazz ...@@ -98,18 +103,15 @@ namespace armarx::armem::server::obj::clazz
update.arrivedTime = update.referencedTime = update.sentTime = now; update.arrivedTime = update.referencedTime = update.sentTime = now;
arondto::ObjectClass objectClass = objectClassFromInfo(info); arondto::ObjectClass objectClass = objectClassFromInfo(info);
update.instancesData = update.instancesData = {objectClass.toAron()};
{
objectClass.toAron()
};
} }
ARMARX_INFO << "Loaded " << commit.updates.size() << " object classes from '" ARMARX_INFO << "Loaded " << commit.updates.size() << " object classes from '"
<< objectFinder.getPackageName() << "'."; << objectFinder.getPackageName() << "'.";
iceMemory.commitLocking(commit); iceMemory.commitLocking(commit);
} }
void
void Segment::visualizeClass(const MemoryID& entityID, bool showAABB, bool showOOBB) Segment::visualizeClass(const MemoryID& entityID, bool showAABB, bool showOOBB)
{ {
const Eigen::Matrix4f pose = Eigen::Matrix4f::Identity(); const Eigen::Matrix4f pose = Eigen::Matrix4f::Identity();
...@@ -124,10 +126,11 @@ namespace armarx::armem::server::obj::clazz ...@@ -124,10 +126,11 @@ namespace armarx::armem::server::obj::clazz
{ {
try try
{ {
std::optional<arondto::ObjectClass> aron = doLocked([this, &entityID]() std::optional<arondto::ObjectClass> aron = doLocked(
{ [this, &entityID]() {
return segmentPtr->findLatestInstanceDataAs<arondto::ObjectClass>(entityID, 0); return segmentPtr->findLatestInstanceDataAs<arondto::ObjectClass>(entityID,
}); 0);
});
if (not aron.has_value()) if (not aron.has_value())
{ {
return; return;
...@@ -136,23 +139,24 @@ namespace armarx::armem::server::obj::clazz ...@@ -136,23 +139,24 @@ namespace armarx::armem::server::obj::clazz
if (not aron->simoxXmlPath.package.empty()) if (not aron->simoxXmlPath.package.empty())
{ {
layerObject.add(viz::Object(entityID.str()) layerObject.add(viz::Object(entityID.str())
.file(aron->simoxXmlPath.package, aron->simoxXmlPath.path) .file(aron->simoxXmlPath.package, aron->simoxXmlPath.path)
.pose(pose)); .pose(pose));
} }
if (showAABB) if (showAABB)
{ {
layerAABB.add(viz::Box("AABB") layerAABB.add(viz::Box("AABB")
.pose(pose * simox::math::pose(aron->aabb.center)) .pose(pose * simox::math::pose(aron->aabb.center))
.size(aron->aabb.extents) .size(aron->aabb.extents)
.color(simox::Color::cyan(255, 64))); .color(simox::Color::cyan(255, 64)));
} }
if (showOOBB) if (showOOBB)
{ {
layerOOBB.add(viz::Box("OOBB") layerOOBB.add(viz::Box("OOBB")
.pose(pose * simox::math::pose(aron->oobb.center, aron->oobb.orientation)) .pose(pose * simox::math::pose(aron->oobb.center,
.size(aron->oobb.extents) aron->oobb.orientation))
.color(simox::Color::lime(255, 64))); .size(aron->oobb.extents)
.color(simox::Color::lime(255, 64)));
} }
} }
catch (const armem::error::ArMemError& e) catch (const armem::error::ArMemError& e)
...@@ -170,16 +174,16 @@ namespace armarx::armem::server::obj::clazz ...@@ -170,16 +174,16 @@ namespace armarx::armem::server::obj::clazz
arviz.commit({layerObject, layerOrigin, layerAABB, layerOOBB}); arviz.commit({layerObject, layerOrigin, layerAABB, layerOOBB});
} }
arondto::ObjectClass
arondto::ObjectClass Segment::objectClassFromInfo(const ObjectInfo& info) Segment::objectClassFromInfo(const ObjectInfo& info)
{ {
namespace fs = std::filesystem; namespace fs = std::filesystem;
arondto::ObjectClass data; arondto::ObjectClass data;
toAron(data.id, info.id()); toAron(data.id, info.id());
auto setPathIfExists = [](armarx::arondto::PackagePath & aron, auto setPathIfExists =
const PackageFileLocation & location) [](armarx::arondto::PackagePath& aron, const PackageFileLocation& location)
{ {
if (fs::is_regular_file(location.absolutePath)) if (fs::is_regular_file(location.absolutePath))
{ {
...@@ -206,18 +210,18 @@ namespace armarx::armem::server::obj::clazz ...@@ -206,18 +210,18 @@ namespace armarx::armem::server::obj::clazz
if (auto recogNames = info.loadRecognizedNames()) if (auto recogNames = info.loadRecognizedNames())
{ {
data.names.recognizedNames = recogNames.value(); data.names.recognized = recogNames.value();
} }
if (auto spokenNames = info.loadSpokenNames()) if (auto spokenNames = info.loadSpokenNames())
{ {
data.names.spokenNames = spokenNames.value(); data.names.spoken = spokenNames.value();
} }
return data; return data;
} }
void
void Segment::RemoteGui::setup(const Segment& segment) Segment::RemoteGui::setup(const Segment& segment)
{ {
using namespace armarx::RemoteGui::Client; using namespace armarx::RemoteGui::Client;
...@@ -232,15 +236,15 @@ namespace armarx::armem::server::obj::clazz ...@@ -232,15 +236,15 @@ namespace armarx::armem::server::obj::clazz
group.addChildren({layout, VSpacer()}); group.addChildren({layout, VSpacer()});
} }
void
void Segment::RemoteGui::update(Segment& segment) Segment::RemoteGui::update(Segment& segment)
{ {
data.update(segment); data.update(segment);
visu.update(segment); visu.update(segment);
} }
void
void Segment::RemoteGui::Data::setup(const Segment& segment) Segment::RemoteGui::Data::setup(const Segment& segment)
{ {
using namespace armarx::RemoteGui::Client; using namespace armarx::RemoteGui::Client;
...@@ -264,8 +268,8 @@ namespace armarx::armem::server::obj::clazz ...@@ -264,8 +268,8 @@ namespace armarx::armem::server::obj::clazz
group.addChild(grid); group.addChild(grid);
} }
void
void Segment::RemoteGui::Data::update(Segment& segment) Segment::RemoteGui::Data::update(Segment& segment)
{ {
if (reloadButton.wasClicked()) if (reloadButton.wasClicked())
{ {
...@@ -275,31 +279,35 @@ namespace armarx::armem::server::obj::clazz ...@@ -275,31 +279,35 @@ namespace armarx::armem::server::obj::clazz
} }
if (infiniteHistory.hasValueChanged() || maxHistorySize.hasValueChanged()) if (infiniteHistory.hasValueChanged() || maxHistorySize.hasValueChanged())
{ {
segment.doLocked([this, &segment]() segment.doLocked(
{ [this, &segment]()
segment.properties.maxHistorySize = infiniteHistory.getValue() ? -1 : maxHistorySize.getValue();
if (segment.segmentPtr)
{ {
segment.segmentPtr->setMaxHistorySize(long(segment.properties.maxHistorySize)); segment.properties.maxHistorySize =
} infiniteHistory.getValue() ? -1 : maxHistorySize.getValue();
}); if (segment.segmentPtr)
{
segment.segmentPtr->setMaxHistorySize(
long(segment.properties.maxHistorySize));
}
});
} }
} }
void
void Segment::RemoteGui::Visu::setup(const Segment& segment) Segment::RemoteGui::Visu::setup(const Segment& segment)
{ {
using namespace armarx::RemoteGui::Client; using namespace armarx::RemoteGui::Client;
showComboBox = {}; showComboBox = {};
showOptionsIndex.clear(); showOptionsIndex.clear();
segment.segmentPtr->forEachEntity([this](const wm::Entity & entity) segment.segmentPtr->forEachEntity(
{ [this](const wm::Entity& entity)
std::stringstream option; {
option << entity.id().entityName << " (" << entity.id().providerSegmentName << ")"; std::stringstream option;
showComboBox.addOption(option.str()); option << entity.id().entityName << " (" << entity.id().providerSegmentName << ")";
showOptionsIndex.push_back(entity.id()); showComboBox.addOption(option.str());
}); showOptionsIndex.push_back(entity.id());
});
if (showOptionsIndex.empty()) if (showOptionsIndex.empty())
{ {
showComboBox.addOption("<none>"); showComboBox.addOption("<none>");
...@@ -318,8 +326,8 @@ namespace armarx::armem::server::obj::clazz ...@@ -318,8 +326,8 @@ namespace armarx::armem::server::obj::clazz
group.addChild(grid); group.addChild(grid);
} }
void
void Segment::RemoteGui::Visu::update(Segment& segment) Segment::RemoteGui::Visu::update(Segment& segment)
{ {
if (showButton.wasClicked()) if (showButton.wasClicked())
{ {
...@@ -331,4 +339,4 @@ namespace armarx::armem::server::obj::clazz ...@@ -331,4 +339,4 @@ namespace armarx::armem::server::obj::clazz
} }
} }
} } // namespace armarx::armem::server::obj::clazz
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <RobotAPI/libraries/armem/core/Time.h> #include <RobotAPI/libraries/armem/core/Time.h>
#include <RobotAPI/libraries/armem_robot/types.h> #include <RobotAPI/libraries/armem_robot/types.h>
#include <RobotAPI/libraries/core/FramedPose.h> #include <RobotAPI/libraries/core/FramedPose.h>
#include <RobotAPI/libraries/core/Names.h>
#include "aron_forward_declarations.h" #include "aron_forward_declarations.h"
...@@ -67,7 +68,7 @@ namespace armarx::armem::clazz ...@@ -67,7 +68,7 @@ namespace armarx::armem::clazz
armarx::PackagePath meshObjPath; armarx::PackagePath meshObjPath;
simox::AxisAlignedBoundingBox aabb; simox::AxisAlignedBoundingBox aabb;
simox::OrientedBoxf oobb; simox::OrientedBoxf oobb;
// TODO NAMES armarx::Names names;
std::vector<Feature> ivtFeatures; std::vector<Feature> ivtFeatures;
}; };
} // namespace armarx::armem::clazz } // namespace armarx::armem::clazz
......
...@@ -261,7 +261,8 @@ namespace armarx::aron::data ...@@ -261,7 +261,8 @@ namespace armarx::aron::data
const auto& p = data->getPath(); const auto& p = data->getPath();
if (not p.hasDirectPrefix(this->getPath())) if (not p.hasDirectPrefix(this->getPath()))
{ {
ARMARX_DEBUG << "An element added to a dict does not have a correct path set. This " ARMARX_DEBUG << deactivateSpam(5)
<< "An element added to a dict does not have a correct path set. This "
"may cause errors. Please use setElemetCopy() instead."; "may cause errors. Please use setElemetCopy() instead.";
} }
} }
......
...@@ -371,6 +371,7 @@ namespace armarx ...@@ -371,6 +371,7 @@ namespace armarx
.executionId = skills::SkillExecutionID::FromIce(update.executionId, providerId), .executionId = skills::SkillExecutionID::FromIce(update.executionId, providerId),
.parameters = armarx::aron::data::Dict::FromAronDictDTO(update.parameters), .parameters = armarx::aron::data::Dict::FromAronDictDTO(update.parameters),
.callbackInterface = update.callbackInterface, .callbackInterface = update.callbackInterface,
.result = armarx::aron::data::Dict::FromAronDictDTO(update.result)
}}; }};
skills::fromIce(update.status, ret.status); skills::fromIce(update.status, ret.status);
setResultFromIce(ret, update); setResultFromIce(ret, update);
......
...@@ -46,6 +46,8 @@ armarx_add_library( ...@@ -46,6 +46,8 @@ armarx_add_library(
detail/SkillImplementationWrapper.h detail/SkillImplementationWrapper.h
SkillContext.h SkillContext.h
blueprints/SkillWithContextBlueprint.h
mixins/All.h mixins/All.h
mixins/ArvizSkillMixin.h mixins/ArvizSkillMixin.h
......
...@@ -210,7 +210,7 @@ namespace armarx::plugins ...@@ -210,7 +210,7 @@ namespace armarx::plugins
auto it = auto it =
skillExecutions.emplace(std::piecewise_construct, skillExecutions.emplace(std::piecewise_construct,
std::make_tuple(executionId), std::make_tuple(executionId),
std::make_tuple(*fac, std::make_tuple(fac,
executionId, executionId,
executionRequest.parameters, executionRequest.parameters,
executionRequest.callbackInterface)); executionRequest.callbackInterface));
...@@ -265,7 +265,7 @@ namespace armarx::plugins ...@@ -265,7 +265,7 @@ namespace armarx::plugins
auto it = auto it =
skillExecutions.emplace(std::piecewise_construct, skillExecutions.emplace(std::piecewise_construct,
std::make_tuple(executionId), std::make_tuple(executionId),
std::make_tuple(*fac, std::make_tuple(fac,
executionId, executionId,
executionRequest.parameters, executionRequest.parameters,
executionRequest.callbackInterface)); executionRequest.callbackInterface));
......
...@@ -72,7 +72,7 @@ namespace armarx::plugins ...@@ -72,7 +72,7 @@ namespace armarx::plugins
{ {
auto fac = std::make_unique<FactoryT>(std::forward<Args>(args)...); auto fac = std::make_unique<FactoryT>(std::forward<Args>(args)...);
auto* facPtr = fac.get(); auto* facPtr = fac.get();
addCustomSkillFactory(std::move(fac)); addSkillFactory(std::move(fac));
return static_cast<FactoryT*>(facPtr); return static_cast<FactoryT*>(facPtr);
} }
...@@ -189,7 +189,7 @@ namespace armarx ...@@ -189,7 +189,7 @@ namespace armarx
requires skills::isSkillBlueprint<FacT> FacT* requires skills::isSkillBlueprint<FacT> FacT*
addCustomSkillFactory(Args&&... args) addCustomSkillFactory(Args&&... args)
{ {
return plugin->addSkillFactory<FacT>(std::forward<Args>(args)...); return plugin->addCustomSkillFactory<FacT>(std::forward<Args>(args)...);
} }
private: private:
......
/*
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* ArmarX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package RobotAPI
* @author Christoph Pohl ( christoph dot pohl at kit dot edu )
* @date 05.12.23
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#pragma once
#include <RobotAPI/libraries/skills/provider/SkillFactory.h>
namespace armarx
{
namespace skills
{
// template <typename T>
// concept takesContext = requires(typename T::Context cntxt) {
// { T::connectTo(cntxt) } -> void;
// };
template <typename SkillT>
class SkillWithContextBlueprint : public SkillBlueprint
{
public:
using ContextT = typename SkillT::Context;
template <typename... Args>
SkillWithContextBlueprint(Args&&... args) :
SkillBlueprint(*SkillBlueprint::ForSkill<SkillT>(std::forward<Args>(args)...))
{
}
virtual std::unique_ptr<Skill>
createSkill(const ProviderID& pid) const override
{
if (not isConnected_)
{
return nullptr;
}
auto s = _createSkill();
s->setProviderId(pid);
static_cast<SkillT*>(s.get())->connectTo(context_);
return s;
}
virtual SkillDescription
createSkillDescription(const skills::ProviderID& pid) const
{
auto s = _createSkill();
s->setProviderId(pid);
return s->getSkillDescription();
}
void
connectTo(const ContextT& context)
{
context_ = context;
isConnected_ = true;
}
private:
std::atomic_bool isConnected_ = false;
ContextT context_;
};
} // namespace skills
} // namespace armarx
\ No newline at end of file
...@@ -5,7 +5,7 @@ namespace armarx ...@@ -5,7 +5,7 @@ namespace armarx
namespace skills::detail namespace skills::detail
{ {
SkillRuntime::SkillRuntime( SkillRuntime::SkillRuntime(
const skills::SkillBlueprint& fac, const skills::SkillBlueprint* fac,
const skills::SkillExecutionID& execId, const skills::SkillExecutionID& execId,
const aron::data::DictPtr& initial_parameters, const aron::data::DictPtr& initial_parameters,
const skills::callback::dti::SkillProviderCallbackInterfacePrx& callbackInterface) : const skills::callback::dti::SkillProviderCallbackInterfacePrx& callbackInterface) :
...@@ -120,7 +120,8 @@ namespace armarx ...@@ -120,7 +120,8 @@ namespace armarx
ARMARX_INFO_S << "Construct skill: " << skillName; ARMARX_INFO_S << "Construct skill: " << skillName;
updateStatus(SkillStatus::Constructing); updateStatus(SkillStatus::Constructing);
this->skill = this->factory.createSkill(providerId); ARMARX_CHECK_NOT_NULL(factory) << "Skill Factory is a nullptr";
this->skill = this->factory->createSkill(providerId);
this->skill->setExecutorName(executorName); this->skill->setExecutorName(executorName);
this->skill->setManager(manager); this->skill->setManager(manager);
this->skill->setCallback([&](const SkillStatus s, const armarx::aron::data::DictPtr& d) this->skill->setCallback([&](const SkillStatus s, const armarx::aron::data::DictPtr& d)
...@@ -242,6 +243,7 @@ namespace armarx ...@@ -242,6 +243,7 @@ namespace armarx
{ {
std::string message = "SkillError 201: The prepare method of skill '" + std::string message = "SkillError 201: The prepare method of skill '" +
skillName + "' did not succeed."; skillName + "' did not succeed.";
ARMARX_ERROR_S << message;
return exitAndMakeFailedResult(message); return exitAndMakeFailedResult(message);
} }
} }
...@@ -340,7 +342,7 @@ namespace armarx ...@@ -340,7 +342,7 @@ namespace armarx
// Exit succeeded! // Exit succeeded!
// All succeeded! // All succeeded!
{ {
updateStatus(SkillStatus::Succeeded); updateStatus(SkillStatus::Succeeded, mainRet.data);
// return result of main method // return result of main method
std::unique_lock l(skillStatusesMutex); std::unique_lock l(skillStatusesMutex);
......
#pragma once #pragma once
#include <experimental/memory>
#include <shared_mutex> #include <shared_mutex>
#include <RobotAPI/interface/skills/SkillManagerInterface.h> #include <RobotAPI/interface/skills/SkillManagerInterface.h>
...@@ -18,7 +19,7 @@ namespace armarx ...@@ -18,7 +19,7 @@ namespace armarx
class SkillRuntime class SkillRuntime
{ {
private: private:
const skills::SkillBlueprint factory; const std::experimental::observer_ptr<const skills::SkillBlueprint> factory;
std::unique_ptr<Skill> skill; std::unique_ptr<Skill> skill;
mutable std::mutex executionMutex; mutable std::mutex executionMutex;
...@@ -33,7 +34,7 @@ namespace armarx ...@@ -33,7 +34,7 @@ namespace armarx
std::thread execution; std::thread execution;
// ctor // ctor
SkillRuntime(const skills::SkillBlueprint& fac, SkillRuntime(const skills::SkillBlueprint* fac,
const skills::SkillExecutionID&, const skills::SkillExecutionID&,
const aron::data::DictPtr&, const aron::data::DictPtr&,
const skills::callback::dti::SkillProviderCallbackInterfacePrx&); const skills::callback::dti::SkillProviderCallbackInterfacePrx&);
......