Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Arcade drive method bug? (http://www.chiefdelphi.com/forums/showthread.php?t=103704)

Joe Ross 23-02-2012 18:58

Arcade drive method bug?
 
While looking at the RobotDrive.cpp file, I found what looks like a bug.

Code:

/**
 * Arcade drive implements single stick driving.
 * Given a single Joystick, the class assumes the Y axis for the move value and the X axis
 * for the rotate value.
 * (Should add more information here regarding the way that arcade drive works.)
 * @param stick The joystick to use for Arcade single-stick driving. The Y-axis will be selected
 * for forwards/backwards and the X-axis will be selected for rotation rate.
 * @param squaredInputs If true, the sensitivity will be increased for small values
 */
void RobotDrive::ArcadeDrive(GenericHID *stick, bool squaredInputs)
{
        // simply call the full-featured ArcadeDrive with the appropriate values
        ArcadeDrive(stick->GetY(), stick->GetX(), stick->GetTrigger());
}

It seems like the it should be
Code:

ArcadeDrive(stick->GetY(), stick->GetX(), squaredInputs);
This would match the java library. Am I missing anything?

mikets 23-02-2012 21:09

Re: Arcade drive method bug?
 
We also found a potential bug in ArcadeDrive. According to the code below, a positive rotateValue will make the robot turn left and negative will make it turn right. As far as I understand it, this is opposite to convention. I cross checked this with MecanumDrive_Cartesian where positive rotation will turn right and negative rotation will turn left (which agrees with convention). We found this by accident because we had to change our wheels from Mecanum to regular and all the sudden the robot turns the other way.
Code:

void RobotDrive::ArcadeDrive(float moveValue, float rotateValue, bool squaredInputs)
{
    ....
    if (moveValue > 0.0)
    {
        if (rotateValue > 0.0)
        {
            leftMotorOutput = moveValue - rotateValue;
            rightMotorOutput = max(moveValue, rotateValue);
        }
        else
        {
            leftMotorOutput = max(moveValue, -rotateValue);
            rightMotorOutput = moveValue + rotateValue;
        }
    }
    else
    {
        if (rotateValue > 0.0)
        {
            leftMotorOutput = - max(-moveValue, rotateValue);
            rightMotorOutput = moveValue + rotateValue;
        }
        else
        {
            leftMotorOutput = moveValue - rotateValue;
            rightMotorOutput = - max(-moveValue, -rotateValue);
        }
    }
}



All times are GMT -5. The time now is 12:57.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi