OCCRA
Go to Post Real projects have good and bad aspects, problems that must be dealt with, and lots of things that dont make any sense from your side of the fence. - KenWittlief [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Events   CD-Media   CD-Spy   FRC-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-22-2012, 07:48 PM
2185Bilal's Avatar
2185Bilal 2185Bilal is offline
Driver, Ld. Programmer, Electrical
AKA: Bilal Majeed
FRC #2185 (Ramazoidz)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2011
Location: Toronto, Canada
Posts: 110
2185Bilal will become famous soon enough
Send a message via Skype™ to 2185Bilal
Post Joystick

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
__________________
RAMAZOIDZ

2009 Toronto West Regional - Regional Winners
2009 Waterloo Regional - Regional Winners
Reply With Quote
  #2   Spotlight this post!  
Unread 06-23-2012, 11:29 AM
FrankJ's Avatar
FrankJ FrankJ is offline
Robot Mentor
FRC #2974 (WALT)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2009
Location: Marietta GA
Posts: 999
FrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond repute
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.
Reply With Quote
  #3   Spotlight this post!  
Unread 06-24-2012, 07:35 PM
2185Bilal's Avatar
2185Bilal 2185Bilal is offline
Driver, Ld. Programmer, Electrical
AKA: Bilal Majeed
FRC #2185 (Ramazoidz)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2011
Location: Toronto, Canada
Posts: 110
2185Bilal will become famous soon enough
Send a message via Skype™ to 2185Bilal
Re: Joystick

Quote:
Originally Posted by FrankJ View Post
My programmer hates it when I look over his shoulder, but I probably could get the code snippets if you want.
Yes, please. That would be nice. Because i am kind of lost
__________________
RAMAZOIDZ

2009 Toronto West Regional - Regional Winners
2009 Waterloo Regional - Regional Winners
Reply With Quote
  #4   Spotlight this post!  
Unread 06-24-2012, 08:08 PM
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Itinerant Programmer
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 7,456
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
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.
__________________
The mind sees only what the mind is prepared to comprehend - Henri Bergson
358 Beta notes & results

Last edited by Mark McLeod : 06-24-2012 at 08:15 PM.
Reply With Quote
  #5   Spotlight this post!  
Unread 06-28-2012, 01:10 PM
2185Bilal's Avatar
2185Bilal 2185Bilal is offline
Driver, Ld. Programmer, Electrical
AKA: Bilal Majeed
FRC #2185 (Ramazoidz)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2011
Location: Toronto, Canada
Posts: 110
2185Bilal will become famous soon enough
Send a message via Skype™ to 2185Bilal
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);

    	}
    	
    }
__________________
RAMAZOIDZ

2009 Toronto West Regional - Regional Winners
2009 Waterloo Regional - Regional Winners
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:28 PM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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