BOM¶
The BOM (Bearing and Orientation Module) is used to locate other robots and to figure out how far away they are.
Sample code¶
#include <dragonfly_lib.h> /* * Turns on the BOM so that other robots can find this one */ void BOM_on(void) { bom_init(BOM10); // must be called before using any BOM code bom_on(); // turns on the BOM }
#include <dragonfly_lib.h> /* * Searches for robots with their BOMs on in front of this one. * If a robot is detected in front of this one, turns the orbs green. * If there is no robot in front of this one, turns the orbs red. */ void find_robot(void) { orb_init(); // must be called before using any orb code bom_init(BOM10); // must be called before using any BOM code while(1) // repeat the following code in brackets forever { bom_refresh(BOM_ALL); // gets the newest values from each BOM detector int bom = bom_get_max(); // gets the index of the BOM where the signal is strongest // if the strongest signal is from detectors 2-6, then the other robot is in front of this one if(bom >= 2 && bom <= 6) orb_set_color(GREEN); // other robot detected - turn the orbs green else // no robot in front of this one orb_set_color(RED); // turn the orbs red } }
Header File¶
For a full list of functions, see the BOM code header file.
Debugging¶
Things to check/maintain:- Yellow ground wire is plugged in (picture)
- detector on 9, 10, 11, 12 were OK; the rest of the detectors needed to be reversed (see picture)
- wire harness
Schematics¶
Inputs to the BOM:
Output from the BOM: