RcdMathLib_doc
Open Source Library for Linear and Non-linear Algebra
distance_based_test.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Zakaria Kasmi <zkasmi@inf.fu-berlin.de>
3  * 2020 Freie Universität Berlin
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser General
6  * Public License v2.1. See the file LICENSE in the top level directory for more
7  * details.
8  */
9 
25 #include <stdio.h>
26 
27 #include "trilateration.h"
28 #include "matrix.h"
29 #include "vector.h"
30 #include "dist_based_position.h"
31 
33 {
34  puts("***************** Distance-based system example *****************");
35  matrix_t ref_pos_matrix[4][3] = { { 0, 0, 1.67 }, // P1
36  { 4.5, 0, 0.75 }, // P2
37  { 4.5, 4.45, 0.75 }, // P3
38  { 0, 4.92, 0.86 } // P4
39  };
40 
41  matrix_t true_pos[3] = { 1.0000, 3.0000, 0.0000 }; // is usually unknown
42  /* measured distances to the reference stations */
43  matrix_t measured_dist_arr[4] = { 3.577157155, 4.685985423, 3.883094303,
44  2.320377599 };
45  /* estimated position */
46  matrix_t est_pos[4];
47  uint8_t ref_point_num = 4;
48  trilateration2(ref_point_num, ref_pos_matrix, measured_dist_arr,
49  est_pos, NULL);
50 
51  printf("true position = ");
52  vector_flex_print(3, true_pos, 5, 4);
53  puts("");
54 
55  printf("estimated position = ");
56  vector_flex_print(3, &est_pos[1], 5, 7);
57  puts("");
58 }
vector_flex_print
void vector_flex_print(uint32_t length, vector_t arr[], uint8_t before_dot, uint8_t after_dot)
Display the values of the vector's elements.
Definition: vector.c:284
trilateration.h
Implement the trilateration algorithm.
dist_based_position.h
Functions of distance-based localization systems.
matrix.h
Matrix computations.
distance_based_test
void distance_based_test(void)
Example of a distance-based localization system.
Definition: distance_based_test.c:32
trilateration2
void trilateration2(uint8_t anchor_num, matrix_t anchor_pos_matrix[anchor_num][3], matrix_t dist_arr[], matrix_t solution_x1[], matrix_t solution_x2[])
Implement the trilateration algorithm.
Definition: trilateration.c:69
matrix_t
#define matrix_t
Define the data type of the matrix elements.
Definition: matrix.h:38
vector.h
Vector computations.