32 #include <RobotAPI/libraries/armem_robot_state/aron/Proprioception.aron.generated.h>
33 #include <RobotAPI/libraries/armem_robot_state/aron/Transform.aron.generated.h>
50 std::vector<armem::MemoryID>
65 RobotStatePredictionClient::_queryEntityIDs(
const std::string& coreSegmentName)
89 std::vector<armem::PredictionRequest>
91 const std::vector<armem::MemoryID>& entityIDs,
93 const std::string& engineID)
95 std::vector<armem::PredictionRequest> requests;
96 requests.reserve(entityIDs.size());
108 std::vector<PredictionResult>
111 const std::string& engineID)
113 const std::vector<PredictionRequest> requests =
119 std::vector<PredictionResult>
128 std::optional<Eigen::Affine3f>
130 const std::vector<armem::PredictionResult>& localizationPredictionResults,
131 const std::vector<armem::MemoryID>& localizationEntityIDs,
134 ARMARX_CHECK_EQUAL(localizationPredictionResults.size(), localizationEntityIDs.size());
135 std::stringstream errorMessages;
137 namespace loc = armem::robot_state::localization;
139 std::optional<armem::wm::CoreSegment> coreSegment;
141 loc::TransformQuery query;
144 query.header.agent =
"";
145 query.header.timestamp = predictedTime;
147 for (
size_t i = 0; i < localizationPredictionResults.size(); ++i)
154 if (query.header.agent.empty())
156 const arondto::Transform tf = arondto::Transform::FromAron(result.
prediction);
157 query.header.agent = tf.header.agent;
165 update.entityID = entityID;
166 update.referencedTime = predictedTime;
168 coreSegment->update(
update);
173 errorMessages <<
"Prediction of '" << entityID <<
"'"
178 std::optional<Eigen::Affine3f> result;
179 if (coreSegment.has_value())
181 loc::TransformResult tf =
182 loc::TransformHelper::lookupTransform(coreSegment.value(), query);
186 result = tf.transform.transform;
190 errorMessages <<
"\nFailed to lookup transform: " << tf.errorMessage <<
"\n";
194 if (not errorMessages.str().empty())
202 std::optional<std::map<std::string, float>>
204 const std::vector<PredictionResult>& proprioceptionPredictionResults,
205 const std::string& robotName)
207 auto it = std::find_if(proprioceptionPredictionResults.begin(),
208 proprioceptionPredictionResults.end(),
210 { return result.snapshotID.entityName == robotName; });
211 if (it != proprioceptionPredictionResults.end())
214 auto prop = armem::arondto::Proprioception::FromAron(result.
prediction);
215 return prop.joints.position;
224 std::optional<Eigen::Affine3f>
227 const std::string& engineID)
229 const std::vector<PredictionResult> results =
predict(entityIDs, predictedTime, engineID);
230 std::optional<Eigen::Affine3f> pose =
lookupGlobalPose(results, entityIDs, predictedTime);
235 std::optional<std::map<std::string, float>>
238 const std::string& robotName,
239 const std::string& engineID)
241 const std::vector<PredictionResult> results =
predict(entityIDs, predictedTime, engineID);
248 const std::vector<armem::MemoryID>& propEntityIDs,
250 const std::string& robotName,
251 const std::string& engineID)
256 const std::vector<armem::MemoryID> entityIDs =
259 if (entityIDs.empty())
264 auto _results =
predict(entityIDs, predictedTime,
"Linear");
267 std::vector<armem::PredictionResult> locResults, propResults;