1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-10-27 21:47:39 +00:00

Remove build and data folders, move tests and utils to the base of the source tree

This commit is contained in:
Carles Fernandez
2024-10-04 11:55:09 +02:00
parent 5be2971c9b
commit 825037592a
251 changed files with 154 additions and 179 deletions

View File

@@ -0,0 +1,147 @@
/*!
* \file README.txt
* \brief How to add a block to the Simulink Library repository of Matlab,
* how to use the "gnss_sdr_tcp_connector_parallel_tracking_start.m" script
* and how to replace the tracking block of the library. Parallel Computing
* version.
*
* \author David Pubill, 2012. dpubill(at)cttc.es
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is part of GNSS-SDR.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -------------------------------------------------------------------------
*/
IMPORTANT: Please, to use this tracking check the configuration file called
'gnss-sdr_tcp_connector_tracking.conf'. There are two major changes:
1.- Choose the [GPS_L1_CA_TCP_CONNECTOR_Tracking] tracking algorithm.
2.- Choose a tcp port for channel 0 (e.g. Tracking.port_ch0=2070;)
A) HOW TO add a block to the Simulink Library repository of your Matlab installation
---------------------------------------------------------------------------------
(These steps should be followed only the first time)
1.- Copy the content of this folder to a folder accessible from Simulink.
2.- In the Matlab Command Window type:
>> simulink;
to open the Simulink Library Browser.
3.- Right-click on the Simulink/User-Defined Functions of the Simulink
Library menu, and click on "Open User-Defined Functions library"
(Window_1).
4.- Open the library model 'gnss_sdr_tcp_connector_tracking_lib.mdl'
(Window_2)
5.- If this is not the first time there should be an existing 'gnss-sdr'
block in the 'User-Defined Functions' window that should be deleted
before drag and drop the new 'gnss_sdr' block (which includes 3 blocks:
- 'gnss_sdr_tcp_connector_tracking_rx' block
- 'gnss_sdr_tcp_connector_tracking' block
- 'gnss_sdr_tcp_connector_tracking_tx' block)
from Window_2 to Window_1. A new message should appear: "This library
is locked. The action performed requires it to be unlocked". Then,
click on the "Unlock" button (the block will be copied) and close
Window_2.
6.- Right-click on the 'gnss-sdr' block and click on "Link Options -->
Disable link", repeat the action but now clicking on "Link Options -->
Break link". This action disables and breaks the link with the
original library model.
7.- On Window_1 save the "simulink/User-Defined Functions" library.
To do that go to "File > Save". Then, close Window_1.
8.- From "Simulink Library Browser" window, press F5 to refresh and generate
the new Simulink Library repository (it may take a few seconds). This
completes the installation of the custom Simulink block.
B) HOW TO use the "gnss_sdr_tcp_connector_parallel_tracking_start.m" script:
----------------------------------------------------------------
----------------------- ------------------ -----------------------
| | | | | |
| gnss_sdr_tcp_ | | gnss_sdr_tcp_ | | gnss_sdr_tcp_ |
| connector_tracking_ | --> | connector_ | --> | connector_tracking_ |
| rx | | tracking | | tx |
| | | | | |
----------------------- ------------------ -----------------------
The 'gnss_sdr_tcp_connector_parallel_tracking_start.m' is the script that
builds and configures a Simulink model for interacting with the GNSS-SDR
platform through a TCP communication. Some 'User parameters' can be
modified but, by default, these are the values assigned:
%User parameters
host = '84.88.61.86'; %Remote IP address (GNSS-SDR computer IP)
port = 2070; %Remote port (GNSS-SDR computer port for Ch0)
num_vars_rx = 9; %Number of variables expected from GNSS-SDR
num_vars_tx = 4; %Number of variable to be transmitted to GNSS-SDR
timeout = '40'; %Timeout in seconds
'host', 'port' and 'timeout' parameters configure both
'gnss_sdr_tcp_connector_tracking_rx' and 'gnss_sdr_tcp_connector_tracking_tx'
blocks. The 'port' parameter sets the base port number for the first
channel (ch0). Each of the subsequent channels increases their port by one
unit (e.g. ch0_port=2070, ch1_port=2071,...).
Also the name of the tracking block can be modified. It must match with
the Simulink model name:
%Name of the tracking block, it must match the Simulink model name
tracking_block_name = 'gnss_sdr_tcp_connector_tracking';
To configure the MATLAB to work in parallel mode (the 'Parallel Computing'
Toolbox must be installed in the MATLAB) type in the Matlab Command Window
the following:
>> matlabpool(C)
where C is the number of cores of the computer to be used.
Then it should appear a message like this one:
"Destroying 1 pre-existing parallel job(s) created by matlabpool that were
in the finished or failed state.
Starting matlabpool using the 'local' configuration ... connected to 4
labs."
Once the MATLAB is configured to work in parallel mode, type the following
to run the script:
>> gnss_sdr_tcp_connector_parallel_tracking_start(N,C);
where N must match the number of channels configured in the GNSS-SDR
platform and C is the same as before.
Note: to stop working with the parallel mode type in the Command Window
the following:
>> matlabpool close
C) HOW TO replace the tracking block of the library
------------------------------------------------
1.- Open the library model 'gnss_sdr_tcp_connector_tracking_lib.mdl'
2.- Unlock the library. Click on "Edit > Unlock Library".
3.- Open the "gnss-sdr" block and change the "gnss_sdr_tcp_connector_tracking"
block by another one. If the name is different it must be updated in
the "gnss_sdr_tcp_connector_parallel_tracking_start.m" code (see
section B)
4.- Save the new library.
5.- Go to section A and follow the instructions.

View File

@@ -0,0 +1,188 @@
% This MATLAB function builds and configures a Simulink model
% for interacting with the GNSS-SDR platform through a TCP
% communication. Parallel Computing version.
% \author David Pubill, 2012. dpubill(at)cttc.es
%
% ----------------------------------------------------------------------
%
% Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
%
% GNSS-SDR is a software defined Global Navigation
% Satellite Systems receiver
%
% This file is part of GNSS-SDR.
%
% SPDX-License-Identifier: GPL-3.0-or-later
%
% ----------------------------------------------------------------------
%/
function gnss_sdr_tcp_connector_parallel_tracking_start(num_channels, num_cores)
%The parallel for (parfor) loop allows to build and run a Simulink
%model in parallel mode, programming different threads
parfor i = 0:num_cores-1;
%Open and close the Simulink Library
simulink('open');
simulink('close');
%User parameters
host = '84.88.61.86'; %Remote IP address (GNSS-SDR computer IP)
port = 2070; %Remote port (GNSS-SDR computer port for Ch0)
num_vars_rx = 9; %Number of variables expected from GNSS-SDR
num_vars_tx = 4; %Number of variable to be transmitted to GNSS-SDR
timeout = '40'; %Timeout [s]
%Name of the tracking block, it must match the Simulink model name
tracking_block_name = 'gnss_sdr_tcp_connector_tracking';
% Layout coordinates for the gnss_sdr_tcp_connector_tracking blocks
X0 = 20;
X1 = 170;
Y0 = 20;
Y1 = 140;
X_offset = 200;
Y_offset = 160;
%Calculate the size of the data received from GNSS-SDR
%(float = 4 bytes each variable)
datasize_RX = num_vars_rx*4;
%Create a Simulink model
model_name = ['gnss_sdr_tcp_connector_parallel_tracking_aux_', num2str(i)];
new_system(model_name);
open_system(model_name);
%Set parameters to avoid warnings in the Command Window
set_param(model_name,...
'InheritedTsInSrcMsg', 'none');
warning('off', 'Simulink:Commands:SetParamLinkChangeWarn');
%Assign values to the variables used by Simulink in the base workspace
assignin('base', 'Ti', 1e-3);
assignin('base', 'f0', 1.57542e9);
assignin('base', 'SFunSlope', 3.5);
assignin('base', 'Tc', 4e-3/4092);
assignin('base', 'T', 1e-3);
assignin('base', 'B_PLL', 50);
assignin('base', 'B_DLL', 2);
%Calculate some variables to control the number of blocks that
%should content each Simulink model in function of the number of
%cores specified
min_num_blocks_per_model = floor(num_channels/num_cores);
id = rem(num_channels,num_cores);
if(i<id)
aux=1;
else
aux=0;
end
%Build the Simulink model for the core 'i'
for m = 0:min_num_blocks_per_model+aux-1
index = m + min_num_blocks_per_model*i + min(id,i);
%Add and prepare an empty block to become the TCP connector block
tcp_connector_block=[model_name, '/gnss_sdr_tcp_connector_tracking_', num2str(index)];
add_block('simulink/Ports & Subsystems/Subsystem', tcp_connector_block);
delete_line(tcp_connector_block, 'In1/1', 'Out1/1')
tcp_connector_tracking_i_In1 = [model_name,'/gnss_sdr_tcp_connector_tracking_',num2str(index),'/In1'];
tcp_connector_tracking_i_Out1 = [model_name,'/gnss_sdr_tcp_connector_tracking_',num2str(index),'/Out1'];
delete_block(tcp_connector_tracking_i_In1);
delete_block(tcp_connector_tracking_i_Out1);
%Add to the TCP connector block the receiver, the tracking and the
%transmitter blocks
tcp_connector_tracking_rx_block = [model_name,'/gnss_sdr_tcp_connector_tracking_',num2str(index),'/gnss_sdr_tcp_connector_tracking_rx'];
tcp_connector_tracking_block = [model_name,'/gnss_sdr_tcp_connector_tracking_',num2str(index),'/', tracking_block_name];
tcp_connector_tracking_tx_block = [model_name,'/gnss_sdr_tcp_connector_tracking_',num2str(index),'/gnss_sdr_tcp_connector_tracking_tx'];
add_block('simulink/User-Defined Functions/gnss_sdr/gnss_sdr_tcp_connector_tracking_rx',tcp_connector_tracking_rx_block);
path_to_tracking_block = ['simulink/User-Defined Functions/gnss_sdr/', tracking_block_name];
add_block(path_to_tracking_block, tcp_connector_tracking_block);
add_block('simulink/User-Defined Functions/gnss_sdr/gnss_sdr_tcp_connector_tracking_tx',tcp_connector_tracking_tx_block);
%Connect the receiver block to the tracking block
for j=1:num_vars_rx;
rx_out_ports =['gnss_sdr_tcp_connector_tracking_rx/', num2str(j)];
tracking_in_ports =[tracking_block_name, '/', num2str(j)];
add_line(tcp_connector_block, rx_out_ports, tracking_in_ports)
end
%Connect the tracking block to the transmitter block
for k=1:num_vars_tx;
tracking_out_ports =[tracking_block_name, '/', num2str(k)];
tx_in_ports =['gnss_sdr_tcp_connector_tracking_tx/',num2str(k)];
add_line(tcp_connector_block, tracking_out_ports, tx_in_ports)
end
%Add, place and connect two scopes in the TCP connector block
name_scope_1 = [tcp_connector_block,'/Scope'];
add_block('simulink/Sinks/Scope', name_scope_1, 'Position', [500 300 550 350]);
set_param(name_scope_1, 'NumInputPorts', '4', 'LimitDataPoints', 'off');
add_line(tcp_connector_block, 'gnss_sdr_tcp_connector_tracking_rx/9', 'Scope/1', 'autorouting','on')
tracking_scope_port2 = [tracking_block_name,'/2'];
add_line(tcp_connector_block, tracking_scope_port2, 'Scope/2', 'autorouting','on')
tracking_scope_port3 = [tracking_block_name,'/3'];
add_line(tcp_connector_block, tracking_scope_port3, 'Scope/3', 'autorouting','on')
tracking_scope_port4 = [tracking_block_name,'/4'];
add_line(tcp_connector_block, tracking_scope_port4, 'Scope/4', 'autorouting','on')
name_scope_2 = [tcp_connector_block,'/EPL'];
add_block('simulink/Sinks/Scope', name_scope_2, 'Position', [500 400 550 450]);
set_param(name_scope_2, 'LimitDataPoints', 'off');
tracking_scope2_port5 = [tracking_block_name,'/5'];
add_line(tcp_connector_block, tracking_scope2_port5, 'EPL/1', 'autorouting','on')
num_port = port+index;
%Set the TCP receiver parameters
tcp_receiver = [model_name,'/gnss_sdr_tcp_connector_tracking_',num2str(index),'/gnss_sdr_tcp_connector_tracking_rx/RX'];
set_param(tcp_receiver, 'Port', num2str(num_port), 'Host', host, 'DataSize', num2str(datasize_RX), 'Timeout', timeout);
%Set the TCP transmitter parameters
tcp_transmitter = [model_name, '/gnss_sdr_tcp_connector_tracking_',num2str(index),'/gnss_sdr_tcp_connector_tracking_tx/TX'];
set_param(tcp_transmitter, 'Port', num2str(num_port), 'Host', host,'Timeout', timeout);
%New layout coordinates for each block
X2 = X0 + floor(m/4)*X_offset;
X3 = X1 + floor(m/4)*X_offset;
Y2 = Y0 + (m-4*floor(m/4))*Y_offset;
Y3 = Y1 + (m-4*floor(m/4))*Y_offset;
%Place the block in the layout
set_param(tcp_connector_block, 'Position', [X2 Y2 X3 Y3]);
end
%Set parameters to configure the model Solver
set_param(model_name,...
'SolverType', 'Fixed-step', 'Solver', 'FixedStepDiscrete',...
'FixedStep', 'auto', 'StopTime', 'inf');
%Save the model with a definitive name
model_name_ready = ['gnss_sdr_tcp_connector_parallel_tracking_ready_', num2str(i)];
save_system(model_name, model_name_ready);
%Pause the thread 'i*5' seconds in function of the number of core.
%This allows the system to establish the TCP connections in the
%correct order
if (aux == 0)
pause(i*5);
end
%Run the Simulink model
set_param(model_name_ready,'simulationcommand','start');
end
end

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,5 @@
/*
* SPDX-FileCopyrightText: David Pubill, 2012. dpubill(at)cttc.es
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/