-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the ability to reset the position of the motors in odometry_start() #758
base: ev3dev-stretch
Are you sure you want to change the base?
Conversation
Thanks for the contribution! To help me understand the use-case here, how does this differ from setting the positions before starting odometry? It seems like resetting motor positions is not directly related to starting the odometry thread; is the idea that you often want to reset the motor positions at the same time as starting odometry, so you might as well have it together? |
Hello - thanks for looking at my request. The use case is for FLL where someone would want to run some code, then move the robot and run a the code again or new code without restarting the program. You could create a different function to reset the positions but since the code already resets the odometry x,y it makes sense to also have the option to do it here. |
I suppose I'm just confused about why calling code cares about the motor position. The odometry uses the "position" value of the motors to compute deltas, but not absolute positions, meaning it shouldn't matter to the odometry system whether you have reset the position or not. Is your code separately using the position values of individual motors for something other than odometry? Or is there something about odometry that doesn't work if you don't reset the position (i.e., a bug)? In case this isn't making sense, perhaps a brief explanation of |
If you look in motor.py in def _odometry_monitor. you see the code:
If the robot has moved then self.left_motor.position and self.right_motor.position are not 0 but the left_current and right_current are 0. So the first pass makes it seem like the robot has moved a large distance which I doesn't make sense to me. |
Ah, I see what you're saying; that definitely seems like a bug. I think the following: left_previous = 0
right_previous = 0 Should have presumably been: left_previous = self.left_motor.position
right_previous = self.right_motor.position Good catch! @dwalton76 Are you watching this thread? Could you weigh in here? |
It would be helpful to be able top reset the motor positions at odometry start as well as set the coordinates. There are many instances (such as when you want to move the robot) that you want to have a clean slate on your odometry.