Programming Holonomic

We have our driver control and nothing is working. The ports are all in the right place.

void usercontrol(void) {
while (1) {

                                //Sideways//

FrontLeft.spin(directionType::fwd, Controller1.Axis4.value(),velocityUnits::pct);
FrontRight.spin(directionType::rev, Controller1.Axis4.value(),velocityUnits::pct);
BackLeft.spin(directionType::rev, Controller1.Axis4.value(),velocityUnits::pct);
BackRight.spin(directionType::fwd, Controller1.Axis4.value(),velocityUnits::pct);

                                //Forwards///fvv    

BackLeft.spin(directionType::fwd, Controller1.Axis2.value(),velocityUnits::pct);
FrontLeft.spin(directionType::fwd, Controller1.Axis2.value(),velocityUnits::pct);
FrontRight.spin(directionType::fwd, Controller1.Axis2.value(),velocityUnits::pct);
BackRight.spin(directionType::fwd, Controller1.Axis2.value(),velocityUnits::pct);
//Open Scissor//
if (Controller1.ButtonL1.pressing()){
BackLeft.spin(directionType::fwd);
FrontLeft.spin(directionType::rev);
BackRight.spin(directionType::fwd);
FrontRight.spin(directionType::rev);
}
else if (Controller1.ButtonL2.pressing()){
BackLeft.spin(directionType::rev);
FrontLeft.spin(directionType::fwd);
BackRight.spin(directionType::rev);
FrontRight.spin(directionType::fwd);
}
else {
BackLeft.stop();
FrontLeft.stop();
BackRight.stop();
FrontRight.stop();

                                //TractionGripper//

if (Controller1.ButtonR1.pressing()){
LeftGripper.spin(directionType::fwd);
RightGripper.spin(directionType::fwd);
}
else if (Controller1.ButtonR2.pressing()){
LeftGripper.spin(directionType::rev);
RightGripper.spin(directionType::rev);
}
else{
LeftGripper.stop();
RightGripper.stop();
}

// ........................................................................
// Insert user code here. This is where you use the joystick values to 
// update your motors, etc.
// ........................................................................

vex::task::sleep(20); //Sleep the task for a short amount of time to prevent wasted resources. 
  }
}

}

//
// Main will set up the competition functions and callbacks.

int main() {

//Run the pre-autonomous function. 
pre_auton();

//Set up callbacks for autonomous and driver control periods.
Competition.autonomous(autonomous);
Competition.drivercontrol(usercontrol);

//Prevent main from exiting with an infinite loop.                        
while(1) {
  vex::task::sleep(100);//Sleep the task for a short amount of time to prevent wasted resources.
}    

}

You’re giving conflicting commands to the motors. You’re also missing an axis. Holonomic control takes three joystick axes: translate forward/back, translate left/right, and rotate.

How do i fix the conflicting commands in the code?
I am not too sure how i am suppose to alter it.

The conflict is that you have two calls to spin for each drive motor instead of just one.

The code needs to make a decision on when to run Sideways code verses Forward/Reverse code. Something like you did with TractionGripper.

No, it is perfectly possible (and desirable) to translate sideways while also translating forwards. The code needs to come up with a single output value for each motor from the three relevant input values.

I don’t disagree with that, and I hadn’t planned on leaving xium hanging. But sometimes you need to walk before you run. I don’t really like the V +/- H +/- Y approach since it clips. I much prefer an approach that uses the full range of the stick and that gets a bit more involved.

@xium I posted and example arcade calculations for skid steer
Pros, code issue(Op control).

I suppose it wouldn’t be too difficult to add a third joy direction. The simple approach would be to do the mV and mH calculations for x-drive and then add in the yaw calc on top of that (basically the same as the equations in the link).

1 Like