Skip to content
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

✨ Microdisconnect Detection #5

Open
SizzinSeal opened this issue Nov 20, 2024 · 3 comments
Open

✨ Microdisconnect Detection #5

SizzinSeal opened this issue Nov 20, 2024 · 3 comments

Comments

@SizzinSeal
Copy link
Member

Overview

It was recently discovered that you can detect motor micro-disconnect (a disconnect and reconnect happening within 300ms) by using motor timestamps.

Motivation

Micro-disconnects are silent errors. No orange warning on the brain screen or message on the brain log. API like motor.is_connected() also do not connect them. However, the encoder position still resets, and the motor won't spin again until a different pwm command was sent to the motor. This should be handled.

Implementation

Here is a proof of concept: https://pastebin.com/737y1TP8
This is similar to the existing system, so integration shouldn't be too hard.

How it works

When calling pros::c::motor_get_raw_position, a timestamp is returned along with the position. The timestamp is the time of the onboard motor clock when the measurement was taken. If a disconnect occurs, this timestamp resets. By keeping track of this timestamp, we can detect all disconnects, micro or otherwise.

However, the clocks on the motors drift significantly from each other and the clock on the V5 brain. So, we need to calculate the range of possible timestamp values after some time has passed.

There is another problem as well. Consider these 2 measurements:

measurement #1:
system time: 500ms
motor time: 700ms

// a disconnect has occurred between the 2 measurements 

measurement #2:
system time: 1500ms
motor time: 800ms

It's not enough to just keep track of whether the motor timestamp decreased, we need to keep track of the difference between the motor timestamp and v5 brain timestamp.

@SizzinSeal SizzinSeal changed the title ✨ Microdisconnect ✨ Microdisconnect Detection Nov 20, 2024
@ABUCKY0
Copy link

ABUCKY0 commented Nov 20, 2024

could you put a thing in while the imu calibrates to also measure motor drift over time and have teams put it in initialize so it will take like a second to measure the motor time drift

@SizzinSeal
Copy link
Member Author

Its possible yes

@ion098
Copy link

ion098 commented Nov 20, 2024

There is another problem as well. Consider these 2 measurements:

measurement #1:
system time: 500ms
motor time: 700ms

// a disconnect has occurred between the 2 measurements 

measurement #2:
system time: 1500ms
motor time: 800ms

It's not enough to just keep track of whether the motor timestamp decreased, we need to keep track of the difference between the motor timestamp and v5 brain timestamp.

Could this not be mitigated by having a thread that checks all motors every 10ms, making the chances of this happening negligible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants