Holonomic Programming

How do you program a standard 4-wheel holonomic robot (wheels in corners(easy C Pro))?

https://vexforum.com/t/answered-can-license-plates-be-oriented-sideways/27784/1&highlight=holonomic

Enjoy,
-Cody

I know Cody has already posted the link, but next time, try searching the forum for answers to your questions before making a new thread, many times people have already asked the same question, and people have given them answers. :slight_smile:

Thanks,
-Jordan

OK, I watched the tutorial, and used the program in my robot. But the program is for a + design holonomic robot, mine is a X design. After tinkering with the program for hours, I almost have it working. The robot will now move in any direction, but it won’t spin. Help! Below is the prgram I’m using(easyC Pro):

#include “Main.h”

void main (void)
{
int joy_1_x = 127;
int joy_1_y = 127;
int joy_2_x = 127;
int m1 = 0;
int m2 = 0;
int m3 = 0;
int m4 = 0;

while (1==1)
{
joy_1_x = GetRxInput (1,1);
joy_1_y = GetRxInput (1,2);
joy_2_x = GetRxInput (1,4);
joy_1_x = joy_1_x - 127;
joy_1_y= joy_1_y- 127;
joy_2_x= joy_2_x - 127;
m1 = (-1joy_1_y) + (joy_1_x) + (-1joy_2_x);
m2 = (joy_1_y) + (-1joy_1_x) + (-1joy_2_x);
m3 = (-1joy_1_y) + (joy_1_x) + (-1joy_2_x);
m4 = (joy_1_y) + (-1joy_1_x) + (-1joy_2_x);
if (m1>=127)
{
m1 = 127
}
else if (m1 <= -127)
{
m1 = -127
}
// Other checks are included in actual program
m1 = -1m1 + 127
m2 = -1
m2 + 127
m3 = m3 + 127
m4 = m4 + 127
SetPWM (1,m1)
SetPWM (2,m2)
SetPWM (3,m3)
SetPWM (4,m4)
}
}

No, the code Cody explained how to make in his tutorial was for an X holonomic drive…

#include “Main.h”

void main (void)
{
//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(1==1)
 {

      // Grab Values
  joy_1_x = GetRxInput (1,1) - 127;
  joy_1_y = GetRxInput (1,2) - 127;
  joy_2_x = GetRxInput (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
  SetPWM (1, m1 + 127);
  SetPWM (2, m2 + 127);
  SetPWM (3, m3 + 127);
  SetPWM (4, m4 + 127);
 }

}

Above is Cody’s code (haha) with a few mods, use this, then the only thing you should have to change is weather the “joy_1_y”, “joy_1_x” and “joy_2_x” are negative or positive in each line of:
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);

Which can be changed by adding or taking away “-1*”.
Some other things you might need to change are the motors being negative or positive, depending on how many gears you have from the motor to the wheel.

The simplest way to change between X and + mode holonomics (while using an old transmitter) is to use the 12 mix vs 23 mix functions of the transmitter. It rotates your coordinate system 45 degrees.

I finally got the robot running! And I’d like to thank everyone for their advice, especially jgraber for pointing out the obvious. A note for anyone making a holonomic drive: Set the transmitter to 23 mode. Thanks again!

Please explain this, I never really understood that function… How does it convert an (X,Y) matrix of values 45? What are the new minimum and maximum values? If I’m looking at the (X, Y) variables and I move the joystick strait up, what values will I get?

Nice! :cool:

-Cody

I learned about it word-of-mouth, experimentally verified it, and passed it on without getting to the root of the solution. But I did some limited on-line resarch and thought experiments at Cody’s prompting.
Per last page of this section of inventors guide:
http://www.vexrobotics.com/docs/inventors-guide/main-2008/13-e-transmitter-menus-06272008.pdf

23 mode is full scale unmixed tank drive mode, which you (Cody) developed your code for, which runs on X holo, since it doesn’t have any transmitter premix involved. The new PS-type cortex controller doesn’t look like it has 12mix mode anyway.
So the real question is why 12mix mode converts from X to +.
12mix mode is arcade mode premixed.
In a squarebot configuration, 23(un)mix mode directly controlling the motors with one joystick will require stick in the corner for straight ahead. Since this is a 45 degree shift from arcade mode, it makes sense that a using 12mix mode = arcade mode control on a X holonomic programming code will let it work properly on a + holo chassis.
If you have a + holo chassis, it would be a good idea to figure out all the details of what the controller is doing for(or to) you, or rewrite the code to not use the controller mixing, to make sure you know and have control of what is going on. It would be sad to be accidently limited to 50% power without realizing it or knowing why.

Cody, the above is a hand-waving theoretical answer.
If you are still interested in detailed answers to your specific questions as applied to 12mix mode, I think you’ll have more satisfaction if you measure them experimentally for yourself.

jgraber,

Thanks very much for that, I never bothered reading the manual (imagine that). After reading the Inventor’s Guide I realized what going on. Please know that I HIGHLY recommend that everyone stay in “2+3” mode. I say “2+3” because 23 overcomplicated things, all were talking about is Ch. 2 and Ch. 3.

Anyone looking for a “+” holonomic code simple needs to set the left and right motors equal to the Y axis of the left joystick, then invert one of the two motors output. Repeat this for the top and bottom motors except you will set those to the X axis and invert one. If you invert the wrong motor, the robot will move backward. If this happens, simply flip which motor is inverted. Then add in the right joystick’s X axis value for rotation.

Jgraber, I had no idea that the transmitter had so many built in control functions. Thanks for teaching me something!

-Cody

OH!
thats y its called mode “12” and mode “23”
i feel so stupid now :stuck_out_tongue:
going to try it out
(i remember when i first started vex, i went over the program for hours because the mode was wrong :P)

I know that you already have a code that works for you, but I posted the code for an X base holonomic drive robot in EasyC Pro last fall -https://vexforum.com/local_links.php?action=jump&catid=26&id=146.

I don’t remember what mode my transmitter was set at, but I used the channels on the right-hand stick to control the X-Y movements and the left-hand stick to control spinning. I thought that it worked really well and I owed it all to Cody’s great tutorial.

Very interesting. Thank you all for your help.