|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
How to Make the Robot Drive Forward in Autonomous
This may seem like a simple question but I can't get it to work. I am using commandbase java.
I have a chassis subsystem here: Code:
package edu.wpi.first.LFRobot2014.subsystems;
import edu.wpi.first.LFRobot2014.RobotMap;
import edu.wpi.first.LFRobot2014.commands.DriveTele;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.command.Subsystem;
/**
*
* @author Developer
*/
public class Chassis extends Subsystem {
// Put methods for controlling this subsystem
// here. Call these from Commands.
RobotDrive drive;
public void initDefaultCommand() {
// Set the default command for a subsystem here.
setDefaultCommand(new DriveTele());
}
public Chassis(){
drive = new RobotDrive(RobotMap.leftMotorPort, RobotMap.rightMotorPort);
drive.setSafetyEnabled(false);
}
public void driveTele(Joystick leftStick, Joystick rightStick){
drive.tankDrive(leftStick, rightStick);
}
public void setSpeed(double speed){
drive.setMaxOutput(speed);
}
}
THANKS! |
|
#2
|
||||
|
||||
|
Re: How to Make the Robot Drive Forward in Autonomous
You use the same subsystem.
Add the following method: Code:
public void driveAuton(double speed, double turnRate)
{
drive.arcadeDrive(speed, turnRate);
}
To implement timing is also pretty simple. In the init of your command, type: setTimeout(timeToRun); (replace timeToRun with the amount of time you want to drive forward. Then, in the isFinished of your command, type: return isTimedOut(); |
|
#3
|
||||
|
||||
|
Re: How to Make the Robot Drive Forward in Autonomous
I think this should work...
Add this method to Chassis.java Code:
public void driveAuto(double speed) {
drive.setLeftRightMotorOutputs(speed, -speed); //The - may be wrong
}
Last edited by xForceDee : 04-02-2014 at 22:19. Reason: Be sure to add double in the parameter (getting too used to python) |
|
#4
|
||||
|
||||
|
Re: How to Make the Robot Drive Forward in Autonomous
Okay - THANKS guys!
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|