Hello, so for our final in our robotics class we had to get a working autonomous on our starstruck bot, and ive been having problems with the autonomous not running. Right now my autonomus is really small bc i dont know the times needed, but i need this to run so i can check it. Heres a copy of the code:
#pragma config(Motor, port1, rightliftindown, tmotorVex393_HBridge, openLoop, reversed)
#pragma config(Motor, port2, rightdrive, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, rightliftinup, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port4, leftliftoutup, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port5, leftliftinup, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, leftliftoutdown, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, rightliftoutdown, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port8, rightliftoutup, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port9, leftdrive, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port10, leftliftindown, tmotorVex393_HBridge, openLoop, reversed)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//
// Select Download method as “competition”
#pragma competitionControl(Competition)
//Main competition background code…do not modify!
#include “Vex_Competition_Includes.c”
/----------------------------------------------------------------------------------------------------
|* - Dual Joystick Control with 4 Motors - |
| ROBOTC on VEX 2.0 Cortex |
| |
| This program uses both the Left and the Right joysticks to run the robot using “tank control”. |
| |
| ROBOT CONFIGURATION |
| NOTES: |
| 1) Reversing both right-side motors (ports 2 and 3) in the “Motors and Sensors Setup” is |
| needed with the “VEX Tumbler” model, but may not be needed for all robot configurations. |
| 2) Ch1 is the X axis and Ch2 is the Y axis for the RIGHT joystick. |
| 3) Ch3 is the Y axis and Ch4 is the X axis for the LEFT joystick. |
*----------------------------------------------------------------------------------------------------/
//+++++++++++++++++++++++++++++++++++++++++++++| MAIN |+++++++++++++++++++++++++++++++++++++++++++++++
//////////////////////////////////////////////////////////////////////////////////////////
// User control task //
// this is a task to control the robot during the user control phase of the competition //
// //
//////////////////////////////////////////////////////////////////////////////////////////
task usercontrol()
{
while(1 == 1)
{
//Right side of the robot is controlled by the right joystick, Y-axis
motor[rightdrive] = vexRT[Ch2];
//Left side of the robot is controlled by the left joystick, Y-axis
motor[leftdrive] = vexRT[Ch3];
//moving the arm up (all together)
if(vexRT[Btn6U] == 1)
//moving the arm up (all together)
{
motor[leftliftoutup] = 127;
motor[leftliftoutdown] = 127;
motor[leftliftinup] = -127; //move up
motor[leftliftindown] = -127;
motor[rightliftoutup] = -127;
motor[rightliftoutdown] = -127;
motor[rightliftinup] = 127;
motor[rightliftindown] = 127;
}
else if(vexRT[Btn6D] == 1)
//moving the arm down (all together)
{
motor[leftliftoutup] = -127;
motor[leftliftoutdown] = -127;
motor[leftliftinup] = 127; //move down
motor[leftliftindown] = 127;
motor[rightliftoutup] = 127;
motor[rightliftoutdown] = 127;
motor[rightliftinup] = -127;
motor[rightliftindown] = -127;
}
else {
//stopping the arm down (all together)
motor[leftliftoutup] = 0;
motor[leftliftoutdown] = 0;
motor[leftliftinup] = 0;
motor[leftliftindown] = 0;
motor[rightliftoutup] = 0;
motor[rightliftoutdown] = 0;
motor[rightliftinup] = 0;
motor[rightliftindown] = 0;
}
}
}
//end of task main
///////////////////////////////////////////////////////////////////////////////////////////
// Below is the code for the pre autonomous portion, qhich describs the motor shortcuts //
// shown in the autonomous portion of the competition //
///////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
// Autonomus Control Task //
// This is a task to control the robot during the autonomous phase of the comnpetition //
// as well as autonomous skills competition //
/////////////////////////////////////////////////////////////////////////////////////////
void pre_auton()
{
bStopTasksBetweenModes = true;
}
task autonomous()
{
//lift arms
//CAN BE CHANGEd For EXTrA MoVEMENT NoT SUrE HoW FAr IT WIll Go
wait1Msec(2000);
motor[leftliftoutup] = 127;
motor[leftliftoutdown] = 127;
motor[leftliftinup] = -127; //move up
motor[leftliftindown] = -127;
motor[rightliftoutup] = -127;
motor[rightliftoutdown] = -127;
motor[rightliftinup] = 127;
motor[rightliftindown] = 127;
wait1Msec(900);
motor[leftliftoutup] = 0;
motor[leftliftoutdown] = 0;
motor[leftliftinup] = 0; //move up
motor[leftliftindown] = 0;
motor[rightliftoutup] = 0;
motor[rightliftoutdown] = 0;
motor[rightliftinup] = 0;
motor[rightliftindown] = 0;
//drive forward-run drive motors for 1 sec
motor[leftdrive] = 127;
motor[rightdrive] = 127;
wait1Msec(1000);
motor[leftdrive] = 0;
motor[rightdrive] = 0;
wait1Msec(500);
}