00001 /********************************************************************* 00002 * 00003 * This is free and unencumbered software released into the public domain. 00004 * 00005 * Anyone is free to copy, modify, publish, use, compile, sell, or 00006 * distribute this software, either in source code form or as a compiled 00007 * binary, for any purpose, commercial or non-commercial, and by any 00008 * means. 00009 * 00010 * In jurisdictions that recognize copyright laws, the author or authors 00011 * of this software dedicate any and all copyright interest in the 00012 * software to the public domain. We make this dedication for the benefit 00013 * of the public at large and to the detriment of our heirs and 00014 * successors. We intend this dedication to be an overt act of 00015 * relinquishment in perpetuity of all present and future rights to this 00016 * software under copyright law. 00017 * 00018 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00019 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00020 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00021 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00022 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00023 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00024 * OTHER DEALINGS IN THE SOFTWARE. 00025 * 00026 * For more information, please refer to <http://unlicense.org/> 00027 * 00028 **********************************************************************/ 00029 00030 #ifndef HYDRA_H 00031 #define HYDRA_H 00032 00033 #include <razer_hydra/filters.h> 00034 #include <tf/tf.h> 00035 #include <stdint.h> 00036 #include <fcntl.h> 00037 #include <unistd.h> 00038 #include <sys/types.h> 00039 #include <sys/stat.h> 00040 #include <sys/ioctl.h> 00041 #include <linux/hidraw.h> 00042 #include <libusb-1.0/libusb.h> 00043 00044 namespace razer_hydra 00045 { 00046 00047 class RazerHydra 00048 { 00049 public: 00050 RazerHydra(); 00051 ~RazerHydra(); 00052 //usb_dev_handle *hid_dev; 00053 //int hid_dev_iface; 00054 //int hid_dev_ep_in; 00055 //uint16_t raw[NUM_SENSORS]; 00056 int hidraw_fd; 00057 00058 bool init(const char *device); 00059 bool poll(uint32_t ms_to_wait, float low_pass_corner_hz = 5.0); 00060 00061 int16_t raw_pos[6], raw_quat[8]; 00062 uint8_t raw_buttons[2]; 00063 int16_t raw_analog[6]; 00064 00065 00066 tf::Vector3 pos[2]; 00067 tf::Quaternion quat[2]; 00068 OnePoleVector3 filter_pos[2]; 00069 OnePoleQuaternion filter_quat[2]; 00070 float analog[6]; 00071 uint8_t buttons[14]; 00072 00073 OnePole<float> period_estimate; 00074 ros::WallTime last_cycle_start; 00075 00076 }; 00077 00078 } 00079 00080 #endif 00081