config

 1# Native imports
 2from typing import Tuple
 3
 4# Third-party imports
 5from wpimath.geometry import Rotation2d
 6
 7class OperatorRobotConfig:
 8    # Default start position for red alliance using always-blue-alliance coordinates
 9    # Coordinates are x (meters), y (meters), and rotation (degrees)
10    red_default_start_pose: Tuple[float] = (10.0, 1.5, 0.0)
11    # Default start position for blue alliance using always-blue-alliance coordinates
12    # Coordinates are x (meters), y (meters), and rotation (degrees)
13    blue_default_start_pose: Tuple[float] = (7.7, 6.0, 180.0)
14    # Give in front-left, front-right, back-left, back-right order
15    # ids for the drive controllers
16    swerve_module_channels: Tuple[int] = (50, 53, 56, 59)
17    # Give in front-left, front-right, back-left, back-right order
18    # starting rotational position for the absolute encoders
19    swerve_abs_encoder_calibrations: Tuple[float] = (
20        10.283203125 / 360.0, 323.6148 / 360.0,  347.2737188 / 360.0, 83.2865625 / 360.0
21    )
22    swerve_steer_pid: Tuple[float] = (0.011, 0, 0)
23    swerve_drive_pid: Tuple[float] = (0.0021, 0, 0, 0) # TODO: tune PIDs
24    pathplanner_translation_pid: Tuple[float] = (4.0, 0.0, 0.0)
25    pathplanner_rotation_pid: Tuple[float] = (5.0, 0.0, 0.0)
26
27    # Camera mounts and robot geometry are defined in constants/robot_geometry.py.
28    # See constants.robot_geometry.CAMERAS for positions, angles, and FOV.
29
30    # Vision filtering thresholds (see subsystem/localization/VISION.md)
31    vision_ambiguity_threshold: float = 0.2
32    vision_single_tag_max_distance_m: float = 4.0
33    vision_field_border_margin_m: float = 0.5
34    vision_max_z_error_m: float = 0.5
35    vision_max_rotation_error_deg: float = 20.0
36
37    # Dynamic standard deviation base values (x meters, y meters, theta radians)
38    # See VISION.md for how these are scaled with distance.
39    vision_single_tag_std_devs: Tuple[float] = (4.0, 4.0, float('inf'))
40    vision_multi_tag_std_devs: Tuple[float] = (0.5, 0.5, 1.0)
41    vision_std_dev_distance_factor: float = 30.0
42    # How many robot loop cycles between vision updates.
43    # 1 = every cycle (~20ms). Increase if vision still uses too much CPU.
44    vision_update_rate_divisor: int = 1
45    # First three elements are PID, last two elements are trapezoidal profile
46    # Translation trapezoidal profile units are mps and mps^2, rotation are rps and rps^2
47    pid_to_pose_translation_pid_profile: Tuple[float] = (2.0, 0.0, 0.0, 3, 1.5)
48    pid_to_pose_rotation_pid_profile: Tuple[float] = (
49        1.0, 0.0, 0.0, Rotation2d.fromDegrees(360).radians(), Rotation2d.fromDegrees(360).radians()
50    )
51    # Tolerance of x, y, and omega position errors within which robot is at target pose
52    # x error is in meters, y error is in meters, omega error is in radians
53    pid_to_pose_setpoint_tolerances: Tuple[float] = (0.25, 0.25, Rotation2d.fromDegrees(10).radians())
54
55    # Robot motion constraints when running PathPlanner during teleop.
56    # Values to give are: max translation velocity (mps), max translation acceleration (mps^2),
57    # max angular velocity (dps), max angular acceleration (dps^2).
58    teleop_pathplan_constraints: Tuple[float] = (2.5, 2.0, 360.0, 360.0)
59
60    # Placeholder: not yet wired into IntakePosition (uses hardcoded gains)
61    intake_pivot_pid: Tuple[float] = [0, 0, 0, 1 / 565]
62
63
64class HoodConfig:
65    # PID gains for hood position control (WPILib PIDController)
66    hoodPID = (0.2, 0.02, 0)
67    # ArmFeedforward gains: (kS, kG, kV, kA)
68    hoodFeedforward = (0.4, 0.04, 0, 0)
69    # Offset in degrees from hood 0-position to true horizontal.
70    horizontalOffsetDegrees = 0.0
71
72
73class NfcBatteryTrackerConfig:
74    # Serial port for PN532 NFC reader.
75    # Default COM12 for dev/sim. roboRIO port TBD when hardware is wired.
76    nfc_serial_port: str = 'COM12'
77    nfc_baud_rate: int = 115200
78    nfc_poll_interval_disabled: float = 1.0   # seconds between polls when disabled
79
80
81class ShooterConfig:
82    # Configs for shooter
83    shooterFeedMotorPIDF = (0.000224999996135011, 0, 0, 1 / 473)
84    shooterFlywheelMotorPIDF = (0, 0, 0, 1 / 560)
class OperatorRobotConfig:
 8class OperatorRobotConfig:
 9    # Default start position for red alliance using always-blue-alliance coordinates
10    # Coordinates are x (meters), y (meters), and rotation (degrees)
11    red_default_start_pose: Tuple[float] = (10.0, 1.5, 0.0)
12    # Default start position for blue alliance using always-blue-alliance coordinates
13    # Coordinates are x (meters), y (meters), and rotation (degrees)
14    blue_default_start_pose: Tuple[float] = (7.7, 6.0, 180.0)
15    # Give in front-left, front-right, back-left, back-right order
16    # ids for the drive controllers
17    swerve_module_channels: Tuple[int] = (50, 53, 56, 59)
18    # Give in front-left, front-right, back-left, back-right order
19    # starting rotational position for the absolute encoders
20    swerve_abs_encoder_calibrations: Tuple[float] = (
21        10.283203125 / 360.0, 323.6148 / 360.0,  347.2737188 / 360.0, 83.2865625 / 360.0
22    )
23    swerve_steer_pid: Tuple[float] = (0.011, 0, 0)
24    swerve_drive_pid: Tuple[float] = (0.0021, 0, 0, 0) # TODO: tune PIDs
25    pathplanner_translation_pid: Tuple[float] = (4.0, 0.0, 0.0)
26    pathplanner_rotation_pid: Tuple[float] = (5.0, 0.0, 0.0)
27
28    # Camera mounts and robot geometry are defined in constants/robot_geometry.py.
29    # See constants.robot_geometry.CAMERAS for positions, angles, and FOV.
30
31    # Vision filtering thresholds (see subsystem/localization/VISION.md)
32    vision_ambiguity_threshold: float = 0.2
33    vision_single_tag_max_distance_m: float = 4.0
34    vision_field_border_margin_m: float = 0.5
35    vision_max_z_error_m: float = 0.5
36    vision_max_rotation_error_deg: float = 20.0
37
38    # Dynamic standard deviation base values (x meters, y meters, theta radians)
39    # See VISION.md for how these are scaled with distance.
40    vision_single_tag_std_devs: Tuple[float] = (4.0, 4.0, float('inf'))
41    vision_multi_tag_std_devs: Tuple[float] = (0.5, 0.5, 1.0)
42    vision_std_dev_distance_factor: float = 30.0
43    # How many robot loop cycles between vision updates.
44    # 1 = every cycle (~20ms). Increase if vision still uses too much CPU.
45    vision_update_rate_divisor: int = 1
46    # First three elements are PID, last two elements are trapezoidal profile
47    # Translation trapezoidal profile units are mps and mps^2, rotation are rps and rps^2
48    pid_to_pose_translation_pid_profile: Tuple[float] = (2.0, 0.0, 0.0, 3, 1.5)
49    pid_to_pose_rotation_pid_profile: Tuple[float] = (
50        1.0, 0.0, 0.0, Rotation2d.fromDegrees(360).radians(), Rotation2d.fromDegrees(360).radians()
51    )
52    # Tolerance of x, y, and omega position errors within which robot is at target pose
53    # x error is in meters, y error is in meters, omega error is in radians
54    pid_to_pose_setpoint_tolerances: Tuple[float] = (0.25, 0.25, Rotation2d.fromDegrees(10).radians())
55
56    # Robot motion constraints when running PathPlanner during teleop.
57    # Values to give are: max translation velocity (mps), max translation acceleration (mps^2),
58    # max angular velocity (dps), max angular acceleration (dps^2).
59    teleop_pathplan_constraints: Tuple[float] = (2.5, 2.0, 360.0, 360.0)
60
61    # Placeholder: not yet wired into IntakePosition (uses hardcoded gains)
62    intake_pivot_pid: Tuple[float] = [0, 0, 0, 1 / 565]
red_default_start_pose: Tuple[float] = (10.0, 1.5, 0.0)
blue_default_start_pose: Tuple[float] = (7.7, 6.0, 180.0)
swerve_module_channels: Tuple[int] = (50, 53, 56, 59)
swerve_abs_encoder_calibrations: Tuple[float] = (0.028564453125, 0.89893, 0.9646492188888889, 0.2313515625)
swerve_steer_pid: Tuple[float] = (0.011, 0, 0)
swerve_drive_pid: Tuple[float] = (0.0021, 0, 0, 0)
pathplanner_translation_pid: Tuple[float] = (4.0, 0.0, 0.0)
pathplanner_rotation_pid: Tuple[float] = (5.0, 0.0, 0.0)
vision_ambiguity_threshold: float = 0.2
vision_single_tag_max_distance_m: float = 4.0
vision_field_border_margin_m: float = 0.5
vision_max_z_error_m: float = 0.5
vision_max_rotation_error_deg: float = 20.0
vision_single_tag_std_devs: Tuple[float] = (4.0, 4.0, inf)
vision_multi_tag_std_devs: Tuple[float] = (0.5, 0.5, 1.0)
vision_std_dev_distance_factor: float = 30.0
vision_update_rate_divisor: int = 1
pid_to_pose_translation_pid_profile: Tuple[float] = (2.0, 0.0, 0.0, 3, 1.5)
pid_to_pose_rotation_pid_profile: Tuple[float] = (1.0, 0.0, 0.0, 6.283185307179586, 6.283185307179586)
pid_to_pose_setpoint_tolerances: Tuple[float] = (0.25, 0.25, 0.17453292519943295)
teleop_pathplan_constraints: Tuple[float] = (2.5, 2.0, 360.0, 360.0)
intake_pivot_pid: Tuple[float] = [0, 0, 0, 0.0017699115044247787]
class HoodConfig:
65class HoodConfig:
66    # PID gains for hood position control (WPILib PIDController)
67    hoodPID = (0.2, 0.02, 0)
68    # ArmFeedforward gains: (kS, kG, kV, kA)
69    hoodFeedforward = (0.4, 0.04, 0, 0)
70    # Offset in degrees from hood 0-position to true horizontal.
71    horizontalOffsetDegrees = 0.0
hoodPID = (0.2, 0.02, 0)
hoodFeedforward = (0.4, 0.04, 0, 0)
horizontalOffsetDegrees = 0.0
class NfcBatteryTrackerConfig:
74class NfcBatteryTrackerConfig:
75    # Serial port for PN532 NFC reader.
76    # Default COM12 for dev/sim. roboRIO port TBD when hardware is wired.
77    nfc_serial_port: str = 'COM12'
78    nfc_baud_rate: int = 115200
79    nfc_poll_interval_disabled: float = 1.0   # seconds between polls when disabled
nfc_serial_port: str = 'COM12'
nfc_baud_rate: int = 115200
nfc_poll_interval_disabled: float = 1.0
class ShooterConfig:
82class ShooterConfig:
83    # Configs for shooter
84    shooterFeedMotorPIDF = (0.000224999996135011, 0, 0, 1 / 473)
85    shooterFlywheelMotorPIDF = (0, 0, 0, 1 / 560)
shooterFeedMotorPIDF = (0.000224999996135011, 0, 0, 0.0021141649048625794)
shooterFlywheelMotorPIDF = (0, 0, 0, 0.0017857142857142857)