#include <fob.h>

Classes | |
| class | bird |
| A bird in a Flock of Birds. More... | |
| struct | change_option |
| Flock of Birds change command. | |
| struct | command |
| Flock of Birds command. | |
| struct | error_t |
| Describes an internal flock hardware error. More... | |
| struct | examine_option |
| Flock of Birds examine command. | |
Public Types | |
| enum | hemisphere { AFT, FORWARD, LEFT, RIGHT, UP, DOWN } |
| Hemisphere in which all sensors are operating. | |
| enum | port_speed { FAST, SLOW } |
| Serial port speed. | |
| enum | error_level { WARNING1, WARNING2, FATAL } |
| Serverity of hardware error. | |
| typedef unsigned char | mode |
| Desired output format for a bird. | |
| typedef std::vector< fob::bird * > | bird_list |
| A list of birds. | |
Public Member Functions | |
| fob (void) | |
| Constructor. | |
| fob (const std::string &device_name, fob::hemisphere hemi, port_speed speed=FAST, unsigned long sleep_ms=500) | |
| Constructor with options. | |
| ~fob (void) | |
| Destructor. | |
| const fob & | open (const std::string &device_name, fob::hemisphere hemisphere, port_speed speed=FAST, unsigned long sleep_ms=500) |
| Opens the flock of birds. | |
| bool | close (void) |
| Closes the flock of birds. | |
| fob::bird_list & | get_birds (void) |
| Returns a list of birds in the flock. | |
| bool | fly (void) |
| Sets the birds flying. | |
| bool | print_bird_status (void) |
| Print out status of each bird. | |
| operator bool (void) const | |
Return false if flock is in an error state. | |
| const std::string & | get_error (void) const |
| Returns a string describing the current error. | |
| void | set_sleep (unsigned long ms) |
| Sets the amount of time to sleep between flock commands (in ms). | |
| unsigned long | get_sleep (void) const |
| Returns the amount of time to sleep (in ms) between flock commands. | |
| void | set_error_level (error_level lvl) |
| Sets the error level at which flock hardware errors will cause the fob object enter an error state. | |
Static Public Attributes | |
| static const mode | POSITION = 0x01 |
| Request position information from bird. | |
| static const mode | ORIENTATION = 0x02 |
| Request orientation information from bird. | |
| static const mode | BUTTONS = 0x04 |
| Request button information from bird. | |
| static const unsigned char | BUTTON_NONE = 0x0 |
| No button pressed. | |
| static const unsigned char | BUTTON_LEFT = 0x10 |
| Left button mask. | |
| static const unsigned char | BUTTON_MIDDLE = 0x30 |
| Middle button mask. | |
| static const unsigned char | BUTTON_RIGHT = 0x70 |
| Right button mask. | |
Friends | |
| void * | get_flock_data (void *flock) |
| Thread data retrieval function. | |
All orientation and position information is returned in units that make sense to OpenGL's reference frame (x: screen right, y: screen up, z: out of screen). Note that this is different from the Flock of Birds' default reference frame (x: out of screen, y: screen left, z: screen down). Use this object as follows:
//open the flock of birds that is on the 2nd serial port and //with sensors in front of the main transmitter //sleep about 500ms between configuration commands fob flock( "/dev/ttyS1", fob::FORWARD, fob::FAST, 500 ); //make sure that everything opened ok if( !flock ) { //something went wrong std::cerr << "error: " << flock.get_error( ) << std::endl; return 1; } //get a list of all birds in the flock fob::bird_list birds = flock.get_birds( ); //we want position, orientation, button information from all birds for( unsigned int i = 0; i < birds.size( ); ++i ) { birds[ i ]->set_mode( fob::POSITION | fob::ORIENTATION | fob::BUTTONS ); } //set the flock flying flock.fly( ); //give the birds a little time to startup sleep( 1 ); //main loop math::vector3 position; math::quaternion orientation; unsigned char buttons; while( 1 ) { for( unsigned int i = 0; i < birds.size( ); ++i ) { //get latest info from birds birds[ i ]->get_position( position ); birds[ i ]->get_quaternion( orientation ); birds[ i ]->get_buttons( buttons ); std::cout << "bird i: pos: " << position << std::endl; std::cout << "bird i: quat: " << orientation << std::endl; std::cout << "bird i: buttons: " << ((buttons == fob::BUTTON_LEFT) ? 1 | 0) << ((buttons == fob::BUTTON_MIDDLE) ? 1 | 0) << ((buttons == fob::BUTTON_LEFT) ? 1 | 0) << std::endl; } } //close the flock (optional) flock.close( );
Definition at line 115 of file fob.h.
| fob::fob | ( | void | ) |
Constructor.
Creates an fob object. It does not open the flock. To open the flock, call fob::open.
Definition at line 1090 of file fob.cpp.
References get_flock_data.
| fob::fob | ( | const std::string & | device_name, | |
| fob::hemisphere | hemi, | |||
| fob::port_speed | speed = FAST, |
|||
| unsigned long | sleep_ms = 500 | |||
| ) |
Constructor with options.
Creates an fob object. Opens the flock.
| device_name | Serial port the flock is connected too. | |
| hemi | Hemisphere in which all birds of the flock will operate. | |
| speed | Speed at which the host system will communicate with the flock hardware. Use fob::SLOW for older flock hardware. | |
| sleep_ms | Amount of time to sleep between sending commands to the flock hardware (in ms). |
Definition at line 1109 of file fob.cpp.
References get_flock_data, and open().
| fob::~fob | ( | void | ) |
| void fob::set_error_level | ( | error_level | lvl | ) | [inline] |
| void fob::set_sleep | ( | unsigned long | ms | ) | [inline] |
Sets the amount of time to sleep between flock commands (in ms).
Sending data to the flock to fast results in placing the flock into an unstable state. One can use this method to set a small amount of time the library should sleep when sending data to the flock. Note that this time only effects the flock startup time. It does not effect the rate at which flock data is retrieved.
| ms | Time to sleep in milliseconds. |
Definition at line 675 of file fob.h.
Referenced by open().
| void* get_flock_data | ( | void * | flock | ) | [friend] |
1.5.7.1