|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
hello,
so the problem is that since our robot is a 4-wheel drive, it travels pretty fast. To control the robot we are using a gamepad and the code is written so it is a tank drive. So we use the 2 joysticks on the gamepad to control each side of the robot. And the problem is that if we just tap the joystick the robot goes flying, so we were thinking of limiting the speed to only 50%, so when the joystick is pushed fully the robot will only travels half speed. So how do i do that in java plz help |
|
#2
|
||||
|
||||
|
Re: Joystick
Our standard tank drive regular runs at 50% max speed with a turbo button that boosts it to 100%.
Basically you multiply the joystick output by a constant to send a range of -0.5 to 0.5 to the motor controller. When the turbo button is pressed you double the value. If then statements would work. My programmer hates it when I look over his shoulder, but I probably could get the code snippets if you want. |
|
#3
|
||||
|
||||
|
Re: Joystick
Quote:
![]() |
|
#4
|
|||||
|
|||||
|
Re: Joystick
The joystick value ranges from -1 to 1.
Multiply the joystick value by the percentage of power that you want. e.g., .5 for 50% or .25 for 25% or .75 for 75% power So, a joystick value of -1 (full forward) * .75 = -.75 (or 75% of full power) Using this method will cost power on the turns as well as the straightaways though, and depending on your wheelbase/wheel stickyness/ground surface may make turning difficult. A better answer is to change the sprocket ratio driving the wheels. Increase the sprocket sizes on the wheels to lower your speed and increase turning torque. Last edited by Mark McLeod : 06-24-2012 at 08:15 PM. |
|
#5
|
||||
|
||||
|
Re: Joystick
This is what i did
Tell me if its wrong or right Code:
// TELOPERATED PERIOD CODE //
public void teleopPeriodic() {
if (controller.getRawButton(1)){
drive.tankDrive(controller, 2, controller, 5);
}else{
drive.setMaxOutput(0.5);
drive.tankDrive(controller, 2, controller, 5);
}
}
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|