FB::variant hapticAPI::getDeviceType() { char type[20]; if (hdPhantomGetType(deviceID, type) == -1) return NotInitializedString; else return type; }
//=========================================================================== cPhantomDevice::cPhantomDevice(unsigned int a_deviceNumber) { // default specification setup m_specifications.m_manufacturerName = "Sensable Technologies"; m_specifications.m_modelName = "PHANTOM"; m_specifications.m_maxForce = 6.0; // [N] m_specifications.m_maxForceStiffness = 1000.0; // [N/m] m_specifications.m_maxTorque = 0.0; // [N*m] m_specifications.m_maxTorqueStiffness = 0.0; // [N*m/Rad] m_specifications.m_maxGripperTorque = 0.0; // [N] m_specifications.m_maxGripperTorqueStiffness = 0.0; // [N*m/m] m_specifications.m_maxLinearDamping = 8.0; // [N/(m/s)] m_specifications.m_workspaceRadius = 0.10; // [m]; m_specifications.m_sensedPosition = true; m_specifications.m_sensedRotation = true; m_specifications.m_sensedGripper = false; m_specifications.m_actuatedPosition = true; m_specifications.m_actuatedRotation = false; m_specifications.m_actuatedGripper = false; m_specifications.m_leftHand = true; m_specifications.m_rightHand = true; // device is not yet available or ready m_driverInstalled = false; m_systemAvailable = false; m_systemReady = false; // check if Phantom drivers installed #if defined(_WIN32) if (m_dllcount == 0) { hdPhantomDriverDLL = LoadLibrary("HD.dll"); if (hdPhantomDriverDLL == NULL) { return; } } // the Phantom drivers are installed m_driverInstalled = true; // load dll library if (m_dllcount == 0) { hdPhantomDLL = LoadLibrary("hdPhantom.dll"); } // check if DLL loaded correctly if (hdPhantomDLL == NULL) { return; } // load different callbacks hdPhantomGetNumDevices = (int (__stdcall*)(void)) GetProcAddress(hdPhantomDLL, "hdPhantomGetNumDevices"); hdPhantomOpen = (int (__stdcall*)(int)) GetProcAddress(hdPhantomDLL, "hdPhantomOpen"); hdPhantomClose = (int (__stdcall*)(int)) GetProcAddress(hdPhantomDLL, "hdPhantomClose"); hdPhantomGetPosition = (int (__stdcall*)(int, double*, double*, double*)) GetProcAddress(hdPhantomDLL, "hdPhantomGetPosition"); hdPhantomGetLinearVelocity = (int (__stdcall*)(int, double*, double*, double*)) GetProcAddress(hdPhantomDLL, "hdPhantomGetLinearVelocity"); hdPhantomGetRotation = (int (__stdcall*)(int, double*, double*, double*, double*, double*, double*, double*, double*, double*)) GetProcAddress(hdPhantomDLL, "hdPhantomGetRotation"); hdPhantomGetButtons = (int (__stdcall*)(int)) GetProcAddress(hdPhantomDLL, "hdPhantomGetButtons"); hdPhantomSetForce = (int (__stdcall*)(int, double*, double*, double*)) GetProcAddress(hdPhantomDLL, "hdPhantomSetForce"); hdPhantomSetTorque = (int (__stdcall*)(int, double*, double*, double*)) GetProcAddress(hdPhantomDLL, "hdPhantomSetTorque"); hdPhantomGetWorkspaceRadius = (int (__stdcall*)(int, double*)) GetProcAddress(hdPhantomDLL, "hdPhantomGetWorkspaceRadius"); hdPhantomGetType = (int (__stdcall*)(int, char*)) GetProcAddress(hdPhantomDLL, "hdPhantomGetType"); hdPhantomStartServo = (void (__stdcall*)(void)) GetProcAddress(hdPhantomDLL, "hdPhantomStartServo"); hdPhantomStopServo = (void (__stdcall*)(void)) GetProcAddress(hdPhantomDLL, "hdPhantomStopServo"); #endif #if defined(_LINUX) // initialize open haptics init(); // the Phantom drivers are installed m_driverInstalled = true; #endif // get the number ID of the device we wish to communicate with m_deviceID = a_deviceNumber; // get the number of Force Dimension devices connected to this computer int numDevices = hdPhantomGetNumDevices(); // check if such device is available if ((a_deviceNumber + 1) > (unsigned int)numDevices) { // no, such ID does not lead to an existing device m_systemAvailable = false; } else { // yes, this ID leads to an existing device m_systemAvailable = true; } // read information related to the device hdPhantomGetWorkspaceRadius(m_deviceID, &m_specifications.m_workspaceRadius); // read the device model char name[255]; hdPhantomGetType(m_deviceID, &name[0]); m_specifications.m_modelName = name; ///////////////////////////////////////////////////////////////////// // Define specifications given the device model ///////////////////////////////////////////////////////////////////// if (m_specifications.m_modelName == "PHANTOM Omni") { m_specifications.m_maxForce = 4.0; // [N] m_specifications.m_maxForceStiffness = 700.0; // [N/m] m_specifications.m_maxLinearDamping = 5.0; // [N/(m/s)] } // increment counter m_dllcount++; }