Revision 1345
Final spline code for master/slave
updated outdated libdragonfly and libwireless
branches/encoders/code/behaviors/spline/slave/slave.c | ||
---|---|---|
18 | 18 |
volatile int left_ref; |
19 | 19 |
volatile int right_ref; |
20 | 20 |
|
21 |
volatile int left_old; |
|
22 |
volatile int right_old; |
|
21 |
volatile int left_err_old;
|
|
22 |
volatile int right_err_old;
|
|
23 | 23 |
|
24 |
volatile int left_vel_old = 0; |
|
25 |
volatile int right_vel_old = 0; |
|
26 |
|
|
24 | 27 |
volatile int left_i = 0; |
25 | 28 |
volatile int right_i = 0; |
26 | 29 |
|
27 | 30 |
volatile int left_u; |
28 | 31 |
volatile int right_u; |
29 | 32 |
|
30 |
volatile int left_vel = 0;
|
|
31 |
volatile int right_vel = 0;
|
|
33 |
volatile int left_vel; |
|
34 |
volatile int right_vel; |
|
32 | 35 |
|
33 | 36 |
#define PL 1 |
34 | 37 |
#define DL 0.1 |
35 | 38 |
#define IL 0.1 |
36 | 39 |
|
40 |
/* |
|
37 | 41 |
#define PR 1.5 |
38 | 42 |
#define DR 0.2 |
39 | 43 |
#define IR 0.1 |
44 |
*/ |
|
45 |
#define PR 1 |
|
46 |
#define DR 0.1 |
|
47 |
#define IR 0.1 |
|
40 | 48 |
|
41 | 49 |
|
42 |
#define INTERVAL 50
|
|
50 |
#define INTERVAL 20
|
|
43 | 51 |
|
44 | 52 |
/* receive motor speed from master: |
45 | 53 |
* left_speed left_dir right_speed right_dir |
... | ... | |
50 | 58 |
if (type != MOTOR) return; |
51 | 59 |
|
52 | 60 |
left_ref = packet[0]; |
61 |
if (left_ref > 127) |
|
62 |
left_ref -= 256; |
|
53 | 63 |
right_ref = packet[1]; |
64 |
if (right_ref > 127) |
|
65 |
right_ref -= 256; |
|
54 | 66 |
|
55 |
sprintf(buf, "received: %d %d\n", left_ref, right_ref); |
|
56 |
usb_puts(buf); |
|
67 |
// sprintf(buf, "received: %d %d\n", left_ref, right_ref);
|
|
68 |
// usb_puts(buf);
|
|
57 | 69 |
//orb_set_color(GREEN); |
58 | 70 |
} |
59 | 71 |
|
... | ... | |
61 | 73 |
int left_err = left_ref - left_vel; |
62 | 74 |
int right_err = right_ref - right_vel; |
63 | 75 |
|
64 |
left_err = left_vel == 2048 ? left_old : left_err; |
|
65 |
right_err = right_vel == 2048 ? right_old : right_err; |
|
76 |
if (!left_ref) |
|
77 |
left_err = 0; |
|
78 |
if (!right_ref) |
|
79 |
right_err = 0; |
|
80 |
|
|
81 |
// left_err = left_vel == 2048 ? left_err_old : left_err; |
|
82 |
// right_err = right_vel == 2048 ? right_err_old : right_err; |
|
66 | 83 |
|
67 | 84 |
left_i += left_err; |
68 |
left_u = (int)(PL*(float)left_err + DL*(float)(left_err - left_old) + IL*(float)left_i); |
|
69 |
left_old = left_err; |
|
85 |
left_u = (int)(PL*(float)left_err + DL*(float)(left_err - left_err_old) + IL*(float)left_i);
|
|
86 |
left_err_old = left_err;
|
|
70 | 87 |
|
71 | 88 |
right_i += right_err; |
72 |
right_u = (int)(PR*(float)right_err + DR*(float)(right_err - right_old) + IR*(float)right_i); |
|
73 |
right_old = right_err; |
|
89 |
right_u = (int)(PR*(float)right_err + DR*(float)(right_err - right_err_old) + IR*(float)right_i);
|
|
90 |
right_err_old = right_err;
|
|
74 | 91 |
|
92 |
// sprintf(buf, "u: %d %d\n", left_u, right_u); |
|
93 |
// usb_puts(buf); |
|
94 |
|
|
75 | 95 |
if (left_u < 0) { |
76 | 96 |
left_dir = 0; |
77 | 97 |
left_u = -left_u; |
... | ... | |
91 | 111 |
|
92 | 112 |
left_u = left_u > 210 ? 210 : left_u; |
93 | 113 |
right_u = right_u > 210 ? 210 : right_u; |
114 |
|
|
115 |
if (!left_ref) |
|
116 |
left_u = 0; |
|
117 |
if (!right_ref) |
|
118 |
right_u = 0; |
|
94 | 119 |
} |
95 | 120 |
|
96 | 121 |
int main (void) { |
... | ... | |
101 | 126 |
//usb_puts("xbee id "); |
102 | 127 |
//usb_putc(wl_get_xbee_id()); |
103 | 128 |
wl_init(); |
104 |
left_ref = 20; |
|
105 |
right_ref = 20; |
|
129 |
|
|
106 | 130 |
wl_register_packet_group(&packetHandler); |
107 | 131 |
//orb_set_color(RED); |
108 | 132 |
//motor1_set(FORWARD,230); |
109 | 133 |
//motor2_set(FORWARD,230); |
110 | 134 |
|
111 | 135 |
while (1) { |
112 |
usb_puts("We Win\n"); |
|
113 |
//left_vel = encoder_get_v(0); |
|
114 |
//right_vel = encoder_get_v(1); |
|
115 |
delay_ms(1000); |
|
116 |
//if (!(count % INTERVAL)) { |
|
117 |
// wl_send_global_packet(GROUP, ENCODER, encoder, 2, 0); |
|
136 |
|
|
137 |
left_vel = encoder_get_v(0); |
|
138 |
right_vel = encoder_get_v(1); |
|
139 |
// err handling |
|
140 |
if (left_vel == 2048) |
|
141 |
left_vel = left_vel_old; |
|
142 |
else |
|
143 |
left_vel_old = left_vel; |
|
144 |
|
|
145 |
if (right_vel == 2048) |
|
146 |
right_vel = right_vel_old; |
|
147 |
else |
|
148 |
right_vel_old = right_vel; |
|
149 |
|
|
150 |
|
|
151 |
if (!(count % INTERVAL)) { |
|
152 |
wl_send_global_packet(GROUP, ENCODER, encoder, 2, 0); |
|
118 | 153 |
encoder[0] = left_vel; |
119 | 154 |
encoder[1] = right_vel; |
120 |
|
|
121 |
// usb_puti(left_vel); |
|
122 |
// sprintf(buf, "sent (%d): %d %d %d %d\n", count, left_vel, right_vel, encoder[0], encoder[1]); |
|
123 |
// usb_puts(buf); |
|
124 |
// usb_puti(encoder[0]); |
|
125 |
// } |
|
126 |
|
|
155 |
//sprintf(buf, "sent (%d): %d %d %d %d\n", count, left_vel, right_vel, encoder[0], encoder[1]); |
|
156 |
//usb_puts(buf); |
|
157 |
} |
|
127 | 158 |
|
128 |
//ctrl();
|
|
159 |
ctrl(); |
|
129 | 160 |
|
130 |
// if (!(count % INTERVAL))
|
|
131 |
// wl_do();
|
|
161 |
if (!(count % INTERVAL))
|
|
162 |
wl_do();
|
|
132 | 163 |
|
133 | 164 |
// sprintf(buf, "motor (%d): %d %d %d %d\n", count, left_dir, left_ref, right_dir, right_ref); |
134 | 165 |
// usb_puts(buf); |
135 | 166 |
|
136 |
//motor1_set(left_dir, left_u);
|
|
137 |
//motor2_set(right_dir, right_u);
|
|
167 |
motor1_set(left_dir, left_u);
|
|
168 |
motor2_set(right_dir, right_u); |
|
138 | 169 |
|
139 | 170 |
count++; |
140 |
delay_ms(1000);
|
|
171 |
// delay_ms(100);
|
|
141 | 172 |
} |
142 | 173 |
} |
174 |
|
branches/encoders/code/behaviors/spline/slave/Makefile | ||
---|---|---|
92 | 92 |
# Optimization level, can be [0, 1, 2, 3, s]. |
93 | 93 |
# 0 = turn off optimization. s = optimize for size. |
94 | 94 |
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
95 |
OPT = s
|
|
95 |
OPT = 0
|
|
96 | 96 |
|
97 | 97 |
# Debugging format. |
98 | 98 |
# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. |
branches/encoders/code/behaviors/spline/master/master.c | ||
---|---|---|
23 | 23 |
PacketGroupHandler packetHandler = {GROUP, 0, 0, &packet_receive, 0}; |
24 | 24 |
|
25 | 25 |
void packet_receive (char type, int source, char* packet, int length) { |
26 |
|
|
27 | 26 |
if(type == ENCODER) |
28 | 27 |
{ |
29 | 28 |
if(id == -1) |
... | ... | |
32 | 31 |
motor1_set(1, 200); |
33 | 32 |
usb_putc(packet[0]); |
34 | 33 |
usb_putc(packet[1]); |
35 |
// usb_putc(packet[2]); |
|
36 |
// usb_putc(packet[3]); |
|
37 | 34 |
} |
38 |
|
|
39 | 35 |
} |
40 | 36 |
|
41 | 37 |
int main (void) { |
... | ... | |
55 | 51 |
lcd_puts("starting init"); |
56 | 52 |
data[0] = usb_getc(); |
57 | 53 |
data[1] = usb_getc(); |
58 |
//data[2] = usb_getc(); |
|
59 |
//data[3] = usb_getc(); |
|
60 |
|
|
54 |
|
|
61 | 55 |
lcd_puts("Done with init\n"); |
62 | 56 |
|
63 | 57 |
wl_send_global_packet(GROUP, MOTOR, data, 2, 0); |
... | ... | |
67 | 61 |
wl_register_packet_group(&packetHandler); |
68 | 62 |
} |
69 | 63 |
|
70 |
// lcd_clear_screen(); |
|
71 |
while (1) { |
|
72 |
if(position == SENDER) |
|
73 |
{ |
|
74 |
data[0] = usb_getc(); |
|
75 |
data[1] = usb_getc(); |
|
76 |
//data[2] = usb_getc(); |
|
77 |
//data[3] = usb_getc(); |
|
78 |
wl_send_global_packet(GROUP, MOTOR, data, 2, 0); |
|
79 |
} |
|
64 |
while (1) { |
|
65 |
if(position == SENDER) |
|
66 |
{ |
|
67 |
data[0] = usb_getc(); |
|
68 |
data[1] = usb_getc(); |
|
69 |
wl_send_global_packet(GROUP, MOTOR, data, 2, 0); |
|
70 |
} |
|
80 | 71 |
|
81 |
wl_do();
|
|
82 |
}
|
|
83 |
|
|
72 |
wl_do();
|
|
73 |
}
|
|
74 |
|
|
84 | 75 |
} |
85 |
|
|
76 |
|
branches/encoders/code/lib/include/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 |
|
branches/encoders/code/lib/include/libwireless/wireless.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 wireless.h |
3 | 28 |
* @brief Contains definitions for the wireless library. |
4 | 29 |
* |
... | ... | |
6 | 31 |
* |
7 | 32 |
* @author Brian Coltin, Colony Project, CMU Robotics Club |
8 | 33 |
**/ |
9 |
|
|
34 |
|
|
35 |
#ifndef WIRELESS_H |
|
36 |
#define WIRELESS_H |
|
37 |
|
|
10 | 38 |
//Note: If this is raised above 16, we will need to do |
11 | 39 |
//something about frame numbers for TX Status packets. |
12 | 40 |
/** |
13 | 41 |
* The maximum number of packet groups. |
14 | 42 |
**/ |
43 |
//TODO: a PacketGroupHandler is at least 10 bytes (I don't know if function pointers are 2 bytes |
|
44 |
// or 4 bytes). That means that in the c file, your array of packet groups is at least 160 bytes. |
|
45 |
// Normally that might be fine (the robot's avr chips have 4k SRAM), but austin's chip only has |
|
46 |
// 1k SRAM, so if this number can be reduced or if the size of the struct could be reduced, that would be a plus. |
|
15 | 47 |
#define WL_MAX_PACKET_GROUPS 16 |
16 | 48 |
|
17 | 49 |
/** |
... | ... | |
20 | 52 |
* |
21 | 53 |
* Contains functions and definitions for dealing with wireless functionality.<br><br> |
22 | 54 |
* |
23 |
* The wireless library provides a modular method for dealing with
|
|
55 |
* The wireless library provides a modular method for dealing with |
|
24 | 56 |
* wireless packets, by allowing packet groups to be registered. |
25 | 57 |
* A packet group is a collection of packets which share a packet |
26 |
* group code. Each packet in the group also has a type. A packet
|
|
58 |
* group code. Each packet in the group also has a type. A packet |
|
27 | 59 |
* group code and type are sent with each packet. When a packet |
28 |
* with a group code registered in the wireless library is
|
|
60 |
* with a group code registered in the wireless library is |
|
29 | 61 |
* received, the corresponding event handler is called. The |
30 | 62 |
* event handler uses the packet type and other information |
31 | 63 |
* stored in the packet to respond.<br><br> |
... | ... | |
39 | 71 |
|
40 | 72 |
/** |
41 | 73 |
* @struct PacketGroupHandler |
42 |
* A PacketGroupHandler represents a packet group, and is used to
|
|
74 |
* A PacketGroupHandler represents a packet group, and is used to |
|
43 | 75 |
* register a packet group with the wireless library. It contains |
44 | 76 |
* handlers for various events which can occur related to a packet |
45 | 77 |
* group. |
46 | 78 |
**/ |
79 |
//TODO: the order of member variables in this struct should be changed in case the compile packs the struct |
|
80 |
// In order to achieve the best packing, the variables should be listed in order of decreasing memory size. |
|
81 |
// Thus, pointers should be first, followed by int, followed by char. |
|
47 | 82 |
typedef struct |
48 | 83 |
{ |
49 | 84 |
/** |
... | ... | |
51 | 86 |
* must be unique. The maximum number of packet groups |
52 | 87 |
* is defined by WL_MAX_PACKET_GROUPS. |
53 | 88 |
**/ |
89 |
//TODO: if this number must be less than or equal to WL_MAX_PACKET_GROUPS, don't you only need |
|
90 |
// one byte for it and it can be made an unsigned char? |
|
54 | 91 |
unsigned int groupCode; |
55 | 92 |
|
56 | 93 |
/** |
... | ... | |
58 | 95 |
* but in wl_do). |
59 | 96 |
**/ |
60 | 97 |
void (*timeout_handler) (void); |
61 |
|
|
98 |
|
|
62 | 99 |
/** |
63 | 100 |
* Called when a transmit status packet is received |
64 | 101 |
* from the XBee where the first four bits of the frame |
... | ... | |
69 | 106 |
* we did not. |
70 | 107 |
**/ |
71 | 108 |
void (*handle_response) (int frame, int received); |
72 |
|
|
109 |
|
|
73 | 110 |
/** |
74 | 111 |
* Called when we receive a packet from this group. |
75 | 112 |
* |
... | ... | |
79 | 116 |
* @param packet the packet received |
80 | 117 |
* @param length the length of the packet |
81 | 118 |
**/ |
82 |
void (*handle_receive) (char type, int source, unsigned char* packet, |
|
83 |
int length); |
|
84 |
|
|
119 |
void (*handle_receive) (char type, int source, unsigned char* packet, int length); |
|
120 |
|
|
85 | 121 |
/** |
86 | 122 |
* Called for any cleanup when the network is turned off. |
87 | 123 |
**/ |
88 | 124 |
void (*unregister) (void); |
89 |
|
|
125 |
|
|
90 | 126 |
} PacketGroupHandler; |
91 | 127 |
|
92 | 128 |
/**@brief Initialize the wireless library **/ |
93 |
void wl_init(void);
|
|
129 |
int wl_init(void);
|
|
94 | 130 |
/**@brief Uninitialize the wireless library **/ |
95 | 131 |
void wl_terminate(void); |
96 | 132 |
/**@brief Perform wireless library functionality **/ |
... | ... | |
101 | 137 |
void wl_unregister_packet_group(PacketGroupHandler* h); |
102 | 138 |
|
103 | 139 |
/**@brief Send a packet to a specific robot in any PAN **/ |
104 |
void wl_send_robot_to_robot_global_packet(char group, char type, |
|
105 |
char* data, int len, int dest, char frame); |
|
140 |
int wl_send_robot_to_robot_global_packet(char group, char type, char* data, int len, int dest, char frame); |
|
106 | 141 |
/**@brief Send a packet to a specific robot in our PAN **/ |
107 |
void wl_send_robot_to_robot_packet(char group, char type, |
|
108 |
char* data, int len, int dest, char frame); |
|
142 |
int wl_send_robot_to_robot_packet(char group, char type, char* data, int len, int dest, char frame); |
|
109 | 143 |
/**@brief Send a packet to all robots **/ |
110 |
void wl_send_global_packet(char group, char type, |
|
111 |
char* data, int len, char frame); |
|
144 |
int wl_send_global_packet(char group, char type, char* data, int len, char frame); |
|
112 | 145 |
/**@brief Send a packet to all robots in our PAN **/ |
113 |
void wl_send_pan_packet(char group, char type, |
|
114 |
char* data, int len, char frame); |
|
146 |
void wl_send_pan_packet(char group, char type, char* data, int len, char frame); |
|
115 | 147 |
|
116 | 148 |
/**@brief Set the PAN we are using **/ |
117 |
void wl_set_pan(int pan);
|
|
149 |
int wl_set_pan(int pan);
|
|
118 | 150 |
/**@brief Get the PAN we are using **/ |
119 | 151 |
int wl_get_pan(void); |
120 | 152 |
/**@brief Set the channel we are using **/ |
121 |
void wl_set_channel(int channel);
|
|
153 |
int wl_set_channel(int channel);
|
|
122 | 154 |
/**@brief Get the channel we are using **/ |
123 | 155 |
int wl_get_channel(void); |
124 | 156 |
/**@brief Get the 16-bit address of the XBee module **/ |
125 |
unsigned int wl_get_xbee_id(void); |
|
157 |
int wl_get_xbee_id(void); |
|
158 |
/**@brief Set the com port on a computer, undefined on the robot.**/ |
|
159 |
void wl_set_com_port(char* port); |
|
126 | 160 |
|
127 | 161 |
/** @} **/ // end defgroup |
128 | 162 |
|
163 |
#endif |
|
164 |
|
branches/encoders/code/lib/include/libwireless/wl_token_ring.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 wl_token_ring.h |
3 | 28 |
* @brief Declarations for the token ring packet group |
4 | 29 |
* |
... | ... | |
7 | 32 |
* @author Brian Coltin, Colony Project, CMU Robotics Club |
8 | 33 |
**/ |
9 | 34 |
|
35 |
#ifndef WL_TOKEN_RING_H |
|
36 |
#define WL_TOKEN_RING_H |
|
37 |
|
|
10 | 38 |
/** |
11 | 39 |
* @defgroup tokenring Token Ring |
12 | 40 |
* @brief Wireless library token ring implementation |
... | ... | |
19 | 47 |
**/ |
20 | 48 |
|
21 | 49 |
/**@brief Register the token ring group with the wireless library.**/ |
22 |
void wl_token_ring_register(void);
|
|
50 |
int wl_token_ring_register(void);
|
|
23 | 51 |
/**@brief Unregister the token ring group with the wirelss library.**/ |
24 | 52 |
void wl_token_ring_unregister(void); |
25 | 53 |
/**@brief Set the functions called to turn the bom on and off.**/ |
26 |
void wl_token_ring_set_bom_functions(void (*on_function) (void), |
|
27 |
void (*off_function) (void), int (*max_bom_function) (void));
|
|
54 |
void wl_token_ring_set_bom_functions(void (*on_function) (void), void (*off_function) (void),
|
|
55 |
int (*max_bom_function) (void));
|
|
28 | 56 |
|
29 | 57 |
/**@brief Join the token ring **/ |
30 |
void wl_token_ring_join(void);
|
|
58 |
int wl_token_ring_join(void);
|
|
31 | 59 |
/**@brief Leave the token ring **/ |
32 | 60 |
void wl_token_ring_leave(void); |
33 |
/**@brief Request a BOM flash from the specified robot **/ |
|
34 |
void wl_token_request(int robot); |
|
35 | 61 |
|
36 | 62 |
/**@brief Return the number of robots in the token ring **/ |
37 | 63 |
int wl_token_get_robots_in_ring(void); |
... | ... | |
56 | 82 |
|
57 | 83 |
/** @} **/ //end token ring group |
58 | 84 |
|
85 |
#endif |
branches/encoders/code/lib/include/libwireless/wl_defs.h | ||
---|---|---|
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 |
/** |
|
27 |
* @file wl_defs.h |
|
28 |
* @brief Definitions for Wireless |
|
29 |
* |
|
30 |
* Contains definitions for wireless packet groups, packet types, |
|
31 |
* debugging information, etc. |
|
32 |
* |
|
33 |
* @author Brian Coltin, Colony Project, CMU Robotics Club |
|
34 |
**/ |
|
35 |
|
|
36 |
#ifndef WL_DEFS_H |
|
37 |
#define WL_DEFS_H |
|
38 |
|
|
1 | 39 |
//comment out this line if using a computer hooked up to an xbee |
2 | 40 |
//#define ROBOT |
3 | 41 |
|
4 | 42 |
//uncomment this line for debug information |
5 |
#define WL_DEBUG |
|
43 |
//#define WL_DEBUG
|
|
6 | 44 |
|
7 | 45 |
// Packet Groups and Types |
8 | 46 |
|
... | ... | |
15 | 53 |
#define WL_TOKEN_RING_GROUP 2 |
16 | 54 |
|
17 | 55 |
#define WL_TOKEN_PASS 1 |
18 |
#define WL_TOKEN_BOM_ON 2 |
|
19 |
#define WL_TOKEN_INTERRUPT_REQUEST 3 |
|
20 |
#define WL_TOKEN_INTERRUPT_PASS 4 |
|
21 |
#define WL_TOKEN_JOIN 5 |
|
22 |
#define WL_TOKEN_JOIN_ACCEPT 6 |
|
56 |
#define WL_TOKEN_SENSOR_MATRIX 2 |
|
57 |
#define WL_TOKEN_BOM_ON 3 |
|
58 |
#define WL_TOKEN_JOIN 4 |
|
59 |
#define WL_TOKEN_JOIN_ACCEPT 5 |
|
23 | 60 |
|
24 | 61 |
// timing constants |
62 |
#ifndef FIREFLY |
|
25 | 63 |
#define BOM_DELAY 100 |
26 |
#define DEATH_DELAY 3 |
|
64 |
#else |
|
65 |
#define BOM_DELAY 200 |
|
66 |
#endif |
|
67 |
|
|
68 |
#define DEATH_DELAY 4 |
|
27 | 69 |
#define JOIN_DELAY 8 |
28 | 70 |
|
29 |
// Recharging group |
|
30 |
#define WL_RECHARGE_GROUP 3 |
|
31 |
|
|
32 |
#define WL_RECHARGE_POLL_STATIONS 1 |
|
33 |
#define WL_RECHARGE_STATION_AVAILABLE 2 |
|
34 |
#define WL_RECHARGE_REQUEST 3 |
|
35 |
#define WL_RECHARGE_REQUEST_ACCEPT 4 |
|
36 |
#define WL_RECHARGE_VERIFY 5 |
|
37 |
#define WL_RECHARGE_CANCEL 6 |
|
38 |
#define WL_RECHARGE_SEEKING 7 |
|
39 |
#define WL_RECHARGE_DOCKED 8 |
|
40 |
|
|
41 | 71 |
#ifdef WL_DEBUG |
42 | 72 |
|
43 | 73 |
#ifdef ROBOT |
... | ... | |
63 | 93 |
|
64 | 94 |
#endif |
65 | 95 |
|
96 |
#endif |
|
97 |
|
branches/encoders/code/lib/include/libwireless/xbee.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 xbee.h |
3 | 28 |
* @brief Contains definitions for using the XBee |
4 | 29 |
* |
... | ... | |
10 | 35 |
* @author Brian Coltin, Colony Project, CMU Robotics Club |
11 | 36 |
**/ |
12 | 37 |
|
38 |
#ifndef XBEE_H |
|
39 |
#define XBEE_H |
|
40 |
|
|
13 | 41 |
/** |
42 |
* The port to use the XBee from on the computer. |
|
43 |
* Also, a backup port if the other is used. |
|
44 |
**/ |
|
45 |
#ifndef ROBOT |
|
46 |
#define XBEE_PORT_DEFAULT "/dev/ttyUSB1" |
|
47 |
#endif |
|
48 |
|
|
49 |
/** |
|
14 | 50 |
* @defgroup xbee XBee |
15 | 51 |
* @brief Interface with the XBee module |
16 | 52 |
* |
... | ... | |
38 | 74 |
#define XBEE_RX 0x81 |
39 | 75 |
|
40 | 76 |
/**@brief Initialize the XBee library **/ |
41 |
void xbee_lib_init(void);
|
|
77 |
int xbee_lib_init(void);
|
|
42 | 78 |
/**@brief Uninitialize the XBee library **/ |
43 | 79 |
void xbee_terminate(void); |
44 | 80 |
/**@brief Get a packet from the XBee **/ |
45 | 81 |
int xbee_get_packet(unsigned char* packet); |
46 | 82 |
/**@brief Send a packet to the XBee **/ |
47 |
void xbee_send_packet(char* packet, int len, int dest, |
|
48 |
char options, char frame); |
|
83 |
int xbee_send_packet(char* packet, int len, int dest, char options, char frame); |
|
49 | 84 |
/**@brief Set the PAN ID for the XBee **/ |
50 |
void xbee_set_pan_id(int id);
|
|
85 |
int xbee_set_pan_id(int id);
|
|
51 | 86 |
/**@brief Get the XBee's PAN ID **/ |
52 | 87 |
unsigned int xbee_get_pan_id(void); |
53 | 88 |
/**@brief Set the channel the XBee is currently using **/ |
54 |
void xbee_set_channel(int channel);
|
|
89 |
int xbee_set_channel(int channel);
|
|
55 | 90 |
/**@brief Get the channel the XBee is currently using **/ |
56 | 91 |
int xbee_get_channel(void); |
57 | 92 |
/**@brief Get the XBee's 16-bit address **/ |
58 | 93 |
unsigned int xbee_get_address(void); |
94 |
/**@brief Set the com port on a computer, undefined on the robot**/ |
|
95 |
void xbee_set_com_port(char* port); |
|
59 | 96 |
|
60 | 97 |
/**@}**/ //end defgroup |
61 | 98 |
|
99 |
#endif |
branches/encoders/code/lib/include/libwireless/wl_error_group.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 wl_error_group.h |
28 |
* @brief Error Packets |
|
29 |
* |
|
30 |
* A packet group for sending error packets. |
|
31 |
* |
|
32 |
* @author Brian Coltin, Colony Project, CMU Robotics Club |
|
33 |
**/ |
|
34 |
|
|
35 |
#ifndef WL_ERROR_GROUP_H |
|
36 |
#define WL_ERROR_GROUP_H |
|
37 |
|
|
38 |
/** |
|
39 |
* @file wl_error_group.h |
|
3 | 40 |
* @brief A packet group for error messages. |
4 | 41 |
* |
5 | 42 |
* A packet group for sending and receiving error |
... | ... | |
26 | 63 |
|
27 | 64 |
/** @} **/ // end defgroup |
28 | 65 |
|
66 |
#endif |
branches/encoders/code/lib/include/libdragonfly/lights.h | ||
---|---|---|
1 |
// FIXME remove |
|
2 |
typedef unsigned char uint8_t; |
|
3 |
|
|
4 |
|
|
1 | 5 |
/** |
6 |
* Copyright (c) 2007 Colony Project |
|
7 |
* |
|
8 |
* Permission is hereby granted, free of charge, to any person |
|
9 |
* obtaining a copy of this software and associated documentation |
|
10 |
* files (the "Software"), to deal in the Software without |
|
11 |
* restriction, including without limitation the rights to use, |
|
12 |
* copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
13 |
* copies of the Software, and to permit persons to whom the |
|
14 |
* Software is furnished to do so, subject to the following |
|
15 |
* conditions: |
|
16 |
* |
|
17 |
* The above copyright notice and this permission notice shall be |
|
18 |
* included in all copies or substantial portions of the Software. |
|
19 |
* |
|
20 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
21 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
22 |
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
23 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
24 |
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
25 |
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
26 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
27 |
* OTHER DEALINGS IN THE SOFTWARE. |
|
28 |
**/ |
|
29 |
|
|
30 |
|
|
31 |
/** |
|
2 | 32 |
* @file lights.h |
3 | 33 |
* @brief Contains declarations for managing the orbs. |
4 | 34 |
* |
... | ... | |
11 | 41 |
#ifndef _LIGHTS_H_ |
12 | 42 |
#define _LIGHTS_H_ |
13 | 43 |
|
44 |
/** |
|
45 |
* @addtogroup orbs |
|
46 |
* @{ |
|
47 |
**/ |
|
14 | 48 |
|
15 | 49 |
/** |
50 |
* Quick start: call orb_init_pwm or orb_init_binary, depending on which mode you want to use. Call orb*set or |
|
51 |
* orb*set_color to set the orbs. |
|
52 |
* |
|
53 |
* The orbs have two modes of operation: PWM mode and binary mode. In PWM mode, a pwm signal is generated by a hardware |
|
54 |
* timer and the orbs can be set to a value of 0 through 255. In binary mode, the orbs can only be turned on or off and |
|
55 |
* a value of 0 means "off" and any other value means "on". The mode can be chosen on initialization and can be changed |
|
56 |
* at runtime using the orb_set_mode function. |
|
57 |
* |
|
58 |
* Operation (PWM mode): On timer overflow, all LEDs with a value>0 are turned on and the output compare value for the |
|
59 |
* first LED is loaded. On compare match, the corresponding LED is turned off and the next output compare value is |
|
60 |
* loaded. All masks are precomputed and sorted by time when setting the values. |
|
61 |
* |
|
62 |
* The data structure (pwm_t) containing the PWM times and masks is triple buffered. This is because the buffer the ISR |
|
63 |
* is reading from may only be modified on timer overflow before the next PWM sequence is started, because otherwise the |
|
64 |
* next OCR value might be sed to a value smaller than the current timer value, resulting in the remaining channels not |
|
65 |
* being turned off in that PWM period (flash to on). When using two buffers, the page flip can only occur on a timer |
|
66 |
* overflow for the same reason. So after writing a buffer and marking it for page flip, neither of the buffers could be |
|
67 |
* modified because the front buffer is read by the ISR and the back buffer could be switched at any time. So the |
|
68 |
* calling thread would have to be delayed by up to one full PWM period (8ms in the current implementation, but |
|
69 |
* 20ms-50ms would be a reasonable value to expect here). To avoid this, triple buffering is used. |
|
70 |
* |
|
71 |
* The code for applying the orbs is fairly optimized. See the apply_orbs function for some time measurements and |
|
72 |
* further nodes. |
|
73 |
* |
|
74 |
* The PWM frequency is 120Hz (8ms period time). The next lower frequency (determined by the prescaler) is 30 Hz which |
|
75 |
* is too slow (orbs flicker). |
|
76 |
* |
|
77 |
* The orbs code is thread safe, which means that the functions may be called from another interrupt handler. If there |
|
78 |
* are multiple concurrent calls to the orb*set* functions, one of them is ignored and the orbs are never left in an |
|
79 |
* inconsistent state. For example, if the orbs are set to green by the main thread and to red by an interrupt handler, |
|
80 |
* the resulting color will be either red or green, but never yellow. |
|
81 |
* Thread safety is achieved by grabbing a lock at the beginning of all functions that modify the orb code and releasing |
|
82 |
* the lock at the end. If the lock is already taken, the function just returns doing nothing. |
|
83 |
* |
|
84 |
* Some performance measurements: |
|
85 |
* - Time for setting new orb values (PWM mode): 35us-72us (depending on the degree to which the array is |
|
86 |
* already in the correct order) |
|
87 |
* - Time for setting new orb values (binary mode): 5.5us |
|
88 |
* |
|
89 |
* - Interrupt time (PWM mode only): 8us (overflow) |
|
90 |
* 10us (output compare) |
|
91 |
* 6us (last output compare) |
|
92 |
* 30us (output compare, all value equal) |
|
93 |
* |
|
94 |
* - Maximum total interrupt time per period: 64us |
|
95 |
* - Maximum CPU usage for interrupts (PWM mode only): <0.8% |
|
96 |
* |
|
97 |
* - Maximum contiguous synchronized block: 30us (output compare interrupt, all values equal) |
|
98 |
* |
|
99 |
* There are some potential optimizations left. See the source code for more information. |
|
100 |
* |
|
101 |
* A note on robustness: if the output compare interrupt is disabled for too long, either due to a long ISR or a long |
|
102 |
* synchronized code block, the orbs will flicker to brighter values for being turned off too late. With software PWM, |
|
103 |
* there's nothing at all to be done about that. The problem can be alleviated by using a lower PWM frequency, but then |
|
104 |
* the orbs will start flickering all the time due to the low update frequency. |
|
105 |
* Some measurements: with 100us synchronized blocks, the flickering is accepptably low. Longer synchronized blocks |
|
106 |
* mean more flickering. At 1ms synchronized blocks, the flickering is quite bad, especially for low orb values. Note |
|
107 |
* that orb value 0 never flickers at all because the corresponding channels are not turned on at all. |
|
108 |
* Test code (note the _delay_us restrictions!) |
|
109 |
* orb_set (1,1,1); while (1) { SYNC { for (uint8_t m=0; m<10; ++m) { _delay_us(10); } } } |
|
110 |
**/ |
|
111 |
|
|
112 |
/** @} **/ //end addtogroup |
|
113 |
|
|
114 |
/** |
|
16 | 115 |
* @addtogroup orbs |
17 | 116 |
* @{ |
18 | 117 |
**/ |
19 | 118 |
|
20 |
//ORB Colors
|
|
119 |
// ***** Predefined colors *****
|
|
21 | 120 |
/** @brief Red **/ |
22 | 121 |
#define RED 0xE0 |
23 | 122 |
/** @brief Orange **/ |
... | ... | |
40 | 139 |
#define MAGENTA 0xE3 |
41 | 140 |
/** @brief White **/ |
42 | 141 |
#define WHITE 0xFE |
43 |
/** @brief Turn the orb off (White) **/
|
|
44 |
#define ORB_OFF 0xFE //ORB_OFF->WHITE
|
|
142 |
/** @brief Turn the orb off **/ |
|
143 |
#define ORB_OFF 0x00
|
|
45 | 144 |
|
46 |
/** @brief Enables the orbs **/ |
|
145 |
|
|
146 |
|
|
147 |
// ***** Initialization ***** |
|
148 |
|
|
149 |
/** @brief Enables the orbs in default mode **/ |
|
47 | 150 |
void orb_init(void); |
151 |
|
|
152 |
/** @brief Enables the orbs in binary mode **/ |
|
153 |
void orb_init_binary (void); |
|
154 |
|
|
155 |
/** @brief Enables the orbs in PWM mode **/ |
|
156 |
void orb_init_pwm (void); |
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
// ***** Mode setting ***** |
|
161 |
|
|
162 |
/** Specification of the orb mode **/ |
|
163 |
typedef uint8_t orb_mode_t; |
|
164 |
|
|
165 |
/** @brief PWM mode **/ |
|
166 |
#define orb_mode_pwm 0 |
|
167 |
|
|
168 |
/** @brief Binary mode **/ |
|
169 |
#define orb_mode_binary 1 |
|
170 |
|
|
171 |
|
|
172 |
/** @brief Switches the orbs to the specified mode **/ |
|
173 |
void orb_set_mode (orb_mode_t mode); |
|
174 |
|
|
175 |
/** @brief Disables the orb timer, but does not change the mode **/ |
|
176 |
void orb_disable_timer (void); |
|
177 |
|
|
178 |
/** @brief Enables the orb timer, but does not change the mode **/ |
|
179 |
void orb_enable_timer (void); |
|
180 |
|
|
181 |
|
|
182 |
|
|
183 |
// ***** Setting RGB colors ***** |
|
184 |
|
|
185 |
/** @brief set the specified orb to a specified color **/ |
|
186 |
void orb_n_set (uint8_t num, uint8_t red, uint8_t green, uint8_t blue); |
|
187 |
|
|
48 | 188 |
/** @brief Set both orbs to a specified color **/ |
49 |
void orb_set(unsigned char red_led, unsigned char green_led,
|
|
50 |
unsigned char blue_led); |
|
189 |
void orb_set(uint8_t red, uint8_t green, uint8_t blue);
|
|
190 |
|
|
51 | 191 |
/** @brief Set orb1 to a specified color **/ |
52 |
void orb1_set(unsigned char red_led, unsigned char green_led,
|
|
53 |
unsigned char blue_led); |
|
192 |
void orb1_set(uint8_t red_led, uint8_t green_led, uint8_t blue_led);
|
|
193 |
|
|
54 | 194 |
/** @brief Set orb2 to a specified color **/ |
55 |
void orb2_set(unsigned char red_led, unsigned char green_led, |
|
56 |
unsigned char blue_led); |
|
195 |
void orb2_set(uint8_t red_led, uint8_t green_led, uint8_t blue_led); |
|
57 | 196 |
|
58 |
/** @brief Set both orbs to a specified color **/ |
|
59 |
void orb_set_color(int col); |
|
197 |
void orbs_set (uint8_t red1, uint8_t green1, uint8_t blue1, uint8_t red2, uint8_t green2, uint8_t blue2); |
|
198 |
|
|
199 |
|
|
200 |
|
|
201 |
// ***** Settings predefined colors ***** |
|
202 |
|
|
203 |
/** @brief set the specified orb to the specified color **/ |
|
204 |
void orb_n_set_color(uint8_t num, uint8_t col); |
|
205 |
|
|
60 | 206 |
/** @brief Set orb1 to a specified color **/ |
61 |
void orb1_set_color(int col); |
|
207 |
void orb1_set_color(uint8_t col); |
|
208 |
|
|
62 | 209 |
/** @brief Set orb2 to a specified color **/ |
63 |
void orb2_set_color(int col);
|
|
210 |
void orb2_set_color(uint8_t col);
|
|
64 | 211 |
|
65 |
/** @brief Disable the orbs **/ |
|
66 |
void orb_disable(void); |
|
67 |
/** @brief Enable the orbs **/ |
|
68 |
void orb_enable(void); |
|
212 |
/** @brief set the orbs to specified colors **/ |
|
213 |
void orbs_set_color(uint8_t col1, uint8_t col2); |
|
69 | 214 |
|
215 |
/** @brief Set both orbs to a specified color **/ |
|
216 |
void orb_set_color(uint8_t col); |
|
217 |
|
|
218 |
|
|
219 |
|
|
70 | 220 |
/** @} **/ //end addtogroup |
71 | 221 |
|
72 | 222 |
#endif |
73 |
|
branches/encoders/code/lib/include/libdragonfly/spi.h | ||
---|---|---|
4 | 4 |
* @author Colony Project, CMU Robotics Club |
5 | 5 |
**/ |
6 | 6 |
|
7 |
/** |
|
8 |
* @addtogroup spi |
|
9 |
* @{ |
|
10 |
**/ |
|
11 |
|
|
7 | 12 |
#ifndef __SPI_H__ |
8 | 13 |
#define __SPI_H__ |
9 | 14 |
|
... | ... | |
21 | 26 |
typedef void (*spi_fun_recv_t)(char); |
22 | 27 |
typedef void (*spi_fun_recv_complete_t)(void); |
23 | 28 |
|
29 |
/** |
|
30 |
* @brief Initialize SPI |
|
31 |
* |
|
32 |
* @param spi_fun_recv_t The function that handles SPI data, byte for byte. |
|
33 |
* @param spi_fun_recv_complete_t Called on a completed transmission - typically for cleaning up. |
|
34 |
*/ |
|
24 | 35 |
void spi_init (spi_fun_recv_t, spi_fun_recv_complete_t); |
36 |
|
|
37 |
/** |
|
38 |
* @brief Initialize SPI transfer. |
|
39 |
* |
|
40 |
* @param char The number of bytes to transfer. |
|
41 |
*/ |
|
25 | 42 |
void spi_transfer (char); |
26 | 43 |
|
44 |
/**@}**/ //end group |
|
45 |
|
|
27 | 46 |
#endif |
branches/encoders/code/lib/include/libdragonfly/time.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 |
|
|
27 |
/** |
|
2 | 28 |
* @file time.h |
3 | 29 |
* @brief Contains time-related functions and definitions |
4 | 30 |
* |
... | ... | |
11 | 37 |
#ifndef _TIME_H_ |
12 | 38 |
#define _TIME_H_ |
13 | 39 |
|
14 |
/*Maximum # of functions*/ |
|
15 |
#define MAX_FUNCTIONS 10 |
|
16 |
|
|
17 |
|
|
18 | 40 |
/* Predefined times for prescale_opt in time.c. |
19 | 41 |
To make you own, know that a pulse is 1/16th of a second. You cannot get less than this. To get more, you need |
20 | 42 |
to know how many 16ths of a second are in the time you want. (Time_desired * 16 = prescaler_opt) |
... | ... | |
41 | 63 |
/** @brief Delay execution for the specified time **/ |
42 | 64 |
void delay_ms(int ms) ; |
43 | 65 |
/** @brief Enable the realtime clock **/ |
44 |
int rtc_multi_init(int* prescale_opt, void (*rtc_fun[])(void), int argc);
|
|
66 |
void rtc_init(int prescale_opt, void (*rtc_func)(void));
|
|
45 | 67 |
/** @brief Reset the counter of the realtime clock **/ |
46 | 68 |
void rtc_reset(void); |
47 | 69 |
/** @brief Get the value of the realtime clock. **/ |
48 | 70 |
int rtc_get(void); |
49 | 71 |
|
50 |
int rtc_add_function(void (*rtc_f) (void), int prescale_opt); |
|
51 |
|
|
52 |
int rtc_remove_function(void (*rtc_func)(void)); |
|
53 |
int rtc_get_function_count(void); |
|
54 |
|
|
55 |
int rtc_init(int prescale_opt, void (*rtc_func)(void)); |
|
56 |
|
|
57 | 72 |
/** @} **/ |
58 | 73 |
|
59 | 74 |
#endif |
branches/encoders/code/lib/include/libdragonfly/motor.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 |
|
|
27 |
/** |
|
2 | 28 |
* @file motor.h |
3 | 29 |
* @brief Contains definitions for controlling the motors |
4 | 30 |
* |
branches/encoders/code/lib/include/libdragonfly/analog.h | ||
---|---|---|
1 | 1 |
/** |
2 |
* Copyright (c) 2007 Colony Project |
|
2 | 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 |
/** |
|
27 |
* |
|
3 | 28 |
* @file analog.h |
4 | 29 |
* @brief Contains functions and definitions for using the ADC |
5 | 30 |
* |
... | ... | |
12 | 37 |
|
13 | 38 |
* @author Colony Project, CMU Robotics Club, based on firefly |
14 | 39 |
* code by Tom Lauwers |
15 |
*/ |
|
40 |
*/
|
|
16 | 41 |
|
17 | 42 |
#ifndef _ANALOG_H |
18 | 43 |
#define _ANALOG_H |
19 | 44 |
|
45 |
#include <inttypes.h> |
|
46 |
|
|
20 | 47 |
/** |
21 | 48 |
* @addtogroup analog |
22 | 49 |
* @{ |
... | ... | |
43 | 70 |
/** @brief Analog port 9 **/ |
44 | 71 |
#define AN9 0x09 |
45 | 72 |
/** @brief Analog port 10 **/ |
46 |
#define AN10 0x0a
|
|
73 |
#define AN10 0x0A
|
|
47 | 74 |
/** @brief Analog port 11 **/ |
48 |
#define AN11 0x0b
|
|
75 |
#define AN11 0x0B
|
|
49 | 76 |
/** @brief Analog port 12 **/ |
50 |
#define AN12 0x0c
|
|
77 |
#define AN12 0x0C
|
|
51 | 78 |
/** @brief Analog port 13 **/ |
52 |
#define AN13 0x0d
|
|
79 |
#define AN13 0x0D
|
|
53 | 80 |
/** @brief Analog port 14 **/ |
54 |
#define AN14 0x0e
|
|
81 |
#define AN14 0x0E
|
|
55 | 82 |
/** @brief Analog port 15 **/ |
56 |
#define AN15 0x0f
|
|
83 |
#define AN15 0x0F
|
|
57 | 84 |
|
85 |
/** @brief BOM_PORT analog port for BOM **/ |
|
86 |
#define BOM_PORT AN0 |
|
58 | 87 |
/** @brief EXT_MUX analog port **/ |
59 | 88 |
#define EXT_MUX AN7 |
60 | 89 |
/** @brief Analog port for the wheel **/ |
... | ... | |
62 | 91 |
/** @brief Analog port for the battery voltage detector **/ |
63 | 92 |
#define BATT_PORT AN11 |
64 | 93 |
|
65 |
/** @brief Initialize analog ports. **/ |
|
66 |
void analog_init(void); |
|
67 |
/** @brief Read an 8-bit number from an analog port. **/ |
|
94 |
#define ADC_START 1 |
|
95 |
#define ADC_STOP 0 |
|
96 |
|
|
97 |
#define ADMUX_OPT 0x60 |
|
98 |
|
|
99 |
/** @brief Struct to hold the value of a particular analog port **/ |
|
100 |
typedef struct { |
|
101 |
uint8_t adc8; |
|
102 |
uint16_t adc10; |
|
103 |
} adc_t; |
|
104 |
|
|
105 |
|
|
106 |
/** @brief Initialize analog ports. Will start running a loop |
|
107 |
if start_conversion is ADC_START.**/ |
|
108 |
void analog_init(int start_conversion); |
|
109 |
/** @brief starts the analog loop. Doesn't do anything if the loop is already running. **/ |
|
110 |
void analog_start_loop(void); |
|
111 |
/** @brief Stops the analog loop. Doesn't do anything if the loop is already stopped. **/ |
|
112 |
void analog_stop_loop(void); |
|
113 |
/** @brief Returns an 8-bit analog value from the look up table. Use this instead of analog_get8. **/ |
|
68 | 114 |
unsigned int analog8(int which); |
69 |
/** @brief Read a 10-bit number from an analog port. **/
|
|
115 |
/** @brief Returns an 10-bit analog value from the look up table. Use this instead of analog_get10. **/
|
|
70 | 116 |
unsigned int analog10(int which); |
71 | 117 |
/** @brief Read the position of the wheel. **/ |
72 | 118 |
int wheel(void); |
119 |
/** @brief Read an 8-bit number from an analog port. Loop must be stopped for this to work. **/ |
|
120 |
unsigned int analog_get8(int which); |
|
121 |
/** @brief Read a 10-bit number from an analog port. Loop must be stopped for this to work. **/ |
|
122 |
unsigned int analog_get10(int which); |
|
73 | 123 |
|
124 |
|
|
74 | 125 |
/**@}**/ //end group |
75 | 126 |
|
76 | 127 |
#endif |
128 |
|
branches/encoders/code/lib/include/libdragonfly/odometry.h | ||
---|---|---|
1 |
|
|
2 |
/** |
|
3 |
* @file odometry.h |
|
4 |
* @brief Code for estimating the robots pose. |
|
5 |
* |
|
6 |
* Offers simple position and orientation information. |
|
7 |
* |
|
8 |
* @author Colony Project, CMU Robotics Club |
|
9 |
**/ |
|
10 |
|
|
11 |
#ifndef __ODOMETRY_C__ |
|
12 |
#define __ODOMETRY_C__ |
|
13 |
|
|
14 |
/** |
|
15 |
* @addtogroup odometry |
|
16 |
* @{ |
|
17 |
**/ |
|
18 |
|
|
19 |
//Odometry resolution, *64 microseconds. |
|
20 |
#define ODOMETRY_CLK 255u |
|
21 |
#define TIME_SCALE 64 |
|
22 |
|
|
23 |
//Wheel = 2.613 in. |
|
24 |
//Circumference = 208.508133 mm |
|
25 |
//Distance per encoder click (circumference / 1024) = 203.621224 um. |
|
26 |
//Robot width = 5.3745 in. = 136.5123 mm |
|
27 |
|
|
28 |
#define ROBOT_WIDTH_UM 137000 //um |
|
29 |
#define CLICK_DISTANCE_UM 204 //um |
|
30 |
|
|
31 |
#define DISTANCE_SCALE 2.10526316 //Magic constant. |
|
32 |
#define ANGLE_SCALE 1.12823207 //Magic constant. |
|
33 |
|
|
34 |
/** @brief Retrieve the robots estimated x position*/ |
|
35 |
long odometry_dx(void); |
|
36 |
|
|
37 |
/** @brief Retrieve the robots estimated y position*/ |
|
38 |
long odometry_dy(void); |
|
39 |
|
|
40 |
/** @brief Retrieve the robots estimated orientation*/ |
|
41 |
double odometry_angle(void); |
|
42 |
|
|
43 |
/** @brief Initialize odometry. MUST be called before |
|
44 |
* the other functions work.**/ |
|
45 |
void odometry_init(void); |
|
46 |
|
|
47 |
/** @brief Reset position and orientation to the origin facing |
|
48 |
* the x axis.*/ |
|
49 |
void odometry_reset(void); |
|
50 |
|
|
51 |
/** @brief Report estimated velocity [mm/s].*/ |
|
52 |
long odometry_velocity(void); |
|
53 |
|
|
54 |
/**@}**/ //end group |
|
55 |
|
|
56 |
#endif |
branches/encoders/code/lib/include/libdragonfly/encoders.h | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
* @file encoders.h |
|
4 |
* @brief Contains functions for reading encoder values. |
|
5 |
* |
|
6 |
* Contains high and low level functions for reading encoders |
|
7 |
* including reading out total distance covered, and |
|
8 |
* eventually velocity. |
|
9 |
* |
|
10 |
* @author Colony Project, CMU Robotics Club |
|
11 |
*/ |
|
12 |
|
|
13 |
/** |
|
14 |
* @addtogroup encoders |
|
15 |
* @{ |
|
16 |
**/ |
|
17 |
|
|
18 |
#ifndef __ENCODERS_H__ |
|
19 |
#define __ENCODERS_H__ |
|
20 |
|
|
21 |
|
|
22 |
#ifndef LEFT |
|
23 |
#define LEFT 0 |
|
24 |
#endif |
|
25 |
#ifndef RIGHT |
|
26 |
#define RIGHT 1 |
|
27 |
#endif |
|
28 |
|
|
29 |
/** @brief Magnet misaligned - likely distance from encoder problem. **/ |
|
30 |
#define ENCODER_MAGNET_FAILURE 1025 |
|
31 |
/** @brief Encoder misaligned - likely on XY plane. **/ |
|
32 |
#define ENCODER_MISALIGNED 1027 |
|
33 |
/** @brief Not enough time has passed - encoders not initialized in hardware. **/ |
|
34 |
#define ENCODER_DATA_NOT_READY 1026 |
|
35 |
|
|
36 |
//delay_ms argument after a full read is complete |
|
37 |
#define ENCODER_DELAY 20 |
|
38 |
|
|
39 |
//Data invalid flags (hardware failure): |
|
40 |
#define OCF _BV(4) |
|
41 |
#define COF _BV(3) |
|
42 |
|
|
43 |
//Data invalid alarm (May be invalid): |
|
44 |
#define LIN _BV(2) |
|
45 |
|
|
46 |
#define MagINCn _BV(1) |
|
47 |
#define MagDECn _BV(0) |
|
48 |
|
|
49 |
////////////////////////////// |
|
50 |
//#define BUFFER_SIZE 23 |
|
51 |
#define BUFFER_SIZE 46 |
|
52 |
#define ERR_VEL 1024 |
|
53 |
////////////////////////////// |
|
54 |
|
|
55 |
|
|
56 |
/** @brief Initialize encoders. **/ |
|
57 |
void encoders_init(void); |
|
58 |
/** @brief Read instantaneous encoder value. **/ |
|
59 |
int encoder_read(char encoder); |
|
60 |
/** @brief Currently a stub - DO NOT Use. **/ |
|
61 |
char encoder_direction(char encoder); |
|
62 |
|
|
63 |
/** @brief Get total distance traveled. **/ |
|
64 |
int encoder_get_dx(char encoder); |
|
65 |
/** @brief Reset distance counter. **/ |
|
66 |
void encoder_rst_dx(char encoder); |
|
67 |
/** @brief Get time count: The number of encoder reads that have occurred. **/ |
|
68 |
int encoder_get_tc(void); |
|
69 |
/** @brief Reset the time count. **/ |
|
70 |
void encoder_rst_tc(void); |
|
71 |
|
|
72 |
/** @brief Still untested, so use at your own risk. **/ |
|
73 |
int encoder_get_v(char encoder); |
|
74 |
|
|
75 |
/** @brief Waits for the next encoder reading, then returns. **/ |
|
76 |
void encoder_wait( int nReadings ); |
|
77 |
|
|
78 |
/**@}**/ //end group |
|
79 |
|
|
80 |
#endif |
Also available in: Unified diff