The main purpose of SNACS is to simulate GNSS signal propagation in different channels. We start by generating a simple channel impulse response (CIR) file. The CIR will contain a single component that rests at delay = 0 s for the duration of one second and starts to move then. This situation could describe a receiver that is solely receiving the line-of-sight (LOS) signal of a transmitter. After one second it starts to move away from the transmitter.
You can define the maximum speed of the vehicle. The acceleration is computed in a continuous way using the cosine function.
The file is saved in HDF5 format to snacs_cir_moving_los_v01.h5.
3 % SNACS - The Satellite Navigation Radio Channel Simulator
5 % Copyright (C) 2010 F. M. Schubert
7 % This program is free software: you can redistribute it and/or modify
8 % it under the terms of the GNU General Public License as published by
9 % the Free Software Foundation, either version 3 of the License, or
10 % (at your option) any later version.
12 % This program is distributed in the hope that it will be useful,
13 % but WITHOUT ANY WARRANTY; without even the implied warranty of
14 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 % GNU General Public License
for more details.
17 % You should have received a copy of the GNU General Public License
18 % along with
this program. If not, see <http:
21 % This file generates an artifical times series with 1 line-of-sight path
22 % that begins to accelerate slowly up to a constant speed.
31 addpath('../helper_functions');
36 h5_filename =
'snacs_cir_moving_los_v01-2.h5';
40 cir_amount = len * cir_rate;
43 start_acceleration = 1.0; % in s
44 full_speed_at = 3.0; % in s
46 c0 = 2.99e8; % speed of light in m/s
48 carrier_frequency = 1.5e9; % in Hz
49 carrier_wavelength = c0 / carrier_frequency;
51 %% write Parameters to HDF5 file
53 simulation_parameters.c0 = c0;
54 simulation_parameters.cir_rate = cir_rate;
55 simulation_parameters.cir_amount = cir_amount;
57 init_snacs_cir_file(h5_filename, simulation_parameters);
61 % TODO check
for maximum vehicle speed:
62 maximum_possible_speed = c0 * cir_rate / carrier_frequency / 2; % sampling theorem
64 cir_start_acceleration = start_acceleration * cir_rate;
65 cir_full_speed_at = full_speed_at * cir_rate;
66 cirs_acceleration = cir_full_speed_at - cir_start_acceleration;
68 speeds = zeros(cir_amount, 1);
69 distances = zeros(cir_amount, 1);
70 los_complex_amplitudes = zeros(cir_amount, 1);
72 %% generate channel impulse response
74 wbh = waitbar(0,
'generating channel impulse response...');
76 wb_update = cir_amount / 10;
79 if (mod(k, wb_update) == 0) waitbar(k/cir_amount, wbh); end;
81 cir_number = k-1; % k-1: CIR number should start at 0
85 if (k < cir_start_acceleration)
86 % no movement, delay = 0:
88 elseif ( (k >= cir_start_acceleration) && (k < cir_full_speed_at) )
89 % acceleration
using a cos
function:
90 speeds(k) = speed * (cos(pi + (k-cir_start_acceleration) / cirs_acceleration * pi) + 1)/2;
92 % linear acceleration:
93 % speeds(k) = speed * (k-cir_start_acceleration) / cirs_acceleration;
94 elseif (k >= cir_full_speed_at)
95 % constant full speed:
99 % calculate distance
using the speed. k * 1/cir_rate is the current
101 distances(k) = speeds(k) * k * 1/cir_rate;
103 % build
struct for writing to HDF5 file:
104 los_struct = struct('delay', {0}, 'real', {0}, 'imag', {0});
106 % calculate the line of sight complex amplitude:
107 los_complex_amplitudes(k) = 1.0 * exp(j * (2.0 * pi / carrier_wavelength) * distances(k));
109 % calculate LOS delay from distance using speed of light:
110 los_struct.delay = distances(k) / c0;
111 los_struct.real = real(los_complex_amplitudes(k));
112 los_struct.imag = imag(los_complex_amplitudes(k));
114 % write this CIR to file:
115 append_one_cir_to_cir_file(h5_filename, cir_number, los_struct);
120 % write reference distances to file:
121 hdf5write(h5_filename, '/reference_range/range_absolut' , distances, 'WriteMode', 'append');
125 x_ax = 0:1/cir_rate:cir_amount/cir_rate - 1/cir_rate;
128 title(
'Receiver Speed');
133 ylabel(
'Speed [m/s]');
134 ylim([-10, speed + 20]);
136 if save_figures save_figure_as_png(
'../../documentation/doxygen-sources/graphic/example03_receiver-speed.png'); end
139 title(
'Distance Receiver - Transmitter');
141 plot(x_ax, distances);
144 ylabel(
'Distance [m]');
145 ylim([-10, distances(end) + 20]);
147 if save_figures save_figure_as_png(
'../../documentation/doxygen-sources/graphic/example03_distance.png'); end
150 title(
'Line-Of-Sight Amplitude');
152 plot(x_ax, abs(los_complex_amplitudes));
156 ylim([-10, los_complex_amplitudes(end) + 10]);
158 if save_figures save_figure_as_png(
'../../documentation/doxygen-sources/graphic/example03_amplitude.png'); end
161 title(
'Line-Of-Sight Phase');
163 plot(x_ax, angle(los_complex_amplitudes));
166 ylabel(
'Phase [rad]');
169 if save_figures save_figure_as_png(
'../../documentation/doxygen-sources/graphic/example03_phase.png'); end