Adds python interface to PID and SemanticVersion.#229
Conversation
Signed-off-by: LolaSegura <lsegura@ekumenlabs.com>
Codecov Report
@@ Coverage Diff @@
## ign-math6 #229 +/- ##
==========================================
Coverage 99.21% 99.21%
==========================================
Files 65 65
Lines 6089 6089
==========================================
Hits 6041 6041
Misses 48 48 Continue to review full report at Codecov.
|
francocipollone
left a comment
There was a problem hiding this comment.
LGTM, just some nits
|
I've removed the draft label. @LolaSegura Let me know if there is something that is missing |
Signed-off-by: LolaSegura <lsegura@ekumenlabs.com>
francocipollone
left a comment
There was a problem hiding this comment.
LGTM
@scpeters @chapulina It is ready for a review!
Signed-off-by: Louise Poubel <louise@openrobotics.org>
chapulina
left a comment
There was a problem hiding this comment.
LGTM!
The Update(const double _error, const std::chrono::duration &_dt) method received a variable of type std::chrono::duration. To give support to this method in python a new update function was defined using the %extend command. This new update method receives a variable of type double double Update(const double error, double dt).
I think this is ok for now, but maybe in the future we should look into using python time to be more expressive?
Agree. I think that we should provide a conversion from std::chrono to python time. Sadly, swig doesn't provide bindings as it does for |
Signed-off-by: LolaSegura lsegura@ekumenlabs.com
🎉 New feature
Related to #101 #210
Summary
Adds Python interface for two math classes: PID, SemanticVersion. For each class a python test has been created.
Related issues and notes
PID
operator=is not supported, there was no way to copy two variables of type PID.Update(const double _error, const std::chrono::duration<double> &_dt)method received a variable of typestd::chrono::duration. To give support to this method in python a new update function was defined using the%extendcommand. This new update method receives a variable of type doubledouble Update(const double error, double dt).void Errors(double &_pe, double &_ie, double &_de) const;method changed the values of the arguments inside it. For native types swig has a way to handle this using the%apply <type> *OUTPUT {}directive. So in python this method can be used as[pe, ie, de] = pid.errors()%renamecommand is failing on adding and under case when the variable name is conformed by one letter and a world, for example,PGain()was being renamed aspgain()instead ofp_gain(). So this cases where contemplated using an specific%renametag.SemanticVersion
std_string.imodule was added in order to work withstd::string.Checklist
codecheckpassed (See contributing)