Forgot throttle needs inverting. Actually drives now.
This commit is contained in:
parent
fae8d71f03
commit
9b8b4ff845
@ -1,5 +1,6 @@
|
|||||||
#include "WPILib.h"
|
#include "WPILib.h"
|
||||||
#include "TankDrive.h"
|
#include "TankDrive.h"
|
||||||
|
#include "Shooter.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This sample shows how to use the new CANTalon to just run a motor in a basic
|
* 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);
|
drive.Drive(&lstick);
|
||||||
|
|
||||||
float power = (1.0 - rstick.GetThrottle()) / 2.0;
|
float power = (1.0 - rstick.GetThrottle()) / 2.0;
|
||||||
shooter1.Set(power);
|
//shooter1.Set(power);
|
||||||
shooter2.Set(power);
|
//shooter2.Set(power);
|
||||||
|
shooter.SetPower(power);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,16 +9,21 @@
|
|||||||
#define SRC_SHOOTER_H_
|
#define SRC_SHOOTER_H_
|
||||||
|
|
||||||
class Shooter {
|
class Shooter {
|
||||||
RobotDrive shooterDrive;
|
|
||||||
public:
|
public:
|
||||||
Shooter(CANTalon *s1, CANTalon *s2) {
|
Shooter(CANTalon *s1, CANTalon *s2) {
|
||||||
shooterDrive = RobotDrive(s1, s2);
|
shooterDrive = new RobotDrive(s1, s2);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~Shooter()
|
||||||
|
{
|
||||||
|
delete shooterDrive;
|
||||||
}
|
}
|
||||||
virtual ~Shooter();
|
|
||||||
|
|
||||||
void SetPower(float power) {
|
void SetPower(float power) {
|
||||||
shooterDrive.ArcadeDrive(power, 0, false);
|
shooterDrive->TankDrive(power, -power, false);
|
||||||
}
|
}
|
||||||
|
private:
|
||||||
|
RobotDrive *shooterDrive;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SRC_SHOOTER_H_ */
|
#endif /* SRC_SHOOTER_H_ */
|
||||||
|
@ -23,8 +23,8 @@ class TankDrive {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
TankDrive(CANTalon *l1, CANTalon *l2, CANTalon* r1, CANTalon *r2) {
|
TankDrive(CANTalon *l1, CANTalon *l2, CANTalon* r1, CANTalon *r2) {
|
||||||
dt1 = RobotDrive(l1, r1);
|
dt1 = new RobotDrive(l1, r1);
|
||||||
dt2 = RobotDrive(l2, r2);
|
dt2 = new RobotDrive(l2, r2);
|
||||||
}
|
}
|
||||||
virtual ~TankDrive() {
|
virtual ~TankDrive() {
|
||||||
delete dt1;
|
delete dt1;
|
||||||
@ -37,7 +37,9 @@ public:
|
|||||||
* Some math on the "rot" variable could make the driving smoother, I think.
|
* Some math on the "rot" variable could make the driving smoother, I think.
|
||||||
*/
|
*/
|
||||||
void Drive(Joystick *js) {
|
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);
|
/ 2.0);
|
||||||
|
|
||||||
// set deadzone
|
// set deadzone
|
||||||
@ -51,12 +53,12 @@ public:
|
|||||||
float speed = y * th;
|
float speed = y * th;
|
||||||
float rot = x; // do some math here to smooth out turning?
|
float rot = x; // do some math here to smooth out turning?
|
||||||
|
|
||||||
dt1.ArcadeDrive(speed, rot, false);
|
dt1->ArcadeDrive(speed, rot, false);
|
||||||
dt2.ArcadeDrive(speed, rot, false);
|
dt2->ArcadeDrive(speed, rot, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RobotDrive dt1, dt2;
|
RobotDrive *dt1, *dt2;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SRC_TANKDRIVE_H_ */
|
#endif /* SRC_TANKDRIVE_H_ */
|
||||||
|
Reference in New Issue
Block a user