Go to Post Tank tracks are one of those things that keep showing up on FIRST robots, in ways that I dont understand. - KenWittlief [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Spotlight this post!  
Unread 05-10-2008, 17:41
Foster Foster is offline
Engineering Program Management
VRC #8081 (STEMRobotics)
Team Role: Mentor
 
Join Date: Jul 2007
Rookie Year: 2005
Location: Delaware
Posts: 1,393
Foster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond repute
Re: Omni Vex code in easyc?

If you search for holonomic drive, you can find a number of posts about it.

Arthur Dutra wrote this code (and posted it) to support a holononmic drive. One joystick stick moves forward/back and side-side (and diagonally) for translation motion. The other joystic moves left/right to rotate, both can be moved at the same time.

The platform consists of four omni wheels mounted at 180 degrees from the next corner (ie two go "forward / backwards" two go "left / right"

Code is for the WPILibrary, so it should work fine with EasyC.

Let us know how you make out.

Code:
#include "API.h"

void main ( void )
{
int LF; // Left Front
int RF; // Right Front
int LR; // Left Rear
int RR; // Right Rear
int leftx;
int lefty;
int rightx;
int spin;
      while ( 1 )
      {
            // Get Data 
            leftx = GetRxInput ( 1 , 4 ) ; // Left Joystick, X Axis
            lefty = GetRxInput ( 1 , 3 ) ; // Left Joystick, Y Axis
            rightx = GetRxInput ( 1 , 1 ) ; // Right Joystick, X Axis
            // Half the input signal (so code does not overflow past 255)
            leftx = leftx / 2 ;
            lefty = lefty / 2 ;
            spin = rightx / 2 ;
            // Drive Code Algorithim
            LF = RR = lefty - leftx + 127 ;
            RF = LR = 255 - lefty - leftx ;
            RR = 255 - RR ; // Reverse Direction of RR motor
            LR = 255 - LR ; // Reverse Direction of LR motor
            // Spin Code Algorithim
            RF = RF - spin + 63 ;
            RR = RR - spin + 63 ;
            LF = LF - spin + 63 ;
            LR = LR - spin + 63 ;
            // Code overflow prevention
            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 ) ;
      }
}
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2008 Omni Drive Code Help Vasily Zaitsev Technical Discussion 5 27-01-2008 00:57
pic: vex omni drive 1902_Battery_SGT FIRST Tech Challenge 6 28-05-2006 17:55
pic: simple omni vex bot colin340 FIRST Tech Challenge 15 05-05-2006 17:16
EasyC Default Code Team 1649 Programming 13 29-01-2006 11:52
Vex Easyc vs Mplab Joohoo Programming 17 27-01-2006 08:22


All times are GMT -5. The time now is 19:26.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi