Gyroscope values in Sensor::Info

Former Member
Former Member
It would be very useful to have a gyro field in the Sensor::Info structure available to those watches that have a gyroscope. It opens very interesting possibilities for development.

Thanks!
  • You need to use VS Code with the 1.0.0 extention.  The device is set for 3.3.0 and the eclipse pluging can't handle that.  Here's one of my apps using the f6pro System 5 preview device with VS Code:

  • Can anyone help me whith how to get to the f6pro preview in eclipse? Or is this not available yet?

    I tried using the Venu but it doesn't recognize sensorData.gyro  

    You need to use the SDK Manager to download the devices which are literally named:

    - fēnix® 6 Pro System 5 Preview

    - VenuTm 2 System 5 Preview

    Perhaps they aren't available for you yet? I only received them recently, even though they were announced five days ago.

    As Jim mentioned, the fenix 6 Pro System 5 Preview device apparently doesn't run in Eclipse.

    However, I've got the following code running without error for the Venu 2 System 5 Preview (in VS Code or Eclipse), as well as f6 Pro System Preview in VS Code. Only problem is it doesn't seem to do anything, even when I simulate FIT data in the simulator. I can confirm that it does crash if you try to run it on any other device (which is expected and proves that the System 5 preview devices have something that the other devices do not.)

    I also get a runtime error if :gyroscope["sampleRate"] is missing, which proves that the API is at least validating the gyroscope args.

    I added the following to my view class:

        function gyro_callback(sensorData) {
            var x  = gyroscopeData.x;
            var y = gyroscopeData.y;
            var z = gyroscopeData.z;       

            System.println("gyro x = " + x); // this line is never reached
            System.println("gyro y = " + y);
            System.println("gyro z = " + z);
        }
        
        function initialize() {
            View.initialize();
        
            Sensor.registerSensorDataListener(method(:gyro_callback), {
                :period => 1,
                :gyroscope => {
                    :enabled => true,
                    :sampleRate => 25
                }
            });
            System.println("test"); // this line is reached

       //...

    Maybe there's something wrong with my code? I didn't spend a lot of time on this and none of my apps use high frequency sensor data.

  • You must use one of the "System 5 preview" device to use System 5 functionality.

  • You must use one of the "System 5 preview" device to use System 5 functionality.

    Thanks I did that.

    However, I've got the following code running without error for the Venu 2 System 5 Preview (in VS Code or Eclipse), as well as f6 Pro System Preview in VS Code. Only problem is it doesn't seem to do anything, even when I simulate FIT data in the simulator. I can confirm that it does crash if you try to run it on any other device (which is expected and proves that the System 5 preview devices have something that the other devices do not.)

    As I said, if I run the same code on non-System 5 devices, it crashes with a run-time error.

    If I run it on a System 5 device as is, it does not crash. On the same device, if I remove gyroscope["sampleRate"], it gives me a runtime error complaining that gyroscope sampleRate is missing, which suggests that the System 5 API is being called, as it's validating the gyroscope args properly.

    Only thing is I don't see any gyroscope data when running it in the sim. Maybe it's not implemented or maybe there's something wrong with my code.

  • You need to have a "has" on non System 5 preview devices to avaid the crash.

    This is only the 1st beta, and in the past there have been as many as three betas.  You'll also see 0 for body battery in this beta, and 35 for stress, without any way to use fit data.

  • You need to have a "has" on non System 5 preview devices to avaid the crash.

    It's not real production code, I was just playing with it for fun to see what would happen.

    I'm not concerned about the crash at all. The point was to demonstrate that something different was happening with System 5 devices vs. non-System 5 devices, which supports the idea that the code works properly with System 5 devices.

    The point of my post was to answer the question "how do you access the gyro data" in System 5 Preview by saying:

    - The code "works" (it doesn't crash)

    - But you won't see any data yet (as far as I can tell.)

    I also wanted to point out that it does work in Eclipse if you choose Venu 2 System 5 Preview. Again, in this case, my definition of "works" is: "runs without crashing" (which was the point of trying it out in the non-System 5 preview devices).

    Sorry I didn't make that crystal clear.

  • Thanks, I had the Venu selected, but not the preview device.... looking Im downloading the preview devices

  • Oh no.........   I just tried my code - which will require both accelerometer readings and the gyro readings at the same time, and surprise surprise........  " Exception: More than one instance of data listener not allowed"

    How to get around that?

    Can 1 Data listener listen to more than 1 sensor or is there some other limit at play here? 

  • Can 1 Data listener listen to more than 1 sensor

    Yeah, just specify options for all the sensors you're interested in, in the options to registerSensorDataListener.

    Then handle all the different types of sensors in the callback you registered.

    In my example, instead of calling my callback function gyro_callback, a better name probably would've been sensor_callback.

  • Thanks, Can you also confirm - when listing the options do I list the full options for 1 sensor, then just continue with the full options for the other;;;; eg

    var gyrooptions = {
    :period => 1,
    :gyroscope => {
    :enabled => true, // Enable the accelerometer
    :sampleRate => 25,
    }

    };

    var acceloptions = {
    :period => 1, 
    :accelerometer => {
    :enabled => true,

    :sampleRate => 25,
    :includePower => true,
    :includePitch => false,
    :includeRoll => false// 25 samples
    }

    }

    Sensor.registerSensorDataListener(method(:sensor_callback), acceloptions, gyrooptions);

     

    function sensor_callback(sensorData) {

    cool stuff in here

    }