48 #ifndef _MIRA_FRAMEWORKTRANSFORMER_H_ 49 #define _MIRA_FRAMEWORKTRANSFORMER_H_ 66 class FrameworkTransformer;
102 template<
typename Transform,
typename Filter>
110 template<
typename ChannelTransformType,
typename Transform,
typename Filter>
111 bool getTransformData(
const Time& time, Transform& oTransform, Filter&& filter);
129 default:
return "-INVALID VALUE-";
136 template <
typename Derived>
141 template <
typename Reflector>
144 Derived* This =
static_cast<Derived*
>(
this);
146 r.interface(
"IFrameworkTransformer");
148 (
void (Derived::*)(
const std::string&,
const std::string&))&Derived::addLink,
150 "add a link between the two specified nodes",
151 "child",
"child node frame ID",
"/robot/ArmFrame",
152 "parent",
"parent node frame ID",
"/robot/RobotBaseFrame");
154 r.method(
"getTransform2", &Derived::getTransform2, This,
155 "obtains the 2D transform between the two specified nodes",
156 "target",
"target frame ID",
"/robot/RobotFrame",
157 "source",
"source frame ID",
"/GlobalFrame");
159 r.method(
"getTransformCov2", &Derived::getTransformCov2, This,
160 "obtains the 2D transform with covariance between the two specified nodes",
161 "target",
"target frame ID",
"/robot/RobotFrame",
162 "source",
"source frame ID",
"/GlobalFrame");
164 r.method(
"getTransform3", &Derived::getTransform3, This,
165 "obtains the 3D transform between the two specified nodes",
166 "target",
"target frame ID",
"/robot/RobotFrame",
167 "source",
"source frame ID",
"/GlobalFrame");
169 r.method(
"getTransformCov3", &Derived::getTransformCov3, This,
170 "obtains the 3D transform with covariance between the two specified nodes",
171 "target",
"target frame ID",
"/robot/RobotFrame",
172 "source",
"source frame ID",
"/GlobalFrame");
174 r.method(
"publishTransform2", &Derived::publishTransform2, This,
175 "publishes the 2D transform of the specified node",
176 "nodeID",
"ID of node to change",
"/robot/HandFrame",
177 "transform",
"transformation for the node",
Pose2());
179 r.method(
"publishTransformCov2", &Derived::publishTransformCov2, This,
180 "publishes the 2D transform with covariance of the specified node",
181 "nodeID",
"ID of node to change",
"/robot/HandFrame",
182 "transform",
"transformation for the node",
PoseCov2());
184 r.method(
"publishTransform3", &Derived::publishTransform3, This,
185 "publishes the 3D transform of the specified node",
186 "nodeID",
"ID of node to change",
"/robot/HandFrame",
187 "transform",
"transformation for the node",
Pose3());
189 r.method(
"publishTransformCov3", &Derived::publishTransformCov3, This,
190 "publishes the 3D transform with covariance of the specified node",
191 "nodeID",
"ID of node to change",
"/robot/HandFrame",
192 "transform",
"transformation for the node",
PoseCov3());
197 template <
typename Derived>
204 template <
typename Reflector>
209 Derived* This =
static_cast<Derived*
>(
this);
211 r.interface(
"IFrameworkTransformerLinkType");
213 (
void (Derived::*)(
const std::string&,
const std::string&,
216 "add a link between the two specified nodes, with a specified type",
217 "child",
"child node frame ID",
"/robot/ArmFrame",
218 "parent",
"parent node frame ID",
"/robot/RobotBaseFrame",
221 r.method(
"addTypedLink",
222 (
void (Derived::*)(
const std::string&,
const std::string&,
225 "alias for addLink(child, parent, type), provided for backward compatibility",
226 "child",
"child node frame ID",
"/robot/ArmFrame",
227 "parent",
"parent node frame ID",
"/robot/RobotBaseFrame",
259 void addLink(
const std::string& childID,
const std::string& parentID);
274 void addLink(
const std::string& childID,
const std::string& parentID,
283 template<
typename Transform>
284 void publishTransform(
const std::string& nodeID,
const Transform& transform,
303 template<
typename Transform,
typename Filter = NearestNeighborInterpolator>
305 const std::string& targetID,
306 const std::string& sourceID,
307 const Transform& transform,
319 const std::string& otherTransformer);
321 bool createLink(
const std::string& childID,
const std::string& parentID,
325 const std::string& childID,
const std::string& parentID,
329 bool implementsLinkType,
330 const std::string& childID,
const std::string& parentID,
345 const std::string& source);
347 const std::string& source);
349 const std::string& source);
351 const std::string& source);
352 void publishTransform2(
const std::string& nodeID,
const RigidTransform2f& transform);
353 void publishTransformCov2(
const std::string& nodeID,
const RigidTransformCov2f& transform);
354 void publishTransform3(
const std::string& nodeID,
const RigidTransform3f& transform);
355 void publishTransformCov3(
const std::string& nodeID,
const RigidTransformCov3f& transform);
385 template <
typename ChannelTransformType,
typename Filter>
387 static void get(
Channel<void>& channel,
const Time& time, ChannelTransformType& oTransform, Filter& filter) {
389 oTransform = ch.
get(time, filter);
394 template <
typename ChannelTransformType>
400 template <
typename ChannelTransformType>
406 template <
typename ChannelTransformType>
412 template <
typename ChannelTransformType>
418 template <
typename ChannelTransformType>
424 template <
typename Transform>
426 static void set(
Authority& authority,
const std::string& nodeID,
427 const Transform& transform,
const Time& time);
432 template<
typename Transform,
typename Filter>
442 if( !getTransformData<RigidTransform2f>(time,transform,filter) &&
443 !getTransformData<RigidTransform3f>(time,transform,filter) &&
444 !getTransformData<RigidTransformCov2f>(time,transform,filter) &&
445 !getTransformData<RigidTransformCov3f>(time,transform,filter))
446 MIRA_THROW(XRuntime,
"Unknown transform type in channel '" 447 << mChannel.
getID() <<
"', typename: " 452 template<
typename ChannelTransformType,
typename Transform,
typename Filter>
453 inline bool FrameworkTransformerNode::getTransformData(
const Time& time,
454 Transform& oTransform,
460 if(
type!=typeId<ChannelTransformType>())
466 if(mChannel.
getTypename()!=typeName<ChannelTransformType>())
472 ChannelTransformType transform;
483 template<
typename Transform>
485 const Transform& transform,
491 template<
typename Transform,
typename Filter>
493 const std::string& targetID,
494 const std::string& sourceID,
495 const Transform& transform,
503 MIRA_THROW(XRuntime,
"Node " << nodeID <<
" does not exist");
505 MIRA_THROW(XRuntime,
"Target node " << targetID <<
" does not exist");
507 MIRA_THROW(XRuntime,
"Source node " << sourceID <<
" does not exist");
508 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:458
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
#define MIRA_THROW(ex, msg)
Macro for throwing an exception.
Definition: Exception.h:78
Typename getTypename() const
Return the typename of the channel.
Definition: Channel.h:482
Wrapper class for boost::posix_time::ptime for adding more functionality to it.
Definition: Time.h:418
Filter that returns the nearest neighbor.
1D linear interpolator.
Definition: LinearInterpolator.h:70
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
static Time now()
Returns the current utc based time.
Definition: Time.h:481
Framework channel classes.
Stamped< T > get()
Returns the latest data from the channel by value.
Definition: Channel.h:893
int getTypeId() const
Returns the type id of the channel.
Definition: Channel.h:468
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:525