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. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104

    Hi all,

    Unity has built-in support for only some of the sensors on mobile devices.
    This package provides access to every single sensor of your Android device. It can and has been used for augmented reality, multisensoric games, visualization and more. Sensors just work as expected, independent of device and app alignment and orientation.

    The demo application (exactly the one contained in the package) is available from the Android Market (goo.gl/gkFq7).

    Link to Asset Store:

    http://u3d.as/2aR



    Feature list of GyroDroid 5.2:
    • support for every single sensor Android is capable of:
      • Rotation Vector
      • Gyroscope
      • Accelerometer
      • Linear Acceleration
      • Gravity
      • Light
      • Proximity
      • Orientation
      • Pressure
      • Magnetic Field
      • Processor Temperature
      • Ambient Temperature
      • Relative Humidity
      • Magnetic Field (uncalibrated)
      • Gyroscope (uncalibrated)
      • Game Rotation Vector
      • Step Detector
      • Step Counter
      • Geomagnetic Rotation Vector
    • experimental support for iOS cross-compiling (so rotation just works the same on both platforms)
    • you can do pretty much everything the Android sensor API can do:
    • check whether sensor is available
    • activate/deactivate sensor
    • set fetching speed
    • get info about power usage, manufacturer etc.
    • ... (see this link for a complete list of sensors and their attributes)
    • fallback handler for device rotation - if one sensor is not supported, the next best sensor is choosen
    • selectable rotation sensor technique (different combinations of sensors to achieve a complete, three-axis rotation value)
    • multiple demo scenes and samples for different usage scenarios
    • really easy to use (enable a sensor for your application = 2 lines of code, and that's if you don't want to use the provided prefabs)
    • supports Unity Remote 4 for debugging rotation sensors in the editor
    There's also a tutorial about how to use GyroDroid together with Qualcomm's Vuforia augmented reality solution here.

    You can try everything out in this demo scene (this complete application is included with the package, too):
    Android Market (goo.gl/gkFq7) (simply type into your mobile's browser to install the application, or install directly from market)


    By default, GyroDroid sends sensor hardware statistics to help us improve it. 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.

    The demo application features several useful example scenes:

    • camera as window (first person view)
    • rotating around an object (third person view)
    • explorable world (moving camera target), switch between first and third person view
    • rotation values relative to start rotation
    • linear acceleration
    • light sensor
    • device as a box
    • compass usage
    • statistics - overview over all sensors

    Link to Asset Store:

    http://u3d.as/2aR

    Don't forget to write a review once you bought it :).

    Have fun and create cool things!
    prefrontal cortex



    Changelog for 5.2

    • added Unity 5 support
    • minor bug fixes
    Changelog for 5.0:
    • 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 4 (for acceleration and rotation vector)
    Changelog for 4.0:
    • Unity 4.2 broke GyroDroid due to internal changes, works again on Unity 4.x
    • added experimental iOS support (rotation, gyroscope, linear acceleration)
    • New sensor: ambient temperature
    • New sensor: relative humidity
    • added DeactivateRotation to SensorHelper
    • bigger font size for demo app and dpi-dependant scaling
    • bug fixes
    Changelog for 3.1:
    • New example scene: Explorable World (touch-to-drag, change between first and third person camera, changing camera target)
    • New example scene: SuperDroid (uses rotation values relative to starting rotation)
    • added possibility to use a specific rotation sensor technique
    • correctly report first rotation value after initialization of sensors
    • Start menu with scrollbars and bigger buttons
    • fix: Linear Acceleration did not work on some devices (reminder: not available prior to Android 2.3)
    • fix: Statistics scene crash
    Changelog for 2.5:
    • screen rotation fix for portrait devices (like Galaxy S2, Nexus S, ...)
    • compass example scene
    • additional package for easier incorporation into your own project (so you don't have to manually find all the files you need)
    • other modes than "Landscape Left" may be used for device orientation (even Auto).
    • linearAcceleration (not available prior to Android 2.3) always uses the right directions.
     
    Last edited: Mar 13, 2015
  2. nukeD

    nukeD

    Joined:
    Feb 12, 2009
    Posts:
    411
    great work!
    im on vacation, but was able to download the v2 demo on the galaxy tab and htc desire. unfortunately it crashes each time i select a category from the main menu. am i doing something wrong? firmware 2.2
    thank you
     
    Last edited: Aug 20, 2011
  3. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    Hey,

    we weren't aware that there are a few Android 2.3 calls inside our library (so the minimum required API level is currently 9 / Android 2.3.0). We will look into this issue as soon as possible - thanks for pointing this out!
     
  4. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    Okay, so Android 2.3 introduced a bunch of sensors not available before. These sensors are, according to the SDK:
    • Gravity
    • Linear Acceleration
    • Rotation Vector

    Unfortunately, these are the Really Cool Ones (the ones which work best and are most accurate).
    The current application will crash running on Android 2.2 and below because of trying to access the regarding constants and functions --- oops, that's entirely our fault.

    Be assured that the sensors available prior to Android 2.3 will work just fine in the next version of GyroDroid, shouldn't take very long to correct that mistake.
     
  5. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    The problem is fixed, and we updated the download link in the first post. The demo scene should work now down to Android 2.1, although Android 2.3 introduced more accurate sensors.

    We tested on the following devices:
    • Samsung Galaxy Tab 7" - Android 2.2
    • Samsung Galaxy Tab 10.1v - Android 3.0
    • Motorola Xoom - Android 3.0
    • Samsung Google Nexus S - Android 2.3.3
    • Motorola Milestone - Android 2.2
    Review is pending, so in a few days, the fixed version (2.1) is available in the Asset Store!
     
  6. nukeD

    nukeD

    Joined:
    Feb 12, 2009
    Posts:
    411
    thanks a lot!
    the demo works on the tab now.
    what i need works perfectly, on the other hand:
    the linear accel demo does nothing, maybe the tab + andro 22 doesnt support it
    the box demo (awesome btw) works in all directions except one, check it out

    very good work, thanks
     
  7. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    If you open the StatisticsDemo on Galaxy Tab 7", you will see that LinearAcceleration sensor isn't available (unfortunately, it was introduced with Android 2.3). Glad you like the other demos! Consider writing a review in the AssetStore, please :) .
     
  8. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,080
    just tried the apk - this is pretty cool, and it's neat that you have created an interface for all Android components!
     
  9. Bratmandu

    Bratmandu

    Joined:
    Jul 27, 2011
    Posts:
    14
    Very cool! Although I think the camera is rotated 90degrees - - i.e. in the 'camera window' mode - moving the phone (galaxy s) up and down moves the camera up and down - but the camera is viewing everything 90 degrees sideways. Probably easy to sort out in Unity. Can't wait to get stuck into this, thanks!
     
  10. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Hi pfc.

    Good work! I have recently bought your plugin and so far I am happy with it.
    But I have a problem. I cannot use it to look at the magnetic north.

    Can you give a code example on how to achieve that please?

    Thank you.

    edit: nevermind, sorted this out. It was a unity thing.
     
    Last edited: Nov 1, 2011
  11. janoonk

    janoonk

    Joined:
    Dec 3, 2008
    Posts:
    79
    Any chance on supporting GPS? I think from Unity 3.3+ onwards GPS is supported on Android using the iPhoneSettings class but not all functions mentioned in the Android SDK are implemented :( So I was hoping you would...
     
    Last edited: Sep 28, 2011
  12. slidingcarlos

    slidingcarlos

    Joined:
    Apr 9, 2010
    Posts:
    7
    I totally agree with janook!!.... GPS and Compass support would be GREAT for my upcomming project... any chance you´r asset will be supporting both in the near future, or in any future!?
     
  13. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    Hey all,

    sorry for the long time without answers - finally we're back :)
    Compass is supported right now - you can simply use the MagneticField sensor (which basically is the compass included with the device). In the next version, we will also provide an example scene on how to use it, so it will be easier for you then.
    We are also looking into fully supporting GPS, including all the features Android provides.
    There are also some things to fix, like not-quite-right screen rotations on some devices.

    I cannot give you a release date quite yet, but thanks for all your comments and requests!
     
  14. vfxdomain

    vfxdomain

    Joined:
    Apr 23, 2011
    Posts:
    8
  15. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Hi pfc.

    I had problems with screen rotations on xperia mini and on samsung galaxy2.
    Can you give a hint on how it can be sorted out?
    Has it anything to do with the remapcoordinates() command from android?

    gps support is welcome!
     
    Last edited: Nov 1, 2011
  16. LastTemplar

    LastTemplar

    Joined:
    Nov 7, 2011
    Posts:
    12
    When will you make fixes for phones like Samsung Galaxy S2? I purchased the gyrodroid app and the axis are inverted. I really need this functionality because I need to complete a project in a month.
     
  17. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    Hello all,

    we just published version 2.5 of GyroDroid, should be available soon!

    Change log:

    • screen rotation fix for portrait devices (like Galaxy S2, Nexus S, ...)
    • compass example scene
    • additional package for easier incorporation into your own project (so you don't have to manually find all the files you need)
    • other modes than "Landscape Left" may be used for device orientation (even Auto).
    • linearAcceleration (not available prior to Android 2.3) always uses the right directions.
    We also updated the apk-file, so you can test the new version right now: goo.gl/oLkOQ

    Have fun!
    prefrontal cortex

    Asset Store Link

    PS.: We decided to implement GPS functionality into a new package, because of fundamental implementation differences and different requirements for your project (GPS needs manifest permissions, sensor usage does not). The GPS plugin isn't ready yet, but we are working on it.
     
    Last edited: Nov 10, 2011
  18. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    @vfxdomain:
    Have a look at the TurntableRotation example. This is exactly the functionality you need - the horizon is fixed to the "real" horizon if you rotate the device. You only need to use the rotation values to steer your airplane.
     
  19. FiveFingers

    FiveFingers

    Joined:
    Oct 15, 2009
    Posts:
    541
    I wonder what will be the difference from Unity's android.location mapping and this plugin.
    At the moment Unity's locationInfo are working great, only timestamp seem to be broken.

    Perhaps even a fix only on that side (the locationInfo.timestamp) would be enough to make willing to buy.
     
  20. wsteptoe

    wsteptoe

    Joined:
    May 26, 2011
    Posts:
    12
    I have recently purchased GyroDroid and need some help regarding calculating relative rotation from a starting pose.

    I am using the rotation as returned from SensorHelper. However, this only considers absolute rotation and sets the transform.rotation accordingly. Is there an in-built way of calculating rotation from a given starting pose? I.e. the position that the user is currently holding the phone.
     
  21. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    Hey wsteptoe,

    have a look at the TurntableCamera script provided in an example scene. This uses a starting rotation (the current direction the camera is looking in) and applies the sensor values from there.

    What you need is something like this:

    • set a start rotation
    • get first sensor value (this is done in TurntableCamera, take a look at it)
    • in Update, multiply all rotations together:

    Code (csharp):
    1. transform.rotation = startRotation * SensorHelper.rotation * Quaternion.Inverse(firstSensorRotationValue);
    Hope that helps!
     
  22. Teuton

    Teuton

    Joined:
    Jun 24, 2010
    Posts:
    15
    "package name" need match Unity`s Bundle Identifier?
     
  23. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    @Teuton: Make sure to correctly set company name, product name and bundle identifier in the Build settings, like for every Android application. If that does not solve your problem, please provide some more info about your specific problem.
     
  24. pscinmtlinmtl

    pscinmtlinmtl

    Joined:
    Jan 26, 2012
    Posts:
    2
    Hi,

    I tried GyroDroid's MinimalSensorCamera on 2 android devices:
    Samsung Galaxy S II
    Nexus S

    Both device doesn't work correctly with the example scene "Camera as window". Here's a video of the problem:
    http://www.youtube.com/watch?v=Q0pdbPVov-U

    As you can see in the video, sometimes I rotate around myself but the 3d scene doesn't move at all. Also, there is an angle where the scene oscillate between two position (maybe when the gyro is near 360). Eventually, I want to remove the 3d scene and overlay the rear camera of the android with some 3d (for augmented reality). But it won't work if it's lagging like that.

    There's an application called Sensor Meter, in it you can view the sensors and it looks more precise. Also they have an option for the refresh rate (set to Game)?

    I was wondering if there's any ways of fixing those issues. Note that the Gyro is calibrated (in Settings - Display - Gyro sensor calibration).

    Thank you for your time
     
  25. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    Hey psc,

    an updated version of GyroDroid is in the making. Hopefully, we can release it by the end of the week. It will contain alternative methods to retrieve the rotation value for devices which have issues with the default RotationVector setting (although they support it, some devices just return crappy values).

    SensorMeter uses one of these alternate methods to retrieve the rotation value (accelerometer+orientation), so your results should be better in a few days :).
     
  26. pscinmtlinmtl

    pscinmtlinmtl

    Joined:
    Jan 26, 2012
    Posts:
    2
    That would be fantastic, I need to upload my application next Monday. I don't want to push you, just motivate you! GyroDroid is an excellent application at a good price.
     
  27. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    Hello all,

    took a bit longer than usual to get the package approved, but now the next version of GyroDroid is available!

    The demo application is now available on the Android Market for easier access: http://goo.gl/gkFq7
    Asset store link: http://u3d.as/2aR


    Besides some bug fixes and minor improvements (see first post for these), there are new example scenes to show more usecases and to help you get started:

    1. An explorable world. Just drag with your finger to move around, switch between first person and third person sensor camera.




    2. SuperDroid! Shows how to use rotation values relative to the starting orientation.


     
  28. Leonsito

    Leonsito

    Joined:
    May 21, 2010
    Posts:
    23
    Fantastic work, Camera as window is exactly what I was looking for ;)
     
  29. Horsepower

    Horsepower

    Joined:
    Feb 1, 2012
    Posts:
    3
    Is it possible to using Gyrodroid with "Phidgets Spatial 3/3/3" gyro sensor, instead of Android sensor???:confused:

    "Phidgets Spatial 3/3/3" is one very good and professional gyro, accelerometer, magnetic field, compass, Sensor:
    http://www.phidgets.com/products.php?category=5&product_id=1056_0

    Or, the Gyrodroid run only with Android Tablet and Phone sensor???:(
     
  30. lockbox

    lockbox

    Joined:
    Feb 10, 2012
    Posts:
    519
    Your Android Market demo app works great, except for the last menu selection, " Statistics - All Sensors". All I get is a black screen. I'm using a Samsung Captivate, running Android 2.3.5.
     
  31. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    @Horsepower: This package enables access to Android sensors exclusively. These gyro sensors are something entirely different; if you want to use them inside Unity, you should take a look at their C# code samples for this device (located at the lower right of the website).

    @lockbox: If you know how to do that, it would be great if you could send a logcat output from starting the app to closing it to our mail address, so we can look into the issue. As far as we know, you are the first encountering such error :).
     
  32. sulix

    sulix

    Joined:
    Oct 5, 2011
    Posts:
    2
    Hi

    GyroDroid seems to produce some kind of memory corruption problems. If we use gyrodroid in cominbination with gravitational data, after some time the application will behave unexpectedly. Some game objects disappear, the application crashes sometimes. The application behaves in a way that doesn't even exist theoretically in the C# code. The errors are reproduceable and very similar on each test run.
    We tested this on two Android devices, one of them was the Galaxy S2.

    The application will work perfectly fine if we remove everything associated with Gyrodroid.
     
  33. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    This, of course, shouldn't happen. GameObjects disappearing sounds a bit unlikely, or rather related to your code - in managed code (C# and Java), your application will crash instead of becoming corrupted.

    Could you please send something we can test per mail? Otherwise we have no chance to investigate, as such an error has never happened to us. Not even on Galaxy S2, which we also tested.
     
  34. Xentar

    Xentar

    Joined:
    Apr 8, 2011
    Posts:
    23
    This plugin work on android 2.3.6? I tryed to test the demo on my Galaxy Ace, but i get an "force closed" message...
    Thanks in advance
     
  35. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    @sulix, @centar:

    Please provide a logcat output so we can investigate further.


    This is the only chance for us to fix such errors without actually having each and every device at hand. Thanks in advance for your help.
     
  36. TechDevTom

    TechDevTom

    Joined:
    Oct 21, 2011
    Posts:
    33
    Hey there, I just tried to install the demo on my HTC Wildfire S but it says that the demo is incompatible, is there any chance you will be making GyroDroid compatible with my phone?

    Thanks for any information in advance!
     
  37. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    @TSLoire:
    Which Android version is your device running on?
     
  38. TechDevTom

    TechDevTom

    Joined:
    Oct 21, 2011
    Posts:
    33
    Hey pfc, I'm using Android Version 2.3.5!
     
  39. Tork

    Tork

    Joined:
    Apr 23, 2012
    Posts:
    3
    I ask this because I have tried several scripts and assets without any luck, what I want to do is make the cam work as the gyroscope (which works nicely in your demo) but I'm afraid it won't do the same without a .class or something

    Maybe its a n00b question but I would prefer to be sure before I start buying stuff

    Thanks ^^
     
  40. cfloutier

    cfloutier

    Joined:
    Jul 30, 2009
    Posts:
    34
    I'm using the last version and it is working perfectly !!! thanks a lot for this excellent tool.

    But I've got a little trouble when the compass is not yet well calibrated. The values returned are incorrects.

    It is well resolved after one or two 8 made with the mobile. But is there a way to detect this like most compass application does. I want just to show to the user with a popup image that he need to do some littles loops.

    thanks in advance
     
  41. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    @Tork: There are several example scenes (all you see in the market). The scripts to access the sensors are all really short because of lots of work done in the background; if you just want the basic functionality, you simply plug the camera script onto your camera and copy the plugin's data files to the appropriate locations. The full C# code is included (so, no DLL or something), so you can look at that as well. Only the Java parts are compiled into a java plugin which you include with your project.

    @cfloutier: Could you post an example of an application that shows that calibration is needed? We can have a look at it. What you could do right now is detect strange values in the application and decide whether calibration should be done (values jumping around, very high mean difference between frames, ...).
     
  42. Tork

    Tork

    Joined:
    Apr 23, 2012
    Posts:
    3
    If there are the C files ready to be imported then it sounds awesome!
    I will purchase it before friday then :D

    Thank you for your fast response
     
  43. cfloutier

    cfloutier

    Joined:
    Jul 30, 2009
    Posts:
    34
    thanks pfc for the quick response. the simple compass application (in the app market) does what I want to do. It just show a bitmap of a big \ with explications when it detect that calibration is needed.
    I'll try to compute mean differences and post a sample here if i succeed.
     
  44. Tork

    Tork

    Joined:
    Apr 23, 2012
    Posts:
    3
    Just wanted to say that it works perfect :D (or at least what I tried)
    Just purchased it

    Thanks $35 are worth it
     
  45. harleycw

    harleycw

    Joined:
    Apr 1, 2009
    Posts:
    22
    Nice job on developing these Gyro assets. Should this be working with the Unity Remote? I can see the demo screen when I start the editor but it seems like through Unity Remote it cannot access the sensors and not even the finger drag. Can somebody confirm if this is supposed to work? If so, what may be the problem. If not, are there plans to support this? Without this functionality, development will be a bit slower.

    I see the following Warning:
    WARNING: Sensors can only be accessed on the device.
    UnityEngine.Debug:Log(Object)
    Sensor:Awake() (at Assets/GyroDroid/Sensor.cs:601)
    UnityEngine.GameObject:AddComponent()
    Sensor:get_singleton() (at Assets/GyroDroid/Sensor.cs:384)
    Sensor:CheckID(Type) (at Assets/GyroDroid/Sensor.cs:286)
    Sensor:Get(Type) (at Assets/GyroDroid/Sensor.cs:301)
    SensorHelper:ActivateRotation() (at Assets/GyroDroid/SensorHelper.cs:120)
    TurntableSensorCamera:Start() (at Assets/GyroDroid/SampleScripts/TurntableSensorCamera.cs:47)
     
  46. pfc

    pfc

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

    unfortunately, sensors aren't sent by the Unity Remote application. This is something only the Unity guys could fix.

    But we built kind of a debug mode into GyroDroid. If you press "Play", a new GameObject called Singleton::SensorHelper is created.
    It has the Sensor script attached, and this script has "Sensor Debug Values" exposed in the Inspector, where you can manually (or by script) change the sensor values used in the Editor. If you place the Sensor script somewhere in your scene while not in Play mode, this instance of the script will be used and no new GameObject created. This way, you can "preset" sensor values for testing (you can also disable/enable certain device features to test the fallback mechanisms for missing sensors).

    Regarding the finger drag: That should work with UnityRemote. But sensors definitely do not work. The warning is there to tell you exactly that.

    I hope that helps! At least for us, many things can be tested by changing the values in the Sensor script, without the need to use a real device all time.
     
  47. harleycw

    harleycw

    Joined:
    Apr 1, 2009
    Posts:
    22
    Yes, this helps quite a bit. Especially since I was having trouble with creating the actual Android packages. Now I can at least tweak the values to see what they do in the interface. As a quick test, I added the Z value capability in the linear acceleration demo and now the little droid goes in all three directions. Thanks !!!
     
  48. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    Glad it helps. We should probably put that fact into the documentation, I think right now you could not have found it anywhere but by chance. :)
     
  49. android_dev

    android_dev

    Joined:
    Jul 9, 2011
    Posts:
    19
    I've purchased your plugin and tried to import it into my existing project (iOS/Android). I haven't used any scripts in my scene yet but I can't compile the iOS version anymore. Is it possible to disable it in an iOS scene?
     
  50. pfc

    pfc

    Joined:
    Jul 28, 2011
    Posts:
    104
    Hey,

    that's due to the fact that some Android-specific classes aren't available for other types of Builds, so you get errors. But there is a way around that - just provide Unity with the missing classes when building for anything different than Android, and gone are the errors.

    We made a C# script with that classes for another project, so here it is! (Would probably be a good idea for us to just include it with the next version)

    Just put that script next to Sensor.cs and you should be able to compile your project for other platforms again without changing anything. Keep in mind that GyroDroid is still Android-only, so it won't do anything at all on another platform.

    View attachment $NonAndroidFallback.cs
     
    Last edited: May 15, 2012