Here's a pseudo-translation of the German manual using Google language tools:
Modeling of state machines for
Lego Mindstorms NXT
Frank Zimmermann
ft.zimmermann @ web.de
FH Northern Academy
19. January 2008
Contents
1 Installation 1
1.1 Installation Requirements. . . . . . . . . . . . . . . . . . . . . 1
1.2 plugin installed. . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Condition Automatic 3
2.1 The metamodel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 state machines. . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2.1 states. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2.2 Exports of state machines. . . . . . . . . . . . . 8
2.2.3 Explicit events. . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2.4 Implicit Events. . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3 Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.3.1 driving on the line. . . . . . . . . . . . . . . . . . . . . . 13
2.3.2 Jager cats. . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.3.3 agility with your dog. . . . . . . . . . . . . . . . . . . . . 16
Index 19
Chapter 1
Installation
"Murphy, O'Malley, Sod and Parkinson are alive and well - and
working on your project. "
Without author
1.1 Installation Requirements
Before using Eclipse programs can be created, you must flash leJOS on the NXT. The plugin currently does not have the functionality to download leJOS on to the Brick.
The Lejos plugin is created for Eclipse Europa. Go to the Eclipse Homepage for the free download.
Currently, the plugin works under the Win32 platform using Bluetooth or USB connection, under Mac OSX using Bluetooth only. It uses the BlueCove Java Bluetooth interface for access. This means that on the
PC installed Bluetooth stack BlueCove must be supported. With Windows
XP SP2, Microsoft offers a Bluetooth stack, which should work.
Figure 1.1 shows my installation.
(Figure removed)
Figure 1.1: Example for installed Bluetooth Stack
1.2 plugin install
The plugin uses GMF (Graphics Modeling Framework), so the instructions to install the associated features are: To install, use HELP > SOFTWARE UPDATES > FIND AND INSTALL ... > SEARCH FOR NEW FEATURES TO INSTALL
Click NEXT and Select "Europa Discovery site" and click Finish. Select your closest Server. Expand the Europa Discovery Site and select "Models and Model Development" and select the Graphics Modeling Framework. Click "Select Required" to install the necessary plug-ins from the Discovery Europa Site. Click next to install this plugin.
In addition to the GMF plug-ins you also need OAW (Open Architectureware). Use the Update Site:
http://www.openarchitectureware.org/upd ... e/site.xml
Install the OAW classic feature.
Tip: Expand the product selection OAW Classic, then you can select only the OAW Classic feature. It requires two additional features from this update site, so click "Select Required" before clicking Next.
Install the leJOS plugin here:
http://fermat.nordakademie.de/update/site.xml
Chapter 2
State machines
"Trust is good - control is better."
-Lenin, falsely ascribed
For lots of complex control tasks, it may be necessary, these task structure so that it remains about looking bar. A robot with a complicated movement of leads, but it must be interrupted at any time can, because the sensor is against an obstacle or because it encounters an Abyss. If the programmers are even all possible events care needs, the program will quickly uncommon terms. There will be a Instance needed a orderly control over ausubt and in case of need to interruption of work performed. The interplay between about orderly Instance and the real work needs to be regulated. This is a state machine is an appropriate means.
2.1 The metamodel
In a meta model is the fundamental structure of the scope described. It contains the model elements, their sense of abstraction to Simplify the application contributes. In the case of a control a NXT Robots is the biggest challenge is to see a number of quasi-parallel running applications to coordinate with each other. It should be task of the metamodel to this complexity before the programmer as far as possible to hide. It is the task of technical experts, to the implementation of synchronization tasks to care.
(Figure removed)
Figure 2.1: Metamodel of the state machines
2.2 State machines
State machines are often used in computer science to describe program flow. State machines are therefore suitable especially for this Purpose, because they can particularly well represent state diagrams. They contain a condition in which the system and the other transition state, defined by the events are drawn. With these diagrams it is possible to visualize the end and thus easier to understand the overview. A reduced Error is the result.
In addition to the above applications of state machines, a wide Dissemination in the description of protocols and in theoretical computer science as finite automata.
Figure 2.1 shows the metamodel of state machines. The root element
is "Diagram." A chart included in the current version exactly
a state machine. A version of the plugin with a number of "state machine" is certainly a useful extension. A state machine has essentially two tasks:
1. Exports of the actions of the states
2. Switching between the states
In these applications are generated by two different tasks Thread done. The program does, however, not care about the synchronization of these threads.
In the plugin, you can use a state machine about the context of
models directory of the project with leJOS.
FILE > NEW > OTHER > leJOS STATE MACHINE DIAGRAM.
The First diagram shows an error, because only a state machine diagram must be created. Since much space is typically needed for graphical modeling , the editor window is used to maximize the View. The range of graphic Editor on Figure 2.2 shows tools for adding
to a state machine diagram
of state variables in the variables of the states and state machines
of states, events, a start state and control flow between
Events and states in the modeling of state machines.
(Figure removed)
Figure 2.2: State Machine in the editor window
2.2.1 Formation
STATE:
A state models a particular situation in which an object is located. This situation is aggravated by the task described. For example, there is in a robot, the black line on a drive to two in the eyes immediately falling states: "On the Line" and "In addition to the Line ".
Consummation first are static, which means that they describe a situation,
not a behavior. The state can, however, three behavioral specifications,
For example, in the form of a Java program instructions associated with
are:
1. Entry behavior that is executed when the state machine
in the state occurs
2. Exit behavior is behavior that is executed when the state machine
leave the state
3. Do activity, which is executed while the state machine is in the state
All three behavioral specifications are collectively referred to as the behavior of the Condition described.
2.2.1 Definitions
Condition
This definition of a state is based on the ideas of programming, which are found in the standard modeling language UML.
(Figure removed)
Figure 2.3: The behavior specification
Since states describe static situations, the name should be actually a
Noun phrase, which this situation is short and precise description. "To the
Line" is a good example. Often, however, do the behavior in the foreground, so that the nominal phrase, sometimes even a verbal phrase, "Drive On Line" is.
Graphically, a condition usually a rectangle with rounded corners shown
slightly different forms of representation but are also used, see
Examples in the figure right.
To illustrate an example. For the first state machine we need
a state with the name "Welcome". As the course will conduct used.
- Code: Select all
1 LCD. drawstring ( "Hello World");
2 LCD. refresh();
The course of conduct must be a complete statement in Java. In order for a State Machine can be executed, must be established, which First state to be executed. We use a starting state, in UML is called pseudo-state. Pseudo because this state by the State Machine is never used. It
serves only to mark the beginning of processing. The start state is
Then with an arrow with the first connected state.
The state machine starts in the Welcome condition and leads the course of conduct out. It is in this case the famous "Hello, world!" Edition. See:
http://de.wikipedia.org/wiki/Zustandsautomat_(UML)
This one ended, so, a successor state is sought. But it is not defined, and therefore the state machine stops at this point and will exit. Liked the behavior of other states exports, so needed to transition state, which will be drawn by events.
DEMOLITION:
If, after the processing of a state, there is no successor state, it terminates processing.
2.2.2 Definitions
Demolition
2.2.2 Exports of state machines
The high loading and starting the state machine can be determined from the context of the state machines are made out. There are three variants
that can be selected. See Figure 2.5.
With Upload, Animate, and starting the state machine to the Brick uploaded and if the option is run automatically after upload (see Figure
2.6) is activated, the machine will also start. If additional or Generate
BT animation code is active, it is assumed that the robot is animated
to be (single active state in the diagram). A corresponding Communication is established. The upload and the launch of Program may also use a USB cable. The conditions obtained from the designated leJOS documentation. When Run and Animate is No Upload performed. And Animate Only when the program needs to predict Brick in the running.
To experience is the order in which you act is very important. In particular it must be on the Brick before the upload starts.
(Figure removed)
Figure 2.5: Upload and Starting a state machine
(Figure removed)
Figure 2.6: Settings leJOS
(Figure Removed)
Figure 2.7: Communications Preferences
If the system has no Bluetooth interface, it must have a USB Bluetooth Stick inserted before the communication is started. Unfortunately communication is not foolproof, and after a sequence error is recommended that both the Brick, as well as to restart Eclipse.
Specifically, do the following settings
(* Table Text Start *)
Setting importance Recommendation
Directory name for
Models
Name of the model list
Default models leave
Directory name for
Java generation
Name of the directory
for generated Java classes
Default src-gen leave
Directory name for
leJOS linked files
Name of the directory
linked files for leJOS
Default'm leaving. To
Check Navigator
View used.
Verbose output for
Link
Controls whether the job in the le -
JOS Records Method issued
will
For debugging on
Default value is true left.
Run Program after
upload
Automatic Restart
after the upload
true or false, depending on the needs
Use USB for download or
Launching the program to use.
Only for Win. None
Animation.
Cableless rocks
Use BT for BT download, program start
or animation
use. No animation.
Default selected respectively.
NXT BT name readable name for NXT
Bricks
NXT respectively. Changing the
Name is the future of music.
NXT BT Address address will be the first
Contact is automatically determined
Only enter if known.
For animation required.
Remember BT
Address
Knowledge of the address
verkurzt upload time
Factor 2
Only delete if the
NXT is changed.
Generate BT Animation
Code
Animation code mitgenerieren
depending on the needs true or
false
Communications
delay
Delay between
Launching the program and start animation
in ms
Default 10000 respectively,
only decrease with caution.
(* Table text ends*)