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 / 26964
26963  |  26965
Subject: 
Re: TachoSpeed.nqc
Newsgroups: 
lugnet.robotics
Date: 
Tue, 13 Mar 2007 23:00:00 GMT
Original-From: 
linmix <linmix@gmail.^ihatespam^com>
Viewed: 
3953 times
  
John Hansen wrote:

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 second one to execute when the first one is false then you want a construct
like this:

if (TachoSpeed(OUT_R) < threshold) {
}
else if (TachoSpeed(OUT_L) < threshold) {
}

You don't need to add another else without an if.  You would benefit a lot from
writing out your program in what is called "pseudo code".
That's exactly what I'm trying to achieve.
I hadn't actually written out any pseudo code, but it is (almost)exactly
the way I had thought it through in my head.
My main problem is that I think up what I'd like to do and then have to
scour the API to find out if it can be done and how.
That means that I make mistakes like the if/if statement because I
thought I'd found what I needed and looked no further.
The pseudo code above would quite readily be written like this:

#define threshold 62          // change to make more/less sensitive
#define reverse(t) OnRev(OUT_L+OUT_R); Wait(t);
#define clockwise(t) OnRev(OUT_R); OnFwd(OUT_L); Wait(t);
#define c_clockwise(t) OnRev(OUT_L); OnFwd(OUT_R); Wait(t);

task main()
{
  OnFwd(OUT_L+OUT_R);
  until((TachoSpeed(OUT_L) > threshold) && (TachoSpeed(OUT_R) > threshold));

Shouldn't that be || instead of &&? I don't need both motors to slow
down before I take an action.
The main problem with your approach is that the motors do not stall when the
robot hits an obstacle so it will be hard for you to distinguish between the
motor speed slowing due to low battery levels, increased load (like going up an
incline), or pushing a moveable obstacle out of the way.
Actually I was thinking about writing a calibration routine tocompensate
for some of that. Something along the lines of:

place the bot against a wall
start it
wait a short time to give the motors time to get up to speed
save the TachoSpeed of left and right into a variable (maybe just one
variable with the average of both)
wait for a touch sensor to be pressed.
Start the main task
Why not just use a
touch sensor attached to a bumper mechanism?

John Hansen
Now that would be cheating, wouldn't it ;)

I'm trying to learn to program by using NQC with a hands-on approach.
I read in the Programmer's guide that this was a possibility and decided
to try if I could make it work. So far I've learned a lot from you guys
and it is actually working better and better, so I'm really happy

linmix



Message is in Reply To:
  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)

13 Messages in This Thread:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    
Active threads in Robotics

 
Verified and Trusted Team of Hackers
4 hours ago
Custom Search

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