LoSensors.h

Go to the documentation of this file.
00001 /**
00002    \file  Robots/LoBot/irccm/LoSensors.h
00003    \brief Sensors API for Robolocust iRobot Create Command Module control
00004    program.
00005 
00006    This file defines an API for retrieving relevant sensor data from the
00007    iRobot Create using the Open Interface.
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/LoSensors.h $
00045    $Id: LoSensors.h 13769 2010-08-08 01:34:02Z mviswana $
00046 */
00047 
00048 #ifndef LOBOT_IRCCM_SENSORS_DOT_H
00049 #define LOBOT_IRCCM_SENSORS_DOT_H
00050 
00051 /*-------------------------- INITIALIZATION ---------------------------*/
00052 
00053 /// This function initializes the sensors module. It must be called early
00054 /// during the low-level controller's initialization sequence. This
00055 /// function is responsible for properly debouncing the rear proximity
00056 /// detectors.
00057 void lo_init_sensors(void) ;
00058 
00059 /// On its rear, the robot sports a pair of Sharp GP2D15 IR proximity
00060 /// detectors to help prevent bumping into things as it backs up. Since
00061 /// the Command Module is also accessed from the rear, these two sensors
00062 /// detect the user's hand as soon as the robot is turned on and cause it
00063 /// to spin and move forward, away from the "obstacle" behind it.
00064 ///
00065 /// This can be very annoying, especially when we want the robot to
00066 /// remain stationary at some fixed initial starting position prior to
00067 /// the commencement of an experiment/run.
00068 ///
00069 /// To work around this behaviour, we allow the high-level controller to
00070 /// specify when the rear bumpers should be enabled and when they should
00071 /// be ignored. Furthermore, the user can also toggle these sensors by
00072 /// using the SPOT button on the Roomba Remote.
00073 ///
00074 /// These functions turn the rear bumpers on/off.
00075 //@{
00076 void lo_enable_rear_bumps (int) ;
00077 void lo_disable_rear_bumps(int) ;
00078 void lo_toggle_rear_bumps(void) ;
00079 //@}
00080 
00081 /// When the rear bumpers are enabled, the low-level controller will
00082 /// respond to rear bump events in one of two ways:
00083 ///
00084 ///    1. just stop the robot when either of the rear bump sensors is
00085 ///       active
00086 ///
00087 ///    2. stop the robot, then spin it a small amount either clockwise or
00088 ///       counterclockwise depending on which side the obstacle appears
00089 ///       and, finally, move the robot forward a little bit
00090 ///
00091 /// By default, the low-level controller simply stops the robot. However,
00092 /// the high-level controller can instruct the low-level controller to
00093 /// adopt the second action described above by passing a '1' as the
00094 /// parameter to the LOBOT_CMD_ENABLE_REAR_BUMPS command.
00095 ///
00096 /// Additionally, the user can switch between the above two actions by
00097 /// using the MAX button on the Roomba Remote.
00098 ///
00099 /// This function toggles the flag responsible for deciding which of the
00100 /// above two actions to take when a rear bump event is detected.
00101 void lo_toggle_rear_bumps_spin(void) ;
00102 
00103 /*---------------------- RETRIEVING SENSOR DATA -----------------------*/
00104 
00105 /**
00106    This function retrieves the current sensor data from the Create
00107    robot. The Create is queried for all its sensor packets.
00108 
00109    To indicate to the main program that new sensor data has been
00110    retrieved, it sets a flag.
00111 
00112    The main loop of the low-level Command Module control program will
00113    test this flag in each iteration and then send the sensor data off to
00114    the high level.
00115 */
00116 void lo_sensors(void) ;
00117 
00118 /// The lo_sensors() function retrieves the current sensor data from the
00119 /// Create robot and stores it in an internal array. This function
00120 /// returns a sensor byte given its index.
00121 ///
00122 /// NOTE: The indices into the internal sensor data array are defined in
00123 /// LoCMInterface.h.
00124 char lo_get_sensor(unsigned char index) ;
00125 
00126 /*----------------------- UPDATING SENSOR DATA ------------------------*/
00127 
00128 /// In response to events such as bumps and cliffs, the low-level
00129 /// controller backs up the robot (or moves it forward if that is the
00130 /// appropriate response) and spins it in place by some small amount.
00131 /// When we do that, we should add the amount of linear and rotational
00132 /// displacement to the encoder's estimates. Otherwise, the next sensor
00133 /// packet we send to the high-level controller will report odometry
00134 /// values associated with the sensor query sent to the iRobot Create
00135 /// prior to the low-level controller's bumps/cliffs avoidance. These
00136 /// incorrect odometry estimates can wreak havoc on any high-level
00137 /// localization modules and other parts that rely on reasonably accurate
00138 /// odometry from the low-level.
00139 ///
00140 /// This function adds the given displacements to the low-level sensor
00141 /// packet that is currently pending, i.e., "waiting" to be sent to the
00142 /// high-level controller.
00143 void lo_update_odometry(int distance, int angle) ;
00144 
00145 /// When the high-level controller sends a SPIN command, it will specify
00146 /// the amount to be spun. However, the actual amount spun may be
00147 /// slightly more or less (due to motor/encoder errors). Furthermore, the
00148 /// robot may also experience some slight translational motion in
00149 /// addition to the requested rotation.
00150 ///
00151 /// To ensure that the high-level receives accurate motion updates in the
00152 /// next SENSORS acknowledgement, we should record the translation and
00153 /// rotation resulting from the SPIN command in some temporary variables
00154 /// and add those values to the encoder data retrieved from the Create
00155 /// when the time comes to send the next ACK_SENSORS.
00156 ///
00157 /// This function updates the temporary variables alluded to above.
00158 void lo_update_pending_odometry(int distance, int angle) ;
00159 
00160 /*------------------------- SENSOR DATA STATE -------------------------*/
00161 
00162 /// Check if sensor data is available for sending to the high level.
00163 char lo_sensors_pending(void) ;
00164 
00165 /// When the rear bump sensors are active, the low-level controller can
00166 /// be configured to respond by simply stopping the robot (default
00167 /// behaviour) or by spinning in-place and then moving up. This function
00168 /// returns false if the former configuration is in effect and true for
00169 /// the latter.
00170 char lo_rear_bumps_spin(void) ;
00171 
00172 /*------------------------ SENDING SENSOR DATA ------------------------*/
00173 
00174 /// Send pending/current sensor data to the high level.
00175 void lo_send_sensors(void) ;
00176 
00177 /*---------------------------------------------------------------------*/
00178 
00179 #endif
Generated on Sun May 8 08:41:30 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3