Merge branch 'shooter'
This commit is contained in:
commit
eb9c9b3415
@ -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
|
||||
@ -15,7 +16,7 @@ class Robot: public IterativeRobot {
|
||||
CANTalon shooter1;
|
||||
CANTalon shooter2;
|
||||
TankDrive drive;
|
||||
|
||||
Shooter shooter;
|
||||
Joystick rstick, lstick;
|
||||
|
||||
// update every 0.01 seconds/10 milliseconds.
|
||||
@ -24,11 +25,19 @@ class Robot: public IterativeRobot {
|
||||
|
||||
public:
|
||||
Robot() :
|
||||
r1_drive(1), // Initialize the Talon as device 1. Use the roboRIO web
|
||||
r2_drive(2), // interface to change the device number on the talons.
|
||||
l1_drive(3), l2_drive(4), shooter1(10), shooter2(11), drive(
|
||||
&l1_drive, &l2_drive, &r1_drive, &r2_drive), rstick(0), lstick(
|
||||
1) {
|
||||
r1_drive(1), // right wheel 1
|
||||
r2_drive(2), // right wheel 2
|
||||
l1_drive(3), // left wheel 1
|
||||
l2_drive(4), // left wheel 2
|
||||
shooter1(10), // shooter drive 1
|
||||
shooter2(11), // shooter drive 2
|
||||
drive( // initialize TankDrive object.
|
||||
&l1_drive, &l2_drive, &r1_drive, &r2_drive),
|
||||
shooter( // initialize Shooter object.
|
||||
&shooter1, &shooter2),
|
||||
rstick(0), // right stick (operator)
|
||||
lstick(1) // left stick (driver)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@ -53,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);
|
||||
|
||||
}
|
||||
|
||||
|
29
DriveBase/src/Shooter.h
Normal file
29
DriveBase/src/Shooter.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Shooter.h
|
||||
*
|
||||
* Created on: Feb 2, 2016
|
||||
* Author: Jason
|
||||
*/
|
||||
|
||||
#ifndef SRC_SHOOTER_H_
|
||||
#define SRC_SHOOTER_H_
|
||||
|
||||
class Shooter {
|
||||
public:
|
||||
Shooter(CANTalon *s1, CANTalon *s2) {
|
||||
shooterDrive = new RobotDrive(s1, s2);
|
||||
}
|
||||
|
||||
virtual ~Shooter()
|
||||
{
|
||||
delete shooterDrive;
|
||||
}
|
||||
|
||||
void SetPower(float power) {
|
||||
shooterDrive->TankDrive(power, -power, false);
|
||||
}
|
||||
private:
|
||||
RobotDrive *shooterDrive;
|
||||
};
|
||||
|
||||
#endif /* SRC_SHOOTER_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_ */
|
||||
|
Reference in New Issue
Block a user