ROBOTC.net forums
http://www.robotc.net/forums/

Robotc error
http://www.robotc.net/forums/viewtopic.php?f=52&t=4258
Page 1 of 1

Author:  JAF [ Thu Feb 16, 2012 1:07 pm ]
Post subject:  Robotc error

I was programming a robot in my pre-engineering class and this error popped up. I haven't seen it before and I need some help debugging it.

**Error**:Compile time constant array index '64' is outside of array bound '0..43'

Author:  mightor [ Thu Feb 16, 2012 1:14 pm ]
Post subject:  Re: Robotc error

You may have a mistake in your code somewhere, where you are accessing an array with an index that is larger than the actual size of the array. If we could see your code it would probably make it easier to pinpoint the issue.

- Xander

Author:  JAF [ Thu Feb 16, 2012 1:37 pm ]
Post subject:  Re: Robotc error

Code:
task main()
{  while (vexRT[Btn7D]==0)
  {
  }

  ClearTimer (T1);
  while (time1[T1]<60000)
  {
    startMotor (rightMotor, 65);
    startMotor (leftMotor, 65);
    untilSonarLessThan(sensorSONAR_inch, 0.0625);
    startMotor (rightElbow, -65);
    startMotor (leftElbow, -65);
    startMotor (wrist, -35);
    wait (1);
    startMotor (leftMotor, -65
  }


  while (time1[T1]>60000)
  {
    motor(rightMotor) = vexRT (Ch2);
    motor(leftMotor) = vexRT (Ch3);
    if(vexRT [Btn6D] == 1)
    {
      motor [rightElbow] = 65;
    }
    else if(vexRT [Btn6U] == 1)
    {
      motor [rightElbow] = -65;
    }
    else
    {
      motor [rightElbow] = 0;
    }
    if(vexRT [Btn5D] == 1)
    {
      motor [leftElbow] = 65;
    }
    else if(vexRT [Btn5U] == 1)
    {
      motor [leftElbow] = -65;
    }
    else
    {
      motor [leftElbow] = 0;
    }
   ** if (vexRT[btn8U] ==1) **
    {
      motor [wrist] =60;
    }
    else if(vexRT [btn8D] ==1)
    {
      motor [wrist] =-60;
    }
    else
    {
      motor [wrist] =0;
    }
  }
}

** error

Author:  mightor [ Thu Feb 16, 2012 2:13 pm ]
Post subject:  Re: Robotc error

Please attach the complete program so I can yang it through the compiler myself without needing to make pragmas and stuff.

- Xander

Author:  JAF [ Thu Feb 16, 2012 2:17 pm ]
Post subject:  Re: Robotc error

mightor wrote:
Please attach the complete program so I can yang it through the compiler myself without needing to make pragmas and stuff.

- Xander

I copy and pasted the program

Author:  mightor [ Thu Feb 16, 2012 2:24 pm ]
Post subject:  Re: Robotc error

Where are the pragmas? This is not a complete program.

- Xander

Author:  magicode [ Thu Feb 16, 2012 5:15 pm ]
Post subject:  Re: Robotc error

This program wouldn't even compile even if you did have the proper include files:
Code:
  wait (1);
  startMotor (leftMotor, -65
}

Author:  mightor [ Fri Feb 17, 2012 3:59 am ]
Post subject:  Re: Robotc error

I wasn't even going to try and parse that thing in my head before I had the complete thing. That's what compilers are for :)

- Xander

Author:  JAF [ Fri Feb 17, 2012 1:16 pm ]
Post subject:  Re: Robotc error

mightor wrote:
I wasn't even going to try and parse that thing in my head before I had the complete thing. That's what compilers are for :)

- Xander


#pragma config(Sensor, in1, lineTrackerLeft, sensorLineFollower)
#pragma config(Sensor, in2, lineTrackerCenter, sensorLineFollower)
#pragma config(Sensor, in3, lineTrackerRight, sensorLineFollower)
#pragma config(Sensor, dgtl1, Sonar, sensorSONAR_inch)
#pragma config(Sensor, dgtl3, limitSwitch, sensorTouch)
#pragma config(Motor, port2, rightMotor, tmotorNormal, openLoop, reversed)
#pragma config(Motor, port3, leftMotor, tmotorNormal, openLoop)
#pragma config(Motor, port4, rightElbow, tmotorNormal, openLoop, reversed)
#pragma config(Motor, port5, leftElbow, tmotorNormal, openLoop)
#pragma config(Motor, port6, wrist, tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{ while (vexRT[Btn7D]==0)
{
}

ClearTimer (T1);
int threshold;
threshold= 3013;
while (time1 [T1]<60000)
{
if (SensorValue (lineTrackerLeft) < threshold)
{
motor [leftMotor] = 0;
motor [rightMotor] = 65;
}
if (SensorValue (lineTrackerCenter) < threshold)
{
motor [leftMotor] = 65;
motor [rightMotor] =65;
}
if (SensorValue (lineTrackerRight) < threshold)
{
motor [leftMotor] = 65;
motor [rightMotor] = 0;
}
}
while (time1[T1]<60000)
{
startMotor (wrist, 60);
wait (.01);
startMotor (rightMotor, -65);
startMotor (leftMotor, -65);
wait (.5);
startMotor (rightElbow, 50);
startMotor (leftElbow, 50);
startMotor (wrist, -50);
untilButtonPress (limitSwitch);
startMotor (leftMotor, -65);
startMotor (rightMotor, 65);
wait (5);
startMotor (rightMotor, 65);
startMotor (leftMotor, 65);
untilSonarLessThan(0.0625);
startMotor (rightElbow, -65);
startMotor (leftElbow, -65);
startMotor (wrist, -35);
wait (1);
stopMotor (rightElbow);
stopMotor (leftElbow);
stopMotor (wrist);
startMotor (leftMotor, -65);
startMotor (rightMotor, 65);
wait(5);
stopMotor (leftMotor);
stopMotor (rightMotor);
wait(.01);
startMotor (rightMotor, 65);
startMotor (leftMotor, 65);
untilSonarLessThan (4);
startMotor (rightElbow, 30);
startMotor (leftElbow, 30);
startMotor (wrist, -30);
wait(.5);
stopMotor (rightElbow);
stopMotor (leftElbow);
startMotor (wrist, 50);
wait(.5);

}


while (time1[T1]>60000)
{
motor(rightMotor) = vexRT (Ch2);
motor(leftMotor) = vexRT (Ch3);
if(vexRT [Btn6D] == 1)
{
motor [rightElbow] = 65;
}
else if(vexRT [Btn6U] == 1)
{
motor [rightElbow] = -65;
}
else
{
motor [rightElbow] = 0;
}
if(vexRT [Btn5D] == 1)
{
motor [leftElbow] = 65;
}
else if(vexRT [Btn5U] == 1)
{
motor [leftElbow] = -65;
}
else
{
motor [leftElbow] = 0;
}
**** if (vexRT[btn8U] ==1)
{
motor [wrist] =60;
}
else if(vexRT [btn8D] ==1)
{
motor [wrist] =-60;
}
else
{
motor [wrist] =0;
}
}
}

Author:  mightor [ Fri Feb 17, 2012 1:32 pm ]
Post subject:  Re: Robotc error

Change btn8U to Btn8U and btn8D Btn8D and it'll compile fine.

Next you paste code, could you put inside code tags like this:
Code:
[code]your code goes here[/code]

That makes it a lot more readable :)

- Xander

Author:  JAF [ Fri Feb 17, 2012 1:35 pm ]
Post subject:  Re: Robotc error

mightor wrote:
Change btn8U to Btn8U and btn8D Btn8D and it'll compile fine.

Next you paste code, could you put inside code tags like this:
Code:
[code]your code goes here[/code]

That makes it a lot more readable :)

- Xander


Yes. Thanks for the help!

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/