Skip to content
This repository has been archived by the owner on Oct 7, 2021. It is now read-only.

Shifter: leg_3jnt_01 joint flipping problem #11

Open
miquelcampos opened this issue Aug 8, 2018 · 4 comments
Open

Shifter: leg_3jnt_01 joint flipping problem #11

miquelcampos opened this issue Aug 8, 2018 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@miquelcampos
Copy link
Member

From @Lohult on August 5, 2018 12:42

Hi Miquel,

I have discovered a bit of a flipping problem with the leg_3jnt_01 component.

The leg component has joints ranging from leg_L0_0_jnt through to leg_L0_9_jnt followed by leg_L0_end_jnt.

The flipping occurs when rotating leg_L0_ik_ctl in positive X. 91.068 is the exact number where the flip occurs (the guide is kept in default arrangement for the test).

At 91.068 rotation X on the IK control leg_L0_9_jnt and leg_L0_end_jnt flips from zero to -180. When skinning to these joints it becomes quite obvious when the flipping occurs.

My use case is a cat leg and the IK controller get rotated to curl the paw while walking for example.

Copied from original issue: mgear-dev/mgear_legacy#236

@miquelcampos miquelcampos self-assigned this Aug 8, 2018
@miquelcampos
Copy link
Member Author

From @Lohult on August 8, 2018 5:29

This problem can perhaps be fixed if the way the foot connects to the leg is setup in a way that it has a control that when rotated only affects the foot but when translated affects both ik effector and foot.

@miquelcampos
Copy link
Member Author

Hi @Lohult I will check this since I also have another bug in this component:
#4

Thanks for the feedback :)

@miquelcampos
Copy link
Member Author

I moving this to the other repository https://github.com/mgear-dev/shifter_classic_components/issues/

@miquelcampos miquelcampos added the bug Something isn't working label Aug 8, 2018
@jdrese jdrese changed the title leg_3jnt_01 joint flipping problem Shifter: leg_3jnt_01 joint flipping problem Nov 29, 2018
@miquelcampos
Copy link
Member Author

miquelcampos commented Oct 4, 2020

Review the component with the feedback from the forum

http://forum.mgear-framework.com/t/hind-legs-for-quadraped-dont-align-with-guides-created/1698/4

Aerys code

import pymel.core as pm
from mgear.core.transform import getChainTransform2

# Pick joint chains
jnts = [pm.PyNode("jnt" + str(i)) for i in range(4)]
helperJnts = [pm.PyNode("helperJnt" + str(i)) for i in range(3)]

# Read world space xforms and positions
jnt_xform = [j.getMatrix(ws=1) for j in jnts]
Jn = [j.translate for j in jnt_xform]
L = sum([(Jn[i + 1] - Jn[i]).length() for i in range(3)])

# Compute ja and Jfull
ja = (Jn[1] - Jn[0])
ja.normalize()
Jfull = Jn[3] - Jn[0]

# Main formula
A = (Jfull * Jfull - L * L) / (2 * (ja * Jfull - L))

# Construct helper joint chain
hj1_pos = [Jn[0], Jn[0] + ja * A, Jn[3]]
hj1_norm = pm.dt.cross(Jn[1] - Jn[0], Jn[2] - Jn[1])
hj_xform = getChainTransform2(hj1_pos, hj1_norm)

helperJnts[0].setMatrix(hj_xform[0], ws=1)
helperJnts[1].setMatrix(hj_xform[1], ws=1)
helperJnts[2].setMatrix(hj_xform[2], ws=1)

image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant