25 #include <SimoxUtility/math/pose.h>
41 defs->optional(p.predictionsPerObject,
"predictions.NumberPerObject",
42 "How many predictions with increasing time offsets to make per object.");
44 defs->optional(p.millisecondPredictionIncrement,
"predictions.TimeIncrement",
45 "The size of the prediction time offset increment in milliseconds.");
52 return "ObjectPoseClientExample";
65 this->objectProcessingTaskRun();
67 objectProcessingTask->start();
79 void ObjectPoseClientExample::objectProcessingTaskRun()
83 while (objectProcessingTask && !objectProcessingTask->isStopped())
89 ARMARX_VERBOSE <<
"Received poses of " << objectPoses.size() <<
" objects.";
100 for (
const objpose::ObjectPose& objectPose : objectPoses)
103 .
pose(objectPose.objectPoseGlobal)
105 .
alpha(objectPose.confidence));
109 stage.
add(visualizePredictions(client, objectPoses));
112 cycle.waitForCycleDuration();
118 ObjectPoseClientExample::visualizePredictions(
const objpose::ObjectPoseClient& client,
123 objpose::ObjectPosePredictionRequestSeq requests;
124 for (
const objpose::ObjectPose& objectPose : objectPoses)
126 for (
int i = 0; i < p.predictionsPerObject; ++i)
128 objpose::ObjectPosePredictionRequest request;
129 toIce(request.objectID, objectPose.objectID);
130 request.settings.predictionEngineID =
"Linear Position Regression";
131 toIce(request.timestamp,
135 requests.push_back(request);
139 objpose::ObjectPosePredictionResultSeq results;
142 results = client.objectPoseStorage->predictObjectPoses(requests);
144 catch (
const Ice::LocalException& e)
146 ARMARX_INFO <<
"Failed to get predictions for object poses: " << e.what();
149 for (
size_t i = 0; i < results.size(); ++i)
151 const objpose::ObjectPosePredictionResult& result = results.at(i);
154 auto predictedPose = armarx::fromIce<objpose::ObjectPose>(result.prediction);
155 Eigen::Vector3f predictedPosition =
156 simox::math::position(predictedPose.objectPoseGlobal);
158 (p.predictionsPerObject - (
static_cast<int>(i) % p.predictionsPerObject)) *
159 255 / p.predictionsPerObject;
161 viz::Arrow(predictedPose.objectID.str() +
" Linear Prediction " +
163 .fromTo(simox::math::position(
164 objectPoses.at(i / p.predictionsPerObject).objectPoseGlobal),
170 ARMARX_INFO <<
"Prediction for object '" << result.prediction.objectID
171 <<
"' failed: " << result.errorMessage;