FRCTeam2992 / Robot2023

FRC Team 2992's 2023 Robot Code
Other
1 stars 0 forks source link

[Arm] -- Init of motor encoder at reboot sometimes fails or gives bad result #38

Open msonnier opened 1 year ago

msonnier commented 1 year ago

Expected operation

Occasionally on reboot or code restart we get inaccurate encoder value initialized into arm motor encoder on restart. This has 2 root causes:

Assumptions you can make

Implementation notes

The following notes should help you navigate how to implement this Command Sequence. You can always ask your Programming Lead or Mentor for help if needed. Please explicitly call out any new EMPTY commands or functions in your pull request with this change when you submit it for review..

To try and account for mechanical slop, we look at arm absolute position every encoder reset. If it's at extreme top or bottom of range of motion, we assume gravity is "pulling arm" into the opposite end of mechanical slop. We subtract the empirically measured slop from Cancoder reading before applying that value into motor encoder in these cases.

msonnier commented 1 year ago

Cancoder had lost power and we still inited the encoder against a bogus value. Need to do some kind of check at init and if cancoder not present and it's autoinit we KNOW where we should be so set from that. If it's Teleop Init and we can't see Cancoder not sure what to do.