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

Is changing the non-root cascaded coords allowed? #327

Open
HiroIshida opened this issue Dec 18, 2023 · 1 comment
Open

Is changing the non-root cascaded coords allowed? #327

HiroIshida opened this issue Dec 18, 2023 · 1 comment

Comments

@HiroIshida
Copy link
Contributor

I expected new and co2's worldcoords match, but they don't.

import numpy as np
from skrobot.coordinates import CascadedCoords, Coordinates
np.random.seed(0)

co1 = CascadedCoords(pos = [0.1, 0.2, 0.3])
co2 = CascadedCoords()
co1.assoc(co2)
new = Coordinates(np.random.randn(3))
co2.newcoords(new)
print(new)
print(co2)

output

#<Coordinates 0x7f3010dd8700 1.764 0.400 0.979 / 0.0 -0.0 0.0>
#<CascadedCoords 0x7f3010ebf3a0 1.864 0.600 1.279 / 0.0 -0.0 0.0>

Looks like a bug, but I'm not certain.
Is changing the child coords allowed? If so, the above behavior is itended?

@iory
Copy link
Owner

iory commented Dec 25, 2023

Thank you for pointing out the issue. The newcoords method in CascadedCoords is set to change position relative to the parent link by default. To change coordinates relative to the world instead of the parent, you can do as follows. However, as you mentioned, this behavior might be confusing. As a solution, it might be better to add arguments like "world" or "local" to newcoords, similar to other functions, to allow changing coordinates relative to these. What do you think?

import numpy as np
from skrobot.coordinates import CascadedCoords, Coordinates
np.random.seed(0)

co1 = CascadedCoords(pos=[0.1, 0.2, 0.3])
co2 = CascadedCoords()
co1.assoc(co2)
new = Coordinates(pos=[1, 2, 3])
co2.newcoords(co2.parent.copy_worldcoords().inverse_transformation().transform(
    new))
# co2.newcoords(new)
print(new)
print(co2)

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

No branches or pull requests

2 participants