-
Notifications
You must be signed in to change notification settings - Fork 0
Add hood control #64
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: main
Are you sure you want to change the base?
Add hood control #64
Conversation
|
@DannyPomeranian can you get this ready for testing by tomorrow night? |
|
@rafzip I'm working on this now, it should be ready today and will be ready by Thursday |
d2c3f22 to
1fd01a7
Compare
|
@codecov-ai-reviewer review |
|
If you're all gonna use AI to review code… at least be upfront about it. |
Greptile Overview
|
| Filename | Overview |
|---|---|
| components/shooter.py | Added hood motor control with SparkMax, encoder configuration, and pitch control methods, but hood motor runs continuously at constant speed instead of using closed-loop position control |
Sequence Diagram
sequenceDiagram
participant User
participant ShooterComponent
participant HoodMotor as Hood Motor (SparkMax)
participant HoodEncoder as Absolute Encoder
participant FlywheelMotors as Flywheel Motors
participant FeederMotor as Feeder Motor
Note over ShooterComponent: Initialization
ShooterComponent->>HoodMotor: Configure SparkMax with PID
ShooterComponent->>HoodEncoder: Set conversion factor & zero offset
ShooterComponent->>FlywheelMotors: Configure TalonFX gains
Note over User,ShooterComponent: Control Flow
User->>ShooterComponent: change_pitch_relative(angle)
ShooterComponent->>HoodEncoder: getPosition()
HoodEncoder-->>ShooterComponent: current_angle
ShooterComponent->>ShooterComponent: clamp(current_angle - angle)
ShooterComponent->>ShooterComponent: Update desired_hood_angle
User->>ShooterComponent: change_pitch_absolute(angle)
ShooterComponent->>ShooterComponent: clamp(90 - angle)
ShooterComponent->>ShooterComponent: Update desired_hood_angle
User->>ShooterComponent: shoot()
ShooterComponent->>ShooterComponent: Set target velocities
Note over ShooterComponent: Execute Loop (every 20ms)
ShooterComponent->>FlywheelMotors: VelocityVoltage control
ShooterComponent->>FeederMotor: PercentOutput control
ShooterComponent->>HoodMotor: set(hood_move_speed)
Note over HoodMotor: Runs at constant 0.01 speed<br/>(Closed-loop control commented out)
ShooterComponent->>HoodEncoder: getPosition()
HoodEncoder-->>ShooterComponent: current_angle
ShooterComponent->>ShooterComponent: hood_is_at_setpoint()
Note over ShooterComponent: Check with math.isclose()<br/>(incorrect rel_tol usage)
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.
2 files reviewed, 5 comments
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.
2 files reviewed, 4 comments
components/shooter.py
Outdated
| def change_pitch_relative(self, angle): | ||
| self.desired_hood_angle = self.get_hood_angle() - angle | ||
| clamp(self.desired_hood_angle, self.MIN_HOOD_ANGLE, self.MAX_HOOD_ANGLE) |
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.
clamp() returns a value but it's not being assigned - desired_hood_angle remains unclamped.
| def change_pitch_relative(self, angle): | |
| self.desired_hood_angle = self.get_hood_angle() - angle | |
| clamp(self.desired_hood_angle, self.MIN_HOOD_ANGLE, self.MAX_HOOD_ANGLE) | |
| def change_pitch_relative(self, angle): | |
| self.desired_hood_angle = clamp( | |
| self.get_hood_angle() - angle, self.MIN_HOOD_ANGLE, self.MAX_HOOD_ANGLE | |
| ) |
Prompt To Fix With AI
This is a comment left during a code review.
Path: components/shooter.py
Line: 93:95
Comment:
`clamp()` returns a value but it's not being assigned - `desired_hood_angle` remains unclamped.
```suggestion
def change_pitch_relative(self, angle):
self.desired_hood_angle = clamp(
self.get_hood_angle() - angle, self.MIN_HOOD_ANGLE, self.MAX_HOOD_ANGLE
)
```
How can I resolve this? If you propose a fix, please make it concise.
components/shooter.py
Outdated
| def change_pitch_absolute(self, angle): | ||
| self.desired_hood_angle = 90 - angle | ||
| clamp(self.desired_hood_angle, self.MIN_HOOD_ANGLE, self.MAX_HOOD_ANGLE) |
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.
clamp() returns a value but it's not being assigned - desired_hood_angle remains unclamped.
| def change_pitch_absolute(self, angle): | |
| self.desired_hood_angle = 90 - angle | |
| clamp(self.desired_hood_angle, self.MIN_HOOD_ANGLE, self.MAX_HOOD_ANGLE) | |
| def change_pitch_absolute(self, angle): | |
| self.desired_hood_angle = clamp( | |
| 90 - angle, self.MIN_HOOD_ANGLE, self.MAX_HOOD_ANGLE | |
| ) |
Prompt To Fix With AI
This is a comment left during a code review.
Path: components/shooter.py
Line: 97:99
Comment:
`clamp()` returns a value but it's not being assigned - `desired_hood_angle` remains unclamped.
```suggestion
def change_pitch_absolute(self, angle):
self.desired_hood_angle = clamp(
90 - angle, self.MIN_HOOD_ANGLE, self.MAX_HOOD_ANGLE
)
```
How can I resolve this? If you propose a fix, please make it concise.|
|
||
| self.feeder_motor.set(ControlMode.PercentOutput, self.target_feeder_percentage) | ||
|
|
||
| self.hood_motor.set(self.hood_move_speed) |
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.
Hood motor runs continuously at constant speed every execution cycle - will keep moving even when at setpoint or when not commanded.
Prompt To Fix With AI
This is a comment left during a code review.
Path: components/shooter.py
Line: 117:117
Comment:
Hood motor runs continuously at constant speed every execution cycle - will keep moving even when at setpoint or when not commanded.
How can I resolve this? If you propose a fix, please make it concise.| MAX_HOOD_ANGLE = 70 # TODO Tune this value | ||
| MIN_HOOD_ANGLE = 10 # TODO Tune this value | ||
|
|
||
| MOTOR_GEAR_RATIO = 24 / 22 |
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.
MOTOR_GEAR_RATIO defined but never used in code.
Prompt To Fix With AI
This is a comment left during a code review.
Path: components/shooter.py
Line: 30:30
Comment:
`MOTOR_GEAR_RATIO` defined but never used in code.
How can I resolve this? If you propose a fix, please make it concise.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.
1 file reviewed, 1 comment
| MIN_HOOD_ANGLE = 10 # TODO Tune this value | ||
|
|
||
| MOTOR_GEAR_RATIO = 24 / 22 | ||
| ENCODER_ROTS_PER_HOOD_DEGREE = 54 / 26 / 360 |
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.
Conversion factor should be in degrees per encoder rotation, not encoder rotations per degree. The formula should be 360 * 26 / 54 (inverse of current value).
Prompt To Fix With AI
This is a comment left during a code review.
Path: components/shooter.py
Line: 31:31
Comment:
Conversion factor should be in degrees per encoder rotation, not encoder rotations per degree. The formula should be `360 * 26 / 54` (inverse of current value).
How can I resolve this? If you propose a fix, please make it concise.
No description provided.