Project

General

Profile

Statistics
| Revision:

root / branches / wireless / docs / libdragonfly / html / group__bom.html @ 1578

History | View | Annotate | Download (19.3 KB)

1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
3
<title>Colony: BOM (Bearing and Orientation Module)</title>
4
<link href="tabs.css" rel="stylesheet" type="text/css">
5
<link href="doxygen.css" rel="stylesheet" type="text/css">
6
</head><body>
7
<!-- Generated by Doxygen 1.5.8 -->
8
<div class="navigation" id="top">
9
  <div class="tabs">
10
    <ul>
11
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
12
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
13
      <li><a href="modules.html"><span>Modules</span></a></li>
14
      <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
15
      <li><a href="files.html"><span>Files</span></a></li>
16
    </ul>
17
  </div>
18
</div>
19
<div class="contents">
20
<h1>BOM (Bearing and Orientation Module)</h1>Functions for dealing with the BOM.  
21
<a href="#_details">More...</a>
22
<p>
23
<table border="0" cellpadding="0" cellspacing="0">
24
<tr><td></td></tr>
25
<tr><td colspan="2"><br><h2>Defines</h2></td></tr>
26
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g3f1e6fc7eeb6d7cffde8bb03ff8dc488"></a><!-- doxytag: member="bom::BOM_ALL" ref="g3f1e6fc7eeb6d7cffde8bb03ff8dc488" args="" -->
27
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bom.html#g3f1e6fc7eeb6d7cffde8bb03ff8dc488">BOM_ALL</a>&nbsp;&nbsp;&nbsp;0xFFFF</td></tr>
28

    
29
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Include all elements in the 16-bit bitfield. <br></td></tr>
30
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="gacc7c8241c56ea13b6d50efb281df890"></a><!-- doxytag: member="bom::BOM10" ref="gacc7c8241c56ea13b6d50efb281df890" args="" -->
31
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bom.html#gacc7c8241c56ea13b6d50efb281df890">BOM10</a>&nbsp;&nbsp;&nbsp;0</td></tr>
32

    
33
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Original BOM - No Range, No Individual LED control. <br></td></tr>
34
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g8c5367cf01a2a7ede66be0f2a49b28d0"></a><!-- doxytag: member="bom::BOM15" ref="g8c5367cf01a2a7ede66be0f2a49b28d0" args="" -->
35
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bom.html#g8c5367cf01a2a7ede66be0f2a49b28d0">BOM15</a>&nbsp;&nbsp;&nbsp;1</td></tr>
36

    
37
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">BOM 1.5 - No Range, Individual LED control. <br></td></tr>
38
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g1ff400a0e77d2266138b080061f49d01"></a><!-- doxytag: member="bom::RBOM" ref="g1ff400a0e77d2266138b080061f49d01" args="" -->
39
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bom.html#g1ff400a0e77d2266138b080061f49d01">RBOM</a>&nbsp;&nbsp;&nbsp;2</td></tr>
40

    
41
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">RBOM - Range, Individual LED control. <br></td></tr>
42
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
43
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bom.html#g246031da5c3e5b2a9a9e26111f94eefc">bom_init</a> (char type)</td></tr>
44

    
45
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Initialize the bom according to bom type.  <a href="#g246031da5c3e5b2a9a9e26111f94eefc"></a><br></td></tr>
46
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bom.html#g7a588733784c3e3ac915b7caef6365a9">bom_refresh</a> (int bit_field)</td></tr>
47

    
48
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Refresh bom_val[] with new values from analog8. analog_init and bom_init must be called for this to work.  <a href="#g7a588733784c3e3ac915b7caef6365a9"></a><br></td></tr>
49
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bom.html#gd28d2a59a5090390e20f87cfd05b0a8b">bom_get</a> (int which)</td></tr>
50

    
51
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Gets the bom reading from bom_val[which]. Call bom_refresh beforehand to read new bom values.  <a href="#gd28d2a59a5090390e20f87cfd05b0a8b"></a><br></td></tr>
52
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bom.html#gbce8d8dd8f11d8f5e9f9d74d84ea15db">bom_get_max</a> (void)</td></tr>
53

    
54
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Compares all the values in bom_val[] and returns the index to the highest value element.  <a href="#gbce8d8dd8f11d8f5e9f9d74d84ea15db"></a><br></td></tr>
55
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bom.html#g88316fc0dab8c7e6bb700ba8981e5765">bom_get_max10</a> (int *dist)</td></tr>
56

    
57
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Computes the weighted average of all the bom readings to estimate the position and distance of another robot.  <a href="#g88316fc0dab8c7e6bb700ba8981e5765"></a><br></td></tr>
58
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bom.html#g184db44bd32eef775c650c7f369b7ffa">bom_set_leds</a> (int bit_field)</td></tr>
59

    
60
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Enables the selected bom leds on a BOM1.5.  <a href="#g184db44bd32eef775c650c7f369b7ffa"></a><br></td></tr>
61
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bom.html#g86753fe7440cd64e60c58ad31c62264a">get_max_bom</a> (void)</td></tr>
62

    
63
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">(DEPRECATED) Gets and compares all bom values. Returns the index to the highest value element since last refresh.  <a href="#g86753fe7440cd64e60c58ad31c62264a"></a><br></td></tr>
64
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bom.html#g3311d5de1727b36719d19d54bdd42278">bom_on</a> (void)</td></tr>
65

    
66
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Turns on all BOM leds, or turns on enabled leds on a BOM1.5.  <a href="#g3311d5de1727b36719d19d54bdd42278"></a><br></td></tr>
67
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bom.html#gb64c33f35899910af466984af149ab71">bom_off</a> (void)</td></tr>
68

    
69
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Turns off all bom leds.  <a href="#gb64c33f35899910af466984af149ab71"></a><br></td></tr>
70
<tr><td colspan="2"><br><h2>Variables</h2></td></tr>
71
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="gb9a919548df2f027e0d599ecf65d735d"></a><!-- doxytag: member="bom::bom_initd" ref="gb9a919548df2f027e0d599ecf65d735d" args="" -->
72
unsigned char&nbsp;</td><td class="memItemRight" valign="bottom"><b>bom_initd</b> = 0</td></tr>
73

    
74
</table>
75
<hr><a name="_details"></a><h2>Detailed Description</h2>
76
Functions for dealing with the BOM. 
77
<p>
78
The Bearing and Orientation Module / Barrel of Monkeys / BOM is a custom sensor designed and built by the Colony Project. It consists of a ring of 16 IR emitters and 16 IR detectors. The BOM is most often use to determine the direction of other robots. This module contains functions for controlling the BOM.<p>
79
Include <a class="el" href="bom_8h.html" title="Definitions for using the BOM.">bom.h</a> to access these functions. <hr><h2>Function Documentation</h2>
80
<a class="anchor" name="gd28d2a59a5090390e20f87cfd05b0a8b"></a><!-- doxytag: member="bom.c::bom_get" ref="gd28d2a59a5090390e20f87cfd05b0a8b" args="(int which)" -->
81
<div class="memitem">
82
<div class="memproto">
83
      <table class="memname">
84
        <tr>
85
          <td class="memname">int bom_get           </td>
86
          <td>(</td>
87
          <td class="paramtype">int&nbsp;</td>
88
          <td class="paramname"> <em>which</em>          </td>
89
          <td>&nbsp;)&nbsp;</td>
90
          <td></td>
91
        </tr>
92
      </table>
93
</div>
94
<div class="memdoc">
95

    
96
<p>
97
Gets the bom reading from bom_val[which]. Call bom_refresh beforehand to read new bom values. 
98
<p>
99
Gets the bom reading from bom_val[which]. Call bom_refresh beforehand to read new bom values.<p>
100
<dl class="pre" compact><dt><b>Precondition:</b></dt><dd>must call bom refresh first</dd></dl>
101
<dl compact><dt><b>Parameters:</b></dt><dd>
102
  <table border="0" cellspacing="2" cellpadding="0">
103
    <tr><td valign="top"></td><td valign="top"><em>which</em>&nbsp;</td><td>which bom value to return</td></tr>
104
  </table>
105
</dl>
106
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the bom value, -1 on error</dd></dl>
107
see bom_refresh 
108
</div>
109
</div><p>
110
<a class="anchor" name="gbce8d8dd8f11d8f5e9f9d74d84ea15db"></a><!-- doxytag: member="bom.c::bom_get_max" ref="gbce8d8dd8f11d8f5e9f9d74d84ea15db" args="(void)" -->
111
<div class="memitem">
112
<div class="memproto">
113
      <table class="memname">
114
        <tr>
115
          <td class="memname">int bom_get_max           </td>
116
          <td>(</td>
117
          <td class="paramtype">void&nbsp;</td>
118
          <td class="paramname">          </td>
119
          <td>&nbsp;)&nbsp;</td>
120
          <td></td>
121
        </tr>
122
      </table>
123
</div>
124
<div class="memdoc">
125

    
126
<p>
127
Compares all the values in bom_val[] and returns the index to the highest value element. 
128
<p>
129
Compares all the values in bom_val[] and returns the index to the lowest (max) value element.<p>
130
<dl class="pre" compact><dt><b>Precondition:</b></dt><dd>must call bom refresh </dd></dl>
131
<dl class="return" compact><dt><b>Returns:</b></dt><dd>index to the lowest (max) bom value element. -1 if no value is lower than BOM_VALUE_THRESHOLD, -2 if the bom is not initialized </dd></dl>
132

    
133
</div>
134
</div><p>
135
<a class="anchor" name="g88316fc0dab8c7e6bb700ba8981e5765"></a><!-- doxytag: member="bom.c::bom_get_max10" ref="g88316fc0dab8c7e6bb700ba8981e5765" args="(int *dist)" -->
136
<div class="memitem">
137
<div class="memproto">
138
      <table class="memname">
139
        <tr>
140
          <td class="memname">int bom_get_max10           </td>
141
          <td>(</td>
142
          <td class="paramtype">int *&nbsp;</td>
143
          <td class="paramname"> <em>dist</em>          </td>
144
          <td>&nbsp;)&nbsp;</td>
145
          <td></td>
146
        </tr>
147
      </table>
148
</div>
149
<div class="memdoc">
150

    
151
<p>
152
Computes the weighted average of all the bom readings to estimate the position and distance of another robot. 
153
<p>
154
Computes the weighted average of all the bom readings to estimate the position (and distance) of another robot.<p>
155
<dl class="pre" compact><dt><b>Precondition:</b></dt><dd>must call bom refresh </dd></dl>
156
<dl compact><dt><b>Parameters:</b></dt><dd>
157
  <table border="0" cellspacing="2" cellpadding="0">
158
    <tr><td valign="top"></td><td valign="top"><em>dist</em>&nbsp;</td><td>pointer to int in which to return the estimated distance to the other robot </td></tr>
159
  </table>
160
</dl>
161
<dl class="return" compact><dt><b>Returns:</b></dt><dd>estimated position of the max bom value element as a fixed point value analogous to 10 times the index of the max bom value. -1 if no value is lower than BOM_VALUE_THRESHOLD, -2 if the bom is not initialized </dd></dl>
162

    
163
</div>
164
</div><p>
165
<a class="anchor" name="g246031da5c3e5b2a9a9e26111f94eefc"></a><!-- doxytag: member="bom.c::bom_init" ref="g246031da5c3e5b2a9a9e26111f94eefc" args="(char type)" -->
166
<div class="memitem">
167
<div class="memproto">
168
      <table class="memname">
169
        <tr>
170
          <td class="memname">int bom_init           </td>
171
          <td>(</td>
172
          <td class="paramtype">char&nbsp;</td>
173
          <td class="paramname"> <em>type</em>          </td>
174
          <td>&nbsp;)&nbsp;</td>
175
          <td></td>
176
        </tr>
177
      </table>
178
</div>
179
<div class="memdoc">
180

    
181
<p>
182
Initialize the bom according to bom type. 
183
<p>
184
Initializes the BOM. Call bom_init before reading bom values or turning bom leds.<p>
185
INCOMPLETE - No utilization of BOM1.5 RSSI capability. Probably leave this out until Cornell and Pras return<p>
186
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 if init succesfull, an error code otherwise</dd></dl>
187
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="group__bom.html#g7a588733784c3e3ac915b7caef6365a9" title="Refresh bom_val[] with new values from analog8. analog_init and bom_init must be...">bom_refresh</a>, bom_leds_on, bom_leds_off </dd></dl>
188

    
189
</div>
190
</div><p>
191
<a class="anchor" name="gb64c33f35899910af466984af149ab71"></a><!-- doxytag: member="bom.c::bom_off" ref="gb64c33f35899910af466984af149ab71" args="(void)" -->
192
<div class="memitem">
193
<div class="memproto">
194
      <table class="memname">
195
        <tr>
196
          <td class="memname">int bom_off           </td>
197
          <td>(</td>
198
          <td class="paramtype">void&nbsp;</td>
199
          <td class="paramname">          </td>
200
          <td>&nbsp;)&nbsp;</td>
201
          <td></td>
202
        </tr>
203
      </table>
204
</div>
205
<div class="memdoc">
206

    
207
<p>
208
Turns off all bom leds. 
209
<p>
210
Turns off all bom leds.<p>
211
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 if init succesfull, an error code otherwise</dd></dl>
212
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="group__bom.html#g3311d5de1727b36719d19d54bdd42278" title="Turns on all BOM leds, or turns on enabled leds on a BOM1.5.">bom_on</a> </dd></dl>
213

    
214
</div>
215
</div><p>
216
<a class="anchor" name="g3311d5de1727b36719d19d54bdd42278"></a><!-- doxytag: member="bom.c::bom_on" ref="g3311d5de1727b36719d19d54bdd42278" args="(void)" -->
217
<div class="memitem">
218
<div class="memproto">
219
      <table class="memname">
220
        <tr>
221
          <td class="memname">int bom_on           </td>
222
          <td>(</td>
223
          <td class="paramtype">void&nbsp;</td>
224
          <td class="paramname">          </td>
225
          <td>&nbsp;)&nbsp;</td>
226
          <td></td>
227
        </tr>
228
      </table>
229
</div>
230
<div class="memdoc">
231

    
232
<p>
233
Turns on all BOM leds, or turns on enabled leds on a BOM1.5. 
234
<p>
235
Flashes the BOM. If using a BOM1.5, only the emitters that have been enabled using bom_set_leds will turn on.<p>
236
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 if init succesfull, an error code otherwise</dd></dl>
237
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="group__bom.html#gb64c33f35899910af466984af149ab71" title="Turns off all bom leds.">bom_off</a>, <a class="el" href="group__bom.html#g184db44bd32eef775c650c7f369b7ffa" title="Enables the selected bom leds on a BOM1.5.">bom_set_leds</a> </dd></dl>
238

    
239
</div>
240
</div><p>
241
<a class="anchor" name="g7a588733784c3e3ac915b7caef6365a9"></a><!-- doxytag: member="bom.c::bom_refresh" ref="g7a588733784c3e3ac915b7caef6365a9" args="(int bit_field)" -->
242
<div class="memitem">
243
<div class="memproto">
244
      <table class="memname">
245
        <tr>
246
          <td class="memname">int bom_refresh           </td>
247
          <td>(</td>
248
          <td class="paramtype">int&nbsp;</td>
249
          <td class="paramname"> <em>bit_field</em>          </td>
250
          <td>&nbsp;)&nbsp;</td>
251
          <td></td>
252
        </tr>
253
      </table>
254
</div>
255
<div class="memdoc">
256

    
257
<p>
258
Refresh bom_val[] with new values from analog8. analog_init and bom_init must be called for this to work. 
259
<p>
260
Iterates through each bit in the bit_field. For each set bit, sets the corresponding bom select bits and updates the corresponding bom value with an analog_get8 reading. analog_init and bom_init must be called for this to work. Must call this before reading BOM values!<p>
261
<dl compact><dt><b>Parameters:</b></dt><dd>
262
  <table border="0" cellspacing="2" cellpadding="0">
263
    <tr><td valign="top"></td><td valign="top"><em>bit_field</em>&nbsp;</td><td>specifies which elements in bom_val[] should be updated. Use BOM_ALL to refresh all values. Ex. if 0x0003 is passed, bom_val[0] and bom_val[1] will be updated.</td></tr>
264
  </table>
265
</dl>
266
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 if init succesfull, an error code otherwise</dd></dl>
267
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="group__bom.html#gd28d2a59a5090390e20f87cfd05b0a8b" title="Gets the bom reading from bom_val[which]. Call bom_refresh beforehand to read new...">bom_get</a> </dd></dl>
268

    
269
</div>
270
</div><p>
271
<a class="anchor" name="g184db44bd32eef775c650c7f369b7ffa"></a><!-- doxytag: member="bom.c::bom_set_leds" ref="g184db44bd32eef775c650c7f369b7ffa" args="(int bit_field)" -->
272
<div class="memitem">
273
<div class="memproto">
274
      <table class="memname">
275
        <tr>
276
          <td class="memname">int bom_set_leds           </td>
277
          <td>(</td>
278
          <td class="paramtype">int&nbsp;</td>
279
          <td class="paramname"> <em>bit_field</em>          </td>
280
          <td>&nbsp;)&nbsp;</td>
281
          <td></td>
282
        </tr>
283
      </table>
284
</div>
285
<div class="memdoc">
286

    
287
<p>
288
Enables the selected bom leds on a BOM1.5. 
289
<p>
290
Iterates through each bit in the bit_field. If the bit is set, the corresponding emitter will be enabled to turn on when <a class="el" href="group__bom.html#g3311d5de1727b36719d19d54bdd42278" title="Turns on all BOM leds, or turns on enabled leds on a BOM1.5.">bom_on()</a> is called. bom_init must be called for this to work. Does nothing if a BOM1.0 is installed<p>
291
<dl compact><dt><b>Parameters:</b></dt><dd>
292
  <table border="0" cellspacing="2" cellpadding="0">
293
    <tr><td valign="top"></td><td valign="top"><em>bit_field</em>&nbsp;</td><td>specifies which leds should be turned on when bom_on is called. Use BOM_ALL to turn on all bom leds. Ex. if 0x0005 is passed, leds 0 and 2 will be turned on.</td></tr>
294
  </table>
295
</dl>
296
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 if init succesfull, an error code otherwise </dd></dl>
297

    
298
</div>
299
</div><p>
300
<a class="anchor" name="g86753fe7440cd64e60c58ad31c62264a"></a><!-- doxytag: member="bom.c::get_max_bom" ref="g86753fe7440cd64e60c58ad31c62264a" args="(void)" -->
301
<div class="memitem">
302
<div class="memproto">
303
      <table class="memname">
304
        <tr>
305
          <td class="memname">int get_max_bom           </td>
306
          <td>(</td>
307
          <td class="paramtype">void&nbsp;</td>
308
          <td class="paramname">          </td>
309
          <td>&nbsp;)&nbsp;</td>
310
          <td></td>
311
        </tr>
312
      </table>
313
</div>
314
<div class="memdoc">
315

    
316
<p>
317
(DEPRECATED) Gets and compares all bom values. Returns the index to the highest value element since last refresh. 
318
<p>
319
(DEPRECATED) Returns the direction of the maximum BOM reading, as an integer in the range 0-15. 0 indicates to the robot's right, while the rest of the sensors are numbered counterclockwise. This is useful for determining the direction of a robot flashing its BOM, of only one robot is currently doing so. analog_init must be called before this function can be used.<p>
320
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the direction of the maximum BOM reading</dd></dl>
321
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="group__analog.html#gf998a4653bf62164fcc93b0f58796ab5" title="Initialize analog ports. Will start running a loop if start_conversion is ADC_START...">analog_init</a> </dd></dl>
322

    
323
</div>
324
</div><p>
325
</div>
326
<hr size="1"><address style="text-align: right;"><small>Generated on Fri Nov 20 21:51:59 2009 for Colony by&nbsp;
327
<a href="http://www.doxygen.org/index.html">
328
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
329
</body>
330
</html>