Start a new topic

[Android Plugin:DeviceMotionInputPluginMotion]What is the DeviceMotionData for DeviceRotationEvent or DeviceOrientationEvent?

Hi.


We are developing an Android application with Wikitude DeviceMotionInputPlutinModule and checked DeviceMotionInputPluginModule.hpp and SensorEvent.hpp.

But we couldn't find any information about DeviceMotionData, DeviceRotationEvent, or DeviceOrientationEvent.

What should we set as DeviceMotionData on calling DeviceMotionInputPluginModule interfaces.


SDK: WikitudeSDK_NativeAPI_Android_9-10-0_2021-08-23_23-36-05


Best regards,

Hironori


Hi,


DeviceMotionData is a 4x4 Matrix struct with rotation or orientation float values and DeviceRotationEvent and DeviceOrientationEvent are just structs containing these 4x4 Matrix. In the end, when you call 

registerNotifyNewDeviceRotationEventHandler(DeviceMotionData callback), the callback will be called each time the device rotates so you have the latest values all the time.


Best regards,

Aitor.

Hi Aitor,


Thank you for your reply.


We are sorry, we would like to develop a plugin to handle a external camera with sensors.

So we are developing a plugin with `CameraFrameInputPluginModule` and `DeviceMotionInputPluginModule`.


when you call 

> registerNotifyNewDeviceRotationEventHandler(DeviceMotionData callback), the callback will be called each time the device rotates so you have the latest values all the time.


I think `registerNotifyNewDeviceRotationEventHandler()` is for comsumers of the `DeviceRotationEvent` and `DeviceOrientationEvent`. But we'd like to develop a `DeviceMotionInputPluginModule` itself as a supplier of the our external sensors.

Finally, we found that calling `notifyNewDeviceRotationEventHandler()` with 4x4 rotation matrix took effect.



Then we found the another trouble. The motion sensor embedded in the smartphone continues to send `DeviceRotationEvent`, the target area switches continuously between depending on our sensors and embeded sensors.

How can we disable the embedded sensors?


Best regards,

Hironori.


Your approach looks correct to me. Could you give me more info of what you are exactly doing?

  • Are you only calling notifyNewDeviceRotationEventHandler() or also calling notifyNewDeviceOrientationEventHandler()?
  • Are the motion sensor embedded values being retrieved in the registerNotifyNewDeviceRotationEventHandler() callback?
  • Which sensor provider are you using in this case?


Best regards,

Aitor.

Aitor,


Thank you for your replies.


Are you only calling notifyNewDeviceRotationEventHandler() or also calling notifyNewDeviceOrientationEventHandler()?


We tried both cases, but got the same result.


> Are the motion sensor embedded values being retrieved in the registerNotifyNewDeviceRotationEventHandler() callback?


We called `registerNotifyNewDeviceRotationEventHandler()` on our DeviceMotionInputPluginModule instance, then the callback received only value of our sensor values.


We saw the comment `/* Called from the Wikitude SDK */` in the DeviceMotionInputPluginModule.h and the `Plugin` class has `deviceRotationEventAvailable()` callback.

So we tried to implement the `deviceRotationEventAvailable()` in the `Plugin` class and received values of both the embedded motion sensor and the our external motion sensor.


> Which sensor provider are you using in this case?


What do you mean the "sensor provider"?


We are receiving the quaternion of the camera device via the USB serial.



Best regards,

Hironori.


Hi,


In the Plugin.h class we also expose the setDeviceMotionInputPluginModule() method which should be used in order to remove the internal DeviceMotionInputPluginModule and use your own one. Did you call this method after creating your DeviceMotionInputPluginModule instance?


Best regards,

Aitor.

Aitor,


> Did you call this method after creating your DeviceMotionInputPluginModule instance?


Yes, we call this method in the constructor of the Plugin class after calling setCameraFrameInputPluginModule(), as the following snippet (we try to modify the SimpleInputPlugin in the Examples/NativeSDKExamples).

SimpleInputPlugin::SimpleInputPlugin() : Plugin("plugin.input.yuv.simple"){ SimpleInputPlugin::instance = this; setCameraFrameInputPluginModule(std::make_unique<MyFrameInputPluginModule>(true /*reguest rendering*/, [&]{ callInitializedJNIMethod(_sdkCameraReleasedMethodId); })); setDeviceMotionInputPluginModule(std::make_unique<MyDeviceMotionInputPluginModule>()); }


Best regards,
Hironori.

Hi,


Everything you are doing seems correct to me, so in order to reproduce your issue locally I would need that you send us the sample code / project. Is that possible?


Thank you,

Aitor.

Aitor,


We made our sample with Examples/NativeSDKExamples in the WikitudeSDK_NativeAPI_Android_9-10-0_2021-08-23_23-36-05.zip, and we attached the sample project as a patch file DeviceMotionInputPluginModule.patch.

Please apply this patch in the Examples/NativeSDKExamples directory.

If you want the whole project, we can publish to the Bitbucket repository.


Please try the Instant Tracking - Simple example, then you could see the green rectangle switching continuously between depending on embeded sensors and our virtual motion value.


Best regards,

Hironor.

Hi,


Thank you very much for the .patch. Now I'm able to reproduce your issue and can confirm that this behaviour is not correct so I'm opening an internal ticket to investigate it as soon as possible. Unfortunately, there's no workaround you can apply to avoid this in the meantime, so I ask you for a little patience from your part. Sorry for the inconvenience.


Best regards,

Aitor.

Aitor,


Thank you for your following and investigating the our trouble.

We expect that this trouble will be fixed.


Best regards,

Hironori.


Login or Signup to post a comment