sphero-inc / Sphero-Android-SDK

🚫 DEPRECATED REPO: Sphero™ is the amazing robotic ball ( gosphero.com ), this is the repository for the Android SDK for Sphero™. Visit dev site for more information:
https://developer.gosphero.com
160 stars 86 forks source link

Locator Data when motor is not on #17

Open DarrenGuinness opened 8 years ago

DarrenGuinness commented 8 years ago

Hi there, I am working on some applications that use the locator data stream on the Ollie, and noticed that I can see the movement of the locator fine when the motor is on, but when the motor is off only backwards motion adjusts the locator values. Meaning that if you push the device forward the location does not change, but if the device is pushed backwards the location values do change. Is this supposed to happen? Or Is there any way I can get locator values in all directions when the motor is not turned on?

DarrenGuinness commented 8 years ago

Just a clarification, the locator values do work in all directions if the motor is never started. But once the motor has been used once and then stopped, the locator values only go in the backwards direction.

iamcgn commented 8 years ago

Hi Dronious, Thanks for reaching out about this issue. I'm going to look into it and will let get back to you. Thanks for your patience.

DarrenGuinness commented 8 years ago

I found a workaround that seems to solve the issue. This seems to fix the sensor issue in both the odometry, and backEMF readings.

It appears that the motors are being reset to the forward direction when any roll, rawMotorCommand, or stop command has been issued which means that the back electromotive force can only be read in one direction (opposite of forward with respect to the robot). The proposed workaround sets the each of the motors to a very low power in opposite directions effectively allowing the robot to read both forward and backward motions again and needs to be called after each motor command to reset the sensor readings.

`` var resetMotors =function() { ldirection=0x01; //set to observe forward motion rdirection=0x02; //set to observe backward motion power = 1; //very low power var opts = { lmode: ldirection, lpower: power, rmode: rdirection, rpower: power }

orb.setRawMotors(opts, function(err, data){

});

} ``