diff --git a/external/vendor/Amethyst_API_Devices.h b/external/vendor/Amethyst_API_Devices.h index 72e9bce..9f96c67 100644 --- a/external/vendor/Amethyst_API_Devices.h +++ b/external/vendor/Amethyst_API_Devices.h @@ -31,7 +31,7 @@ inline std::wstring StringToWString(const std::string& str) { const int count = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.length(), nullptr, 0); std::wstring w_str(count, 0); - MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.length(), &w_str[0], count); + MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.length(), w_str.data(), count); return w_str; } @@ -40,14 +40,14 @@ inline std::string WStringToString(const std::wstring& w_str) { const int count = WideCharToMultiByte(CP_UTF8, 0, w_str.c_str(), w_str.length(), nullptr, 0, nullptr, nullptr); std::string str(count, 0); - WideCharToMultiByte(CP_UTF8, 0, w_str.c_str(), -1, &str[0], count, nullptr, nullptr); + WideCharToMultiByte(CP_UTF8, 0, w_str.c_str(), -1, str.data(), count, nullptr, nullptr); return str; } namespace ktvr { // Interface Version - static const char* IAME_API_Devices_Version = "IAME_API_Version_018"; + static const char* IAME_API_Devices_Version = "IAME_API_Version_020"; // Return messaging types enum K2InitErrorType @@ -135,6 +135,9 @@ namespace ktvr [[nodiscard]] Eigen::Vector3d getJointPosition() const { return jointPosition; } [[nodiscard]] Eigen::Quaterniond getJointOrientation() const { return jointOrientation; } + [[nodiscard]] Eigen::Vector3d getPreviousJointPosition() const { return previousJointPosition; } + [[nodiscard]] Eigen::Quaterniond getPreviousJointOrientation() const { return previousJointOrientation; } + [[nodiscard]] Eigen::Vector3d getJointVelocity() const { return jointVelocity; } [[nodiscard]] Eigen::Vector3d getJointAcceleration() const { return jointAcceleration; } @@ -151,8 +154,12 @@ namespace ktvr Eigen::Quaterniond orientation, const ITrackedJointState state) { + previousJointPosition = jointPosition; + previousJointOrientation = jointOrientation; + jointPosition = std::move(position); jointOrientation = std::move(orientation); + trackingState = state; // Update pose timestamp @@ -169,6 +176,9 @@ namespace ktvr Eigen::Vector3d angularAcceleration, const ITrackedJointState state) { + previousJointPosition = jointPosition; + previousJointOrientation = jointOrientation; + jointPosition = std::move(position); jointOrientation = std::move(orientation); @@ -187,6 +197,7 @@ namespace ktvr // For servers! void update_position(Eigen::Vector3d position) { + previousJointPosition = jointPosition; jointPosition = std::move(position); // Update pose timestamp @@ -197,6 +208,7 @@ namespace ktvr // For servers! void update_orientation(Eigen::Quaterniond orientation) { + previousJointOrientation = jointOrientation; jointOrientation = std::move(orientation); } @@ -235,6 +247,9 @@ namespace ktvr Eigen::Vector3d jointPosition = Eigen::Vector3d(0., 0., 0.); Eigen::Quaterniond jointOrientation = Eigen::Quaterniond(1., 0., 0., 0.); + Eigen::Vector3d previousJointPosition = Eigen::Vector3d(0., 0., 0.); + Eigen::Quaterniond previousJointOrientation = Eigen::Quaterniond(1., 0., 0., 0.); + Eigen::Vector3d jointVelocity = Eigen::Vector3d(0., 0., 0.); Eigen::Vector3d jointAcceleration = Eigen::Vector3d(0., 0., 0.); @@ -242,6 +257,7 @@ namespace ktvr Eigen::Vector3d jointAngularAcceleration = Eigen::Vector3d(0., 0., 0.); ITrackedJointState trackingState = State_NotTracked; + long long poseTimestamp = 0; long long previousPoseTimestamp = 0; }; diff --git a/external/vendor/Amethyst_API_Paths.h b/external/vendor/Amethyst_API_Paths.h index 0ab3517..3cb9762 100644 --- a/external/vendor/Amethyst_API_Paths.h +++ b/external/vendor/Amethyst_API_Paths.h @@ -16,9 +16,11 @@ namespace ktvr // Get file location in AppData inline std::wstring GetK2AppDataFileDir(const std::wstring& relativeFilePath) { - CreateDirectory(std::wstring(std::wstring(_wgetenv(L"APPDATA")) + - L"\\Amethyst\\").c_str(), nullptr); - return std::wstring(_wgetenv(L"APPDATA")) + L"\\Amethyst\\" + relativeFilePath; + std::filesystem::create_directories( + std::wstring(_wgetenv(L"APPDATA")) + L"\\Amethyst\\"); + + return std::wstring(_wgetenv(L"APPDATA")) + + L"\\Amethyst\\" + relativeFilePath; } // Get file location in AppData @@ -26,9 +28,9 @@ namespace ktvr const std::wstring& relativeFolderName, const std::wstring& relativeFilePath) { - CreateDirectory( - std::wstring(std::wstring(_wgetenv(L"APPDATA")) + - L"\\Amethyst\\logs\\" + relativeFolderName + L"\\").c_str(), nullptr); + std::filesystem::create_directories( + std::wstring(_wgetenv(L"APPDATA")) + + L"\\Amethyst\\logs\\" + relativeFolderName + L"\\"); return std::wstring(_wgetenv(L"APPDATA")) + L"\\Amethyst\\logs\\" + relativeFolderName + L"\\" + relativeFilePath;