34 def->topic<KinematicUnitListener>(
"RealRobotState",
"KinematicUnitName");
35 def->optional(frequency,
"UpdateFrequency",
"Frequency of updates in Hz");
42 return "SimpleEpisodicMemoryKinematicUnitConnector";
46 frequency(10), updated(false), timestampLastUpdateInMs(0)
62 &SimpleEpisodicMemoryKinematicUnitConnector::checkAndSendToMemory,
63 (1.0f / frequency * 1000));
64 periodic_task->start();
70 periodic_task->stop();
79 SimpleEpisodicMemoryKinematicUnitConnector::checkAndSendToMemory()
81 std::lock_guard l(jointAngle_mutex);
82 std::lock_guard ll(jointVelocity_mutex);
83 std::lock_guard lll(jointTorque_mutex);
84 std::lock_guard llll(jointAcceleration_mutex);
85 std::lock_guard lllll(jointCurrent_mutex);
86 std::lock_guard llllll(jointTemperature_mutex);
87 std::lock_guard lllllll(jointEnabled_mutex);
89 std::lock_guard u(updatedMutex);
90 if (!updated || timestampLastUpdateInMs == 0)
95 memoryx::KinematicUnitEvent event;
96 event.receivedInMs = timestampLastUpdateInMs;
98 for (
const auto& [key, value] : jointAngleMap)
100 event.data[key].jointAngle = value;
103 for (
const auto& [key, value] : jointVelocityMap)
105 event.data[key].jointVelocity =
value;
108 for (
const auto& [key, value] : jointTorqueMap)
110 event.data[key].jointTorque =
value;
113 for (
const auto& [key, value] : jointAccelerationMap)
115 event.data[key].jointAcceleration =
value;
118 for (
const auto& [key, value] : jointCurrentMap)
120 event.data[key].current =
value;
123 for (
const auto& [key, value] : jointTemperatureMap)
125 event.data[key].temperature =
value;
128 for (
const auto& [key, value] : jointEnabledMap)
130 event.data[key].enabled =
value;
136 timestampLastUpdateInMs = 0;
154 std::lock_guard l(jointAngle_mutex);
155 double received = IceUtil::Time::now().toMilliSecondsDouble();
156 for (
const auto& [key, value] :
data)
158 jointAngleMap[key] = value;
162 std::lock_guard u(updatedMutex);
163 this->updated =
true;
164 this->timestampLastUpdateInMs = received;
174 std::lock_guard l(jointVelocity_mutex);
175 double received = IceUtil::Time::now().toMilliSecondsDouble();
176 for (
const auto& [key, value] :
data)
178 jointVelocityMap[key] = value;
182 std::lock_guard u(updatedMutex);
183 this->updated =
true;
184 this->timestampLastUpdateInMs = received;
194 std::lock_guard l(jointTorque_mutex);
195 double received = IceUtil::Time::now().toMilliSecondsDouble();
196 for (
const auto& [key, value] :
data)
198 jointTorqueMap[key] = value;
202 std::lock_guard u(updatedMutex);
203 this->updated =
true;
204 this->timestampLastUpdateInMs = received;
214 std::lock_guard l(jointAcceleration_mutex);
215 double received = IceUtil::Time::now().toMilliSecondsDouble();
216 for (
const auto& [key, value] :
data)
218 jointTorqueMap[key] = value;
222 std::lock_guard u(updatedMutex);
223 this->updated =
true;
224 this->timestampLastUpdateInMs = received;
234 std::lock_guard l(jointCurrent_mutex);
235 double received = IceUtil::Time::now().toMilliSecondsDouble();
236 for (
const auto& [key, value] :
data)
238 jointCurrentMap[key] = value;
242 std::lock_guard u(updatedMutex);
243 this->updated =
true;
244 this->timestampLastUpdateInMs = received;
250 const NameValueMap&
data,
255 std::lock_guard l(jointTemperature_mutex);
256 double received = IceUtil::Time::now().toMilliSecondsDouble();
257 for (
const auto& [key, value] :
data)
259 jointTemperatureMap[key] = value;
263 std::lock_guard u(updatedMutex);
264 this->updated =
true;
265 this->timestampLastUpdateInMs = received;
275 std::lock_guard l(jointEnabled_mutex);
276 double received = IceUtil::Time::now().toMilliSecondsDouble();
277 for (
const auto& [key, value] :
data)
279 jointEnabledMap[key] = value.enabled;
283 std::lock_guard u(updatedMutex);
284 this->updated =
true;
285 this->timestampLastUpdateInMs = received;
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()