I have been writing code for over 6 years now and i am completely confused at what is wrong with our auton. We have gotten to the point where we are unable to have an auton because, first of all NOTHING RUNS although the code is perfectly formatted and was checked by everyone on my team, or the immediately after auton when we go into driver as soon as you make any movement with the controller everything disconnects from our controller, and that continues to occur through out the match so you are unable to move at all. I have gotten to the point where I removed all my PID and Slew rate to prevent any sort of error. You can imagine how frustrating this is as Ive spent tons of hours writing extremely complex code but Im unable to run any of it due to all the errors that we’ve been viewing in our competitions. I’ve provided my code below from our last competition. If anyone can provide me with an answer as to why it runs auton the way it does and why it screws up when ever we have an auton thatd be great.
(please remember it only disconnects when there IS an auton)
The auton you will see is a short auton we wrote in the finals at the last competition we went to run into another team’s auton. It is the reason we lost the match for the auton didn’t run at all and afterwards during match play everything continued to disconnect and freeze up.
#pragma config(Sensor, in1, Lift, sensorPotentiometer)
#pragma config(Sensor, in2, Gyro, sensorGyro)
#pragma config(Sensor, in3, Auton, sensorAnalog)
#pragma config(Sensor, dgtl2, LeftDrive, sensorQuadEncoder)
#pragma config(Sensor, dgtl4, RightDrive, sensorQuadEncoder)
#pragma config(Sensor, dgtl7, Solenoid1, sensorDigitalOut)
#pragma config(Motor, port1, FL, tmotorVex393HighSpeed_HBridge, openLoop, driveRight)
#pragma config(Motor, port2, LBR, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port3, BL, tmotorVex393HighSpeed_MC29, openLoop, driveLeft)
#pragma config(Motor, port4, LBL, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port5, RBR, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port6, LTL, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port7, RBL, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port8, RTR, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port9, BR, tmotorVex393_MC29, openLoop, reversed, driveRight)
#pragma config(Motor, port10, FR, tmotorVex393HighSpeed_HBridge, openLoop, driveLeft)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#pragma platform(VEX2)
#pragma competitionControl(Competition)
#include "Vex_Competition_Includes.c"
#define JOY_DRIVE_V vexJSRightV
#define JOY_DRIVE_H vexJSRightH
#define JOY_THRESHOLD 10
void pre_auton() //RESETS A FEW SENSORS
{
bStopTasksBetweenModes = false;
SensorValue[LeftDrive] = 0;
SensorValue[RightDrive] = 0;
}
task Claw ()
{
while(true){
if (vexRT[Btn5U] == 1){
SensorValue(Solenoid1) = 0;
}
else if (vexRT[Btn5D] == 1){
SensorValue(Solenoid1) = 1;
}
}
}
task ArcadeDrive() //THE SINGLE LEFT JOYSTICK DRIVE FOR PRIMARY CONTROLLER
{
int ctl_v;
int ctl_h;
while( true )
{
ctl_v = vexRT JOY_DRIVE_V ];
ctl_h = vexRT JOY_DRIVE_H ];
if( (abs(ctl_v) <= JOY_THRESHOLD) && (abs(ctl_h) <= JOY_THRESHOLD) )
{
motor[FL] = 0;
motor[FR] = 0;
motor[BL] = 0;
motor[BR] = 0;
}
else
{
motor[FL] = (ctl_v + ctl_h) / 1.5;
motor[FR] = (ctl_v - ctl_h) / 1.5;
motor[BL] = (ctl_v + ctl_h) / 1.5;
motor[BR] = (ctl_v - ctl_h) / 1.5;
}
// don't overload cpu
wait1Msec( 10 );
}
}
task LiftSimple (){
while(1==1){
motor[LBR] = vexRT[Ch3]+6;
motor[LBL] = vexRT[Ch3]+6;
motor[RBR] = vexRT[Ch3]+6;
motor[LTL] = vexRT[Ch3]+6;;
motor[RBL] = vexRT[Ch3]+6;;
motor[RTR] = vexRT[Ch3]+6;;
}
}
void pre_auton()
{
bStopTasksBetweenModes = true;
SensorValue[LeftDrive] = 0;
SensorValue[RightDrive] = 0;
}
task autonomous()
{
motor[FR] = 127;
motor[BR] = 127;
motor[BL] = 127;
motor[FL] = 127;
wait1Msec(13000);
motor[FR] = 0;
motor[BR] = 0;
motor[BL] = 0;
motor[FL] = 0;
}
task usercontrol()
{
startTask( ArcadeDrive);
startTask(LiftSimple);
startTask(Claw);
while(1==1){
}
}