Creating stable roll joints in Maya
Euler rotations create a complicated issue to solve when trying to extract a stable twist value you can propagate along rolls joints for areas like the shoulder, forearm and hip.
Using just the rotation of the twist axis fails because of gimbal, even if you use the best rotate order. Using orient constraints with a single axis fails cause it produces flips and weird values. Although there may be multiple "good" solutions, one simple built in solution is when using the IK single chain handle (ikSCsolver). You could probably get a similar result with an aim constraint. This method is stable from 180 to -180 degrees on the twist axis, then it will flip.
So how is it done?
1. Duplicate the shoulder joint twice, creating dup1 and dup2, translate dup1 to the elbow and parent dup2 to dup1.
2. Then make an ik handle from dup1 to dup2 and make sure it is set to ikSCsolver in the Attribute Editor under IK Solver Attributes.
3. Parent dup1 to the shoulder and the ik handle to the clavicle.
Done! Now when you rotate the shoulder dup1 will contain the twist value on the axis aiming down the shoulder, ie rotateX. You can then use this rotation to drive the twisting joints. Setting this up on the forearm is just slightly different, dup1 is instead parented to the elbow and the ik handle is parented to the wrist.
Here is an example of the shoulder and forearm rolls setup with an ik SC Handle: