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
29
31#include <MemoryX/interface/core/EntityBase.h>
32#include <MemoryX/interface/memorytypes/MemoryEntities.h>
33
34namespace armarx
35{
36 template <class IceBaseClass, class DerivedClass>
37 class GenericFactory;
38}
39
40namespace memoryx
41{
42 class ObjectInstance;
44
47
48 class ObjectInstance : public memoryx::ObjectInstanceBase, public memoryx::Entity
49 {
50 template <class IceBaseClass, class DerivedClass>
52
53 public:
54 /**
55 * Constructs a new ObjectInstance WorkingMemory entity. A name needs to be assigned. The id is optional.
56 *
57 * @param name friendly name of the instance
58 * @param id optional id of the instance
59 **/
60 ObjectInstance(const std::string& name, const std::string& id = "");
61 ObjectInstance(const ObjectInstance& source);
62
63 /**
64 * Retrieve existence certainty for this instance. The existence certainty encodes how likely the scene containes this instance at the given position and orientation.
65 * 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
66 * perfect knowledge.
67 *
68 * @return existance certainty as probability
69 **/
70 float getExistenceCertainty(const ::Ice::Current& = Ice::emptyCurrent) const override;
71
72 /**
73 * Set existence certainty for this instance. The existence certainty encodes how likely the scene containes this instance at the given position and orientation.
74 * 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
75 * perfect knowledge.
76 *
77 * @param existanceCertainty existance certainty as probability
78 **/
79 void setExistenceCertainty(float existenceCertainty,
80 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,
86 const ::Ice::Current& = Ice::emptyCurrent) override;
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,
109 const ::Ice::Current& = Ice::emptyCurrent) override;
110 void setLocalizationTimestamp(const IceUtil::Time& timestamp);
111 void setLocalizationTimestamp(const armarx::TimestampBasePtr& timestamp);
112 bool hasLocalizationTimestamp() const;
113 IceUtil::Time getLocalizationTimestamp() const;
114
115 /**
116 * Get uncertainty of position estimate.
117 *
118 * @return 3 dimensional multivariate normal distribution with mean at the position
119 **/
120 MultivariateNormalDistributionBasePtr
121 getPositionUncertainty(const ::Ice::Current& = Ice::emptyCurrent) const override;
122
123 /**
124 * Set uncertainty of position estimate.
125 *
126 * @param uncertainty 3 dimensional multivariate normal distribution with mean at the position
127 **/
128 void setPositionUncertainty(const MultivariateNormalDistributionBasePtr& uncertainty,
129 const ::Ice::Current& = Ice::emptyCurrent) override;
130
131 /**
132 * Retrieve attribute which holds instance position.
133 *
134 * @return attribute holding mean value of position as well as probability distribution
135 **/
136 EntityAttributeBasePtr getOrientationAttribute() const;
137
138 /**
139 * Retrieve orientation of the instance.
140 *
141 * @return orientation linked to a named coordinate frame
142 **/
144
145 /**
146 * Set orientation of the instance.
147 *
148 * @param orientation orientation linked to a named coordinate frame
149 **/
150 void setOrientation(const armarx::FramedOrientationBasePtr& orientation,
151 const ::Ice::Current& = Ice::emptyCurrent) override;
152
153 /**
154 * @brief Convenience function to get position and orientation attributes at once
155 * @return current pose
156 */
158
159 /**
160 * @brief Convenience function to set position and orientation attributes at once
161 * @param newPose New Pose to set
162 */
163 void setPose(const armarx::FramedPoseBasePtr& newPose);
164
165 /**
166 * Retrieve classes and associated class membership probability for this instance
167 *
168 * @return map of class names and probabilities
169 **/
170 ClassProbabilityMap getClasses(const ::Ice::Current& = Ice::emptyCurrent) const override;
171
172 /**
173 * Set the class attribute of the ObjectInstance. Corresponds to calling clearClasses() and addClass(...).
174 *
175 * @param className name of the class
176 * @param probability probability of class membership
177 **/
178 void setClass(const std::string& className,
179 float probability,
180 const Ice::Current& = Ice::emptyCurrent) override;
181
182 /**
183 * Adds new class membership to the class attribute
184 *
185 * @param className name of the class
186 * @param probability probability of class membership
187 **/
188 void addClass(const std::string& className,
189 float probability,
190 const Ice::Current& = Ice::emptyCurrent) override;
191
192 /**
193 * Clear class membership
194 **/
195 void clearClasses(const Ice::Current& = Ice::emptyCurrent) override;
196
197 /**
198 * Retrieve the class with highest membership probability
199 *
200 * @return className
201 **/
202 ::std::string
203 getMostProbableClass(const ::Ice::Current& = Ice::emptyCurrent) const override;
204
205 /**
206 * Retrieve membership probability for a given class
207 *
208 * @param className
209 **/
210 float getClassProbability(const ::std::string& className,
211 const ::Ice::Current& = Ice::emptyCurrent) const override;
212
213 /**
214 * Set the motion model for this object
215 *
216 * @param motionModel The motion model
217 **/
220
221 // TODO: cloning will probabily also not work without the implementation of a copy constructor
222 Ice::ObjectPtr ice_clone() const override;
223 ObjectInstancePtr clone(const Ice::Current& c = Ice::emptyCurrent) const;
224
225 protected:
226 // ice interface implementation on Base data types. Replaces in c++ by derived instance getters, setters (see above)
227 armarx::FramedPositionBasePtr
228 getPositionBase(const ::Ice::Current& = Ice::emptyCurrent) const override;
229 armarx::FramedOrientationBasePtr
230 getOrientationBase(const ::Ice::Current& = Ice::emptyCurrent) const override;
231
233
234 private:
236 void output(std::ostream& stream) const;
237
238 public: // streaming operator
239 friend std::ostream&
240 operator<<(std::ostream& stream, const ObjectInstance& rhs)
241 {
242 rhs.output(stream);
243 return stream;
244 }
245
246 friend std::ostream&
247 operator<<(std::ostream& stream, const ObjectInstancePtr& rhs)
248 {
249 rhs->output(stream);
250 return stream;
251 }
252
253 friend std::ostream&
254 operator<<(std::ostream& stream, const ObjectInstanceBasePtr& rhs)
255 {
256 stream << ObjectInstancePtr::dynamicCast(rhs);
257 return stream;
258 }
259 };
260
261} // namespace memoryx
std::string timestamp()
constexpr T c
Entity is the superclass for all MemoryX memory chunks.
Definition Entity.h:246
void setMotionModel(AbstractMotionModelPtr motionModel)
Set the motion model for this object.
int getLocalizationPriority(const ::Ice::Current &=Ice::emptyCurrent) const override
void setOrientation(const armarx::FramedOrientationBasePtr &orientation, const ::Ice::Current &=Ice::emptyCurrent) override
Set orientation of the instance.
void setPositionUncertainty(const MultivariateNormalDistributionBasePtr &uncertainty, const ::Ice::Current &=Ice::emptyCurrent) override
Set uncertainty of position estimate.
EntityAttributeBasePtr getOrientationAttribute() const
Retrieve attribute which holds instance position.
armarx::FramedPosePtr getPose() const
Convenience function to get position and orientation attributes at once.
friend std::ostream & operator<<(std::ostream &stream, const ObjectInstance &rhs)
armarx::FramedOrientationPtr getOrientation() const
Retrieve orientation of the instance.
armarx::FramedPositionPtr getPosition() const
Retrieve position of the instance.
void setClass(const std::string &className, float probability, const Ice::Current &=Ice::emptyCurrent) override
Set the class attribute of the ObjectInstance.
bool hasLocalizationTimestamp() const
armarx::FramedPositionBasePtr getPositionBase(const ::Ice::Current &=Ice::emptyCurrent) const override
void setExistenceCertainty(float existenceCertainty, const ::Ice::Current &=Ice::emptyCurrent) override
Set existence certainty for this instance.
AbstractMotionModelPtr motionModel
void addClass(const std::string &className, float probability, const Ice::Current &=Ice::emptyCurrent) override
Adds new class membership to the class attribute.
void clearClasses(const Ice::Current &=Ice::emptyCurrent) override
Clear class membership.
float getExistenceCertainty(const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve existence certainty for this instance.
void setPose(const armarx::FramedPoseBasePtr &newPose)
Convenience function to set position and orientation attributes at once.
void setPosition(const armarx::FramedPositionBasePtr &position, const ::Ice::Current &=Ice::emptyCurrent) override
Set position of the instance.
AbstractMotionModelPtr getMotionModel() const
armarx::FramedOrientationBasePtr getOrientationBase(const ::Ice::Current &=Ice::emptyCurrent) const override
::std::string getMostProbableClass(const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve the class with highest membership probability.
void setLocalizationPriority(Ice::Int priority, const ::Ice::Current &=Ice::emptyCurrent) override
void setLocalizationTimestamp(const IceUtil::Time &timestamp)
Ice::ObjectPtr ice_clone() const override
ObjectInstance(const std::string &name, const std::string &id="")
Constructs a new ObjectInstance WorkingMemory entity.
MultivariateNormalDistributionBasePtr getPositionUncertainty(const ::Ice::Current &=Ice::emptyCurrent) const override
Get uncertainty of position estimate.
EntityAttributeBasePtr getPositionAttribute() const
Retrieve attribute which holds instance position.
ObjectInstancePtr clone(const Ice::Current &c=Ice::emptyCurrent) const
float getClassProbability(const ::std::string &className, const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve membership probability for a given class.
ClassProbabilityMap getClasses(const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve classes and associated class membership probability for this instance.
IceUtil::Time getLocalizationTimestamp() const
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< FramedPosition > FramedPositionPtr
Definition FramedPose.h:149
IceInternal::Handle< FramedOrientation > FramedOrientationPtr
Definition FramedPose.h:207
IceInternal::Handle< FramedPose > FramedPosePtr
Definition FramedPose.h:272
VirtualRobot headers.
IceInternal::Handle< ObjectInstance > ObjectInstancePtr
IceInternal::Handle< AbstractMotionModel > AbstractMotionModelPtr