Skip to content

Commit 902c027

Browse files
authored
Merge pull request #172 from machines-in-motion/topic/mnaveau/fix_python_bindings_bugs
[operators][fir_filter] fix some bug on the python bindings side
2 parents 42ea48c + 57b6fc2 commit 902c027

10 files changed

+146
-43
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ include/sot-core/import-default-paths.h
44
unitTesting/test-paths.h
55
*~
66
_build*
7+
*__pycache__*

src/dynamic_graph/sot/core/math_small_entities.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
HomoToTwist, Inverse_of_matrix, Inverse_of_matrixHomo,
1212
Inverse_of_matrixrotation, Inverse_of_matrixtwist, Inverse_of_unitquat,
1313
MatrixDiagonal, MatrixHomoToPose, MatrixHomoToPoseQuaternion,
14-
PoseQuatToMatrixHomo, MatrixHomoToPoseRollPitchYaw, MatrixHomoToPoseUTheta,
15-
MatrixToHomo, MatrixToQuaternion, MatrixToRPY, MatrixToUTheta,
16-
MatrixHomoToSE3Vector, SE3VectorToMatrixHomo, MatrixTranspose,
17-
Multiply_double_vector, Multiply_matrix_vector,
14+
PoseQuaternionToMatrixHomo, MatrixHomoToPoseRollPitchYaw,
15+
MatrixHomoToPoseUTheta, MatrixToHomo, MatrixToQuaternion, MatrixToRPY,
16+
MatrixToUTheta, MatrixHomoToSE3Vector, SE3VectorToMatrixHomo,
17+
MatrixTranspose, Multiply_double_vector, Multiply_matrix_vector,
1818
Multiply_matrixTwist_vector, Multiply_matrixHomo_vector,
1919
Multiply_of_double, Multiply_of_matrix, Multiply_of_matrixHomo,
2020
Multiply_of_matrixrotation, Multiply_of_matrixtwist,

src/dynamic_graph/sot/core/meta_task_posture.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from dynamic_graph.sot.core.matrix_util import matrixToTuple, vectorToTuple
55
from dynamic_graph.sot.core.meta_task_6d import toFlags # kept for backward compatibility
66
from dynamic_graph.sot.core.meta_tasks import setGain
7-
from dynamic_graph.sot.core.sot import Task
7+
from dynamic_graph.sot.core.task import Task
88
from numpy import identity, matrix, zeros
99

1010

src/dynamic_graph/sot/core/meta_task_visual_point.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from dynamic_graph.sot.core.gain_adaptive import GainAdaptive
44
from dynamic_graph.sot.core.meta_tasks import setGain
55
from dynamic_graph.sot.core.op_point_modifier import OpPointModifier
6-
from dynamic_graph.sot.core.sot import Task
6+
from dynamic_graph.sot.core.task import Task
77
from dynamic_graph.sot.core.visual_point_projecter import VisualPointProjecter
88

99

src/matrix/fir-filter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ using dynamicgraph::Vector;
2323
\
2424
template <> \
2525
const std::string sotClassType<sotSigType, sotCoefType>::CLASS_NAME = \
26-
std::string(className) + "_" + #sotSigType + "," + #sotCoefType + "_"; \
26+
std::string(className) + "_" + #sotSigType + "_" + #sotCoefType; \
2727
\
2828
template <> \
2929
const std::string &sotClassType<sotSigType, sotCoefType>::getClassName(void) \

src/matrix/operator-python-module-py.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,12 @@ BOOST_PYTHON_MODULE(wrap)
9999
/* --- SE3/SO3 conversions ----------------------------------------------- */
100100
/* ----------------------------------------------------------------------- */
101101

102-
exposeUnaryOp < HomogeneousMatrixToVector> ();
103102
exposeUnaryOp < SkewSymToVector> ();
104103
exposeUnaryOp < PoseUThetaToMatrixHomo> ();
104+
exposeUnaryOp < MatrixHomoToPoseUTheta> ();
105+
exposeUnaryOp < MatrixHomoToSE3Vector> ();
106+
exposeUnaryOp < SE3VectorToMatrixHomo> ();
107+
exposeUnaryOp < PoseQuaternionToMatrixHomo> ();
105108
exposeUnaryOp < MatrixHomoToPoseQuaternion> ();
106109
exposeUnaryOp < MatrixHomoToPoseRollPitchYaw> ();
107110
exposeUnaryOp < PoseRollPitchYawToMatrixHomo> ();

src/matrix/operator.cpp

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -57,42 +57,13 @@ REGISTER_UNARY_OP(InverserQuaternion, Inverse_of_unitquat);
5757
/* --- SE3/SO3 conversions ----------------------------------------------- */
5858
/* ----------------------------------------------------------------------- */
5959

60-
REGISTER_UNARY_OP(HomogeneousMatrixToVector, MatrixHomoToPoseUTheta);
61-
62-
struct HomogeneousMatrixToSE3Vector
63-
: public UnaryOpHeader<MatrixHomogeneous, dg::Vector> {
64-
void operator()(const MatrixHomogeneous &M, dg::Vector &res) {
65-
res.resize(12);
66-
res.head<3>() = M.translation();
67-
res.segment(3, 3) = M.linear().row(0);
68-
res.segment(6, 3) = M.linear().row(1);
69-
res.segment(9, 3) = M.linear().row(2);
70-
}
71-
};
72-
REGISTER_UNARY_OP(HomogeneousMatrixToSE3Vector, MatrixHomoToSE3Vector);
73-
74-
struct SE3VectorToHomogeneousMatrix
75-
: public UnaryOpHeader<dg::Vector, MatrixHomogeneous> {
76-
void operator()(const dg::Vector &vect, MatrixHomogeneous &Mres) {
77-
Mres.translation() = vect.head<3>();
78-
Mres.linear().row(0) = vect.segment(3, 3);
79-
Mres.linear().row(1) = vect.segment(6, 3);
80-
Mres.linear().row(2) = vect.segment(9, 3);
81-
}
82-
};
83-
REGISTER_UNARY_OP(SE3VectorToHomogeneousMatrix, SE3VectorToMatrixHomo);
60+
REGISTER_UNARY_OP(MatrixHomoToPoseUTheta, MatrixHomoToPoseUTheta);
61+
REGISTER_UNARY_OP(MatrixHomoToSE3Vector, MatrixHomoToSE3Vector);
62+
REGISTER_UNARY_OP(SE3VectorToMatrixHomo, SE3VectorToMatrixHomo);
8463
REGISTER_UNARY_OP(SkewSymToVector, SkewSymToVector);
8564
REGISTER_UNARY_OP(PoseUThetaToMatrixHomo, PoseUThetaToMatrixHomo);
8665
REGISTER_UNARY_OP(MatrixHomoToPoseQuaternion, MatrixHomoToPoseQuaternion);
87-
88-
struct PoseQuaternionToMatrixHomo
89-
: public UnaryOpHeader<Vector, MatrixHomogeneous> {
90-
void operator()(const dg::Vector &vect, MatrixHomogeneous &Mres) {
91-
Mres.translation() = vect.head<3>();
92-
Mres.linear() = VectorQuaternion(vect.tail<4>()).toRotationMatrix();
93-
}
94-
};
95-
REGISTER_UNARY_OP(PoseQuaternionToMatrixHomo, PoseQuatToMatrixHomo);
66+
REGISTER_UNARY_OP(PoseQuaternionToMatrixHomo, PoseQuaternionToMatrixHomo);
9667
REGISTER_UNARY_OP(MatrixHomoToPoseRollPitchYaw, MatrixHomoToPoseRollPitchYaw);
9768
REGISTER_UNARY_OP(PoseRollPitchYawToMatrixHomo, PoseRollPitchYawToMatrixHomo);
9869
REGISTER_UNARY_OP(PoseRollPitchYawToPoseUTheta, PoseRollPitchYawToPoseUTheta);

src/matrix/operator.hh

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ struct InverserQuaternion
278278
/* --- SE3/SO3 conversions ----------------------------------------------- */
279279
/* ----------------------------------------------------------------------- */
280280

281-
struct HomogeneousMatrixToVector
281+
struct MatrixHomoToPoseUTheta
282282
: public UnaryOpHeader<MatrixHomogeneous, dg::Vector> {
283283
inline void operator()(const MatrixHomogeneous &M, dg::Vector &res) {
284284
res.resize(6);
@@ -310,6 +310,35 @@ struct PoseUThetaToMatrixHomo
310310
}
311311
};
312312

313+
struct SE3VectorToMatrixHomo
314+
: public UnaryOpHeader<dg::Vector, MatrixHomogeneous> {
315+
void operator()(const dg::Vector &vect, MatrixHomogeneous &Mres) {
316+
Mres.translation() = vect.head<3>();
317+
Mres.linear().row(0) = vect.segment(3, 3);
318+
Mres.linear().row(1) = vect.segment(6, 3);
319+
Mres.linear().row(2) = vect.segment(9, 3);
320+
}
321+
};
322+
323+
struct MatrixHomoToSE3Vector
324+
: public UnaryOpHeader<MatrixHomogeneous, dg::Vector> {
325+
void operator()(const MatrixHomogeneous &M, dg::Vector &res) {
326+
res.resize(12);
327+
res.head<3>() = M.translation();
328+
res.segment(3, 3) = M.linear().row(0);
329+
res.segment(6, 3) = M.linear().row(1);
330+
res.segment(9, 3) = M.linear().row(2);
331+
}
332+
};
333+
334+
struct PoseQuaternionToMatrixHomo
335+
: public UnaryOpHeader<Vector, MatrixHomogeneous> {
336+
void operator()(const dg::Vector &vect, MatrixHomogeneous &Mres) {
337+
Mres.translation() = vect.head<3>();
338+
Mres.linear() = VectorQuaternion(vect.tail<4>()).toRotationMatrix();
339+
}
340+
};
341+
313342
struct MatrixHomoToPoseQuaternion
314343
: public UnaryOpHeader<MatrixHomogeneous, Vector> {
315344
inline void operator()(const MatrixHomogeneous &M, Vector &res) {

tests/matrix/test_operator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ BOOST_AUTO_TEST_CASE(matrixHomo_poseQuaternion) {
199199
test_impl<MatrixHomoToPoseQuaternion, PoseQuaternionToMatrixHomo>();
200200
}
201201
BOOST_AUTO_TEST_CASE(matrixHomo_se3Vector) {
202-
test_impl<HomogeneousMatrixToSE3Vector, SE3VectorToHomogeneousMatrix>();
202+
test_impl<MatrixHomoToSE3Vector, SE3VectorToMatrixHomo>();
203203
}
204204

205205
BOOST_AUTO_TEST_SUITE_END()

tests/python/python_imports.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/usr/bin/env python
2+
3+
import unittest
4+
5+
class PythonImportTest(unittest.TestCase):
6+
def test_math_small_entities(self):
7+
try:
8+
import dynamic_graph.sot.core.math_small_entities
9+
except ImportError as ie:
10+
self.fail(str(ie))
11+
12+
def test_feature_position_relative(self):
13+
try:
14+
import dynamic_graph.sot.core.feature_position_relative
15+
except ImportError as ie:
16+
self.fail(str(ie))
17+
18+
def test_feature_position(self):
19+
try:
20+
import dynamic_graph.sot.core.feature_position
21+
except ImportError as ie:
22+
self.fail(str(ie))
23+
24+
def test_matrix_util(self):
25+
try:
26+
import dynamic_graph.sot.core.matrix_util
27+
except ImportError as ie:
28+
self.fail(str(ie))
29+
30+
def test_meta_task_6d(self):
31+
try:
32+
import dynamic_graph.sot.core.meta_task_6d
33+
except ImportError as ie:
34+
self.fail(str(ie))
35+
36+
def test_meta_task_posture(self):
37+
try:
38+
import dynamic_graph.sot.core.meta_task_posture
39+
except ImportError as ie:
40+
self.fail(str(ie))
41+
42+
def test_meta_task_visual_point(self):
43+
try:
44+
import dynamic_graph.sot.core.meta_task_visual_point
45+
except ImportError as ie:
46+
self.fail(str(ie))
47+
48+
def test_meta_tasks_kine_relative(self):
49+
try:
50+
import dynamic_graph.sot.core.meta_tasks_kine_relative
51+
except ImportError as ie:
52+
self.fail(str(ie))
53+
54+
def test_meta_tasks_kine(self):
55+
try:
56+
import dynamic_graph.sot.core.meta_tasks_kine
57+
except ImportError as ie:
58+
self.fail(str(ie))
59+
60+
def test_meta_tasks(self):
61+
try:
62+
import dynamic_graph.sot.core.meta_tasks
63+
except ImportError as ie:
64+
self.fail(str(ie))
65+
66+
def test_attime(self):
67+
try:
68+
import dynamic_graph.sot.core.utils.attime
69+
except ImportError as ie:
70+
self.fail(str(ie))
71+
72+
def test_history(self):
73+
try:
74+
import dynamic_graph.sot.core.utils.history
75+
except ImportError as ie:
76+
self.fail(str(ie))
77+
78+
@unittest.skip("Fail on 'import dynamic_graph.matlab'")
79+
def test_thread_interruptible_loop(self):
80+
try:
81+
import dynamic_graph.sot.core.utils.thread_interruptible_loop
82+
except ImportError as ie:
83+
self.fail(str(ie))
84+
85+
86+
def test_viewer_helper(self):
87+
try:
88+
import dynamic_graph.sot.core.utils.viewer_helper
89+
except ImportError as ie:
90+
self.fail(str(ie))
91+
92+
93+
def test_viewer_loger(self):
94+
try:
95+
import dynamic_graph.sot.core.utils.viewer_loger
96+
except ImportError as ie:
97+
self.fail(str(ie))
98+
if __name__ == '__main__':
99+
unittest.main()

0 commit comments

Comments
 (0)