![]() |
Using joystick buttons with Command based programming
I'm new to command based robot programming with Java and for some reason I can't get the Joystick buttons to control my solenoid for my drive shifter.
It appears as though it's not even accepting Button input, but I'm not positive. I want Joystick Button A to enable the one side of DoubleSolenoid then another button to enable side 2 of DoubleSolenoid. I'm thinking my initialization of my button is wrong or something? OI CODE Code:
package org.usfirst.frc.team869.robot;shiftDriveSpeed Command: Code:
package org.usfirst.frc.team869.robot.commands;driveShifter Subsystem Code:
package org.usfirst.frc.team869.robot.subsystems;Robot class Code:
package org.usfirst.frc.team869.robot; |
Re: Using joystick buttons with Command based programming
Instead of putting
Code:
joystickButtonA.whenPressed(new shiftDriveSpeed());Code:
public OI(){ |
Re: Using joystick buttons with Command based programming
Quote:
Code:
ERROR Unhandled exception: java.lang.ExceptionInInitializerError at [org.usfirst.frc.team869.robot.Robot.robotInit(Robot.java:42), edu.wpi.first.wpilibj.IterativeRobot.startCompetition(IterativeRobot.java:72), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java:241)]ERROR Unhandled exception: java.lang.ExceptionInInitializerError at [org.usfirst.frc.team869.robot.Robot.robotInit(Robot.java:42), edu.wpi.first.wpilibj.IterativeRobot.startCompetition(IterativeRobot.java:72), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java:241)]When I remove that code I get RobotCode and can still use the drive train however I see this in the console: Code:
Exception in thread "main" java.lang.NoClassDefFoundError: edu/wpi/first/wpilibj/internal/HardwareTimer So when I modify it with what you mentioned it breaks it, however there may be something underlying in my code that's ultimately causing that issue. |
Re: Using joystick buttons with Command based programming
Whenever we get the robots don't quit error, we're always assigning two sensors to one port, so maybe you're assigning two solenoids to one port on the PCM.
|
Re: Using joystick buttons with Command based programming
Quote:
So when I remove the PCM assignment from the DoubleSolenoid object that error goes away. But then I re-add the modifications you mentioned before and I still get this error: Code:
ERROR Unhandled exception: java.lang.ExceptionInInitializerError at [org.usfirst.frc.team869.robot.Robot.robotInit(Robot.java:42), edu.wpi.first.wpilibj.IterativeRobot.startCompetition(IterativeRobot.java:72), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java:241)]OI Looks like this: Code:
package org.usfirst.frc.team869.robot; |
Re: Using joystick buttons with Command based programming
If it helps the repo is here and I just committed it:
https://github.com/ckirschner/FRC-869-Robot-2016 |
Re: Using joystick buttons with Command based programming
You might want to have Commandbase.init() in your robotInit.
Like so: Code:
public void robotInit() {I'm not positive that's the issue, but it might be a problem. |
Re: Using joystick buttons with Command based programming
in robotInit, you have to initialise your subsystems before your OI. Else you will try to build commands that use methods from non-existing subsystems
|
Re: Using joystick buttons with Command based programming
Quote:
Quote:
Okay that makes sense then. I will check that out today. However one question I have about that (I apologize I'm not actually a programmer, just appointed to this position as the best candidate to figure out programming the robot :yikes: ) If you look in my code I created the driveTrain class in the Robot class but not in robotInit and the drive train works. So is that sufficient? And if so, or if not, what exactly is robotInit doing that the declaration inside the Robot class isn't? Code:
public class Robot extends IterativeRobot { |
| All times are GMT -5. The time now is 08:25 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi