Wrong gravitational acceleration in IMU model (imuSemsor) in sensor fusion toolbox.
59 次查看(过去 30 天)
显示 更早的评论
Hello dear friends,
I have been struggling with the sensor fusion toolbox lately. In short, I create a stationary model of an IMU sensor and I expect it to only capture the gravity. The problem is the direction actually!
With the IMUs we know that they capture g in the opposite direction (if the gravity is downwards, the sensor captures it upwards). Consider a stationary IMU that we are holding still; The reason that keeps it from falling, is the force that we are applying to the IMU and the IMU actually captures the acceleration caused by the applied force. So that's the reason why IMUs capture g upwards and not downwards.
But with the simple example below, we see that such thing doesn't happen with the sensor fusion toolbox.
IMU = imuSensor('accel-gyro-mag','ReferenceFrame','NED'); % Creating an IMU object
acc = [0 0 0]; % Acceleration of the IMU with respect to the NED Frame
angVel = [0 0 0]; % Angular Velocity of the IMU with respect to the NED Frame
orientation = [[1 0 0];...
[0 1 0];...
[0 0 1]]; % Orientation of the IMU with respect to the NED Frame
[accelReadings,gyroReadings,magReadings] = IMU(acc,angVel,orientation);
accelReadings
The IMU has no acceleration nor angular velocity with respect to the 'North-East-Down' frame and the orientation of the IMU sensor is the same as the 'NED' frame. So Its Z axis alligns with the 'Down' direction. But we know that g should be captured upwards (-down) so g should be negative (-9.81) in the Z direction of the local frame of the IMU but as can be seen above, it's positive! Can someone help me with this issue please?
Thanks in advance
1 个评论
Paul
2021-9-2
编辑:Paul
2021-9-3
If you look on the doc page for imuSensor under the Algorithms section for the accelerometer, it shows a block diagram of the accelerometer model. In that diagram, it shows the input to the model is called "acceleration," which is combined with "g" to form a quantity called "Total Acceleration." The diagram doesn't show whether "g" is added or subtracted. (Edit: See the Answer below for how how Total Acceleration is calculated). However, the results shown in your Question, and from the doc page example Generate Ideal IMU Data from Stationary Input, and the term "Total Acceleration," all suggest that the "acceleration" input into the model is, what I would call, the specific force and the output is a measurement of inertial acceleration.
a_i (output) = a_sf (input) + g
Unfortunately for me, and I guess you would agree, such an approach is exactly the opposite of how I would expect an acceleromter model to operate. In fact, I would leave "g" out of the model altogether and leave that up to the user to ensure that the input is specific force.
Furthermore, the doc page doesn't say what it assumes about the direction of "g." Is it always in the Down direction in the local NED frame? Can the user specify a WGS-84 model somehow? It doesn't look like it, which is another reason to let the user deal with gravity.
Interestingly enough, the imuSensor in 2019a yields the exact same result, but the doc page doesn't show the formation of a Total Acceleration.
采纳的回答
Mehdi Ejtehadi
2021-9-4
4 个评论
Paul
2021-9-4
Ok. Now I see where you're coming from.
Do you agree that it's functionally equivalent to have:
On input:
acc - acceleration of the IMU relative to the NED frame (assuming the NED frame is an inertial frame) resolved in the NED frame: ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/729459/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/729459/image.png)
angVel - angular velocity of the IMU relative to the NED frame (assuming the NED frame is an inertial frame) resolved in the NED frame: ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/729464/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/729464/image.png)
orientation - Rotation matrix that takes a vector resolved in NED to resolved in IMU: ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/729469/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/729469/image.png)
On output:
negate the accelReadings to form the accelerometer measurement: ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/729474/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/729474/image.png)
The gyro measurment is gyroReadings
This approach would yield:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/729479/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/729484/image.png)
which I think is the desired result.
更多回答(1 个)
Ryan Salvo
2021-9-2
Hi Mehdi and Paul,
The equation for total acceleration is actually listed below the block diagram in the imuSensor documentation page.
Obtain Total Acceleration
To obtain the total acceleration (totalAcc), the acceleration is preprocessed by negating and adding the gravity constant vector (g= [0; 0; 9.8] m/s2) as:
totalAcc=−acceleration+g
This convention is used to obtain an accelerometer reading of [0 0 0] when the sensor is in freefall and the sensor frame is aligned with the parent/navigation frame.
The algorithm is the same in R2019a, but the documention page was updated after that release to include the Total Acceleration equation.
Thanks,
Ryan
1 个评论
Paul
2021-9-2
Thank you for pointing out the equattion in the Algorithms section.
The documentation would be much clearer if it said:
To obtain the total acceleration (totalAcc), the input acceleration (acc) is preprocessed by negating it and adding the gravity constant vector (g= [0; 0; 9.8] m/s2) as:
Setting aside the wording, the doc basically says the output is the negative of the input. Let's verify:
IMU = imuSensor('accel-gyro-mag','ReferenceFrame','NED'); % Creating an IMU object
acc = [1e5 1e5 1e5]; % Acceleration of the IMU with respect to the NED Frame
angVel = [0 0 0]; % Angular Velocity of the IMU with respect to the NED Frame
orientation = [[1 0 0];...
[0 1 0];...
[0 0 1]]; % Orientation of the IMU with respect to the NED Frame
[accelReadings,gyroReadings,magReadings] = IMU(acc,angVel,orientation);
accelReadings
Sure enough, the output is the negative of the input! Is that documented other than in that equation (I did not check carefully)? So the user has to know to negate the output before using it downstream? Is that really desired behavior for a generic accelerometer model?
Also, the reason for doing it that way doesn't really make sense. It would be much more straightforward to simply use:
totalAcc = acceleration - g
This equation would also result in the (ideal) accelerometer reading [0 0 0] when in free fall (assuming that the user's implementation of the gravity model is the same as that assumed in the imuSensor, which is another weakness of this implementation), and has the advantage that the user is not obligated to worry about the polarity of the output.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!