Go to Post Ahem, a climbing xerox machine. Also known as the scariest type of xerox machine this Earth has ever seen. - itsjustjon [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-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 13-12-2012, 21:16
inkspell4's Avatar
inkspell4 inkspell4 is offline
Registered User
FRC #3650 (Robo Raptors)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Maryland
Posts: 326
inkspell4 will become famous soon enough
Programming an Arcade Drive

How would you go about programming a class as a custom arcade drive for your robot?

What type of formulas would you need to use?
__________________
Chesapeake Regional : 2013, 2012, 2011
Rookie Year: 2011
2013 RoboRaptors Team 3650 Programming Team Captain
Team Website : http://www.roboraptorsfrcteam3650.com/index.html
_____________________________________________
Reply With Quote
  #2   Spotlight this post!  
Unread 13-12-2012, 23:20
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,042
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Programming an Arcade Drive

Quote:
Originally Posted by inkspell4 View Post
How would you go about programming a class as a custom arcade drive for your robot?

What type of formulas would you need to use?
http://www.chiefdelphi.com/media/papers/2661


Reply With Quote
  #3   Spotlight this post!  
Unread 15-12-2012, 20:49
inkspell4's Avatar
inkspell4 inkspell4 is offline
Registered User
FRC #3650 (Robo Raptors)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Maryland
Posts: 326
inkspell4 will become famous soon enough
Is the puedo-code on the referenced page written in python and if so do you know what the java equivalent might be
__________________
Chesapeake Regional : 2013, 2012, 2011
Rookie Year: 2011
2013 RoboRaptors Team 3650 Programming Team Captain
Team Website : http://www.roboraptorsfrcteam3650.com/index.html
_____________________________________________

Last edited by inkspell4 : 15-12-2012 at 21:22.
Reply With Quote
  #4   Spotlight this post!  
Unread 15-12-2012, 21:18
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,042
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Programming an Arcade Drive

Quote:
Originally Posted by inkspell4 View Post
Is that written in python and if so do you know what the java equivalent might be
What does the pronoun "that" refer to in the above sentence


Reply With Quote
  #5   Spotlight this post!  
Unread 15-12-2012, 21:21
inkspell4's Avatar
inkspell4 inkspell4 is offline
Registered User
FRC #3650 (Robo Raptors)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Maryland
Posts: 326
inkspell4 will become famous soon enough
Sorry,

I was referring to the puedo-code found on the page that was previously referenced
__________________
Chesapeake Regional : 2013, 2012, 2011
Rookie Year: 2011
2013 RoboRaptors Team 3650 Programming Team Captain
Team Website : http://www.roboraptorsfrcteam3650.com/index.html
_____________________________________________
Reply With Quote
  #6   Spotlight this post!  
Unread 15-12-2012, 21:25
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,042
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Programming an Arcade Drive

Quote:
Originally Posted by inkspell4 View Post
Sorry,

I was referring to the puedo-code found on the page that was previously referenced
There are 8 documents. Which document are you referring to.


Reply With Quote
  #7   Spotlight this post!  
Unread 15-12-2012, 22:26
inkspell4's Avatar
inkspell4 inkspell4 is offline
Registered User
FRC #3650 (Robo Raptors)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Maryland
Posts: 326
inkspell4 will become famous soon enough
To tell you the truth i cant make sense of any of the psuedo-code files
__________________
Chesapeake Regional : 2013, 2012, 2011
Rookie Year: 2011
2013 RoboRaptors Team 3650 Programming Team Captain
Team Website : http://www.roboraptorsfrcteam3650.com/index.html
_____________________________________________
Reply With Quote
  #8   Spotlight this post!  
Unread 15-12-2012, 23:52
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,042
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Programming an Arcade Drive

Quote:
Originally Posted by inkspell4 View Post
To tell you the truth i cant make sense of any of the psuedo-code files
Do you want help making sense of them? If so, tell me what doesn't make sense to you, and I will try to explain.

In your original post, you said you wanted the "formulas" so you could program a "custom arcade drive".

If, however, all you want is canned Java code that already works, you can find it in the WPILibrary.



Reply With Quote
  #9   Spotlight this post!  
Unread 16-12-2012, 00:32
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: Programming an Arcade Drive

Basic arcade drive in Java:

(Everything in red can be renamed.)

Code:
throttle = joystick.getY();
turnValue = joystick.getX();

leftMtr = throttle + turnValue;
rightMtr = throttle - turnValue;

public double getArcadeLeftMotor() {
        return leftMtr;
    }

public double getArcadeRightMotor() {
        return rightMtr;            
    }

plug in getArcadeLeftMotor() and getArcadeLeftMotor() as the left and right channels in a JoystickDrive object
And that's all you need for a very basic arcade drive. You need to experimentally determine what values the joystick outputs at each position using print statements or a software such as Xpadder and adjust what it's doing accordingly. This setup is determinant on the Y axis "up" being a positive value and the X axis "left" being a negative value.

But the basic code is a bit lacking. At high speeds the robot is going to tend to keep going more and it won't turn so well. It also results in situations where you get bad clipping because of the addition and subtaction. So we make the algorithm a bit more complex...

Code:
throttle = joystick.getY();
turnValue = joystick.getX();

leftMtr = throttle + turnValue;
rightMtr = throttle - turnValue;

public double getArcadeLeftMotor() {
        return leftMtr + skim(rightMtr);
    }

    public double getArcadeRightMotor() {
        return rightMtr + skim(leftMtr);            
    }

public double skim(double v) {
    if (v > 1.0) {
        return -((v - 1.0) * RobotMap.TURNING_GAIN);
    } else if (v < -1.0) {
        return -((v + 1.0) * RobotMap.TURNING_GAIN);
    } return 0; 
    }
What this does is take the excess off if it results in a number greater than 1.0 or less than -1.0 and subtract it from the other side of the robot, after applying a multiplier of less than one to reduce it. You can then experiment with the multiplier to find something that feels better than the original code. A multiplier of 0 is equivalent to the original code.

You can use whatever algorithm you want to smooth it out. skim() is just an example, and some teams have found better algorithms entirely. Play around with it until you find something that works well. Good luck.
__________________
Research is what I’m doing when I don’t know what I’m doing.
- Wernher von Braun
Attending: Raleigh NC Regional

Last edited by F22Rapture : 16-12-2012 at 00:38.
Reply With Quote
  #10   Spotlight this post!  
Unread 16-12-2012, 11:50
inkspell4's Avatar
inkspell4 inkspell4 is offline
Registered User
FRC #3650 (Robo Raptors)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Maryland
Posts: 326
inkspell4 will become famous soon enough
Could you please further explain the function and purpose of the skim method. Im relatively new to learning how to program an arcade drive
__________________
Chesapeake Regional : 2013, 2012, 2011
Rookie Year: 2011
2013 RoboRaptors Team 3650 Programming Team Captain
Team Website : http://www.roboraptorsfrcteam3650.com/index.html
_____________________________________________
Reply With Quote
  #11   Spotlight this post!  
Unread 16-12-2012, 12:17
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: Programming an Arcade Drive

Quote:
Originally Posted by inkspell4 View Post
Could you please further explain the function and purpose of the skim method. Im relatively new to learning how to program an arcade drive
The joystick value is a decimal from 0 to 1, and the robot drive method cuts everything off at one. That means you lose some sensitivity to turning at higher speeds because .75 throttle + .45 turn is going to result in 1.2, which gets cut back down to 1.0.

Skim takes whatever was left on the end (in this case .2), multiplies it by another value, (say .5), and then subtracts it from the other side of the drivetrain.

So instead of .75 throttle and .45 turn giving you full throttle on one side and .3 on the other, it gives you full throttle on one side and .2 on the other. So it's more accurate to the driver's input.

The trick is finding an algorithm that has a comfortable response curve.
__________________
Research is what I’m doing when I don’t know what I’m doing.
- Wernher von Braun
Attending: Raleigh NC Regional
Reply With Quote
  #12   Spotlight this post!  
Unread 16-12-2012, 17:08
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,042
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Programming an Arcade Drive


Here's a contour map of the "skim" method with gain=0.5.

Here's a contour map of the linear interpolation method with a=0.5 and b=1.0

Notice that the contour maps are identical all around the perimeter, but differ in how they get there. The linear one tries to provide linear response to the joystick in both X and Y directions. How that plays out in actual use is an open question. I'd like to hear back from teams who have tried the linear interpolation arcade.


Attached Thumbnails
Click image for larger version

Name:	skim5.png
Views:	46
Size:	31.6 KB
ID:	13309  Click image for larger version

Name:	linear51.png
Views:	33
Size:	34.3 KB
ID:	13311  

Last edited by Ether : 16-12-2012 at 17:19. Reason: fixed links
Reply With Quote
  #13   Spotlight this post!  
Unread 16-12-2012, 15:06
inkspell4's Avatar
inkspell4 inkspell4 is offline
Registered User
FRC #3650 (Robo Raptors)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Maryland
Posts: 326
inkspell4 will become famous soon enough
Ok thanks that makes sense now
__________________
Chesapeake Regional : 2013, 2012, 2011
Rookie Year: 2011
2013 RoboRaptors Team 3650 Programming Team Captain
Team Website : http://www.roboraptorsfrcteam3650.com/index.html
_____________________________________________
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 09:58.

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


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