1

I am trying to build an android application for sphero where I need to stop sphero in certain zones of the room and I am trying to do so with the locatorData using a DeviceMessenger.AsyncDataListener.

I have noticed, however that it is impossible to tell where he is while he is still rolling and stop it when it is in a certain set of coordinates, because the data arrives with great delay. He basically stops much farther and I can see the coordinates increasing with delay on screen. I know the communication is asynchronous and i could somehow be losing some data during communication but I thought that by giving him a window around the coordinates I want him to be I would be able to stop him more or less in that zone, but it doesn't look like it works decently.

For now, the only solution I've come up with is to send a roll command, calculate the amount of time it needs to roll to get to those coordinates based on velocity and send a delayed stop command, but I don't like this solution and I don't think it's going to work correctly in the long run, when I implement all the features I need. Does anyone have any suggestions about the locatorData and how to use it in this case?

excentris
  • 471
  • 1
  • 7
  • 25

1 Answers1

3

I have used the 'locatorData' before and what you are trying to do is very possible. There are a couple ways you can go about accomplishing it.

The great delay you are experiencing is not communication delay, but the fact that the Locator sensor only updates 10 times a second (10Hz). However, this should still be more than enough time to work within your constraints of stopping the ball within a boundary. Another factor is, have you thought about that the ball needs about 1-2 feet to come to a stop? This depends on the speed the ball is traveling when you send a stop rolling command.

One way you cab accomplish your goal is by driving the ball at a slower speed. If you were to drive at 50% power instead of 100% your results should be more accurate. Since, the time delay and stop delay have less impact on the accuracy.

Another way you could accomplish this is by doing a predictive algorithm. Using the 'locatorData', you know where the ball is (x, y), and you know the velocity in which it is traveling (vx, vy) you can predict where it is going to be in the future. Therefore, you can send a stop command in advance when your algorithm determines the ball will be at your destination in 1-2 seconds.

You might want to look into the ConfigureLocator command as well, since this can make the starting point of your ball be (x=0, y=0).

I hope this information helps!