Team2168 / 2015_Main_Robot

Source code for the 2015 season
2 stars 0 forks source link

DriveXDistance Incorrect - Solved #100

Closed NotInControl closed 9 years ago

NotInControl commented 9 years ago

@jcorcoran , @ExcelledProducts ...

So here is the problem as to why the drive x distance was going the wrong distance (but thinking it finished at the correct distance).

The drivePos controller gets its position feedback from the IMU class, and the IMU calculates averaged distance traversed by the drivetrain.

The current calculation is

return leftEncoder.getPos() + rightEncoder.getPos() / 2;

as can be seen in this line https://github.com/Team2168/2015_Main_Robot/blob/master/src/org/team2168/PID/sensors/IMU.java#L65

however, the calc should be

return (leftEncoder.getPos() + rightEncoder.getPos()) / 2.0;

damn parenthesis error. So we can fix this after WPI since all autos are based off of the current offset. The current code only divides the right encoder by 2... lol

NotInControl commented 9 years ago

Alternatively we can fix this now and reduce all setpoints.

The current calc does the following: If your Target Distance is Y, the robot stops short at a distance X, where the relationship is:

X = Y/1.5; 

So, if your target was 4.5ft, the Robot Would only Drive approx. 3ft and stop (but thinking it drove 4.5 ft).

If we fix this problem now by correcting the calc and assuming all current setpoints were done imperially They would just need to be reduced by a factor of 1.5.

So If the current setpoint is SP (calculated with robot imperically), after the fix the new correct setpoint should be SP/1.5. This will keep the robot driving the same distance.

So do we want to fix this now, or after WPI?

jcorcoran commented 9 years ago

After pls

NotInControl commented 9 years ago

fixed in SHA: 5376c8598cf8e494f9705390ecca41230c77da08