A UNIX-based Simulator for LegOS with an Applet-GUI
LegoSim is (yet another) simulator for LegOS / BrickOS.
Why another simulator?
- At the time the project started, there was no other simulator.
- Once Emulegos was announced, we did not like the look-and-feel.
- We wanted to separate the GUI from the simulator.
- We prefer a GUI that closely resembles the RCX.
- We wanted a flexible GUI that can also serve as a control unit,
not just as a simulator interface.
- We wanted a simulator that can live without the GUI, for example,
to connect it to other RCXs via IR.
- You may run the GUI on a different machine than the simulator.
How does it work?
- There are two separate components, a Java-Applet GUI and a
simulator library, which are coupled by Perl scripts.
- The simulator library
- is a replacement for LegOS that can be linked with any LegOS application.
- Tasks are mapped onto POSIX Threads.
- Input and ouput of any devices is simulated as a string on
stdin/stdout following a grammatical specification.
- The Java-Applet GUI
- displays the actions of the RCX received in stdin as closely as possible.
- accepts inputs and generates the appropriate stdout string to
forward the input to the RCX.
- Perl scripts connect the GUI to the LegOS application and vice
versa (see picture 2).
What is or is not supported?
- API based on LegOS 0.1.7.
- sensors: touch (press black Lego brick of sensor 1/2/3) or enter
value in yellow input field above respective sensor.
- actuators: last action is displayed in yellow fields below
respective actuators (motors).
- IR: output of RCX displayed in to yellow field, input to RCX can
be entered into same filed, then press "ir send".
- buttons: Press On-Off or Run. View and Prgm not supported yet.
- LCD: basic LCD output, but not in 7 segment format. Refresh ignored.
- Sound: not at all.
Where do I get it, what kind of software
is required, how do I install it?
- Here are the bundled sources.
- Linux: gcc/egcs, glibc2 or some POSIX
Threads, Java JDK, Perl.
- SunOS 4.1.x: gcc/egcs, FSU Pthreads, and
(maybe on some other host) Java JDK, Perl.
- others: Tested under Linux but may run elsewhere with the same
- Install for Linux as follows (for SunOS 4.1.x, replace LINUX -> SUN4):
- get two windows (xterms)
- in window 1:
- cd $HOME
- tar xzf legosim.tgz
- cd legosim
- if your installation path is not $HOME/legosim, then
edit Makefile.common to set correct SIM_ROOT
(and, if using FSU Pthreads, also THREAD_ROOT)
- cd LINUX
- cd ../examples/LINUX
- make simple-rover
- ../../tcp2stdout 4712 | simple-rover | ../../stdin2tcp localhost 4711 5
- now you have 5 seconds to execute the last command in window
2; if you see "Connection refused", enter the previous command again
- in window 2:
- cd $HOME
- cd legosim
- tcp2stdout 4711 | appletviewer legosim.html | stdin2tcp localhost 4712 5
- Once you see "Connected to localhost, port #4711/4712", you have
done it! The simple-rover program is running in the simulator
(how does this work? see picture 2)
- Now click on the black Lego blick above sensor 1.
- You should see the motors (and LCD) reverse, go left (A reverse, C
forward), and forward again.
- Notice the required changes to your LegOS program:
When you want to test LegOS programs with this
simulator, you need to:
- insert sim_init(); as the first thing in main()
- replace kill -> sim_kill
- #include "kmain.h" to get rid of a warning
How about Documentation and other Pointers?
Bugs and a wish list:
- On-Off clear the memory, i.e., the program cannot run again.
- Run only toggles the walker. It does not run/stop the program.
- View/Prgm do not work yet.
- LCD refresh is ignored.
- Sound does not work.
- The simulator should really be a library, not just a collection of
- The sensors and actuators should be displayed with symbols,
directions and slides bars (for speed).
- Mail your enhancements to Frank Mueller.
Who is responsible for this software?
Frank Müllers home page