33 def->topic<PlatformUnitListener>(
"Armar6PlatformUnit",
"PlatformUnitName");
34 def->optional(frequency,
"UpdateFrequency",
"Frequency of updates in Hz");
40 return "SimpleEpisodicMemoryPlatformUnitConnector";
46 timestampLastUpdateInMs_pose(0),
47 updated_target(false),
48 timestampLastUpdateInMs_target(0)
64 &SimpleEpisodicMemoryPlatformUnitConnector::checkAndSendToMemory, (1.0f / frequency * 1000));
65 periodic_task->start();
71 periodic_task->stop();
80 void SimpleEpisodicMemoryPlatformUnitConnector::checkAndSendToMemory()
82 std::lock_guard l(platformPose_mutex);
83 std::lock_guard ll(platformTarget_mutex);
84 std::lock_guard lll(platformAcceleration_mutex);
87 std::lock_guard u(updatedMutex_pose);
88 if (updated_pose && timestampLastUpdateInMs_pose != 0)
90 memoryx::PlatformUnitEvent event;
91 event.receivedInMs = timestampLastUpdateInMs_pose;
98 event.acc_rot = acc_rot;
102 updated_pose =
false;
103 timestampLastUpdateInMs_pose = 0;
108 std::lock_guard u(updatedMutex_target);
109 if (updated_target && timestampLastUpdateInMs_target != 0)
111 memoryx::PlatformUnitTargetEvent event;
112 event.receivedInMs = timestampLastUpdateInMs_target;
114 event.target_x = goal_x;
115 event.target_y = goal_y;
116 event.target_rot = goal_rot;
120 updated_target =
false;
121 timestampLastUpdateInMs_target = 0;
129 std::lock_guard l(platformPose_mutex);
130 std::lock_guard u(updatedMutex_pose);
131 double received = IceUtil::Time::now().toMilliSecondsDouble();
134 rot = pose.rotationAroundZ;
136 timestampLastUpdateInMs_pose = received;
141 std::lock_guard l(platformTarget_mutex);
142 std::lock_guard u(updatedMutex_target);
143 double received = IceUtil::Time::now().toMilliSecondsDouble();
147 updated_target =
true;
148 timestampLastUpdateInMs_target = received;
153 std::lock_guard l(platformAcceleration_mutex);
154 std::lock_guard u(updatedMutex_pose);
155 double received = IceUtil::Time::now().toMilliSecondsDouble();
160 timestampLastUpdateInMs_pose = received;