0

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
tinkerer
  • 11
  • 2

1 Answers1

1

I think that the reason you are seeing these numbers is due to the example you are using. I read that you are using the key drive example, with modifications to create these results. The problem with that is, that when you press a key, the ball TURNS then goes in the indicated direction. Therefore the ball, with respect to its accelerometer, is always being hit in the same direction, causing those kinds of results up there. Now if you wanted to see the different axes you would need to develop a way to cause an impact on the side of the ball perpendicular to where the tail light is, which usually is not something achievable while it's moving (unless you hit it from the side while it's driving).

Hunter Lang
  • 101
  • 4
  • No idea why I didn't see this. I made a terrible assumption that the accelerometers were with respect to the tail light. Thanks for the heads up. I am trying to make sphero bounce around in a physical box. Anything you could suggest that would make the result better with regards to the capabilities of sphero? – tinkerer Jan 30 '14 at 21:48
  • If you set the heading to some known value, then track it's changes, you should be able to see what direction that Sphero thinks it's facing, then adjust the axes against this angle. Also, if the answer was correct for you, please help me out and accept it. – Hunter Lang Feb 06 '14 at 19:16
  • thanks for the follow up. Since I posted, I have been very busy and have yet to try it out. I should have some free time in the next few weeks and I will let you know if this was in fact the issue. Thanks! – tinkerer Mar 12 '14 at 17:33
  • Have a look at my edit if you have some time. Thanks for your insight. – tinkerer Mar 26 '14 at 15:17