imuSensor loadparams unable to load NoiseType from json File
15 views (last 30 days)
Show older comments
"Gyroscope": {
"MeasurementRange": 0,
"Resolution": 0.0,
"ConstantBias": [0, 0, 0],
"AxesMisalignment": [0, 0, 0],
"NoiseDensity": [0.0, 0.0, 0.0],
"BiasInstability": [0.0, 0.0, 0.0],
"RandomWalk": [0,0,0],
"NoiseType": "single-sided", (delete this line the code runs fine)
"TemperatureBias": [0.0, 0.0, 0.0],
"TemperatureScaleFactor": [0, 0, 0],
"AccelerationBias": [0, 0, 0]
},
(REAL VALUES HAVE BEEN CHANGED TO 0)
I have created a json file which I already verified is working correctly however if I try to add NoiseType: "single-sided", as a parameter it immediately throws an error saying:
>> load_IMU_JSON
Unexpected token single-sided in JSON file. All values should be numeric or 'Inf'.
Error in
pv = fusion.internal.SensorParamLoader.parseParams(...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in
loadparams(s, fn, "IMU");
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Okay thats fine so lets assume then despite the documentation provided by matlab saying the parameter is "single-sided" | "double-sided" lets set it as 1 so maybe it will override the default.
This is the new error I get:
>> load_IMU_JSON
Error when constructing gyroparams. Error was : Expected NoiseType to match one of these values:
'double-sided', 'single-sided'
The input, '1', did not match any of the valid values.
Error in
gp = fusion.internal.SensorParamLoader.configureParams(gp, pv);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in
loadparams(s, fn, "IMU");
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Now if I just remove NoiseType entirely the json file will load with all my other parameters correctly and I know I could simply just write the matlab code as follows:
loadparams(s, fn, "IMU");
disp(s);
s.Accelerometer.NoiseType = "single-sided";
disp(s.Accelerometer);
which would then override the double-sided however I really wanted to keep everything clean. Any tips would be greatly appreciated this is the most confusing error ever.
0 Comments
Accepted Answer
Umar
on 21 Jan 2026 at 6:13
Edited: Umar
on 21 Jan 2026 at 6:14
Hi @Brendan,
I went through your post about the NoiseType parameter issue with imuSensor's loadparams function, and I completely understand your frustration. This isn't a confusing error at all—you've actually uncovered a legitimate design limitation in MATLAB's JSON parser that MathWorks hasn't properly documented.Here's what's happening:The fusion.internal.SensorParamLoader.parseParams function (line 44) was hardcoded to only accept numeric values or 'Inf' from JSON files. When NoiseType was added as a feature to gyroparams and accelparams later on, nobody updated the JSON parser to handle string parameters. So you're stuck in a catch-22:
* Try "NoiseType": "single-sided" → Parser rejects it (wants numbers only)
* Try "NoiseType": 1 → Parser accepts it, but then configureParams rejects it (wants the actual strings 'double-sided' or 'single-sided')
The smoking gun here is that MathWorks' own generic.json example file doesn't include NoiseType at all. You can see this in their documentation at https://www.mathworks.com/help/fusion/ref/imusensor.loadparams.html - they know about this limitation and just avoid it.Your workaround is actually the right approach and what MathWorks implicitly recommends:
loadparams(s, fn, "IMU");
s.Accelerometer.NoiseType = "single-sided";
s.Gyroscope.NoiseType = "single-sided";
I know you wanted to keep everything clean in the JSON, but given this architectural limitation, the post-load override is the cleanest solution available right now. If you want to make it more organized, you could wrap it in a helper function:
function s = loadIMUWithNoiseType(jsonFile, partName, noiseType)
s = imuSensor;
loadparams(s, jsonFile, partName);
s.Accelerometer.NoiseType = noiseType;
s.Gyroscope.NoiseType = noiseType;
if contains(s.IMUType, 'mag')
s.Magnetometer.NoiseType = noiseType;
end
end
You could even add a comment in your JSON file to document this:
{
"_comment": "NoiseType cannot be loaded from JSON due to parser
limitations. Set after loadparams().",
"Gyroscope": {
...
}
}
Since this is a real inconsistency between what the documentation says NoiseType accepts and what the JSON loader actually supports, it's worth reporting to MathWorks. You've already started the conversation on MATLAB Answers, which is great. You might also want to file a formal bug report at https://www.mathworks.com/support so their engineering team can potentially fix this in a future release.
The relevant documentation links are:
* imuSensor.loadparams: https://www.mathworks.com/help/fusion/ref/imusensor.loadparams.html
* gyroparams properties: https://www.mathworks.com/help/fusion/ref/gyroparams-properties.html
* accelparams properties: https://www.mathworks.com/help/fusion/ref/accelparams-properties.html
Bottom line: you're not doing anything wrong, the parser just wasn't designed to handle this parameter through JSON. Your workaround is solid and probably what everyone else using this feature is doing too.
Hope this clears things up.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!