View unanswered posts | View active topics It is currently Thu Jul 24, 2014 4:03 pm






Reply to topic  [ 5 posts ] 
**FATAL** Compiler error but it works anyway... 
Author Message
Rookie

Joined: Thu May 01, 2008 3:56 am
Posts: 3
Location: Belgium
Post **FATAL** Compiler error but it works anyway...
I got the following fatal error
Quote:
**FATAL**:Compiler error. Failed to release temporary registers 1(1) to 2. Pass 'Assign Addresses'

but the robot is working fine.
Here is my code:
Code:

const tMotor right = (tMotor) motorA;
const tMotor left = (tMotor) motorC;
const TSynchedMotors rightLeft = synchAC;
const TSynchedMotors leftRight = synchCA;
void Move(int motorSteps, int steering, int speed, bool doLog);
void BackTrace(int steps);

/*
 * Semaphore (Lock) mechanism for task management
 */
#define Lock(sem) int sem
#define Acquire(sem) while(sem){}; sem = 1
#define Release(sem) sem = 0
Lock(motorLock);

/*
 * logs for storing motor movements
 * implemented as a stack of size LOG_SIZE
 */
#define LOG_SIZE 10
int speedLog[LOG_SIZE];
int steeringLog[LOG_SIZE];
int stepLog[LOG_SIZE];
int currentLogIndex;
int numberOfLogEntries;
void LogData(int speed, int steering, int motorSteps);
void ClearLog();

typedef enum
{
   stateInitializing,
   stateSearching,      // exploring floor to find a black line
     stateIdentifying,      // is it really a line?
     stateFollowing,      // following a blackline
     stateShuttingDown
} TStates;

TStates currentState = stateInitializing;

task main()
{
   currentState = stateInitializing;
     // Continuous loop for state machine
     while (true)
     {
       switch (currentState)
       {
       case stateInitializing:
          currentLogIndex = 0;
         numberOfLogEntries = 0;
         ClearLog();
         Release(motorLock);
         currentState = stateSearching;
         break;

       case stateSearching:
         Move(360,0,50,true);
         Move(360,0,-50,true);
         BackTrace(2);
         currentState = stateShuttingDown;
         break;

       case stateIdentifying:
         /* Insert program specific code here */
         break;

       case stateFollowing:
         /* Insert program specific code here */
         break;

       case stateShuttingDown:
         StopAllTasks();
         break;
       }
     }
}

void LogData(int speed, int steering, int motorSteps)
{
   if (++currentLogIndex == LOG_SIZE) {currentLogIndex = 0;}
   speedLog[currentLogIndex] = speed;
   steeringLog[currentLogIndex] = steering;
   stepLog[currentLogIndex] = motorSteps;
   if (numberOfLogEntries < LOG_SIZE) {numberOfLogEntries++;}
}

void ClearLog()
{
   for (int i = 0; i < LOG_SIZE; i++)
   {
      speedLog[i] = 0;
      steeringLog[i] = 0;
      stepLog[i] =0;
   }
}

void Move(int motorSteps, int steering, int speed, bool doLog)
{
   if(steering >= 0)       // right turn
   {
      Acquire(motorLock);
      nSyncedMotors = leftRight;
      nSyncedTurnRatio = (100 - (2*abs(steering)));
      nMotorEncoderTarget[left]  = motorSteps;
      motor[left] = speed;
      while(nMotorRunState[left] != runStateIdle) {}
      Release(motorLock);
   }
   else      // left turn
   {
      Acquire(motorLock);
      nSyncedMotors = rightLeft;
      nSyncedTurnRatio = (100 - (2*abs(steering)));
      nMotorEncoderTarget[right]  = motorSteps;
      motor[right] = speed;
      while(nMotorRunState[right] != runStateIdle) {}
      Release(motorLock);
   }
   if (doLog) {LogData(speed, steering, motorSteps);}
   return;
}

void BackTrace(int steps)
{
   if (steps > numberOfLogEntries) {steps = numberOfLogEntries;}
   for (int i = 1; i <= steps; i++)
   {
      Move(stepLog[currentLogIndex],-steeringLog[currentLogIndex],-speedLog[currentLogIndex],false);
      if (--currentLogIndex < 0) {currentLogIndex = LOG_SIZE -1;}
      numberOfLogEntries--;
   }
}

The error concerns line 129:
Quote:
Move(stepLog[currentLogIndex],-steeringLog[currentLogIndex],-speedLog[currentLogIndex],false);


Something to worry about?


Thu May 01, 2008 4:06 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Jan 31, 2007 3:39 am
Posts: 299
Location: San Diego, California. USA
Post 
Hmm, I compiled your code using V1.30 and I don't get any error messages, what version are you currently running on?

_________________
Mmmm Legos B-)

My Robot Projects:
http://www.freewebs.com/robotprojects/


Thu May 01, 2008 8:09 pm
Profile WWW
Rookie

Joined: Thu May 01, 2008 3:56 am
Posts: 3
Location: Belgium
Post 
The lastest download from the robotc.net site: V1.10 (under windows XP-SP2 running in a VirtualBox on opensuse 10.3.)

What is the meaning of this error message?


Fri May 02, 2008 2:31 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Jan 31, 2007 3:39 am
Posts: 299
Location: San Diego, California. USA
Post 
Allot of bugs have been fixed since v1.10, the unofficial beta releases have gone up to v1.30, I suggest downloading and installing v1.30.

Version v1.30 download
http://www.robotc.net/lego/downloads/RO ... BETA_2.exe

I am running v1.30, any your code compiled just fine, I believe it is a compiler bug that has been recently fixed B-).

Good luck, and fell free to ask any more questions B-)
Scott

_________________
Mmmm Legos B-)

My Robot Projects:
http://www.freewebs.com/robotprojects/


Fri May 02, 2008 5:48 am
Profile WWW
Rookie

Joined: Thu May 01, 2008 3:56 am
Posts: 3
Location: Belgium
Post 
Worked, indeed. Thanks.

V1.30.beta2 is causing troubles with my BT but V1.30 is ok.


Fri May 02, 2008 9:17 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 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.