View Single Post
  #3   Spotlight this post!  
Unread 13-01-2006, 17:20
artdutra04's Avatar
artdutra04 artdutra04 is offline
VEX Robotics Engineer
AKA: Arthur Dutra IV; NERD #18
FRC #0148 (Robowranglers)
Team Role: Engineer
 
Join Date: Mar 2005
Rookie Year: 2002
Location: Greenville, TX
Posts: 3,078
artdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond repute
Re: Mixing Joystick Values for mecanum wheels

Quote:
Originally Posted by [Leav
any ideas on how to integrate the Z axis so that when stationary the robot can be controlled to turn around itself but can still be turned while moving in a straight line (i realize that the form would be a circle of sorts)

later 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)
This following code does exactly what you want, but it does not use a gyro. The robot control is relative to the current position of the robot. It might not be as easy to drive as an absolute position omni/mecanum drive, but it is still very intuitive and easy to control.

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 ) ;
      }
}
And here is that code in action:

~15 Mb - Windows Media Video - http://www.team228.org/index/multime...omic-drive.wmv
__________________
Art Dutra IV
Robotics Engineer, VEX Robotics, Inc., a subsidiary of Innovation First International (IFI)
Robowranglers Team 148 | GUS Robotics Team 228 (Alumni) | Rho Beta Epsilon (Alumni) | @arthurdutra

世上无难事,只怕有心人.

Last edited by artdutra04 : 13-01-2006 at 17:26.