X-Drive on EasyC

On EasyC do you program an X-drive like a regular holonomic or is it different?

I have not used EasyC, however I know that the basic concepts of coding are the same whether you are using RobotC or EasyC.

I am not sure what you mean by “a normal holonomic”, so I will just show you what we did this year.

There are several different configurations you can have on your remote for a holonomic drive, however the basic concept for coding all of them is the same. You are going to have 4 different outputs for each of the 4 wheels. Each output for each wheel is comprised of two things, your X axis movement and your Y axis movement; your forwards-backwards movement, and your left-right movement (I’m going to ignore turning for a moment). So what you are doing is adding your X axis movement with your Y axis movement. Say your right joystick is what controls strafing, and you have a regular tank drive programmed in for your forwards backwards motion. Assuming your motors are set up so a positive value on all four would result in moving straight forwards, here is what that would look like:

motor[leftFront] = vexRT[Ch3] + vexRT[Ch1];
motor[leftBack] = vexRT[Ch3] - vexRT[Ch1];
motor[rightFront] = vexRT[Ch2] - vexRT[Ch1];
motor[rightBack] = vexRT[Ch2] + vexRT[Ch1];

You can apply this principle no matter how you want the controller programmed. For instance, we actually are using buttons 5U and 6U as our strafing actuators, and so we used that same principle except instead of Ch1, we used the button values multiplied times a variable that was the speed we wanted to strafe at.

Hope this helped!
Luke Rohler

An x drive is a holonomic so yes just use the holonomic drive function. the same goes with mechanum drives. You could very well use what master Luke has suggested and get the same results from it because that’s probably what is inside the holonomic function anyway.

the way you would do it from scratch would be to use a get ‘analog input’ each channel and save each one to a different variable and then put the in a set motor function by clicking a custom speed and putting the code in there.

The code for getting the channels would look something like this:

getAnolagImput(1) = chanel1;
getAnolagImput(2) = chanel2;
getAnolagImput(3) = chanel3;

then the first line of Lukes code would look like this (LeftFront is just a place holder for whatever port # you happen to make it)


setMotor(LeftFront, chanel3 + chanel1);

I’m not sure what you mean by “regular holonomic” – some would consider an X-drive to be a “regular holonomic”. If by “regular holonomic” you mean a +drive (plus-drive), the programming for + vs. X drives are different.

EasyC for Cortex has an X-holonomic command in the menu. It shows a diagram of which of the 4 ports used are assigned to each of the 4 motors as configured. You assign which channel you want to use to control the motors.

The programming is essentially done for you. You just need to make sure the X-holonomic command is in a loop, so you’re continually updating the controller.

“getAnolagImput”

That’s a new one :slight_smile:

Thanks guys!

Hi Everyone,

I’m trying to do this in Easy C, however can’t seem to find a combo that works with the pre-programmed setup in Easy C!

Please help.

I looked in the online window and in order to make the motors turn clockwise they need these values:

Front Left (Motor 1) -
Back Left (Motor 2) +
Front Right (Motor 9) +
Back Right (Motor 10) -

Meaning that to …

           STRAFE   STRAFE
            LEFT       RIGHT

FL(1) - +
BL(2) - +
FR(9) + -
BR(10) + -

           MOVE              MOVE
           FORWARDS      BACKWARDS

FL(1) + -
BL(2) - +
FR(9) + -
BR(10) - +

          ROTATE       ROTATE
           RIGHT           LEFT 

FL(1) + -
BL(2) - +
FR(9) - +
BR(10) + -

Bearing this in mind, I opened a New competition program and clicked on operator control tab. Then expanded the joystick menu and dragged and dropped the holonomous option. Then I saw what the .jpg shows.

How do I set it up?

I can’t seem to figure it out!

Thanks in advance!

Well first set all the motor ports in the window to the corresponding motor. “front left” meaning the motor in the front left corner

Then test that. You might have to click invert on some of the motors if they are going in the wrong direction.

Also just for clarification on the vex joystick each direction on each joystick is given a channel number so that you can customize which channel does what in the holonomic block.

Yes done that, however, cant get a combination of which motors to invert which works.

e.g. invert the right hand side motors means that channel 2 strafes left and right.
BUT channel 3 rotates instead of forward/backward.

and channel 4 rotates the other way.

totally stuck! :confused:

You haven’t posted your code that you tried, not even the first one.
The picture you posted is the default Holonomic setup, which does not include channel 2, but you said channel 2 was doing something.
Post your code if you are stuck. include a picture of your robot would also help.

Note that swapping the polarity of the motor (unplug and replug in backwards) to the MC#29 (or ports 1,10) is the same as clicking the invert option on the program, and is quicker since you don’t even have to stop to reload the cortex.

There are 2**4 =16 combinations of inversion on 4 motors, it sounds like you need to write them down and check them one by one. Other procedural tips:

  • You are using omniwheels, right, not normal wheels?

  • put a postit note on the front corner marked front, and start every test with the robot in front of you, facing away from you, on a foam floor, with some ballast weight on the robot (to make sure all 4 omni wheels are touching)

  • make sure the motor numbers in the holonomic code block match front/right/left/back.

  • do the same tests in the same order every time: rotate left, rotate right; If you get the motors inverted so that all motors rotate correctly, the rest should also work if you have the motor numbers correct.

  • You can walk through the next 15 combinations of inversion most quickly by using this gray code pattern: 1,2,1, 3, 1,2,1, 4, 1,2,1, 3, 1,2,1 ;assuming motors numbered 1,2,3,4, just swap polarity on each number as it is.

Forget about strafe to start with.

You posted this.

presumably control values to make motors turn CW.

From this I see that FL and BR need inversion so positive control = CW motion. But, CW on left is forward and CW on right is backwards, so then invert the right hand side motors.

FL = motor 1 - Invert
BL = motor 2 - no invert
FR = motor 9 - invert
BR = motor 10 - no invert

start there and see if fwd/rev and rotate work (ie. arcade drive). Then see what happens with strafe.

Thanks for your help so far. This is something that surely should be much easier than it is.

Ok so I set the motors up on easy C to all NOT be inverted. Then downloaded the program. (you can see my robot on the 1st pic).

Then (look at the 2nd pic) I tried all of the combinations, noting down what happened.

I noticed that to get channel 1 to rotate, motors 2 and 9 needed the same polarity.

However, on those combinations channels 3 and 4 both moved the robot in a diagonal direction.

No combination seemed to make the robot move forward/backward.

I don’t know why this is.

The robot is quite light, could it be that it needs lots of downforce to make the omni wheels work? If so, this is not good!

The other thing worth mentioning is that I don’t know what you mean by ‘code’. I’ve always programmed controllers in arcade/tank setup by doing it this way.

But this holonomous is really baffling me. :confused:


Based on your pictures you are going to have issues for two reasons:

1.) As you said…its too light. You need a bit of weight that is evenly distributed to get a good test of most x-drives.

2.) Your X is not an X. All wheels should be equal distance from each other. I’m sure it can technically work like you have it, but you are going to have all sorts of problems I think. (you have have a rectangular frame, not a square)

I would personally do the testing by actually monitoring which directions the wheels are moving when you request certain movements…not the robot itself.

THIS IS NOT A POLARITY ISSUE, PUT THE MOTORS ALL IN THE SAME POLARITY. IE PLUG THE BLACK WIRE TO THE BLACK WIRE AND THE RED TO THE RED.

THEN…

start changing which of the four ports goes to which motor until the f***ing thing moves correctly (IE forward) when you push up on the left stick.

Then work on strafing. If it moves correctly going forward and strafes the wrong direction there’s an easy fix.

PRO TIP: Use the included diagram…

So I gave in and created the holo block in EasyC. It looks like perhaps with a correctly wired robot then nothing is inverted (i.e… EasyC takes care of logic internally), but, as Cody so elegantly pointed out, you have at least one wire plugged in the wrong way (port 10), so… either fix that (with EasyC black wire goes towards vexnet key on ports 1&10, the opposite from ROBOTC unfortunately) or invert port 10 on the holo block.

With such a non-square design, and no weight, accurate from/back movement will not be so good.

haha ok Thanks guys. I echo your frustration Cody!

With your way it should throw up 96 combinations (by my maths) as opposed to the 16 by changing the polarity. Will give that a try.

Jpearman - the intention is to fix the mount on top with the linear lift so that will increase the downforce. Whether it will be enough is another question.

Will add more weight on for now and give it a try.

It’s good this is all being spoken about on here as it will help others in the future who have this problem.

Thanks again for your brilliant help so far.

Will get there in the end!

Just get the wiring correct (red-red on the MC29 connections and ports 1&10 correct) and then the default of no inversion on the holo block motors should work I think.

GREAT NEWS GUYS!

Got it to work!!!

Channel 3 F/W
Channel 4 L/R
Channel 1 Rotate

Had them all on positive polarity

Front Left (Motor 1 to Port 1)
Back Left (Motor 2 to Port 2)
Front Right (Motor 9 to Port 9)
Back Left (Motor 10 to Port 10)

LOL!

Doesn’t go exactly straight but as you said I think thats because it’s rectangular.

I think this is the mistake I made. I thought it was going diagonally when actually it WAS going forward all along, but the frame shape was affecting why it wasn’t going ‘straight’.

I’ll adjust the frame! Thank you all so much for your brilliant input and advice.

Knew it would be a simple thing!

Congrats.

Having a non-square design isn’t nominal, but it’ll only really hurt you when rotating, play with it and if it’s a real problem then I’d suggest going for a more square-ish design. If it’s not a real problem, you can keep it or change it, up to you.

I’ve seen non-square, and even non-45 degree holonomics, they’re funny looking but still work decently well.

Sailing through the air, like a majestic Eagle, piloting a blimp.

Ha, I meant to say “eloquently”, stupid auto correct.