47 #ifndef _MIRA_TRANSFORMCAST_H__ 48 #define _MIRA_TRANSFORMCAST_H__ 60 template<
typename TargetTransform,
61 typename TargetT,
int TargetDim,
62 typename SourceTransform,
63 typename SourceT,
int SourceDim>
64 struct TransformCast {
65 static TargetTransform invoke(
const SourceTransform& other) {
66 RigidTransform<TargetT,SourceDim> tfWithTargetT(other.t.template cast<TargetT>(), other.r.template cast<TargetT>());
67 return TransformCast<RigidTransform<TargetT,TargetDim>, TargetT, TargetDim,
68 RigidTransform<TargetT,SourceDim>, TargetT, SourceDim>::invoke(tfWithTargetT);
75 template<
typename TargetT,
int TargetDim,
76 typename SourceTransform,
77 typename SourceT,
int SourceDim>
78 struct TransformCast<RigidTransformCov<TargetT, TargetDim>, TargetT, TargetDim, SourceTransform, SourceT, SourceDim> {
79 static RigidTransformCov<TargetT, TargetDim> invoke(
const SourceTransform& other) {
80 RigidTransformCov<TargetT,SourceDim> tfWithTargetT(other.template cast<TargetT>());
81 return TransformCast<RigidTransformCov<TargetT, TargetDim>, TargetT, TargetDim,
82 RigidTransformCov<TargetT,SourceDim>, TargetT, SourceDim>::invoke(tfWithTargetT);
90 template<
typename T,
int Dim>
91 struct TransformCast<RigidTransform<T, Dim>, T, Dim, RigidTransform<T, Dim>, T, Dim> {
92 static RigidTransform<T, Dim> invoke(
const RigidTransform<T, Dim>& other) {
98 template<
typename T,
int Dim>
99 struct TransformCast<RigidTransformCov<T, Dim>, T, Dim, RigidTransformCov<T, Dim>, T, Dim> {
100 static RigidTransformCov<T, Dim> invoke(
const RigidTransformCov<T, Dim>& other) {
109 struct TransformCast<RigidTransform<T,2>, T, 2, RigidTransform<T,3>, T, 3> {
110 static RigidTransform<T,2> invoke(
const RigidTransform<T,3>& other) {
114 return RigidTransform<T,2>(other.x(), other.y(), euler(0,0) );
121 struct TransformCast<RigidTransform<T,3>, T, 3, RigidTransform<T,2>, T, 2> {
122 static RigidTransform<T,3> invoke(
const RigidTransform<T,2>& other) {
131 struct TransformCast<RigidTransformCov<T,2>, T, 2, RigidTransformCov<T,3>, T, 3> {
132 static RigidTransformCov<T,2> invoke(
const RigidTransformCov<T,3>& other) {
143 cov.template block<2,2>(0,0) = otherEulerCov.template block<2,2>(0,0);
145 cov.template block<2,1>(0,2) = otherEulerCov.template block<2,1>(0,3);
147 cov.template block<1,2>(2,0) = otherEulerCov.template block<1,2>(3,0);
149 cov(2,2) = otherEulerCov(3,3);
151 return RigidTransformCov<T,2>(other.x(), other.y(), euler(0,0), cov);
158 struct TransformCast<RigidTransformCov<T,3>, T, 3, RigidTransformCov<T,2>, T, 2> {
159 static RigidTransformCov<T,3> invoke(
const RigidTransformCov<T,2>& other) {
164 eulerCov.template block<2,2>(0,0) = other.cov.template block<2,2>(0,0);
166 eulerCov.template block<2,1>(0,3) = other.cov.template block<2,1>(0,2);
168 eulerCov.template block<1,2>(3,0) = other.cov.template block<1,2>(2,0);
170 eulerCov(3,3) = other.cov(2,2);
175 return RigidTransformCov<T, 3>(
177 orientation, eulerCov);
183 template<
typename T,
int D>
184 struct TransformCast<RigidTransformCov<T,D>, T, D, RigidTransform<T,D>, T, D> {
185 static RigidTransformCov<T,D> invoke(
const RigidTransform<T,D>& other) {
186 return RigidTransformCov<T,D>(other);
192 template<
typename T,
int D>
193 struct TransformCast<RigidTransform<T,D>, T, D, RigidTransformCov<T,D>, T, D> {
194 static RigidTransform<T,D> invoke(
const RigidTransformCov<T,D>& other) {
195 return RigidTransform<T,D>(other);
201 template<
typename T,
int TargetD,
int SourceD>
202 struct TransformCast<RigidTransformCov<T,TargetD>, T, TargetD,
203 RigidTransform<T,SourceD>, T, SourceD> {
204 static RigidTransformCov<T,TargetD> invoke(
const RigidTransform<T,SourceD>& other) {
206 typedef TransformCast<RigidTransform<T,TargetD>, T, TargetD,
207 RigidTransform<T,SourceD>, T, SourceD> Cast;
208 RigidTransform<T,TargetD> tmp = Cast::invoke(other);
211 return RigidTransformCov<T,TargetD>(tmp);
217 template<
typename T,
int TargetD,
int SourceD>
218 struct TransformCast<RigidTransform<T,TargetD>, T, TargetD,
219 RigidTransformCov<T,SourceD>, T, SourceD> {
220 static RigidTransform<T,TargetD> invoke(
const RigidTransformCov<T,SourceD>& other) {
222 typedef TransformCast<RigidTransform<T,TargetD>, T, TargetD,
223 RigidTransform<T,SourceD>, T, SourceD> Cast;
224 return Cast::invoke(other);
248 template<
typename TargetTransform,
typename OtherT,
int OtherD>
251 return TransformCast<TargetTransform,
typename TargetTransform::Type, TargetTransform::Dim,
269 template<
typename TargetTransform,
typename OtherT,
int OtherD>
272 return TransformCast<TargetTransform,
typename TargetTransform::Type, TargetTransform::Dim,
Eigen::Matrix< T, 6, 6 > quaternionCovToYawPitchRollCov(const Eigen::Matrix< T, 7, 7 > &covariance, const Eigen::Quaternion< T > &q)
Converts a 7x7 dimensional quaternion covariance (3D + Quaternion) back to a 6x6 dimensional euler co...
Definition: YawPitchRoll.h:318
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
Conversion from yaw, pitch and roll to Quaternion and vice versa.
Eigen::Matrix< typename Eigen::MatrixBase< Derived >::Scalar, 3, 1 > eulerAngles(const Eigen::MatrixBase< Derived > &mat, typename Eigen::MatrixBase< Derived >::Index a0, typename Eigen::MatrixBase< Derived >::Index a1, typename Eigen::MatrixBase< Derived >::Index a2)
Returns the Euler-angles of the rotation matrix mat using the convention defined by the triplet (a0...
Definition: YawPitchRoll.h:86