|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Robot won't drive. Help with "command based" programming
Here's our code, including our subsystem (cassie), our command (dothedrive), and our Robot file. It just won't drive no matter what we do. We have one joystick and mecanum drive.
public class cassie extends Subsystem { public SpeedController leftfront = RobotMap.cassieleftfront; public SpeedController rightfront = RobotMap.cassierightfront; public SpeedController leftrear = RobotMap.cassieleftrear; public SpeedController rightrear = RobotMap.cassierightrear; public RobotDrive wholecassie = RobotMap.cassiewholecassie; public void initDefaultCommand() { } public void takeJoyStickInput(Joystick joy1) { wholecassie.mecanumDrive_Cartesian(joy1.getRawAxis (1), joy1.getRawAxis(2), joy1.getRawAxis(0),0); } public void stop() { wholecassie.mecanumDrive_Cartesian(0, 0, 0,0); } } public class dothedrive extends Command { public dothedrive() { requires(Robot.cassie); } protected void initialize() { } protected void execute() { Robot.cassie.takeJoyStickInput(Robot.oi.getSidewin der()); } protected boolean isFinished() { return false; } protected void end() { Robot.cassie.stop(); } protected void interrupted() { } } public class Robot extends IterativeRobot { Command autonomousCommand; public static OI oi; public static cassie cassie; public static lift lift; public static grip grip; public static vision vision; public void robotInit() { RobotMap.init(); cassie = new cassie(); lift = new lift(); grip = new grip(); vision = new vision(); oi = new OI(); autonomousCommand = new AutonomousCommand(); } public void disabledInit() { } public void disabledPeriodic() { Scheduler.getInstance().run(); } public void autonomousInit() { if (autonomousCommand != null) autonomousCommand.start(); } public void autonomousPeriodic() { Scheduler.getInstance().run(); } public void teleopInit() { if (autonomousCommand != null) autonomousCommand.cancel(); } public void teleopPeriodic() { Scheduler.getInstance().run(); wholecassie.dothedrive(); //this is the line that I'm confused on } public void testPeriodic() { LiveWindow.run(); } |
|
#2
|
||||
|
||||
|
Re: Robot won't drive. Help with "command based" programming
I believed the line you are concerned about should be
Code:
Scheduler.getInstance().add(teleopCommand); Last edited by Jalerre : 24-01-2015 at 17:54. |
|
#3
|
||||
|
||||
|
Re: Robot won't drive. Help with "command based" programming
If you were to make the command dothedrive the default command for the cassie subsystem, you wouldn't have to specifically call it in the Robot class as long as you have an object of the subsystem there. You can do this by adding this line inside your initDefaultCommand() inside your cassie subsystem
Code:
setDefaultCommand(new dothedrive()); Last edited by Camilo86 : 24-01-2015 at 21:18. |
|
#4
|
|||
|
|||
|
Re: Robot won't drive. Help with "command based" programming
Thank you! I will try these solutions.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|