Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extrapolated prediction to drift compensation #1184

Merged
merged 7 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions gui/public/i18n/en/translation.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,12 @@ settings-general-tracker_mechanics-drift_compensation-description =
Change amount of compensation and up to how many resets are taken into account.
This should only be used if you need to reset very often!
settings-general-tracker_mechanics-drift_compensation-enabled-label = Drift compensation
settings-general-tracker_mechanics-drift_compensation-prediction = Drift compensation prediction
# This cares about multilines
settings-general-tracker_mechanics-drift_compensation-prediction-description =
Predicts yaw drift compensation beyond previously measured range.
Enable this if the tracker is continuously spinning on yaw axis.
settings-general-tracker_mechanics-drift_compensation-prediction-label = Drift compensation prediction
settings-general-tracker_mechanics-drift_compensation_warning =
<b>Warning:</b> Only use drift compensation if you need to reset
very often (every ~5-10 minutes).
Expand Down
3 changes: 3 additions & 0 deletions gui/src/components/onboarding/pages/ConnectTracker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const statusLabelMap = {
'onboarding-connect_tracker-connection_status-none',
[WifiProvisioningStatus.SERIAL_INIT]:
'onboarding-connect_tracker-connection_status-serial_init',
[WifiProvisioningStatus.OPTAINING_MAC_ADDRESS]:
'onboarding-connect_tracker-connection_status-optaining_mac_address',
[WifiProvisioningStatus.PROVISIONING]:
'onboarding-connect_tracker-connection_status-provisioning',
[WifiProvisioningStatus.CONNECTING]:
Expand All @@ -46,6 +48,7 @@ const statusLabelMap = {
const statusProgressMap = {
[WifiProvisioningStatus.NONE]: 0,
[WifiProvisioningStatus.SERIAL_INIT]: 0.2,
[WifiProvisioningStatus.OPTAINING_MAC_ADDRESS]: 0.3,
[WifiProvisioningStatus.PROVISIONING]: 0.4,
[WifiProvisioningStatus.CONNECTING]: 0.6,
[WifiProvisioningStatus.LOOKING_FOR_SERVER]: 0.8,
Expand Down
30 changes: 30 additions & 0 deletions gui/src/components/settings/pages/GeneralSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ interface SettingsForm {
};
driftCompensation: {
enabled: boolean;
prediction: boolean;
amount: number;
maxResets: number;
};
Expand Down Expand Up @@ -139,6 +140,7 @@ const defaultValues: SettingsForm = {
filtering: { amount: 0.1, type: FilteringType.NONE },
driftCompensation: {
enabled: false,
prediction: false,
amount: 0.1,
maxResets: 1,
},
Expand Down Expand Up @@ -283,6 +285,7 @@ export function GeneralSettings() {

const driftCompensation = new DriftCompensationSettingsT();
driftCompensation.enabled = values.driftCompensation.enabled;
driftCompensation.prediction = values.driftCompensation.prediction;
driftCompensation.amount = values.driftCompensation.amount;
driftCompensation.maxResets = values.driftCompensation.maxResets;
settings.driftCompensation = driftCompensation;
Expand Down Expand Up @@ -708,6 +711,33 @@ export function GeneralSettings() {
setShowDriftCompWarning(true);
}}
/>
<div className="flex flex-col pt-2 pb-4"></div>
<Typography bold>
{l10n.getString(
'settings-general-tracker_mechanics-drift_compensation-prediction'
)}
</Typography>
<div className="flex flex-col pt-2 pb-4">
{l10n
.getString(
'settings-general-tracker_mechanics-drift_compensation-prediction-description'
)
.split('\n')
.map((line, i) => (
<Typography color="secondary" key={i}>
{line}
</Typography>
))}
</div>
<CheckBox
variant="toggle"
outlined
control={control}
name="driftCompensation.prediction"
label={l10n.getString(
'settings-general-tracker_mechanics-drift_compensation-prediction-label'
)}
/>
<DriftCompensationModal
accept={() => {
setShowDriftCompWarning(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ class DriftCompensationConfig {
// Is drift compensation enabled
var enabled = false

// Is drift prediction enabled
var prediction = false

// Amount of drift compensation applied
var amount = 0.8f

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public static int createDriftCompensationSettings(
.createDriftCompensationSettings(
fbb,
driftCompensationConfig.getEnabled(),
driftCompensationConfig.getPrediction(),
driftCompensationConfig.getAmount(),
driftCompensationConfig.getMaxResets()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class RPCSettingsHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) {
.vrConfig
.driftCompensation
driftCompensationConfig.enabled = req.driftCompensation().enabled()
driftCompensationConfig.prediction = req.driftCompensation().prediction()
driftCompensationConfig.amount = req.driftCompensation().amount()
driftCompensationConfig.maxResets = req.driftCompensation().maxResets()
driftCompensationConfig.updateTrackersDriftCompensation()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class TrackerResetsHandler(val tracker: Tracker) {
private var driftSince: Long = 0
private var timeAtLastReset: Long = 0
private var compensateDrift = false
private var driftPrediction = false
private var driftCompensationEnabled = false
private var resetMountingFeet = false
private var armsResetMode = ArmsResetModes.BACK
Expand Down Expand Up @@ -78,6 +79,7 @@ class TrackerResetsHandler(val tracker: Tracker) {
*/
fun readDriftCompensationConfig(config: DriftCompensationConfig) {
compensateDrift = config.enabled
driftPrediction = config.prediction
driftAmount = config.amount
val maxResets = config.maxResets

Expand Down Expand Up @@ -186,11 +188,11 @@ class TrackerResetsHandler(val tracker: Tracker) {
*/
private fun adjustToDrift(rotation: Quaternion): Quaternion {
if (driftCompensationEnabled && totalDriftTime > 0) {
return rotation
.interpR(
averagedDriftQuat * rotation,
driftAmount * ((System.currentTimeMillis() - driftSince).toFloat() / totalDriftTime),
)
var driftTimeRatio = ((System.currentTimeMillis() - driftSince).toFloat() / totalDriftTime)
if (!driftPrediction) {
driftTimeRatio = min(1.0f, driftTimeRatio)
}
return averagedDriftQuat.pow(driftAmount * driftTimeRatio) * rotation
}
return rotation
}
Expand Down
2 changes: 1 addition & 1 deletion solarxr-protocol
Submodule solarxr-protocol updated 725 files