Mechanum wheel program is going diaganol

Hello, my program makes the robot do a arc or diagonal. Please help

here is my code

/*----------------------------------------------------------------------------*/
/*                                                                            */
/*    Module:       main.cpp                                                  */
/*    Author:       VEX                                                       */
/*    Created:      Wed Sep 25 2019                                           */
/*    Description:  SDV Template (Drivetrain)                                 */
/*                                                                            */
/*    Name:                                                                   */
/*    Date:                                                                   */
/*    Class:                                                                  */
/*                                                                            */
/*----------------------------------------------------------------------------*/

// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name]               [Type]        [Port(s)]
// Drivetrain           drivetrain    1, 2            
// Vision5              vision        5               
// ---- END VEXCODE CONFIGURED DEVICES ----

#include "vex.h"


using namespace vex;
brain brain1;
vex::motor ClawMotor = vex::motor(vex::PORT3);

vex::motor LtMotorF = vex::motor(vex::PORT7);
vex::motor RtMotorF = vex::motor(vex::PORT16);
vex::motor LtMotorB = vex::motor(vex::PORT2);
vex::motor RtMotorB = vex::motor(vex::PORT14);

vex::motor Motor1 = vex::motor(vex::PORT6, true);
vex::motor Motor2 = vex::motor(vex::PORT19, true);
vex::controller Controller1 = vex::controller();

motor_group LeftMotor (LtMotorB,LtMotorF);
motor_group RightMotor(RtMotorB,RtMotorF);

int main() {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();

  while (true) {

    int forward = Controller1.Axis3.position(vex::percent);
   int sideways = Controller1.Axis4.position(vex::percent);
   int turn = Controller1.Axis1.position(vex::percent);

   RtMotorF.spin(vex::forward, forward - sideways + turn, vex::percent);
   LtMotorF.spin(vex::forward,  forward + sideways - turn, vex::percent);
   RtMotorB.spin(vex::forward,  forward + sideways + turn, vex::percent);
   LtMotorB.spin(vex::forward,   forward - sideways - turn, vex::percent);
    wait (20,msec);
  }
}

Diagonal lines are just a combination of going forward or backward and strafing at the same time. Using more strafe will make you go more side ways and using less strafe will make you go more straight. As for arcs they are a combination of turning and strafing and sometimes also going forward as well. Arcs are a lot harder from what I have heard. Just make sure your driver has lots of time to get comfortable with them and watch a lot of videos to help get a sense of when to strafe and when to turn. (7K’s google matches have some insane driving).

But i am asking how to make it go side to side

Oh, if you have set up your wheels correctly follow this diagram.


Your plus, minuses look good to me, Are you looking for autonomous help? If not what does your current code do?

1 Like

The idea is one joy stick controls the foward backward, and side to side, the other is the turning

Your code looks fine to me. I, unfortunately, cannot help anymore as this is outside my area of expertise. Make sure your wheels are set up in the correct orientation. I may be able to help if I knew how the robot reacted when this code was used.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.