Go to Post You mean nobody else has picked up on the hint about next year's game being called "Whack the Billfred"? - EricH [more]
Home
Go Back   Chief Delphi > Technical > Technical Discussion
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 22-03-2011, 11:05
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,100
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: Swerve drive with automatic rotation?

Quote:
Originally Posted by Chexposito View Post
we also had to create a function that converted the counts from 0 to 360 no matter what the count. then a pass that into another function that decided the closest way to get to the heading determined by the joystick. then had to do vector addition from the joystick to create ... a degree for the heading.
Since you are a programmer you may be interested in this. The following 2 lines of C code will do everything mentioned above. Try it with any gyro angle (positive, negative, greater than 360, etc) and any Joystick coordinates:

Code:
error = atan2(Xj,-Yj)*180/pi - gyroAngle;

error = error-360*floor(0.5+error/360);
"Xj,Yj" are the "uncorrected" joystick coordinates (Yj = -1 is full forward)

"gyroAngle" is in degrees clockwise

"error" is the clockwise angle error in degrees. It is the shortest path to the target.




Last edited by Ether : 22-03-2011 at 11:08.
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


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

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