Revision 1510
Implementing function to calculate get_bom_vector() function. Added
MATLAB script to assist in calculating the scalar value used to scale up
the BOM unit vectors such that the worst case sum will not overflow an
int data type.
main.c | ||
---|---|---|
1 |
#include <stdint.h> |
|
1 | 2 |
#include <dragonfly_lib.h> |
2 | 3 |
#include <wl_basic.h> |
3 |
#include <stdint.h>
|
|
4 |
#include <stdlib.h>
|
|
4 | 5 |
|
5 | 6 |
/* Struct for storing vector components */ |
6 | 7 |
typedef struct { |
7 |
uint8_t x;
|
|
8 |
uint8_t y;
|
|
8 |
int x;
|
|
9 |
int y;
|
|
9 | 10 |
} Vector; |
10 | 11 |
|
11 | 12 |
|
12 | 13 |
/* Function Prototypes */ |
13 |
static const Vector get_bom_vector();
|
|
14 |
static int get_bom_vector(Vector*);
|
|
14 | 15 |
|
15 | 16 |
|
16 | 17 |
/******************************* |
... | ... | |
81 | 82 |
int main (void) { |
82 | 83 |
|
83 | 84 |
/* Store current BOM readings and use them as a weighting factor */ |
84 |
int intensity[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
85 |
uint8_t intensity[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
85 | 86 |
|
86 | 87 |
/* Arrays for storing the weighted x ("Rightness") and y ("Forwardness") |
87 | 88 |
* components. Calculated by multiplying the intensity by the x and y |
... | ... | |
150 | 151 |
} |
151 | 152 |
|
152 | 153 |
|
153 |
static Vector get_bom_vector() {
|
|
154 |
static int get_bom_vector(Vector* bom_vector) {
|
|
154 | 155 |
|
156 |
return EXIT_SUCCESS; |
|
157 |
|
|
155 | 158 |
} |
Also available in: Unified diff