View unanswered posts | View active topics It is currently Sat Jan 21, 2017 11:38 pm

Reply to topic  [ 2 posts ] 
Vex Omni Wheel Drive Code Help 
Author Message

Joined: Thu Nov 29, 2012 9:32 pm
Posts: 8
Post Vex Omni Wheel Drive Code Help
Ok so for fun i made a simple square chassis bot with a motor+wheel on each of the sides (not angled like most bots) to have a holonomic bot. My goal is to have the left joystick control the omni direction part of the movement (front, back, left, right, etc) and the right joy stick to control the rotating of the bot. I know how to program it if i were to angle each of the 4 wheels, but i dont want to do that. I want to have a wheel on the front, back, left, and right. I need a little help fixing the code to work how i want it to.
#pragma config(Motor,  port1,           leftWheel,     tmotorVex393, openLoop, reversed)
#pragma config(Motor,  port4,           frontWheel,       tmotorVex393, openLoop, reversed)
#pragma config(Motor,  port5,           backWheel,      tmotorVex393, openLoop)
#pragma config(Motor,  port7,           tropheeMotor,      tmotorVex393, openLoop)
#pragma config(Motor,  port10,          rightWheel,    tmotorVex393, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()

   //Create "deadzone" variables. Adjust threshold value to increase/decrease deadzone
int X2 = 0, Y1 = 0, X1 = 0, threshold = 15;

//Loop Forever
while(1 == 1)
   //Create "deadzone" for Y1/Ch3
   if(abs(vexRT[Ch3]) > threshold)
      Y1 = vexRT[Ch3];
      Y1 = 0;

   //Create "deadzone" for X1/Ch4
   if(abs(vexRT[Ch4]) > threshold)
      X1 = vexRT[Ch4];
      X1 = 0;

   //Create "deadzone" for X2/Ch1
   if(abs(vexRT[Ch1]) > threshold)
      X2 = vexRT[Ch1];
      X2 = 0;

   //Remote Control Commands
   motor[leftWheel] = Y1 + X2;
   motor[rightWheel] =  Y1 - X2;
   motor[frontWheel] = X1 + X2;
   motor[backWheel] =  X1 - X2;

Above is the current code that i have for it. I know that the remote control commands are wrong...could someone help me make it right?

Also i know it I put

and vice versa and such that the controls will work fine, EXCEPT that the top speed of the robot when going straight will be 63. How can i fix that?

Wed Feb 26, 2014 8:11 pm

Joined: Thu Dec 01, 2011 12:07 am
Posts: 146
Post Re: Vex Omni Wheel Drive Code Help
Break the tasks down a little...
- Calculate the speed you want by taking the absolute value of the X and Y average
- Calculate the direction you want by using a little trigonometry
- Apply the direction and speed to the motors with more trigonometry

Review this post to help with the 3rd element above

Thu Feb 27, 2014 1:55 pm
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.