-
Notifications
You must be signed in to change notification settings - Fork 0
/
GPS.m
66 lines (58 loc) · 2.05 KB
/
GPS.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
classdef GPS < handle
%GPS An instance of this class represents a GPS sensor
% Unlike the PX4 simulator, this GPS sensor represents the filtered
% global position (normally a fused measurement of accelerometers and
% raw GPS data).
properties
% unsigned integer ms timestamp representing the time since this
% sensor was powered on.
time_ms = 0
% float degrees WGS84 Latitude
lat = 0.0
% float degrees WGS84 Longitude
lon = 0.0
% float m Altitude (MSL)
alt = 0.0
% float m Altitude above ground
relative_alt = 0.0
% float m/s Ground X Speed (Latitude, positive north)
vx = 0.0
% float m/s Ground Y Speed (Longitude, positive east)
vy = 0.0
% float m/s Ground Z Speed (Altitude, positive down)
vz = 0.0
% float degrees Vehicle heading (yaw angle), 0.0..359.99 degrees.
% 0 represents true North, 90 represents true East.
hdg = 0.0
end
properties (Access = private)
state_listeners = []
end
events
StateChange
end
methods
function obj = GPS()
%GPS Construct an instance of this class
end
function commit(obj)
obj.notifyStateChange()
end
function notifyStateChange(obj)
% notifyStateChange Trigger the StateChange event and notify
% all subscribers
notify(obj, 'StateChange');
end
function subscribeToStateChange(obj, subscriber)
% subscribeToStateChange Set an event listener to trigger when
% a state change occurs.
% On input
% obj - an instance of the GPS class
% subscriber - a function handle to trigger
% Example:
% gps.subscribeToStateChange(@uas.updateState);
lh = obj.addlistener('StateChange', subscriber);
obj.state_listeners = [obj.state_listeners, lh];
end
end
end