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 2
2
# Open Source Software; you can modify and/or share it under the terms of
3
3
# the WPILib BSD license file in the root directory of this project.
4
4
5
- from typing import Union , cast
5
+ from typing import Generic
6
6
7
7
from wpimath .trajectory import TrapezoidProfile
8
8
9
9
from .subsystem import Subsystem
10
+ from .typing import GenericProfiledPIDController
10
11
11
12
12
- class ProfiledPIDSubsystem (Subsystem ):
13
+ class ProfiledPIDSubsystem (Subsystem , Generic [ GenericProfiledPIDController ] ):
13
14
"""
14
15
A subsystem that uses a :class:`wpimath.controller.ProfiledPIDController`
15
16
or :class:`wpimath.controller.ProfiledPIDControllerRadians` to
@@ -19,12 +20,12 @@ class ProfiledPIDSubsystem(Subsystem):
19
20
20
21
def __init__ (
21
22
self ,
22
- controller ,
23
+ controller : GenericProfiledPIDController ,
23
24
initial_position : float = 0 ,
24
25
):
25
26
"""Creates a new PIDSubsystem."""
26
27
super ().__init__ ()
27
- self ._controller = controller
28
+ self ._controller : GenericProfiledPIDController = controller
28
29
self ._enabled = False
29
30
self .setGoal (initial_position )
30
31
@@ -38,7 +39,7 @@ def periodic(self):
38
39
39
40
def getController (
40
41
self ,
41
- ):
42
+ ) -> GenericProfiledPIDController :
42
43
"""Returns the controller"""
43
44
return self ._controller
44
45
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