diff --git a/matlab/GPSaidedINS_car.m b/matlab/GPSaidedINS_car.m index d84bef978535a29c328ff3bd7ab9214a0f804497..00e72941df9abec3b1d7c06aad841c6c1549ce8b 100644 --- a/matlab/GPSaidedINS_car.m +++ b/matlab/GPSaidedINS_car.m @@ -95,7 +95,7 @@ for k=2:N turn=true; end %update sensor state - sensor=gps_randomized_car(t(k),sensor,turn,sv); %remove _randomized for worst case + sensor=gps_randomized_car(t(k),sensor,turn,sv); %determine if GPS position is available GPS_position=strcmp(sensor.state,'position_available'); %compute power consumption diff --git a/matlab/GPSaidedINS_cycling.m b/matlab/GPSaidedINS_cycling.m index 87d5a6d1bcb0bbda7a19891c5214b369afe634ff..5e09a35bb7c73890225a4221ce66dd720be15c45 100644 --- a/matlab/GPSaidedINS_cycling.m +++ b/matlab/GPSaidedINS_cycling.m @@ -101,7 +101,7 @@ for k=start_sim:start_sim+length_sim turn=true; end %update sensor state - sensor=gps_randomized_cycling(t(k),sensor,turn,sv); %remove _randomized for worst case + sensor=gps_randomized_cycling(t(k),sensor,turn,sv); %determine if GPS position is available GPS_position=strcmp(sensor.state,'position_available'); %compute power consumption diff --git a/matlab/gps.m b/matlab/gps.m deleted file mode 100644 index 55f0ab917a6156e9e3dee6bcb6dcec4d08e38a61..0000000000000000000000000000000000000000 --- a/matlab/gps.m +++ /dev/null @@ -1,156 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% GPS sensor dynamics %% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%STATE is a struct (called sensor) with the following fields -% state -[string]the current proceural state: no_info, cold_start, read_ephemeris, -% position_available, warm_start_avaialable, warm_start -% howLong -[double]when the current procedural state has been entered -% ephExp -[double]expiration time of ephemeris data -% fp -[int]number of tracked satelliets -% eph -[int]number of satellites for which ephemeris data are available - -%INPUTS -% -time -% -state -% -turn on/off (true=turn_ON, false=turn_OFF) -% -visible satellites - -%OUTPUTS -% -state - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -function sensor=gps(time,sensor_in,turn,sv) - -%% parameters -%define how many satellites you need to track given the accuracy requirements -required_sv= 4; -%define how long ephemeris data last -ephDuration=1800.0; -%define how much time is required to read the ephemeris data -ttge=59.0; -%define how much time is required to fetch the satellites signal -ttfs=0.01; - -%% initialize output -sensor = sensor_in; - -%% equations -%you cannot track satellites that you dont see -sensor.fp=min(sensor_in.fp,sv); -sensor.eph=min(sensor_in.eph,sv); - -%% events -ephemeris_expired=(time>sensor.ephExp)||(sensor.eph<required_sv); %ephemeris data are expired -lost_visibility=(sensor.fp<required_sv); -fetch_fp=(time-sensor_in.howLong)>=ttfs; -get_ephemeris=(time-sensor_in.howLong)>ttge; - -%% transitions and updates -%for each of the states handle eventual transitions and updates -%(i)if any transition is fired, always update the time the surrent state was entered -%(ii)other updates depend on the spefic transition that is fired -if strcmp(sensor_in.state,'no_info') - if(turn) - sensor.state='cold_start'; - sensor.howLong=time; - end -end -if strcmp(sensor_in.state,'position_available') - if(get_ephemeris) - sensor.state='position_available'; - sensor.howLong=time; - sensor.eph=sv; - sensor.ephExp=time+ephDuration; - end - if(~turn) - sensor.state='warm_start_available'; - sensor.howLong=time; - sensor.fp=0; - end - if(lost_visibility) - sensor.state='warm_start'; - sensor.howLong=time; - %might have to go on to cold_start - if(ephemeris_expired) - sensor.state='cold_start'; - sensor.howLong=time; - sensor.eph=0; - end - end - if(ephemeris_expired) - sensor.state='read_ephemeris'; - sensor.howLong=time; - sensor.eph=0; - %might have to go on to cold_start - if(lost_visibility) - sensor.state='cold_start'; - sensor.howLong=time; - end - end -end -if strcmp(sensor_in.state,'read_ephemeris') - if(get_ephemeris) - sensor.state='position_available'; - sensor.howLong=time; - sensor.eph=sv; - sensor.ephExp=time+ephDuration; - end - if(~turn) - sensor.state='no_info'; - sensor.howLong=time; - sensor.fp=0; - end - if(lost_visibility) - sensor.state='cold_start'; - sensor.howLong=time; - end -end -if strcmp(sensor_in.state,'warm_start') - if(fetch_fp) - sensor.state='position_available'; - sensor.howLong=time; - sensor.fp=sv; - end - if(ephemeris_expired) - sensor.state='cold_start'; - sensor.howLong=time; - sensor.eph=0; - end - if(~turn) - sensor.state='warm_start_available'; - sensor.howLong=time; - sensor.fp=0; - end -end -if strcmp(sensor_in.state,'cold_start') - if(fetch_fp) - sensor.state='read_ephemeris'; - sensor.howLong=time; - sensor.fp=sv; - end - if(~turn) - sensor.state='no_info'; - sensor.howLong=time; - sensor.fp=0; - end -end -if strcmp(sensor_in.state,'warm_start_available') - if(turn) - sensor.state='warm_start'; - sensor.howLong=time; - end - if(ephemeris_expired) - sensor.state='no_info'; - sensor.howLong=time; - sensor.eph=0; - end -end - -end - - - - -