WindRiver "TankDrive"

I followed the guide as to how to set up a project and it seems much simpler than MPLab. I’d like to be able to set up the TankDrive function so that we can automatically adjust to half speed if the trigger on the joystick is pressed, among other things. I’ve been looking for where the “TankDrive” function is defined so I can edit it.

Is this what I should go about doing? If not, what should I do?

You have a couple ways on implementing it. I wouldn’t suggest editing the WPILib, at least not yet as there will still be patches that may overwrite what you do. You could create your own class and inherit that. Or you could create your own Joystick class instead, inheriting the Joystick and adding the scaling to the GeyY() function (or if you assign a different axis for drive). There is also RobotDrive::TankDrive(float leftDrive, float rightDrive) that you could use when the trigger is pressed. The function is defined in RobotDrive.h

I think that TankDrive(float leftDrive, float rightDrive) is used in the original program.

But would this work?

within the code, making two variables, one leftHalf and another rightHalf. Then continually assigning each to leftJoystick/2 and rightJoystick/2 respectively?

And then having an

else if (triggerPressed==1) {
    myRobot->TankDrive(leftHalf, rightHalf);
}

after the if that determines whether to use arcade or tank driving?

You could even simplify that instead of having the rightHalf variable:


else if (triggerPressed)
{
    myRobot->TankDrive(leftJoystick->GetY()/2,rightJoystick->GetY()/2);
}

Edit: May I suggest having a trigger on each side slow down that side’s motor instead of one on one side slowing them both down?

That’s what I was planning on doing. Thanks.