Skip to content

Commit 37a5123

Browse files
committed
Update ADIS16460 to match other IMUs in matlab with additional methods
Signed-off-by: Travis F. Collins <travis.collins@analog.com>
1 parent b3c92be commit 37a5123

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

+adi/+ADIS16460/Rx.m

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
classdef Rx < matlab.system.mixin.CustomIcon & adi.common.Rx ...
2-
& matlabshared.libiio.base & adi.common.Attribute
2+
& matlabshared.libiio.base & adi.common.Attribute ...
3+
& adi.common.Sensor
34
%RX ADIS16460 Inertial Measurement Unit
45
% The adi.ADIS16460.Rx System object is a signal source that can
56
% collect IMU data from the ADIS16460.
@@ -18,12 +19,6 @@
1819
% contiguous within that buffer. However, successive buffers are not.
1920
%
2021
% <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ADIS16460.pdf">ADIS16460 Datasheet</a>
21-
properties (Nontunable)
22-
%SamplesPerFrame Samples Per Frame
23-
% Number of samples per frame, specified as an even positive
24-
% integer from 2 to 16,777,216.
25-
SamplesPerFrame = 1024;
26-
end
2722
properties
2823
%SampleRate Sample Rate
2924
% Baseband sampling rate in Hz, specified as a scalar
@@ -107,11 +102,24 @@
107102

108103
end
109104

105+
%% Sensor specific APIs
106+
methods
107+
function [accelReadings, gyroReadings, valid] = read(obj)
108+
[accelReadings, gyroReadings, valid] = step(obj);
109+
end
110+
function flush(obj)
111+
flushBuffers(obj);
112+
end
113+
end
114+
110115
%% API Functions
111116
methods (Hidden, Access = protected)
112117

113118
function [accelReadings, gyroReadings, valid] = stepImpl(obj)
114119
[dataR, valid] = stepImpl@adi.common.Rx(obj);
120+
if strcmpi(obj.ReadMode,'latest')
121+
dataR = dataR(end:-1:1,:);
122+
end
115123
data = obj.AttributeScales.*double(dataR);
116124
% AngularVelocity
117125
gyroReadings = data(:,1:3);
@@ -121,8 +129,7 @@
121129
end
122130

123131
function flag = isInactivePropertyImpl(obj, prop)
124-
flag = isInactivePropertyImpl@adi.common.RxTx(obj, prop);
125-
flag = flag || strcmpi(prop,'EnabledChannels');
132+
flag = isInactivePropertyImpl@adi.common.Sensor(obj, prop);
126133
end
127134

128135
function icon = getIconImpl(obj)
@@ -135,7 +142,7 @@
135142
scales(c) = obj.getAttributeDouble(obj.channel_names{c},'scale',false);
136143
end
137144
end
138-
145+
139146
function setupInit(obj)
140147
obj.setDeviceAttributeRAW('current_timestamp_clock',obj.TimeStampClockSource);
141148
obj.setDeviceAttributeRAW('sampling_frequency',num2str(obj.SampleRate));
@@ -159,7 +166,7 @@ function updateBuildInfo(buildInfo, bldCfg)
159166
function bName = getDescriptiveName(~)
160167
bName = 'ADIS16460';
161168
end
162-
169+
163170
end
164171
end
165172

sensor_examples/adis16460.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
%% Setup
66
% IMU
77
IMU = adi.ADIS16460.Rx;
8-
IMU.SamplesPerFrame = 32;
8+
IMU.SamplesPerRead = 32;
99
IMU.uri = 'ip:analog';
1010
% Filter
1111
fs = IMU.SampleRate;

sensor_examples/adis16460_motion.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@
55
%% Setup
66
% IMU
77
IMU = adi.ADIS16460.Rx;
8-
IMU.SamplesPerFrame = 8;
8+
IMU.SamplesPerRead = 8;
99
IMU.uri = 'ip:analog';
1010
IMU.SampleRate = 128;
1111
fs = IMU.SampleRate;
1212
% Filter
1313
ifilt = imufilter('SampleRate', fs);
1414
% Scopes
15+
N = 64;
1516
viewer = HelperOrientationViewer;
1617
ts = dsp.TimeScope;
1718
ts.SampleRate = fs;
1819
ts.TimeSpanOverrunAction = 'Scroll';
19-
ts.TimeSpan = 1/fs*1024;
20+
ts.TimeSpan = 1/fs*N;
2021
ts.NumInputPorts = 2;
2122
ts.ShowLegend = true;
2223
ts.ChannelNames = {'Acceleration X','Acceleration Y','Acceleration Z',...
@@ -33,7 +34,7 @@
3334
numSamples = IMU.SamplesPerFrame;
3435
t = 0:1/fs:(numSamples-1)/fs;
3536

36-
for k=1:2e2
37+
for k=1:N
3738
[acc,gyro] = IMU();
3839
for ii=1:size(acc,1)
3940
qimu = ifilt(acc(ii,:), gyro(ii,:));

0 commit comments

Comments
 (0)