Skip to content

Commit caa24f5

Browse files
authored
Merge pull request #152 from NoelieRamuzat/devel
[operator] Add operator PoseQuaternionToHomogeneousMatrix
2 parents 2ccf06c + f8978fb commit caa24f5

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

Diff for: src/dynamic_graph/sot/core/math_small_entities.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
Compose_R_and_T, ConvolutionTemporal, HomoToMatrix, HomoToRotation,
1111
HomoToTwist, Inverse_of_matrix, Inverse_of_matrixHomo,
1212
Inverse_of_matrixrotation, Inverse_of_matrixtwist, Inverse_of_unitquat,
13-
MatrixDiagonal, MatrixHomoToPose, MatrixHomoToPoseQuaternion,
13+
MatrixDiagonal, MatrixHomoToPose, MatrixHomoToPoseQuaternion, PoseQuatToMatrixHomo,
1414
MatrixHomoToPoseRollPitchYaw, MatrixHomoToPoseUTheta, MatrixToHomo,
1515
MatrixToQuaternion, MatrixToRPY, MatrixToUTheta, MatrixTranspose,
1616
Multiply_double_vector, Multiply_matrix_vector,

Diff for: src/matrix/operator.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,15 @@ struct MatrixHomoToPoseQuaternion
356356
};
357357
REGISTER_UNARY_OP(MatrixHomoToPoseQuaternion, MatrixHomoToPoseQuaternion);
358358

359+
struct PoseQuaternionToMatrixHomo
360+
: public UnaryOpHeader<Vector, MatrixHomogeneous> {
361+
void operator()(const dg::Vector &vect, MatrixHomogeneous &Mres) {
362+
Mres.translation() = vect.head<3>();
363+
Mres.linear() = VectorQuaternion(vect.tail<4>()).toRotationMatrix();
364+
}
365+
};
366+
REGISTER_UNARY_OP(PoseQuaternionToMatrixHomo, PoseQuatToMatrixHomo);
367+
359368
struct MatrixHomoToPoseRollPitchYaw
360369
: public UnaryOpHeader<MatrixHomogeneous, Vector> {
361370
void operator()(const MatrixHomogeneous &M, dg::Vector &res) {

Diff for: tests/matrix/test_operator.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ template <> VectorQuaternion random<VectorQuaternion>() {
154154
template <> MatrixRotation random<MatrixRotation>() {
155155
return MatrixRotation(random<VectorQuaternion>());
156156
}
157+
template <> MatrixHomogeneous random<MatrixHomogeneous>() {
158+
MatrixHomogeneous matrix_homo;
159+
matrix_homo.translation() = Eigen::Vector3d::Random();
160+
matrix_homo.linear() = random<MatrixRotation>();
161+
return matrix_homo;
162+
}
157163

158164
template <typename type> bool compare(const type &a, const type &b) {
159165
return a.isApprox(b);
@@ -189,5 +195,8 @@ BOOST_AUTO_TEST_CASE(quaternion_rpy) {
189195
BOOST_AUTO_TEST_CASE(matrix_quaternion) {
190196
test_impl<MatrixToQuaternion, QuaternionToMatrix>();
191197
}
198+
BOOST_AUTO_TEST_CASE(matrixHomo_poseQuaternion) {
199+
test_impl<MatrixHomoToPoseQuaternion, PoseQuaternionToMatrixHomo>();
200+
}
192201

193202
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)