Fixing H-Drive Curving


So my team built a H-drive base but the center omnis are not exactly straight. Hence, the robot forms a crescent instead of a going in a straight line when attempting to strafe. I know this in an inherently mechanical issue but I do not have the resources to correct it so I’m looking to fix it in code. I know when trying to strafe I can have to outer wheels rotate to counter the crescent. I’ve tried this and it does work so the robot strafes properly. However, then I lose the ability to move diagonally as the outer wheels are locked to rotate to counter crescent and cannot move forward or backward at once. Any idea how to fix this?


In general, please post your code if asking for help.

If you have an H-drive, your robot should be able to translate and rotate independently - one should not preclude the other. Your code could look something like (pseudocode):

double forward = joystick.getY;
double strafe = joystick.getX;
double rotate = secondJoystick.getX;
double counterRotationConstant = 0.2;

if (Math.abs(strafe) > 0.1) {
    rotate = rotate + counterRotationConstant

DriveBase.hDrive(forward, strafe, rotate);

The better solution to this problem is to put a gyro on your robot, and use it to keep your heading constant when there’s no commanded rotation.

indent preformatted text by 4 spaces

 //       hdrive.arcadeDrive(-m_stick.getRawAxis(5), -0.5);
 //double speed = -m_stick.getRawAxis(5)*0.5;
hdrive.arcadeDrive(-m_stick.getRawAxis(5)*0.75, -0.25);

    double retardation =- m_stick.getRawAxis(2) ;
    omniMotor.set(ControlMode.PercentOutput, retardation);

  else if(m_stick.getRawAxis(2)<-.3)
    //double speed = -m_stick.getRawAxis(5)*0.5;
  //  hdrive.arcadeDrive(-m_stick.getRawAxis(5), 0.5);

    double retardation =- m_stick.getRawAxis(2);
    omniMotor.set(ControlMode.PercentOutput, retardation);
   // double speed = -m_stick.getRawAxis(5)*0.5;
    hdrive.arcadeDrive(-m_stick.getRawAxis(5)*0.75, m_stick.getRawAxis(0));
    double retardation = 0;
    omniMotor.set(ControlMode.PercentOutput, retardation);

Axis 5 is forward and back, 0 is rotation, and 2 is center omnis. The 0.3 is there as a deadzone but you can see in the first if and else if, the robot has a hard coded valued for rotation (empirically determined) and thus, it cannot move diagonally