![]() |
Mixing Joystick Values for mecanum wheels
We are preparing for the possibility of installing mecanum wheels on our robot this year and as a proccess are trying to figure out how to mix three joystick values into a working motor signal...
X is what controls your left/right movement. y is what controls your up/down movement. and Z is supposed to control the robot's spin around the Z axis. we have nailed the combo for X and Y but i'm still lacking the Z integration... Code:
m1/-------------\m2later on i hope to tackle moving on a straight line in relation to the field while all the while turning, so that the effect is somewhat like an ice puck, turning around itself while still moving in a straight line) but first thing first.... any idea how to integrate the Z axis control? Thanks, -Leav |
Re: Mixing Joystick Values for mecanum wheels
Most of the time, when a team wants to get that Z axis going, they use a second joystick. Three-axis gameport joysticks are next to impossible to find (or, once found, are of sketchy quality).
|
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"~15 Mb - Windows Media Video - http://www.team228.org/index/multime...omic-drive.wmv |
Re: Mixing Joystick Values for mecanum wheels
Wow! Thats probably the coolest VEX bot I've ever seen. Looks like you were
owning at savage soccer. Its to bad VEX doesn't have a gyro looks like it may have helped keep the robot going strait. I'm defiantly going to try this code with the FRC robot. |
Re: Mixing Joystick Values for mecanum wheels
Quote:
Quote:
I have a couple of questions though: 1)what does Code:
GetRxInput ( 1 , 4 ) ;I assumed that it get's the forth axis position information from joystick 1 and so on for Code:
GetRxInput ( 1 , 1) ;Code:
GetRxInput ( 1 , 3 ) ;i'm assuming a RC like radio control... am i right? 2)Why did you cut all the joystick values in half? Code:
leftx = leftx / 2 ;let's say that the joystick is full forward with no spin Code:
leftx = GetRxInput ( 1 , 4 ) ----->=127 ;Code:
leftx = leftx / 2 = 63;and then: Code:
LF = RR = lefty - leftx + 127 = 127-63+127=193 ;Code:
RF = RF - spin + 63 = 63-63+63=63 ;Code:
RF=63 ;also, with full forward the motors only get up to 193 max 63 min values... (instead of 255 max and 0 min...) is this intentional? would you mind clearing this up for me? :confused: Thanks! -Leav |
Re: Mixing Joystick Values for mecanum wheels
This is the format for GetRxInput for Vex
GetRxInput ( Controller # , Channel # ); For FRC its: GetOIAInput (Port # , Joystick Axis # ); |
Re: Mixing Joystick Values for mecanum wheels
Quote:
|
Re: Mixing Joystick Values for mecanum wheels
artdutra04, would you mind clearing up my confusion?
|
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 ) ;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 ;3)something doesn't make sense: let's say that the joystick is full forward with no spin Code:
leftx = GetRxInput ( 1 , 4 ) ----->=127 ;Code:
leftx = leftx / 2 = 63;and then: Code:
LF = RR = lefty - leftx + 127 = 127-63+127=193 ;Code:
RF = RF - spin + 63 = 63-63+63=63 ;Code:
RF=63 ;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 |
Re: Mixing Joystick Values for mecanum wheels
There are other ways of doing this that will get you the full range of values. By the way, the range is 0-255.
I made up some mixing equations for an omni drive that I was making, but its outputs aren't the wheel setup that you have, so they would have to be revised. One suggestion that might help to get you in the right direction is to first map out your stuff for going forward/backward and left right. Then, consider turning as an override so that you have one speed that each wheel wants to go in the desired x-y direction and the value of how much you want to turn and scale down the effect of the x-y motion as the desired turn gets sharper. Assume X, Y, and Z are your inputs, Z being rotation. I beleive your final product will look something like: n=abs(z-127)/128; LF=Z+n( (X-Y); //and adjust this for each of your wheels |
Re: Mixing Joystick Values for mecanum wheels
Quote:
|
| All times are GMT -5. The time now is 17:54. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi