It no worky.
This commit is contained in:
parent
bc81c928a8
commit
8cca3ff8df
@ -1,7 +1,8 @@
|
|||||||
#include "WPILib.h"
|
#include "WPILib.h"
|
||||||
#include "TankDrive.h"
|
//#include "TankDrive.h"
|
||||||
#include "Shooter.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
|
||||||
* throttle mode, in the same manner as you might control a traditional PWM
|
* throttle mode, in the same manner as you might control a traditional PWM
|
||||||
@ -11,8 +12,8 @@
|
|||||||
#ifndef BUTTON_LAYOUT
|
#ifndef BUTTON_LAYOUT
|
||||||
#define BUTTON_LAYOUT
|
#define BUTTON_LAYOUT
|
||||||
|
|
||||||
#define TRIGGER 0
|
#define TRIGGER 1
|
||||||
#define THUMB 1
|
#define THUMB 2
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -24,7 +25,8 @@ class Robot: public IterativeRobot {
|
|||||||
CANTalon shooter1;
|
CANTalon shooter1;
|
||||||
CANTalon shooter2;
|
CANTalon shooter2;
|
||||||
CANTalon ramp;
|
CANTalon ramp;
|
||||||
TankDrive drive;
|
// Counter ramp_lift;
|
||||||
|
RobotDrive drive;
|
||||||
Shooter shooter;
|
Shooter shooter;
|
||||||
Joystick rstick, lstick;
|
Joystick rstick, lstick;
|
||||||
|
|
||||||
@ -41,12 +43,13 @@ public:
|
|||||||
shooter1(10), // shooter drive 1
|
shooter1(10), // shooter drive 1
|
||||||
shooter2(11), // shooter drive 2
|
shooter2(11), // shooter drive 2
|
||||||
ramp(12),
|
ramp(12),
|
||||||
drive( // initialize TankDrive object.
|
drive( // initialize RobotDrive object.
|
||||||
&l1_drive, &l2_drive, &r1_drive, &r2_drive),
|
&l1_drive, &r1_drive),
|
||||||
shooter( // initialize Shooter object.
|
shooter( // initialize Shooter object.
|
||||||
&shooter1, &shooter2, &ramp),
|
&shooter1, &shooter2, &ramp),
|
||||||
rstick(0), // right stick (operator)
|
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() {
|
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;
|
float power = (1.0 - rstick.GetThrottle()) / 2.0;
|
||||||
|
|
||||||
//shooter.SetPower(power);
|
shooter.SetPower(power);
|
||||||
if(rstick.GetRawButton(TRIGGER))
|
if(rstick.GetRawButton(TRIGGER))
|
||||||
{
|
{
|
||||||
// SHOOT THE BALL
|
// SHOOT THE BALL
|
||||||
ramp.Set(-0.5);
|
ramp.Set(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rstick.GetRawButton(THUMB))
|
if(rstick.GetRawButton(THUMB))
|
||||||
{
|
{
|
||||||
// lower the ramp
|
// lower the ramp
|
||||||
ramp.Set(0.5);
|
ramp.Set(1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -18,17 +18,25 @@
|
|||||||
* Encapsulates two RobotDrive objects and keeps them synced by sending
|
* Encapsulates two RobotDrive objects and keeps them synced by sending
|
||||||
* identical ArcadeDrive calls to each. Also handles massaging of Joystick
|
* identical ArcadeDrive calls to each. Also handles massaging of Joystick
|
||||||
* data to smooth out drive operations.
|
* data to smooth out drive operations.
|
||||||
|
*
|
||||||
|
* TODO: Make this reflect what this class actually does.
|
||||||
*/
|
*/
|
||||||
class TankDrive {
|
class TankDrive {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TankDrive(CANTalon *l1, CANTalon *l2, CANTalon* r1, CANTalon *r2) {
|
TankDrive(CANTalon *l1, CANTalon *l2, CANTalon* r1, CANTalon *r2) {
|
||||||
dt1 = new RobotDrive(l1, r1);
|
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() {
|
virtual ~TankDrive() {
|
||||||
delete dt1;
|
delete dt1;
|
||||||
delete dt2;
|
// delete dt2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,7 +45,7 @@ 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();
|
/*float x = js->GetX();
|
||||||
float y = js->GetY();
|
float y = js->GetY();
|
||||||
float th = -((1.0 - (js->GetThrottle()))
|
float th = -((1.0 - (js->GetThrottle()))
|
||||||
/ 2.0);
|
/ 2.0);
|
||||||
@ -52,14 +60,23 @@ public:
|
|||||||
|
|
||||||
float speed = y * th;
|
float speed = y * th;
|
||||||
// TODO: do some math here to smooth out turning?
|
// 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);
|
dt1->ArcadeDrive(speed, rot, false);
|
||||||
dt2->ArcadeDrive(speed, rot, false);
|
dt2->ArcadeDrive(speed, rot, false);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RobotDrive *dt1, *dt2;
|
RobotDrive *dt1/*, *dt2*/;
|
||||||
|
|
||||||
|
CANTalon l1, right1, left2, right2;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SRC_TANKDRIVE_H_ */
|
#endif /* SRC_TANKDRIVE_H_ */
|
||||||
|
Reference in New Issue
Block a user