Robowflex  v0.1
Making MoveIt Easy
robowflex::TF Namespace Reference

Collection of methods relating to transforms and transform math. More...

Functions

RobotPose identity ()
 Creates the Identity pose. More...
 
RobotPose createPoseXYZ (double x, double y, double z)
 Creates a robot pose from a linear component and zero orientation. More...
 
RobotPose createPoseXYZ (const Eigen::Ref< const Eigen::Vector3d > &translation)
 Creates a robot pose from a linear component and zero orientation. More...
 
RobotPose createPoseXYZ (double x, double y, double z, double X, double Y, double Z)
 Creates a robot pose from a linear component and XYZ convention Euler angles. More...
 
RobotPose createPoseXYZ (const Eigen::Ref< const Eigen::Vector3d > &translation, const Eigen::Ref< const Eigen::Vector3d > &rotation)
 Creates a robot pose from a linear component and XYZ convention Euler angles. More...
 
RobotPose createPoseQ (double x, double y, double z, double W, double X, double Y, double Z)
 Creates a robot pose from a linear component and a Quaternion. More...
 
RobotPose createPoseQ (const Eigen::Ref< const Eigen::Vector3d > &translation, const Eigen::Ref< const Eigen::Vector4d > &rotation)
 Creates a robot pose from a linear component and a quaternion. More...
 
RobotPose createPoseQ (const Eigen::Ref< const Eigen::Vector3d > &translation, const Eigen::Quaterniond &rotation)
 Creates a robot pose from a linear component and a quaternion. More...
 
Eigen::Quaterniond getPoseRotation (const RobotPose &pose)
 Get the rotational component of a robot pose. More...
 
Eigen::Vector3d pointMsgToEigen (const geometry_msgs::Point &msg)
 Converts a point message to an Eigen::Vector3d. More...
 
geometry_msgs::Point pointEigenToMsg (const Eigen::Vector3d &vector)
 Converts an Eigen::Vector3d to a point message. More...
 
Eigen::Vector3d vectorMsgToEigen (const geometry_msgs::Vector3 &msg)
 Converts a vector message to an Eigen::Vector3d. More...
 
geometry_msgs::Vector3 vectorEigenToMsg (const Eigen::Vector3d &vector)
 Converts an Eigen::Vector3d to a vector message. More...
 
RobotPose poseMsgToEigen (const geometry_msgs::Pose &msg)
 Converts a pose message to RobotPose. More...
 
geometry_msgs::Pose poseEigenToMsg (const RobotPose &pose)
 Converts an RobotPose to a pose message. More...
 
Eigen::Quaterniond quaternionMsgToEigen (const geometry_msgs::Quaternion &msg)
 Converts a quaternion message to Eigen::Quaterniond. More...
 
geometry_msgs::Quaternion quaternionEigenToMsg (const Eigen::Quaterniond &quaternion)
 Converts an Eigen::Quaterniond to a quaternion message. More...
 
moveit_msgs::BoundingVolume getBoundingVolume (const RobotPose &pose, const GeometryConstPtr &geometry)
 Get a bounding volume message for given geometry at a pose. More...
 
moveit_msgs::PositionConstraint getPositionConstraint (const std::string &ee_name, const std::string &base_name, const RobotPose &pose, const GeometryConstPtr &geometry)
 Get a position constraint message. More...
 
Eigen::Vector3d samplePositionConstraint (const moveit_msgs::PositionConstraint &pc)
 
moveit_msgs::OrientationConstraint getOrientationConstraint (const std::string &ee_name, const std::string &base_name, const Eigen::Quaterniond &orientation, const Eigen::Vector3d &tolerances)
 Get an orientation constraint message. More...
 
Eigen::Quaterniond sampleOrientation (const Eigen::Quaterniond &orientation, const Eigen::Vector3d &tolerances)
 Sample an orientation from a given orientation with XYZ Euler angle tolerances. More...
 
Eigen::Quaterniond sampleOrientationUniform (const Eigen::Vector3d &tolerances)
 Sample an orientation within the XYZ Euler angle tolerances. More...
 
Eigen::Quaterniond offsetOrientation (const Eigen::Quaterniond &orientation, const Eigen::Vector3d &axis, double value)
 Offset an orientation by a rotation about an axis. More...
 
Eigen::Vector3d samplePositionUniform (const Eigen::Vector3d &bounds)
 Sample a position within the given bounds using a uniform distribution. More...
 
Eigen::Vector3d samplePositionGaussian (const Eigen::Vector3d &stddev)
 Sample a position from a gaussian distribution with mean zero and given standard deviation. More...
 
RobotPose samplePoseUniform (const Eigen::Vector3d &pos_bounds, const Eigen::Vector3d &orn_bounds)
 Sample a pose within the given position, orientation bounds. More...
 
RobotPose samplePoseGaussian (const Eigen::Vector3d &pos_stddev, const Eigen::Vector3d &orn_bounds)
 Sample a pose with gaussian sampling for the position with given standard deviations and uniform sampling for the orientation within the given bounds. More...
 
RobotPose transformMsgToEigen (const geometry_msgs::TransformStamped &tf)
 Decode a message as a transform. More...
 
geometry_msgs::TransformStamped transformEigenToMsg (const std::string &source, const std::string &target, const RobotPose &tf)
 Encode a transform as a message. More...
 
double angleNormalize (double v)
 Normalize an angle between -pi to pi. More...
 
double toDegrees (double v)
 Convert an angle to degrees. More...
 
double toRadians (double v)
 Convert an angle to radians. More...
 
bool isVecZero (const Eigen::Ref< const Eigen::VectorXd > &v, double tolerance=constants::eps)
 Checks if a vector is close to zero. More...
 

Detailed Description

Collection of methods relating to transforms and transform math.

Function Documentation

◆ angleNormalize()

double robowflex::TF::angleNormalize ( double  v)

Normalize an angle between -pi to pi.

Parameters
[in]vThe angle.
Returns
The normalized angle.

Definition at line 293 of file tf.cpp.

294 {
295  return (v > constants::pi) ? constants::two_pi - v : v;
296 }
static const double two_pi
Definition: constants.h:24
static const double pi
Definition: constants.h:21

◆ createPoseQ() [1/3]

RobotPose robowflex::TF::createPoseQ ( const Eigen::Ref< const Eigen::Vector3d > &  translation,
const Eigen::Quaterniond &  rotation 
)

Creates a robot pose from a linear component and a quaternion.

Parameters
[in]translationtranslation component.
[in]rotationrotational component.
Returns
A new robot pose from components.

Definition at line 59 of file tf.cpp.

61 {
62  RobotPose pose = RobotPose::Identity();
63  pose.translation() = translation;
64  pose.linear() = rotation.toRotationMatrix();
65 
66  return pose;
67 }
std::decay< decltype(std::declval< moveit::core::Transforms >().getTransform("")) >::type RobotPose
A pose (point in SE(3)) used in various functions. Defined from what MoveIt! uses.
Definition: adapter.h:24

◆ createPoseQ() [2/3]

RobotPose robowflex::TF::createPoseQ ( const Eigen::Ref< const Eigen::Vector3d > &  translation,
const Eigen::Ref< const Eigen::Vector4d > &  rotation 
)

Creates a robot pose from a linear component and a quaternion.

Parameters
[in]translationtranslation component.
[in]rotationrotational component (W, X, Y, Z quaternion values).
Returns
A new robot pose from components.

Definition at line 53 of file tf.cpp.

55 {
56  return createPoseQ(translation, Eigen::Quaterniond(rotation));
57 }
RobotPose createPoseQ(double x, double y, double z, double W, double X, double Y, double Z)
Creates a robot pose from a linear component and a Quaternion.
Definition: tf.cpp:47

◆ createPoseQ() [3/3]

RobotPose robowflex::TF::createPoseQ ( double  x,
double  y,
double  z,
double  W,
double  X,
double  Y,
double  Z 
)

Creates a robot pose from a linear component and a Quaternion.

Parameters
[in]xX-axis translation.
[in]yY-axis translation.
[in]zZ-axis translation.
[in]WReal quaternion component.
[in]Xi quaternion component.
[in]Yj quaternion component.
[in]Zk quaternion component.
Returns
A new robot pose from components.

Definition at line 47 of file tf.cpp.

48 {
49  return createPoseQ(Eigen::Vector3d{x, y, z}, //
50  Eigen::Vector4d{W, X, Y, Z});
51 }

◆ createPoseXYZ() [1/4]

RobotPose robowflex::TF::createPoseXYZ ( const Eigen::Ref< const Eigen::Vector3d > &  translation)

Creates a robot pose from a linear component and zero orientation.

Parameters
[in]translationTranslation component.
Returns
A new robot pose from components.

Definition at line 19 of file tf.cpp.

20 {
21  RobotPose pose = RobotPose::Identity();
22  pose.translation() = translation;
23 
24  return pose;
25 }

◆ createPoseXYZ() [2/4]

RobotPose robowflex::TF::createPoseXYZ ( const Eigen::Ref< const Eigen::Vector3d > &  translation,
const Eigen::Ref< const Eigen::Vector3d > &  rotation 
)

Creates a robot pose from a linear component and XYZ convention Euler angles.

Parameters
[in]translationTranslation component.
[in]rotationRotational component (X, Y, Z angles).
Returns
A new robot pose from components.

Definition at line 33 of file tf.cpp.

35 {
36  RobotPose pose = RobotPose::Identity();
37  pose.translation() = translation;
38 
39  pose.linear() = (Eigen::AngleAxisd(rotation[0], Eigen::Vector3d::UnitX()) *
40  Eigen::AngleAxisd(rotation[1], Eigen::Vector3d::UnitY()) *
41  Eigen::AngleAxisd(rotation[2], Eigen::Vector3d::UnitZ()))
42  .toRotationMatrix();
43 
44  return pose;
45 }

◆ createPoseXYZ() [3/4]

RobotPose robowflex::TF::createPoseXYZ ( double  x,
double  y,
double  z 
)

Creates a robot pose from a linear component and zero orientation.

Parameters
[in]xX-axis translation.
[in]yY-ayis translation.
[in]zZ-azis translation.
Returns
A new robot pose from components.

Definition at line 14 of file tf.cpp.

15 {
16  return createPoseXYZ(x, y, z, 0, 0, 0);
17 }
RobotPose createPoseXYZ(double x, double y, double z)
Creates a robot pose from a linear component and zero orientation.
Definition: tf.cpp:14

◆ createPoseXYZ() [4/4]

RobotPose robowflex::TF::createPoseXYZ ( double  x,
double  y,
double  z,
double  X,
double  Y,
double  Z 
)

Creates a robot pose from a linear component and XYZ convention Euler angles.

Parameters
[in]xX-axis translation.
[in]yY-ayis translation.
[in]zZ-azis translation.
[in]XRotation about X.
[in]YRotation about Y.
[in]ZRotation about Z.
Returns
A new robot pose from components.

Definition at line 27 of file tf.cpp.

28 {
29  return createPoseXYZ(Eigen::Vector3d{x, y, z}, //
30  Eigen::Vector3d{X, Y, Z});
31 }

◆ getBoundingVolume()

moveit_msgs::BoundingVolume robowflex::TF::getBoundingVolume ( const RobotPose pose,
const GeometryConstPtr geometry 
)

Get a bounding volume message for given geometry at a pose.

Parameters
[in]posePose to place geometry at.
[in]geometryGeometry to get bounding volume for.
Returns
Bounding volume message for geometry at pose.

Definition at line 151 of file tf.cpp.

152 {
153  moveit_msgs::BoundingVolume bv;
154 
155  if (geometry->isMesh())
156  {
157  bv.meshes.push_back(geometry->getMeshMsg());
158  bv.mesh_poses.push_back(TF::poseEigenToMsg(pose));
159  }
160  else
161  {
162  bv.primitives.push_back(geometry->getSolidMsg());
163  bv.primitive_poses.push_back(TF::poseEigenToMsg(pose));
164  }
165 
166  return bv;
167 }
geometry_msgs::Pose poseEigenToMsg(const RobotPose &pose)
Converts an RobotPose to a pose message.
Definition: tf.cpp:120

◆ getOrientationConstraint()

moveit_msgs::OrientationConstraint robowflex::TF::getOrientationConstraint ( const std::string ee_name,
const std::string base_name,
const Eigen::Quaterniond &  orientation,
const Eigen::Vector3d &  tolerances 
)

Get an orientation constraint message.

Parameters
[in]ee_nameThe name of the end-effector link.
[in]base_nameThe frame of pose and orientation.
[in]orientationThe desired orientation.
[in]tolerancesXYZ Euler angle tolerances about orientation.
Returns
The orientation constraint as a MoveIt message.

Definition at line 189 of file tf.cpp.

193 {
194  moveit_msgs::OrientationConstraint constraint;
195 
196  constraint.header.frame_id = base_name;
197  constraint.link_name = ee_name;
198  constraint.absolute_x_axis_tolerance = tolerances[0];
199  constraint.absolute_y_axis_tolerance = tolerances[1];
200  constraint.absolute_z_axis_tolerance = tolerances[2];
201  constraint.orientation = TF::quaternionEigenToMsg(orientation);
202  constraint.weight = 1;
203 
204  return constraint;
205 }
geometry_msgs::Quaternion quaternionEigenToMsg(const Eigen::Quaterniond &quaternion)
Converts an Eigen::Quaterniond to a quaternion message.
Definition: tf.cpp:140

◆ getPoseRotation()

Eigen::Quaterniond robowflex::TF::getPoseRotation ( const RobotPose pose)

Get the rotational component of a robot pose.

Parameters
[in]poseThe pose to get the rotation from.
Returns
The rotational component of the pose.

Definition at line 69 of file tf.cpp.

70 {
71  return Eigen::Quaterniond(pose.rotation());
72 }

◆ getPositionConstraint()

moveit_msgs::PositionConstraint robowflex::TF::getPositionConstraint ( const std::string ee_name,
const std::string base_name,
const RobotPose pose,
const GeometryConstPtr geometry 
)

Get a position constraint message.

Parameters
[in]ee_nameThe name of the end-effector link.
[in]base_nameThe frame of pose and orientation.
[in]poseThe pose of geometry in base_frame.
[in]geometryThe geometry describing the position constraint.
Returns
The position constraint as a MoveIt messsage.

Definition at line 169 of file tf.cpp.

172 {
173  moveit_msgs::PositionConstraint constraint;
174 
175  constraint.header.frame_id = base_name;
176  constraint.link_name = ee_name;
177 
178  // TODO: Expose as a parameter
179  constraint.target_point_offset.x = 0;
180  constraint.target_point_offset.y = 0;
181  constraint.target_point_offset.z = 0;
182 
183  constraint.constraint_region = getBoundingVolume(pose, geometry);
184  constraint.weight = 1;
185 
186  return constraint;
187 }
moveit_msgs::BoundingVolume getBoundingVolume(const RobotPose &pose, const GeometryConstPtr &geometry)
Get a bounding volume message for given geometry at a pose.
Definition: tf.cpp:151

◆ identity()

RobotPose robowflex::TF::identity ( )

Creates the Identity pose.

Returns
A new identity robot pose.

Definition at line 9 of file tf.cpp.

10 {
11  return RobotPose::Identity();
12 }

◆ isVecZero()

bool robowflex::TF::isVecZero ( const Eigen::Ref< const Eigen::VectorXd > &  v,
double  tolerance = constants::eps 
)

Checks if a vector is close to zero.

Parameters
[in]vVector to check.
[in]toleranceTolerance of what is considered zero.
Returns
Whether the vector's norm is below the tolerance threshold.

Definition at line 321 of file tf.cpp.

322 {
323  return v.norm() < tolerance;
324 }

◆ offsetOrientation()

Eigen::Quaterniond robowflex::TF::offsetOrientation ( const Eigen::Quaterniond &  orientation,
const Eigen::Vector3d &  axis,
double  value 
)

Offset an orientation by a rotation about an axis.

Parameters
[in]orientationOrientation to offset.
[in]axisAxis to offset orientation about.
[in]valueValue by which to offset.
Returns
The new orientation.

Definition at line 228 of file tf.cpp.

230 {
231  return Eigen::AngleAxisd(value, axis) * orientation;
232 }

◆ pointEigenToMsg()

geometry_msgs::Point robowflex::TF::pointEigenToMsg ( const Eigen::Vector3d &  vector)

Converts an Eigen::Vector3d to a point message.

Parameters
[in]vectorVector to convert.
Returns
vector as a point message.

Definition at line 84 of file tf.cpp.

85 {
86  geometry_msgs::Point msg;
87  msg.x = vector[0];
88  msg.y = vector[1];
89  msg.z = vector[2];
90 
91  return msg;
92 }

◆ pointMsgToEigen()

Eigen::Vector3d robowflex::TF::pointMsgToEigen ( const geometry_msgs::Point &  msg)

Converts a point message to an Eigen::Vector3d.

Parameters
[in]msgMessage to convert.
Returns
msg as an Eigen::Vector3d.

Definition at line 74 of file tf.cpp.

75 {
76  Eigen::Vector3d vector;
77  vector[0] = msg.x;
78  vector[1] = msg.y;
79  vector[2] = msg.z;
80 
81  return vector;
82 }

◆ poseEigenToMsg()

geometry_msgs::Pose robowflex::TF::poseEigenToMsg ( const RobotPose pose)

Converts an RobotPose to a pose message.

Parameters
[in]posePose to convert.
Returns
pose as a pose message.

Definition at line 120 of file tf.cpp.

121 {
122  geometry_msgs::Pose msg;
123 
124  const auto &t = pose.translation();
125  msg.position.x = t.x();
126  msg.position.y = t.y();
127  msg.position.z = t.z();
128 
129  const auto &r = getPoseRotation(pose);
130  msg.orientation = quaternionEigenToMsg(r);
131 
132  return msg;
133 }
Eigen::Quaterniond getPoseRotation(const RobotPose &pose)
Get the rotational component of a robot pose.
Definition: tf.cpp:69

◆ poseMsgToEigen()

RobotPose robowflex::TF::poseMsgToEigen ( const geometry_msgs::Pose &  msg)

Converts a pose message to RobotPose.

Parameters
[in]msgMessage to convert.
Returns
msg an RobotPose.

Definition at line 114 of file tf.cpp.

115 {
116  return RobotPose(Eigen::Translation3d(msg.position.x, msg.position.y, msg.position.z) *
117  quaternionMsgToEigen(msg.orientation));
118 }
Eigen::Quaterniond quaternionMsgToEigen(const geometry_msgs::Quaternion &msg)
Converts a quaternion message to Eigen::Quaterniond.
Definition: tf.cpp:135

◆ quaternionEigenToMsg()

geometry_msgs::Quaternion robowflex::TF::quaternionEigenToMsg ( const Eigen::Quaterniond &  quaternion)

Converts an Eigen::Quaterniond to a quaternion message.

Parameters
[in]quaternionQuaternion to convert.
Returns
quaternion as a quaternion message.

Definition at line 140 of file tf.cpp.

141 {
142  geometry_msgs::Quaternion msg;
143  msg.w = quaternion.w();
144  msg.x = quaternion.x();
145  msg.y = quaternion.y();
146  msg.z = quaternion.z();
147 
148  return msg;
149 }

◆ quaternionMsgToEigen()

Eigen::Quaterniond robowflex::TF::quaternionMsgToEigen ( const geometry_msgs::Quaternion &  msg)

Converts a quaternion message to Eigen::Quaterniond.

Parameters
[in]msgMessage to convert.
Returns
msg an Eigen::Quaterniond.

Definition at line 135 of file tf.cpp.

136 {
137  return Eigen::Quaterniond(msg.w, msg.x, msg.y, msg.z);
138 }

◆ sampleOrientation()

Eigen::Quaterniond robowflex::TF::sampleOrientation ( const Eigen::Quaterniond &  orientation,
const Eigen::Vector3d &  tolerances 
)

Sample an orientation from a given orientation with XYZ Euler angle tolerances.

Parameters
[in]orientationThe desired mean orientation.
[in]tolerancesXYZ Euler angle tolerances about orientation.
Returns
The sampled orientation.

Definition at line 207 of file tf.cpp.

209 {
210  const auto vec = RNG::uniformVec(tolerances);
211  Eigen::Quaterniond sampled = Eigen::AngleAxisd(vec[0], Eigen::Vector3d::UnitX()) //
212  * Eigen::AngleAxisd(vec[1], Eigen::Vector3d::UnitY()) //
213  * Eigen::AngleAxisd(vec[2], Eigen::Vector3d::UnitZ());
214 
215  return orientation * sampled;
216 }
Eigen::Vector3d uniformVec(const Eigen::Vector3d &lbound, const Eigen::Vector3d &ubound)
Generate a uniform real vector within given bounds: [lower_bound, upper_bound)
Definition: random.cpp:88

◆ sampleOrientationUniform()

Eigen::Quaterniond robowflex::TF::sampleOrientationUniform ( const Eigen::Vector3d &  tolerances)

Sample an orientation within the XYZ Euler angle tolerances.

Parameters
[in]tolerancesXYZ Euler angle tolerances about orientation.
Returns
The sampled orientation.

Definition at line 218 of file tf.cpp.

219 {
220  const auto vec = RNG::uniformRPY(tolerances);
221  Eigen::Quaterniond sampled = Eigen::AngleAxisd(vec[0], Eigen::Vector3d::UnitX()) //
222  * Eigen::AngleAxisd(vec[1], Eigen::Vector3d::UnitY()) //
223  * Eigen::AngleAxisd(vec[2], Eigen::Vector3d::UnitZ());
224 
225  return sampled;
226 }
Eigen::Vector3d uniformRPY(const Eigen::Vector3d &lbound, const Eigen::Vector3d &ubound)
Uniform random sampling of Euler roll-pitch-yaw angles within lower bound lbound and upper bound ubou...
Definition: random.cpp:57

◆ samplePoseGaussian()

RobotPose robowflex::TF::samplePoseGaussian ( const Eigen::Vector3d &  pos_stddev,
const Eigen::Vector3d &  orn_bounds 
)

Sample a pose with gaussian sampling for the position with given standard deviations and uniform sampling for the orientation within the given bounds.

Parameters
[in]pos_stddevThe desired position standard deviations.
[in]orn_boundsThe desired orientation bounds.
Returns
The sampled pose.

Definition at line 253 of file tf.cpp.

254 {
255  auto sampled = RobotPose::Identity();
256  sampled.translation() = samplePositionGaussian(pos_stddev);
257  sampled.linear() = sampleOrientationUniform(orn_bounds).toRotationMatrix();
258 
259  return sampled;
260 }
Eigen::Vector3d samplePositionGaussian(const Eigen::Vector3d &stddev)
Sample a position from a gaussian distribution with mean zero and given standard deviation.
Definition: tf.cpp:239
Eigen::Quaterniond sampleOrientationUniform(const Eigen::Vector3d &tolerances)
Sample an orientation within the XYZ Euler angle tolerances.
Definition: tf.cpp:218

◆ samplePoseUniform()

RobotPose robowflex::TF::samplePoseUniform ( const Eigen::Vector3d &  pos_bounds,
const Eigen::Vector3d &  orn_bounds 
)

Sample a pose within the given position, orientation bounds.

Parameters
[in]pos_boundsThe desired position bounds.
[in]orn_boundsThe desired orientation bounds.
Returns
The sampled pose.

Definition at line 244 of file tf.cpp.

245 {
246  auto sampled = RobotPose::Identity();
247  sampled.translation() = samplePositionUniform(pos_bounds);
248  sampled.linear() = sampleOrientationUniform(orn_bounds).toRotationMatrix();
249 
250  return sampled;
251 }
Eigen::Vector3d samplePositionUniform(const Eigen::Vector3d &bounds)
Sample a position within the given bounds using a uniform distribution.
Definition: tf.cpp:234

◆ samplePositionConstraint()

Eigen::Vector3d robowflex::TF::samplePositionConstraint ( const moveit_msgs::PositionConstraint &  pc)

◆ samplePositionGaussian()

Eigen::Vector3d robowflex::TF::samplePositionGaussian ( const Eigen::Vector3d &  stddev)

Sample a position from a gaussian distribution with mean zero and given standard deviation.

Parameters
[in]stddevThe desired standard deviation for the position.
Returns
The sampled position.

Definition at line 239 of file tf.cpp.

240 {
241  return RNG::gaussianVec(stddev);
242 }
Eigen::Vector3d gaussianVec(const Eigen::Vector3d &mean, const Eigen::Vector3d &stddev)
Generate a random real vector using a normal distribution with given mean and standard deviation.
Definition: random.cpp:103

◆ samplePositionUniform()

Eigen::Vector3d robowflex::TF::samplePositionUniform ( const Eigen::Vector3d &  bounds)

Sample a position within the given bounds using a uniform distribution.

Parameters
[in]boundsThe desired mean orientation.
Returns
The sampled position.

Definition at line 234 of file tf.cpp.

235 {
236  return RNG::uniformVec(bounds);
237 }

◆ toDegrees()

double robowflex::TF::toDegrees ( double  v)

Convert an angle to degrees.

Parameters
[in]vThe angle in radians.
Returns
The angle in degrees.

Definition at line 298 of file tf.cpp.

299 {
300  double n = angleNormalize(v);
301  double d = n * 180. / constants::pi;
302  if (n >= 0)
303  return d;
304 
305  return 360. + d;
306 }
double angleNormalize(double v)
Normalize an angle between -pi to pi.
Definition: tf.cpp:293

◆ toRadians()

double robowflex::TF::toRadians ( double  v)

Convert an angle to radians.

Parameters
[in]vThe angle in degrees.
Returns
The angle in radians.

Definition at line 308 of file tf.cpp.

309 {
310  if (v < 0)
311  v += 360.;
312  if (v >= 360.)
313  v -= 360.;
314 
315  if (v <= 180.)
316  return v * constants::pi / 180.;
317 
318  return -(360. - v) * constants::pi / 180.;
319 }

◆ transformEigenToMsg()

geometry_msgs::TransformStamped robowflex::TF::transformEigenToMsg ( const std::string source,
const std::string target,
const RobotPose tf 
)

Encode a transform as a message.

Parameters
[in]sourceSource frame.
[in]targetTarget frame.
[in]tfTransform between frames.
Returns
Transform message.

Definition at line 262 of file tf.cpp.

264 {
265  geometry_msgs::TransformStamped msg;
266 
267  msg.header.stamp = ros::Time::now();
268  msg.header.frame_id = source;
269  msg.child_frame_id = target;
270 
271  const auto &t = tf.translation();
272  msg.transform.translation.x = t.x();
273  msg.transform.translation.y = t.y();
274  msg.transform.translation.z = t.z();
275 
276  const auto &r = TF::getPoseRotation(tf);
277  msg.transform.rotation = quaternionEigenToMsg(r);
278 
279  return msg;
280 }

◆ transformMsgToEigen()

RobotPose robowflex::TF::transformMsgToEigen ( const geometry_msgs::TransformStamped &  tf)

Decode a message as a transform.

Parameters
[in]tfTransform message.
Returns
The transform.

Definition at line 282 of file tf.cpp.

283 {
284  RobotPose pose;
285  pose.translation().x() = tf.transform.translation.x;
286  pose.translation().y() = tf.transform.translation.y;
287  pose.translation().z() = tf.transform.translation.z;
288 
289  pose.linear() = quaternionMsgToEigen(tf.transform.rotation).toRotationMatrix();
290  return pose;
291 }

◆ vectorEigenToMsg()

geometry_msgs::Vector3 robowflex::TF::vectorEigenToMsg ( const Eigen::Vector3d &  vector)

Converts an Eigen::Vector3d to a vector message.

Parameters
[in]vectorVector to convert.
Returns
vector as a vector message.

Definition at line 104 of file tf.cpp.

105 {
106  geometry_msgs::Vector3 msg;
107  msg.x = vector[0];
108  msg.y = vector[1];
109  msg.z = vector[2];
110 
111  return msg;
112 }

◆ vectorMsgToEigen()

Eigen::Vector3d robowflex::TF::vectorMsgToEigen ( const geometry_msgs::Vector3 &  msg)

Converts a vector message to an Eigen::Vector3d.

Parameters
[in]msgMessage to convert.
Returns
msg as an Eigen::Vector3d.

Definition at line 94 of file tf.cpp.

95 {
96  Eigen::Vector3d vector;
97  vector[0] = msg.x;
98  vector[1] = msg.y;
99  vector[2] = msg.z;
100 
101  return vector;
102 }