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

runStateIdle not working in Virtual World
http://www.robotc.net/forums/viewtopic.php?f=55&t=3912
Page 1 of 1

Author:  cullman2 [ Fri Dec 23, 2011 4:18 am ]
Post subject:  runStateIdle not working in Virtual World

I have the below function that should turn the bot 90 degrees. Inside the function there are two while loops. The first while loop is broken as the entrance conditional is never true. The second while loop, commented out, works fine.

The issue is that runStateIdle and/or runStateHoldPosition are never really set, thus the conditional is never true and the while loop is never executed. I have tried placing a timer before the while loop and the bot turns but only for the duration of the timer. Where upon the while loop conditional is tested false and the motors are shutdown.

Has anyone else had trouble with runStateIdle not working correctly inside Virtual World?

Code:
//FUNCTION right point turn 90 degrees
void turnRight90()
{
  //distance one wheel must travel for 90 degree point turn:
  //wheel base/diameter =~ 92mm
  //circumference = 92mm * 3.14 = 288.88
  //90 degrees == 288.88/4 = 72.22
  //wheel diameter = 42.2 mm
  //wheel circumference = 42.2 * 3.14 = 132.508
  int countsToTravel = (72.22/132.508)*(360);

  //encoder target for countsToTravel
  nMotorEncoder[motorB] = 0;
  nMotorEncoder[motorC] = 0;
  nMotorEncoderTarget[motorB] = countsToTravel * -1;
  nMotorEncoderTarget[motorC] = countsToTravel;
  motor[motorB] = -50;
  motor[motorC] = 50;
  while(nMotorRunState[motorB] != runStateIdle && nMotorRunState[motorC] != runStateIdle)
  {
    EndTimeSlice();
  }
  // while(nMotorEncoder[motorB] >= countsToTravel * -1 && nMotorEncoder[motorC] <= countsToTravel)
  // {
    // wait10Msec(10);
  // }

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

Author:  Ed Paradis [ Thu Jan 05, 2012 11:31 am ]
Post subject:  Re: runStateIdle not working in Virtual World

Hi,

The RVW doesn't currently support the advanced NXT motor speed controls currently. This means variables such as "nMotorEncoderTarget" and "nMotorRunState" aren't populated.

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