Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the possibility to use FromPython to generate rotation and position in the python bindings #959

Merged
merged 4 commits into from
Jan 26, 2022

Conversation

GiulioRomualdi
Copy link
Member

With this PR it is possible to use FromPython methods to covert a python array into a rotation/position

For instance thanks to this PR it will be possible to write the following code in python

transform = idyn.Transform()

transform.setRotation(idyn.Rotation.FromPython(base_rotation))
transform.setPosition(idyn.Position.FromPython(base_position))

Before this PR as far as I know the way to populate a transform object was this one

base_rotation_idyn = idyn.Rotation()
base_position_idyn = idyn.Position()
base_pose_idyn = idyn.Transform()

for i in range(0, 3):
    base_position_idyn.setVal(i, base_position[I])
    for j in range(0, 3):
        base_rotation_idyn.setVal(i, j, base_rotation[i, j])

base_pose_idyn.setRotation(base_rotation_idyn)
base_pose_idyn.setPosition(base_position_idyn)

@GiulioRomualdi GiulioRomualdi self-assigned this Jan 24, 2022
- 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
@GiulioRomualdi
Copy link
Member Author

Thanks to bccbbe4 it is now also possible to do

import idyntree.bindings as idyn
import numpy as np

T = idyn.Transform()
T.setRotation(np.eye(3))
T.setPosition([1,2,3])

p = idyn.Position([1,2,3])
R = idyn.Rotation(np.eye(3))

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Member

@traversaro traversaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment.

Co-authored-by: Silvio Traversaro <silvio.traversaro@iit.it>
@traversaro traversaro closed this Jan 25, 2022
@traversaro traversaro reopened this Jan 25, 2022
@traversaro traversaro closed this Jan 26, 2022
@traversaro traversaro reopened this Jan 26, 2022
@traversaro traversaro merged commit 7f611e3 into devel Jan 26, 2022
@traversaro traversaro deleted the bindings/rotation_position branch January 26, 2022 08:27
@traversaro
Copy link
Member

Sorry, I did an error and squashed the commits even if they were correctly separated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants