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.
......
......@@ -1353,8 +1353,8 @@ namespace armarx
auto it = reportedJointStatuses.find(rn[i]->getName());
if (it == reportedJointStatuses.end())
{
ARMARX_WARNING << deactivateSpam(5, rn[i]->getName()) << "Joint Status for " << rn[i]->getName()
<< " was not reported!";
ARMARX_VERBOSE << deactivateSpam(5, rn[i]->getName()) << "Joint Status for "
<< rn[i]->getName() << " was not reported!";
continue;
}
JointStatus currentStatus = it->second;
......
......@@ -82,7 +82,6 @@ armarx_enable_aron_file_generation_for_target(
"${LIB_NAME}"
ARON_FILES
aron/ObjectID.xml
aron/ObjectNames.xml
aron/ObjectPose.xml
aron/ObjectType.xml
aron/PoseManifoldGaussian.xml
......
......@@ -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/PackagePath.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" />
</AronIncludes>
<GenerateTypes>
......@@ -83,7 +83,7 @@ Core segment type of Object/Class.
</ObjectChild>
<ObjectChild key="names">
<armarx::arondto::ObjectNames />
<armarx::arondto::Names />
</ObjectChild>
<ObjectChild key="ivtFeatures">
......
......@@ -4,50 +4,53 @@
#include <RobotAPI/libraries/armem/core/aron_conversions.h>
#include <RobotAPI/libraries/aron/common/aron_conversions.h>
namespace armarx::armem
namespace armarx
{
void
fromAron(const arondto::ObjectInstance& dto, objpose::arondto::ObjectPose& bo)
armem::fromAron(const arondto::ObjectInstance& dto, objpose::arondto::ObjectPose& bo)
{
bo = dto.pose;
}
void
toAron(arondto::ObjectInstance& dto, const objpose::arondto::ObjectPose& bo)
armem::toAron(arondto::ObjectInstance& dto, const objpose::arondto::ObjectPose& bo)
{
dto.pose = bo;
}
void
fromAron(const arondto::ObjectInstance& dto, objpose::ObjectPose& bo)
armem::fromAron(const arondto::ObjectInstance& dto, objpose::ObjectPose& bo)
{
objpose::fromAron(dto.pose, bo);
}
void
toAron(arondto::ObjectInstance& dto, const objpose::ObjectPose& bo)
armem::toAron(arondto::ObjectInstance& dto, const objpose::ObjectPose& bo)
{
objpose::toAron(dto.pose, bo);
}
/* Attachments */
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);
aron::fromAron(dto.frame, bo.frame);
}
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);
aron::toAron(dto.frame, bo.frame);
}
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);
aron::fromAron(dto.transformation, bo.transformation);
......@@ -57,7 +60,8 @@ namespace armarx::armem
}
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);
aron::toAron(dto.transformation, bo.transformation);
......@@ -67,8 +71,8 @@ namespace armarx::armem
}
void
fromAron(const arondto::attachment::ArticulatedObjectAttachment& dto,
attachment::ArticulatedObjectAttachment& bo)
armem::fromAron(const arondto::attachment::ArticulatedObjectAttachment& dto,
attachment::ArticulatedObjectAttachment& bo)
{
fromAron(dto.agent, bo.agent);
aron::fromAron(dto.transformation, bo.transformation);
......@@ -78,8 +82,8 @@ namespace armarx::armem
}
void
toAron(arondto::attachment::ArticulatedObjectAttachment& dto,
const attachment::ArticulatedObjectAttachment& bo)
armem::toAron(arondto::attachment::ArticulatedObjectAttachment& dto,
const attachment::ArticulatedObjectAttachment& bo)
{
toAron(dto.agent, bo.agent);
aron::toAron(dto.transformation, bo.transformation);
......@@ -89,7 +93,7 @@ namespace armarx::armem
}
void
toAron(arondto::Marker& dto, const marker::Marker& bo)
armem::toAron(arondto::Marker& dto, const marker::Marker& bo)
{
dto.name = bo.name;
armarx::toAron(dto.robotGlobal, bo.robotGlobal);
......@@ -100,7 +104,7 @@ namespace armarx::armem
}
void
fromAron(const arondto::Marker& dto, marker::Marker& bo)
armem::fromAron(const arondto::Marker& dto, marker::Marker& bo)
{
bo.name = dto.name;
armarx::fromAron(dto.robotGlobal, bo.robotGlobal);
......@@ -109,13 +113,13 @@ namespace armarx::armem
armarx::fromAron(dto.markerPose, bo.markerPose);
}
} // namespace armarx::armem
} // namespace armarx
namespace armarx::armem::clazz
namespace armarx::armem
{
void
fromAron(const arondto::Feature& dto, Feature& bo)
clazz::fromAron(const arondto::Feature& dto, Feature& bo)
{
bo.angle = dto.angle;
bo.scale = dto.scale;
......@@ -125,7 +129,7 @@ namespace armarx::armem::clazz
}
void
toAron(arondto::Feature& dto, const Feature& bo)
clazz::toAron(arondto::Feature& dto, const Feature& bo)
{
dto.angle = bo.angle;
dto.scale = bo.scale;
......@@ -135,7 +139,7 @@ namespace armarx::armem::clazz
}
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.simoxXmlPath, bo.simoxXmlPath);
......@@ -147,6 +151,7 @@ namespace armarx::armem::clazz
armarx::fromAron(dto.meshObjPath, bo.meshObjPath);
armarx::fromAron(dto.aabb, bo.aabb);
armarx::fromAron(dto.oobb, bo.oobb);
fromAron(dto.names, bo.names);
bo.ivtFeatures.clear();
for (const auto& i : dto.ivtFeatures)
{
......@@ -155,7 +160,7 @@ namespace armarx::armem::clazz
}
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.simoxXmlPath, bo.simoxXmlPath);
......@@ -167,6 +172,7 @@ namespace armarx::armem::clazz
armarx::toAron(dto.meshObjPath, bo.meshObjPath);
armarx::toAron(dto.aabb, bo.aabb);
armarx::toAron(dto.oobb, bo.oobb);
toAron(dto.names, bo.names);
dto.ivtFeatures.clear();
for (const auto& i : bo.ivtFeatures)
{
......@@ -174,7 +180,7 @@ namespace armarx::armem::clazz
}
}
} // namespace armarx::armem::clazz
} // namespace armarx::armem
armarx::armem::MemoryID
armarx::armem::obj::makeObjectInstanceMemoryID(const objpose::ObjectPose& objectPose)
......
#pragma once
#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/Marker.aron.generated.h>
#include <RobotAPI/libraries/armem_objects/aron/ObjectClass.aron.generated.h>
......@@ -32,6 +33,7 @@ namespace armarx::armem
void fromAron(const arondto::Marker& dto, marker::Marker& bo);
void toAron(arondto::Marker& dto, const marker::Marker& bo);
} // namespace armarx::armem
namespace armarx::armem::clazz
......@@ -44,10 +46,9 @@ namespace armarx::armem::clazz
} // namespace armarx::armem::clazz
#include <RobotAPI/libraries/armem/core/MemoryID.h>
namespace armarx::armem::obj
{
/// Make a Memory ID for the object instance snapshot representing this pose.
MemoryID makeObjectInstanceMemoryID(const objpose::ObjectPose& objectPose);
} // namespace armarx::armem::obj
#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
{
std::optional<armem::clazz::ObjectClass>
......@@ -27,6 +31,42 @@ namespace armarx::armem::obj::clazz
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
ClassReader::propertyPrefix() const
{
......
......@@ -21,11 +21,10 @@
#pragma once
#include <mutex>
#include <map>
#include <optional>
#include <RobotAPI/libraries/armem/client/util/SimpleReaderBase.h>
#include <RobotAPI/libraries/armem_objects/aron_conversions.h>
#include <RobotAPI/libraries/armem_objects/types.h>
namespace armarx::armem::obj::clazz
......@@ -38,11 +37,18 @@ namespace armarx::armem::obj::clazz
std::optional<armem::clazz::ObjectClass> getObjectClass(const std::string& providerName,
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:
std::string propertyPrefix() const final;
Properties defaultProperties() const final;
private:
};
......
#include "Segment.h"
#include <RobotAPI/libraries/aron/core/Exception.h>
#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 <filesystem>
#include <SimoxUtility/color/Color.h>
#include <SimoxUtility/math/pose/pose.h>
#include <SimoxUtility/shapes/AxisAlignedBoundingBox.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
{
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()
{
}
void Segment::defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string& prefix)
void
Segment::defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string& prefix)
{
SpecializedCoreSegment::defineProperties(defs, prefix);
defs->optional(p.objectsPackage, prefix + "ObjectsPackage", "Name of the objects package to load from.");
defs->optional(p.loadFromObjectsPackage, prefix + "LoadFromObjectsPackage",
defs->optional(p.objectsPackage,
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.");
floorVis.defineProperties(defs, prefix + "Floor.");
}
void Segment::init()
void
Segment::init()
{
SpecializedCoreSegment::init();
......@@ -55,8 +59,8 @@ namespace armarx::armem::server::obj::clazz
}
}
void Segment::connect(viz::Client arviz)
void
Segment::connect(viz::Client arviz)
{
this->arviz = arviz;
......@@ -64,28 +68,29 @@ namespace armarx::armem::server::obj::clazz
floorVis.updateFloorObject(*segmentPtr);
}
void Segment::loadByObjectFinder(const std::string& objectsPackage)
void
Segment::loadByObjectFinder(const std::string& objectsPackage)
{
loadByObjectFinder(ObjectFinder(objectsPackage));
}
void Segment::loadByObjectFinder(const ObjectFinder& finder)
void
Segment::loadByObjectFinder(const ObjectFinder& finder)
{
this->objectFinder = finder;
loadByObjectFinder();
}
void Segment::loadByObjectFinder()
void
Segment::loadByObjectFinder()
{
const Time now = Time::Now();
const bool checkPaths = false;
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 '"
<< objectFinder.getPackageName() << "' ...";
Commit commit;
......@@ -98,18 +103,15 @@ namespace armarx::armem::server::obj::clazz
update.arrivedTime = update.referencedTime = update.sentTime = now;
arondto::ObjectClass objectClass = objectClassFromInfo(info);
update.instancesData =
{
objectClass.toAron()
};
update.instancesData = {objectClass.toAron()};
}
ARMARX_INFO << "Loaded " << commit.updates.size() << " object classes from '"
<< objectFinder.getPackageName() << "'.";
iceMemory.commitLocking(commit);
}
void Segment::visualizeClass(const MemoryID& entityID, bool showAABB, bool showOOBB)
void
Segment::visualizeClass(const MemoryID& entityID, bool showAABB, bool showOOBB)
{
const Eigen::Matrix4f pose = Eigen::Matrix4f::Identity();
......@@ -124,10 +126,11 @@ namespace armarx::armem::server::obj::clazz
{
try
{
std::optional<arondto::ObjectClass> aron = doLocked([this, &entityID]()
{
return segmentPtr->findLatestInstanceDataAs<arondto::ObjectClass>(entityID, 0);
});
std::optional<arondto::ObjectClass> aron = doLocked(
[this, &entityID]() {
return segmentPtr->findLatestInstanceDataAs<arondto::ObjectClass>(entityID,
0);
});
if (not aron.has_value())
{
return;
......@@ -136,23 +139,24 @@ namespace armarx::armem::server::obj::clazz
if (not aron->simoxXmlPath.package.empty())
{
layerObject.add(viz::Object(entityID.str())
.file(aron->simoxXmlPath.package, aron->simoxXmlPath.path)
.pose(pose));
.file(aron->simoxXmlPath.package, aron->simoxXmlPath.path)
.pose(pose));
}
if (showAABB)
{
layerAABB.add(viz::Box("AABB")
.pose(pose * simox::math::pose(aron->aabb.center))
.size(aron->aabb.extents)
.color(simox::Color::cyan(255, 64)));
.pose(pose * simox::math::pose(aron->aabb.center))
.size(aron->aabb.extents)
.color(simox::Color::cyan(255, 64)));
}
if (showOOBB)
{
layerOOBB.add(viz::Box("OOBB")
.pose(pose * simox::math::pose(aron->oobb.center, aron->oobb.orientation))
.size(aron->oobb.extents)
.color(simox::Color::lime(255, 64)));
.pose(pose * simox::math::pose(aron->oobb.center,
aron->oobb.orientation))
.size(aron->oobb.extents)
.color(simox::Color::lime(255, 64)));
}
}
catch (const armem::error::ArMemError& e)
......@@ -170,16 +174,16 @@ namespace armarx::armem::server::obj::clazz
arviz.commit({layerObject, layerOrigin, layerAABB, layerOOBB});
}
arondto::ObjectClass Segment::objectClassFromInfo(const ObjectInfo& info)
arondto::ObjectClass
Segment::objectClassFromInfo(const ObjectInfo& info)
{
namespace fs = std::filesystem;
arondto::ObjectClass data;
toAron(data.id, info.id());
auto setPathIfExists = [](armarx::arondto::PackagePath & aron,
const PackageFileLocation & location)
auto setPathIfExists =
[](armarx::arondto::PackagePath& aron, const PackageFileLocation& location)
{
if (fs::is_regular_file(location.absolutePath))
{
......@@ -206,18 +210,18 @@ namespace armarx::armem::server::obj::clazz
if (auto recogNames = info.loadRecognizedNames())
{
data.names.recognizedNames = recogNames.value();
data.names.recognized = recogNames.value();
}
if (auto spokenNames = info.loadSpokenNames())
{
data.names.spokenNames = spokenNames.value();
data.names.spoken = spokenNames.value();
}
return data;
}
void Segment::RemoteGui::setup(const Segment& segment)
void
Segment::RemoteGui::setup(const Segment& segment)
{
using namespace armarx::RemoteGui::Client;
......@@ -232,15 +236,15 @@ namespace armarx::armem::server::obj::clazz
group.addChildren({layout, VSpacer()});
}
void Segment::RemoteGui::update(Segment& segment)
void
Segment::RemoteGui::update(Segment& segment)
{
data.update(segment);
visu.update(segment);
}
void Segment::RemoteGui::Data::setup(const Segment& segment)
void
Segment::RemoteGui::Data::setup(const Segment& segment)
{
using namespace armarx::RemoteGui::Client;
......@@ -264,8 +268,8 @@ namespace armarx::armem::server::obj::clazz
group.addChild(grid);
}
void Segment::RemoteGui::Data::update(Segment& segment)
void
Segment::RemoteGui::Data::update(Segment& segment)
{
if (reloadButton.wasClicked())
{
......@@ -275,31 +279,35 @@ namespace armarx::armem::server::obj::clazz
}
if (infiniteHistory.hasValueChanged() || maxHistorySize.hasValueChanged())
{
segment.doLocked([this, &segment]()
{
segment.properties.maxHistorySize = infiniteHistory.getValue() ? -1 : maxHistorySize.getValue();
if (segment.segmentPtr)
segment.doLocked(
[this, &segment]()
{
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 Segment::RemoteGui::Visu::setup(const Segment& segment)
void
Segment::RemoteGui::Visu::setup(const Segment& segment)
{
using namespace armarx::RemoteGui::Client;
showComboBox = {};
showOptionsIndex.clear();
segment.segmentPtr->forEachEntity([this](const wm::Entity & entity)
{
std::stringstream option;
option << entity.id().entityName << " (" << entity.id().providerSegmentName << ")";
showComboBox.addOption(option.str());
showOptionsIndex.push_back(entity.id());
});
segment.segmentPtr->forEachEntity(
[this](const wm::Entity& entity)
{
std::stringstream option;
option << entity.id().entityName << " (" << entity.id().providerSegmentName << ")";
showComboBox.addOption(option.str());
showOptionsIndex.push_back(entity.id());
});
if (showOptionsIndex.empty())
{
showComboBox.addOption("<none>");
......@@ -318,8 +326,8 @@ namespace armarx::armem::server::obj::clazz
group.addChild(grid);
}
void Segment::RemoteGui::Visu::update(Segment& segment)
void
Segment::RemoteGui::Visu::update(Segment& segment)
{
if (showButton.wasClicked())
{
......@@ -331,4 +339,4 @@ namespace armarx::armem::server::obj::clazz
}
}
}
} // namespace armarx::armem::server::obj::clazz
......@@ -30,6 +30,7 @@
#include <RobotAPI/libraries/armem/core/Time.h>
#include <RobotAPI/libraries/armem_robot/types.h>
#include <RobotAPI/libraries/core/FramedPose.h>
#include <RobotAPI/libraries/core/Names.h>
#include "aron_forward_declarations.h"
......@@ -67,7 +68,7 @@ namespace armarx::armem::clazz
armarx::PackagePath meshObjPath;
simox::AxisAlignedBoundingBox aabb;
simox::OrientedBoxf oobb;
// TODO NAMES
armarx::Names names;
std::vector<Feature> ivtFeatures;
};
} // namespace armarx::armem::clazz
......
......@@ -261,7 +261,8 @@ namespace armarx::aron::data
const auto& p = data->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.";
}
}
......
......@@ -371,6 +371,7 @@ namespace armarx
.executionId = skills::SkillExecutionID::FromIce(update.executionId, providerId),
.parameters = armarx::aron::data::Dict::FromAronDictDTO(update.parameters),
.callbackInterface = update.callbackInterface,
.result = armarx::aron::data::Dict::FromAronDictDTO(update.result)
}};
skills::fromIce(update.status, ret.status);
setResultFromIce(ret, update);
......
......@@ -46,6 +46,8 @@ armarx_add_library(
detail/SkillImplementationWrapper.h
SkillContext.h
blueprints/SkillWithContextBlueprint.h
mixins/All.h
mixins/ArvizSkillMixin.h
......
......@@ -210,7 +210,7 @@ namespace armarx::plugins
auto it =
skillExecutions.emplace(std::piecewise_construct,
std::make_tuple(executionId),
std::make_tuple(*fac,
std::make_tuple(fac,
executionId,
executionRequest.parameters,
executionRequest.callbackInterface));
......@@ -265,7 +265,7 @@ namespace armarx::plugins
auto it =
skillExecutions.emplace(std::piecewise_construct,
std::make_tuple(executionId),
std::make_tuple(*fac,
std::make_tuple(fac,
executionId,
executionRequest.parameters,
executionRequest.callbackInterface));
......
......@@ -72,7 +72,7 @@ namespace armarx::plugins
{
auto fac = std::make_unique<FactoryT>(std::forward<Args>(args)...);
auto* facPtr = fac.get();
addCustomSkillFactory(std::move(fac));
addSkillFactory(std::move(fac));
return static_cast<FactoryT*>(facPtr);
}
......@@ -189,7 +189,7 @@ namespace armarx
requires skills::isSkillBlueprint<FacT> FacT*
addCustomSkillFactory(Args&&... args)
{
return plugin->addSkillFactory<FacT>(std::forward<Args>(args)...);
return plugin->addCustomSkillFactory<FacT>(std::forward<Args>(args)...);
}
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
namespace skills::detail
{
SkillRuntime::SkillRuntime(
const skills::SkillBlueprint& fac,
const skills::SkillBlueprint* fac,
const skills::SkillExecutionID& execId,
const aron::data::DictPtr& initial_parameters,
const skills::callback::dti::SkillProviderCallbackInterfacePrx& callbackInterface) :
......@@ -120,7 +120,8 @@ namespace armarx
ARMARX_INFO_S << "Construct skill: " << skillName;
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->setManager(manager);
this->skill->setCallback([&](const SkillStatus s, const armarx::aron::data::DictPtr& d)
......@@ -242,6 +243,7 @@ namespace armarx
{
std::string message = "SkillError 201: The prepare method of skill '" +
skillName + "' did not succeed.";
ARMARX_ERROR_S << message;
return exitAndMakeFailedResult(message);
}
}
......@@ -340,7 +342,7 @@ namespace armarx
// Exit succeeded!
// All succeeded!
{
updateStatus(SkillStatus::Succeeded);
updateStatus(SkillStatus::Succeeded, mainRet.data);
// return result of main method
std::unique_lock l(skillStatusesMutex);
......
#pragma once
#include <experimental/memory>
#include <shared_mutex>
#include <RobotAPI/interface/skills/SkillManagerInterface.h>
......@@ -18,7 +19,7 @@ namespace armarx
class SkillRuntime
{
private:
const skills::SkillBlueprint factory;
const std::experimental::observer_ptr<const skills::SkillBlueprint> factory;
std::unique_ptr<Skill> skill;
mutable std::mutex executionMutex;
......@@ -33,7 +34,7 @@ namespace armarx
std::thread execution;
// ctor
SkillRuntime(const skills::SkillBlueprint& fac,
SkillRuntime(const skills::SkillBlueprint* fac,
const skills::SkillExecutionID&,
const aron::data::DictPtr&,
const skills::callback::dti::SkillProviderCallbackInterfacePrx&);
......