frc538 / 2020-infinite-recharge

Robot code for FRC Team 538.
0 stars 0 forks source link

Horizontal Alignment Command #53

Open drewwhis opened 4 years ago

drewwhis commented 4 years ago

Write a command to instruct the robot to move left or right depending on the value it gets for vx.

It will look very similar to the AutoDriveCommand, except we don't have to pass in any values.

In the execute, we can just say:

double vx = // Get vx from SmartDashboard
if (vx > 1) {
  // Move right (toward center)
  mDrive.drive(0, 0.25, 0);
} else if (vx < -1) {
  // Move left (toward center)
  mDrive.drive(0,-0.25,0);
}

Then our isFinished could just return vx < 1 && vx > -1

This would get us within 1 degree horizontally.

We would also want to call our zeroing method in the initialize method. We may also want to add some code to determine if the target has been detected.

This assumes that vx is 0 when we're lined up.