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






Reply to topic  [ 6 posts ] 
Obstacle Course 
Author Message
Rookie

Joined: Sun Nov 18, 2012 11:49 pm
Posts: 6
Post Obstacle Course
After the lining tracking ends in the obstacle course, my robot turns in circles instead of stopping. I already watched and did what the video said to do but it's still spinning in circles. Can you help? Thanks! :D
Here's my code :-)


Attachments:
nxt_wait_for_push 2.c [3.89 KiB]
Downloaded 209 times
Fri Dec 07, 2012 1:19 am
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 534
Post Re: Obstacle Course
The problem you are seeing lies in this section of code:

Code:
 while(SensorValue(touchSensor)== 0)

       {

       if(SensorValue(lightSensor) < 45)

         {
       motor[motorC] = 100;
       motor[motorB] = 20;

        }
     else
      {

       motor[motorC] = 20;
       motor[motorB] = 100;
      }
    }


The questions you have to ask yourself are: What is the robot doing? What do I want it to do? What is this code telling the robot to do?

Remember, the robot will do only and exactly what you program it to do; it does not make assumptions.

Hint: Usually when a robot continues an action, it is stuck in a loop and the condition to stop it cannot be met.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Fri Dec 07, 2012 1:27 pm
Profile
Rookie

Joined: Thu Jul 18, 2013 9:01 pm
Posts: 4
Post Re: Obstacle Course
I am not sure why "Challenge Incomplete - Try Again... You did not complete the challenge on the intended path"

I completed the challenge by touching wall, following line, using sonar to get to calibration area, and made it to goal. Code:

task main()
{
//FORWARD UNTIL PUSH

wait1Msec(2000); // Robot waits for 2000 milliseconds before executing program

while(SensorValue(touch) == 0) // Loop while robot's bumper/touch sensor isn't pressed in
{
motor[rightMotor] = 100; // Motor on motorB is run at half (50) power forward
motor[leftMotor] = 100; // Motor on NXT is run at half (50) power forward
}
motor[rightMotor] = 0; // Motor on motorB is run at half (50) power forward
motor[leftMotor] = 0; // Motor on NXT is run at half (50) power forward
wait1Msec(2000); // Robot waits for 2000 milliseconds before executing program


//TURN LEFT

wait1Msec(2000); // Robot waits for 2000 milliseconds before executing program

motor[rightMotor] = 80;
motor[leftMotor] = -80;
wait1Msec(750);

motor[rightMotor] = 0;
motor[leftMotor] = 0;
wait1Msec(2000);

//FORWARD UNTIL LINE

wait1Msec(2000); // 2 Second Delay

//Clear Encoders
nMotorEncoder[rightMotor] = 0;
nMotorEncoder[leftMotor] = 0;

while(nMotorEncoder[leftMotor] < 600)
{
//...Move Forward
motor[rightMotor] = 50;
motor[leftMotor] = 50;
}
motor[rightMotor] = 0;
motor[leftMotor] = 0;
wait1Msec(2000);

//FOLLOW LINE

wait1Msec(2000);

int threshold = 45;

ClearTimer(T1);
while(time1[T1] < 28000)
{
// sensor sees light:
if(SensorValue(light) < 47)
{
// counter-steer left:
motor[leftMotor] = 0;
motor[rightMotor] = 35;
}
// sensor sees dark:
else
{
// counter-steer right:
motor[leftMotor] = 35;
motor[rightMotor] = 0;
}
}

motor[rightMotor] = 0;
motor[leftMotor] = 0;
wait1Msec(2000);


//TURN LEFT

wait1Msec(2000);

motor[rightMotor] = 40;
motor[leftMotor] = -40;
wait1Msec (170);


//FORWARD UNTIL SONAR

while(SensorValue(sonar) > 5|| SensorValue(sonar) == -1) // while the sonarSensor sensor is reading in values larger than our
{ // threshold, or reading out of range (-1 = no object in sight)
// move forward:
motor[rightMotor] = 55; // set motorB to speed 55
motor[leftMotor] = 55; // set motorC to speed 55
}
// stop the robot:
motor[rightMotor] = 0; // set motorB to speed 0
motor[leftMotor] = 0; // set motorC to speed 0
wait1Msec (1000);


// BACKWARD
motor[rightMotor] = -20;
motor[leftMotor] = -20;
wait1Msec(500);


//TURN RIGHT

wait1Msec(2000);

motor[rightMotor] = -40;
motor[leftMotor] = 40;
wait1Msec(1500);

motor[rightMotor] = 0;
motor[leftMotor] = 0;
wait1Msec(2000);



//FORWARD UNTIL ULTRASONIC

while(SensorValue(sonar) > 5|| SensorValue(sonar) == -1) // while the sonarSensor sensor is reading in values larger than our
{ // threshold, or reading out of range (-1 = no object in sight)
// move forward:
motor[rightMotor] = 55;
motor[leftMotor] = 55;
}
// stop the robot:
motor[rightMotor] = 0;
motor[leftMotor] = 0;
wait1Msec (1000);


//TURN RIGHT

wait1Msec(2000);

motor[rightMotor] = -70;
motor[leftMotor] = 70;
wait1Msec(700);

motor[rightMotor] = 0;
motor[leftMotor] = 0;
wait1Msec(2000);


//...Move Forward
nMotorEncoder[rightMotor] = 0;
nMotorEncoder[leftMotor] = 0;

while(nMotorEncoder[leftMotor] < 3000)
{
//...Move Forward
motor[rightMotor] = 80;
motor[leftMotor] = 80;
}
motor[rightMotor] = 0;
motor[leftMotor] = 0;
wait1Msec(2000);

}


Thu Jul 18, 2013 9:13 pm
Profile
Moderator
Moderator

Joined: Mon Oct 04, 2010 2:18 pm
Posts: 117
Post Re: Obstacle Course
Does your entire robot make it into the goal area?


Fri Jul 19, 2013 6:55 pm
Profile
Rookie

Joined: Thu Jul 18, 2013 9:01 pm
Posts: 4
Post Re: Obstacle Course
The robot goes the whole way in the goal area (I tried programming it to make it go farther to no avail) then says "Fail"

https://docs.google.com/file/d/0B19jMvB ... sp=sharing


Fri Jul 19, 2013 7:44 pm
Profile
Rookie

Joined: Tue Feb 14, 2012 3:08 am
Posts: 1
Post Re: Obstacle Course
I have the same problem in my setup. I touch the wall follow the line move to the end of the exercise and I get the error that I did not follow the intended path.

I even tried doing it without touching the wall but it still doesn't work.

Any ideas?


Fri Nov 29, 2013 5:25 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 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.