Okay kids, i like to think im an alright programmer but i have a noob question. I am beginning to write our autonomous and I want it to drive forward. When i run it the robot moves forward half an inch. When i run only the function “blast” the left side runs but not the right side. Im looking for errors and i think another set of eyes might help. Thanks.
#pragma config(Sensor, in1, liftleft, sensorPotentiometer)
#pragma config(Sensor, in2, liftright, sensorPotentiometer)
#pragma config(Sensor, dgtl1, rightdrive, sensorQuadEncoder)
#pragma config(Sensor, dgtl3, leftdrive, sensorQuadEncoder)
#pragma config(Motor, port1, rd, tmotorVex393HighSpeed_HBridge, openLoop)
#pragma config(Motor, port2, leftd, tmotorVex393HighSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port3, leftc, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port4, liftl, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port5, mobileleft, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port6, mobileright, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, liftr, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port8, rightc, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port9, rightd, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port10, ld, tmotorVex393HighSpeed_HBridge, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
/*---------------------------------------------------------------------------*/
/* */
/* Description: Competition template for VEX EDR */
/* */
/*---------------------------------------------------------------------------*/
// This code is for the VEX cortex platform
#pragma platform(VEX2)
// Select Download method as "competition"
#pragma competitionControl(Competition)
//Main competition background code...do not modify!
#include "Vex_Competition_Includes.c"
/*---------------------------------------------------------------------------*/
/* Pre-Autonomous Functions */
/* */
/* You may want to perform some actions before the competition starts. */
/* Do them in the following function. You must return from this function */
/* or the autonomous and usercontrol tasks will not be started. This */
/* function is only called once after the cortex has been powered on and */
/* not every time that the robot is disabled. */
/*---------------------------------------------------------------------------*/
//set drive motors equal
float ndistance = 0;
//drive strait
void blast(){
if(SensorValue[leftdrive] < SensorValue[rightdrive]){
motor[ld] = 127;
motor[rd] = 100;
}
else if(SensorValue[leftdrive] > SensorValue[rightdrive]){
motor[ld] = 100;
motor[rd] = 100;
}
else{
motor[ld] = 127;
motor[rd] = 127;
}
}
//same in reverse
void blastbackwards(){
if( abs(SensorValue[leftdrive]) < abs(SensorValue[rightdrive])){
motor[leftd] = -127;
motor[rightd] = -100;
}
else if(abs(SensorValue[leftdrive]) > abs(SensorValue[rightdrive])){
motor[leftd] = -100;
motor[rightd] = -100;
}
else{
motor[leftd] = -127;
motor[rightd] = -127;
}
}
//drive strait for set distance
void gottablast(float distance){
ndistance = (distance/12.566) * 540.540;//converts inches to degrees
while(SensorValue[leftdrive] < ndistance){
blast();
}
motor[leftd] = 0;
motor[rightd] = 0;
}
//same for revearse
void gottablastbackwards(float distance){
ndistance = (distance/12.566) * 540.540;//converts inches to degrees
while(abs(SensorValue[leftdrive]) < ndistance){
blastbackwards();
}
motor[leftd] = 0;
motor[rightd] = 0;
}
void turnright(float degrees){
while(SensorValue[leftdrive] < degrees){
motor[leftd] = 127;
motor[rightd] = -127;
}
motor[leftd] = 0;
motor[rightd] = 0;
}
void turnleft(float degrees){
while(abs(SensorValue[leftdrive]) < degrees){
motor[leftd] = -127;
motor[rightd] = 127;
}
motor[leftd] = 0;
motor[rightd] = 0;
}
void lift(float time){
motor[liftl] = 127;
motor[liftr] = 127;
wait1Msec(time);
motor[liftl] = 0;
motor[liftr] = 0;
}
void lower(float time){
motor[liftl] = -127;
motor[liftr] = -127;
wait1Msec(time);
motor[liftl] = 0;
motor[liftr] = 0;
}
void mogo(float time){
motor[mobileleft] = 127;
motor[mobileright] = 127;
wait1Msec(time);
motor[mobileleft] = 0;
motor[mobileright] = 0;
}
void mogodown(float time){
motor[mobileleft] = -127;
motor[mobileright] = -127;
wait1Msec(time);
motor[mobileleft] = 0;
motor[mobileright] = 0;
}
void sensorReset(){
SensorValue[leftdrive] = 0;
SensorValue[rightdrive] = 0;
}
void pre_auton()
{
// Set bStopTasksBetweenModes to false if you want to keep user created tasks
// running between Autonomous and Driver controlled modes. You will need to
// manage all user created tasks if set to false.
bStopTasksBetweenModes = true;
// Set bDisplayCompetitionStatusOnLcd to false if you don't want the LCD
// used by the competition include file, for example, you might want
// to display your team name on the LCD in this function.
// bDisplayCompetitionStatusOnLcd = false;
// All activities that occur before the competition starts
// Example: clearing encoders, setting servo positions, ...
}
/*---------------------------------------------------------------------------*/
/* */
/* Autonomous Task */
/* */
/* This task is used to control your robot during the autonomous phase of */
/* a VEX Competition. */
/* */
/* You must modify the code to add your own robot specific commands here. */
/*---------------------------------------------------------------------------*/
task autonomous()
{
motor[leftc] = motor[leftd];
motor[rightc]= motor[rightd];
motor[rd] = motor[rightd];
motor[ld] = motor[leftd];
sensorReset();
lift(500);
lower(700);
wait1Msec(100);
lift(400);
wait1Msec(100);
gottablast(30);
}