Go to the documentation of this file.
25 #include <SimoxUtility/json.h>
26 #include <SimoxUtility/algorithm/string.h>
28 #include <VirtualRobot/ManipulationObject.h>
62 defs->component(workingMemory);
63 defs->component(robotStateComponent);
64 defs->component(priorKnowledge);
66 defs->optional(updateFrequency,
"UpdateFrequency",
"Target number of updates per second.");
67 defs->optional(configFile,
"ConfigFile",
"Path to the config file.");
68 defs->optional(loadObjectDatasetsStr,
"LoadDatasets",
"Only load the files for the following datasets, separated by ;. Load all if input is empty.");
75 return "WorkingMemoryObjectPoseProvider";
82 ARMARX_INFO <<
"Loading config file '" << configFile <<
"' ...";
83 if (std::filesystem::is_regular_file(configFile))
85 const nlohmann::json j = nlohmann::read_json(configFile);
90 ARMARX_INFO <<
"No config file at '" << configFile <<
"'";
101 ARMARX_IMPORTANT <<
"Loading workingmemory and priorknowledge entites and files. This may take a while....";
104 std::vector<std::string> loadDatasets =
simox::alg::split(loadObjectDatasetsStr,
";");
106 objectClassSegment.
initFromProxy(priorKnowledge, loadDatasets);
115 while (task && !task->isStopped())
117 provideObjectInstancesPoses();
140 void WorkingMemoryObjectPoseProvider::provideObjectInstancesPoses()
142 std::scoped_lock lock(mutex);
143 std::vector<ObjectInstancePtr> instances = attachments.
queryObjects();
144 provideObjectInstancesPoses(instances);
147 void WorkingMemoryObjectPoseProvider::provideObjectInstancesPoses(
const std::vector<ObjectInstancePtr>& objectInstances)
151 for (
const auto& instance : objectInstances)
153 objectPoses.push_back(toProvidedObjectPose(instance).
toIce());
161 WorkingMemoryObjectPoseProvider::toProvidedObjectPose(
166 pose.
objectType = armarx::objpose::KnownObject;
167 std::string className = instance->getMostProbableClass();
171 className = it->second;
176 pose.
objectPose = instance->getPose()->toEigen();
183 pose.
confidence = instance->getExistenceCertainty();
184 if (instance->hasLocalizationTimestamp())
193 std::optional<ObjectClassWrapper> objectClass = objectClassSegment.
getClass(className);
197 VirtualRobot::CollisionModelPtr collisionModel = objectClass->manipulationObject->getCollisionModel();
198 VirtualRobot::BoundingBox bb = collisionModel->getBoundingBox(
false);
199 Eigen::Vector3f bbMin = bb.getMin();
200 Eigen::Vector3f bbMax = bb.getMax();
201 Eigen::Vector3f extents = bbMax - bbMin;
205 (0.5 * (bbMin + bbMax)).eval(),
219 armarx::objpose::ProviderInfo info;
227 std::scoped_lock lock(mutex);
234 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
objpose::ObjectPoseTopicPrx objectPoseTopic
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
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)