# Fixing H-Drive Curving

#1

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?

#2

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.

#3
``````indent preformatted text by 4 spaces
if(m_stick.getRawAxis(2)>.3)
{

//double speed = -m_stick.getRawAxis(5)*0.5;

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;

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

else
{
// double speed = -m_stick.getRawAxis(5)*0.5;