To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.org.us.laflrcOpen lugnet.org.us.laflrc in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Organizations / United States / LafLRC / 332
331  |  333
Subject: 
3T
Newsgroups: 
lugnet.org.us.laflrc
Date: 
Fri, 3 Mar 2006 15:45:47 GMT
Viewed: 
1739 times
  
Well, I've had some time on my hands, and being totally unhappy with my 3T robot
I decided a re-build was in order.  Probably an 85% - 90% rebuild.  About the
only thing that wasn't touched was my cube magazine & the dropper mechanism.
Everything else was changes to some extent.  Taking a cue from the rest of you,
and having rescued my touch sensors from my NEIRG robot, I decided to ditch the
rotation sensors and go with touch sensors for both X & Y movements.  Much, much
better.

I finally got workable code last night, but still not as streamlined as I'd
like.

Which leads me to this....

I have noticed an interesting thing in Mindscript, and I'm hoping somebody out
there might take notice of this and explain it to me.

program 3T{
// lots of variables declared
event scancomplete when scandone = 1
main {
   scandone = 0
   start scan
   wait until scancomplete
   stop scan
}
task Scan {

   if A = 0 {
      //move to A location and scan for block
      CurX = 1
      CurY = 1

      <code here to scan and set A to 1 if block is present>

      if A = 1 {
          // if block was present A is 1 now
          // return scanner to home position
          CurX = 0 // set variable CurX to 0-- home position of scanner
          CurY = 0 // set variable CurY to 0-- home position of scanner
          set scandone = 1 // scandone variable is watched by an event
                           // when event fires scan task stops
      }
   }
   If B = 0 {
      //repeat same steps for B location
   }
}

besides being crappy code, my problem is this.  If I detect a block in A, it
should immediately recognize that, return home and stop the scanning task.  It
does this, but apparently not until it has already executed a few more lines of
code.  I know this because when it returns home, the CurX and CurY values have
already been reassigned to the location of B (1,2).  Here's my workaround...
insert a 1/2 second wait command just before the if B = 0 statement.  If I do
this, it works just fine.  I haven't figured out how long I have to wait, but
1/2 a sec works.  Anybody know why it works this way?

John



Message has 4 Replies:
  Re: 3T
 
I'm not sure about the RCX, but with some languages, things like events, or other tasks, will not start executing until the current task gives up the processor. (like in a wait) Here's a suggestion that should avoid the delay... (...) ... (...) * If (...) (19 years ago, 3-Mar-06, to lugnet.org.us.laflrc)
  Re: 3T
 
(...) I ran mine last night at a "family science night" for a school. Big hit, although I *absolutely* need error checking in my code (playing against a robot is easy - playing against a 5-year-old, with a couple of 4-year-olds constantly hitting (...) (19 years ago, 3-Mar-06, to lugnet.org.us.laflrc)
  Re: 3T
 
(...) Actually, John, I think I may be able to explain the problem. You have two tasks running at the same time. For the most part, the processor will switch between the main task, and the scan tast. So, the order of execution would be something (...) (19 years ago, 3-Mar-06, to lugnet.org.us.laflrc)
  Re: 3T
 
(...) as a mindscript guy, i cant say i've had this problem. i ~think~ the STOP TASK command stops the task at the END of that task. not mid task when the STOP was called. (1) If i wasn't busy with a R20 robot I would code a quick test to test for (...) (19 years ago, 4-Mar-06, to lugnet.org.us.laflrc)

9 Messages 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