View unanswered posts | View active topics It is currently Fri Dec 19, 2014 7:31 pm






Reply to topic  [ 14 posts ] 
**Error**:array index '6' is outside of array bound '0..5' 
Author Message
Rookie

Joined: Fri Nov 14, 2008 10:15 pm
Posts: 6
Post **Error**:array index '6' is outside of array bound '0..5'
**Error**:Compile time constant array index '6' is outside of array bound '0..5'

I been trying to figure out this error for hours and I can't fix it. I'm trying to use four FTC motors on my team's robot. The compiler accepts the first three FTC motors, but when I try to use the fourth one this error comes up. Our team really needs to use four motors so is there any body out there that cane help me!!! :breakcomputer:


Fri Nov 14, 2008 10:36 pm
Profile
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Post Re: **Error**:array index '6' is outside of array bound '0..5'
Please post the #pragma statements from the top of your program.

_________________
Jeff McBride
Benson Robotics Club


Fri Nov 14, 2008 11:33 pm
Profile
Rookie

Joined: Sat Apr 19, 2008 11:51 am
Posts: 43
Post Re: **Error**:array index '6' is outside of array bound '0..5'
if you have an array like
int var_array[6]
the count starts with zero:
0,1,2,3,4,5 are just your 6 indices.

if you try to access an index [6] this will cause this error message: the highest legal value is 5!


Sat Nov 15, 2008 7:02 am
Profile
Rookie

Joined: Fri Nov 14, 2008 10:15 pm
Posts: 6
Post Re: **Error**:array index '6' is outside of array bound '0..5'
#pragma config(Hubs, S1, HTMotor, HTMotor, none, none)
#pragma config(Motor, motorD, , tmotorNormal, openLoop, )
#pragma config(Motor, motorE, , tmotorNormal, openLoop, )
#pragma config(Motor, mtr_S1_C2_1, , tmotorNormal, openLoop, )
#pragma config(Motor, mtr_S1_C2_2, , tmotorNormal, openLoop, )
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//


Sat Nov 15, 2008 4:08 pm
Profile
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Post Re: **Error**:array index '6' is outside of array bound '0..5'
Hmm. This is the way that the indexes into the motor[] array are defined in RobotCIntrinsics.h:

Code:
typedef enum
{
  motorA               = 0,
  motorB               = 1,
  motorC               = 2,
   //
   // HiTechnic Motor Controllers.
   //    - Each controller supports two motors
   //    = Up to four controllers per sensor port.
   //
   //motorD               =  3,
  //motorE,

   mtr_S1_C1_1     =  3,
  mtr_S1_C1_2,
    mtr_S1_C2_1,
  mtr_S1_C2_2,
...


That means that mtr_S1_C2_2 should have the value of 6.

The motor array is defined to be size kNumOfTotalMotors which is defined as follows:

Code:
#define kNumbOfRealMotors             ((ubyte) 3)
...
#define kNumbOfVirtualMotors          ((ubyte) (4 * 4 * 2))
...
#define kNumbOfTotalMotors            ((ubyte) (kNumbOfRealMotors + kNumbOfVirtualMotors))
// 'kNumbOfTotalMotors' must be <= 8 to fit in lower 6 bits of mask of 1-sbyte


That means that the array should be 35 elements long. However, the weird comment at the end of that block of code worries me.

I think that this is something that Dick is going to have to look into. I'll email him about it.

_________________
Jeff McBride
Benson Robotics Club


Sat Nov 15, 2008 6:05 pm
Profile
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Post Re: **Error**:array index '6' is outside of array bound '0..5'
Just a thought... Do you actually have two Motor Controllers chained together on your robot? The kit only comes with one so you would have had to order a second one.

_________________
Jeff McBride
Benson Robotics Club


Sat Nov 15, 2008 6:10 pm
Profile
Rookie

Joined: Fri Nov 14, 2008 10:15 pm
Posts: 6
Post Re: **Error**:array index '6' is outside of array bound '0..5'
I am just preprograming everything because we are behind schedual, but we are ordering the second motor controller.

Thanks for helping me!!! :D


Sat Nov 15, 2008 6:30 pm
Profile
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Post Re: **Error**:array index '6' is outside of array bound '0..5'
Your problem may be due to not actually having the second motor controller installed. How are you planning to use the four motors? Do you have a four wheel robot with two on each side and one motor on each wheel or are you doing something more complicated? If you have a one motor per wheel and two wheels per side you can get away with using a single motor controller by hooking the two motors on the left side together into one motor port and the two motors on the right side together into the other motor port.

_________________
Jeff McBride
Benson Robotics Club


Sat Nov 15, 2008 9:21 pm
Profile
Rookie

Joined: Fri Nov 14, 2008 10:15 pm
Posts: 6
Post Re: **Error**:array index '6' is outside of array bound '0..5'
We are using two motors for the drive train (one motor per rear wheel), and two motors for the bucket lift.


Sat Nov 15, 2008 10:02 pm
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 615
Post Re: **Error**:array index '6' is outside of array bound '0..5'
Jeff McBride wrote:
<<snip>>...
#define kNumbOfTotalMotors ((ubyte) (kNumbOfRealMotors + kNumbOfVirtualMotors))
// 'kNumbOfTotalMotors' must be <= 8 to fit in lower 6 bits of mask of 1-sbyte
[/code]

That means that the array should be 35 elements long. However, the weird comment at the end of that block of code worries me.

I think that this is something that Dick is going to have to look into. I'll email him about it.

This -- "must be <= 8 to fit in lower 6 bits of mask of 1-sbyte" -- is a legacy comment related to really old first generation implementation of ROBOTC on the LEGO RCX. With that system, rather than specifying a single motor you specified a bit map representing the three possible motors on the RCX and motor commands could be made to apply to multiple motors. This is not longer accepted. I have cleaned up the comment for the next release of ROBOTC.


Sun Nov 16, 2008 10:33 am
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 615
Post Re: **Error**:array index '6' is outside of array bound '0..5'
Please make sure you have downloaded / upgraded to the latest version (1.46) or ROBOTC. The link is one of the stickies on this forum. I think the problems you are/were having relates to an earlier release.

Are you now still having the array out of range problem? I cannot duplicate it with version 1.46.


Sun Nov 16, 2008 11:06 am
Profile
Rookie

Joined: Fri Nov 14, 2008 10:15 pm
Posts: 6
Post Re: **Error**:array index '6' is outside of array bound '0..5'
The ROBOTC program we are using is the Single licence Version 1.40 CD found in the robot kit we ordered. We are not using the RCX intelligent brick, but we are using the NXT Intelligent brick. So, are you telling me that the CD FIRST gave us in the robot kit is out of date!?

Here is the coding that I'm try to compile:

#pragma config(Hubs, S1, HTMotor, HTMotor, none, none)
#pragma config(Motor, motorD, , tmotorNormal, openLoop, )
#pragma config(Motor, motorE, , tmotorNormal, openLoop, )
#pragma config(Motor, mtr_S1_C2_1, , tmotorNormal, openLoop, )
#pragma config(Motor, mtr_S1_C2_2, , tmotorNormal, openLoop, )
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "JoystickDriver.c"

task main()
{
while (true)
{
getJoystickSettings(joystick);
motor[motorD] = joystick.joy1_y1;
motor[motorE] = joystick.joy1_y2;
if (joy1Btn(1) != 0)
{
motor[mtr_S1_C2_1] = 100;
motor[mtr_S1_C2_2] = -100;
}
if (joy1Btn(2) != 0)
{
motor[mtr_S1_C2_1] = -100;
motor[mtr_S1_C2_2] = 100;
}
}
}


Sun Nov 16, 2008 3:39 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3297
Location: Rotterdam, The Netherlands
Post Re: **Error**:array index '6' is outside of array bound '0..5'
No, he is saying that an update has been published since that CD was pressed and sent out to people. You can't possibly think that an update is going to magically find its way onto your CD after it's made. Updates happen, be grateful they do.

The thread Dick is referring to can be found here: viewtopic.php?f=33&t=826

Good luck.

Regards,
Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Nov 16, 2008 5:34 pm
Profile WWW
Rookie

Joined: Fri Nov 14, 2008 10:15 pm
Posts: 6
Post Re: **Error**:array index '6' is outside of array bound '0..5'
Ok, I uninstalled the version 1.40 Single Licence ROBOTC CD, and I installed the ROBOTC version 1.46 and the error is gone now when I compiled it.

Thanks for helping me out a lot!!! :bigthumb: :D :lol: :D :) :o :programmer:


Sun Nov 16, 2008 9:22 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 14 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.