From 9b8b4ff8457e95f69f8819992712a7887cb1fd84 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Wed, 3 Feb 2016 07:50:19 -0500 Subject: [PATCH] Forgot throttle needs inverting. Actually drives now. --- DriveBase/src/Robot.cpp | 6 ++++-- DriveBase/src/Shooter.h | 13 +++++++++---- DriveBase/src/TankDrive.h | 14 ++++++++------ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/DriveBase/src/Robot.cpp b/DriveBase/src/Robot.cpp index 877480b..4a8ad95 100644 --- a/DriveBase/src/Robot.cpp +++ b/DriveBase/src/Robot.cpp @@ -1,5 +1,6 @@ #include "WPILib.h" #include "TankDrive.h" +#include "Shooter.h" /** * This sample shows how to use the new CANTalon to just run a motor in a basic @@ -61,8 +62,9 @@ public: drive.Drive(&lstick); float power = (1.0 - rstick.GetThrottle()) / 2.0; - shooter1.Set(power); - shooter2.Set(power); + //shooter1.Set(power); + //shooter2.Set(power); + shooter.SetPower(power); } diff --git a/DriveBase/src/Shooter.h b/DriveBase/src/Shooter.h index 2cf4e41..3a44dcf 100644 --- a/DriveBase/src/Shooter.h +++ b/DriveBase/src/Shooter.h @@ -9,16 +9,21 @@ #define SRC_SHOOTER_H_ class Shooter { - RobotDrive shooterDrive; public: Shooter(CANTalon *s1, CANTalon *s2) { - shooterDrive = RobotDrive(s1, s2); + shooterDrive = new RobotDrive(s1, s2); + } + + virtual ~Shooter() + { + delete shooterDrive; } - virtual ~Shooter(); void SetPower(float power) { - shooterDrive.ArcadeDrive(power, 0, false); + shooterDrive->TankDrive(power, -power, false); } +private: + RobotDrive *shooterDrive; }; #endif /* SRC_SHOOTER_H_ */ diff --git a/DriveBase/src/TankDrive.h b/DriveBase/src/TankDrive.h index bc8ad0e..b41c796 100644 --- a/DriveBase/src/TankDrive.h +++ b/DriveBase/src/TankDrive.h @@ -23,8 +23,8 @@ class TankDrive { public: TankDrive(CANTalon *l1, CANTalon *l2, CANTalon* r1, CANTalon *r2) { - dt1 = RobotDrive(l1, r1); - dt2 = RobotDrive(l2, r2); + dt1 = new RobotDrive(l1, r1); + dt2 = new RobotDrive(l2, r2); } virtual ~TankDrive() { delete dt1; @@ -37,7 +37,9 @@ public: * Some math on the "rot" variable could make the driving smoother, I think. */ void Drive(Joystick *js) { - float x = js->GetX(), y = js->GetY(), th = ((1.0 - (js.GetThrottle())) + float x = js->GetX(); + float y = js->GetY(); + float th = -((1.0 - (js->GetThrottle())) / 2.0); // set deadzone @@ -51,12 +53,12 @@ public: float speed = y * th; float rot = x; // do some math here to smooth out turning? - dt1.ArcadeDrive(speed, rot, false); - dt2.ArcadeDrive(speed, rot, false); + dt1->ArcadeDrive(speed, rot, false); + dt2->ArcadeDrive(speed, rot, false); } private: - RobotDrive dt1, dt2; + RobotDrive *dt1, *dt2; }; #endif /* SRC_TANKDRIVE_H_ */