If you send differing commands to a motor in rapid succession, it will do strange things. Make sure that the drive motors are only being controlled by one driver at a time, or come up with a system to share control. One way to ensure a single driver at a time could be allowing either driver to take control while neither are sending drive base commands, but then locking the other driver out until the first driver has released the joysticks.
I see one issue, and you already solved it in one instance.
if(partnerCh2 < threshold)
Since this is used, any value below the threshold (20) wouldn’t be counted, which will be a problem when attempting to drive backwards (i.e. -127). This can be fixed by simply adding an absolute value around partnerCh2 and similar entries, like you did in the very first if loop.
How about this? Also make sure you paste the code in the competition template as well if you’re competing.
(Sorry for bad syntax vexforum doesn’t support pressing tab)
I would recommend against that. You’re giving both drivers control of the motors at the same time. Not only that, you’re including in that combination what should be dead zones based on your threshold. For example, let’s say the partner joystick sits at -15 on channel 2 and +15 on channel 3. When both people do nothing, no problem. But when the main controller tries to drive, the robot will always tend to veer in the same direction, which will be awkward to control and will cap your maximum straight-line speed. The originally provided method, outside of forgetting abs() in some spots, is far superior for what it’s trying to do.
#pragma config(Motor, port1, RightFrontDrive, tmotorVex393HighSpeed_HBridge, openLoop, reversed, driveRight)
#pragma config(Motor, port2, RightMiddleDrive, tmotorVex393HighSpeed_MC29, openLoop, reversed, driveRight)
#pragma config(Motor, port3, RightBackDrive, tmotorVex393HighSpeed_MC29, openLoop, reversed, driveRight)
#pragma config(Motor, port8, LeftFrontDrive, tmotorVex393HighSpeed_MC29, openLoop, driveRight)
#pragma config(Motor, port9, LeftMiddleDrive, tmotorVex393HighSpeed_MC29, openLoop, driveRight)
#pragma config(Motor, port10, LeftBackDrive, tmotorVex393HighSpeed_HBridge, openLoop, driveRight)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main(){
int threshold = 20;
int mastercontrol = 1;//This would be used to determine when the master controller is being ran
//Create Chan2 and Chan3, and set the initial value to 0 to have a value in case joystick wasn't connected.
int Chan2 = 0;
int Chan3 = 0;
while(1==1){
//This would be used to allow the master controller to override the slave controller when the
//master controller is outside of the threshold
if(abs(vexRT[Ch2])<threshold &&abs(vexRT[Ch3])<threshold){
mastercontrol = 0;
}
else{
mastercontrol = 1;
}
//If the master controller joystick values are above the threshold, override slave
if(mastercontrol == 1){
//Apply Chan3 to the master channel 3
Chan3 = vexRT[Ch3];
//Set Chan3 to 0 if channel 3 is within threshold
if(abs(vexRT[Ch3])<threshold) Chan3 = 0;
//Apply Chan2 to the master channel 2
Chan2 = vexRT[Ch2];
//Set Chan2 to 0 if channel 3 is within threshold
if(abs(vexRT[Ch2])<threshold) Chan2 = 0;
}
//Enable the slave controller
else{
//Apply Chan3 to the slave channel 3
Chan3 = vexRT[Ch3Xmtr2];
//Set Chan3 to 0 if channel 3 is within threshold
if(abs(vexRT[Ch3Xmtr2])<threshold) Chan3 = 0;
//Apply Chan2 to the slave channel 2
Chan2 = vexRT[Ch2Xmtr2];
//Set Chan2 to 0 if channel 3 is within threshold
if(abs(vexRT[Ch2Xmtr2])<threshold) Chan2 = 0;
}
motor[LeftFrontDrive] = Chan3 ;
motor[LeftMiddleDrive] = Chan3 ;
motor[LeftBackDrive] = Chan3 ;
motor[RightFrontDrive] = Chan2 ;
motor[RightMiddleDrive] = Chan2 ;
motor[RightBackDrive] = Chan2 ;
}//End of While Loop
}// End of Task