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