Go to the documentation of this file.
25 #include <SimoxUtility/algorithm/string.h>
26 #include <SimoxUtility/json.h>
27 #include <VirtualRobot/CollisionDetection/CollisionModel.h>
28 #include <VirtualRobot/ManipulationObject.h>
64 defs->component(workingMemory);
65 defs->component(robotStateComponent);
66 defs->component(priorKnowledge);
68 defs->optional(updateFrequency,
"UpdateFrequency",
"Target number of updates per second.");
69 defs->optional(configFile,
"ConfigFile",
"Path to the config file.");
70 defs->optional(loadObjectDatasetsStr,
72 "Only load the files for the following datasets, separated by ;. Load all "
73 "if input is empty.");
81 return "WorkingMemoryObjectPoseProvider";
88 ARMARX_INFO <<
"Loading config file '" << configFile <<
"' ...";
89 if (std::filesystem::is_regular_file(configFile))
91 const nlohmann::json j = nlohmann::read_json(configFile);
96 ARMARX_INFO <<
"No config file at '" << configFile <<
"'";
107 ARMARX_IMPORTANT <<
"Loading workingmemory and priorknowledge entites and files. This may "
111 std::vector<std::string> loadDatasets =
simox::alg::split(loadObjectDatasetsStr,
";");
113 objectClassSegment.
initFromProxy(priorKnowledge, loadDatasets);
123 while (task && !task->isStopped())
125 provideObjectInstancesPoses();
148 WorkingMemoryObjectPoseProvider::provideObjectInstancesPoses()
150 std::scoped_lock lock(mutex);
151 std::vector<ObjectInstancePtr> instances = attachments.
queryObjects();
152 provideObjectInstancesPoses(instances);
156 WorkingMemoryObjectPoseProvider::provideObjectInstancesPoses(
157 const std::vector<ObjectInstancePtr>& objectInstances)
161 for (
const auto& instance : objectInstances)
163 objectPoses.push_back(toProvidedObjectPose(instance).
toIce());
170 WorkingMemoryObjectPoseProvider::toProvidedObjectPose(
const ObjectInstancePtr& instance)
174 pose.
objectType = armarx::objpose::KnownObject;
175 std::string className = instance->getMostProbableClass();
179 << it->second <<
"'";
180 className = it->second;
185 pose.
objectPose = instance->getPose()->toEigen();
192 pose.
confidence = instance->getExistenceCertainty();
193 if (instance->hasLocalizationTimestamp())
202 std::optional<ObjectClassWrapper> objectClass = objectClassSegment.
getClass(className);
206 VirtualRobot::CollisionModelPtr collisionModel =
207 objectClass->manipulationObject->getCollisionModel();
208 VirtualRobot::BoundingBox bb = collisionModel->getBoundingBox(
false);
209 Eigen::Vector3f bbMin = bb.getMin();
210 Eigen::Vector3f bbMax = bb.getMax();
211 Eigen::Vector3f extents = bbMax - bbMin;
223 armarx::objpose::ProviderInfo
226 armarx::objpose::ProviderInfo info;
233 const AttachObjectToRobotNodeInput& attachment,
236 std::scoped_lock lock(mutex);
242 const DetachObjectFromRobotNodeInput& detachment,
245 std::scoped_lock lock(mutex);
static std::string resolvePath(const std::string &path, bool verbose=true)
Resolves environment variables and home paths and tries to make path absolute.
void from_json(const nlohmann::json &j, Config &config)
std::map< std::string, std::string > objectNames
armarx::ObjectID objectID
The object ID, i.e. dataset, class name and instance name.
armarx::objpose::ProviderInfo getProviderInfo(const Ice::Current &=Ice::emptyCurrent) override
void attachObjectToRobotNode(const memoryx::AttachObjectToRobotNodeInput &attachment)
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
const std::string GlobalFrame
This util class helps with keeping a cycle time during a control cycle.
std::optional< ObjectClassWrapper > getClass(std::string const &className) const
std::string objectPoseFrame
void detachObjectFromRobotNode(const memoryx::DetachObjectFromRobotNodeInput &detachment)
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void Identity(MatrixXX< N, N, T > *a)
void onInitComponent() override
void fromIce(Eigen::Vector2f &e, const Ice::FloatSeq &ice)
void initFromProxy(memoryx::PriorKnowledgeInterfacePrx const &priorKnowledge, const std::vector< std::string > &datasets)
void to_json(nlohmann::json &j, const Config &config)
IceInternal::Handle< ObjectInstance > ObjectInstancePtr
objpose::ObjectPoseStorageInterfacePrx objectPoseTopic
void initFromProxies(const WorkingMemoryInterfacePrx &workingMemory, const armarx::RobotStateComponentInterfacePrx &robotStateComponent)
Set the proxies.
IceUtil::Time waitForCycleDuration()
This function will wait (virtual or system time) until the cycle time is reached.
std::string providerName
Name of the providing component.
void toIce(const Eigen::Vector2f &e, Ice::FloatSeq &ice)
void onConnectComponent() override
std::vector< ProvidedObjectPose > ProvidedObjectPoseSeq
void onDisconnectComponent() override
An object pose provided by an ObjectPoseProvider.
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
ObjectType objectType
Known or unknown object.
Default component property definition container.
SpamFilterDataPtr deactivateSpam(float deactivationDurationSec=10.0f, const std::string &identifier="", bool deactivate=true) const
disables the logging for the current line for the given amount of seconds.
std::optional< simox::OrientedBoxf > localOOBB
Object bounding box in object's local coordinate frame.
void detachObjectFromRobotNode(const DetachObjectFromRobotNodeInput &detachment, const Ice::Current &) override
std::string getName() const
Retrieve name of object.
std::vector< ObjectInstancePtr > queryObjects()
Get all entities from objectInstanceSegment and cast them to ObjectInstance.
float confidence
Confidence in [0, 1] (1 = full, 0 = none).
void attachObjectToRobotNode(const AttachObjectToRobotNodeInput &attachment, const Ice::Current &) override
DateTime timestamp
Source timestamp.
std::string getDefaultName() const override
void onExitComponent() override
Eigen::Matrix4f objectPose
std::vector< std::string > split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
void setInstanceName(const std::string &instanceName)