HelperOrientationViewer error even with correct syntax
5 views (last 30 days)
Show older comments
I have a persisting error on MATLAB with the helperOrientationViewer class. My code:
a = arduino('COM4', 'Nano33IoT', 'Libraries', 'I2C');
fs = 100; %sample rate in Hz
imu = bno055(a, 'SampleRate', fs, 'OutputFormat', 'matrix','OperatingMode','amg');
ts = tic;
stopTimer = 50;
magReadings=[];
while(toc(ts) < stopTimer)
% Rotate the sensor along x axis from 0 to 360 degree.
% Take 2-3 rotations to improve accuracy.
% For other axes, rotate along that axes.
[accel,gyro,mag] = read(imu);
magReadings = [magReadings;mag];
end
[A, b] = magcal(magReadings); % A = 3x3 matrix for soft iron correction
% b = 3x1 vector for hard iron correction
% GyroscopeNoise, AccelerometerNoise and MagnetometerNoise are determined from the BNO055 datasheet using the following formula
% NoisePower = OutputNoisePowerDensityrms^2 * Bandwidth
GyroscopeNoiseBNO055 = 3.05e-06; % GyroscopeNoise (variance value) in units of (rad/s)^2
AccelerometerNoiseBNO055 = 67.53e-06; % AccelerometerNoise (variance value)in units of (m/s^2)^2
MagnetometerNoiseBNO055 = 1; %MagnetometerNoise (variance value) in units of uT^2
viewer = HelperOrientationViewer('Title',{'AHRS Filter'});
FUSE = ahrsfilter('SampleRate',imu.SampleRate,'GyroscopeNoise',GyroscopeNoiseBNO055,'AccelerometerNoise',AccelerometerNoiseBNO055,'MagnetometerNoise',MagnetometerNoiseBNO055);
stopTimer=10;
magx_correction = b(1);
magy_correction = b(2);
magz_correction = b(3);
ts = tic;
while(toc(ts) < stopTimer)
[accel,gyro,mag] = read(imu);
% Align coordinates in accordance with NED convention
accel = [-accel(:,1), accel(:,2), accel(:,3)];
gyro = [gyro(:,1), -gyro(:,2), -gyro(:,3)];
mag = [(mag(:,1)-magx_correction), -(mag(:,2)- magy_correction), -(mag(:,3)-magz_correction)] * A;
rotators = FUSE(accel,gyro,mag);
for j = numel(rotators)
viewer(rotators(j));
end
end
release(imu);
delete(imu);
clear;
Which is the same as the example (https://uk.mathworks.com/help/supportpkg/arduinoio/ug/read-and-plot-real-time-data-from-bno055-sensor-in-ndof-mode.html) except for the arduino and connection, gives this error:
'HelperOrientationViewer' is used in the following examples:
Wireless Data Streaming Using BNO055 and Bluetooth® and Estimating Orientation Using Sensor Fusion
Binaural Audio Rendering Using Head Tracking
Estimating Orientation Using Inertial Sensor Fusion and MPU-9250
Wireless Data Streaming and Sensor Fusion Using BNO055
IMU and GPS Fusion for Inertial Navigation
Pose Estimation From Asynchronous Sensors
Error in BNO055 (line 27)
viewer = HelperOrientationViewer('Title',{'AHRS Filter'});
When run the live script of the example https://uk.mathworks.com/help/supportpkg/arduinoio/ug/read-and-plot-real-time-data-from-bno055-sensor-in-ndof-mode.html .The same error appears:
viewer = HelperOrientationViewer;
'HelperOrientationViewer' is used in the following examples:
Even this code:
fused1 = quaternion(1,0,0,0);
viewer1 = HelperOrientationViewer;
viewer1(fused1);
Has the error:
'HelperOrientationViewer' is used in the following examples:
Wireless Data Streaming Using BNO055 and Bluetooth® and Estimating Orientation Using Sensor Fusion
Binaural Audio Rendering Using Head Tracking
Estimating Orientation Using Inertial Sensor Fusion and MPU-9250
Wireless Data Streaming and Sensor Fusion Using BNO055
IMU and GPS Fusion for Inertial Navigation
Pose Estimation From Asynchronous Sensors
Error in test (line 2)
viewer1 = HelperOrientationViewer;
1 Comment
Image Analyst
on 15 Nov 2023
I'm not even sure what the error is. Are you sure you copied everything? I mean, "'HelperOrientationViewer' is used in the following examples" <== OK, fine but that doesn't look like an error. Then
Error in test (line 2)
viewer1 = HelperOrientationViewer;
OK, that tells us what line in your code produced the error but does not say exactly what the error is.
Answers (1)
Brian Fanous
on 17 Nov 2023
You should use the poseplot function instead of HelperOrientationViewer.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!