Forgot throttle needs inverting. Actually drives now.

This commit is contained in:
Jason Cox 2016-02-03 07:50:19 -05:00
parent fae8d71f03
commit 9b8b4ff845
3 changed files with 21 additions and 12 deletions

View File

@ -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);
}

View File

@ -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_ */

View File

@ -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_ */