Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   WindRiver "TankDrive" (http://www.chiefdelphi.com/forums/showthread.php?t=72041)

KRibordy 01-13-2009 04:56 PM

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?

wt200999 01-13-2009 05:20 PM

Re: WindRiver "TankDrive"
 
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

KRibordy 01-13-2009 05:29 PM

Re: WindRiver "TankDrive"
 
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
Code:

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

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

wt200999 01-13-2009 05:48 PM

Re: WindRiver "TankDrive"
 
You could even simplify that instead of having the rightHalf variable:

Code:

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?

KRibordy 01-13-2009 06:13 PM

Re: WindRiver "TankDrive"
 
That's what I was planning on doing. Thanks.


All times are GMT -5. The time now is 10:34 AM.

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