# Omni Drive --- HELP PLEASE

Hello,
i want to have a omni directional drive, i have the chassis ready but i am not able to make a proper program.
I am using the older version of easyC, i tried everything but nothing worked.
I saw all the codes on this site, tried them but they didnt work.
In my chassis wheels aren’t perpendicular to each other, in other words they are at the four corners of the chassis.

I really need help. Any type of help will be appreciated.

Thank you.

Please note that I moved your Post from the VRC-Round Up Official Rules Q&A Forum to the Technical Discussion Forum because it does not only relate to the VRC Round Up game.

Does you Omni Wheel design look like smartkid’s Holonomic design shown in the thread Holonomic drives: A video tutorial by Smartkid??

Can you Post the Link to the EasyC Code that you tried to use??

The RobotC program for smartkid’s design should look like this, it can be converted to EasyC if that would help you:

``````
//Vars

joy_1_x = 127;
joy_1_y = 127;

joy_2_x = 127;
joy_2_y = 127;

m1 = 0;
m2 = 0;
m3 = 0;
m4 = 0;

while(teleop)
{

// Grab Values
joy_1_x = vexrx(1,1) - 127;
joy_1_y = vexrx(1,2) - 127;
joy_2_x = vexrx(1,2) - 127;

//Math...
m1 = (joy_1_y) + (-1 * joy_1_x) + (-1 * joy_2_x);
m2 = (-1 * joy_1_y) + (-1 * joy_1_x) + (-1 * joy_2_x);
m3 = (-1 * joy_1_y) + (joy_1_x) + (-1 * joy_2_x);
m4 = (joy_1_y) + (joy_1_x) + (-1 * joy_2_x);

//Checks
if (m1 >= 127)
{
m1 = 127;
}
else if(m1 <= -127)
{
m1 = -127;
}

if (m2 >= 127)
{
m2 = 127;
}
else if(m2 <= -127)
{
m2 = -127;
}

if (m3 >= 127)
{
m3 = 127;
}
else if(m3 <= -127)
{
m3 = -127;
}

if (m4 >= 127)
{
m4 = 127;
}
else if(m4 <= -127)
{
m4 = -127;
}

//Output
pwm(1, m1 + 127);
pwm(2, m2 + 127);
pwm(3, m3 + 127);
pwm(4, m4 + 127);

}

``````

Just to let you know, that code was actually meant to use for EasyC, not RobotC, it will not work correctly for RobotC, as RobotC uses motor power values from 127 to -127, not 0 to 255 (I think?) like EasyC does. But the code should work perfectly fine for EasyC.

P.S. The code can be easily changed to work with RobotC.

-Jordan

Me Culpa…

With calls to a function called [FONT=“Courier New”]vexrx(1,1)[/FONT], it did not look like EasyC.

Either way, I think what konkey is describing should be solve-able with the code posted by smartkid…

hey does anyone have a “H” drive code?
school didnt start yet so i didnt fiddle arond with that yet…

True, I believe Cody just wrote out the code from memory. And yes, it should be simple to re-write into EasyC code.

Good luck konkey, and feel free to ask any other questions you may have.

-Jordan

Can you post a link to the Power Train layout??? This sounds like a nice “distraction” from everyday coding… oh!
uhh standard H drive
port 1: front right
port 2 : back right
port 3: front left
port 4: back left
port 5: strafe
is that what you want?
if not i can always pm you a copy of my H drive
oh i only have easyC pro btw
thanks

Yes, PM is fine, I was wondering about how the Wheels were aligned with the Chassis.

Not a Problem, I have EasyC 1.1, 2.x, Pro (3.x) and RobotC 1.x and 2.x, plus MCC18 with MPLAB.

Okay, this is very simple, but you will have to tell me how you want to control it, do you want what our team did? (Tank drive, but if you move both joystick’s horizontally it causes the center linear drive wheel to run.)

-Jordan

Here is Post from the Re: Holonomic drives: A video tutorial by Smartkid Thread:
Re: Holonomic drives: A video tutorial by Smartkid (Post 87)

This is a nice diagram of a type of Holonomic Drive.

right joystick controls x,y movement
left joystick (left to right) controls rotation
sent you the screenshot marko

Thank you so much.
I used Cody’s code, and it works really well, but i have a small problem.
I am using EasyC, after uploading the program, when i drive the chassis, all the 3 motors work, but the one in port 3, motor 3 dosent work on y-axis.
and when i am not doing anything, when i am not moving the joystick, motor 2 and motor 3 keep spinning, like the wheels keep spinning and that is causing me a little problem.

If you can just guide me a little bit more, please.

Thank You so much. Okay, to do this is very simple, we simply take Cody’s code (Haha. =D ), and edit the motor power and direction calculation part:

``````m1 = (joy_1_y) + (-1 * joy_1_x) + (-1 * joy_2_x);
m2 = (-1 * joy_1_y) + (-1 * joy_1_x) + (-1 * joy_2_x);
m3 = (-1 * joy_1_y) + (joy_1_x) + (-1 * joy_2_x);
m4 = (joy_1_y) + (joy_1_x) + (-1 * joy_2_x);``````

Now we can just remove the joy_1_x parts (the right joystick’s X axis movement, that causes the robot to move left and right), as the only thing we want the “main” four motors/wheels (the ones set up in the tank drive configuration) to do, is to drive forward, backward, and spin, no left to right movement, as that is done by the 5th drive motor/wheel. So, we will get this: (Remember, since you want the right side to control the direction, and the left to control spinning/turning, we flip which joystick is “1” and which one is “2”.)

``````m1 = (joy_2_y) + (-1 * joy_1_x);
m2 = (-1 * joy_2_y) + (-1 * joy_1_x);
m3 = (-1 * joy_2_y) + (-1 * joy_1_x);
m4 = (joy_2_y) + (-1 * joy_1_x);``````

**EDIT:

Now, since this part is only tank drive, both left motors will be equal in direction and speed, same with the right, but also our motor setup is a little different, so we will do this:

``````**m1 = (joy_2_y) + (-1 * joy_1_x);
m2 = (joy_2_y) + (-1 * joy_1_x);
m3 = (joy_2_y) + (joy_1_x);
m4 = (joy_2_y) + (joy_1_x);**``````

**

Now we simply add in the 5th drive motor/wheel, which is equal to joy_1_x (the right joystick’s X axis movement), to get this:

``````m1 = (joy_2_y) + (-1 * joy_1_x);
m2 = (joy_2_y) + (-1 * joy_1_x);
m3 = (joy_2_y) + (joy_1_x);
m4 = (joy_2_y) + (joy_1_x);
m5 = (joy_1_y);``````

NOTE: You may have to reverse some of the drive motors to get this to work properly, but you should not have to edit this code.

All in all you will get something like this:

``````//Vars

joy_1_x = 127;
joy_1_y = 127;

joy_2_x = 127;
joy_2_y = 127;

m1 = 0;
m2 = 0;
m3 = 0;
m4 = 0;
m5 = 0;

while(teleop)
{

// Grab Values
joy_1_x = vexrx(1,1) - 127;
joy_1_y = vexrx(1,2) - 127;
joy_2_x = vexrx(1,2) - 127;

//Math...
m1 = (joy_2_y) + (-1 * joy_1_x);
m2 = (joy_2_y) + (-1 * joy_1_x);
m3 = (joy_2_y) + (joy_1_x);
m4 = (joy_2_y) + (joy_1_x);
m5 = joy_2_x;

//Checks
if (m1 >= 127)
{
m1 = 127;
}
else if(m1 <= -127)
{
m1 = -127;
}

if (m2 >= 127)
{
m2 = 127;
}
else if(m2 <= -127)
{
m2 = -127;
}

if (m3 >= 127)
{
m3 = 127;
}
else if(m3 <= -127)
{
m3 = -127;
}

if (m4 >= 127)
{
m4 = 127;
}
else if(m4 <= -127)
{
m4 = -127;
}

//Output
pwm(1, m1 + 127);
pwm(2, m2 + 127);
pwm(3, m3 + 127);
pwm(4, m4 + 127);
pwm(5, m5 + 127);

}``````

-Jordan

umm thatnks jordan
i know how to do that via robotc now but still not in easyc i also have a copy of smartkids programming, so i may be able to disect it when i get back
@marko
it didnt work for some reason

Sorry, I do not own EasyC and I’m not very familiar with it, but I thought it was fairly simple to convert from similar text into EasyC code, am I wrong?

-Jordan

OK, got your Drive Train layout, and got Directional Controls from previous posts…

What do you consider the X and Y movement?? X being Forward and Back, and Y being Left and Right??

Is it OK if the Rotation is combined with the X and Y directions, or should the Rotation ONLY be allowed when the X and Y motion is Neutral (Zero).

How do you activate the Strafe Mode??? Does it need to be combined with the Rotation or X and Y Motion.

I believe he means X to be Left and Right, and Y to be Forward and Back, at least that is what Cody and I have used.

-Jordan

Doh!!! Yes… X being Left and Right and Y being Forward and Back.