Quote:
Originally Posted by Mubtasim
Rookie team programmer (in java) with no experience. The following program suppose to:
in Auto-
Start m_window motor
wait 3 seconds
Start m_shooter motor
(and do the same again when auto init)
in Teleop-
When left trigger > start m_window motor
when right trigger > start m_shooter motor
use the default code drive commands when asked.
|
Is that all you are trying to do? There is no reason for you to use the the default code template. It is really complicated and has too much things inside of it which as far as i know you do not need.
In your case i would start off with the "SimpleRobotTemplateProject" It comes with auto, teleop, and test. No programming is in it so you can start fresh.
This is how the program should look(i did not test this but it should work):
Code:
package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Timer;
public class RobotTemplate extends SimpleRobot {
RobotDrive m_robotDrive;
RobotDrive m_window;
RobotDrive m_shooter;
Joystick driver,co_driver;
public void robotInit() {
m_robotDrive = new RobotDrive(9,10);
m_window = new RobotDrive(6,7);
m_shooter = new RobotDrive(5,3);
driver = new Joystick(1);
co_driver = new Joystick(2);
}
public void autonomous() {
m_window.drive(1,0);
Timer.delay(3);
m_shooter.drive(1,0);
}
public void operatorControl() {
while (isOperatorControl() && isEnabled()) {
m_robotDrive.arcadeDrive(driver);
m_window.drive((driver.getTrigger() ? 1 : 0), 0);
m_shooter.drive((co_driver.getTrigger() ? 1 : 0), 0);
}
}
public void test() {
}
}
The code uses two joysticks since you wanted triggers. You did not specify the joystick so i assumed you were using the Logitech Attack 3. the driver Joystick turns the window motor on/off and the co_driver joystick turns the shooter on/off. Auto does what you wanted and the robot can be driven with the driver joystick. This code SHOULD work but every robot is built differently and everyone programs in their own way. Try it out. One upload of this code wont hurt.
