To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 26953
26952  |  26954
Subject: 
Re: TachoSpeed.nqc
Newsgroups: 
lugnet.robotics
Date: 
Mon, 12 Mar 2007 22:35:24 GMT
Original-From: 
linmix <linmix@^StopSpam^gmail.com>
Viewed: 
3778 times
  
John Hansen wrote:
In lugnet.robotics, linmix <linmix@gmail.com> wrote:

When the TachoSpeed reported by watching the brick is around 57, the
brick doesn't do anything if the response value is set to 62. It does at
66 or 67 but that also makes it impossible to negotiate a slope because
the inclinations also makes the TachoCount value drop and the brick
turns around


I don't really understand what you mean when you say "the brick doesn't do
anything".  Can you be more specific?

Sorry. I meant to say 'the brick never executes the if statement'.
Am I right in thinking that if both Tachospeed (OUT_L) and  Tachospeed
(OUT_R) drop below the threshold value the first 'if ' is more likely to
be executed?


They will both be executed in sequence if at the time the second if statement
reads the TachoSpeed setting on OUT_L it happens to be below the threshold
setting.  If you described exactly what you are trying to make the robot do it
might be easier for both of us to figure out what is going wrong.  You may want
to try letting your robot get up to speed outside of your while loop and then
get rid of the 2/10s a second wait and OnFwd call at the start of the while
loop.  Perhaps you should make the two if statements into a single if/else
statement instead.

John Hansen
I don't see 1) how I could make an if/else statement or 2) what the
benefit would be.

1) If I make an if/else statement isn't 'else' executed always if 'if'
is not true? In that case I'd have to add a third statement saying what
to do if neither OUT_L nor OUT-R drop below the threshold value.
I'm not 100% sure but I believe it'd have to look something like this:

task main()
      {
      OnFwd (OUT_L+OUT_R);
      Wait (20);
      while (true)
           {
           if (TachoSpeed(OUT_R) < threshold) //default behaviour
              {
              reverse (50);
              clockwise (30);
              OnFwd (OUT_L+OUT_R);
              Wait (20);
              }
           else if (TachoSpeed(OUT_L) < threshold) // alternate behaviour
              {
              reverse (50);
              c_clockwise (30);
              OnFwd (OUT_L+OUT_R);
              Wait (20);
              }
           else  //do this if none of the above applies
              {
              OnFwd (OUT_L+OUT_R);
              Wait (20);
              }
          }
      }

2) what would be the advantage of doing it this way?

regards,
linmix



Message has 1 Reply:
  Re: TachoSpeed.nqc
 
(...) The question you need to answer for yourself is this: Do I want my robot to to potentially execute both if blocks in sequence or do I only want the second if block to execute if the first condition is known to be false? If you only want the (...) (18 years ago, 13-Mar-07, to lugnet.robotics)

Message is in Reply To:
  Re: TachoSpeed.nqc
 
(...) I don't really understand what you mean when you say "the brick doesn't do anything". Can you be more specific? (...) They will both be executed in sequence if at the time the second if statement reads the TachoSpeed setting on OUT_L it (...) (18 years ago, 12-Mar-07, to lugnet.robotics)

13 Messages in This Thread:



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

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    
Active threads in Robotics

 
Verified and Trusted Team of Hackers
7 hours ago
Custom Search

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