Skip to content
Snippets Groups Projects
Commit c9e4cbb4 authored by Philip Scherer's avatar Philip Scherer
Browse files

Migrate RobotStateMemory predictions

parent f95f6c8a
No related branches found
No related tags found
1 merge request!265Robot state predictions
......@@ -205,32 +205,6 @@ namespace armarx::armem::server::robot_state
return { new Pose(poseMap[robotName].matrix()) };
}
armem::prediction::data::PredictionResultSeq
RobotStateMemory::predict(const armem::prediction::data::PredictionRequestSeq& requests)
{
std::vector<armem::prediction::data::PredictionResult> results;
for (const auto& request : requests)
{
auto boRequest = armarx::fromIce<armem::PredictionRequest>(request);
armem::PredictionResult result;
if (armem::contains(workingMemory().id().withCoreSegmentName("Proprioception"),
boRequest.snapshotID) &&
!boRequest.snapshotID.hasGap() && boRequest.snapshotID.hasTimestamp())
{
result = proprioceptionSegment.predict(boRequest);
}
else
{
result.success = false;
result.errorMessage << "No predictions are supported for MemoryID "
<< boRequest.snapshotID;
}
results.push_back(result.toIce());
}
return results;
}
/*************************************************************/
// RobotUnit Streaming functions
/*************************************************************/
......
......@@ -79,11 +79,6 @@ namespace armarx::armem::server::robot_state
// GlobalRobotPoseProvider interface
armarx::PoseBasePtr getGlobalRobotPose(Ice::Long timestamp, const std::string& robotName, const ::Ice::Current&) override;
using ReadWritePluginUser::predict;
armem::prediction::data::PredictionResultSeq
predict(const armem::prediction::data::PredictionRequestSeq& requests) override;
protected:
......
......@@ -42,6 +42,7 @@ namespace armarx::armem::server::wm::detail
{
public:
explicit Prediction(const std::map<std::string, Predictor>& predictors = {})
: _predictors(predictors)
{
}
......@@ -119,6 +120,11 @@ namespace armarx::armem::server::wm::detail
public:
using Prediction<DerivedT>::Prediction;
explicit PredictionContainer(const std::map<std::string, Predictor>& predictors = {})
: Prediction<DerivedT>(predictors)
{
}
std::vector<PredictionResult>
dispatchPredictions(const std::vector<PredictionRequest>& requests)
{
......
......@@ -39,6 +39,14 @@ namespace armarx::armem::server::robot_state::proprioception
" when requested via the PredictingMemoryInterface (in seconds).");
}
void Segment::init()
{
Base::init();
segmentPtr->addPredictor(
"Linear", [this](const PredictionRequest& request) { return this->predict(request); });
}
void Segment::onConnect(RobotUnitInterfacePrx robotUnitPrx)
{
this->robotUnit = robotUnitPrx;
......
......@@ -55,6 +55,8 @@ namespace armarx::armem::server::robot_state::proprioception
void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string& prefix = "") override;
void init() override;
void onConnect(RobotUnitInterfacePrx robotUnitPrx);
......
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