V5 vexcode Pro xdrive

I am trying to code a xdrive on vex code pro but dont know what im doing, i can program tank drive but not holonomic drive.

heres my code

/*----------------------------------------------------------------------------*/
/*                                                                            */
/*    Module:       main.cpp                                                  */
/*    Author:       C:\Users\Daniel                                           */
/*    Created:      Sat Apr 17 2021                                           */
/*    Description:  V5 project                                                */
/*                                                                            */
/*----------------------------------------------------------------------------*/

// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name]               [Type]        [Port(s)]
// Leftfront            motor         11              
// Rightfront           motor         1               
// Leftrear             motor         16              
// Rightrear            motor         12              
// Controller1          controller                    
// ---- END VEXCODE CONFIGURED DEVICES ----

#include "vex.h"

using namespace vex;

int main() {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();
   //start by displaying what program is running on the LCD
  Brain.Screen.setPenColor(color::blue);
  Brain.Screen.print("Hello there");
  Brain.Screen.newLine(); 
  Brain.Screen.newLine();    
  Brain.Screen.setPenColor(color::red);
  Brain.Screen.print("General Kenobi");
    //create an infinate while loop to continually check the controller readings
    while(1){ 
     Leftfront.spin(forward,Controller1.Axis2.position()+Controller1.Axis1.position()+Controller1.Axis4.position(), percent);
     Rightfront.spin(forward,Controller1.Axis2.position()+Controller1.Axis1.position()+Controller1.Axis4.position(), percent);
     Rightrear.spin(forward,Controller1.Axis2.position()+Controller1.Axis1.position()+Controller1.Axis4.position(), percent);
     Leftrear.spin(forward,Controller1.Axis2.position()+Controller1.Axis1.position()+Controller1.Axis4.position(), percent);
     
     
   
 
  
  
  
        }
        

   task::sleep(20);}

It doesn’t seem like you quite understand what to do with the inputs. Check out this video (skip to 0:53 ish). While he is programming with the old cortex, the concepts should help

6 Likes

I sort of understand it but its RobotC, how do i get it into VexcodePro

Your code is correct. You just need to change a couple of ± signs to -. Watching the above video will give you the information you need.

1 Like

thank u.

next question, how do i get my motors running at less than 100%

For auton? Just type 50 where you have your long equation.

For driver control? Just don’t move the joystick as far.

Or are you looking to create a macro?

2 Likes

Try this: Holonomic drives 2.0: A video tutorial by Cody

1 Like