-
Notifications
You must be signed in to change notification settings - Fork 0
added rumblyrumble #114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
added rumblyrumble #114
Conversation
|
Forgot to register command |
|
Fix usage of Timer here too |
|
|
||
| private Config config; | ||
| private int times; | ||
| private Timer timer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not initialized
| import org.teamtators.rotator.operatorInterface.LogitechF310; | ||
| import org.teamtators.rotator.operatorInterface.RumbleType; | ||
|
|
||
| public class RumblyRumble extends CommandBase implements Configurable<RumblyRumble.Config> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just call this OIRumble or JoystickRumble
| case LEFT: | ||
| setRumble(RumbleType.kLeftRumble, value); | ||
| break; | ||
| case RIGHT: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
break?
|
Do we want a logger? |
fc9af7a to
7214f33
Compare
|
|
||
| static class Config { | ||
| public int maxTimes; | ||
| public float onTime; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're in double territory now and you better act like it
2b3cf4d to
bdc828d
Compare
| @Override | ||
| public void configure(OIRumble.Config config) { | ||
| this.config = config; | ||
| timer = robot.timer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be created in the constructor. In this scope there isn't even a "robot"
| private boolean rumbling; | ||
|
|
||
| public OIRumble(CoreRobot robot) { | ||
| super("RumblyRumble"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should have the same name as the command
| } | ||
|
|
||
| @Override | ||
| public void configure(OIRumble.Config config) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to specify that it's an OIRumble.Config, just Config should work
| public int maxTimes; | ||
| public double onTime; | ||
| public double offTime; | ||
| public LogitechF310 joystick; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does one specify a LogitechF310 in config? This should probably just be name of the joystick, and then you can get the right one in configure
| logger.info("Rumbling {} times", config.maxTimes); | ||
| times = 0; | ||
| config.joystick.setRumble(config.type, config.value); | ||
| rumbling = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're setting rumbling to false after starting it rumbling on the line before
| @Override | ||
| protected boolean step() { | ||
| if(rumbling && timer.hasPeriodElapsed(config.onTime)) { | ||
| config.joystick.setRumble(config.type, 0.0f); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0 will do
| } | ||
|
|
||
| protected void finish() { | ||
| config.joystick.setRumble(config.type, 0.0f); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also just a 0 here works
| if(rumbling && timer.hasPeriodElapsed(config.onTime)) { | ||
| config.joystick.setRumble(config.type, 0.0f); | ||
| rumbling = false; | ||
| times ++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Autoformat all your files
bdc828d to
e771a5a
Compare
|
Appears to depend on #119 |
| @Override | ||
| public void configure(Config config) { | ||
| this.config = config; | ||
| if (config.joystick == "driver") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once #121 is merged, this should use that
| private AbstractOperatorInterface operatorInterface; | ||
|
|
||
| public OIRumble(CoreRobot robot) { | ||
| super("IORumble"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong
| @Override | ||
| public void configure(Config config) { | ||
| this.config = config; | ||
| if (config.joystick == "driver") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should use .equals() method, not ==
| this.config = config; | ||
| if (config.joystick == "driver") { | ||
| joystick = operatorInterface.driverJoystick(); | ||
| } else if (config.joystick == "gunner") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And what if they ask for a joystick that doesn't exist?
82707e4 to
ce994bf
Compare
ce994bf to
bb6e316
Compare
No description provided.