Skip to content

Commit

Permalink
Extend the python bindings for Rotation Position and Transform
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
GiulioRomualdi committed Jan 25, 2022
1 parent 35ff9e5 commit bccbbe4
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions bindings/python/python.i
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,13 @@ import_array();

return iDynTree::RotationRaw(in, static_cast<unsigned>(i), static_cast<unsigned>(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<unsigned>(in_rows),
static_cast<unsigned>(in_cols)));
return rot;
}
};

%extend iDynTree::Position {
Expand All @@ -335,8 +342,29 @@ import_array();

return iDynTree::PositionRaw(in, static_cast<unsigned>(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<unsigned>(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<unsigned>(in_rows),
static_cast<unsigned>(in_cols)));
}
};


%attributeref(iDynTree::FreeFloatingPos, iDynTree::Transform&, worldBasePos)
%attributeref(iDynTree::FreeFloatingPos, iDynTree::JointPosDoubleArray&, jointPos)
%attributeref(iDynTree::FreeFloatingVel, iDynTree::Twist&, baseVel)
Expand Down

0 comments on commit bccbbe4

Please sign in to comment.