-
Notifications
You must be signed in to change notification settings - Fork 7
Added autonomous driving code to hoppers using ping sensors #18
base: develop
Are you sure you want to change the base?
Added autonomous driving code to hoppers using ping sensors #18
Conversation
9bcb438 to
e7042ea
Compare
…ut need to add ability to add constant to the SynchronousPID @rothso.
…ce dummy values with real values and test. Fingers crossed.
… - can tune later.
…le running command or while in teleop.
…ngleHoldController. Works when not right up against ping sensor, not sure why very small readings make it go in the opposite direction. Testing needed.
e7042ea to
f084149
Compare
b52beab to
3bd2f1a
Compare
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.
Preliminary review!
I've kept in mind that this is still very much a rough draft and so your names, organization, and structure are likely temporary. I've geared my comments to be not so much about polishing a product but rather reorganizing what you currently have to reduce code duplication, standardize vocabulary, and remove dead code to repay the techinical debt of moving fast and breaking things before the very act comes to ironically slow us down.
With respect to the autonomous routine, is it safe to transition from Y to X without braking in between? I also believe we're currently running at a slow speed. Are things ready to be tested and tuned on the mock field?
| public final double yDist; | ||
|
|
||
| Feedback(double currentAngle) { | ||
| Feedback(double currentAngle, double xDist, double yDist) { |
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.
If we want more than two ping sensors on the bot, then these won't be xDist and yDist for long. Maybe distinguish them with left/right/front/rear instead?
| gyro | ||
| ); | ||
| // private static final DistanceSensor xDistPing = Hardware.DistanceSensors.digitalUltrasonic(0,1); | ||
| // private static final DistanceSensor yDistPing = Hardware.DistanceSensors.digitalUltrasonic(2,3); |
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.
Dead code. Can be removed to avoid confusion.
| public void robotInit() { | ||
| Strongback.configure().recordNoEvents().recordNoData(); | ||
| IO.xDistPing.setAutomaticMode(true); | ||
| IO.yDistPing.setAutomaticMode(true); |
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.
These two lines are super important. I think they're better placed in a static initializer at the bottom of IO so they're closer to the ping sensor declarations. Someone in the future who wants to just copy/paste the IO class into another project may not remember to configure the ping sensors.
static {
xDistPing.setAutomaticMode(true);
yDistPing.setAutomaticMode(true);
}| reactor.onTriggeredSubmit(rightJoystick.getButton(3), () -> new HoldAngleCommand(drive, 135)); | ||
| reactor.onTriggeredSubmit(rightJoystick.getButton(4), () -> new HoldAngleCommand(drive, 0)); | ||
|
|
||
| reactor.onTriggeredSubmit(leftJoystick.getButton(6), () -> new DriveToYX(drive,60,66,60,0)); |
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.
Button 6 was being used for one of the Driving buttons. Could you find that test up there and change it to 9? Maybe move the line for 10 to be above 11 while you're at it too.
After this PR gets merged we should consider archiving some of these tests. I've got a long-term solution in mind for this button fiasco that doesn't involve attaching a piano to the DriverStation.
| @Override | ||
| public void autonomousInit() { | ||
| Strongback.start(); | ||
| // make sure these measurements are 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.
Can you remove this line? Sorry about that, looks like it was left over from the rebase.
|
|
||
| @Override | ||
| public Drive.Signal computeSignal(Drive.Signal feedForward, Feedback feedback) { | ||
| // multiplied xSpeed by -1 because otherwise, would go in wrong direction |
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.
Is this comment out of date?
| @Override | ||
| public Drive.Signal computeSignal(Drive.Signal feedForward, Feedback feedback) { | ||
| // multiplied xSpeed by -1 because otherwise, would go in wrong direction | ||
| double xSpeed = this.xTranslationPID.calculate(feedback.xDist) + this.ADDED_POWER; |
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.ADDED_POWER might be better written as just ADDED_POWER because it's static.
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.
On that note, how does the bot stop when the ADDED_POWER is always added? Are you relying on friction?
| @Override | ||
| public boolean isOnTarget() { | ||
| return (xDistPingSensor <= hackTargetX); | ||
| // return xTranslationPID.isWithinTolerance(); |
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.
Looks like we're good to revert the code back.
| /** | ||
| * Created by shrey on 1/29/2017. | ||
| */ | ||
| public class DriveToYX extends CommandGroup { |
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.
Do you think it's too early to put this into a class? This may make it harder to add more Commands to the ping sensor routine because you would have to add additional parameters to the class. I would consider removing this class and inlining the CommandGroup in Robot.java, similar to how the strafing CommandGroup is written.
| private static final double ROTATION_KP = 0.008; | ||
| // private static final double ROTATION_KD = 0; | ||
| // private static final double ROTATION_KI = 0; | ||
| // private static final double ROTATION_FF = 0; |
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.
Dead code. Looks like it can be removed, since you've inlined all the 0s.
Just realized I never made a pull request for this. Added ping sensors to drive to the hopper.