File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 22# Open Source Software; you can modify and/or share it under the terms of
33# the WPILib BSD license file in the root directory of this project.
44
5- from typing import Union , cast
5+ from typing import Generic
66
77from wpimath .trajectory import TrapezoidProfile
88
99from .subsystem import Subsystem
10+ from .typing import GenericProfiledPIDController
1011
1112
12- class ProfiledPIDSubsystem (Subsystem ):
13+ class ProfiledPIDSubsystem (Subsystem , Generic [ GenericProfiledPIDController ] ):
1314 """
1415 A subsystem that uses a :class:`wpimath.controller.ProfiledPIDController`
1516 or :class:`wpimath.controller.ProfiledPIDControllerRadians` to
@@ -19,12 +20,12 @@ class ProfiledPIDSubsystem(Subsystem):
1920
2021 def __init__ (
2122 self ,
22- controller ,
23+ controller : GenericProfiledPIDController ,
2324 initial_position : float = 0 ,
2425 ):
2526 """Creates a new PIDSubsystem."""
2627 super ().__init__ ()
27- self ._controller = controller
28+ self ._controller : GenericProfiledPIDController = controller
2829 self ._enabled = False
2930 self .setGoal (initial_position )
3031
@@ -38,7 +39,7 @@ def periodic(self):
3839
3940 def getController (
4041 self ,
41- ):
42+ ) -> GenericProfiledPIDController :
4243 """Returns the controller"""
4344 return self ._controller
4445
Original file line number Diff line number Diff line change 1+ from typing import TypeVar
2+
3+ from wpimath .controller import ProfiledPIDController , ProfiledPIDControllerRadians
4+
5+ GenericProfiledPIDController = TypeVar (
6+ "GenericProfiledPIDController" , ProfiledPIDControllerRadians , ProfiledPIDController
7+ )
You can’t perform that action at this time.
0 commit comments