Adds python interface to Quaternion, Pose3, Matrix3 and Matrix4#221
Adds python interface to Quaternion, Pose3, Matrix3 and Matrix4#221
Conversation
Codecov Report
@@ Coverage Diff @@
## ign-math6 #221 +/- ##
==========================================
Coverage 99.40% 99.40%
==========================================
Files 66 66
Lines 6185 6185
==========================================
Hits 6148 6148
Misses 37 37
Continue to review full report at Codecov.
|
6f5bb13 to
ad00569
Compare
Signed-off-by: LolaSegura <lsegura@ekumenlabs.com>
Signed-off-by: LolaSegura <lsegura@ekumenlabs.com>
Signed-off-by: LolaSegura <lsegura@ekumenlabs.com>
Signed-off-by: LolaSegura <lsegura@ekumenlabs.com>
Signed-off-by: LolaSegura <lsegura@ekumenlabs.com>
Signed-off-by: LolaSegura <lsegura@ekumenlabs.com>
…tyle. Signed-off-by: LolaSegura <lsegura@ekumenlabs.com>
…hon test to the python folder. Signed-off-by: LolaSegura <lsegura@ekumenlabs.com>
ad00569 to
88dc6f6
Compare
francocipollone
left a comment
There was a problem hiding this comment.
Good job! Just a few comments.
Signed-off-by: LolaSegura <lsegura@ekumenlabs.com>
Signed-off-by: LolaSegura <lsegura@ekumenlabs.com>
Signed-off-by: LolaSegura <lsegura@ekumenlabs.com>
Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
I've pushed a workaround at f394e9c for adding coverage to |
Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
|
I've just fixed conflicts. |
|
I'm almost done reviewing this; looks good so far, and you've found bugs in our c++ code! Great work |
This changes the test matrices that are multiplied togther so that they aren't scalar multiples of each other. This confirms non-commutativity in the test. Signed-off-by: Steve Peters <scpeters@openrobotics.org>
|
I noticed a problem in our |
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
|
I added a stream out test to Matrix3_TEST.py in bb6b120 |
|
there's one final thing that I've noticed and will file in an issue: the python tests are missing some statement in which scalars are left multiplied to Vector and Matrix types ( |
|
Nice catch. Thanks for filling the issue. |
* Adds scripting interface to Quaternion and a python test * Adds scripting interface to Matrix3 and a python test * Adds scripting interface to Pose3 and a python test * Solves bug in the Reset() method inside Pose3 * Adds scripting interface to Matrix4 and a python test * Solves bug in the Construct test for Matrix4 class * Adds %rename tag to interface files in order to match pep-8 naiming style. * Adds a python method to convert from a Matrix3 to a Quaternion. * Adds to_quaternion() method to Matrix3. Signed-off-by: LolaSegura <lsegura@ekumenlabs.com> * Adds python binding for Quaternion::ToAxis method. Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com> * Matrix3_TEST: improve multiplication test This changes the test matrices that are multiplied togther so that they aren't scalar multiples of each other. This confirms non-commutativity in the test. * Matrix3_TEST.py: add stream out test Signed-off-by: Steve Peters <scpeters@openrobotics.org> Co-authored-by: Franco Cipollone <franco.c@ekumenlabs.com> Co-authored-by: Franco Cipollone <53065142+francocipollone@users.noreply.github.com> Co-authored-by: Steve Peters <scpeters@openrobotics.org> Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
🎉 New feature
Goes on top of #216
Related to #101 #210
Summary
Adds Python interface for three math classes: Quaternion, Pose3, Matrix3, Matrix4. For each class a python test has been created.
Related issues and notes
Quaternion
operator<<had to be made. This adds a__str()__method that callsoperator<<inside.W(),X(),Y()andZ()was re-defined using%extend().void ToAxis(Vector3<T> &_axis, T &_angle) const;is currently not being supported because both parameters (_axisand_angle) are being modify inside it and there is not a straight forward implementation for these cases when using swig.- The solution we implemented was not giving support to the Quaternion constructor from a Matrix3 (which was the only method that was using the Matrix3 class) and add a python method to Matrix3 that makes this transformation. We used the
- Another option could be that: instead of defining the Quaternion templates inside the
define them inside the%extendcommand and called theQuaternion(Matrix3<t> _mat);constructor inside it.Quaternion.ifile, like is being done at the momentMatrix3.ifile, and add an extension of the matrix method that is being called in the constructor from the Quaternion class:This last approach would imply that for using Quaternion in python the class Matrix3 has to be bind.
Pose3
Reset()method resets the value of the quaternion as:this->q = Quaternion<double> ::IdentityI change this tothis->q = Quaternion<T> ::Identitybecause the implementation would only work when the template was of type double. 'operator<<had to be made. This adds a__str()__method that callsoperator<<inside.Matrix3
operator<<had to be made. This adds a__str()__method that callsoperator<<inside.operator()method functionality in python, the class had to be extended in the interface file.Matrix4
Matrix4_TEST.ccon the constructor test bothforloops where testingEXPECT_DOUBLE_EQ(mat2(i, **i**), 0.0);, so only the elements on the diagonal were tested. I changed toEXPECT_DOUBLE_EQ(mat2(i, **j**), 0.0);operator<<had to be made. This adds a__str()__method that callsoperator<<inside.operator()method functionality in python, the class had to be extended in the interface file.Checklist
codecheckpassed (See contributing)