-
Notifications
You must be signed in to change notification settings - Fork 113
Better handling of motor faults #3425
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
base: master
Are you sure you want to change the base?
Conversation
… motor fault tracking implemented.
Need to do some final cleanup. I think I left some debugging stuff and I need to make sure all motors restart 3 times before failing (in the video you can see the affected motor only attempt restart twice). |
…eset 3 times, not 2, when fault detected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
almost there!
/* | ||
* Get the motor faults encountered so far. | ||
* | ||
* @return the mapping of motors to the object describing their faults. | ||
*/ | ||
std::unordered_map<int, MotorFaultIndicator> getCachedMotorFaults(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be private:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering if it would be useful for other files to use, perhaps if we wanted per-motor reports of motor faults in thunderscope/robot diag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is communicated through the RobotStatus
proto. Other modules should be getting motor status info from RobotStatus
rather than calling this function directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param velocity the current velocity of the motor | ||
* @param target target rpm | ||
*/ | ||
void readThenWriteToEnabledMotor(uint8_t motor_chip, double& velocity, int target); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use a reference to velocity here? Why not return the velocity?
You should also document that the velocity
is an output argument that the function will modify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember changing this line of code... It looks like deleting the reference should be fine, if you make it return and change around the dependent code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i think that returning the velocity here makes this code more understandable to the layperson
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait so if I make the change to return the velocity from reading then the parameter velocity shouldn't be changed, so I wouldn't need to change docs, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some more comments
Co-authored-by: itsarune <[email protected]>
…e into HandleMotorFault
Scan all motors per call to poll, rather than one per call
Co-authored-by: itsarune <[email protected]>
…e into HandleMotorFault
I'm going to need someone to test this in the mezz, or I can do it in about 2 weeks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left a few comments
…rs per call to poll, rather than one per call" This reverts commit 8271f50
Please fill out the following before requesting review on this PR
Description
See #3408
https://github.com/user-attachments/assets/a77848b3-ee4a-4df8-ad6d-0fa36bc76db8
Changes motor fault handling to a per motor control.
Allows for faulty motors to be disabled without crashing thunderloop.
Disabled motors freewheel and are no longer checked for further issues. They will not be given commands to run.
Testing Done
Tested on robot. When fault is detected, movement halts and motors attempt to restart three times before disabling the affected motor and reinitializing all other motors.
Resolved Issues
Resolves #3408
Length Justification and Key Files to Review
Review Checklist
It is the reviewers responsibility to also make sure every item here has been covered
.h
file) should have a javadoc style comment at the start of them. For examples, see the functions defined inthunderbots/software/geom
. Similarly, all classes should have an associated Javadoc comment explaining the purpose of the class.TODO
(or similar) statements should either be completed or associated with a github issue