Skip to content

Commit

Permalink
Merge pull request #9 from AlphaKnights/pathplanner
Browse files Browse the repository at this point in the history
Pathplanner
  • Loading branch information
JSohn-1 authored Feb 6, 2025
2 parents 8ac7d37 + 03a03e7 commit 55fab2f
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: |
python -m venv venv
source venv/bin/activate
python3 -m pip install "robotpy==2025.2.1.0"
python3 -m pip install robotpy
python3 -m robotpy sync
- name: Run mypy
Expand Down
4 changes: 2 additions & 2 deletions deploy/pathplanner/paths/Example Path.path
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"pointTowardsZones": [],
"eventMarkers": [],
"globalConstraints": {
"maxVelocity": 20.0,
"maxAcceleration": 10.0,
"maxVelocity": 4.0,
"maxAcceleration": 4.0,
"maxAngularVelocity": 540.0,
"maxAngularAcceleration": 720.0,
"nominalVoltage": 12.0,
Expand Down
16 changes: 8 additions & 8 deletions deploy/pathplanner/paths/New Path.path
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
},
{
"anchor": {
"x": 4.399,
"y": 7.0
"x": 8.0,
"y": 5.0
},
"prevControl": {
"x": 3.399,
"y": 7.0
"x": 7.0,
"y": 5.0
},
"nextControl": null,
"isLocked": false,
Expand All @@ -33,22 +33,22 @@
"pointTowardsZones": [],
"eventMarkers": [],
"globalConstraints": {
"maxVelocity": 20.0,
"maxAcceleration": 10.0,
"maxVelocity": 3.0,
"maxAcceleration": 4.0,
"maxAngularVelocity": 540.0,
"maxAngularAcceleration": 720.0,
"nominalVoltage": 12.0,
"unlimited": false
},
"goalEndState": {
"velocity": 0,
"rotation": 0.0
"rotation": 180.0
},
"reversed": false,
"folder": null,
"idealStartingState": {
"velocity": 0,
"rotation": 0.0
},
"useDefaultConstraints": true
"useDefaultConstraints": false
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[tool.robotpy]

# Version of robotpy this project depends on
robotpy_version = "2025.2.1.0"
robotpy_version = "2025.2.1.2"

# Which extra RobotPy components should be installed
# -> equivalent to `pip install robotpy[extra1, ...]
Expand Down
2 changes: 1 addition & 1 deletion subsystems/drivesubsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self) -> None:
)

# The gyro sensor
self.gyro = AHRS(AHRS.NavXComType.kMXP_UART)
self.gyro = AHRS(AHRS.NavXComType.kMXP_SPI)
# self.gyro = wpilib.ADXRS450_Gyro()

# Slew rate filter variables for controlling lateral acceleration
Expand Down
28 changes: 14 additions & 14 deletions subsystems/maxswervemodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,29 @@ def __init__(
drivingConfig.IdleMode(int(ModuleConstants.kDrivingMotorIdleMode))
drivingConfig.smartCurrentLimit(ModuleConstants.kDrivingMotorCurrentLimit)

drivingConfig.encoder.positionConversionFactor(ModuleConstants.kDrivingEncoderPositionFactor)
drivingConfig.encoder.velocityConversionFactor(ModuleConstants.kDrivingEncoderVelocityFactor)
drivingConfig.encoder.positionConversionFactor(ModuleConstants.kDrivingEncoderPositionFactor) \
.velocityConversionFactor(ModuleConstants.kDrivingEncoderVelocityFactor)

drivingConfig.closedLoop.setFeedbackSensor(ClosedLoopConfig.FeedbackSensor.kPrimaryEncoder)
drivingConfig.closedLoop.pid(ModuleConstants.kDrivingP, ModuleConstants.kDrivingI, ModuleConstants.kDrivingD)
drivingConfig.closedLoop.velocityFF(ModuleConstants.kDrivingFF)
drivingConfig.closedLoop.outputRange(ModuleConstants.kDrivingMinOutput, ModuleConstants.kDrivingMaxOutput)
drivingConfig.closedLoop.setFeedbackSensor(ClosedLoopConfig.FeedbackSensor.kPrimaryEncoder) \
.pid(ModuleConstants.kDrivingP, ModuleConstants.kDrivingI, ModuleConstants.kDrivingD) \
.velocityFF(ModuleConstants.kDrivingFF) \
.outputRange(ModuleConstants.kDrivingMinOutput, ModuleConstants.kDrivingMaxOutput)


turningConfig = SparkMaxConfig()

turningConfig.IdleMode(int(ModuleConstants.kTurningMotorIdleMode))
turningConfig.smartCurrentLimit(ModuleConstants.kTurningMotorCurrentLimit)

turningConfig.absoluteEncoder.inverted(True)
turningConfig.absoluteEncoder.positionConversionFactor(ModuleConstants.kTurningEncoderPositionFactor)
turningConfig.absoluteEncoder.velocityConversionFactor(ModuleConstants.kTurningEncoderVelocityFactor)
turningConfig.absoluteEncoder.inverted(True) \
.positionConversionFactor(ModuleConstants.kTurningEncoderPositionFactor) \
.velocityConversionFactor(ModuleConstants.kTurningEncoderVelocityFactor)

turningConfig.closedLoop.setFeedbackSensor(ClosedLoopConfig.FeedbackSensor.kAbsoluteEncoder)
turningConfig.closedLoop.pid(ModuleConstants.kTurningP, ModuleConstants.kTurningI, ModuleConstants.kTurningD)
turningConfig.closedLoop.outputRange(-1, 1)
turningConfig.closedLoop.positionWrappingEnabled(True)
turningConfig.closedLoop.positionWrappingInputRange(0, ModuleConstants.kTurningEncoderPositionPIDMaxInput)
turningConfig.closedLoop.setFeedbackSensor(ClosedLoopConfig.FeedbackSensor.kAbsoluteEncoder) \
.pid(ModuleConstants.kTurningP, ModuleConstants.kTurningI, ModuleConstants.kTurningD) \
.outputRange(-1, 1) \
.positionWrappingEnabled(True) \
.positionWrappingInputRange(0, ModuleConstants.kTurningEncoderPositionPIDMaxInput)

self.drive_motor.configure(drivingConfig, SparkMax.ResetMode.kResetSafeParameters, SparkMax.PersistMode.kPersistParameters)
self.turn_motor.configure(turningConfig, SparkMax.ResetMode.kResetSafeParameters, SparkMax.PersistMode.kPersistParameters)
Expand Down

0 comments on commit 55fab2f

Please sign in to comment.