Skip to content

Commit

Permalink
Add relative pose lock, use slow preset again
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcticFox8515 committed May 21, 2024
1 parent 3b8ea60 commit d015985
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 8 deletions.
13 changes: 10 additions & 3 deletions OpenVR-SpaceCalibrator/Calibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,17 @@ void StartCalibration()
}

void StartContinuousCalibration() {
CalCtx.calibrationSpeed = CalibrationContext::FAST;
CalCtx.calibrationSpeed = CalibrationContext::SLOW;
StartCalibration();
CalCtx.state = CalibrationState::Continuous;
calibration.setRelativeTransformation(CalCtx.refToTargetPose, CalCtx.relativePosCalibrated);
CalCtx.Log("Collecting initial samples...");
calibration.lockRelativePosition = CalCtx.lockRelativePosition;
if (CalCtx.lockRelativePosition) {
CalCtx.Log("Relative position locked");
}
else {
CalCtx.Log("Collecting initial samples...");
}
Metrics::WriteLogAnnotation("StartContinuousCalibration");
}

Expand Down Expand Up @@ -480,6 +486,7 @@ void CalibrationTick(double time)
if (CalCtx.state == CalibrationState::Continuous) {
CalCtx.messages.clear();
calibration.enableStaticRecalibration = CalCtx.enableStaticRecalibration;
calibration.lockRelativePosition = CalCtx.lockRelativePosition;
ok = calibration.ComputeIncremental(lerp, CalCtx.continuousCalibrationThreshold);
}
else {
Expand Down Expand Up @@ -522,7 +529,7 @@ void CalibrationTick(double time)
calibration.Clear();
}
else {
for (int i = 0; i < 10; i++) calibration.ShiftSample();
for (int i = 0; i < 50; i++) calibration.ShiftSample();
}
}
}
Expand Down
1 change: 1 addition & 0 deletions OpenVR-SpaceCalibrator/Calibration.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct CalibrationContext

protocol::AlignmentSpeedParams alignmentSpeedParams;
bool enableStaticRecalibration;
bool lockRelativePosition = false;

Eigen::AffineCompact3d refToTargetPose = Eigen::AffineCompact3d::Identity();
bool relativePosCalibrated = false;
Expand Down
15 changes: 15 additions & 0 deletions OpenVR-SpaceCalibrator/CalibrationCalc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,13 +524,28 @@ bool CalibrationCalc::ComputeIncremental(bool &lerp, double threshold) {

Metrics::RecordTimestamp();

if (lockRelativePosition) {
Eigen::AffineCompact3d byRelPose;
double relPoseError = INFINITY;
Eigen::Vector3d relPosOffset;
CalibrateByRelPose(byRelPose);
ValidateCalibration(byRelPose, &relPoseError, &relPosOffset);
Metrics::posOffset_byRelPose.Push(relPosOffset * 1000);
Metrics::error_byRelPose.Push(relPoseError * 1000);

m_isValid = true;
m_estimatedTransformation = byRelPose;
return true;
}

double priorCalibrationError = INFINITY;
Eigen::Vector3d priorPosOffset;
if (m_isValid) {
ValidateCalibration(m_estimatedTransformation, &priorCalibrationError, &priorPosOffset);

Metrics::posOffset_currentCal.Push(priorPosOffset * 1000);
Metrics::error_currentCal.Push(priorCalibrationError * 1000);

if (priorCalibrationError < 0.005) {
return false;
}
Expand Down
1 change: 1 addition & 0 deletions OpenVR-SpaceCalibrator/CalibrationCalc.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class CalibrationCalc {
static const double AxisVarianceThreshold;

bool enableStaticRecalibration;
bool lockRelativePosition = false;

const Eigen::AffineCompact3d Transformation() const
{
Expand Down
4 changes: 4 additions & 0 deletions OpenVR-SpaceCalibrator/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ static void ParseProfile(CalibrationContext &ctx, std::istream &stream)
if (obj["relative_pos_calibrated"].is<bool>()) {
ctx.relativePosCalibrated = obj["relative_pos_calibrated"].get<bool>();
}
if (obj["lock_relative_position"].is<bool>()) {
ctx.lockRelativePosition = obj["lock_relative_position"].get<bool>();
}
if (obj["relative_transform"].is<picojson::object>()) {
auto relTransform = obj["relative_transform"].get<picojson::object>();
Eigen::Vector3d refToTragetRoation;
Expand Down Expand Up @@ -247,6 +250,7 @@ static void WriteProfile(CalibrationContext &ctx, std::ostream &out)
refToTarget["yaw"].set<double>(refToTragetRoation(1));
refToTarget["pitch"].set<double>(refToTragetRoation(2));
profile["relative_pos_calibrated"].set<bool>(ctx.relativePosCalibrated);
profile["lock_relative_position"].set<bool>(ctx.lockRelativePosition);
profile["relative_transform"].set<picojson::object>(refToTarget);

picojson::value profileV;
Expand Down
6 changes: 4 additions & 2 deletions OpenVR-SpaceCalibrator/UserInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,13 @@ void CCal_BasicInfo() {
ImGui::EndTable();
}

ImGui::Checkbox("Hide target device from application", &CalCtx.quashTargetInContinuous);
ImGui::Checkbox("Hide tracker", &CalCtx.quashTargetInContinuous);
ImGui::SameLine();
ImGui::Checkbox("Enable static recalibration", &CalCtx.enableStaticRecalibration);
ImGui::Checkbox("Static recalibration", &CalCtx.enableStaticRecalibration);
ImGui::SameLine();
ImGui::Checkbox("Enable debug logs", &Metrics::enableLogs);
ImGui::SameLine();
ImGui::Checkbox("Lock relative transform", &CalCtx.lockRelativePosition);

// Status field...

Expand Down
6 changes: 3 additions & 3 deletions Version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#pragma once

#define SPACECAL_VERSION_STRING "1.4-bd_-af-r6"
#pragma once

#define SPACECAL_VERSION_STRING "1.4-bd_-af-r7"
Binary file removed install/OpenVR-SpaceCalibrator - Copy.exe
Binary file not shown.
Binary file removed install/OpenVR-SpaceCalibrator - static v0.exe
Binary file not shown.

1 comment on commit d015985

@dirtball-official
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds awesome!!

TLDR; observations, use cases, hopes

I use a slightly modified Pico Neo 3 (not Pico Neo 3 Link) with Virtual Desktop, Index controllers, and 10 Vive 3.0 trackers. I need to upgrade to a better headset, but it gets the job done for now. One tracker is mounted on the front of the headset and used with TrackerOverride in SteamVR. I'm using the SteamVR chaperone, as the Pico guardian isn't triggered by Index controllers.

I primarily need this software because the image view in the Pico is always spun and flipped to some strange and disorienting angle & rotation when first starting a VR session. It's usually different so I can't set manual tracker offsets. SpaceCalibrator in continuous mode corrects this within seconds.

For me, the ideal sequence of events is as follows:

  • SpaceCalibrator starts as usual, with Continuous Calibration running.
  • 2nd & 3rd rotation offsets (pitch and roll I think??? I can't look right now) under "Edit Calibration" would be rounded off to bigger fractions of a circle. They're often some fraction very close to +/-180 or +/-90 and I'd prefer whole, round numbers. The first (I think yaw??) is good as is.
  • SteamVR chaperone would consistently align with base stations / IRL room. Room setup as done with an Index headset does not match the Pico w/ SpaceCalibrator. I've had no luck with copy/paste in SpaceCalibrator or profiles in OpenVR-AdvancedSettings. I use ChaperoneTweak at the start of every session which works, but takes time.
  • Calibration would then stop unless the Pico image view tracking has shifted/rotated. Then recalibrate (with values rounded as mentioned above) and stop. It sounds like this commit may handle this issue, at least the calibration stop portion. I'm looking forward to testing!

Thanks so much for your work, and for reading the novel above! I couldn't enjoy VR nearly as much without it. I'd love to test and provide feedback at any point if that would aid development.

Please sign in to comment.