Mechanum wheel code

i have the code from my previous team for mecanum wheels and when I downloaded it the wheels wont even move.

here is the code.

frontR.spin(vex::directionType::fwd, Controller1.Axis3.value() + Controller1.Axis1.value() - Controller1.Axis4.value(), vex::velocityUnits::rpm);
frontL.spin(vex::directionType::rev, Controller1.Axis3.value() - Controller1.Axis1.value() + Controller1.Axis4.value(), vex::velocityUnits::rpm);
backR.spin(vex::directionType::fwd, Controller1.Axis3.value() + Controller1.Axis1.value() + Controller1.Axis4.value(), vex::velocityUnits::rpm);
backL.spin(vex::directionType::rev, Controller1.Axis3.value() - Controller1.Axis1.value() - Controller1.Axis4.value(), vex::velocityUnits::rpm);

///put these lines of code below where you name all the motors and stuff.

void wait(float mSec){
vex::task::sleep(mSec);
}
int driveControlTask(){
while (Competition.isAutonomous()!=1){
LeftMotor.spin(vex::directionType::fwd, Controller1.Axis3.value() + Controller1.Axis1.value() + Controller1.Axis4.value(),  vex::velocityUnits::pct);
RightMotor.spin(vex::directionType::fwd, Controller1.Axis3.value() - Controller1.Axis1.value() - Controller1.Axis4.value(), vex::velocityUnits::pct);
BackLeftMotor.spin(vex::directionType::fwd, Controller1.Axis3.value() + Controller1.Axis1.value() - Controller1.Axis4.value(), vex::velocityUnits::pct);
BackRightMotor.spin(vex::directionType::fwd, Controller1.Axis3.value() - Controller1.Axis1.value() + Controller1.Axis4.value(), vex::velocityUnits::pct);
wait(10);

} return(0);
}

-----------------------------------------------------------------------

 ///Place these two lines of code above the while(1){       This is at the bottom of the code
void usercontrol( void ) { 
vex::task driveControl(driveControlTask);

while (1) {
----------------------------------------------------------------------
//Set up callbacks for autonomous and driver control periods. 
///Place the two lines that are below under the //Set up callbacks for autonomous and driver control periods. that is on the bottom of the code.
Competition.autonomous( autonomous );
Competition.drivercontrol( usercontrol );
1 Like

This is what I used for two years. And it works perfect. There has never been any issues. If you have any problems or questions just ask me

whenever we use programs like this our wheels don’t move when we move the joysticks

@Calvin_Thrasher’s code looks right to me. You probably need to reconfigure your motors and ensure they’re properly declared and working.

1 Like

Do you mind showing us your whole code. Because there might be something somewhere else if my code isn’t working for it. Have you tested my code yet

1 Like

You might have your mec wheels setup wrong. Send a pic of the actual robot

Well while that is true they said the wheels wouldn’t move at all. So I don’t think that is the problem.

Could you also with the code off try and physically move the wheels. Because you might have something in one each wheels that is getting caught on something.

we have a rough program made in blocks that works (more or less)

Well if that works for you great. But I would advice you if you want to become good at coding you are going to have to know and to use text. But if you could. At least try once and once and a while to fix the code.

that is our plan we just want something that work while we are trying text as well

Did try and switch out your code with mine?

yes i was having the same issue as our old teams code

Yah that shouldn’t happen. Do you mind posting your code? Myself and others could probably find the issues very quickly

Just to be clear, this is in a while loop, no? So the code continually updates, and doesn’t stop after one run-through?

(Looks something like this):

while(1) {
frontR.spin(vex::directionType::fwd, Controller1.Axis3.value() + Controller1.Axis1.value() - Controller1.Axis4.value(), vex::velocityUnits::rpm);
frontL.spin(vex::directionType::rev, Controller1.Axis3.value() - Controller1.Axis1.value() + Controller1.Axis4.value(), vex::velocityUnits::rpm);
backR.spin(vex::directionType::fwd, Controller1.Axis3.value() + Controller1.Axis1.value() + Controller1.Axis4.value(), vex::velocityUnits::rpm);
backL.spin(vex::directionType::rev, Controller1.Axis3.value() - Controller1.Axis1.value() - Controller1.Axis4.value(), vex::velocityUnits::rpm);
}
2 Likes

I believe so yes
20 characters

I know this topic isn’t about me but is there something better about using rpm at the end of each line more than pct. because I use pct.

/----------------------------------------------------------------------------/
/* /
/
Module: main.cpp /
/
Author: C:\Users\Yoga260 /
/
Created: Mon May 11 2020 /
/
Description: V5 project /
/
/
/
----------------------------------------------------------------------------*/

// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name] [Type] [Port(s)]
// Controller1 controller
// frontR motor 1
// backR motor 10
// frontL motor 11
// backL motor 20
// ---- END VEXCODE CONFIGURED DEVICES ----

#include “vex.h”
#include “robot-config.h”

using namespace vex;

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

;

backR.spin(vex::directionType::fwd, (Controller1.Axis3.value() + Controller1.Axis1.value() + Controller1.Axis4.value(), vex::velocityUnits::pct);
frontL.spin(vex::directionType::fwd, Controller1.Axis3.value() - Controller1.Axis1.value() - Controller1.Axis4.value(), vex::velocityUnits::pct);
backL.spin(vex::directionType::fwd, Controller1.Axis3.value() + Controller1.Axis1.value() - Controller1.Axis4.value(), vex::velocityUnits::pct);
frontR.spin(vex::directionType::fwd, Controller1.Axis3.value() - Controller1.Axis1.value() + Controller1.Axis4.value(), vex::velocityUnits::pct);

}

///Place these two lines of code above the while(1){ This is at the bottom of the code

///Place the two lines that are below under the //Set up callbacks for autonomous and driver control periods. that is on the bottom of the code.

//

I know this sounds silly but can you edit that and put ``` on the first and very last line of that code. It configures it to how it would look on vex code. Make sure there is nothing on the line they are on.