insSensor
Inertial navigation system and GNSS/GPS simulation model
Description
TheinsSensor
System object™ models a device that fuses measurements from an inertial navigation system (INS) and global navigation satellite system (GNSS) such as a GPS, and outputs the fused measurements.
To output fused INS and GNSS measurements:
Create the
insSensor
object and set its properties.Call the object with arguments, as if it were a function.
To learn more about how System objects work, seeWhat Are System Objects?
Creation
Description
returns a System object,INS
= insSensorINS
, that models a device that outputs measurements from an INS and GNSS.
setspropertiesusing one or more name-value pairs. Unspecified properties have default values. Enclose each property name in quotes.INS
= insSensor(Name,Value
)
Properties
Unless otherwise indicated, properties arenontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and therelease
function unlocks them.
If a property istunable, you can change its value at any time.
For more information on changing property values, seeSystem Design in MATLAB Using System Objects.
MountingLocation
—Location of sensor on platform (m)
[0 0 0]
(default) |three-element real-valued vector of form [xyz]
Location of the sensor on the platform, in meters, specified as a three-element real-valued vector of the form [xyz]. The vector defines the offset of the sensor origin from the origin of the platform.
Tunable:Yes
Data Types:single
|double
RollAccuracy
—Accuracy of roll measurement (deg)
0.2
(default) |nonnegative real scalar
Accuracy of the roll measurement of the sensor body, in degrees, specified as a nonnegative real scalar.
Rollis the rotation around thex-axis of the sensor body. Roll noise is modeled as a white noise process.RollAccuracy
sets the standard deviation of the roll measurement noise.
Tunable:Yes
Data Types:single
|double
PitchAccuracy
—Accuracy of pitch measurement (deg)
0.2
(default) |nonnegative real scalar
Accuracy of the pitch measurement of the sensor body, in degrees, specified as a nonnegative real scalar.
Pitchis the rotation around they-axis of the sensor body. Pitch noise is modeled as a white noise process.PitchAccuracy
defines the standard deviation of the pitch measurement noise.
Tunable:Yes
Data Types:single
|double
YawAccuracy
—Accuracy of yaw measurement (deg)
1
(default) |nonnegative real scalar
Accuracy of the yaw measurement of the sensor body, in degrees, specified as a nonnegative real scalar.
Yawis the rotation around thez-axis of the sensor body. Yaw noise is modeled as a white noise process.YawAccuracy
defines the standard deviation of the yaw measurement noise.
Tunable:Yes
Data Types:single
|double
PositionAccuracy
—Accuracy of position measurement (m)
[1 1 1]
(default) |nonnegative real scalar|three-element real-valued vector
Accuracy of the position measurement of the sensor body, in meters, specified as a nonnegative real scalar or a three-element real-valued vector. The elements of the vector set the accuracy of thex-,y-, andz-position measurements, respectively. If you specifyPositionAccuracy
as a scalar value, then the object sets the accuracy of all three positions to this value.
Position noise is modeled as a white noise process.PositionAccuracy
defines the standard deviation of the position measurement noise.
Tunable:Yes
Data Types:single
|double
VelocityAccuracy
—Accuracy of velocity measurement (m/s)
0.05
(default) |nonnegative real scalar
Accuracy of the velocity measurement of the sensor body, in meters per second, specified as a nonnegative real scalar.
Velocity noise is modeled as a white noise process.VelocityAccuracy
defines the standard deviation of the velocity measurement noise.
Tunable:Yes
Data Types:single
|double
AccelerationAccuracy
—Accuracy of acceleration measurement (m/s2)
0
(default) |nonnegative real scalar
Accuracy of the acceleration measurement of the sensor body, in meters per second, specified as a nonnegative real scalar.
Acceleration noise is modeled as a white noise process.AccelerationAccuracy
defines the standard deviation of the acceleration measurement noise.
Tunable:Yes
Data Types:single
|double
AngularVelocityAccuracy
—Accuracy of angular velocity measurement (deg/s)
0
(default) |nonnegative real scalar
Accuracy of the angular velocity measurement of the sensor body, in meters per second, specified as a nonnegative real scalar.
Angular velocity is modeled as a white noise process.AngularVelocityAccuracy
defines the standard deviation of the acceleration measurement noise.
Tunable:Yes
Data Types:single
|double
TimeInput
—Enable input of simulation time
false
or0
(default) |true
or1
Enable input of simulation time, specified as a logical0
(false
) or1
(true
). Set this property totrue
to input the simulation time by using thesimTime
argument.
Tunable:No
Data Types:logical
HasGNSSFix
—Enable GNSS fix
true
or1
(default) |false
or0
Enable GNSS fix, specified as a logical1
(true
) or0
(false
). Set this property tofalse
to simulate the loss of a GNSS receiver fix. When a GNSS receiver fix is lost, position measurements drift at a rate specified by thePositionErrorFactor
property.
Tunable:Yes
Dependencies
To enable this property, setTimeInput
totrue
.
Data Types:logical
PositionErrorFactor
—Position error factor without GNSS fix
[0 0 0]
(default) |nonnegative scalar|1-by-3 vector of scalars
Position error factor without GNSS fix, specified as a scalar or a 1-by-3 vector of scalars.
When theHasGNSSFix
property is set tofalse
, the position error grows at a quadratic rate due to constant bias in the accelerometer. The position error for a position componentE(t) can be expressed asE(t) = 1/2αt2, whereαis the position error factor for the corresponding component andtis the time since the GNSS fix is lost. While running, the object computestbased on thesimTime
input. The computedE(t) values for thex,y, andzcomponents are added to the corresponding position components of thegTruth
input.
Tunable:Yes
Dependencies
To enable this property, setTimeInput
totrue
andHasGNSSFix
tofalse
.
Data Types:single
|double
RandomStream
—Random number source
'Global stream'
(default) |'mt19937ar with seed'
Random number source, specified as one of these options:
'Global stream'
–– Generate random numbers using the current global random number stream.'mt19937ar with seed'
–– Generate random numbers using the mt19937ar algorithm, with the seed specified by theSeed
property.
Data Types:char
|string
Seed
—Initial seed
67
(default) |nonnegative integer
Initial seed of the mt19937ar random number generator algorithm, specified as a nonnegative integer.
Dependencies
To enable this property, setRandomStream
to'mt19937ar with seed'
.
Data Types:single
|double
|int8
|int16
|int32
|int64
|uint8
|uint16
|uint32
|uint64
Usage
Description
models the data received from an INS sensor reading and GNSS sensor reading. The output measurement is based on the inertial ground-truth state of the sensor body,measurement
= INS(gTruth
)gTruth
.
additionally specifies the time of simulation,measurement
= INS(gTruth
,simTime
)simTime
. To enable this syntax, set theTimeInput
property totrue
.
Input Arguments
gTruth
—Inertial ground-truth state of sensor body
structure
Inertial ground-truth state of sensor body, in local Cartesian coordinates, specified as a structure containing these fields:
Field | Description |
---|---|
'Position' |
Position, in meters, specified as a real, finiteN-by-3 matrix of [xyz] vectors.Nis the number of samples in the current frame. |
'Velocity' |
Velocity (v), in meters per second, specified as a real, finiteN-by-3 matrix of [vxvyvz] vector.Nis the number of samples in the current frame. |
'Orientation' |
Orientation with respect to the local Cartesian coordinate system, specified as one of these options:
Each quaternion or rotation matrix is a frame rotation from the local Cartesian coordinate system to the current sensor body coordinate system.Nis the number of samples in the current frame. |
'Acceleration' |
Acceleration (a), in meters per second squared, specified as a real, finiteN-by-3 matrix of [axayaz] vectors.Nis the number of samples in the current frame. |
'AngularVelocity' |
Angular velocity (ω), in degrees per second squared, specified as a real, finiteN-by-3 matrix of [ωxωyωz] vectors.Nis the number of samples in the current frame. |
The field values must be of typedouble
orsingle
.
ThePosition
,Velocity
, andOrientation
fields are required. The other fields are optional.
Example:struct('Position',[0 0 0],'Velocity',[0 0 0],'Orientation',quaternion([1 0 0 0]))
simTime
—Simulation time
nonnegative real scalar
Simulation time, in seconds, specified as a nonnegative real scalar.
Data Types:single
|double
Output Arguments
measurement
— Measurement of sensor body motion
structure
Measurement of the sensor body motion, in local Cartesian coordinates, returned as a structure containing these fields:
Field | Description |
---|---|
'Position' |
Position, in meters, specified as a real, finiteN-by-3 matrix of [xyz] vectors.Nis the number of samples in the current frame. |
'Velocity' |
Velocity (v), in meters per second, specified as a real, finiteN-by-3 matrix of [vxvyvz] vector.Nis the number of samples in the current frame. |
'Orientation' |
Orientation with respect to the local Cartesian coordinate system, specified as one of these options:
Each quaternion or rotation matrix is a frame rotation from the local Cartesian coordinate system to the current sensor body coordinate system.Nis the number of samples in the current frame. |
'Acceleration' |
Acceleration (a), in meters per second squared, specified as a real, finiteN-by-3 matrix of [axayaz] vectors.Nis the number of samples in the current frame. |
'AngularVelocity' |
Angular velocity (ω), in degrees per second squared, specified as a real, finiteN-by-3 matrix of [ωxωyωz] vectors.Nis the number of samples in the current frame. |
The returned field values are of typedouble
orsingle
and are of the same type as the corresponding field values in thegTruth
input.
Object Functions
To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object namedobj
, use this syntax:
release(obj)
Specific toinsSensor
perturbations |
Perturbation defined on object |
perturb |
Apply perturbations to object |
Examples
Generate INS Measurements from Stationary Input
Create a motion structure that defines a stationary position at the local north-east-down (NED) origin. Because the platform is stationary, you need to define only a single sample. Assume the ground-truth motion is sampled for 10 seconds with a 100 Hz sample rate. Create a defaultinsSensor
System object™. Preallocate variables to hold output from theinsSensor
object.
Fs = 100; duration = 10; numSamples = Fs*duration; motion = struct(...'Position',zeros(1,3),...'Velocity',zeros(1,3),...'Orientation',ones(1,1,'quaternion')); INS = insSensor; positionMeasurements = zeros(numSamples,3); velocityMeasurements = zeros(numSamples,3); orientationMeasurements = zeros(numSamples,1,'quaternion');
In a loop, callINS
运动与静止的结构返回position, velocity, and orientation measurements in the local NED coordinate system. Log the position, velocity, and orientation measurements.
fori = 1:numSamples measurements = INS(motion); positionMeasurements(i,:) = measurements.Position; velocityMeasurements(i,:) = measurements.Velocity; orientationMeasurements(i) = measurements.Orientation;end
Convert the orientation from quaternions to Euler angles for visualization purposes. Plot the position, velocity, and orientation measurements over time.
orientationMeasurements = eulerd(orientationMeasurements,'ZYX','frame');t = (0:(numSamples-1))/Fs; subplot(3,1,1) plot(t,positionMeasurements) title('Position') xlabel('Time (s)') ylabel('Position (m)') legend('North','East','Down'次要情节(3、1、2)情节titl (t, velocityMeasurements)e('Velocity') xlabel('Time (s)') ylabel('Velocity (m/s)') legend('North','East','Down') subplot(3,1,3) plot(t,orientationMeasurements) title('Orientation') xlabel('Time (s)') ylabel('Rotation (degrees)') legend('Roll','Pitch','Yaw')
Generate INS Measurements for a Turning Platform
Generate INS measurements using theinsSensor
System object™. UsewaypointTrajectory
to generate the ground-truth path.
Specify a ground-truth orientation that begins with the sensor bodyx-axis aligned with North and ends with the sensor bodyx-axis aligned with East. Specify waypoints for an arc trajectory and a time-of-arrival vector for the corresponding waypoints. Use a 100 Hz sample rate. Create awaypointTrajectory
System object with the waypoint constraints, and setSamplesPerFrame
so that the entire trajectory is output with one call.
eulerAngles = [0,0,0;...0,0,0;...90,0,0;...90,0,0]; orientation = quaternion(eulerAngles,'eulerd','ZYX','frame');r = 20; waypoints = [0,0,0;...100,0,0;...100+r,r,0;...100+r,100+r,0]; toa = [0,10,10+(2*pi*r/4),20+(2*pi*r/4)]; Fs = 100; numSamples = floor(Fs*toa(end)); path = waypointTrajectory('Waypoints',waypoints,...'TimeOfArrival',toa,...'Orientation',orientation,...'SampleRate',Fs,...'SamplesPerFrame',numSamples);
Create aninsSensor
System object to model receiving INS data. Set thePositionAccuracy
to0.1
.
ins = insSensor('PositionAccuracy',0.1);
Call the waypoint trajectory object,path
, to generate the ground-truth motion. Call the INS simulator,ins
, with the ground-truth motion to generate INS measurements.
[motion.Position,motion.Orientation,motion.Velocity] = path(); insMeas = ins(motion);
Convert the orientation returned byins
to Euler angles in degrees for visualization purposes. Plot the full path and orientation over time.
orientationMeasurementEuler = eulerd(insMeas.Orientation,'ZYX','frame');次要情节(2,1,1)情节(insMeas.Position (: 1), insMeas.Position(:,2)); title('Path') xlabel('North (m)') ylabel('East (m)') subplot(2,1,2) t = (0:(numSamples-1)).'/Fs; plot(t,orientationMeasurementEuler(:,1),...t,orientationMeasurementEuler(:,2),...t,orientationMeasurementEuler(:,3)); title('Orientation') legend('Yaw','Pitch','Roll') xlabel('Time (s)') ylabel('Rotation (degrees)')
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
The object functions,perturbations
andperturb
, do not support code generation.
Usage notes and limitations:
SeeSystem Objects in MATLAB Code Generation(MATLAB Coder).
Version History
Introduced in R2022a
Abrir ejemplo
Tiene una versión modificada de este ejemplo. ¿Desea abrir este ejemplo con sus modificaciones?
第一德MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina(Español)
- Canada(English)
- United States(English)
Europe
- Belgium(English)
- Denmark(English)
- Deutschland(Deutsch)
- España(Español)
- Finland(English)
- France(Français)
- Ireland(English)
- Italia(Italiano)
- Luxembourg(English)
- Netherlands(English)
- Norway(English)
- Österreich(Deutsch)
- Portugal(English)
- Sweden(English)
- Switzerland
- United Kingdom(English)