From e274f2347393e7cbf1f755c9ed1593bd31bd1370 Mon Sep 17 00:00:00 2001 From: Martin Miller Date: Mon, 3 Apr 2017 15:16:50 -0500 Subject: Add quaternion accessor to Body. --- src/body.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src/body.cpp') diff --git a/src/body.cpp b/src/body.cpp index 99ea1ed..f7440b5 100644 --- a/src/body.cpp +++ b/src/body.cpp @@ -203,11 +203,11 @@ Body::F ( const Vector3d &ang, const Quaterniond &q, double dt ) #ifdef FULLSTATE Matrix F = Matrix::Zero(); double qbw1,qbw2,qbw3,qbw4; - qbw1 = X(6); - qbw2 = X(7); - qbw3 = X(8); - qbw4 = X(9); - Quaterniond qbw(qbw4,qbw1,qbw2,qbw3); + Quaterniond qbw = qhat(); + qbw1 = qbw.x(); + qbw2 = qbw.y(); + qbw3 = qbw.z(); + qbw4 = qbw.w(); Matrix Rbw(qbw.toRotationMatrix()); #else Matrix F = Matrix::Zero(); @@ -291,7 +291,7 @@ Body::motionModel ( const Vector3d &acc, const Vector3d &ang, const Quaterniond b = Matrix::Zero(); #ifdef FULLSTATE - Quaterniond qbw(X(9),X(6),X(7),X(8)); + Quaterniond qbw qhat(); Matrix Rbw(qbw.toRotationMatrix()); #else Matrix Rbw(q.toRotationMatrix()); @@ -382,3 +382,18 @@ Body::asVector ( const Matrix &m ) return ; } /* ----- end of method Body::asVector ----- */ + +/* + *-------------------------------------------------------------------------------------- + * Class: Body + * Method: Body :: qhat + * Description: Returns the current quaternion estimate. + *-------------------------------------------------------------------------------------- + */ +Quaterniond +Body::qhat ( ) +{ + Quaterniond qbw(X(9),X(6),X(7),X(8)); + return qbw; +} /* ----- end of method Body::qhat ----- */ + -- cgit v1.1