Project

General

Profile

Revision 1512

Edited BOM Vector Component Tables with values which will gaurantee that worst case net vector sum will not overflow an integer data type (16 bits).
Also changed Makefile to have TARGET=push_pull. Also added functionality to MATLAB script so that it will automatically calculate the BOM Vector
Component Table given a scalar value.

View differences:

trunk/code/behaviors/formation_control/push_pull/vectorSizeSpecs.m
28 28

  
29 29

  
30 30
calc_scalar = (2^(dataBits-1)-1) / (max_net_component * maxIntensity);
31
% calc_scalar = 25.560 => use 25 as scalor
31
% calc_scalar = 25.560 for 16 bits => use 25 as scalar for int data type
32 32

  
33 33
fprintf('With %d data bits, calculated scalar value: %.3f\n\n', dataBits, calc_scalar);
34 34

  
......
36 36
% Check worst case
37 37
scaled_vector_components = scalar * vector_components;
38 38

  
39
worst_case = scaled_vector_components * maxIntensity;
39
worst_case = floor(scaled_vector_components) * maxIntensity;
40 40
worst_sum = sum(worst_case);
41
fprintf('With scalar %d, max worst case sum: %d\n', scalar, worst_sum);
41
fprintf('With scalar %d, max worst case sum: %d\n', scalar, round(worst_sum));
42 42
fprintf('Max number: 2^(%d-1) - 1 = %d\n', dataBits, (2^(dataBits-1)-1));
43

  
44

  
45
% Calculate the x and y component arrays which should be used in the
46
% BOM Vector Component Tables in push_pull.c
47
N = 0:15;
48
x_comp = floor(scalar * cos(2 * pi / 16 * N))
49
y_comp = floor(scalar * sin(2 * pi / 16 * N))
trunk/code/behaviors/formation_control/push_pull/push_pull.c
22 22
 * The x component of each BOM detector (indexed from 0 to 15)
23 23
 * was calculated using the following formula:
24 24
 *
25
 *		x_comp[i] = round(100 * cos ( 2 * pi / 16 * i) )
25
 *		x_comp[i] = round(25 * cos ( 2 * pi / 16 * i) )
26 26
 *
27 27
 * If the BOM detectors were superimposed onto a 2 dimensional Cartesian space,
28 28
 * this effectively calculates the x component of the emitter vector where
29 29
 * emitter 0 corresponds to an angle of 0 radians, 4 -> pi/2, 8 -> pi, ect.
30 30
 */
31 31
static const signed int x_comp[16] = {
32
	100,
33
	92,
34
	71,
35
	38,
32
	25,
33
	23,
34
	17,
35
	9,
36 36
	0,
37
	-38,
38
	-71,
39
	-92,
40
	-100,
41
	-92,
42
	-71,
43
	-38,
37
	-9,
38
	-17,
39
	-23,
40
	-25,
41
	-23,
42
	-17,
43
	-9,
44 44
	0,
45
	38,
46
	71,
47
	92
45
	9,
46
	17,
47
	23
48 48
};
49 49

  
50 50

  
......
52 52
 * The y component of each BOM detector (indexed from 0 to 15)
53 53
 * was calculated using the following formula:
54 54
 *
55
 *		y_comp[i] = round(100 * sin ( 2 * pi / 16 * i) )
55
 *		y_comp[i] = round(25 * sin ( 2 * pi / 16 * i) )
56 56
 *
57 57
 * If the BOM detectors were superimposed onto a 2 dimensional Cartesian space,
58 58
 * this effectively calculates the y component of the emitter vector where
......
60 60
 */
61 61
static signed int y_comp[16] = {
62 62
	0,
63
	38,
64
	71,
65
	92,
66
	100,
67
	92,
68
	71,
69
	38,
63
	9,
64
	17,
65
	23,
66
	25,
67
	23,
68
	17,
69
	9,
70 70
	0,
71
	-38,
72
	-71,
73
	-92,
74
	-100,
75
	-92,
76
	-71,
77
	-38
71
	-9,
72
	-17,
73
	-23,
74
	-25,
75
	-23,
76
	-17,
77
	-9
78 78
};
79 79

  
80 80

  
......
153 153

  
154 154
static int get_bom_vector(Vector* bom_vector) {
155 155

  
156
	return EXIT_SUCCESS;
156
	return 0;
157 157

  
158 158
}
trunk/code/behaviors/formation_control/push_pull/Makefile
8 8
endif
9 9

  
10 10
# Target file name (without extension).
11
TARGET = template
11
TARGET = push_pull
12 12

  
13 13
# Uncomment this to use the wireless library
14 14
USE_WIRELESS = 1

Also available in: Unified diff