Question

I have a view with 1 slider. I want to hold the Sphero ball in my hand so when tilt the ball left or right, the slider moves left or right.

What would be the best sample project to figure this out?

OTHER TIPS

I would use https://github.com/orbotix/Sphero-iOS-SDK/tree/master/samples/SensorStreaming

Inside handleAsyncData add a reference to your slider:

- (void)handleAsyncData:(RKDeviceAsyncData *)asyncData
{
   if ([asyncData isKindOfClass:[RKDeviceSensorsAsyncData class]]) {
       packetCounter++;
       if( packetCounter > (TOTAL_PACKET_COUNT-PACKET_COUNT_THRESHOLD)) {
           [self sendSetDataStreamingCommand];
       }

       // Received sensor data, so display it to the user.
       RKDeviceSensorsAsyncData *sensorsAsyncData = (RKDeviceSensorsAsyncData *)asyncData;
       RKDeviceSensorsData *sensorsData = [sensorsAsyncData.dataFrames lastObject];
       RKAccelerometerData *accelerometerData = sensorsData.accelerometerData;
       RKAttitudeData *attitudeData = sensorsData.attitudeData;

        // this Assumes your Slider has been hooked up in the Interface Builder
        // With float values between 1.0 and 0.0
       [MyAccelerometerSlider setFloatValue:accelerometerData.acceleration.x];
       // You could also set it to the Roll value which is better for controller stuff
       [MyOtherSlider setDoubleValue:attitudeData.roll];
   }
}

And just change the axis that you want to monitor from x to y, or z. You can also use other streaming functions from the Streaming sample. ie. Altitude and Quaternions.

Here is the Diagram for Sphero's Accelerometer Sensors:

Sphero heading Diagram

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top