HI, I spent a while trying to figure out mecanum drive and just resorted to a code where I map it in code
/*----------------------------------------------------------------------------*/
/* /
/ Module: main.cpp /
/ Author: danielsarasohn /
/ Created: Tue Nov 03 2020 /
/ Description: V5 project /
/ /
/----------------------------------------------------------------------------*/
// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name] [Type] [Port(s)]
// Controller1 controller
// BackLeft motor 1
// BackRight motor 10
// FrontRight motor 3
// FrontLeft motor 9
// ---- END VEXCODE CONFIGURED DEVICES ----
#include “vex.h”
using namespace vex;
void speed2()
{
FrontRight.spin(directionType::fwd,((Controller1.Axis3.value() - Controller1.Axis1.value()- Controller1.Axis4.value())*2),velocityUnits::rpm);
BackRight.spin(directionType::fwd,((Controller1.Axis3.value() - Controller1.Axis1.value()+ Controller1.Axis4.value())*2),velocityUnits::rpm);
FrontLeft.spin(directionType::fwd,((Controller1.Axis3.value() + Controller1.Axis1.value()+ Controller1.Axis4.value())*2),velocityUnits::rpm);
BackLeft.spin(directionType::fwd,((Controller1.Axis3.value() + Controller1.Axis1.value()- Controller1.Axis4.value())*2),velocityUnits::rpm);
}
void speed4()
{
FrontRight.spin(directionType::fwd,((Controller1.Axis3.value() - Controller1.Axis1.value()- Controller1.Axis4.value())*4),velocityUnits::rpm);
BackRight.spin(directionType::fwd,((Controller1.Axis3.value() - Controller1.Axis1.value()+ Controller1.Axis4.value())*4),velocityUnits::rpm);
FrontLeft.spin(directionType::fwd,((Controller1.Axis3.value() + Controller1.Axis1.value()+ Controller1.Axis4.value())*4),velocityUnits::rpm);
BackLeft.spin(directionType::fwd,((Controller1.Axis3.value() + Controller1.Axis1.value()- Controller1.Axis4.value())*4),velocityUnits::rpm);
}
void slow2()
{
FrontRight.spin(directionType::fwd,((Controller1.Axis3.value() - Controller1.Axis1.value()- Controller1.Axis4.value())/2),velocityUnits::rpm);
BackRight.spin(directionType::fwd,((Controller1.Axis3.value() - Controller1.Axis1.value()+ Controller1.Axis4.value())/2),velocityUnits::rpm);
FrontLeft.spin(directionType::fwd,((Controller1.Axis3.value() + Controller1.Axis1.value()+ Controller1.Axis4.value())/2),velocityUnits::rpm);
BackLeft.spin(directionType::fwd,((Controller1.Axis3.value() + Controller1.Axis1.value()- Controller1.Axis4.value())/2),velocityUnits::rpm);
}
void slow4()
{
FrontRight.spin(directionType::fwd,((Controller1.Axis3.value() - Controller1.Axis1.value()- Controller1.Axis4.value())/4),velocityUnits::rpm);
BackRight.spin(directionType::fwd,((Controller1.Axis3.value() - Controller1.Axis1.value()+ Controller1.Axis4.value())/4),velocityUnits::rpm);
FrontLeft.spin(directionType::fwd,((Controller1.Axis3.value() + Controller1.Axis1.value()+ Controller1.Axis4.value())/4),velocityUnits::rpm);
BackLeft.spin(directionType::fwd,((Controller1.Axis3.value() + Controller1.Axis1.value()- Controller1.Axis4.value())/4),velocityUnits::rpm);
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
while(true) {
if(Controller1.ButtonX.pressing())
{
speed4();
}
if(Controller1.ButtonY.pressing())
{
slow2();
}
if(Controller1.ButtonB.pressing())
{
slow4();
}
if(Controller1.ButtonA.pressing())
{
speed2();
}
FrontRight.spin(directionType::fwd,((Controller1.Axis3.value() - Controller1.Axis1.value()- Controller1.Axis4.value())),velocityUnits::rpm);
BackRight.spin(directionType::fwd,((Controller1.Axis3.value() - Controller1.Axis1.value()+ Controller1.Axis4.value())),velocityUnits::rpm);
FrontLeft.spin(directionType::fwd,((Controller1.Axis3.value() + Controller1.Axis1.value()+ Controller1.Axis4.value())),velocityUnits::rpm);
BackLeft.spin(directionType::fwd,((Controller1.Axis3.value() + Controller1.Axis1.value()- Controller1.Axis4.value())),velocityUnits::rpm);
}
}