Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Branch Integration: collect all recent fixes. #44

Open
wants to merge 86 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
a5f50ec
WIP - buggy.
realtimepeople Jul 26, 2024
bc40a6c
still WIP...
realtimepeople Jul 26, 2024
86bb3f1
...operating quite well. Testing ...
realtimepeople Jul 26, 2024
e2b37d9
Quality function optimized.
realtimepeople Jul 26, 2024
3bbc623
Acceleration calibration test.
realtimepeople Jul 26, 2024
ea0c7a4
Superfluous assignment removed.
realtimepeople Aug 7, 2024
db51b53
Work in progress: 3D magnetic calibration.
realtimepeople Aug 20, 2024
c6d5caa
WIP: Building 3D compass calibrator.
realtimepeople Aug 28, 2024
d2216d5
Added getter method for heading.
realtimepeople Aug 29, 2024
72f0ea2
Magnetic 3d calibration basically up and running.
realtimepeople Aug 29, 2024
40d05e5
Superfluous methods removed.
realtimepeople Aug 29, 2024
10ad189
3d sensor input test.
realtimepeople Aug 29, 2024
a142556
Mag calibrator reference version.
realtimepeople Aug 30, 2024
5ae4f35
Trying to solve overdetermined equation system.
realtimepeople Sep 2, 2024
7517831
Trying to solve overdetermined equation system.
realtimepeople Sep 2, 2024
e4ad620
Bug fixed.
realtimepeople Sep 2, 2024
f3b6eff
Mag calibration: working correctly.
realtimepeople Sep 2, 2024
420bc3a
Automatic 3D compass calibration integrated and used.
realtimepeople Sep 3, 2024
d2b43ac
Cleanup.
realtimepeople Sep 3, 2024
0c4ea30
Cleanup.
realtimepeople Sep 3, 2024
cc62bf8
Cleanup: removed obsolete header.
realtimepeople Sep 3, 2024
a91f7db
Documentation update.
realtimepeople Sep 3, 2024
b955660
Github documentation update.
realtimepeople Sep 3, 2024
16800b7
Magnetic calibration type read from EEPROM.
realtimepeople Sep 3, 2024
a7edeb5
Removed tweaks functionality.
realtimepeople Sep 3, 2024
22f8730
Compass 3D calibration made ready for multi-threading.
realtimepeople Sep 4, 2024
fe407ff
Mag 3D calibration test.
realtimepeople Sep 4, 2024
e9c035d
Bugfix: Poor man's debugging "printf" removed.
realtimepeople Sep 4, 2024
5979f84
Added capability to read and write mag. 3D data to/from disk.
realtimepeople Sep 4, 2024
5454fc4
Switch back to flight version
realtimepeople Sep 4, 2024
07b8663
Comparing 32bit and 64bit matrix arithetics.
realtimepeople Sep 5, 2024
58d4527
Magnetic data collection optimized.
realtimepeople Sep 5, 2024
ed64dee
Cleanup.
realtimepeople Sep 5, 2024
2b49d75
cLEANUP.
realtimepeople Sep 5, 2024
b757efa
Work in progress
realtimepeople Oct 10, 2024
878a490
Alternate quaternion multiplication.
realtimepeople Oct 11, 2024
de1b47f
Testing squared quaternion as compensation basis.
realtimepeople Oct 11, 2024
67c7ac1
Switchable magnetic error compensation.
realtimepeople Oct 12, 2024
18bb5fd
Added design file.
realtimepeople Oct 12, 2024
e223d5e
Sort iron effect data injection test.
realtimepeople Oct 14, 2024
e7cfade
Minor tweaks.
realtimepeople Oct 14, 2024
2cc63dc
Testing 3d calibration and soft iron compensation together.
realtimepeople Oct 15, 2024
eb8513b
Archiving offline calculation script.
realtimepeople Oct 16, 2024
03e81bd
External magnetic calibration and compensation.
realtimepeople Oct 22, 2024
af467a7
Air density mechanism optimized.
realtimepeople Dec 15, 2024
28bd357
Old fashioned prssure vario implemented.
realtimepeople Dec 15, 2024
ada55f1
Switch circling - straight optimized.
realtimepeople Dec 15, 2024
ffc233f
Air density mechanism tuned.
realtimepeople Dec 17, 2024
02aeac8
Soft Iron Compensation successfully tested in SIL.
realtimepeople Dec 24, 2024
443eef2
Configuration switch for SoftIronCompensation activated.
realtimepeople Dec 24, 2024
40ac44d
Density calibration tuning optimized.
realtimepeople Dec 28, 2024
af0c416
Air density mainainance reworked.
realtimepeople Dec 28, 2024
4ccbd6f
Air density maintainance reworked.
realtimepeople Dec 28, 2024
ab239c2
Merge branch 'density_mechanism_optimized' of [email protected]:larus-br…
realtimepeople Dec 28, 2024
2c20e63
Merge branch 'density_mechanism_optimized' of
realtimepeople Dec 28, 2024
e5d0ff1
Anti-GIT-fixes
realtimepeople Dec 28, 2024
53869ee
Density mechanism optimized
realtimepeople Dec 30, 2024
df4344f
Air density initialization simplified and optimized.
realtimepeople Jan 2, 2025
1df6475
Density mechanism simplified.
realtimepeople Jan 3, 2025
784de05
Adaptive air density mechanism.
realtimepeople Jan 3, 2025
27cfd1e
Airborne status optimized.
realtimepeople Jan 5, 2025
d148c0a
Postpone density update until 2nd measurment is done.
realtimepeople Jan 5, 2025
9a915ad
Bugfix: Air density measurement startet on takeoff.
realtimepeople Jan 6, 2025
0bd2152
Tiny optimization: Pressure decimation filter tuned.
realtimepeople Jan 6, 2025
3cc6285
Tiny optimization: Pressure decimation filter tuned.
realtimepeople Jan 6, 2025
a04e2d6
Merge branch 'density_mechanism_optimized' into integration
realtimepeople Jan 8, 2025
615b5d0
Merge remote-tracking branch 'origin/landing_detection_fixed' into in…
realtimepeople Jan 8, 2025
47093bb
"Soft Iron Correction" merged
realtimepeople Jan 8, 2025
89a623b
Bugfix merge completed.
realtimepeople Jan 8, 2025
4bc9f8c
Removed superfluous config parameter (automatic earth field...)
realtimepeople Jan 18, 2025
7a8e909
BUGFIX: Wrong sign in caldulation
realtimepeople Mar 3, 2025
471674b
BUGFIX: Wrong sign in calculation
realtimepeople Mar 3, 2025
fdfbfb9
Merge branch 'BUGFIX_quaternion_from_euler' of [email protected]:larus-b…
realtimepeople Mar 3, 2025
9d14bc7
Source simplified.
realtimepeople Mar 3, 2025
2977e1f
Sensor orientation test.
realtimepeople Mar 6, 2025
8ecd57c
Added support for external 9DOF sensor data.
realtimepeople Mar 10, 2025
4559545
Removed "nick" in definitions and comments.
realtimepeople Mar 10, 2025
435d961
Merge remote-tracking branch 'origin/sensor_orientation_setup' into
realtimepeople Mar 10, 2025
6dc3c3e
Fixed inconsitency due to missing soft iron mechanism.
realtimepeople Mar 10, 2025
52d7554
Method name corrected -> compensate.
realtimepeople Mar 10, 2025
a09b25d
Merge remote-tracking branch 'origin/wind_observer_switching_optimized'
realtimepeople Mar 10, 2025
146b3ad
Merge remote-tracking branch 'origin/vario_supports_old_fashion_press…
realtimepeople Mar 10, 2025
8a1d29d
New CAN format implemented.
realtimepeople Mar 10, 2025
f8f93e4
Heartbeat CAN packet sent @ 1Hz
realtimepeople Mar 10, 2025
b3d1d27
System state and heartbeat support fixed.
realtimepeople Mar 10, 2025
ad02d09
CAN_Id-SystemState -> id 0x12a
Simsys Mar 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
299 changes: 299 additions & 0 deletions ARM_math/arm_mat_inverse_f32.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,299 @@
/* ----------------------------------------------------------------------
* Project: CMSIS DSP Library
* Title: arm_mat_inverse_f32.c
* Description: Floating-point matrix inverse
*
* $Date: 23 April 2021
* $Revision: V1.9.0
*
* Target Processor: Cortex-M and Cortex-A cores
* -------------------------------------------------------------------- */
/*
* Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* 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
*
* 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.
*/

#include "matrix_functions.h"
#include "matrix_utils.h"


/**
@ingroup groupMatrix
*/

/**
@defgroup MatrixInv Matrix Inverse

Computes the inverse of a matrix.

The inverse is defined only if the input matrix is square and non-singular (the determinant is non-zero).
The function checks that the input and output matrices are square and of the same size.

Matrix inversion is numerically sensitive and the CMSIS DSP library only supports matrix
inversion of floating-point matrices.

@par Algorithm
The Gauss-Jordan method is used to find the inverse.
The algorithm performs a sequence of elementary row-operations until it
reduces the input matrix to an identity matrix. Applying the same sequence
of elementary row-operations to an identity matrix yields the inverse matrix.
If the input matrix is singular, then the algorithm terminates and returns error status
<code>ARM_MATH_SINGULAR</code>.

@par Matrix Inverse of a 3 x 3 matrix using Gauss-Jordan Method

\f[
\begin{pmatrix}
a_{1,1} & a_{1,2} & a_{1,3} & | & 1 & 0 & 0\\
a_{2,1} & a_{2,2} & a_{2,3} & | & 0 & 1 & 0\\
a_{3,1} & a_{3,2} & a_{3,3} & | & 0 & 0 & 1\\
\end{pmatrix}
\rightarrow
\begin{pmatrix}
1 & 0 & 0 & | & x_{1,1} & x_{2,1} & x_{3,1} \\
0 & 1 & 0 & | & x_{1,2} & x_{2,2} & x_{3,2} \\
0 & 0 & 1 & | & x_{1,3} & x_{2,3} & x_{3,3} \\
\end{pmatrix}
\f]
*/

/**
@addtogroup MatrixInv
@{
*/

/**
@brief Floating-point matrix inverse.
@param[in] pSrc points to input matrix structure. The source matrix is modified by the function.
@param[out] pDst points to output matrix structure
@return execution status
- \ref ARM_MATH_SUCCESS : Operation successful
- \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed
- \ref ARM_MATH_SINGULAR : Input matrix is found to be singular (non-invertible)
*/
arm_status arm_mat_inverse_f32(
const arm_matrix_instance_f32 * pSrc,
arm_matrix_instance_f32 * pDst)
{
float32_t *pIn = pSrc->pData; /* input data matrix pointer */
float32_t *pOut = pDst->pData; /* output data matrix pointer */

float32_t *pTmp;
uint32_t numRows = pSrc->numRows; /* Number of rows in the matrix */
uint32_t numCols = pSrc->numCols; /* Number of Cols in the matrix */


float32_t pivot = 0.0f, newPivot=0.0f; /* Temporary input values */
uint32_t selectedRow,pivotRow,i, rowNb, rowCnt, flag = 0U, j,column; /* loop counters */
arm_status status; /* status of matrix inverse */

#ifdef ARM_MATH_MATRIX_CHECK

/* Check for matrix mismatch condition */
if ((pSrc->numRows != pSrc->numCols) ||
(pDst->numRows != pDst->numCols) ||
(pSrc->numRows != pDst->numRows) )
{
/* Set status as ARM_MATH_SIZE_MISMATCH */
status = ARM_MATH_SIZE_MISMATCH;
}
else

#endif /* #ifdef ARM_MATH_MATRIX_CHECK */

{
/*--------------------------------------------------------------------------------------------------------------
* Matrix Inverse can be solved using elementary row operations.
*
* Gauss-Jordan Method:
*
* 1. First combine the identity matrix and the input matrix separated by a bar to form an
* augmented matrix as follows:
* _ _ _ _
* | a11 a12 | 1 0 | | X11 X12 |
* | | | = | |
* |_ a21 a22 | 0 1 _| |_ X21 X21 _|
*
* 2. In our implementation, pDst Matrix is used as identity matrix.
*
* 3. Begin with the first row. Let i = 1.
*
* 4. Check to see if the pivot for row i is zero.
* The pivot is the element of the main diagonal that is on the current row.
* For instance, if working with row i, then the pivot element is aii.
* If the pivot is zero, exchange that row with a row below it that does not
* contain a zero in column i. If this is not possible, then an inverse
* to that matrix does not exist.
*
* 5. Divide every element of row i by the pivot.
*
* 6. For every row below and row i, replace that row with the sum of that row and
* a multiple of row i so that each new element in column i below row i is zero.
*
* 7. Move to the next row and column and repeat steps 2 through 5 until you have zeros
* for every element below and above the main diagonal.
*
* 8. Now an identical matrix is formed to the left of the bar(input matrix, pSrc).
* Therefore, the matrix to the right of the bar is our solution(pDst matrix, pDst).
*----------------------------------------------------------------------------------------------------------------*/

/* Working pointer for destination matrix */
pTmp = pOut;

/* Loop over the number of rows */
rowCnt = numRows;

/* Making the destination matrix as identity matrix */
while (rowCnt > 0U)
{
/* Writing all zeroes in lower triangle of the destination matrix */
j = numRows - rowCnt;
while (j > 0U)
{
*pTmp++ = 0.0f;
j--;
}

/* Writing all ones in the diagonal of the destination matrix */
*pTmp++ = 1.0f;

/* Writing all zeroes in upper triangle of the destination matrix */
j = rowCnt - 1U;
while (j > 0U)
{
*pTmp++ = 0.0f;
j--;
}

/* Decrement loop counter */
rowCnt--;
}

/* Loop over the number of columns of the input matrix.
All the elements in each column are processed by the row operations */

/* Index modifier to navigate through the columns */
for(column = 0U; column < numCols; column++)
{
/* Check if the pivot element is zero..
* If it is zero then interchange the row with non zero row below.
* If there is no non zero element to replace in the rows below,
* then the matrix is Singular. */

pivotRow = column;

/* Temporary variable to hold the pivot value */
pTmp = ELEM(pSrc,column,column) ;
pivot = *pTmp;
selectedRow = column;

/* Find maximum pivot in column */

/* Loop over the number rows present below */

for (rowNb = column+1; rowNb < numRows; rowNb++)
{
/* Update the input and destination pointers */
pTmp = ELEM(pSrc,rowNb,column);
newPivot = *pTmp;
if (fabsf(newPivot) > fabsf(pivot))
{
selectedRow = rowNb;
pivot = newPivot;
}
}

/* Check if there is a non zero pivot element to
* replace in the rows below */
if ((pivot != 0.0f) && (selectedRow != column))
{

SWAP_ROWS_F32(pSrc,column, pivotRow,selectedRow);
SWAP_ROWS_F32(pDst,0, pivotRow,selectedRow);


/* Flag to indicate whether exchange is done or not */
flag = 1U;
}





/* Update the status if the matrix is singular */
if ((flag != 1U) && (pivot == 0.0f))
{
return ARM_MATH_SINGULAR;
}


/* Pivot element of the row */
pivot = 1.0f / pivot;

SCALE_ROW_F32(pSrc,column,pivot,pivotRow);
SCALE_ROW_F32(pDst,0,pivot,pivotRow);


/* Replace the rows with the sum of that row and a multiple of row i
* so that each new element in column i above row i is zero.*/

rowNb = 0;
for (;rowNb < pivotRow; rowNb++)
{
pTmp = ELEM(pSrc,rowNb,column) ;
pivot = *pTmp;

MAS_ROW_F32(column,pSrc,rowNb,pivot,pSrc,pivotRow);
MAS_ROW_F32(0 ,pDst,rowNb,pivot,pDst,pivotRow);


}

for (rowNb = pivotRow + 1; rowNb < numRows; rowNb++)
{
pTmp = ELEM(pSrc,rowNb,column) ;
pivot = *pTmp;

MAS_ROW_F32(column,pSrc,rowNb,pivot,pSrc,pivotRow);
MAS_ROW_F32(0 ,pDst,rowNb,pivot,pDst,pivotRow);

}

}

/* Set status as ARM_MATH_SUCCESS */
status = ARM_MATH_SUCCESS;

if ((flag != 1U) && (pivot == 0.0f))
{
pIn = pSrc->pData;
for (i = 0; i < numRows * numCols; i++)
{
if (pIn[i] != 0.0f)
break;
}

if (i == numRows * numCols)
status = ARM_MATH_SINGULAR;
}
}

/* Return to application */
return (status);
}
/**
@} end of MatrixInv group
*/
Loading