Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

GyroDroid - Access each and every sensor on Android devices [RELEASED]

Discussion in 'Assets and Asset Store' started by pfc, Aug 19, 2011.

  1. Nub3h

    Nub3h

    Joined:
    Aug 23, 2012
    Posts:
    56
    Hi,
    I'm trying the plugin on iOS and I noticed that the compass demo isn't working. North and South remain at the same position even though they move a bit when I point the device somewhere else. Any way to fix this? I'm testing on an iPad 3 running 6.1. Thanks.
     
  2. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    @boriel, Nub3h: please send a mail, so we can coordinate beta iOS testing. Thanks!
    Question at all: have you tried iOS support, what happened, what worked, what didn't?
     
  3. Nub3h

    Nub3h

    Joined:
    Aug 23, 2012
    Posts:
    56

    e-mail sent ;)
     
  4. parthdarji

    parthdarji

    Joined:
    Jun 30, 2012
    Posts:
    14
    Hey, I'm using the version 3 of the plugin and I'm not being able to replicate the exact same functionality like the app on the Android market. When I run the app from the demo scene (as is, without any changes), the camera shows different behavior than the app on the store. The Rotation&Orientation is different than the "Rotation Vector". And when I test on the Tab 2 (which doesn't have the gyro), the app on the store works perfect, but the app that I load shows the scene tilted to 90 degrees.

    Is there anything I'm missing out on setup? Please let me know. Thanks.
     
  5. petak_core

    petak_core

    Joined:
    Nov 19, 2012
    Posts:
    57
    Hi pfc,

    I have some trouble about your great asset Gyrodorid. I tested gyrodorid v. 3.2 on our second device Acer Iconia Tab A1-810 (Android 4.2.2.) and it doesn't function. The Gyrodorid / rotation Vector was doing nothing :(

    So I upragrade Gyrodorid on new version 4.0 and Gyrodroid was able to work but only in Y axis.

    This behaviour is the same for my application and the same for your application na Google Play

    So I think it's no "your side" can you look at this and let me know. Thanks.

    Ps.
    Some screenshots from Gyrodoid app:
    $Screenshot_2013-09-18-14-33-32.png $Screenshot_2013-09-18-14-33-39.png $IMG_20130918_143707.jpg
     
  6. Dadaze

    Dadaze

    Joined:
    Sep 21, 2012
    Posts:
    24
    I'm sorry to bother but I really don't have any concise term for this issue.

    I'm making a game that uses gyroscope and I'm using the gravity value which is all fine, so I'm testing on a phone (Galaxy S3): I need to switch the X to Y and vice-versa, so I do this, it works great with little adjustments. I'm testing on another phone (Nexus 10 tablet), the X and Y are switched compared to the galaxy, so not every device has the same gyroscope coordinates, is there a way to unify them and make it all work nice?

    My game needs a landscape orientation and left to right tilting.
     
  7. mnaulet

    mnaulet

    Joined:
    Jan 22, 2013
    Posts:
    16
    Hi
    I've bought today the plugin.
    I test on my tablett (sony Xperia z) with unity.
    I put a model on my scene and I want to rotate my camera with gyroscope.

    It' works but, sometimes, when I'm rotate, my object is moving and don't stay at the same place.
    I don't think it's a performance issue because may tablett is powerful and my model is only a cube.

    I'm trying to decrease the gyro update interval but I obtain the same result.

    Can you help me ?

    Thanks
     
  8. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    @bik3r014: Yes, there are indeed some more issues not adressed by the current GyroDroid release that are broken since Unity 4.1, sorry for that. We have a fix internally but not yet ready for release, but we hope to release it soon.

    @_petak_: We'll look into that, your device seems to have even worse sensor support than most others.

    @DaJuice: You shouldn't simply "swap axes", normally you should rotate the vector so it fits your usecase. GyroDroid attempts to unify the way your app gets the rotation quaternion, but that doesn't necesserily mean that the euler rotations are identical and swappable. Or, your issue might be related to bik3e014's, than a fix will be released soon.

    @mnaulet: This sounds like you should calibrate your device by swinging it around you in an eight-like fashion multiple times (that's the official way to calibrate device sensors on Android). If this doesn't help, try a restart of your device; we had a few cases were that reset the sensors and made them work like they used to do again.
     
  9. Dadaze

    Dadaze

    Joined:
    Sep 21, 2012
    Posts:
    24
    Okay yes, I think both my and bik3r014's issues are connected, I'd gladly rotate the quaternion, but I find no way to efficiently rotate it, I tried using Accelerometer coords and matching them with the gyro then repositioning the gyro with it, but there can be abiguity and it ruins the match... Anyway I hope it will be fixed/unified soon and thanks for the fine product!
     
  10. kolchaud

    kolchaud

    Joined:
    Apr 25, 2012
    Posts:
    28
    Hi PFC,

    I'm testing my project using Gyrodroid (last version) with Android Tablet and Iphone.
    Results : It works fine with Android. and I encounter troubles on Iphone.

    When I start the application my device is put on table :
    * With Android Tablet my camera looks to the ground. Correct behavior. When I take the device in hands, the gyro instrument works fine.
    * With Iphone, my camera looks to forward direction, but it's like my camera lay down the ground. When I take the device in hands, the camera has 90deg (Z-axis) from the correct view.

    My minimal sensor script is :

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class MinimalSensorCamera : MonoBehaviour {
    5.  
    6.     private Quaternion initialCameraRotation = Quaternion.identity;
    7.    
    8.     // Use this for initialization
    9.     void Start () {
    10.         initialCameraRotation = transform.rotation;
    11.         SensorHelper.ActivateRotation();
    12.         useGUILayout = false;
    13.     }
    14.     // Update is called once per frame
    15.     void Update () {   
    16.         transform.rotation = initialCameraRotation * SensorHelper.rotation;
    17.     }
    18.     // Script activation
    19.     void OnEnable()
    20.     {
    21.         initialCameraRotation = transform.rotation * Quaternion.Inverse(SensorHelper.rotation);
    22.     }
    23. }
    You give me this code, because I give the choice to user to move the camera with other controls. So I disable the gyro when users use controls. When they stop, it enables the script and it applies a correction to the rotation, because of user movements.


    Any suggestion on the difference between Android and Iphone initial rotation ?

    Thanks in advance !
     
    Last edited: Oct 16, 2013
  11. falantar14

    falantar14

    Joined:
    Jun 7, 2013
    Posts:
    3
    I'm not sure if I'm doing something wrong but I am not experience good results... I've done everything you've said and the object does not stay in the same place, not even close. It even drifts when I'm not moving the camera.
     
  12. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    @falantar14: Drift usually occurs if your device isn't properly calibrated. Some options here:
    • rotate your device slowly around you in an eight-like fashion. This forces the sensors to recalibrate, because they see every possible rotational value. Normally, this happens through standard use, but especially if testing the same movement over and over the calibration can become off.
    • restart your device. Also in heavy-testing/heavy-use scenarios, we noticed a few devices where the sensors seem to break. A restart solves this problem immediately. We never heard that from users before, just for our test rigs.
    • finally, it may be that your device doesn't have a good implementation of RotationVector sensor. Do the sample scenes work as expected? Does the GyroDroid app from Play Store work as expected? If NO, you can still force GyroDroid to use the Orientation Sensor instead of RotationVector.
     
  13. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,080
    Turntable does not seem to work on iOS 7 / iPhone 5S and iOS6 iPad 4 - also tried with your turntable example ... There seems to be a Plugins/Android folder but where is the Plugins/iOS folder?
     
  14. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    @ina: sent you a pm.
     
  15. HolgerTabiiii

    HolgerTabiiii

    Joined:
    Aug 24, 2013
    Posts:
    4
    is it possible to set delay to Type fastest?
     
  16. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    @HolgerTabiiii: That shouldn't be necessary. "Game", the default mode, is already 60fps and thus at least as fast as Unity runs anyways.
    But nonetheless, yes, you can: take a look at

    Sensor.Activate(Type sensorID, Sensor.Delay sensorSpeed = Sensor.Delay.Game)

    - the last parameter is, by default, "Game", but you can change it. Note that you won't get updates any faster, as Unity pulls the values from native code. Depending on your internal sensors, values could still be smoother.
     
  17. Cheshire Cat

    Cheshire Cat

    Joined:
    Sep 18, 2012
    Posts:
    39
    Hi pfc,
    Have been using yous asset for a month, Turntable script works just out of the box, great work. The only issue it seems to have is a drift with a rotation around y-axis (Samsung Galaxy 3, Android 4.2-4.3). The camera has a constant drift right when in portrait mode, and a 90 degrees left when in landscape mode.
    The last happens always, while a drift in a portrait mode depends on the initial device position - it may be less or more.
    Please advise,
    10x, Ilya
     
  18. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    @Cheshire Cat: we'll be looking into it as soon as possible. There are reports of things being offset on some combinations of Unity/Android versions.
     
  19. Cheshire Cat

    Cheshire Cat

    Joined:
    Sep 18, 2012
    Posts:
    39
    @pfs,
    Hi, looking forward for the fix. Till then, is it possible to disable y-axis rotation in some way?
     
  20. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    @Cheshire Cat, just set the eulerAngles.y value to 0 after getting the rotation value from GyroDroid.
     
  21. Cheshire Cat

    Cheshire Cat

    Joined:
    Sep 18, 2012
    Posts:
    39
    @pfc
    Fine, it works. Another issue: when someone holds a phone in hand, a slight tremor is seen, because the script reacts to every single little change of the sensor. Is it possible to make sensors, especially in Turntable script, less sensitive?

    10x
     
  22. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    @Cheshire Cat
    Sure, you can dampen the values like every other values in Unity, using a Lerp:
    At the beginning of the Update method:
    Code (csharp):
    1. Quaternion tempRotation = transform.rotation;
    At the end of the Update method:
    Code (csharp):
    1. transform.rotation = Quaternion.Lerp(tempRotation, transform.rotation, smoothness);
    With some public smoothness float you can change from the outside.
     
  23. Cheshire Cat

    Cheshire Cat

    Joined:
    Sep 18, 2012
    Posts:
    39
    Thanks, that worked too. Another question: how is it possible to add an constant offset to one of the axises, in order to set horizon line, for example? The following obvious code
    Code (csharp):
    1.  
    2.         //Z offset
    3.         fullEulerAngles = transform.eulerAngles;
    4.         float zOffset = SettingsManager.Instance.getCurrentAgOffsettFactor();
    5.         Vector3 zAxisCorrectedEulerAngle = new Vector3(fullEulerAngles.x, fullEulerAngles.y, fullEulerAngles.z - zOffset);
    6.         transform.eulerAngles = zAxisCorrectedEulerAngle;
    7.  
    at the end of the Update() causes constant rotation of the camera around z axis. What do I miss?
     
  24. AlexSien

    AlexSien

    Joined:
    Jun 18, 2013
    Posts:
    3
    I am currently using your MinimalSensorCameraScript and trying to limit the rotation of the camera link to the gyroscope. I just want the gyroscope add a very small effect to camera (about few degree of amplitude).

    I already made a small script for that but the result is not very efficient, the camera was often blocking in an inelegant way.

    Code (csharp):
    1.  
    2. if (Quaternion.Angle (gyroTransform.rotation, transform) <= limitAngle)
    3.         {
    4.             transform.rotation = Quaternion.Slerp (transform.rotation, gyroTransform.rotation, Time.deltaTime * damping) ;
    5.         }
    6.  
    Is somebody has found a simple and fluid way to limit the rotation of a camera link to the gyroscope?
     
    Last edited: Feb 18, 2014
  25. NinjaDesigns

    NinjaDesigns

    Joined:
    Nov 22, 2013
    Posts:
    6
    PFC- So i just bought the package and have been going through the DemoScenes and they look like everything I would be looking for except when I open the Build Settings, the Build and Run button is greyed out and the Export Button next to it is lit. I dont have a lot of experience since Im new to Android and Unity but Ive never had this issue before trying to upload to Android.

    Thoughts on why this is happening?
     
  26. NinjaDesigns

    NinjaDesigns

    Joined:
    Nov 22, 2013
    Posts:
    6
    PFC- Everything is working fine now, after much troubleshooting the simple solution was a hard reset of my PC and i was able to load everything onto my Galaxy S4 Active.

    QUESTION:
    How could I go about displaying the Bearing of the Compass? Was thinking if it showed just in a GUI Text box in the top right corner, how would I go about doing this?

    This Package gets 5 Stars!
     
  27. guythrep

    guythrep

    Joined:
    Jun 7, 2013
    Posts:
    1
    Hi, this is a very good plugin, i have a question, there is a way using the sensors of move the camera in the XYZ axes? if it's possible how i can do it?
     
    Last edited: Mar 28, 2014
  28. merrill.roller

    merrill.roller

    Joined:
    Jul 2, 2012
    Posts:
    2
    Hi, this is a great plugin. I have been using it for a while, but now I need access to the latest Android sensors released in 4.3 and 4.4 (specifically Geomagnetic Rotation Vector and Game Rotation Vector but it would be nice to have support for all of the new sensors).

    Is there any way to add support for the sensors that have been released since Gyrodroid was developed? Are you planning on updating it to support the latest sensors?

    Thanks!
     
  29. mcchiu

    mcchiu

    Joined:
    Apr 14, 2014
    Posts:
    5
    When importing this asset, it always hangs and can never import gyro_droid.fbx. I have to nuke Unity from task manager and start it up again.
     
  30. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    @all: sorry for the delay, lot of busy things going on. But be assured that the next project in our pipeline to work on and improve is GyroDroid!

    @CheshireCat, AlexSien: that should be solved now (we were in PM/mail contact).

    @NinjaDesigns: Sure, sounds like a possible solution. Glad that you like GyroDroid!

    @guythrep: just take a look at the SuperDroid sample, that should give you a hint on how to move an object according to sensor data. There are of course other ways, but it should give you a starting point.

    @merrill.roller: This is on our list for the next update, which will be in the next weeks. Sure we are planning to update it!

    @mcchiu: What Unity version are you using? We never had this issue before, would be good if you can tell a bit more about what's happening.
     
  31. mcchiu

    mcchiu

    Joined:
    Apr 14, 2014
    Posts:
    5
    I'm using 4.3.4f1. I don't know much about what is happening beyond the fact that it is hanging when the progress bar says "DemoSceneAssets\Prefabs\gyro_droid.FBX" every single time it happens. The scripts and such work fine, though.
     
  32. darkmax

    darkmax

    Joined:
    Feb 21, 2012
    Posts:
    83
    I'm having problems with the compass orientation on ios, if you load the compass escene on the examples on ios devices the arrow never rotates like it should.
     
  33. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    @mcchiu: Maybe you should do a bug report to Unity, as you're the only one reporting such behaviour (and for us it's also working).

    @darkmax: What devices, what kind of problems? Compass works, but wrong orientation? Compass does not do anything? Orientation reversed?
     
  34. darkmax

    darkmax

    Joined:
    Feb 21, 2012
    Posts:
    83
    Devices, I'm trying with iphone 4, ipad 2 generation, and ipad 3 generation, if you run the compass scene the red arrow always points to north, if I Roll the tablet it moves a little but not too much, but if I move on yaw the tablet doesn't move like it should.

    This only happen when I tried on this ios devices, on the android devices it works like it should.
     
    Last edited: May 20, 2014
  35. darkmax

    darkmax

    Joined:
    Feb 21, 2012
    Posts:
    83
    On your IOS devices doesn't show what I mention? or is only this happening on my devices?
     
  36. elray

    elray

    Joined:
    May 23, 2014
    Posts:
    1
    We are using Gyrodroid with Vuforia AR. It works great on Android devices and we could find very useful guidance on the forums, how we should integrate it.
    Now we are trying to make it work on iOS, and we are aware that it is not 100% supported at the moment. Does anybody knows some updates or tips, what features or methods we should use, to enable it? We tried the same way, as we did it for Android and it didn't work on iPhone 4/iPad2.

    We were following this forum of the Vuforia integration:
    http://forum.unity3d.com/threads/10...every-sensor-on-Android-devices-RELASED/page8
     
  37. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    @darkmax: Unfortunately, we don't have that much iOS devices for testing, this is why it's still labeled as "experimental". For iOS, we right now directly access the underlying Unity methods for sensor access, so there's not much we can do (despite trying to fix rotation offsets). If you find the right offsets, feel free to post them here, then we can implement them for next release!

    @elray: answered your e-Mail already, sorry for the delay.
     
  38. Rainking

    Rainking

    Joined:
    Jun 10, 2013
    Posts:
    41
    I got an issue which is very annoying. After updating to Android 4.4 the framerate drops a lot with this plugin - it is now unusable! Even the example App from Playstore (GyroDroid) has big performance issues on my device. My application is running smoothly without the plugin, but in the moment i activate it, the framerate drops to 1 - 15 fps. The Unity Profiler says 85% Overhead when i activate the plugin.

    My Setup:
    - Unity Pro 4.3.4f1
    - Samsung Note 3
    - Android 4.4.2

    Seems to be connected to Android version 4.4.2. I installed the Playstore example from GyroDroid also on my girlfriends mobile (Nexus 4 with 4.4.2) and it has some major performance problems.

    Is anyone experiencing the same issues? Some weeks ago I wrote a short description of my problem to the developer but I did not recieve a response yet.


    Kind regards, Tino
     
    Last edited: May 31, 2014
  39. amrhsn

    amrhsn

    Joined:
    Nov 20, 2012
    Posts:
    17
    1) I read your tutorial on embedding Gyrodroid with Vuforia engine. How is that different than using the "Extended tracking" feature that comes with Vuforia?
    2) Did anyone try it with Windows Phone 8? Will it work?
     
  40. darkmax

    darkmax

    Joined:
    Feb 21, 2012
    Posts:
    83
    I'm not an expert, maybe pfc can answer this much better, but I think the difference between gyrodroid approach and vuforia extended tracking is that vuforia tracks the environment something like "slam tracking", while gyrodroid uses compass and accelerometer to help the device to maintain the position of the augmented object when you are not detecting the image.
    Both methods helps to make more robust the track, just they use different approach. Also when the tutorial was made I think extended tracking wasn't available.

    About windows phone 8 I have no idea if it works, pfc is the one that can answer you this or an user who has windows phone 8 and tried to use this plugin with it. But on the description of the plugin, it never mention that windows phone 8 is supported, so I think is not supported.
     
  41. ronjart

    ronjart

    Joined:
    May 16, 2013
    Posts:
    100
    Can anyone confirm this woks with unity free?
     
  42. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    We just submitted a new version of GyroDroid to the AssetStore. This includes new features such as support for all the new sensors, more iOS support and using the all-new Unity Remote 4 for debugging in the editor (finally!).

    @Rainking: That seems strange, never noticed such performance drops (Unity 4.5 works fine as far as we tested). The new version of GyroDroid should be online in a couple of days, please test then and report your findings.

    @amrhsn, @darkmax: first thanks darkmax, everything you wrote is correct :). When we wrote that tutorial, there was no Extended Tracking. Extended Tracking uses "environment features" and is thus not working so good for changing environments (e.g. on a train, outside, with people moving). Also, it uses a lot of processing power, because a complete processing of every frame for depth clues etc. has to happen. GyroDroid only uses sensor information, which, depending on your device, is as good as using visual clues for simple cases (not moving around while the target is not in view) and uses no additional processing power. All in all, it depends on your usecase which way is better suited.
    Windows Phone 8 is not directly supported, but you should be able to use the included device-specific code structure to make some sensors (e.g. rotation) work cross-platform.

    @ronjart: Yes, it works with Unity free.
     
    amrhsn likes this.
  43. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    Hi everyone,

    the update to GyroDroid 5 is now available in the Asset Store.

    New features and fixes:
    • added all current Android sensors:
      • Magnetic Field (uncalibrated)
      • Gyroscope (uncalibrated)
      • Game Rotation Vector
      • Step Detector
      • Step Counter
      • Geomagnetic Rotation Vector
    • multiplatform fixes for iOS/Android to accomodate for newer versions
    • added some buttons for manual screen rotation in demo scenes
    • added statistics framework to find out percentage values for real world sensor usage (you can opt-out, see ReadMe)
    • added support for Unity Remote 5 (for acceleration and rotation vector)
    The statistics framework completely works in the background and helps us make GyroDroid better, finally we have a way to see sensor usage, sensor manufacturers et cetera without asking hundreds of people manually.

    You can easily opt-out of this completely by adding NO_GYRODROID_STATISTICS to your list of Platform Custom Defines under "Player Settings > Other Settings", see the unity docs for more info.

    As always, please report strange behaviour and rotation offsets, so we can fix it in the next version. The more clustered the world of Android gets (and on iOS, the same is happening), the more feedback we need from our users to provide a unified sensor experience. Thanks!
     
  44. PiMuRho

    PiMuRho

    Joined:
    Jul 11, 2012
    Posts:
    17
    Hi, I just updated to Gyrodroid 5, and now I'm getting a bunch of errors in SensorDeviceIPhone.cs saying that 'SetsensorOn' and 'SetSensorOff' don't exist in the current context.
     
  45. PiMuRho

    PiMuRho

    Joined:
    Jul 11, 2012
    Posts:
    17
    Disregard my previous message, Unity was having a bad day.
    I created a new project, using Unity 4.5, Vuforia 3.0 and Gyrodroid 5. Everything worked fine when testing on the PC, but after attempting to build for Android, it failed and now I have the following errors:

    Assets/Qualcomm Augmented Reality/Scripts/Internal/AndroidUnityPlayer.cs(80,30): error CS1061: Type `AndroidJavaObject' does not contain a definition for `Dispose' and no extension method `Dispose' of type `AndroidJavaObject' could be found (are you missing a using directive or an assembly reference?)

    Assets/Qualcomm Augmented Reality/Scripts/Internal/AndroidUnityPlayer.cs(83,37): error CS1061: Type `AndroidJavaClass' does not contain a definition for `Dispose' and no extension method `Dispose' of type `AndroidJavaClass' could be found (are you missing a using directive or an assembly reference?)


    Some kind of conflict between Vuforia and Gyrodroid?
     
  46. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    @PiMuRho, I think this has nothing to do with GyroDroid at all – this seems to be a incompatibility of Vufiroa 3.0 and Unity 4.5. GyroDroid contains some code to remove compile-time errors for other platforms than Android (Scripts > Utils > NonAndroidFallback), but this should only do something if some other platform than Android is selected for build.
     
  47. PiMuRho

    PiMuRho

    Joined:
    Jul 11, 2012
    Posts:
    17
    I've since created a new clean project with just Unity 4.5 and Vuforia 3 (No Gyrodroid) and have had no issues so far.
    The next step is to reintroduce Gyrodroid and see what happens.

    I guess if all else fails, I'll fall back to an older version of Vuforia, but I'd rather not have to.
     
  48. PiMuRho

    PiMuRho

    Joined:
    Jul 11, 2012
    Posts:
    17
    Literally the instant I import Gyrodroid-minimal, I get the same errors as before.
     
  49. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    OK, I will take a look at it again. A quick fix should be to delete the file in question (Scripts > Uitls > NonAndroidFallback), could you try that please?
     
  50. PiMuRho

    PiMuRho

    Joined:
    Jul 11, 2012
    Posts:
    17
    File deleted, errors disappeared.