|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#8
|
|||||
|
|||||
|
Re: Mixing Joystick Values for mecanum wheels
Quote:
Some of this code is specific to EasyC for Vex, but it should only take slight tweaking to get this code to work for in EasyC for FRC. Code:
GetRxInput ( 1 , 4 ) ; GetRxInput ( 1 , 3 ) ; GetRxInput ( 1 , 1 ) ; Left Joystick, X-Axis: Channel 4 Left Joystick, Y-Axis: Channel 3 Right Joystick, X-Axis: Channel 1 Right Joystick, X-Axis: Channel 2 I am using the left joystick (both axis) to control the forward/reverse/left/right/diagonal movement, and the X-Axis on the right joystick to control the spin. There are also two additional channels (channels 5 and 6) on the Vex transmitter that are controlled via the push buttons on the back of the transmitter, but they weren't used for anything here. 2)Why did you cut all the joystick values in half? Code:
leftx = leftx / 2 ;
lefty = lefty / 2 ;
spin = rightx / 2 ;
This ensures that the variables will never overflow the 0 or 255 limit on the PWM signal.3)something doesn't make sense: let's say that the joystick is full forward with no spin Code:
leftx = GetRxInput ( 1 , 4 ) ----->=127 ;
lefty = GetRxInput ( 1 , 3 ) ------>=256;
rightx = GetRxInput ( 1 , 1 ) ----->=127;
Code:
leftx = leftx / 2 = 63;
lefty = lefty / 2 = 127 ;
spin = rightx / 2 = 63 ;
and then: Code:
LF = RR = lefty - leftx + 127 = 127-63+127=193 ;
RF = LR = 255 - lefty - leftx = 255-127-63=63;
RR = 255 - RR = 63;// Reverse Direction
LR = 255 - LR = 193 ; // Reverse Direction
Code:
RF = RF - spin + 63 = 63-63+63=63 ;
RR = RR - spin + 63 = 63-63+63=63;
LF = LF - spin + 63 = 193-63+63=193;
LR = LR - spin + 63 = 193-63+63=193;
Code:
RF=63 ;
RR=63;
LF=193;
LR=193;
Quote:
And yes, without doing an exponential curve to the values, you will only get half the PWM strength going through this algorithm when you are traveling orthogonally. This is because when you are traveling diagonally, the values going to two of the corner motors are full speed (0 and 255), while the other two corners don't move at all (both are 127). For example, to go to the "Northeast" or travel towards "2 o' clock" relative to the front of the robot, the PWM signal to the motors will be: Code:
255* / --- \ 127 127 \ --- / 0* Last edited by artdutra04 : 15-01-2006 at 10:35. Reason: minor addition |
| 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 |