Changeset 173 in flair-src for trunk/lib/FlairSensorActuator
- Timestamp:
- Apr 26, 2017, 11:12:59 AM (8 years ago)
- Location:
- trunk/lib/FlairSensorActuator/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairSensorActuator/src/Gx3_25_imu_impl.cpp
r167 r173 29 29 #include <Vector3D.h> 30 30 #include <RotationMatrix.h> 31 #include <OneAxisRotation.h> 31 32 32 33 #include <math.h> … … 135 136 filteredAngRates.z = Dequeue(&buf); 136 137 137 ahrsData->SetQuaternionAndAngularRates(eulerAngles.ToQuaternion(), 138 Quaternion quaternion=eulerAngles.ToQuaternion(); 139 self->ApplyRotation(filteredAngRates); 140 self->ApplyRotation(quaternion); 141 ahrsData->SetQuaternionAndAngularRates(quaternion, 138 142 filteredAngRates); 139 143 } else if (command == … … 164 168 matrix(2, 2) = Dequeue(&buf); 165 169 166 ahrsData->SetQuaternionAndAngularRates(matrix.ToQuaternion(), 170 Quaternion quaternion=matrix.ToQuaternion(); 171 self->ApplyRotation(filteredAngRates); 172 self->ApplyRotation(quaternion); 173 ahrsData->SetQuaternionAndAngularRates(quaternion, 167 174 filteredAngRates); 175 176 self->ApplyRotation(rawAcc); 168 177 imuData->SetRawAcc(rawAcc); 169 178 } else if (command == Gx3_25_imu::Quaternion) { … … 183 192 filteredAngRates.z = 0; 184 193 194 self->ApplyRotation(filteredAngRates); 195 self->ApplyRotation(quaternion); 185 196 ahrsData->SetQuaternionAndAngularRates(quaternion, 186 197 filteredAngRates); … … 207 218 imuData->SetDataTime(imuTime); 208 219 ahrsData->SetDataTime(imuTime); 209 self->UpdateImu();210 220 self->ProcessUpdate(ahrsData); 211 221 } -
trunk/lib/FlairSensorActuator/src/Imu.cpp
r167 r173 64 64 } 65 65 66 void Imu:: UpdateImu() {66 void Imu::ApplyRotation(Vector3Df& vector) { 67 67 if (rotation == NULL) { 68 68 Err("not applicable for simulation part.\n"); 69 69 return; 70 70 } 71 Vector3Df rawAcc, rawMag, rawGyr; 72 imuData->GetRawAccMagAndGyr(rawAcc, rawMag, rawGyr); 73 rotation->ComputeRotation(rawAcc); 74 rotation->ComputeRotation(rawGyr); 75 rotation->ComputeRotation(rawMag); 76 imuData->SetRawAccMagAndGyr(rawAcc, rawMag, rawGyr); 71 rotation->ComputeRotation(vector); 72 } 73 74 void Imu::ApplyRotation(Quaternion& quaternion) { 75 if (rotation == NULL) { 76 Err("not applicable for simulation part.\n"); 77 return; 78 } 79 rotation->ComputeRotation(quaternion); 77 80 } 78 81 -
trunk/lib/FlairSensorActuator/src/Imu.h
r137 r173 15 15 16 16 #include <IODevice.h> 17 #include <Vector3D.h> 17 18 18 19 namespace flair { … … 121 122 122 123 /*! 123 * \brief UpdateImu124 * \brief ApplyRotation 124 125 * 125 * The reimplemented class must call this function as soon as IMU datas are 126 *available. \n 126 * The reimplemented class must call this function to rotate IMU datas, before filling the ImuData. \n 127 127 * It handles the data rotation if it was defined. 128 128 * 129 * \param vector vector to apply rotation to 129 130 */ 130 void UpdateImu(); 131 void ApplyRotation(core::Vector3Df& vector); 132 133 /*! 134 * \brief ApplyRotation 135 * 136 * The reimplemented class must call this function to rotate IMU datas, before filling the ImuData. \n 137 * It handles the data rotation if it was defined. 138 * 139 * \param quaternion quaternion to apply rotation to 140 */ 141 void ApplyRotation(core::Quaternion& quaternion); 131 142 132 143 /*! -
trunk/lib/FlairSensorActuator/src/SimuImu.cpp
r167 r173 105 105 106 106 shmem->Read((char *)&state, sizeof(imu_states_t)); 107 ahrsData->SetQuaternionAndAngularRates( 108 Quaternion(state.q0, state.q1, state.q2, state.q3), 109 Vector3Df(state.wx, state.wy, state.wz)); 107 108 Quaternion quaternion(state.q0, state.q1, state.q2, state.q3); 109 Vector3Df angRate(state.wx, state.wy, state.wz); 110 ApplyRotation(angRate); 111 ApplyRotation(quaternion); 112 ahrsData->SetQuaternionAndAngularRates(quaternion,angRate); 110 113 111 114 imuData->SetDataTime(GetTime()); 112 115 ahrsData->SetDataTime(GetTime()); 113 116 114 UpdateImu();115 117 ProcessUpdate(ahrsData); 116 118 }
Note:
See TracChangeset
for help on using the changeset viewer.