Skip to content
Snippets Groups Projects
Commit f6643d65 authored by Fabian Reister's avatar Fabian Reister
Browse files

memory subscriber: subscriptions via topic

parent 745b4ffa
No related branches found
No related tags found
No related merge requests found
......@@ -27,12 +27,37 @@ namespace armarx::navigation::client
ARMARX_INFO << "MemorySubscriber: will handle all events newer than " << lastMemoryPoll
<< ".";
// subscription api
armem::MemoryID subscriptionID;
subscriptionID.coreSegmentName = "Events";
subscriptionID.providerSegmentName = callerId;
// TODO add: memoryNameSystem.subscribe(subscriptionID, this, &MemorySubscriber::onEntityUpdate);
// polling api
ARMARX_TRACE;
task = new armarx::PeriodicTask<MemorySubscriber>(
this, &MemorySubscriber::runPollMemoryEvents, 20);
task->start();
}
void
MemorySubscriber::onEntityUpdate(const armem::MemoryID& subscriptionID,
const std::vector<armem::MemoryID>& snapshotIDs)
{
ARMARX_INFO << "Received " << snapshotIDs.size() << " events from memory";
const armem::client::QueryResult qResult = memoryReader.queryMemoryIDs(snapshotIDs);
if (not qResult.success) /* c++20 [[unlikely]] */
{
ARMARX_WARNING << deactivateSpam(0.1F) << "Memory lookup failed.";
return;
}
handleEvents(qResult.memory);
}
void
MemorySubscriber::handleEvent(const armem::wm::EntityInstance& memoryEntity)
{
......
......@@ -38,6 +38,10 @@ namespace armarx::navigation::client
void runPollMemoryEvents();
void handleEvents(const armem::wm::Memory& memory);
void onEntityUpdate(const armem::MemoryID& subscriptionID,
const std::vector<armem::MemoryID>& snapshotIDs);
private:
const std::string callerId;
armem::client::MemoryNameSystem& memoryNameSystem;
......
......@@ -50,6 +50,7 @@
#include "RobotAPI/components/ArViz/Client/Elements.h"
#include "RobotAPI/components/ArViz/Client/elements/Color.h"
#include "RobotAPI/libraries/armem/core/MemoryID.h"
#include "RobotAPI/libraries/armem/core/Time.h"
#include "RobotAPI/libraries/armem_vision/OccupancyGridHelper.h"
#include "RobotAPI/libraries/armem_vision/client/occupancy_grid/Reader.h"
......@@ -163,7 +164,6 @@ namespace armarx::navigation::components
navRemoteGui = std::make_unique<NavigatorRemoteGui>(remoteGui, *this);
navRemoteGui->enable();
initialized = true;
ARMARX_INFO << "Initialized. Will now respond to navigation requests.";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment