LoWheelDrops.c

Go to the documentation of this file.
00001 /**
00002    \file  Robots/LoBot/irccm/LoWheelDrops.c
00003    \brief Low-level reactions for wheel drop sensors.
00004 
00005    This file defines the functions that implement the wheel drop sensor
00006    action and pending API for the low-level Robolocust control program
00007    meant to be run on the iRobot Create's Command Module.
00008 */
00009 
00010 /*
00011  ************************************************************************
00012  * The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   *
00013  * by the University of Southern California (USC) and the iLab at USC.  *
00014  * See http://iLab.usc.edu for information about this project.          *
00015  *                                                                      *
00016  * Major portions of the iLab Neuromorphic Vision Toolkit are protected *
00017  * under the U.S. patent ``Computation of Intrinsic Perceptual Saliency *
00018  * in Visual Environments, and Applications'' by Christof Koch and      *
00019  * Laurent Itti, California Institute of Technology, 2001 (patent       *
00020  * pending; application number 09/912,225 filed July 23, 2001; see      *
00021  * http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     *
00022  ************************************************************************
00023  * This file is part of the iLab Neuromorphic Vision C++ Toolkit.       *
00024  *                                                                      *
00025  * The iLab Neuromorphic Vision C++ Toolkit is free software; you can   *
00026  * redistribute it and/or modify it under the terms of the GNU General  *
00027  * Public License as published by the Free Software Foundation; either  *
00028  * version 2 of the License, or (at your option) any later version.     *
00029  *                                                                      *
00030  * The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  *
00031  * that it will be useful, but WITHOUT ANY WARRANTY; without even the   *
00032  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      *
00033  * PURPOSE.  See the GNU General Public License for more details.       *
00034  *                                                                      *
00035  * You should have received a copy of the GNU General Public License    *
00036  * along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   *
00037  * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   *
00038  * Boston, MA 02111-1307 USA.                                           *
00039  ************************************************************************
00040 */
00041 
00042 /*
00043    Primary maintainer for this file: mviswana usc edu
00044    $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Robots/LoBot/irccm/LoWheelDrops.c $
00045    $Id: LoWheelDrops.c 13745 2010-08-02 05:27:16Z mviswana $
00046 */
00047 
00048 /*------------------------------ HEADERS ------------------------------*/
00049 
00050 // lobot headers
00051 #include "LoWheelDrops.h"
00052 #include "LoDrive.h"
00053 #include "LoSensors.h"
00054 #include "LoIO.h"
00055 #include "LoCMInterface.h"
00056 #include "LoOpenInterface.h"
00057 
00058 /*------------------------------ GLOBALS ------------------------------*/
00059 
00060 // This variable holds the current state of the wheel drop sensors as
00061 // returned by the LoSensors module.
00062 static char g_drop ;
00063 
00064 /*--------------------- REACTING TO WHEEL DROPS -----------------------*/
00065 
00066 // This function retrieves the wheel drop sensors' state from the
00067 // LoSensors module and shuts off the motors in case any of them are
00068 // active.
00069 //
00070 // DEVNOTE: This function does not check to see if sensor data is
00071 // available before retrieving the wheel drop sensor state. The main
00072 // program should take care of that, i.e., check that sensor data is
00073 // actually available before calling this function. We do it like this
00074 // because there are other low-level sensor reaction modules and all of
00075 // them would have to keep checking the same flag over and over again.
00076 // Much nicer if the main program checks the sensor data availability
00077 // flag once and then calls all the sensor reaction functions one-by-one.
00078 void lo_wheel_drops(void)
00079 {
00080    g_drop = lo_get_sensor(LOBOT_SENSORS_WHEEL_DROPS) & LOBOT_OI_WHEEL_DROP_ANY;
00081    if (g_drop)
00082       lo_stop_immediate() ;
00083 }
00084 
00085 /*---------------- WHEEL DROP SENSOR ACKNOWLEDGEMENTS -----------------*/
00086 
00087 // Check if wheel drops sensor acknowledgement is pending so that main
00088 // loop can send out the ACK the next time it switches to talking to the
00089 // high level via the Command Module's USB port.
00090 char lo_wheel_drops_pending(void)
00091 {
00092    return g_drop ;
00093 }
00094 
00095 // Send pending wheel drops sensor ACK to the high level
00096 void lo_send_wheel_drops(void)
00097 {
00098    lo_tx(LOBOT_ACK_WHEEL_DROPS) ;
00099    lo_tx(g_drop) ;
00100 }
Generated on Sun May 8 08:41:30 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3