29#include <SimoxUtility/math/convert/rpy_to_mat3f.h>
38#include <RobotAPI/libraries/armem_robot_state/aron/Proprioception.aron.generated.h>
55 toDurationMs(std::chrono::high_resolution_clock::time_point start,
56 std::chrono::high_resolution_clock::time_point end)
58 auto duration = std::chrono::duration_cast<std::chrono::microseconds>(end - start);
59 return duration.count() / 1000.f;
74 size_t dataBufferSize = dataBuffer.size();
75 debugObserver->setDebugObserverDatafield(
"RobotStateWriter | Queue Size",
76 static_cast<long>(dataBufferSize));
78 if (
static_cast<long>(dataBufferSize) >
properties.queueSizeWarningThreshold)
81 <<
"RobotStateWriter queue size (" << dataBufferSize
82 <<
") exceeds threshold ("
84 <<
"). The writer is not keeping up with incoming data.";
89 if (
const auto status = dataBuffer.wait_pull(robotUnitData);
90 status == boost::queue_op_status::success)
92 auto start = std::chrono::high_resolution_clock::now();
93 auto endBuildUpdate = start, endProprioception = start, endLocalization = start;
96 endBuildUpdate = std::chrono::high_resolution_clock::now();
102 memory.commitLocking(update.proprioception);
106 memory.commitLocking(update.exteroception);
107 endProprioception = std::chrono::high_resolution_clock::now();
115 endLocalization = std::chrono::high_resolution_clock::now();
119 ARMARX_WARNING <<
"Could not commit data to proprioception segment in memory. "
126 ARMARX_WARNING <<
"Could not commit data to exteroception segment in memory. "
133 auto end = std::chrono::high_resolution_clock::now();
135 debugObserver->setDebugObserverDatafield(
"RobotStateWriter | t Commit (ms)",
136 toDurationMs(start, end));
138 "RobotStateWriter | t Commit 1. Build Update (ms)",
139 toDurationMs(start, endBuildUpdate));
141 "RobotStateWriter | t Commit 2. Proprioception (ms)",
142 toDurationMs(endBuildUpdate, endProprioception));
144 "RobotStateWriter | t Commit 3. Localization (ms)",
145 toDurationMs(endProprioception, endLocalization));
151 <<
static_cast<std::underlying_type<boost::queue_op_status>::type
>(
163 RobotStateWriter::isRunning()
168 RobotStateWriter::Update
174 if (
data.proprioception)
177 up.entityID =
properties.robotUnitProviderID.withEntityName(
178 properties.robotUnitProviderID.providerSegmentName);
179 up.entityID.coreSegmentName =
181 up.referencedTime =
data.timestamp;
182 up.arrivedTime =
data.timestampArrived;
183 up.instancesData = {
data.proprioception};
187 if (
data.exteroception)
190 up.entityID =
properties.robotUnitProviderID.withEntityName(
191 properties.robotUnitProviderID.providerSegmentName);
192 up.entityID.coreSegmentName =
194 up.referencedTime =
data.timestamp;
195 up.instancesData = {
data.exteroception};
200 const std::string platformKey =
"platform";
201 if (
data.proprioception->hasElement(platformKey))
206 update.localization.emplace_back(getTransform(platformData,
data.timestamp));
211 <<
"(No element '" << platformKey <<
"' in proprioception data.)"
212 <<
"\nIf you are using a mobile platform this should not have happened."
213 <<
"\nThis error is only logged once."
214 <<
"\nThese keys exist: " <<
data.proprioception->getAllKeys();
215 noOdometryDataLogged =
true;
225 prop::arondto::Platform platform;
226 platform.fromAron(platformData);
228 const Eigen::Vector3f& relPose = platform.relativePosition;
230 Eigen::Isometry3f odometryPose = Eigen::Isometry3f::Identity();
231 odometryPose.translation() << relPose.x(), relPose.y(), 0;
232 odometryPose.linear() = simox::math::rpy_to_mat3f(0.f, 0.f, relPose.z());
Brief description of class DebugObserverHelper.
const DebugObserverInterfacePrx & getDebugObserver() const
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.
bool isStopped()
Retrieve whether stop() has been called.
std::string providerSegmentName
Helps connecting a Memory server to the Ice interface.
bool commitTransformLocking(const armem::robot_state::localization::Transform &transform)
std::optional< DebugObserverHelper > debugObserver
Update buildUpdate(const RobotUnitData &dataQueue)
void connect(armarx::plugins::DebugObserverComponentPlugin &debugObserverPlugin)
void run(float pollFrequency, Queue &dataBuffer, MemoryToIceAdapter &memory, localization::Segment &localizationSegment)
Reads data from dataQueue and commits to the memory.
armarx::armem::server::robot_state::proprioception::Queue Queue
armarx::SimpleRunningTask ::pointer_type task
static PointerType DynamicCastAndCheck(const VariantPtr &n)
Brief description of class memory.
Brief description of class DebugObserverComponentPlugin.
#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...
#define ARMARX_INFO
The normal logging level.
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
const std::string robotRootNodeName
const std::string proprioceptionCoreSegment
const std::string exteroceptionCoreSegment
armarx::core::time::DateTime Time
std::shared_ptr< Dict > DictPtr
std::string const OdometryFrame
auto transform(const Container< InputT, Alloc > &in, OutputT(*func)(InputT const &)) -> Container< OutputT, typename std::allocator_traits< Alloc >::template rebind_alloc< OutputT > >
Convenience function (with less typing) to transform a container of type InputT into the same contain...
std::vector< std::string > allErrorMessages() const
An update of an entity for a specific point in time.
armem::MemoryID robotUnitProviderID