root / branches / autonomous_recharging / code / projects / libwireless / lib / sensor_matrix.h @ 726
History | View | Annotate | Download (3.08 KB)
1 | 17 | bcoltin | /**
|
---|---|---|---|
2 | 340 | bcoltin | * Copyright (c) 2007 Colony Project
|
3 | 726 | gtress | *
|
4 | 340 | bcoltin | * 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 | 726 | gtress | *
|
13 | 340 | bcoltin | * The above copyright notice and this permission notice shall be
|
14 | * included in all copies or substantial portions of the Software.
|
||
15 | 726 | gtress | *
|
16 | 340 | bcoltin | * 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 | /**
|
||
27 | 17 | bcoltin | * @file sensor_matrix.h
|
28 | * @brief Definitions for sensor matrices
|
||
29 | *
|
||
30 | * Contains functions and declarations for using sensor matrices.
|
||
31 | *
|
||
32 | * @author Brian Coltin, Colony Project, CMU Robotics Club
|
||
33 | **/
|
||
34 | |||
35 | 340 | bcoltin | #ifndef SENSOR_MATRIX_H
|
36 | #define SENSOR_MATRIX_H
|
||
37 | |||
38 | |||
39 | 17 | bcoltin | /**
|
40 | * @defgroup sensormatrix Sensor Matrix
|
||
41 | * @brief the robot sensor matrix
|
||
42 | *
|
||
43 | * These functions and structures are used for localization
|
||
44 | * to determine the relative directions of robots.
|
||
45 | *
|
||
46 | * @{
|
||
47 | **/
|
||
48 | |||
49 | /**
|
||
50 | * @struct SensorMatrix
|
||
51 | *
|
||
52 | * A sensor matrix.
|
||
53 | **/
|
||
54 | typedef struct |
||
55 | { |
||
56 | /**
|
||
57 | * The matrix. Each row represents the readings of one
|
||
58 | * robot.
|
||
59 | **/
|
||
60 | int** matrix;
|
||
61 | 726 | gtress | |
62 | 17 | bcoltin | /**
|
63 | * The element representing a robot is true if that robot
|
||
64 | * is in the token ring and false otherwise.
|
||
65 | **/
|
||
66 | 726 | gtress | char* joined;
|
67 | |||
68 | 17 | bcoltin | /**
|
69 | * The number of robots in the token ring.
|
||
70 | **/
|
||
71 | int numJoined;
|
||
72 | 726 | gtress | |
73 | /**
|
||
74 | * The size of the sensor matrix.
|
||
75 | **/
|
||
76 | int size;
|
||
77 | 17 | bcoltin | } SensorMatrix; |
78 | |||
79 | /**@brief Create a sensor matrix **/
|
||
80 | SensorMatrix* sensor_matrix_create(void);
|
||
81 | /**@brief Destroy a sensor matrix **/
|
||
82 | void sensor_matrix_destroy(SensorMatrix* m);
|
||
83 | /**@brief Add a robot to a sensor matrix **/
|
||
84 | 340 | bcoltin | void sensor_matrix_add_robot(SensorMatrix* m, int id); |
85 | 17 | bcoltin | /**@brief Remove a robot from a sensor matrix **/
|
86 | 340 | bcoltin | void sensor_matrix_remove_robot(SensorMatrix* m, int id); |
87 | 17 | bcoltin | /**@brief Set a reading in a sensor matrix **/
|
88 | void sensor_matrix_set_reading(SensorMatrix* m, int observer, int robot, int reading); |
||
89 | /**@brief Get a reading in a sensor matrix **/
|
||
90 | int sensor_matrix_get_reading(SensorMatrix* m, int observer, int robot); |
||
91 | /**@brief Set whether the robot is in the token ring **/
|
||
92 | void sensor_matrix_set_in_ring(SensorMatrix* m, int robot, int in); |
||
93 | /**@brief Get whether the robot is in the sensor ring **/
|
||
94 | int sensor_matrix_get_in_ring(SensorMatrix* m, int robot); |
||
95 | /**@brief Get the size of the sensor matrix **/
|
||
96 | int sensor_matrix_get_size(SensorMatrix* m);
|
||
97 | /**@brief Get the number of robots which have joined the token ring **/
|
||
98 | int sensor_matrix_get_joined(SensorMatrix* m);
|
||
99 | |||
100 | /** @} **/ //end defgroup |
||
101 | |||
102 | 340 | bcoltin | |
103 | #endif |