joyctrl.h

Go to the documentation of this file.
00001 /*********************************************************
00002  *
00003  * This source code is part of the Carnegie Mellon Robot
00004  * Navigation Toolkit (CARMEN)
00005  *
00006  * CARMEN Copyright (c) 2002 Michael Montemerlo, Nicholas
00007  * Roy, and Sebastian Thrun
00008  *
00009  * CARMEN is free software; you can redistribute it and/or 
00010  * modify it under the terms of the GNU General Public 
00011  * License as published by the Free Software Foundation; 
00012  * either version 2 of the License, or (at your option)
00013  * any later version.
00014  *
00015  * CARMEN is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied 
00017  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00018  * PURPOSE.  See the GNU General Public License for more 
00019  * details.
00020  *
00021  * You should have received a copy of the GNU General 
00022  * Public License along with CARMEN; if not, write to the
00023  * Free Software Foundation, Inc., 59 Temple Place, 
00024  * Suite 330, Boston, MA  02111-1307 USA
00025  *
00026  ********************************************************/
00027 
00029 // @{
00030 
00039 #ifndef CARMEN_JOYCTRL_H
00040 #define CARMEN_JOYCTRL_H
00041 
00042 #ifdef __cplusplus
00043 extern "C" {
00044 #endif
00045 
00046 #include <carmen/carmen.h>
00047 
00048 #include <sys/ioctl.h>
00049 #include <sys/types.h>
00050 #include <fcntl.h>
00051 #include <unistd.h>
00052 #include <stdlib.h>
00053 #include <linux/joystick.h>
00054 
00055 #define         CARMEN_JOYSTICK_DEVICE         "/dev/js0"
00056 #define         CARMEN_JOYSTICK_DEADSPOT       1
00057 #define         CARMEN_JOYSTICK_DEADSPOT_SIZE  0.2
00058 
00059 typedef struct {
00060   int fd;
00061   int nb_axes;
00062   int nb_buttons;
00063   int *axes;
00064   int *buttons;
00065   int deadspot;
00066   double deadspot_size;
00067   int initialized;
00068 } carmen_joystick_type;
00069 
00070 /* Set joystick deadspot */
00071 void carmen_set_deadspot(carmen_joystick_type *joystick, int on_off, double size);
00072 
00073 /* Initialize joystick; has to be called before any other function; *
00074  * returns 0 on success, else -1                                    */
00075 int carmen_initialize_joystick(carmen_joystick_type *joystick);
00076 
00077 /* Request joystick state; returns number of bytes read on success, *
00078  * else -1;                                                         */
00079 int carmen_get_joystick_state(carmen_joystick_type *joystick);
00080 
00081 /* Close joystick */
00082 void carmen_close_joystick(carmen_joystick_type *joystick);
00083 
00084 /* returns translational and rotational velocities from joystick */
00085 void carmen_joystick_control(carmen_joystick_type *joystick, double max_tv, 
00086                              double max_rv, double *tv, double *rv);
00087 
00088 #ifdef __cplusplus
00089 }
00090 #endif
00091 
00092 #endif
00093 // @}

Generated on Wed Apr 5 18:34:18 2006 for CARMEN by  doxygen 1.4.4