I am having real troubles trying to figure out which axis was impacted using the collision detection and the MAC SDK. I can't seem to get any data that makes sense. I have integrated the sample keydrive with collision detection to try and make sense of the collision data that is returned. It seems to be able to detect the collisions ok but the return power values for the x and y axis don't seem to be consistent. Using this little bit of code in my async method:
if ([asyncData isKindOfClass:[RKCollisionDetectedAsyncData class]]) {
RKCollisionDetectedAsyncData *collisionData = (RKCollisionDetectedAsyncData *)asyncData;
xPower = collisionData.impactPower.x;
yPower = collisionData.impactPower.y;
NSLog(@"X Power: %u",collisionData.impactPower.x);
NSLog(@"Y Power: %u",collisionData.impactPower.y);
[RKRollCommand sendStop];
}
I have an output for y collisions of:
2014-01-17 17:16:43.734 KeyDrive[16537:303] X Power: 15
2014-01-17 17:16:43.734 KeyDrive[16537:303] Y Power: 113
2014-01-17 17:16:47.360 KeyDrive[16537:303] X Power: 11
2014-01-17 17:16:47.360 KeyDrive[16537:303] Y Power: 130
and for x collisions:
2014-01-17 17:17:36.921 KeyDrive[16542:303] X Power: 25
2014-01-17 17:17:36.922 KeyDrive[16542:303] Y Power: 130
2014-01-17 17:17:39.862 KeyDrive[16542:303] X Power: 18
2014-01-17 17:17:39.868 KeyDrive[16542:303] Y Power: 116
then I have all my thresholds currently set at:
uint8_t xThreshold = 100;
uint8_t yThreshold = 100;
uint8_t xSpeedThreshold = 100;
uint8_t ySpeedThreshold = 100;
float deadZone = 1.0f;
but I have used many different variations to get some sort of consistency with no luck. Anyone have any advice?
EDIT:
So i tried out the new solution. My test environment was dumbed down to try and solidify my findings. I kept the sphero in place not moving and struck it on the different axes. Although the results were a bit more hopeful, they are still not too reliable. see my results below. I did multiple strikes on every axis with differing results specifically on the y axis. Maybe my y axis accelerometer is a dud?
X+
**Impact** **Accel**
X Y X Y
34 8 0.88208 0.218262
55 3 1.381592 0.092529
33 1 0.861572 -0.046875
58 3 1.376953 0.035645
68 3 1.380371 0.094238
X-
**Impact** **Accel**
X Y X Y
57 3 -1.351074 0.026123
38 2 -0.91748 0.050781
57 0 -1.228271 0.025391
59 5 -1.395264 0.178711
40 2 -0.910156 0.005615
Y+
**Impact** **Accel**
X Y X Y
5 31 0.436523 0.638672
6 31 -0.13623 0.390869
18 40 0.39502 0.661621
26 35 0.647461 0.538818
14 46 0.154297 0.770508
Y-
**Impact** **Accel**
X Y X Y
6 32 0.549805 -0.579834
21 30 0.692383 -0.614014
5 31 0.149414 -0.508301
24 30 0.449463 -0.413574
9 31 0.68457 -0.682861