-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
[Bug] DriveBase.distance() changes after resetting wheel motors' angles #1449
Comments
Thank you! I can see that this could be confusing. Another way to resolve this would be to reset the motors before creating the drive base: left_wheel = Motor(Port.B, Direction.COUNTERCLOCKWISE)
left_wheel.reset_angle(0)
right_wheel = Motor(Port.A, Direction.CLOCKWISE)
right_wheel.reset_angle(0)
robot = DriveBase(left_wheel, right_wheel, 62.4, 110)
Maybe we should do this automatically, and add a note about it in the docs. Related to this, maybe we should also reset the angle when switching to/from using the gyro. |
Thanks
Even then, if the robot references itself with a wall (for example), resets distance, then resets motors, the measured distance will change too, right? This year, in my team's robot we sometimes want to turn with a single wheel, so we reset motors in the wall too (although I don't think it makes much sense to use relative angle here instead of gyro or absolute angle). |
Thank you. I think we haven't given the individual motor resets combined with drive base resets enough thought. I agree that some changes would be helpful, and we can certainly do so. We just have to figure out what's "right", and then find a way to implement it as well. Possible approach: (feel free to suggest others!)
Would this solve your use case? |
That approach is exactly what I had in mind!! 😄 For solving our use case we have made a function similar to this to make sure we always reset distance after motors: def reset_motors():
left_wheel.reset_angle(0)
right_wheel.reset_angle(0)
drivebase.reset() |
We have recently added the ability to pass a desired distance and angle to After giving this more thought in the context of the original question here, I'm not sure that changing the existing behavior would be the best solution. The sources for the drivebase distance are the motor angles. So if you change the motor angles, this will change the distance too. This also applies when moving a single motor. Would it be OK if we added a note to the |
Yeah, that sounds like the best solution 👍. |
Describe the bug
What is the problem?
Hi, I am coaching an FLL team and was testing the robot today using relative distances (passing
target_distance - robot.distance()
toDriveBase.straight()
). I noticed that the robot sometimes moved a lot and other times it moved very little. Later today I was able to isolate the issue and found out that resetting the wheel motors' angles changed the measured distance value. I don't know if it's relevant but we use the SPIKE Prime.To reproduce
I made this program that shows that DriveBase distance changes without moving the motors:
Which outputs this:
As you can see, the robot's measured distance is changed without even moving the motors.
Expected behavior
I think the measured distance should stay the same after resetting the drivebase's motors.
Resetting distance after resetting the motors solves this issue but I spent some time figuring this out.
The text was updated successfully, but these errors were encountered: