ObjectInstance.h
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package MemoryX::Core
17 * @author ALexey Kozlov ( kozlov at kit dot edu), Kai Welke (welke at kit got edu)
18 * @date 2012
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #pragma once
24 
26 #include <MemoryX/interface/core/EntityBase.h>
27 #include <MemoryX/interface/memorytypes/MemoryEntities.h>
28 
31 
33 
34 namespace armarx
35 {
36  template <class IceBaseClass, class DerivedClass> class GenericFactory;
37 }
38 
39 namespace memoryx
40 {
41  class ObjectInstance;
43 
44  class AbstractMotionModel;
46 
48  public memoryx::ObjectInstanceBase,
49  public memoryx::Entity
50  {
51  template <class IceBaseClass, class DerivedClass>
52  friend class armarx::GenericFactory;
53  public:
54 
55  /**
56  * Constructs a new ObjectInstance WorkingMemory entity. A name needs to be assigned. The id is optional.
57  *
58  * @param name friendly name of the instance
59  * @param id optional id of the instance
60  **/
61  ObjectInstance(const std::string& name, const std::string& id = "");
63 
64  /**
65  * Retrieve existence certainty for this instance. The existence certainty encodes how likely the scene containes this instance at the given position and orientation.
66  * The existence certainty represents the current believe for the instance's existance in the dynamic inference process. Values lie in the interval [0:1], where 1 means
67  * perfect knowledge.
68  *
69  * @return existance certainty as probability
70  **/
71  float getExistenceCertainty(const ::Ice::Current& = Ice::emptyCurrent) const override;
72 
73  /**
74  * Set existence certainty for this instance. The existence certainty encodes how likely the scene containes this instance at the given position and orientation.
75  * The existence certainty represents the current believe for the instance's existance in the dynamic inference process. Values lie in the interval [0:1], where 1 means
76  * perfect knowledge.
77  *
78  * @param existanceCertainty existance certainty as probability
79  **/
80  void setExistenceCertainty(float existenceCertainty, const ::Ice::Current& = Ice::emptyCurrent) override;
81 
82 
83  int getLocalizationPriority(const ::Ice::Current& = Ice::emptyCurrent) const override;
84 
85  void setLocalizationPriority(Ice::Int priority, const ::Ice::Current& = Ice::emptyCurrent) override;
86 
87 
88 
89  /**
90  * Retrieve attribute which holds instance position.
91  *
92  * @return attribute holding mean value of position as well as probability distribution
93  **/
94  EntityAttributeBasePtr getPositionAttribute() const;
95 
96  /**
97  * Retrieve position of the instance.
98  *
99  * @return position linked to a named coordinate frame
100  **/
102 
103  /**
104  * Set position of the instance.
105  *
106  * @param orientation position linked to a named coordinate frame
107  **/
108  void setPosition(const armarx::FramedPositionBasePtr& position, const ::Ice::Current& = Ice::emptyCurrent) override;
109  void setLocalizationTimestamp(const IceUtil::Time& timestamp);
110  void setLocalizationTimestamp(const armarx::TimestampBasePtr& timestamp);
111  bool hasLocalizationTimestamp() const;
113 
114  /**
115  * Get uncertainty of position estimate.
116  *
117  * @return 3 dimensional multivariate normal distribution with mean at the position
118  **/
119  MultivariateNormalDistributionBasePtr getPositionUncertainty(const ::Ice::Current& = Ice::emptyCurrent) const override;
120 
121  /**
122  * Set uncertainty of position estimate.
123  *
124  * @param uncertainty 3 dimensional multivariate normal distribution with mean at the position
125  **/
126  void setPositionUncertainty(const MultivariateNormalDistributionBasePtr& uncertainty, const ::Ice::Current& = Ice::emptyCurrent) override;
127 
128  /**
129  * Retrieve attribute which holds instance position.
130  *
131  * @return attribute holding mean value of position as well as probability distribution
132  **/
133  EntityAttributeBasePtr getOrientationAttribute() const;
134 
135  /**
136  * Retrieve orientation of the instance.
137  *
138  * @return orientation linked to a named coordinate frame
139  **/
141 
142  /**
143  * Set orientation of the instance.
144  *
145  * @param orientation orientation linked to a named coordinate frame
146  **/
147  void setOrientation(const armarx::FramedOrientationBasePtr& orientation, const ::Ice::Current& = Ice::emptyCurrent) override;
148 
149  /**
150  * @brief Convenience function to get position and orientation attributes at once
151  * @return current pose
152  */
154 
155  /**
156  * @brief Convenience function to set position and orientation attributes at once
157  * @param newPose New Pose to set
158  */
159  void setPose(const armarx::FramedPoseBasePtr& newPose);
160 
161  /**
162  * Retrieve classes and associated class membership probability for this instance
163  *
164  * @return map of class names and probabilities
165  **/
166  ClassProbabilityMap getClasses(const ::Ice::Current& = Ice::emptyCurrent) const override;
167 
168  /**
169  * Set the class attribute of the ObjectInstance. Corresponds to calling clearClasses() and addClass(...).
170  *
171  * @param className name of the class
172  * @param probability probability of class membership
173  **/
174  void setClass(const std::string& className, float probability, const Ice::Current& = Ice::emptyCurrent) override;
175 
176  /**
177  * Adds new class membership to the class attribute
178  *
179  * @param className name of the class
180  * @param probability probability of class membership
181  **/
182  void addClass(const std::string& className, float probability, const Ice::Current& = Ice::emptyCurrent) override;
183 
184  /**
185  * Clear class membership
186  **/
187  void clearClasses(const Ice::Current& = Ice::emptyCurrent) override;
188 
189  /**
190  * Retrieve the class with highest membership probability
191  *
192  * @return className
193  **/
194  ::std::string getMostProbableClass(const ::Ice::Current& = Ice::emptyCurrent) const override;
195 
196  /**
197  * Retrieve membership probability for a given class
198  *
199  * @param className
200  **/
201  float getClassProbability(const ::std::string& className, const ::Ice::Current& = Ice::emptyCurrent) const override;
202 
203  /**
204  * Set the motion model for this object
205  *
206  * @param motionModel The motion model
207  **/
210 
211  // TODO: cloning will probabily also not work without the implementation of a copy constructor
212  Ice::ObjectPtr ice_clone() const override;
213  ObjectInstancePtr clone(const Ice::Current& c = Ice::emptyCurrent) const;
214 
215  protected:
216  // ice interface implementation on Base data types. Replaces in c++ by derived instance getters, setters (see above)
217  armarx::FramedPositionBasePtr getPositionBase(const ::Ice::Current& = Ice::emptyCurrent) const override;
218  armarx::FramedOrientationBasePtr getOrientationBase(const ::Ice::Current& = Ice::emptyCurrent) const override;
219 
221 
222  private:
223  ObjectInstance();
224  void output(std::ostream& stream) const;
225 
226  public: // streaming operator
227  friend std::ostream& operator<<(std::ostream& stream, const ObjectInstance& rhs)
228  {
229  rhs.output(stream);
230  return stream;
231  }
232 
233  friend std::ostream& operator<<(std::ostream& stream, const ObjectInstancePtr& rhs)
234  {
235  rhs->output(stream);
236  return stream;
237  }
238 
239  friend std::ostream& operator<<(std::ostream& stream, const ObjectInstanceBasePtr& rhs)
240  {
241  stream << ObjectInstancePtr::dynamicCast(rhs);
242  return stream;
243  }
244 
245 
246 
247  };
248 
249 }
250 
memoryx::ObjectInstance::hasLocalizationTimestamp
bool hasLocalizationTimestamp() const
Definition: ObjectInstance.cpp:125
memoryx::ObjectInstance::setLocalizationPriority
void setLocalizationPriority(Ice::Int priority, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ObjectInstance.cpp:147
memoryx::ObjectInstance::getOrientation
armarx::FramedOrientationPtr getOrientation() const
Retrieve orientation of the instance.
Definition: ObjectInstance.cpp:172
memoryx::ObjectInstance::getExistenceCertainty
float getExistenceCertainty(const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve existence certainty for this instance.
Definition: ObjectInstance.cpp:69
Pose.h
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
memoryx::ObjectInstance::getPositionAttribute
EntityAttributeBasePtr getPositionAttribute() const
Retrieve attribute which holds instance position.
Definition: ObjectInstance.cpp:81
memoryx::ObjectInstance
Definition: ObjectInstance.h:47
memoryx::ObjectInstance::setLocalizationTimestamp
void setLocalizationTimestamp(const IceUtil::Time &timestamp)
Definition: ObjectInstance.cpp:115
memoryx::ObjectInstance::setPose
void setPose(const armarx::FramedPoseBasePtr &newPose)
Convenience function to set position and orientation attributes at once.
Definition: ObjectInstance.cpp:190
memoryx::ObjectInstance::setMotionModel
void setMotionModel(AbstractMotionModelPtr motionModel)
Set the motion model for this object.
Definition: ObjectInstance.cpp:289
memoryx::ObjectInstance::operator<<
friend std::ostream & operator<<(std::ostream &stream, const ObjectInstance &rhs)
Definition: ObjectInstance.h:227
memoryx::ObjectInstance::getPositionUncertainty
MultivariateNormalDistributionBasePtr getPositionUncertainty(const ::Ice::Current &=Ice::emptyCurrent) const override
Get uncertainty of position estimate.
Definition: ObjectInstance.cpp:153
memoryx::ObjectInstance::operator<<
friend std::ostream & operator<<(std::ostream &stream, const ObjectInstanceBasePtr &rhs)
Definition: ObjectInstance.h:239
memoryx::ObjectInstance::getClasses
ClassProbabilityMap getClasses(const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve classes and associated class membership probability for this instance.
Definition: ObjectInstance.cpp:198
memoryx::ObjectInstance::getMotionModel
AbstractMotionModelPtr getMotionModel() const
Definition: ObjectInstance.cpp:296
memoryx::ObjectInstance::getLocalizationPriority
int getLocalizationPriority(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ObjectInstance.cpp:138
IceInternal::Handle< ObjectInstance >
memoryx::ObjectInstance::addClass
void addClass(const std::string &className, float probability, const Ice::Current &=Ice::emptyCurrent) override
Adds new class membership to the class attribute.
Definition: ObjectInstance.cpp:238
memoryx::ObjectInstance::setPositionUncertainty
void setPositionUncertainty(const MultivariateNormalDistributionBasePtr &uncertainty, const ::Ice::Current &=Ice::emptyCurrent) override
Set uncertainty of position estimate.
Definition: ObjectInstance.cpp:159
memoryx::ObjectInstance::getPosition
armarx::FramedPositionPtr getPosition() const
Retrieve position of the instance.
Definition: ObjectInstance.cpp:87
FramedPose.h
memoryx::ObjectInstance::operator<<
friend std::ostream & operator<<(std::ostream &stream, const ObjectInstancePtr &rhs)
Definition: ObjectInstance.h:233
memoryx::ObjectInstance::setClass
void setClass(const std::string &className, float probability, const Ice::Current &=Ice::emptyCurrent) override
Set the class attribute of the ObjectInstance.
Definition: ObjectInstance.cpp:219
memoryx::ObjectInstance::getLocalizationTimestamp
IceUtil::Time getLocalizationTimestamp() const
Definition: ObjectInstance.cpp:130
memoryx::AbstractMotionModel
Definition: AbstractMotionModel.h:39
memoryx::ObjectInstance::clearClasses
void clearClasses(const Ice::Current &=Ice::emptyCurrent) override
Clear class membership.
Definition: ObjectInstance.cpp:247
memoryx::ObjectInstance::motionModel
AbstractMotionModelPtr motionModel
Definition: ObjectInstance.h:220
memoryx::ObjectInstance::setPosition
void setPosition(const armarx::FramedPositionBasePtr &position, const ::Ice::Current &=Ice::emptyCurrent) override
Set position of the instance.
Definition: ObjectInstance.cpp:93
memoryx::ObjectInstance::getMostProbableClass
::std::string getMostProbableClass(const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve the class with highest membership probability.
Definition: ObjectInstance.cpp:257
boost::source
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:681
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
memoryx::ObjectInstance::getPose
armarx::FramedPosePtr getPose() const
Convenience function to get position and orientation attributes at once.
Definition: ObjectInstance.cpp:183
memoryx::ObjectInstance::getOrientationBase
armarx::FramedOrientationBasePtr getOrientationBase(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ObjectInstance.cpp:339
memoryx::ObjectInstance::getOrientationAttribute
EntityAttributeBasePtr getOrientationAttribute() const
Retrieve attribute which holds instance position.
Definition: ObjectInstance.cpp:166
Entity.h
memoryx::ObjectInstance::setExistenceCertainty
void setExistenceCertainty(float existenceCertainty, const ::Ice::Current &=Ice::emptyCurrent) override
Set existence certainty for this instance.
Definition: ObjectInstance.cpp:75
memoryx::ObjectInstance::ice_clone
Ice::ObjectPtr ice_clone() const override
Definition: ObjectInstance.cpp:302
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:916
memoryx::ObjectInstance::clone
ObjectInstancePtr clone(const Ice::Current &c=Ice::emptyCurrent) const
Definition: ObjectInstance.cpp:307
armarx::GenericFactory
Definition: FactoryCollectionBase.h:51
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
memoryx::ObjectInstance::getPositionBase
armarx::FramedPositionBasePtr getPositionBase(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ObjectInstance.cpp:334
memoryx::Entity
Definition: Entity.h:246
Variant.h
memoryx::ObjectInstance::setOrientation
void setOrientation(const armarx::FramedOrientationBasePtr &orientation, const ::Ice::Current &=Ice::emptyCurrent) override
Set orientation of the instance.
Definition: ObjectInstance.cpp:178
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
memoryx::ObjectInstance::getClassProbability
float getClassProbability(const ::std::string &className, const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve membership probability for a given class.
Definition: ObjectInstance.cpp:273