36 def->topic<KinematicUnitListener>(
"RealRobotState",
"KinematicUnitName");
37 def->optional(frequency,
"UpdateFrequency",
"Frequency of updates in Hz");
44 return "SimpleEpisodicMemoryKinematicUnitConnector";
48 frequency(10), updated(false), timestampLastUpdateInMs(0)
64 &SimpleEpisodicMemoryKinematicUnitConnector::checkAndSendToMemory,
65 (1.0f / frequency * 1000));
66 periodic_task->start();
72 periodic_task->stop();
81 SimpleEpisodicMemoryKinematicUnitConnector::checkAndSendToMemory()
83 std::lock_guard l(jointAngle_mutex);
84 std::lock_guard ll(jointVelocity_mutex);
85 std::lock_guard lll(jointTorque_mutex);
86 std::lock_guard llll(jointAcceleration_mutex);
87 std::lock_guard lllll(jointCurrent_mutex);
88 std::lock_guard llllll(jointTemperature_mutex);
89 std::lock_guard lllllll(jointEnabled_mutex);
91 std::lock_guard u(updatedMutex);
92 if (!updated || timestampLastUpdateInMs == 0)
97 memoryx::KinematicUnitEvent event;
98 event.receivedInMs = timestampLastUpdateInMs;
100 for (
const auto& [key, value] : jointAngleMap)
102 event.data[key].jointAngle = value;
105 for (
const auto& [key, value] : jointVelocityMap)
107 event.data[key].jointVelocity =
value;
110 for (
const auto& [key, value] : jointTorqueMap)
112 event.data[key].jointTorque =
value;
115 for (
const auto& [key, value] : jointAccelerationMap)
117 event.data[key].jointAcceleration =
value;
120 for (
const auto& [key, value] : jointCurrentMap)
122 event.data[key].current =
value;
125 for (
const auto& [key, value] : jointTemperatureMap)
127 event.data[key].temperature =
value;
130 for (
const auto& [key, value] : jointEnabledMap)
132 event.data[key].enabled =
value;
138 timestampLastUpdateInMs = 0;
156 std::lock_guard l(jointAngle_mutex);
157 double received = IceUtil::Time::now().toMilliSecondsDouble();
158 for (
const auto& [key, value] :
data)
160 jointAngleMap[key] = value;
164 std::lock_guard u(updatedMutex);
165 this->updated =
true;
166 this->timestampLastUpdateInMs = received;
176 std::lock_guard l(jointVelocity_mutex);
177 double received = IceUtil::Time::now().toMilliSecondsDouble();
178 for (
const auto& [key, value] :
data)
180 jointVelocityMap[key] = value;
184 std::lock_guard u(updatedMutex);
185 this->updated =
true;
186 this->timestampLastUpdateInMs = received;
196 std::lock_guard l(jointTorque_mutex);
197 double received = IceUtil::Time::now().toMilliSecondsDouble();
198 for (
const auto& [key, value] :
data)
200 jointTorqueMap[key] = value;
204 std::lock_guard u(updatedMutex);
205 this->updated =
true;
206 this->timestampLastUpdateInMs = received;
216 std::lock_guard l(jointAcceleration_mutex);
217 double received = IceUtil::Time::now().toMilliSecondsDouble();
218 for (
const auto& [key, value] :
data)
220 jointTorqueMap[key] = value;
224 std::lock_guard u(updatedMutex);
225 this->updated =
true;
226 this->timestampLastUpdateInMs = received;
236 std::lock_guard l(jointCurrent_mutex);
237 double received = IceUtil::Time::now().toMilliSecondsDouble();
238 for (
const auto& [key, value] :
data)
240 jointCurrentMap[key] = value;
244 std::lock_guard u(updatedMutex);
245 this->updated =
true;
246 this->timestampLastUpdateInMs = received;
252 const NameValueMap&
data,
257 std::lock_guard l(jointTemperature_mutex);
258 double received = IceUtil::Time::now().toMilliSecondsDouble();
259 for (
const auto& [key, value] :
data)
261 jointTemperatureMap[key] = value;
265 std::lock_guard u(updatedMutex);
266 this->updated =
true;
267 this->timestampLastUpdateInMs = received;
277 std::lock_guard l(jointEnabled_mutex);
278 double received = IceUtil::Time::now().toMilliSecondsDouble();
279 for (
const auto& [key, value] :
data)
281 jointEnabledMap[key] = value.enabled;
285 std::lock_guard u(updatedMutex);
286 this->updated =
true;
287 this->timestampLastUpdateInMs = received;
#define ARMARX_REGISTER_COMPONENT_EXECUTABLE(ComponentT, applicationName)
Default component property definition container.
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
The periodic task executes one thread method repeatedly using the time period specified in the constr...
void onInitComponent() override
void reportJointStatuses(const NameStatusMap &, Ice::Long, bool, const Ice::Current &)
void reportControlModeChanged(const NameControlModeMap &, Ice::Long, bool, const Ice::Current &)
void onDisconnectComponent() override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void reportJointAccelerations(const NameValueMap &, Ice::Long, bool, const Ice::Current &)
SimpleEpisodicMemoryKinematicUnitConnector()
void reportJointTorques(const NameValueMap &, Ice::Long, bool, const Ice::Current &)
void reportJointVelocities(const NameValueMap &, Ice::Long, bool, const Ice::Current &)
void onConnectComponent() override
void reportJointAngles(const NameValueMap &, Ice::Long, bool, const Ice::Current &)
void onExitComponent() override
void reportJointMotorTemperatures(const NameValueMap &, Ice::Long, bool, const Ice::Current &)
void reportJointCurrents(const NameValueMap &, Ice::Long, bool, const Ice::Current &)
std::string getDefaultName() const override
Retrieve default name of component.
std::string m_simple_episodic_memory_proxy_name
memoryx::SimpleEpisodicMemoryInterface::ProxyType m_simple_episodic_memory
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
std::shared_ptr< Value > value()