00001 // Copyright (C) 2010-2011 Institut de Robotica i Informatica Industrial, CSIC-UPC. 00002 // Author 00003 // All rights reserved. 00004 // 00005 // This file is part of iri-ros-pkg 00006 // iri-ros-pkg is free software: you can redistribute it and/or modify 00007 // it under the terms of the GNU Lesser General Public License as published by 00008 // the Free Software Foundation, either version 3 of the License, or 00009 // at your option) any later version. 00010 // 00011 // This program is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU Lesser General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public License 00017 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 // 00019 // IMPORTANT NOTE: This code has been generated through a script from the 00020 // iri_ros_scripts. Please do NOT delete any comments to guarantee the correctness 00021 // of the scripts. ROS topics can be easly add by using those scripts. Please 00022 // refer to the IRI wiki page for more information: 00023 // http://wikiri.upc.es/index.php/Robotics_Lab 00024 00025 #ifndef _iri_joystick_driver_h_ 00026 #define _iri_joystick_driver_h_ 00027 00028 #include "iri_base_driver/iri_base_driver.h" 00029 #include "iri_joystick/IriJoystickConfig.h" 00030 #include <iridrivers/joystick.h> 00031 00032 //include iri_joystick_driver main library 00033 00053 class IriJoystickDriver : public iri_base_driver::IriBaseDriver 00054 { 00055 private: 00056 /* 00057 * Pointer to IRI driver class to make the real operation with theĀ· 00058 * hardware. Default name is iri-joystick-${PID} 00059 */ 00060 CJoystick * jh_; 00061 00062 /* 00063 * linux device path to found the joystick in. Default is /dev/input/js0 00064 */ 00065 std::string dev_; 00066 /* 00067 * Publising topic name. Default is "joy" 00068 */ 00069 std::string pub_channel_name_; 00070 00071 00072 public: 00079 typedef iri_joystick::IriJoystickConfig Config; 00080 00087 Config config_; 00088 00097 IriJoystickDriver(); 00098 00109 bool openDriver(void); 00110 00121 bool closeDriver(void); 00122 00133 bool startDriver(void); 00134 00145 bool stopDriver(void); 00146 00158 void config_update(const Config& new_cfg, uint32_t level=0); 00159 00160 void enable_position_change_callback(int axis_id, 00161 void (* callback) (void * param, unsigned int axis_id, float value), 00162 void * param = 0); 00163 00164 void enable_button_callback(int button_id, 00165 void (* callback) (void * param, unsigned int button_id, bool value), 00166 void * param = 0); 00170 int get_num_buttons() const; 00171 00172 /* 00173 * return the total number of axes detected in device 00174 */ 00175 int get_num_axes() const; 00176 00180 std::string get_device() const; 00181 00188 ~IriJoystickDriver(); 00189 }; 00190 00191 #endif