View unanswered posts | View active topics It is currently Sat Apr 19, 2014 2:28 pm






Reply to topic  [ 2 posts ] 
runStateIdle not working in Virtual World 
Author Message
Rookie

Joined: Fri Dec 23, 2011 2:56 am
Posts: 1
Post 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;
}


Fri Dec 23, 2011 4:18 am
Profile
Rookie
User avatar

Joined: Mon Feb 14, 2011 10:37 am
Posts: 49
Location: The Pitts(burgh)
Post 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.

_________________
Robot Virtual Worlds Technical Lead
Robotics Academy - CMU


Thu Jan 05, 2012 11:31 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.