To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.nqcOpen lugnet.robotics.rcx.nqc in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / NQC / 1290
1289  |  1291
Subject: 
Blocking problem?
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Thu, 3 Jan 2002 09:02:40 GMT
Viewed: 
3128 times
  
Hi all,

The model this is written for is a biped walker with each leg driven by
it's own motor. The PB is a Scout. It uses a modified version of
ping.nqc to do IR proximity detection. When it detects that there is an
obstacle, it should back up, turn and then continue advancing. Since the
turn radius is quite wide, I tried to get fancy and have the proximity
detection keep going and if it detects an obstacle during the turn it
should back up again and try turning again.  Unfortunately this produces
unpredictable results. My guess is I have a blocking problem either in
task ping() or task evade(). Any help would be appretiated.

Here is the code:

int step_time = 35;
int pause = 15;
int stand_time = 20;
int walk_time = 250;
int LEFT;
int RIGHT;
int block = 0;

task walk_forward()
{
  stop evade;
  while (true)
{
         LEFT=7;
         RIGHT=7;
         step();
}
}

task walk_backward()
{
ClearTimer(0);
SetPower(OUT_A+OUT_B,7);
while (Timer(0)<= walk_time)
{
OnFor(OUT_A,step_time);
OnRev(OUT_A);
Wait(pause);
SetOutput(OUT_A, OUT_OFF);

OnFor(OUT_B,step_time);
OnRev(OUT_B);
Wait(pause);
SetOutput(OUT_B, OUT_OFF);
}
}


task turn()
{
   int turning = Random(1);
   until (block == 0)
    {
     if (turning == 1)
     {
     LEFT = 7;
     RIGHT = 2;
     step ();
     }
     else
     {
     LEFT = 2;
     RIGHT = 7;
     step ();
     }
  }
}

task scout_ping()
{
   while(true)
   {
     SendMessage(1);
     if (SENSOR_3 == 2)
     {
      block = 1;
      start evade;
     }
     block = 0;
   }
}

task evade ()
{
      stop walk_forward;
      start walk_backward;
      Wait (walk_time);
      stop walk_backward;
      PlaySound(SOUND_DOWN);
      start turn;
      Wait (walk_time*3);
      stop turn;
      start walk_forward;
}

task main()
{
  CalibrateSensor();
  start scout_ping;
  start walk_forward;
}


sub step()
{
         SetPower(OUT_A,LEFT);
         SetPower(OUT_B,RIGHT);
         OnFor(OUT_A,step_time);
         OnFwd(OUT_A);
         Wait(pause);
         SetOutput(OUT_A, OUT_OFF);

         OnFor(OUT_B,step_time);
         OnFwd(OUT_B);
         Wait(pause);
         SetOutput(OUT_B, OUT_OFF);
}



1 Message in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR