To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.nxtOpen lugnet.robotics.nxt in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / NXT / 767
766  |  768
Subject: 
Re: events /nxt vs. events/rcx
Newsgroups: 
lugnet.robotics.nxt
Date: 
Thu, 31 May 2007 15:43:04 GMT
Viewed: 
21814 times
  
In lugnet.robotics.nxt, Elizabeth Mabrey wrote:

Any suggestion will be greatly appreciated!

   Sigh... "good luck"?

   I don't mean to sound too negative, but this is a hard nut to crack under the
standard FW I think... at least I've yet to figure out a way to do it to my
satisfaction. In fact, more than almost any other single point, this has kept me
from bothering with NBC/NXC: if I'm going to learn a new language, I want it to
clearly extend what I can do, and NBC/NXC just can't do that here. Not because
it's not great, but because it is running on top of the FW that has this
limitation.

   That said, you can get close in certain circumstances. The way I've been
doing it is to implement a state machine, where each state is essentially a
"Move until some encoder duration is reached" system. Since things like Move
blocks under NXT-G are handled in the FW, other things (call them "sensor
watchers") can be running in parallel with the thread that's handling the
motors. If one of those "sensor watcher" threads needs *immediate* control of
the motors (like for running off the sumo ring), it fires off a "motor stop"
command, which it turns out superseeds any currently executing FW motor control
task. Essentially, it's almost like using the motors as a resource to be grabbed
like the old "acquire(resource)" command under NQC. If you do this carefully,
(under NXT-G), you can handle a wide variety of situations... but it's a kludge,
pure & simple. And if I can do it under NXT-G:

http://www.brickshelf.com/cgi-bin/gallery.cgi?i=2065175

...you should certainly be able to make something similar work under NBC/NXC.
Just realize that it's going to be very tricky if you need parallel threads to
communicate to each other very promptly. As long as all the threads spend the
bulk of their time looking at semaphores instead of doing something useful, you
can have threads "politely" interrupt each other... but how much of your
computation do you want to spend on all your threads checking each other?

I understand that NXT VM does not support events like you
find in the RCX.

   There are VMs for the NXT that do support events in a fashion much closer to
the old RCX. These are what I'll move onto, once I get tired of NXT-G (which, I
confess, I just don't seem to be any time soon).

--
Brian "G" Davis



Message is in Reply To:
  events /nxt vs. events/rcx
 
Hi, I tried to write some code to simulate the events like in RCX. It starts to look cluttered. I understand that NXT VM does not support events like you find in the RCX. Any suggestion will be greatly appreciated! Elizabeth (17 years ago, 31-May-07, to lugnet.robotics.nxt)

2 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