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 data inputs example for compass #67

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

VitaminPSG
Copy link
Contributor

@VitaminPSG VitaminPSG commented Sep 12, 2024

The UXF SDK exposes DataInputsManager interface to allow a client to send sensor data coming from a device (or vehicle) to the UXF navigation engine.

Today, this data is supported by the mentioned API:

  • altimeterData
  • accelerometerData
  • rawGyroscopeData
  • compassData
  • etcGateInfo
  • motionData
  • odometryData
  • rawGnssData

In order to have access to DataInputsManager you should:

  1. Add a corresponding module of UXF SDK in your dependencies:

implementation("com.mapbox.navigationux:data-inputs:1.0.0-beta.37.1")

  1. Enable this functionality in DSL API:
 dataInputs {
     enabled = true
 }
  1. That's it. Now, you can use Data Inputs API via Dash.controller like this:
sampleSensorEventManager?.compassData?.observeWhenStarted(this) {
    if (enabled) {
        Log.d(TAG, "Updating compass data: $it")
        Dash.controller.updateCompassData(it)
    }
}

This PR shows how compass data from an android device can be passed to data input manager.

@VitaminPSG VitaminPSG requested a review from a team as a code owner September 12, 2024 13:49
@VitaminPSG VitaminPSG self-assigned this Sep 12, 2024
@VitaminPSG VitaminPSG marked this pull request as draft September 12, 2024 13:49
@VitaminPSG VitaminPSG changed the title - Add data inputs Add data inputs example for compass Sep 12, 2024
@alexzatsepin alexzatsepin force-pushed the sm/add-data-inputs-and-new-props branch from a876478 to d5d4b01 Compare October 2, 2024 16:23
@alexzatsepin alexzatsepin marked this pull request as ready for review October 2, 2024 16:36
@alexzatsepin
Copy link
Collaborator

@Zayankovsky ptal.

sampleSensorEventManager?.compassData?.observeWhenStarted(this) {
if (enabled) {
Log.d(TAG, "Updating compass data: $it")
Dash.controller.updateCompassData(it)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to reset the data when the switch is unchecked?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No

@VitaminPSG VitaminPSG force-pushed the sm/add-data-inputs-and-new-props branch from dd0dee1 to 1a570a6 Compare October 24, 2024 10:01
Comment on lines 446 to 457
bindSwitch(
switch = menuBinding.customCompassDataInputs,
state = setCustomCompassDataInputs,
) { enabled ->
sampleSensorEventManager?.compassData?.observeWhenStarted(this) {
if (enabled) {
Log.d(TAG, "Updating compass data: $it")
Dash.controller.updateCompassData(it)
}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
bindSwitch(
switch = menuBinding.customCompassDataInputs,
state = setCustomCompassDataInputs,
) { enabled ->
sampleSensorEventManager?.compassData?.observeWhenStarted(this) {
if (enabled) {
Log.d(TAG, "Updating compass data: $it")
Dash.controller.updateCompassData(it)
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants