|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#3
|
|||||
|
|||||
|
Re: Mixing Joystick Values for mecanum wheels
Quote:
Here is the code I used for my Vex Holonomic Drive. The motors (when looking onto the top of the robot) were numbers exactly as they would for a mathmatical quadrants. The RF, LF, LR, and RR refer to Right Front, Left Front, Left Rear, and Right Rear wheels respectively. This code can be adaped for possible use in FRC, although you might have to tweak the input by 127. The Vex Transmitter sends 0 - 255 signal, and I think (but am not 100% sure) that some FRC joysticks send -127 - 127 signal. Here is the variable mapping: LF / ---- \ RF LR \ ---- / RR And here is the PWM port mapping: 2 / ---- \ 1 3 \ ---- / 4 And finally, here is the code: Code:
#include "Main.h"
void main ( void )
{
while ( 1 )
{
// Get Data
leftx = GetRxInput ( 1 , 4 ) ;
lefty = GetRxInput ( 1 , 3 ) ;
rightx = GetRxInput ( 1 , 1 ) ;
leftx = leftx / 2 ;
lefty = lefty / 2 ;
spin = rightx / 2 ;
// Drive Code
LF = RR = lefty - leftx + 127 ;
RF = LR = 255 - lefty - leftx ;
RR = 255 - RR ; // Reverse Direction
LR = 255 - LR ; // Reverse Direction
// Spin Code
RF = RF - spin + 63 ;
RR = RR - spin + 63 ;
LF = LF - spin + 63 ;
LR = LR - spin + 63 ;
// Check for values out of range
if ( LF < 0 )
{
LF = 0 ;
}
else if ( LF > 255 )
{
LF = 255 ;
}
if ( RF < 0 )
{
RF = 0 ;
}
else if ( RF > 255 )
{
RF = 255 ;
}
if ( RR < 0 )
{
RR = 0 ;
}
else if ( RR > 255 )
{
RR = 255 ;
}
if ( LR < 0 )
{
LR = 0 ;
}
else if ( LR > 255 )
{
LR = 255 ;
}
// Set Motors
SetMotor ( 1 , RF ) ;
SetMotor ( 2 , LF ) ;
SetMotor ( 3 , LR ) ;
SetMotor ( 4 , RR ) ;
}
}
~15 Mb - Windows Media Video - http://www.team228.org/index/multime...omic-drive.wmv Last edited by artdutra04 : 13-01-2006 at 17:26. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Getting A Bot To Turn | Andrew Blair | Technical Discussion | 20 | 16-10-2005 23:49 |
| Change joystick to pwm mapping | Joe Lewis | Programming | 3 | 30-03-2005 19:27 |
| Changing 1 joystick code to 2 (rookie team) | Brawler006 | Programming | 5 | 20-02-2004 17:00 |
| Lots of Wheels and F = u x N | archiver | 2001 | 17 | 23-06-2002 23:37 |
| "Motors and Drive train edition" of Fresh From the Forum | Ken Leung | CD Forum Support | 6 | 29-01-2002 12:32 |