AbstractMotionModel.cpp
Go to the documentation of this file.
1 
2 #include "AbstractMotionModel.h"
3 
5 
7 {
8  std::unique_lock lock(motionPredictionLock);
9 
10  this->robotStateProxy = robotStateProxy;
11  poseAtLastLocalization = new armarx::LinkedPose();
12  predictedPoseAtStartOfCurrentLocalization = nullptr;
13  globalRobotPoseAtLastLocalization = nullptr;
14  uncertaintyAtLastLocalization = nullptr;
15  uncertaintyAtStartOfCurrentLocalization = nullptr;
16  timeOfLastLocalizationStart = new armarx::TimestampVariant(IceUtil::Time::now());
17  timeOfLastSuccessfulLocalization = new armarx::TimestampVariant(IceUtil::Time::now());
18 }
19 
20 
21 armarx::LinkedPoseBasePtr memoryx::AbstractMotionModel::getPredictedPose(const Ice::Current&)
22 {
23  std::unique_lock lock(motionPredictionLock);
24 
25  armarx::LinkedPosePtr ret = getPredictedPoseInternal();
26  return ret;
27 }
28 
29 
30 memoryx::MultivariateNormalDistributionBasePtr memoryx::AbstractMotionModel::getUncertainty(const Ice::Current&)
31 {
32  std::unique_lock lock(motionPredictionLock);
33 
34  MultivariateNormalDistributionBasePtr ret = getUncertaintyInternal();
35  return ret;
36 }
37 
38 
40  const armarx::LinkedPoseBasePtr& poseAtLastLocalization,
41  const armarx::PoseBasePtr& globalRobotPoseAtLastLocalization,
42  const memoryx::MultivariateNormalDistributionBasePtr& uncertaintyAtLastLocalization,
43  const Ice::Current&)
44 {
45  std::unique_lock lock(motionPredictionLock);
46  this->poseAtLastLocalization = poseAtLastLocalization;
47  timeOfLastSuccessfulLocalization = armarx::TimestampVariantPtr::dynamicCast(timeOfLastLocalizationStart->clone());
48 
49  if (globalRobotPoseAtLastLocalization)
50  {
51  this->globalRobotPoseAtLastLocalization = globalRobotPoseAtLastLocalization;
52  }
53 
54  if (uncertaintyAtLastLocalization)
55  {
56  this->uncertaintyAtLastLocalization = uncertaintyAtLastLocalization;
57  }
58 }
59 
60 
62 {
63  std::unique_lock lock(motionPredictionLock);
64 
65  predictedPoseAtStartOfCurrentLocalization = getPredictedPoseInternal();
66  uncertaintyAtStartOfCurrentLocalization = getUncertaintyInternal();
67  timeOfLastLocalizationStart = new armarx::TimestampVariant(IceUtil::Time::now());
68 }
69 
70 
72 {
73  return predictedPoseAtStartOfCurrentLocalization;
74 }
75 
76 
77 memoryx::MultivariateNormalDistributionBasePtr memoryx::AbstractMotionModel::getUncertaintyAtStartOfCurrentLocalization(const Ice::Current&)
78 {
79  return uncertaintyAtStartOfCurrentLocalization;
80 }
81 
82 
84 {
85  return ice_id();
86 }
87 
88 
90 {
91  if (motionModelName.compare("Static") == 0)
92  {
93  return eMotionModelStaticObject;
94  }
95  else if (motionModelName.compare("RobotHand") == 0)
96  {
97  return eMotionModelRobotHand;
98  }
99  else if (motionModelName.compare("AttachedToOtherObject") == 0)
100  {
101  return eMotionModelAttachedToOtherObject;
102  }
103  else if (motionModelName.compare("KBM") == 0)
104  {
105  return eMotionModelKBM;
106  }
107  else if (motionModelName.empty())
108  {
109  ARMARX_WARNING_S << "Motion model name is empty!";
110  return eMotionModelStaticObject;
111  }
112  else
113  {
114  ARMARX_WARNING_S << "Unknown motion model: " << motionModelName;
115  return eMotionModelStaticObject;
116  }
117 }
118 
119 
120 armarx::LinkedPoseBasePtr memoryx::AbstractMotionModel::getPoseAtLastLocalisation(const Ice::Current&)
121 {
122  std::unique_lock lock(motionPredictionLock);
123 
124  armarx::LinkedPoseBasePtr ret = poseAtLastLocalization;
125  return ret;
126 }
127 
128 
130 {
131 
132 }
armarx::aron::ret
ReaderT::InputType T & ret
Definition: rw.h:21
memoryx::AbstractMotionModel::savePredictedPoseAtStartOfCurrentLocalization
void savePredictedPoseAtStartOfCurrentLocalization(const Ice::Current &=Ice::emptyCurrent) override
Definition: AbstractMotionModel.cpp:61
armarx::TimestampVariant
Definition: TimestampVariant.h:54
memoryx::AbstractMotionModel::AbstractMotionModel
AbstractMotionModel()
Definition: AbstractMotionModel.cpp:129
memoryx::AbstractMotionModel::getPredictedPose
armarx::LinkedPoseBasePtr getPredictedPose(const Ice::Current &=Ice::emptyCurrent) override
Definition: AbstractMotionModel.cpp:21
memoryx::AbstractMotionModel::getUncertainty
MultivariateNormalDistributionBasePtr getUncertainty(const Ice::Current &=Ice::emptyCurrent) override
Definition: AbstractMotionModel.cpp:30
memoryx::AbstractMotionModel::getMotionModelTypeByName
static EMotionModelType getMotionModelTypeByName(std::string motionModelName)
Definition: AbstractMotionModel.cpp:89
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::VariantType::LinkedPose
const VariantTypeId LinkedPose
Definition: LinkedPose.h:43
memoryx::AbstractMotionModel::getMotionModelName
virtual std::string getMotionModelName()
Definition: AbstractMotionModel.cpp:83
memoryx::AbstractMotionModel::getUncertaintyAtStartOfCurrentLocalization
MultivariateNormalDistributionBasePtr getUncertaintyAtStartOfCurrentLocalization(const Ice::Current &=Ice::emptyCurrent) override
Definition: AbstractMotionModel.cpp:77
memoryx::AbstractMotionModel::setPoseAtLastLocalisation
void setPoseAtLastLocalisation(const armarx::LinkedPoseBasePtr &poseAtLastLocalization, const armarx::PoseBasePtr &globalRobotPoseAtLastLocalization, const MultivariateNormalDistributionBasePtr &uncertaintyAtLastLocalization, const Ice::Current &=Ice::emptyCurrent) override
Definition: AbstractMotionModel.cpp:39
ARMARX_WARNING_S
#define ARMARX_WARNING_S
Definition: Logging.h:206
memoryx::AbstractMotionModel::getPredictedPoseAtStartOfCurrentLocalization
armarx::LinkedPoseBasePtr getPredictedPoseAtStartOfCurrentLocalization(const Ice::Current &=Ice::emptyCurrent) override
Definition: AbstractMotionModel.cpp:71
memoryx::AbstractMotionModel::motionPredictionLock
std::recursive_mutex motionPredictionLock
Definition: AbstractMotionModel.h:95
AbstractMotionModel.h
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
Logging.h
memoryx::AbstractMotionModel::getPoseAtLastLocalisation
armarx::LinkedPoseBasePtr getPoseAtLastLocalisation(const Ice::Current &=Ice::emptyCurrent) override
Definition: AbstractMotionModel.cpp:120
memoryx::AbstractMotionModel::EMotionModelType
EMotionModelType
Definition: AbstractMotionModel.h:42