I am experimenting with the accelerometer sensor data. I want to create a project where students design a barrier to stop the sphero at full speed with the minimum of g forces. Like a traffic barrier on the highway. I have created a simple program to run the sphero into a solid barrier. When it hits, stop the program and look at the graphs. However, I am not seeing consistent results. It seems that the sensors record every .3 seconds. Is there a way to increase this rate? I have tried several iterations, using the “onCollision” event with variables and end up with the same in consistent results.
Hi @tmiller48111, welcome to our community!
First off, I love that project idea! Unfortunately, Sphero EDU has to keep the sensor streaming running at a pretty low update rate to accommodate widely varying bluetooth performance across different devices. Since collisions are typically very short duration events, they are actually detected in firmware, where the full 400 Hz IMU update rate is available. EDU only gets a single notification packet to trigger the onCollision event.
With that said, it is possible to stream at higher rates, but you’d need to either write software to do it from scratch or use a 3rd party framework and extend it with whatever data output you need. This one actually looks like it may be a pretty good starting point, though it was developed outside of Sphero and I haven’t tested it:
Since I couldn’t resist a little digging…it looks like you’d want to edit the set_notify() method to only enable the accelerometer in the sensor streaming mask, instead of all sensors. The streaming mask selects which sensor data is sent from the robot. Then turn down the streaming interval as much as you can before you run into problems with BLE bandwidth. Of course, there’s no guarantee that this will get you better data, since you’re still dependent on the performance of your computer’s bluetooth stack.