48 #ifndef _MIRA_FRAMEWORKTRANSFORMER_H_ 49 #define _MIRA_FRAMEWORKTRANSFORMER_H_ 67 class FrameworkTransformer;
103 template<
typename Transform,
typename Filter>
111 template<
typename ChannelTransformType,
typename Transform,
typename Filter>
112 bool getTransformData(
const Time& time, Transform& oTransform, Filter&& filter);
130 default:
return "-INVALID VALUE-";
137 template <
typename Derived>
142 template <
typename Reflector>
145 Derived* This =
static_cast<Derived*
>(
this);
147 r.interface(
"IFrameworkTransformer");
149 (
void (Derived::*)(
const std::string&,
const std::string&))&Derived::addLink,
151 "add a link between the two specified nodes",
152 "child",
"child node frame ID",
"/robot/ArmFrame",
153 "parent",
"parent node frame ID",
"/robot/RobotBaseFrame");
155 r.method(
"getTransform2", &Derived::getTransform2, This,
156 "obtains the 2D transform between the two specified nodes",
157 "target",
"target frame ID",
"/robot/RobotFrame",
158 "source",
"source frame ID",
"/GlobalFrame");
160 r.method(
"getTransformCov2", &Derived::getTransformCov2, This,
161 "obtains the 2D transform with covariance between the two specified nodes",
162 "target",
"target frame ID",
"/robot/RobotFrame",
163 "source",
"source frame ID",
"/GlobalFrame");
165 r.method(
"getTransform3", &Derived::getTransform3, This,
166 "obtains the 3D transform between the two specified nodes",
167 "target",
"target frame ID",
"/robot/RobotFrame",
168 "source",
"source frame ID",
"/GlobalFrame");
170 r.method(
"getTransformCov3", &Derived::getTransformCov3, This,
171 "obtains the 3D transform with covariance between the two specified nodes",
172 "target",
"target frame ID",
"/robot/RobotFrame",
173 "source",
"source frame ID",
"/GlobalFrame");
175 r.method(
"publishTransform2", &Derived::publishTransform2, This,
176 "publishes the 2D transform of the specified node",
177 "nodeID",
"ID of node to change",
"/robot/HandFrame",
178 "transform",
"transformation for the node",
Pose2());
180 r.method(
"publishTransformCov2", &Derived::publishTransformCov2, This,
181 "publishes the 2D transform with covariance of the specified node",
182 "nodeID",
"ID of node to change",
"/robot/HandFrame",
183 "transform",
"transformation for the node",
PoseCov2());
185 r.method(
"publishTransform3", &Derived::publishTransform3, This,
186 "publishes the 3D transform of the specified node",
187 "nodeID",
"ID of node to change",
"/robot/HandFrame",
188 "transform",
"transformation for the node",
Pose3());
190 r.method(
"publishTransformCov3", &Derived::publishTransformCov3, This,
191 "publishes the 3D transform with covariance of the specified node",
192 "nodeID",
"ID of node to change",
"/robot/HandFrame",
193 "transform",
"transformation for the node",
PoseCov3());
198 template <
typename Derived>
205 template <
typename Reflector>
210 Derived* This =
static_cast<Derived*
>(
this);
212 r.interface(
"IFrameworkTransformerLinkType");
214 (
void (Derived::*)(
const std::string&,
const std::string&,
217 "add a link between the two specified nodes, with a specified type",
218 "child",
"child node frame ID",
"/robot/ArmFrame",
219 "parent",
"parent node frame ID",
"/robot/RobotBaseFrame",
222 r.method(
"addTypedLink",
223 (
void (Derived::*)(
const std::string&,
const std::string&,
226 "alias for addLink(child, parent, type), provided for backward compatibility",
227 "child",
"child node frame ID",
"/robot/ArmFrame",
228 "parent",
"parent node frame ID",
"/robot/RobotBaseFrame",
260 void addLink(
const std::string& childID,
const std::string& parentID);
275 void addLink(
const std::string& childID,
const std::string& parentID,
284 template<
typename Transform>
285 void publishTransform(
const std::string& nodeID,
const Transform& transform,
304 template<
typename Transform,
typename Filter = NearestNeighborInterpolator>
305 void publishTransformIndirect(
const std::string& nodeID,
306 const std::string& targetID,
307 const std::string& sourceID,
308 const Transform& transform,
315 void storeTransformTree(
const Path& filename);
319 void registerInterface(
const std::string& interface,
320 const std::string& otherTransformer);
322 bool createLink(
const std::string& childID,
const std::string& parentID,
325 void notifyTransformerOfLink(
const std::string& otherTransformer,
326 const std::string& childID,
const std::string& parentID,
329 void notifyTransformerOfLink(
const std::string& otherTransformer,
330 bool implementsLinkType,
331 const std::string& childID,
const std::string& parentID,
346 const std::string& source);
348 const std::string& source);
350 const std::string& source);
352 const std::string& source);
353 void publishTransform2(
const std::string& nodeID,
const RigidTransform2f& transform);
354 void publishTransformCov2(
const std::string& nodeID,
const RigidTransformCov2f& transform);
355 void publishTransform3(
const std::string& nodeID,
const RigidTransform3f& transform);
356 void publishTransformCov3(
const std::string& nodeID,
const RigidTransformCov3f& transform);
386 template <
typename ChannelTransformType,
typename Filter>
388 static void get(
Channel<void>& channel,
const Time& time, ChannelTransformType& oTransform, Filter& filter) {
390 oTransform = ch.
get(time, filter);
395 template <
typename ChannelTransformType>
401 template <
typename ChannelTransformType>
407 template <
typename ChannelTransformType>
413 template <
typename ChannelTransformType>
419 template <
typename ChannelTransformType>
425 template <
typename Transform>
427 static void set(
Authority& authority,
const std::string& nodeID,
428 const Transform& transform,
const Time& time);
433 template<
typename Transform,
typename Filter>
443 if( !getTransformData<RigidTransform2f>(time,transform,filter) &&
444 !getTransformData<RigidTransform3f>(time,transform,filter) &&
445 !getTransformData<RigidTransformCov2f>(time,transform,filter) &&
446 !getTransformData<RigidTransformCov3f>(time,transform,filter))
447 MIRA_THROW(XRuntime,
"Unknown transform type in channel '" 448 << mChannel.
getID() <<
"', typename: " 453 template<
typename ChannelTransformType,
typename Transform,
typename Filter>
454 inline bool FrameworkTransformerNode::getTransformData(
const Time& time,
455 Transform& oTransform,
461 if(
type!=typeId<ChannelTransformType>())
467 if(mChannel.
getTypename()!=typeName<ChannelTransformType>())
473 ChannelTransformType transform;
484 template<
typename Transform>
486 const Transform& transform,
492 template<
typename Transform,
typename Filter>
494 const std::string& targetID,
495 const std::string& sourceID,
496 const Transform& transform,
504 MIRA_THROW(XRuntime,
"Node " << nodeID <<
" does not exist");
506 MIRA_THROW(XRuntime,
"Target node " << targetID <<
" does not exist");
508 MIRA_THROW(XRuntime,
"Source node " << sourceID <<
" does not exist");
509 Transform inferredTransform = this->
template inferTransform<Transform>(node,target,source,transform,time,filter);
const std::string & getID() const
Return the channel ID, its name.
Definition: Channel.h:457
1D nearest neighbor interpolator.
Definition: NearestNeighborInterpolator.h:68
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
boost::filesystem::path Path
Typedef of a Path (shorter version for boost::filesystem::path)
Definition: Path.h:69
#define MIRA_REFLECT_BASE(reflector, BaseClass)
Macro that can be used to reflect the base class easily.
Definition: ReflectorInterface.h:912
Framework export macro declaration.
#define MIRA_THROW(ex, msg)
Macro for throwing an exception.
Definition: Exception.h:82
Typename getTypename() const
Return the typename of the channel.
Definition: Channel.h:481
Wrapper class for boost::posix_time::ptime for adding more functionality to it.
Definition: Time.h:416
class MIRA_FRAMEWORK_EXPORT Authority
forward declaration
Definition: RemoteConnection.h:74
Filter that returns the nearest neighbor.
1D linear interpolator.
Definition: LinearInterpolator.h:70
#define MIRA_FRAMEWORK_EXPORT
Definition: FrameworkExports.h:61
PropertyHint type(const std::string &t)
Sets the attribute "type" to the specified value.
Definition: PropertyHint.h:295
Authorities act as a facade to the framework.
Definition: Authority.h:94
Framework channel classes.
Stamped< T > get()
Returns the latest data from the channel by value.
Definition: Channel.h:885
static Time now() static Time eternity()
Returns the current utc based time.
Definition: Time.h:479
int getTypeId() const
Returns the type id of the channel.
Definition: Channel.h:467
PropertyHint precision(int p)
Sets the attribute "precision".
Definition: PropertyHint.h:285
Typedefs for different Pose datatypes that are internally RigidTransforms.
Provides method for generating a unique id for any type.
Filter that can be used for linear interpolation.
bool isEmpty() const
Returns if the channel is empty (no data has been published)
Definition: Channel.h:524