/* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef FUSION_H_ #define FUSION_H_ #include "vec.h" #include "mat.h" #include "quat.h" #include #include #ifdef __cplusplus extern "C" { #endif struct FusionParam { float gyro_var; float gyro_bias_var; float acc_stdev; float mag_stdev; }; struct Fusion { Quat x0; struct Vec3 x1; struct Mat33 P[2][2]; struct Mat33 GQGt[2][2]; struct Mat33 Phi0[2]; struct Vec3 Ba, Bm; uint32_t mInitState; float mPredictDt; struct Vec3 mData[3]; uint32_t mCount[3]; uint32_t flags; float fake_mag_decimation; struct FusionParam param; }; enum FusionFlagBits { FUSION_USE_MAG = 1 << 0, FUSION_USE_GYRO = 1 << 1, FUSION_REINITIALIZE = 1 << 2, }; void initFusion(struct Fusion *fusion, uint32_t flags); void fusionHandleGyro(struct Fusion *fusion, const struct Vec3 *w, float dT); int fusionHandleAcc(struct Fusion *fusion, const struct Vec3 *a, float dT); int fusionHandleMag(struct Fusion *fusion, const struct Vec3 *m); void fusionGetAttitude(const struct Fusion *fusion, struct Vec4 *attitude); void fusionGetBias(const struct Fusion *fusion, struct Vec3 *bias); void fusionGetRotationMatrix(const struct Fusion *fusion, struct Mat33 *R); int fusionHasEstimate(const struct Fusion *fusion); #ifdef __cplusplus } #endif #endif // FUSION_H_