| 82 | } // namespace |
| 83 | |
| 84 | static void createYEIImpl(VRPNMultiserverData &data, OSVR_PluginRegContext ctx, |
| 85 | Json::Value const &root, std::string port) { |
| 86 | if (port.empty()) { |
| 87 | throw std::runtime_error( |
| 88 | "Could not create a YEI device: no port specified!."); |
| 89 | } |
| 90 | port = normalizeAndVerifySerialPort(port); |
| 91 | |
| 92 | bool calibrate_gyros_on_setup = |
| 93 | root.get("calibrateGyrosOnSetup", false).asBool(); |
| 94 | bool tare_on_setup = root.get("tareOnSetup", false).asBool(); |
| 95 | double frames_per_second = root.get("framesPerSecond", 250).asFloat(); |
| 96 | |
| 97 | Json::Value commands = root.get("resetCommands", Json::arrayValue); |
| 98 | CStringArray reset_commands; |
| 99 | |
| 100 | if (commands.empty()) { |
| 101 | // Enable Q-COMP filtering by default |
| 102 | reset_commands.push_back("123,2"); |
| 103 | } else { |
| 104 | for (Json::ArrayIndex i = 0, e = commands.size(); i < e; ++i) { |
| 105 | reset_commands.push_back(commands[i].asString()); |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | osvr::vrpnserver::VRPNDeviceRegistration reg(ctx); |
| 110 | |
| 111 | reg.registerDevice(new vrpn_YEI_3Space_Sensor( |
| 112 | reg.useDecoratedName(data.getName("YEI_3Space_Sensor")).c_str(), |
| 113 | reg.getVRPNConnection(), port.c_str(), 115200, calibrate_gyros_on_setup, |
| 114 | tare_on_setup, frames_per_second, 0, 0, 1, 0, |
| 115 | reset_commands.get_array())); |
| 116 | reg.setDeviceDescriptor( |
| 117 | osvr::util::makeString(com_osvr_Multiserver_YEI_3Space_Sensor_json)); |
| 118 | } |
| 119 | |
| 120 | void createYEI(VRPNMultiserverData &data, OSVR_PluginRegContext ctx, |
| 121 | const char *params) { |
no test coverage detected