View Single Post
  #4   Spotlight this post!  
Unread 14-04-2006, 16:50
billbo911's Avatar
billbo911 billbo911 is online now
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,353
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: pic: kiwi vex robot

Quote:
Originally Posted by Tom Bottiglieri
Well credit needs to be given where it's deserved. I got the equations for my kiwi code from the living genious, Joel Johnson.

Anyway, here's what you need to do to make it work:

PHP Code:
//Make sure variables are unsigned ints... rollovers WILL occur with signed ints
unsigned int trans_xtrans_yrot;

//Grab inputs (x,y coords in rectangular coordinates and rotation rate)
trans_x 254 PWM_in1
trans_y 254 PWM_in2
rot 254 PWM_in4;      

//Limit vector length to 127
trans_x = (unsigned int)(37+(254*trans_x)/359);
trans_y = (unsigned int)(37+(254*trans_y)/359);

//Assign and limit wheel outputs
wheel_1  = (unsigned char)limit( (((2*trans_x) + rot) / 3), 0254); 
wheel_2 = (unsigned char)limit( ((601 rot trans_x - (168*trans_y/97)) / 3), 0254); 
wheel_3 = (unsigned char)limit( ((161 rot trans_x + (168*trans_y/97)) / 3) , 0254); 
This assumes you have a limit function, which limits an input value to upper and lower bounds.

PHP Code:
signed int limit(signed int valuesigned int minsigned int max
 { 
      if (
value min
      { 
           
value min
      } else if (
value max
      { 
           
value max
      } 
  
      return 
value
 } 
That should be all you need, and it should work. (It took me about 2 hours to figure out the variables needed to be unsigned. )
Now I know why I like Tom (oh yeah, and Joe too ) so much!!

The problem is, now I have to go buy some omni wheels for this weekends project

BTW. Do you know how the constant values were determined (ie. 37, 359, 601, 168, 97, 161)? Also, I see you are using PWM_in4 for the rotation value. I assume this is off the left stick X-axis. Knowing these can help me modify this stuff for future projects.

Thanks again!!!!
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
Reply With Quote