Revision 1345
Final spline code for master/slave
updated outdated libdragonfly and libwireless
sensor_matrix.h | ||
---|---|---|
1 | 1 |
/** |
2 |
* Copyright (c) 2007 Colony Project |
|
3 |
* |
|
4 |
* Permission is hereby granted, free of charge, to any person |
|
5 |
* obtaining a copy of this software and associated documentation |
|
6 |
* files (the "Software"), to deal in the Software without |
|
7 |
* restriction, including without limitation the rights to use, |
|
8 |
* copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
9 |
* copies of the Software, and to permit persons to whom the |
|
10 |
* Software is furnished to do so, subject to the following |
|
11 |
* conditions: |
|
12 |
* |
|
13 |
* The above copyright notice and this permission notice shall be |
|
14 |
* included in all copies or substantial portions of the Software. |
|
15 |
* |
|
16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
17 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
18 |
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
19 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
20 |
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
21 |
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
22 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
23 |
* OTHER DEALINGS IN THE SOFTWARE. |
|
24 |
**/ |
|
25 |
|
|
26 |
/** |
|
2 | 27 |
* @file sensor_matrix.h |
3 | 28 |
* @brief Definitions for sensor matrices |
4 | 29 |
* |
... | ... | |
7 | 32 |
* @author Brian Coltin, Colony Project, CMU Robotics Club |
8 | 33 |
**/ |
9 | 34 |
|
35 |
#ifndef SENSOR_MATRIX_H |
|
36 |
#define SENSOR_MATRIX_H |
|
37 |
|
|
38 |
|
|
10 | 39 |
/** |
11 | 40 |
* @defgroup sensormatrix Sensor Matrix |
12 | 41 |
* @brief the robot sensor matrix |
... | ... | |
17 | 46 |
* @{ |
18 | 47 |
**/ |
19 | 48 |
|
49 |
#define MAXIMUM_XBEE_ID 0x10 |
|
50 |
#define READING_UNKNOWN 0xFF |
|
51 |
|
|
20 | 52 |
/** |
21 | 53 |
* @struct SensorMatrix |
22 | 54 |
* |
23 | 55 |
* A sensor matrix. |
24 | 56 |
**/ |
57 |
//TODO: the order of member variables in this struct should be changed in case the compile packs the struct |
|
58 |
// In order to achieve the best packing, the variables should be listed in order of decreasing memory size. |
|
59 |
// Thus, pointers should be first, followed by int, followed by char. |
|
25 | 60 |
typedef struct |
26 | 61 |
{ |
27 | 62 |
/** |
28 |
* The size of the sensor matrix. |
|
29 |
**/ |
|
30 |
unsigned int size; |
|
31 |
/** |
|
32 |
* The matrix. Each row represents the readings of one |
|
33 |
* robot. |
|
63 |
* The number of robots in the token ring. |
|
34 | 64 |
**/ |
35 |
int** matrix;
|
|
65 |
int numJoined;
|
|
36 | 66 |
/** |
37 | 67 |
* The element representing a robot is true if that robot |
38 | 68 |
* is in the token ring and false otherwise. |
39 | 69 |
**/ |
40 |
int* joined; |
|
70 |
unsigned char joined[MAXIMUM_XBEE_ID]; |
|
71 |
|
|
72 |
// on the bayboard, we don't include the matrix to save memory. |
|
73 |
#ifndef BAYBOARD |
|
41 | 74 |
/** |
42 |
* The number of robots in the token ring. |
|
75 |
* The matrix. Each row represents the readings of one |
|
76 |
* robot. |
|
43 | 77 |
**/ |
44 |
int numJoined; |
|
78 |
unsigned char matrix[MAXIMUM_XBEE_ID][MAXIMUM_XBEE_ID]; |
|
79 |
#endif |
|
45 | 80 |
} SensorMatrix; |
46 | 81 |
|
47 | 82 |
/**@brief Create a sensor matrix **/ |
48 |
SensorMatrix* sensor_matrix_create(void); |
|
49 |
/**@brief Destroy a sensor matrix **/ |
|
50 |
void sensor_matrix_destroy(SensorMatrix* m); |
|
51 |
/**@brief Add a robot to a sensor matrix **/ |
|
52 |
void sensor_matrix_add_robot(SensorMatrix* m, unsigned int id); |
|
53 |
/**@brief Remove a robot from a sensor matrix **/ |
|
54 |
void sensor_matrix_remove_robot(SensorMatrix* m, unsigned int id); |
|
83 |
void sensor_matrix_create(void); |
|
55 | 84 |
/**@brief Set a reading in a sensor matrix **/ |
56 |
void sensor_matrix_set_reading(SensorMatrix* m, int observer, int robot, int reading);
|
|
85 |
void sensor_matrix_set_reading(int observer, int robot, int reading); |
|
57 | 86 |
/**@brief Get a reading in a sensor matrix **/ |
58 |
int sensor_matrix_get_reading(SensorMatrix* m, int observer, int robot);
|
|
87 |
int sensor_matrix_get_reading(int observer, int robot); |
|
59 | 88 |
/**@brief Set whether the robot is in the token ring **/ |
60 |
void sensor_matrix_set_in_ring(SensorMatrix* m, int robot, int in);
|
|
89 |
void sensor_matrix_set_in_ring(int robot, int in); |
|
61 | 90 |
/**@brief Get whether the robot is in the sensor ring **/ |
62 |
int sensor_matrix_get_in_ring(SensorMatrix* m, int robot); |
|
63 |
/**@brief Get the size of the sensor matrix **/ |
|
64 |
int sensor_matrix_get_size(SensorMatrix* m); |
|
91 |
int sensor_matrix_get_in_ring(int robot); |
|
65 | 92 |
/**@brief Get the number of robots which have joined the token ring **/ |
66 |
int sensor_matrix_get_joined(SensorMatrix* m); |
|
93 |
int sensor_matrix_get_joined(void); |
|
94 |
/**@brief Get the maximum size of the sensor matrix **/ |
|
95 |
int sensor_matrix_get_size(void); |
|
67 | 96 |
|
68 | 97 |
/** @} **/ //end defgroup |
69 | 98 |
|
99 |
|
|
100 |
#endif |
|
101 |
|
Also available in: Unified diff