Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Inverting controls in Java (http://www.chiefdelphi.com/forums/showthread.php?t=84566)

windell747 23-03-2010 08:32

Inverting controls in Java
 
Hi,

Unfortunately, I'm not the programmer for my team, but I did pretty much all of our programming when we were using C. This means that I don't know the Java lingo either. So please bare with me.

What we're trying to do is invert our controls so that we can flip the forward and reverse directions on our robot. This is so that we dont need to turn the robot around to herd balls and stuff. Our programmer said that there is an "invert controls" option, but when she uses it, the axes of the joystick switch.

Has anyone found an easy way to invert the controls for their robot? We're using the out of the box tankdrive routine.

Thanks,
Windell

Jared Russell 23-03-2010 08:41

Re: Inverting controls in Java
 
Code:

RobotDrive myDrive = new RobotDrive(1,2,3,4);

if( invertMyDrive == true )
{
 myDrive.setInvertedMotor(kFrontLeft, true);
 myDrive.setInvertedMotor(kFrontRight, true);
 myDrive.setInvertedMotor(kRearLeft, true);
 myDrive.setInvertedMotor(kRearRight, true);
}

myDrive.tankDrive(leftStick, rightStick);

The above snippet will reverse the forward/backward direction of your bot if the "invertMyDrive" variable (a boolean) is set.

It sounds like if your axes got switched, you only inverted half of the drive.

windell747 23-03-2010 08:47

Re: Inverting controls in Java
 
really appreciate it Jared. I'll pass this on to our programmer!

Geek 2.0 24-03-2010 01:27

Re: Inverting controls in Java
 
You might want an "else" portion in there too to set the back to normal. It's nice to be able to change, but it's nicer to be able to change back :)

Jared Russell 24-03-2010 07:35

Re: Inverting controls in Java
 
Quote:

Originally Posted by Geek 2.0 (Post 942317)
You might want an "else" portion in there too to set the back to normal. It's nice to be able to change, but it's nicer to be able to change back :)

Details, details :)


All times are GMT -5. The time now is 09:43.

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