Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <ros/ros.h>
00019 #include <cob_phidgets/phidget_manager.h>
00020 #include <stdlib.h>
00021 #include <unistd.h>
00022
00023 PhidgetManager::PhidgetManager()
00024 : _manHandle(0)
00025 {
00026 CPhidgetManager_create(&_manHandle);
00027 CPhidgetManager_open((CPhidgetManagerHandle) _manHandle);
00028
00029 sleep(2);
00030 }
00031
00032 PhidgetManager::~PhidgetManager()
00033 {
00034
00035 CPhidgetManager_close((CPhidgetManagerHandle) _manHandle);
00036 CPhidgetManager_delete((CPhidgetManagerHandle) _manHandle);
00037
00038 usleep(500000);
00039 }
00040
00041 auto PhidgetManager::getAttachedDevices()-> std::vector<AttachedDevice>
00042 {
00043 CPhidgetHandle* phidgetList;
00044 int count;
00045 ROS_INFO("getting attached Devices");
00046 CPhidgetManager_getAttachedDevices((CPhidgetManagerHandle) _manHandle, &phidgetList, &count);
00047
00048 std::vector<AttachedDevice> attachedDevices;
00049 int serialNumber;
00050 const char *name;
00051
00052
00053 for (int i = 0; i < count; i++) {
00054 CPhidget_getDeviceName(phidgetList[i], &name);
00055 CPhidget_getSerialNumber(phidgetList[i], &serialNumber);
00056 ROS_INFO("Found %s, with serial: %d", name, serialNumber);
00057
00058 AttachedDevice device{serialNumber, name};
00059 attachedDevices.push_back(device);
00060 }
00061
00062
00063 CPhidgetManager_freeAttachedDevicesArray(phidgetList);
00064
00065 return attachedDevices;
00066 }