File tree 3 files changed +65
-0
lines changed
3 files changed +65
-0
lines changed Original file line number Diff line number Diff line change
1
+ using WPILib . Commands ;
2
+
3
+ namespace WPILib . Extras
4
+ {
5
+ /// <summary>
6
+ /// Implements the boilerplate needed to use an <see cref="IterativeRobot"/>
7
+ /// with the command-based model, by running the scheduler as needed.
8
+ /// </summary>
9
+ public abstract class CommandRobot : IterativeRobot
10
+ {
11
+ // This function is called periodically while disabled
12
+ public override void DisabledPeriodic ( ) => Scheduler . Instance . Run ( ) ;
13
+
14
+ // This function is called periodically during autonomous
15
+ public override void AutonomousPeriodic ( ) => Scheduler . Instance . Run ( ) ;
16
+
17
+ // This function is called when the disabled button is hit.
18
+ public override void DisabledInit ( ) { }
19
+
20
+ // This function is called periodically during operator control
21
+ public override void TeleopPeriodic ( ) => Scheduler . Instance . Run ( ) ;
22
+
23
+ // This function is called periodically during test mode
24
+ public override void TestPeriodic ( ) => LiveWindow . LiveWindow . Run ( ) ;
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using WPILib . Commands ;
3
+
4
+ namespace WPILib . Extras
5
+ {
6
+ /// <summary>
7
+ /// A <see cref="SubsystemCommand"/> depends on the given <see cref="Subsystem"/>.
8
+ /// It stores a local reference to its <see cref="Subsystem" /> to ease access.
9
+ /// </summary>
10
+ public abstract class SubsystemCommand : Command
11
+ {
12
+ protected readonly Subsystem m_subsystem ;
13
+
14
+ /// <summary>
15
+ /// Creates a new <see cref="SubsystemCommand"/> which will depend on the given <see cref="Subsystem"/>.
16
+ /// </summary>
17
+ /// <param name="action">The <see cref="Action"/> to run.</param>
18
+ public SubsystemCommand ( Subsystem subsystem )
19
+ {
20
+ Requires ( subsystem ) ;
21
+ m_subsystem = subsystem ;
22
+ }
23
+
24
+ /// <summary>
25
+ /// Creates a new <see cref="SubsystemCommand"/> with a specific name,
26
+ /// which will depend on the given <see cref="Subsystem"/>.
27
+ /// </summary>
28
+ /// <param name="subsystem">The <see cref="Subsystem"/> to require.</param>
29
+ /// <param name="name">The name for the command.</param>
30
+ public SubsystemCommand ( Subsystem subsystem , string name )
31
+ : base ( name )
32
+ {
33
+ Requires ( subsystem ) ;
34
+ m_subsystem = subsystem ;
35
+ }
36
+ }
37
+ }
Original file line number Diff line number Diff line change 80
80
<Reference Include =" System.Xml" />
81
81
</ItemGroup >
82
82
<ItemGroup >
83
+ <Compile Include =" SubsystemCommand.cs" />
83
84
<Compile Include =" ActionCommand.cs" />
84
85
<Compile Include =" AttributedCommandModel\AttributedRobot.cs" />
85
86
<Compile Include =" AttributedCommandModel\ButtonMethod.cs" />
89
90
<Compile Include =" AttributedCommandModel\RunCommandAttribute.cs" />
90
91
<Compile Include =" AttributedCommandModel\RunCommandOnJoystickAttribute.cs" />
91
92
<Compile Include =" AttributedCommandModel\RunCommandOnNetworkKeyAttribute.cs" />
93
+ <Compile Include =" CommandRobot.cs" />
92
94
<Compile Include =" LabVIEWRobot.cs" />
93
95
<Compile Include =" NavX\AHRS.cs" />
94
96
<Compile Include =" NavX\ContinuousAngleTracker.cs" />
You can’t perform that action at this time.
0 commit comments