-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrobotcontainer.py
More file actions
60 lines (47 loc) · 2.32 KB
/
robotcontainer.py
File metadata and controls
60 lines (47 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Copyright (c) FIRST and other WPILib contributors.
# Open Source Software; you can modify and/or share it under the terms of
# the WPILib BSD license file in the root directory of this project.
import wpilib
import commands2
import commands2.cmd
import commands2.button
import commands.drive_command
import subsystems.drive_subsystem
class RobotContainer:
"""
This class is where the bulk of the robot should be declared. Since Command-based is a
"declarative" paradigm, very little robot logic should actually be handled in the :class:`.Robot`
periodic methods (other than the scheduler calls). Instead, the structure of the robot (including
subsystems, commands, and button mappings) should be declared here.
"""
def __init__(self):
"""The container for the robot. Contains subsystems, OI devices, and commands."""
# The robot's subsystems
self.robotDrive = subsystems.drive_subsystem.DriveSubsystem()
# The driver's controller
self.driverController = wpilib.Joystick(0)
# Configure the button bindings
self.configure_button_bindings()
# Configure default commands
# Set the default drive command to split-stick arcade drive
self.robotDrive.setDefaultCommand(
# A single-stick swerve drive command - field relative, and rate limited
commands.drive_command.DriveCommand(self.robotDrive,
self.driverController.getX(),
self.driverController.getY(),
self.driverController.getZ(),
True,
True)
)
def configure_button_bindings(self):
"""
Use this method to define your button->command mappings. Buttons can be created via the button
factories on commands2.button.CommandGenericHID or one of its
subclasses (commands2.button.CommandJoystick or command2.button.CommandXboxController).
"""
def get_autonomous_command(self) -> commands2.Command:
"""
Use this to pass the autonomous command to the main :class:`.Robot` class.
:returns: the command to run in autonomous
"""
return commands2.InstantCommand()