It no worky.

This commit is contained in:
Aidan Ferguson 2016-02-09 19:32:27 -05:00
parent bc81c928a8
commit 8cca3ff8df
2 changed files with 40 additions and 17 deletions

View File

@ -1,7 +1,8 @@
#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
* throttle mode, in the same manner as you might control a traditional PWM
@ -11,8 +12,8 @@
#ifndef BUTTON_LAYOUT
#define BUTTON_LAYOUT
#define TRIGGER 0
#define THUMB 1
#define TRIGGER 1
#define THUMB 2
#endif
@ -24,7 +25,8 @@ class Robot: public IterativeRobot {
CANTalon shooter1;
CANTalon shooter2;
CANTalon ramp;
TankDrive drive;
// Counter ramp_lift;
RobotDrive drive;
Shooter shooter;
Joystick rstick, lstick;
@ -41,12 +43,13 @@ public:
shooter1(10), // shooter drive 1
shooter2(11), // shooter drive 2
ramp(12),
drive( // initialize TankDrive object.
&l1_drive, &l2_drive, &r1_drive, &r2_drive),
drive( // initialize RobotDrive object.
&l1_drive, &r1_drive),
shooter( // initialize Shooter object.
&shooter1, &shooter2, &ramp),
rstick(0), // right stick (operator)
lstick(1) // left stick (driver)
lstick(1)//, // left stick (driver)
//ramp_lift(1) // counter for the hall sensor on the
{
}
@ -69,21 +72,24 @@ public:
}
void TeleopPeriodic() {
drive.Drive(&lstick);
drive.ArcadeDrive(&lstick);
l2_drive.Set(l1_drive.Get());
r2_drive.Set(r1_drive.Get());
float power = (1.0 - rstick.GetThrottle()) / 2.0;
//shooter.SetPower(power);
shooter.SetPower(power);
if(rstick.GetRawButton(TRIGGER))
{
// SHOOT THE BALL
ramp.Set(-0.5);
ramp.Set(-1);
}
if(rstick.GetRawButton(THUMB))
{
// lower the ramp
ramp.Set(0.5);
ramp.Set(1);
}
else
{

View File

@ -18,17 +18,25 @@
* Encapsulates two RobotDrive objects and keeps them synced by sending
* identical ArcadeDrive calls to each. Also handles massaging of Joystick
* data to smooth out drive operations.
*
* TODO: Make this reflect what this class actually does.
*/
class TankDrive {
public:
TankDrive(CANTalon *l1, CANTalon *l2, CANTalon* r1, CANTalon *r2) {
dt1 = new RobotDrive(l1, r1);
dt2 = new RobotDrive(l2, r2);
CANTalon* left1 = l1;
CANTalon* right1 = r1;
CANTalon* left2 = l2;
CANTalon* right2 = r2;
//dt2 = new RobotDrive(l2, r2);
}
virtual ~TankDrive() {
delete dt1;
delete dt2;
// delete dt2;
}
/**
@ -37,7 +45,7 @@ public:
* Some math on the "rot" variable could make the driving smoother, I think.
*/
void Drive(Joystick *js) {
float x = js->GetX();
/*float x = js->GetX();
float y = js->GetY();
float th = -((1.0 - (js->GetThrottle()))
/ 2.0);
@ -52,14 +60,23 @@ public:
float speed = y * th;
// TODO: do some math here to smooth out turning?
float rot = x * th;
float rot = x * th;*/
dt1->ArcadeDrive(js);
left2.Set(left1.Get());
right2.Set(right1.Get());
// dt2->ArcadeDrive(js);
/*
dt1->ArcadeDrive(speed, rot, false);
dt2->ArcadeDrive(speed, rot, false);
dt2->ArcadeDrive(speed, rot, false);*/
}
private:
RobotDrive *dt1, *dt2;
RobotDrive *dt1/*, *dt2*/;
CANTalon l1, right1, left2, right2;
};
#endif /* SRC_TANKDRIVE_H_ */