diff --git a/.gitignore b/.gitignore index 1ff0378..573b601 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ .metadata +DriveBase/.settings +DriveBase/sysProps.xml diff --git a/DriveBase/src/Robot.cpp b/DriveBase/src/Robot.cpp index 6e6b357..1845216 100644 --- a/DriveBase/src/Robot.cpp +++ b/DriveBase/src/Robot.cpp @@ -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); - printf("~Teleop Periodic End."); + + 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. diff --git a/FRCUserProgram b/FRCUserProgram new file mode 100755 index 0000000..bcba85b Binary files /dev/null and b/FRCUserProgram differ diff --git a/robot.cpp b/robot.cpp new file mode 100644 index 0000000..9565107 --- /dev/null +++ b/robot.cpp @@ -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) +