Skip to content
Snippets Groups Projects
Commit 735268e6 authored by Fabian Tërnava's avatar Fabian Tërnava
Browse files

added ObjectInstance BO class

parent 9201e171
No related branches found
No related tags found
1 merge request!321Merge of all branches of Fabian PK (related to skills)
...@@ -8,6 +8,22 @@ namespace armarx::armem ...@@ -8,6 +8,22 @@ namespace armarx::armem
{ {
void void
fromAron(const arondto::ObjectInstance& dto, ObjectInstance& bo)
{
fromAron(dto.pose, bo.pose);
fromAron(dto.classID, bo.classID);
fromAron(dto.sourceID, bo.sourceID);
}
void
toAron(arondto::ObjectInstance& dto, const ObjectInstance& bo)
{
toAron(dto.pose, bo.pose);
toAron(dto.classID, bo.classID);
toAron(dto.sourceID, bo.sourceID);
}
/*void
fromAron(const arondto::ObjectInstance& dto, objpose::arondto::ObjectPose& bo) fromAron(const arondto::ObjectInstance& dto, objpose::arondto::ObjectPose& bo)
{ {
bo = dto.pose; bo = dto.pose;
...@@ -29,7 +45,7 @@ namespace armarx::armem ...@@ -29,7 +45,7 @@ namespace armarx::armem
toAron(arondto::ObjectInstance& dto, const objpose::ObjectPose& bo) toAron(arondto::ObjectInstance& dto, const objpose::ObjectPose& bo)
{ {
objpose::toAron(dto.pose, bo); objpose::toAron(dto.pose, bo);
} }*/
/* Attachments */ /* Attachments */
......
...@@ -10,12 +10,8 @@ ...@@ -10,12 +10,8 @@
namespace armarx::armem namespace armarx::armem
{ {
void fromAron(const arondto::ObjectInstance& dto, objpose::arondto::ObjectPose& bo); void fromAron(const arondto::ObjectInstance&, ObjectInstance&);
void toAron(arondto::ObjectInstance& dto, const objpose::arondto::ObjectPose& bo); void toAron(arondto::ObjectInstance&, const ObjectInstance&);
void fromAron(const arondto::ObjectInstance& dto, objpose::ObjectPose& bo);
void toAron(arondto::ObjectInstance& dto, const objpose::ObjectPose& bo);
/* Attachments */ /* Attachments */
void fromAron(const arondto::attachment::AgentDescription& dto, attachment::AgentDescription& bo); void fromAron(const arondto::attachment::AgentDescription& dto, attachment::AgentDescription& bo);
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <RobotAPI/libraries/armem_robot/aron/Robot.aron.generated.h> #include <RobotAPI/libraries/armem_robot/aron/Robot.aron.generated.h>
#include <RobotAPI/libraries/armem_robot/aron_conversions.h> #include <RobotAPI/libraries/armem_robot/aron_conversions.h>
#include <RobotAPI/libraries/armem_robot/robot_conversions.h> #include <RobotAPI/libraries/armem_robot/robot_conversions.h>
#include <RobotAPI/libraries/armem_objects/aron_conversions.h>
#include "utils.h" #include "utils.h"
...@@ -262,10 +263,13 @@ namespace armarx::armem::articulated_object ...@@ -262,10 +263,13 @@ namespace armarx::armem::articulated_object
std::optional<robot::RobotState> std::optional<robot::RobotState>
convertToRobotState(const armem::wm::EntityInstance& instance) convertToRobotState(const armem::wm::EntityInstance& instance)
{ {
armarx::armem::arondto::ObjectInstance aronObjectInstance; armarx::armem::ObjectInstance aronObjectInstance;
try try
{ {
aronObjectInstance.fromAron(instance.data()); armarx::armem::arondto::ObjectInstance dto;
dto.fromAron(instance.data());
fromAron(dto, aronObjectInstance);
} }
catch (...) catch (...)
{ {
...@@ -273,9 +277,7 @@ namespace armarx::armem::articulated_object ...@@ -273,9 +277,7 @@ namespace armarx::armem::articulated_object
return std::nullopt; return std::nullopt;
} }
objpose::ObjectPose objectPose; objpose::ObjectPose objectPose = aronObjectInstance.pose;
objpose::fromAron(aronObjectInstance.pose, objectPose);
robot::RobotState robotState{.timestamp = objectPose.timestamp, robot::RobotState robotState{.timestamp = objectPose.timestamp,
.globalPose = Eigen::Affine3f(objectPose.objectPoseGlobal), .globalPose = Eigen::Affine3f(objectPose.objectPoseGlobal),
.jointMap = objectPose.objectJointValues}; .jointMap = objectPose.objectJointValues};
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <RobotAPI/libraries/armem/core/aron_conversions.h> #include <RobotAPI/libraries/armem/core/aron_conversions.h>
#include <RobotAPI/libraries/armem/core/error.h> #include <RobotAPI/libraries/armem/core/error.h>
#include <RobotAPI/libraries/armem/core/operations.h> #include <RobotAPI/libraries/armem/core/operations.h>
#include <RobotAPI/libraries/armem_objects/aron_conversions.h>
#include <RobotAPI/libraries/armem_objects/aron/ObjectClass.aron.generated.h> #include <RobotAPI/libraries/armem_objects/aron/ObjectClass.aron.generated.h>
#include <RobotAPI/libraries/armem_objects/aron/ObjectInstance.aron.generated.h> #include <RobotAPI/libraries/armem_objects/aron/ObjectInstance.aron.generated.h>
#include <RobotAPI/libraries/armem_robot/aron/Robot.aron.generated.h> #include <RobotAPI/libraries/armem_robot/aron/Robot.aron.generated.h>
...@@ -206,8 +207,7 @@ namespace armarx::armem::articulated_object ...@@ -206,8 +207,7 @@ namespace armarx::armem::articulated_object
// arondto::Robot aronArticulatedObject; // arondto::Robot aronArticulatedObject;
// robot::toAron(aronArticulatedObject, obj); // robot::toAron(aronArticulatedObject, obj);
arondto::ObjectInstance objectInstance; ObjectInstance objectInstance;
toAron(objectInstance, obj.config);
const auto classId = storeOrGetClass(obj); const auto classId = storeOrGetClass(obj);
...@@ -218,21 +218,20 @@ namespace armarx::armem::articulated_object ...@@ -218,21 +218,20 @@ namespace armarx::armem::articulated_object
} }
// install memory link // install memory link
toAron(objectInstance.classID, *classId); objectInstance.classID = *classId;
armem::MemoryID id; armem::MemoryID id;
id.setEntityID(classId->getEntityID()); id.setEntityID(classId->getEntityID());
armarx::ObjectID objectId(id.entityName); armarx::ObjectID objectId(id.entityName);
armarx::ObjectID cs(objectId.dataset(), objectId.className(), objectId.instanceName());
armarx::arondto::ObjectID cs;
cs.className = objectId.className();
cs.instanceName = objectId.instanceName();
cs.dataset = objectId.dataset();
objectInstance.pose.objectID = cs; objectInstance.pose.objectID = cs;
update.instancesData = {objectInstance.toAron()}; arondto::ObjectInstance dto;
toAron(dto, objectInstance);
update.instancesData = {dto.toAron()};
update.timeCreated = timestamp; update.timeCreated = timestamp;
ARMARX_DEBUG << "Committing " << update << " at time " << timestamp; ARMARX_DEBUG << "Committing " << update << " at time " << timestamp;
......
...@@ -170,10 +170,8 @@ namespace armarx::armem::server::obj::instance ...@@ -170,10 +170,8 @@ namespace armarx::armem::server::obj::instance
const wm::Entity* entity = findObjectEntity(armarx::fromIce(provided.objectID), providerName); const wm::Entity* entity = findObjectEntity(armarx::fromIce(provided.objectID), providerName);
if (entity) if (entity)
{ {
const arondto::ObjectInstance data = getLatestInstanceData(*entity); const ObjectInstance data = getLatestInstanceData(*entity);
previousPose = data.pose;
previousPose = objpose::ObjectPose();
fromAron(data, *previousPose);
} }
bool discard = false; bool discard = false;
...@@ -274,7 +272,7 @@ namespace armarx::armem::server::obj::instance ...@@ -274,7 +272,7 @@ namespace armarx::armem::server::obj::instance
update.confidence = pose.confidence; update.confidence = pose.confidence;
arondto::ObjectInstance dto; arondto::ObjectInstance dto;
toAron(dto, pose); toAron(dto.pose, pose);
// Search for object class. // Search for object class.
if (auto instance = findClassInstance(pose.objectID)) if (auto instance = findClassInstance(pose.objectID))
{ {
...@@ -504,15 +502,17 @@ namespace armarx::armem::server::obj::instance ...@@ -504,15 +502,17 @@ namespace armarx::armem::server::obj::instance
{ {
entity.getLatestSnapshot().forEachInstance([&out](const wm::EntityInstance & instance) entity.getLatestSnapshot().forEachInstance([&out](const wm::EntityInstance & instance)
{ {
ObjectInstance bo;
arondto::ObjectInstance dto; arondto::ObjectInstance dto;
dto.fromAron(instance.data()); dto.fromAron(instance.data());
fromAron(dto, out); fromAron(dto, bo);
out = bo.pose;
}); });
} }
arondto::ObjectInstance Segment::getLatestInstanceData(const wm::Entity& entity) ObjectInstance Segment::getLatestInstanceData(const wm::Entity& entity)
{ {
ARMARX_CHECK_GREATER_EQUAL(entity.size(), 1); ARMARX_CHECK_GREATER_EQUAL(entity.size(), 1);
const wm::EntitySnapshot& snapshot = entity.getLatestSnapshot(); const wm::EntitySnapshot& snapshot = entity.getLatestSnapshot();
...@@ -520,10 +520,13 @@ namespace armarx::armem::server::obj::instance ...@@ -520,10 +520,13 @@ namespace armarx::armem::server::obj::instance
ARMARX_CHECK_EQUAL(snapshot.size(), 1); ARMARX_CHECK_EQUAL(snapshot.size(), 1);
const wm::EntityInstance& instance = snapshot.getInstance(0); const wm::EntityInstance& instance = snapshot.getInstance(0);
arondto::ObjectInstance data; ObjectInstance bo;
data.fromAron(instance.data()); arondto::ObjectInstance dto;
dto.fromAron(instance.data());
fromAron(dto, bo);
return data; return bo;
} }
...@@ -602,7 +605,7 @@ namespace armarx::armem::server::obj::instance ...@@ -602,7 +605,7 @@ namespace armarx::armem::server::obj::instance
dto.fromAron(instance.data()); dto.fromAron(instance.data());
ObjectPose pose; ObjectPose pose;
fromAron(dto, pose); fromAron(dto.pose, pose);
result.emplace(snapshot.time(), pose); result.emplace(snapshot.time(), pose);
}); });
...@@ -681,7 +684,7 @@ namespace armarx::armem::server::obj::instance ...@@ -681,7 +684,7 @@ namespace armarx::armem::server::obj::instance
<< "' of agent '" << agent->getName() << "', but object is currently not provided."; << "' of agent '" << agent->getName() << "', but object is currently not provided.";
return output; return output;
} }
arondto::ObjectInstance data = getLatestInstanceData(*objectEntity); ObjectInstance data = getLatestInstanceData(*objectEntity);
objpose::ObjectAttachmentInfo info; objpose::ObjectAttachmentInfo info;
info.agentName = agent->getName(); info.agentName = agent->getName();
...@@ -717,10 +720,12 @@ namespace armarx::armem::server::obj::instance ...@@ -717,10 +720,12 @@ namespace armarx::armem::server::obj::instance
update.entityID = objectEntity->id(); update.entityID = objectEntity->id();
update.timeCreated = now; update.timeCreated = now;
{ {
arondto::ObjectInstance updated = data; ObjectInstance updated = data;
toAron(updated.pose.attachment, info); data.pose.attachment = info;
updated.pose.attachmentValid = true;
update.instancesData = { updated.toAron() }; arondto::ObjectInstance dto;
toAron(dto, data);
update.instancesData = { dto.toAron() };
} }
iceMemory.commit(commit); iceMemory.commit(commit);
} }
...@@ -748,15 +753,15 @@ namespace armarx::armem::server::obj::instance ...@@ -748,15 +753,15 @@ namespace armarx::armem::server::obj::instance
ObjectID objectID = armarx::fromIce(input.objectID); ObjectID objectID = armarx::fromIce(input.objectID);
std::string providerName = input.providerName; std::string providerName = input.providerName;
std::optional<objpose::arondto::ObjectAttachmentInfo> attachment; std::optional<objpose::ObjectAttachmentInfo> attachment;
{ {
// Remove from latest pose (if it was cached). // Remove from latest pose (if it was cached).
// Find object pose (provider name can be empty). // Find object pose (provider name can be empty).
wm::Entity* entity = this->findObjectEntity(objectID, input.providerName); wm::Entity* entity = this->findObjectEntity(objectID, input.providerName);
if (entity) if (entity)
{ {
const arondto::ObjectInstance data = getLatestInstanceData(*entity); const ObjectInstance data = getLatestInstanceData(*entity);
if (data.pose.attachmentValid) if (data.pose.attachment)
{ {
attachment = data.pose.attachment; attachment = data.pose.attachment;
...@@ -799,8 +804,8 @@ namespace armarx::armem::server::obj::instance ...@@ -799,8 +804,8 @@ namespace armarx::armem::server::obj::instance
output.numDetached = 0; output.numDetached = 0;
segmentPtr->forEachEntity([this, now, &input, &output](wm::Entity & entity) segmentPtr->forEachEntity([this, now, &input, &output](wm::Entity & entity)
{ {
const arondto::ObjectInstance data = this->getLatestInstanceData(entity); const ObjectInstance data = this->getLatestInstanceData(entity);
if (data.pose.attachmentValid) if (data.pose.attachment)
{ {
++output.numDetached; ++output.numDetached;
// Store non-attached pose in new snapshot. // Store non-attached pose in new snapshot.
...@@ -816,7 +821,7 @@ namespace armarx::armem::server::obj::instance ...@@ -816,7 +821,7 @@ namespace armarx::armem::server::obj::instance
void Segment::storeDetachedSnapshot( void Segment::storeDetachedSnapshot(
wm::Entity& entity, wm::Entity& entity,
const arondto::ObjectInstance& data, const ObjectInstance& data,
Time now, Time now,
bool commitAttachedPose) bool commitAttachedPose)
{ {
...@@ -825,27 +830,29 @@ namespace armarx::armem::server::obj::instance ...@@ -825,27 +830,29 @@ namespace armarx::armem::server::obj::instance
update.entityID = entity.id(); update.entityID = entity.id();
update.timeCreated = now; update.timeCreated = now;
{ {
arondto::ObjectInstance updated; ObjectInstance updated;
if (commitAttachedPose and data.pose.attachmentValid) if (commitAttachedPose and data.pose.attachment)
{ {
ObjectPose objectPose; ObjectPose objectPose = data.pose;
fromAron(data, objectPose);
VirtualRobot::RobotPtr robot = robots.get(objectPose.robotName, objectPose.providerName); VirtualRobot::RobotPtr robot = robots.get(objectPose.robotName, objectPose.providerName);
bool agentSynchronized = false; bool agentSynchronized = false;
updateAttachement(objectPose, robot, agentSynchronized); updateAttachement(objectPose, robot, agentSynchronized);
objectPose.attachment = std::nullopt; objectPose.attachment = std::nullopt;
toAron(updated, objectPose); //toAron(updated, objectPose);
} }
else else
{ {
updated = data; updated = data;
updated.pose.attachmentValid = false; updated.pose.attachment = std::nullopt;
toAron(updated.pose.attachment, objpose::ObjectAttachmentInfo{}); //updated.pose.attachmentValid = false;
//toAron(updated.pose.attachment, objpose::ObjectAttachmentInfo{});
} }
update.instancesData = { updated.toAron() }; arondto::ObjectInstance i;
toAron(i, updated);
update.instancesData = { i.toAron() };
} }
iceMemory.commit(commit); iceMemory.commit(commit);
} }
......
...@@ -27,11 +27,6 @@ ...@@ -27,11 +27,6 @@
#include "Decay.h" #include "Decay.h"
namespace armarx::armem::arondto
{
class ObjectInstance;
}
namespace armarx::armem::server::obj::instance namespace armarx::armem::server::obj::instance
{ {
...@@ -102,7 +97,7 @@ namespace armarx::armem::server::obj::instance ...@@ -102,7 +97,7 @@ namespace armarx::armem::server::obj::instance
static void getLatestObjectPoses(const wm::ProviderSegment& provSeg, ObjectPoseMap& out); static void getLatestObjectPoses(const wm::ProviderSegment& provSeg, ObjectPoseMap& out);
static void getLatestObjectPose(const wm::Entity& entity, ObjectPose& out); static void getLatestObjectPose(const wm::Entity& entity, ObjectPose& out);
static arondto::ObjectInstance getLatestInstanceData(const wm::Entity& entity); static ObjectInstance getLatestInstanceData(const wm::Entity& entity);
::armarx::armem::articulated_object::ArticulatedObjects getArticulatedObjects(); ::armarx::armem::articulated_object::ArticulatedObjects getArticulatedObjects();
...@@ -135,7 +130,7 @@ namespace armarx::armem::server::obj::instance ...@@ -135,7 +130,7 @@ namespace armarx::armem::server::obj::instance
void storeDetachedSnapshot( void storeDetachedSnapshot(
wm::Entity& entity, wm::Entity& entity,
const arondto::ObjectInstance& data, const ObjectInstance& data,
Time now, Time now,
bool commitAttachedPose); bool commitAttachedPose);
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <Eigen/Geometry> #include <Eigen/Geometry>
#include <RobotAPI/libraries/ArmarXObjects/ObjectPose.h>
#include <RobotAPI/libraries/armem/core/MemoryID.h> #include <RobotAPI/libraries/armem/core/MemoryID.h>
#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>
...@@ -31,6 +32,16 @@ ...@@ -31,6 +32,16 @@
#include "aron_forward_declarations.h" #include "aron_forward_declarations.h"
namespace armarx::armem
{
struct ObjectInstance
{
objpose::ObjectPose pose;
MemoryID classID;
MemoryID sourceID;
};
}
namespace armarx::armem::attachment namespace armarx::armem::attachment
{ {
using AgentID = armem::MemoryID; using AgentID = armem::MemoryID;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment