I have a SimMechanics model of a person, created by importing a SolidWorks assembly. I am using motion capture data to drive this model (for the purpose of inverse dynamics analysis), where each model joint is actuated by motion. I am using gimbal joints to represent the person's actual joints (e.g. hip, shoulder, elbow etc) as they have 3 rotational degrees of freedom.
I have written Matlab functions to calculate the Euler/Cardan angles of each joint, i.e. foot to shin, shin to thigh etc, between embedded coordinate systems in each body segment. These angles follow an x-y'-z'' sequence i.e. rotate about x axis first, then (rotated) y', then (twice rotated) z'', to follow the same convention the gimbal joint blocks use. These angles are then used to actuate the joints.
On running my model, however, the body segment orientations are completely wrong. Below is one of the outputs of my Cardan angles function, plotting the embedded coordinate systems onto each joint:
Which looks exactly as it should (each segment x axis is red, y is green, cyan is z). But when I run my SimMechanics model, it's a disaster. This is the first frame, which should correspond with my stick figure above:
Obviously, it's not remotely close, and I cannot work out why. Firstly, an obvious question - is the motion input to a gimbal joint defined in radians, or degrees? I have assumed radians, though I cannot actually see this mentioned in the documentation. I've also added motion sensing to each joint, and checked the sensed positions against the position inputs, and they match, so there's nothing funny happening there. Is the gimbal joint motion actuation definitely about the base x axis, then y', then z''? That's the only thing I can think of that may be causing the problem.
Is anyone able to help me with this?