From bccbbe46399f3b619341a06366765739fd87789f Mon Sep 17 00:00:00 2001 From: Giulio Romualdi Date: Tue, 25 Jan 2022 20:26:06 +0100 Subject: [PATCH] Extend the python bindings for Rotation Position and Transform - Add the possibility to construct a Position object with a python array - Add the possibility to construct a Rotation object with a python matrix - Add the possibility to call setRotation and setPosition directly with python matrix and array --- bindings/python/python.i | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/bindings/python/python.i b/bindings/python/python.i index 333c3f18d94..1e5033fec73 100644 --- a/bindings/python/python.i +++ b/bindings/python/python.i @@ -326,6 +326,13 @@ import_array(); return iDynTree::RotationRaw(in, static_cast(i), static_cast(j)); } + + Rotation(const double* in_data, const std::ptrdiff_t in_rows, const std::ptrdiff_t in_cols) { + iDynTree::Rotation* rot = new iDynTree::Rotation(iDynTree::RotationRaw(in_data, + static_cast(in_rows), + static_cast(in_cols))); + return rot; + } }; %extend iDynTree::Position { @@ -335,8 +342,29 @@ import_array(); return iDynTree::PositionRaw(in, static_cast(size)); } + + Position(const double* in_data, const unsigned in_size) { + iDynTree::Position* pos = new iDynTree::Position(iDynTree::PositionRaw(in_data, in_size)); + return pos; + } }; +%extend iDynTree::Transform { + + void setPosition(const double* in_data, const unsigned in_size) { + $self->setPosition(iDynTree::PositionRaw(in_data, static_cast(in_size))); + } + + void setRotation(const double* in_data, + const std::ptrdiff_t in_rows, + const std::ptrdiff_t in_cols) { + $self->setRotation(iDynTree::RotationRaw(in_data, + static_cast(in_rows), + static_cast(in_cols))); + } +}; + + %attributeref(iDynTree::FreeFloatingPos, iDynTree::Transform&, worldBasePos) %attributeref(iDynTree::FreeFloatingPos, iDynTree::JointPosDoubleArray&, jointPos) %attributeref(iDynTree::FreeFloatingVel, iDynTree::Twist&, baseVel)