View unanswered posts | View active topics It is currently Mon Nov 24, 2014 11:20 am






Reply to topic  [ 7 posts ] 
Severe error in abs() function 
Author Message
Rookie

Joined: Fri Apr 13, 2007 7:48 pm
Posts: 4
Post Severe error in abs() function
Can anybody help with this 'Severe' error:

Quote:
**Severe*:Intrinsic proc 'absS' memory [0/0] is not uninitialized value (-1) Pass/Seq: ''Assign Addresses':55.


The calling line is:
Code:
while(abs(nMotorEncoder[driveMotor]) < rotation);


rotation is defined as 'int'

Thanks

Sangoma


Fri Apr 13, 2007 7:51 pm
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:44 am
Posts: 440
Location: Pittsburgh, PA
Post 
Can you post all of your code? I'm not sure how you are getting that error and doing so would help me debug your code.

I have tried making a sample "abs test" program to see if there could possibly be a problem. However, I was unable to reproduce an error (using v1.02 of ROBOTC for Mindstorms from the Download section). Here is the code:

------------------------------------
Code:
task main()
{

   nMotorEncoder[motorC] = 0;
   nMotorEncoder[motorB] = 0;

   while(abs(nMotorEncoder[leftMotor]) < 1000)
   {
      motor[motorB] = -100;
      motor[motorC] = -100;
   }

   motor[motorC] = 0;
   motor[motorB] = 0;

}


If you are using this code, YOU MUST set up motor C to be an "NXT Motor with Speed CTRL

Please let me know if you are still having problems. Thanks.
Vu

_________________
Vu Nguyen
Software Training Development Team | Webmaster
Need more support? Email ROBOTC Support at support@robotc.net to put in a support ticket

Robotc.net| Robomatter Store | Robotics Academy | CS2N


Fri Apr 20, 2007 3:35 pm
Profile
Rookie

Joined: Fri Apr 13, 2007 7:48 pm
Posts: 4
Post 
Thanks, Vu.

It seems this is hard to repeat! The code below exhibits the problem, but if you remove the steerTo() function it goes away.

Here is a scaled down version:
Code:
const tMotor   sweepMotor           = (tMotor) motorA; //tmotorNxtEncoderClosedLoop //*!!!!*//
const tMotor   steeringMotor        = (tMotor) motorB; //tmotorNxtEncoderClosedLoop //*!!!!*//
const tMotor   driveMotor           = (tMotor) motorC; //tmotorNxtEncoderClosedLoop //*!!!!*//
//*!!CLICK to edit 'wizard' created sensor & motor configuration.                !!*//

int hardLeft = 45;

void steerTo(int angle)
{
   nMotorEncoderTarget[steeringMotor] = abs(angle);
   if (angle > 0)
      motor[steeringMotor] = 50;
   else
      motor[steeringMotor] = -50;
}

void park()
{
   int rotation;

   steerTo(hardLeft);

   rotation = 360;

   nMotorEncoder[driveMotor] = 0;
   nMotorEncoderTarget[driveMotor] = rotation;

   motor[driveMotor] = -100;
   while(abs(nMotorEncoder[driveMotor]) < rotation);
}

task main()
{
   park();
}

_________________
Sangoma


Fri Apr 20, 2007 8:01 pm
Profile
Rookie

Joined: Fri Mar 16, 2007 9:12 am
Posts: 26
Post 
This may not be related, but I had similar problems with my functions that used the nSynchedMotors variables, etc. I eventually changed that back to none at the end of all of my functions that used this and the problems disappeared. Hope this helps.


Mon Apr 23, 2007 2:45 pm
Profile
Rookie

Joined: Fri Apr 13, 2007 7:48 pm
Posts: 4
Post 
Another thing to add is that the code compiles and downloads (and even appears to work) without issue, except for those warnings. I suspect that something confuses the compiler.

_________________
Sangoma


Mon Apr 23, 2007 7:26 pm
Profile
Rookie

Joined: Fri Mar 16, 2007 9:12 am
Posts: 26
Post 
Yep, mine had the same problem.. I had a function that was supposed to make the robot move left if it had a positive input and right if it was a negative value, and it always crashed when the robot turned right.
Code:
void turn(int angle, int& CurrentAngle)
{
   wait1Msec(100);
   float radius = 8;
   float arcLength = 0;
   int mov = 0;
   float wheelCirc = 18;
   bFloatDuringInactiveMotorPWM = false;
   nPidUpdateInterval       = 5;
   nMotorEncoder[motorB]=0;
   nMotorEncoderTarget[motorB]=0;

   if (angle > 0)
   {
      arcLength = radius*(degreesToRadians(angle));
      mov=(arcLength/wheelCirc)*360;
      nSyncedMotors                  = synchBC;
    nMotorEncoderTarget[motorB] = mov;
     nSyncedTurnRatio               = -100;
    motor[motorB]               = 70;
    while (nMotorRunState[motorB] != runStateIdle)
      {
         EndTimeSlice();
      }
      wait1Msec(1);                     // brieft delay
      nSyncedMotors=synchNone;
   }

   else if (angle < 0)
   {
      arcLength = radius*(degreesToRadians(angle*(-1)));
      mov=(arcLength/wheelCirc)*360;
      nSyncedMotors                  = synchBC;
    nMotorEncoderTarget[motorB] = (mov*(-1));
     nSyncedTurnRatio               = -100;
    motor[motorB]               = -70;
    while (nMotorRunState[motorB] != runStateIdle) // wait for action to complete
      {
         EndTimeSlice();
      }
      wait1Msec(1);
      nSyncedMotors=synchNone;
   }
   CurrentAngle += angle;
}


This code is the function I'm talking about, and with the addition of the line, "nSyncedMotors=synchNone;" it works great every run, with the single exception that it doesn't turn exactly the same amount left versus right for some reason, but I'll try to figure that out some other time..

*edit*
Ok, I must have missed that you posted your entire program earlier... Sorry. I think that does look like a bug, since abs() does take a short int, and it looks like the nMotorEncoder[] returns a short int... Anyhow, correct me if I'm wrong, but if you just set the nMotorEncoderTarget, won't the motor stop after it reaches the target anyhow? You could use something like while(nMotorRunState[] != runStateIdle) there right? Just a suggestion, but these NXT's are pretty quirky with this code still.. Sorry again for not looking at your code before posting earlier. Your problem is nothing like I thought at first.


Mon Apr 23, 2007 8:40 pm
Profile
Rookie

Joined: Fri Apr 13, 2007 7:48 pm
Posts: 4
Post 
Thanks for the input. And I'll check on the use of nMotorEncoderTarget!

_________________
Sangoma


Thu Apr 26, 2007 6:59 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 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.