rigidBodyDynamics: Simplify handling of quaternions by maintaining a unit quaternion in the joint state field 'q'
'w' is now obtained from 'v' using the relation w = sqrt(1 - |sqr(v)|) and 'v' is stored in the joint state field 'q' and integrated in the usual manner but corrected using quaternion transformations.
This commit is contained in:
@ -64,8 +64,7 @@ int main(int argc, char *argv[])
|
||||
sphericalJoint.joints()[1]
|
||||
(
|
||||
quaternion(quaternion::ZYX, vector(0.3, 0, 0)),
|
||||
sphericalJoint.state().q(),
|
||||
sphericalJoint.state().w()
|
||||
sphericalJoint.state().q()
|
||||
);
|
||||
|
||||
// Set the gravitational acceleration
|
||||
@ -90,8 +89,7 @@ int main(int argc, char *argv[])
|
||||
<< t << " "
|
||||
<< sphericalJoint.joints()[1]
|
||||
(
|
||||
sphericalJoint.state().q(),
|
||||
sphericalJoint.state().w()
|
||||
sphericalJoint.state().q()
|
||||
).eulerAngles(quaternion::ZYX).x()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user