Go to Post i met ANDY BAKER and D.J... they are awesome! - Arefin Bari [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 05-05-2008, 20:17
mindman13's Avatar
mindman13 mindman13 is offline
Registered User
FRC #2506
 
Join Date: Feb 2008
Location: Franklin
Posts: 6
mindman13 is an unknown quantity at this point
Exclamation HELP Arcade style program for first Robot

How do you get the robot to run off of a single stick arcade style drive? Please help!!!
  #2   Spotlight this post!  
Unread 05-05-2008, 20:38
tdlrali tdlrali is offline
Registered User
FRC #0469 (Las Guerrillas)
Team Role: Programmer
 
Join Date: Sep 2006
Rookie Year: 2006
Location: MI
Posts: 377
tdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud of
Re: HELP Arcade style program for first Robot

There's a couple ways to do it, you have to figure out which is most intuitive.

One example:
Code:
DRIVE_L = (int) STICK_Y + ((int) STICK_X - 127);
DRIVE_R = (int) STICK_Y - ((int) STICK_X - 127);
DRIVE_L = (DRIVE_L<0)?(0):((DRIVE_L>254)?(254):(DRIVE_L));
DRIVE_R = (DRIVE_R<0)?(0):((DRIVE_R>254)?(254):(DRIVE_R));
  #3   Spotlight this post!  
Unread 05-05-2008, 20:39
whytheheckme's Avatar
whytheheckme whytheheckme is offline
Registered User
AKA: Jacob Komar
no team
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Providence, RI
Posts: 1,320
whytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond reputewhytheheckme has a reputation beyond repute
Send a message via ICQ to whytheheckme Send a message via AIM to whytheheckme Send a message via MSN to whytheheckme Send a message via Yahoo to whytheheckme
Re: HELP Arcade style program for first Robot

The easiest way to get started is to install yourself a copy of easyC.

Open a new project, and open the operator control block.
Create a While(1) loop, with an Arcade drive block inside. Compile and download to the robot.

-Jacob
  #4   Spotlight this post!  
Unread 12-05-2008, 19:23
mindman13's Avatar
mindman13 mindman13 is offline
Registered User
FRC #2506
 
Join Date: Feb 2008
Location: Franklin
Posts: 6
mindman13 is an unknown quantity at this point
Unhappy Re: HELP Arcade style program for first Robot

The code works for left and right, but what about diagonals and other in-betweens.
  #5   Spotlight this post!  
Unread 13-05-2008, 02:48
Matt H. Matt H. is offline
Long Distance Mentor
FRC #1726 (N.E.R.D.S.)
Team Role: Alumni
 
Join Date: May 2006
Rookie Year: 2007
Location: Sierra Vista, AZ
Posts: 238
Matt H. has a reputation beyond reputeMatt H. has a reputation beyond reputeMatt H. has a reputation beyond reputeMatt H. has a reputation beyond reputeMatt H. has a reputation beyond reputeMatt H. has a reputation beyond reputeMatt H. has a reputation beyond reputeMatt H. has a reputation beyond reputeMatt H. has a reputation beyond reputeMatt H. has a reputation beyond reputeMatt H. has a reputation beyond repute
Re: HELP Arcade style program for first Robot

Notice how the various joy sticks are subtracted from each other in the code sample. This allows for arcade control in the diagonal etc. (At least that is my understanding).
  #6   Spotlight this post!  
Unread 22-05-2008, 00:52
mluckham's Avatar
mluckham mluckham is offline
Registered User
FRC #0758 (Sky Robotics)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Ontario, Canada
Posts: 116
mluckham will become famous soon enoughmluckham will become famous soon enough
Re: HELP Arcade style program for first Robot

Put the robot up on blocks, so the wheels can spin freely as you test your program.

In a loop, read the joystick fwd/reverse axis into an unsigned char variable called ucjoyfwd. Print it so you can see the value. Copy ucjoyfwd to PWM outputs for both wheels. If one wheel runs backward, reverse the wiring on the Victor so that both run the same way.

In your printout, you see that ucjoyfwd ranges from 0-254 as you move the joystick to change the wheel speeds. I would like you to also load this to an integer variable called ispeed like this:

ispeed = (int) ucjoyfwd - 127

If you print ispeed too, you will see that it ranges from -127 to +127, as ucjoyfwd ranges from 0 to 255. In this new range, you can think of 0 as "stopped", -127 as "full speed reverse", 127 as "full speed forward".

Now instead of copying ucjoyfwd to the PWM outputs, copy (ispeed + 127) to them instead ... which converts ispeed back to the 0-254 range for the purposes of controlling the PWM Victors. The wheels should still turn the same ways and same speeds as before.

ispeedleft = ispeed + 127
ispeedright = ispeed + 127

Now for rotation, we want the wheels to spin at different speeds. So we want to take ispeed and add speed to one wheel, and take it away from the other.

So read the joystick left/right axis value into a different variable ucleftright, and convert it to the +/- 127 range using the same method. Print ucleftright and irotate, to see what they are doing as you move the joystick.

irotate = (int) ucleftright - 127

Now we're coming to the good part.

ispeedleft = ispeed - irotate;
if (ispeedleft > 127) ispeedleft = 127
if (ispeedleft < -127) ispeedleft = -127

ispeedright = ispeed + irotate
if (ispeedright > 127) ispeedright = 127
if (ispeedright < -127) ispeedright = -127

Send ispeedleft + 127 to one PWM Victor, ispeedright + 127 to the other.

Now the fwd/rev motion of the joystick controls your base speed, and the left/right motion controls the difference in speed between left and right motors (ie: the robot turns).
Closed Thread


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
EasyC-FRC - Arcade driving help Roger Programming 3 11-10-2006 15:03
HELP! Can't Program Robot Controller - LED stays on. sheyna Programming 3 21-01-2006 18:50
**FIRST EMAIL**/Scholarships for WPI Summer Robotics Program Rich Wong FIRST E-Mail Blast Archive 0 19-05-2005 16:54
Credits for FIRST program. archiver 2000 6 24-06-2002 00:16
robot control emulator for default or other program CharlieWilken Programming 26 24-02-2002 02:36


All times are GMT -5. The time now is 00:05.

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