From fae8d71f03f2db7ae32ec1411450bdeeb291bf9f Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 2 Feb 2016 10:18:19 -0500 Subject: [PATCH] Added Shooter class. --- DriveBase/src/Robot.cpp | 20 ++++++++++++++------ DriveBase/src/Shooter.h | 24 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 DriveBase/src/Shooter.h diff --git a/DriveBase/src/Robot.cpp b/DriveBase/src/Robot.cpp index d01513e..877480b 100644 --- a/DriveBase/src/Robot.cpp +++ b/DriveBase/src/Robot.cpp @@ -15,7 +15,7 @@ class Robot: public IterativeRobot { CANTalon shooter1; CANTalon shooter2; TankDrive drive; - + Shooter shooter; Joystick rstick, lstick; // update every 0.01 seconds/10 milliseconds. @@ -24,11 +24,19 @@ class Robot: public IterativeRobot { public: Robot() : - r1_drive(1), // Initialize the Talon as device 1. Use the roboRIO web - r2_drive(2), // interface to change the device number on the talons. - l1_drive(3), l2_drive(4), shooter1(10), shooter2(11), drive( - &l1_drive, &l2_drive, &r1_drive, &r2_drive), rstick(0), lstick( - 1) { + r1_drive(1), // right wheel 1 + r2_drive(2), // right wheel 2 + l1_drive(3), // left wheel 1 + l2_drive(4), // left wheel 2 + shooter1(10), // shooter drive 1 + shooter2(11), // shooter drive 2 + drive( // initialize TankDrive object. + &l1_drive, &l2_drive, &r1_drive, &r2_drive), + shooter( // initialize Shooter object. + &shooter1, &shooter2), + rstick(0), // right stick (operator) + lstick(1) // left stick (driver) + { } diff --git a/DriveBase/src/Shooter.h b/DriveBase/src/Shooter.h new file mode 100644 index 0000000..2cf4e41 --- /dev/null +++ b/DriveBase/src/Shooter.h @@ -0,0 +1,24 @@ +/* + * Shooter.h + * + * Created on: Feb 2, 2016 + * Author: Jason + */ + +#ifndef SRC_SHOOTER_H_ +#define SRC_SHOOTER_H_ + +class Shooter { + RobotDrive shooterDrive; +public: + Shooter(CANTalon *s1, CANTalon *s2) { + shooterDrive = RobotDrive(s1, s2); + } + virtual ~Shooter(); + + void SetPower(float power) { + shooterDrive.ArcadeDrive(power, 0, false); + } +}; + +#endif /* SRC_SHOOTER_H_ */