I need help with coding an x-drive in c++

#1

ok so i need a lot of help with my c++ code for my x drive does anyone know how to code an x drive using vcs if so thank you! (i can attach my code if needed)

0 Likes

#2

Post your code and we’ll go from there…

2 Likes

#3

Are you new to C++ and need help with the syntax, or is it specifically the fact that it’s an x-drive?

0 Likes

#4

@Foster’s way is probably best, but reviewing these might help…

Code Check for X Drive VCS

Coding for X-drive in robotC

x drive code

X-Drive in RobotC

VEX Mecanum Drive using ROBOTC

Help with v5 mecanum wheels Programming

There are many more, these were from the forum search and Google for “vex x drive code”. More can be found under “omni-wheel drive” & “holonomic drive” & “mercanum drive”. Along the way you see other good bits about tuning, and of course PID…

I suggest you not limit your studies to solving immediate goals, but research related subjects, and coding in other “languages” and programming environments.

3 Likes

#5

I’m new to c++ this will be my first year not using robotc

0 Likes

#6

Once I get home from my build day I’ll post it

0 Likes

#7

A simple holonomic project in Robot Mesh Studio C++ (which has similar enough names for things that this code should work unmodified). You might see if you like our editor while you’re there.

2 Likes

#8

Ok thank you I will check those out

0 Likes

#9

I just coded one a couple days ago. Perfect timing. If you open a new competition template, get all the motors set up and the two left drives should be reversed in my case. Then in the driver control section use this string of code (This is arcade control, meaning right stick controls movement direction and left and right on the left stick is turning)

  Bleft.spin(vex::directionType::fwd, Controller1.Axis2.value() + Controller1.Axis4.value() - Controller1.Axis1.value(), vex::velocityUnits::pct);
  Fleft.spin(vex::directionType::fwd, Controller1.Axis2.value() + Controller1.Axis4.value() + Controller1.Axis1.value(), vex::velocityUnits::pct);
  Bright.spin(vex::directionType::fwd, Controller1.Axis2.value() - Controller1.Axis4.value() + Controller1.Axis1.value(), vex::velocityUnits::pct);
  Fright.spin(vex::directionType::fwd, Controller1.Axis2.value() - Controller1.Axis4.value() - Controller1.Axis1.value(), vex::velocityUnits::pct);

I’m not entirely sure if this will drive correctly for your robot but if something is backwards just change the plus or minus sign in front of the controller axis or for the first one change the fwd to rev. Good luck!

0 Likes

#10

Thank you very much for this I will definitely be trying this code

0 Likes