capacitor-plugins icon indicating copy to clipboard operation
capacitor-plugins copied to clipboard

Improve acceleration output resolution

Open rzeira opened this issue 2 years ago • 3 comments

Feature Request

Plugin

Motion plugin

Description

Output resolution for acceleration currently goes down to one decimal place (i.e. 10 cm/s^2 at best). The equivalent cordova plugin provides the same acceleration measurement on the same hardware down to several decimal places, as if it was returning the full floating point number. Would it be possible to return the same float with the Capacitor motion plugin?

Preferred Solution

Return full float output from motion plugin.

rzeira avatar Dec 02 '21 18:12 rzeira

At the moment Motion plugin uses the web implementation in all platforms, so only Google and Apple can fix this.

We might consider switching to a native implementation.

jcesarmobile avatar Dec 03 '21 14:12 jcesarmobile

adding more info: In the last week I experienced with Motion API and cordova-plugin-device-orientation as alternatives for getting compass-orientation, and sadly Motion-API is no good for me as alternative right now:

  • In the docs, though the subtitle states "The Motion API tracks accelerometer and device orientation (compass heading, etc.)", in the bottom is looks like you get only relative acceleration and rotation rate and no "compass" feature.
  • Even if Motion-API is implemented exactly like the Web-API, and actually has "compass feature", there are big differences with implementation for different browsers and iOS versions. Check this example
  • Asking for compass permission every launch upon user gesture is not an acceptable UX for me, and shouldn't be for every developer wishes to create native experience
  • cordova-plugin-device-orientation works great out of the box for me, I don't ask for premission over and over, I have really nice and simple method to listen for changes in compass reads with filtering by minimal change in degrees with very accurate resolution!

That's why I think Motion-API should implement native methods to get "devices compass", and even adopt the methods used in the old Cordova's plugin.

My project info: "@capacitor/cli": "3.3.2", "@capacitor/ios": "^3.3.2", "@capacitor/angular": "^2.0.0", "@angular/cli": "^13.1.1", "@capacitor/motion": "^1.0.4", // not in use "cordova-plugin-device-orientation": "^2.0.1",

BTW - Be aware that heading and compass used sometimes interchangeably to describe relative deviation from the magnetic north, while sometimes heading is used to to describe the vector of change in position relative to the north. I'm talking about implementing digital compass in my app and not the other kind of heading.

arielhasidim avatar Jan 04 '22 22:01 arielhasidim

I think native implementation is the right direction. I also think a heading value in addition to the other values can help show the device orientation for navigation apps etc (for example, the one I'm writing) instead of trying to calculate it in JS code... I don't like the fact that device-orientation plugin is deprecated and there's no real alternative (which means I'm using a deprecated software... :-() so it would be extremely helpful to have the motion plugin well supported. If there's something I can do to progress this further let me know, I'll be happy to throw a PR based on the device-orientation code in Cordova...

HarelM avatar Jul 28 '22 18:07 HarelM

I've created a new issue for using native code in motion plugin, so I'm going to close this one in favor of the other one since the only way of improving the acceleration output resolution would be to use native code https://github.com/ionic-team/capacitor-plugins/issues/1192

jcesarmobile avatar Sep 20 '22 16:09 jcesarmobile

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out.

ionitron-bot[bot] avatar Oct 20 '22 17:10 ionitron-bot[bot]