Added shooter Talons to the program. Controlled by opperator throttle.
This commit is contained in:
parent
6d903af729
commit
d4ae350953
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1,3 @@
|
||||
.metadata
|
||||
DriveBase/.settings
|
||||
DriveBase/sysProps.xml
|
||||
|
@ -12,10 +12,12 @@ class Robot : public IterativeRobot {
|
||||
CANTalon r2_drive;
|
||||
CANTalon l1_drive;
|
||||
CANTalon l2_drive;
|
||||
CANTalon shooter1;
|
||||
CANTalon shooter2;
|
||||
RobotDrive drivetrain1;
|
||||
RobotDrive drivetrain2;
|
||||
|
||||
Joystick lstick;
|
||||
Joystick rstick, lstick;
|
||||
|
||||
// update every 0.01 seconds/10 milliseconds.
|
||||
// The talon only receives control packets every 10ms.
|
||||
@ -27,9 +29,12 @@ public:
|
||||
r2_drive(2), // interface to change the device number on the talons.
|
||||
l1_drive(3),
|
||||
l2_drive(4),
|
||||
shooter1(10),
|
||||
shooter2(11),
|
||||
drivetrain1(l1_drive, r1_drive),
|
||||
drivetrain2(l2_drive, r2_drive),
|
||||
lstick(0)
|
||||
rstick(0),
|
||||
lstick(1)
|
||||
{
|
||||
printf("Initializing Robot...");
|
||||
printf("Initializing TankDrive");
|
||||
@ -49,6 +54,8 @@ public:
|
||||
r2_drive.SetSafetyEnabled(false);
|
||||
l1_drive.SetSafetyEnabled(false);
|
||||
l2_drive.SetSafetyEnabled(false);
|
||||
shooter1.SetSafetyEnabled(false);
|
||||
shooter2.SetSafetyEnabled(false);
|
||||
}
|
||||
|
||||
void TeleopInit()
|
||||
@ -66,12 +73,19 @@ public:
|
||||
void TeleopPeriodic()
|
||||
{
|
||||
printf("Teleop Periodic Start.");
|
||||
float speed = lstick.GetY() * (lstick.GetThrottle());
|
||||
float rot = (-1) * lstick.GetTwist();
|
||||
float speed = lstick.GetY() * ((1.0 - (lstick.GetThrottle()))/2.0);
|
||||
float rot = lstick.GetX();
|
||||
|
||||
drivetrain1.ArcadeDrive(speed, rot, false);
|
||||
drivetrain2.ArcadeDrive(speed, rot, false);
|
||||
|
||||
float power = (1.0 - rstick.GetThrottle()) / 2.0;
|
||||
shooter1.Set(power);
|
||||
shooter2.Set(power);
|
||||
|
||||
printf("~Teleop Periodic End.");
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* Runs the motor from the output of a Joystick.
|
||||
|
BIN
FRCUserProgram
Executable file
BIN
FRCUserProgram
Executable file
Binary file not shown.
41
robot.cpp
Normal file
41
robot.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include "WPILib.h"
|
||||
|
||||
/**
|
||||
* This is a demo program showing the use of the RobotDrive class.
|
||||
* The SampleRobot class is the base of a robot application that will automatically call your
|
||||
* Autonomous and OperatorControl methods at the right time as controlled by the switches on
|
||||
* the driver station or the field controls.
|
||||
*
|
||||
* WARNING: While it may look like a good choice to use for your code if you're inexperienced,
|
||||
* don't. Unless you know what you are doing, complex code will be much more difficult under
|
||||
* this system. Use IterativeRobot or Command-Based instead if you're new.
|
||||
*/
|
||||
class Robot: public SampleRobot
|
||||
{
|
||||
RobotDrive myRobot; // robot drive system
|
||||
Joystick stick; // only joystick
|
||||
|
||||
public:
|
||||
Robot() :
|
||||
myRobot(0, 1), // initialize the RobotDrive to use motor controllers on ports 0 and 1
|
||||
stick(0)
|
||||
{
|
||||
myRobot.SetExpiration(0.1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the motors with arcade steering.
|
||||
*/
|
||||
void OperatorControl()
|
||||
{
|
||||
while (IsOperatorControl() && IsEnabled())
|
||||
{
|
||||
myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)
|
||||
Wait(0.005); // wait for a motor update time
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
START_ROBOT_CLASS(Robot)
|
||||
|
Reference in New Issue
Block a user