11 Replies Latest reply on Dec 5, 2013 1:08 PM by Sean Kennedy

    Accelerometer, magnetometer, gyro support?

    Jon Tara

      There was mention in the release notes of accelerometer support in RhoMobile Suite 2.2. I can't find anything in the docs, though. Neither in the docs for the new Rhodes 3.5.1 release.


      This this functionality miss the release, or am I missing the documentation? Or is this only for RhoElements?


      Also, is there a RhoMobile Suite > 2.2 that goes with 3.5.1, or has only the Gem been updated?


      I have an application for this, and this would make it easier. Otherwise, I suppose it wouldn't be too hard to use the existing geolocation code as a model. (I only need to implement this for iOS).


      I already need to write a native extension to expose the vDSP library, which I'll be happy to share. Would be good if I don't need to write native extensions to get the data too.

        • Re: Accelerometer, magnetometer, gyro support?
          Jon Tara

          Apparently, this is in RhoMobile Suite 2.2 but is part of RhoElements.


          The documentation for the Ruby implementation doesn't make any sense, though. What the heck does the "current page" have to do with Ruby? Ruby doesn't know/care about pages. I don't know how one would access Ruby objects in "the current page" since there is no such concept in the Rhodes server.


          I assume it's just incorrect documentation - that there is a global RawSensors object, (or singleton class) that one can use from anywhere, and has callbacks that can be used like any Rhodes callback - e.g. it sends messages to a controller.


          It says it doesn't require a license. Is there anything special I have to do to enable only the parts of RhoElements that don't require a license?


          The documentation needs to be better integrated.


          RawSensors Ruby Object Syntax:  By default the Ruby Object 'RawSensors' will exist on the current page and can be used to interact directly with the RawSensors. All Methods, Parameters and Events are the same as Javascript, however, notice 'RawSensors' needs to start with an uppercase letter. Another difference in Ruby is that methods do not end in '()'

            • Re: Accelerometer, magnetometer, gyro support?
              Darryn Campbell

              Hi Jon,


              I agree it's confusing, let me reach out to the developers of this feature to see if they can contribute to this thread.



              • Re: Accelerometer, magnetometer, gyro support?
                Pietro Francesco Maggi

                Hi Jon,

                so, we are talking about the RawSensor API.


                This API is brand new and it currently supports only iOS and Android devices. I agree that the documentation can be improved, expecially regarding the Ruby syntax...

                Moreover, it's a bit tricky at the beginning to understand that accelerator and magnetometer APIs are just the different usage of the same RawSensor API (infact docs links back to RawSensor documentation).


                But if you have the opportunity to take a look at the webinar registered Dec 5th; Adam Blum has done a good introduction to it starting around the 25th minute into the video.


                To grasp a better understanding of this API usage from a Ruby controller object can be useful to take a look at the sample available on github.



                • Re: Accelerometer, magnetometer, gyro support?



                  Live-cycle of Ruby object linked to current page only for Motorola devices (WM/Android). On non-Moto device (iOS, consumer Android), RawSensor Ruby object is singleton for application (not related to current page).

                  Also Magnetometer on iOS has specific behavior - iPhone calibrate magnetometer each time when you start use it. Calibration require any moving(recommended move and rotation both) of device. But this behavior help produce very high quality magnetic field info (remove self device field data) instead of Android devices.

                • Re: Accelerometer, magnetometer, gyro support?
                  Sean Kennedy

                  Hi Jon.


                  I am curious: Which functionality are you looking for from this type of sensor suite.


                  Accelerometer provides 2 things: 1) Orientation of the device (Handy for screen rotation) which is usually a boolean for the X.Y.Z co-ordinate space.  2) Delta-Vee which is the "change in velocity" over a time period and indirectly the Velocity {Speed} as a derivation of the same.


                  Gyroscopes provide 1 thing: Rotation Detection; or better yet "Delta-Spin" about any of the X.Y.Z. Axis' and of course the "Orientation" in degrees of the same by derivation.


                  Magnetometers provide an additional Orientation using the Magnetic properties of "Planet Earth" for a Degree bearing of the device relative to the "North Magnetic" and are great for getting a Bearing where GPS is no longer helpful (Like Indoors) but some directional orientation is needed.


                  From a Guidance perspective:

                  The reason I am curious is that unless you are sampling these sensors a lot, (A lot more than one would with GPS) the data is not helpful unless you have a way of integrating the data into an "Inertial Navigation System" guidance package.

                  With GPS, this is pretty easy since you have a readily available NMEA data stream, with the Sensors on some devices, there isn't a "NMEA-Like" library to use the data to provide INS guidance.


                  For Orientation perspective: You will know if the unit is upside-down or not.


                  Some devices have code to detect "Device Drop" or "Sudden-Stop" detects.  (If used in a properly mounted vehicle cradle, a device could provide a mode of collision detection) 

                  These however are used to detect clumsy worker habits rather than detecting vehicle "incidents"...



                    • Re: Accelerometer, magnetometer, gyro support?
                      Jon Tara

                      Sorry for the delayed reply. I don't come here often, as the UI is so annoying.


                      I'm interested in recording small movements of the device, and I'm afraid the application is proprietary. However, there are a number of applications in the App Store that do "vibration analysis", and we are using one of those as a "mule" for now. We record the movement (perhaps 1 inch displacement) over an extended period (hours) and then (currently) do off-line analysis using Forrier. (Will eventually be done in app, once we know just how to detect the conditions we are looking for.)


                      The need is mainly for acceleration data, but we do need the gyro sensors to correct for the gravity vector.

                    • Re: Accelerometer, magnetometer, gyro support?
                      Sean Kennedy

                      Thanks Jon.'


                      Aha! An "audio" app.

                      Well more seismic than "audio" per se..

                      But it points to an interesting use: Is the device in Motion, and if so, what is it doing?


                      Passive seismic like this would need to know Orientation (Gravity Vector) to understand what way the unit is "at rest" and then derive the co-ordinate system expected from that.

                      Like: The device is at rest on it's back and any motion in out toward the screen is going to be the "Z" axis and the signal computed will log if the table the unit is resting on : Jumps.