Go to the documentation of this file.
5 #include <sys/inotify.h>
8 #include <Eigen/Geometry>
10 #include <SimoxUtility/algorithm/get_map_keys_values.h>
11 #include <SimoxUtility/algorithm/string.h>
12 #include <SimoxUtility/json.h>
13 #include <SimoxUtility/math/pose/pose.h>
14 #include <SimoxUtility/math/regression/linear.h>
29 #include <RobotAPI/libraries/ArmarXObjects/aron/ObjectPose.aron.generated.h>
40 #include <RobotAPI/libraries/armem_objects/aron/FamiliarObjectInstance.aron.generated.h>
41 #include <RobotAPI/libraries/armem_objects/aron/ObjectClass.aron.generated.h>
42 #include <RobotAPI/libraries/armem_objects/aron/ObjectInstance.aron.generated.h>
59 "Name of robot whose note can be calibrated.\n"
60 "If not given, the 'fallbackName' is used.");
61 defs->optional(
robotNode, prefix +
"robotNode",
"Robot node which can be calibrated.");
62 defs->optional(
offset, prefix +
"offset",
"Offset for the node to be calibrated.");
68 arondto::FamiliarObjectInstance::ToAronType(),
80 SpecializedCoreSegment::defineProperties(defs, prefix);
84 prefix +
"robots.FallbackName",
85 "Robot name to use as fallback if the robot name is not specified "
86 "in a provided object pose.");
95 SpecializedCoreSegment::init();
111 const std::vector<armarx::armem::arondto::FamiliarObjectInstance>& familiarObjectInstances,
112 const std::string& providerName)
122 for (
const armarx::armem::arondto::FamiliarObjectInstance& familiarObjectInstance :
123 familiarObjectInstances)
130 fromAron(familiarObjectInstance.objectID, objectID);
134 update.referencedTime = familiarObjectInstance.timestamp;
135 update.confidence = familiarObjectInstance.confidence;
137 update.instancesData.push_back(familiarObjectInstance.toAron());
141 <<
" familiar object instances from provider " << providerName;
145 std::vector<armarx::armem::arondto::FamiliarObjectInstance>
148 std::vector<armarx::armem::arondto::FamiliarObjectInstance> familiarObjects;
151 [&familiarObjects, &now](
const wm::Entity& entity)
156 armarx::armem::arondto::FamiliarObjectInstance dto;
157 dto.fromAron(instance.
data());
159 if (dto.timestamp <= now)
161 familiarObjects.push_back(dto);
166 return familiarObjects;
169 std::map<std::string, std::vector<armarx::armem::arondto::FamiliarObjectInstance>>
172 std::map<std::string, std::vector<armarx::armem::arondto::FamiliarObjectInstance>>
173 familiarObjectsByProvider;
179 auto& familiarObjects = familiarObjectsByProvider[ps.
name()];
181 [&familiarObjects, &now](
const wm::Entity& entity)
186 armarx::armem::arondto::FamiliarObjectInstance dto;
187 dto.fromAron(instance.
data());
189 if (dto.timestamp <= now)
191 familiarObjects.push_back(dto);
199 return familiarObjectsByProvider;
205 std::string robotName = _robotName;
207 if (robotName.empty())
211 std::stringstream ss;
212 if (providerName.empty())
214 ss <<
"The provided object pose";
218 ss <<
"The object pose provided by '" << providerName <<
"'";
220 ss <<
" does not specify a robot name";
224 ss <<
", and no fallback robot name was configured (e.g. via the properties).\n"
225 <<
"For these object poses, the object instance segment is not able "
226 <<
"to provide transformed object poses (global and in robot root frame).";
233 ss <<
". The object instance segment is falling back to '" <<
fallbackName <<
"'.";
242 if (
auto it =
loaded.find(robotName); it !=
loaded.end())
252 robotName,
Clock::Now(), VirtualRobot::RobotIO::RobotDescription::eStructure);
257 if (not
synchronized)
259 ARMARX_INFO <<
"The robot '" << robotName <<
"' could be loaded, but not"
260 <<
" synchronized successfully (e.g., the global localization "
261 "could be missing). "
262 <<
"Make sure to synchronize it before use if necessary.";
265 loaded.emplace(robotName, robot);
std::vector< armarx::armem::arondto::FamiliarObjectInstance > getFamiliarObjects(const DateTime &now)
const armem::MemoryID coreSegmentID
std::map< std::string, std::vector< armarx::armem::arondto::FamiliarObjectInstance > > getFamiliarObjectsByProvider(const DateTime &now)
Segment(server::MemoryToIceAdapter &iceMemory)
A known object ID of the form "Dataset/ClassName" or "Dataset/ClassName/InstanceName".
const MemoryID familiarObjectInstaceSegmentID
A bundle of updates to be sent to the memory.
Client-side working entity instance.
Helps connecting a Memory server to the Ice interface.
auto & getLatestSnapshot(int snapshotIndex=0)
Retrieve the latest entity snapshot.
SpecializedCoreSegment(MemoryToIceAdapter &iceMemory, const std::string &defaultCoreSegmentName="", aron::type::ObjectPtr coreSegmentAronType=nullptr, int defaultMaxHistorySize=10, const std::vector< PredictionEngine > &predictionEngines={})
#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...
void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="") override
void connect(viz::Client arviz)
#define ARMARX_CHECK_NOT_EMPTY(c)
virtual ~Segment() override
bool forEachEntity(FunctionT &&func)
server::wm::CoreSegment * segmentPtr
MemoryID withProviderSegmentName(const std::string &name) const
std::experimental::observer_ptr< robot_state::VirtualRobotReader > reader
bool forEachProviderSegment(ProviderSegmentFunctionT &&func)
An update of an entity for a specific point in time.
std::map< std::string, VirtualRobot::RobotPtr > loaded
void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="calibration.")
bool update(mongocxx::collection &coll, const nlohmann::json &query, const nlohmann::json &update)
Represents a point in time.
void fromAron(const arondto::MemoryID &dto, MemoryID &bo)
MemoryID withEntityName(const std::string &name) const
MemoryToIceAdapter & iceMemory
bool forEachEntity(EntityFunctionT &&func)
static DateTime Now()
Current time on the virtual clock.
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.
void setTag(const LogTag &tag)
void commit(const std::vector< armarx::armem::arondto::FamiliarObjectInstance > &familiarObjectInstances, const std::string &providerName)
const DataT & data() const
data::CommitResult commit(const data::Commit &commitIce, Time timeArrived)
std::string str() const
Return "dataset/className" or "dataset/className/instanceName".
std::shared_ptr< class Robot > RobotPtr
VirtualRobot::RobotPtr get(const std::string &robotName, const std::string &providerName="")
void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="decay.")