leJOS statemachine development toolkit available

Post your NXJ projects, project ideas, etc here!

Moderators: roger, 99jonathan, imaqine

option "LeJOS statemachine project" unavailable

Postby AegBot » Mon Oct 27, 2008 1:05 am

thanks for your great work!

I tried several versions of eclipse and followed the instructions exactly. but after successfull installation of the plugins there are two problems:
first: there isn't any option "LeJOS statemachine project". so i can't craete a project with the 'L' and 'J' icon as shown in the tutorials.
second: the back init state button can't be connected with any state.

steffen
AegBot
New User
 
Posts: 1
Joined: Sun Oct 26, 2008 5:58 pm

Pseudo-Translation: Part 1

Postby bbagnall » Thu Jun 18, 2009 5:03 am

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*)
Last edited by bbagnall on Fri Jun 19, 2009 3:41 pm, edited 3 times in total.
Intelligence Unleashed: Creating LEGO NXT Robots with Java
Available September 2011
User avatar
bbagnall
Site Admin
 
Posts: 383
Joined: Fri Aug 04, 2006 4:03 pm

Postby bbagnall » Thu Jun 18, 2009 3:43 pm

Part II of translation:

2.2.3 Explicit Events
For a robot to steer to a round, two states are now required: a state of "normal driving" and one that corresponds to the alternate manover. In Figure 2.8 is a machine with these states represented.
EVENT:
An event is described by a condition that at any moment can occur. This condition is also called triggers. The framework uberpruft all triggers of the active state, as long as his course of conduct leads. If an event trigger condition is satisfied, then the course of conduct of the active state will be interrupted.

Figure 2.8: Through touch sensor event drawn

The course of conduct of the second condition "PullBack" the Robot is a fixed route zurucksetzen and then rotate 90 degrees. The first condition is now a feature in the course of conduct. The statement
"Pilot.forward ()" let the robot go forward, and nothing could stop him.
Here comes the event HitSomething come into play. When the touch sensor is selected, the implication is that the trigger condition of the event is satisfied.
The framework is the behavior of the drive course events and the interrupt control of the pull-back Zustandubergeben. Course of conduct could very well have an infinite loop. These events may be interrupted. After execution of the behavior of the state PullBack successor state is not modeled, so the processing according to 2.2.2 at this point
terminated.
This is not useful, because after the escape manover the journey should be continued. Course of conduct of the active state will be interrupted.


Figure 2.8: Through touch sensor event drawn
The course of conduct of the second condition "PullBack" the Robot is a fixed route zurucksetzen and then rotate 90 degrees. The first condition is now a feature in the course of conduct. The statement
"Pilot.forward ()" let the robot go forward, and nothing could stop him.
Here comes the event HitSomething come into play. When the touch sensor is selected, the implication is that the trigger condition of the event is satisfied.
The framework is the behavior of the drive course events and interrupt the control to the state via the pull-back type. Course of conduct could very well have an infinite loop. These events may be interrupted. After execution of the behavior of the state PullBack successor state is not modeled, so the processing according to 2.2.2 at this point
terminated.
This is not useful, because after the escape manover the journey should be continued. Course of conduct of the active state will be interrupted.

2.2.4 Implicit Events
If after the complete execution of the behavior of another state be controlled, this is done by an implicit event.
IMPLIED EVENT:
An implicit event lost a state of transition, when the behavior of the active state has ended without a course of conduct, the event has finished. The triggering of the state can transition to a condition
(Guard Condition) geknupft be.

Figure 2.9: The finished Bumper Car
Upon completion of the behavior of the state "PullBack" is an implicit transition in the event the "drive" state random. This is addressed to the Guard Condition cnt <= 4 geknupft what to follow, that the machine after the discovery of obstacles in all four directions off.
Finally, the possibility of aborting the processing of each state is modeled. It is good style, a control program to quit.
2.3 Examples
2.3.1 along the line
It is a standard task, a robot to build a line to follow.
Even this seemingly boring task may in many different ways can be modified. We use lines or broken lines, which are obstacles, bypassing the need to be, or trying to
Time to minimize the distance for a given macro.
The Lego supplied test track quickly shows its limits. Since the paper does not just surface, it reflects incident light differently. Even
connected with light source of the light sensor will be about driving the white paper, apparently a lot of different intensity values measured.
That makes a calibration of the sensor is inevitable.
For my robot, I prefer to use a flat white surface (table or white coated hardboard from the hardware store) and a role in insulating tape.
The thin insulating tape has the advantage that it is without great Muhe even in tight corners can be glued without wrinkles thrown. If you want, it may also be in different colors, too, I for my part, have
me so far with the black begnugt.

2.3.2 cats Jager
Useful inventions are rare. When cats Jager is one such. In the hallway of my office one day a surfaced cat that a neighbor allegedly belonged, but was too old to get the cat to care.
First, we had still hoped to get rid of this cat can, if you only unkind to her was enough. But unfortunately, the janitor started to feed. After that, there was no prospect that the cat
Leave home ever again. If we now come into the kitchen, one must reckon that the cat on the chair, and only with solid arguments about which to testify is that people belong chairs.
Meanwhile, you can be sure that it does not take 5 minutes, until the cat back in it again if they have kicked out the front. This cat is definitely cause for the invention of this robot. Welfare to calm living cats are hunting for the cats is not visible. The skin absorbs the ultrasound waves so well that the cat "black" is. So a cat replacement ago: Balloons are designated outstanding. Figure 2.10: ride on broken lines
This experiment requires some preparations. Consumables per test:
2 medium-sized balloons, 1 cm double-sided tape. Are still needed:
1 Trade subliche needle for the pinboard and a pen to paint the cat face.
For this experiment, the cats so by balloons gedoubelt (see Figure 2.11). It should not be too small to use, because the ultrasonic sensor
requires that a minimum size. The balloons should be well inflated, so it is easy to burst can be placed. It attached
them with a double-sided tape (carpet tape) on the floor so that they are not the slightest hint of wind to fly them. The double-sided tape
sticks of course not the node, but must be at the top of the balloon attached.
For decoration you can still see a cat face painted on the balloon, but it must be noted that the balloon "verkehrtherum" is pasted.

Figure 2.11: Jager Cats in Action
As a weapon for the Cats have handels Jager usual Pinnadeln preserved.
They can be easily modified so that they punch into the Lego strips fit. With a file or a drill as a lathe is the replacement plastic quick so far removed that the pins fit wonderfully.
Figure 2.12: Pinnadeln modified and original
When programming the finite state machine is the first problem to be dealt with, that the ultrasonic sensor only once every 200 ms to be queried.
On most reliable seems to be the watchword, the sound sensor in an independent sub-machines to run only every 200 ms to measure out.
This part deposited near the measured values in a variable.


2.3.3 agility with your dog
Task is to give the robot commands "Links" and "right" to teach.
He solluber this control through an obstacle course to a target market.
From a voice-controlled robot to speak, in this case but a bit over the top. In fact, the robot to react Gerausch signals. But we only have high and low tone can be distinguished. Some like a dog, not even the words of his men sees, but to recognize the pitch,
whether he will be praised or blamed. The word "Links" contains the vowel i, the long stretched very high can be pronounced. Many a dog owner knows the problem, a dog with the command "seat" to sit to. Experienced dog owners bring their dog the command "Siiieeehhhtz at. Spot table talk "-they tzen" her dog. But the dog has it much easier to adapt to this over exaggerated "i" to custom. It behaves similar to our robot. We speak also "Liiieeehhhnks". Similar talk "right" rather than "Rooohhhchts", then you can get a deep voice produce. These differences are due to various dbA / db measurements detected.
Experiments showed that the differences in the dbA / db measurements are not very stable. Even a loud / quiet human voice affects the
Difference. Therefore needed a Glattungs mechanism of multiple readings in a row averages.

Code: Select all
1 public class mediator {
2 private int current = 0;
3 private int average = 0;
4 private int [] measurements;
5
6 public intermediary (int measurement) {
7 readings = new int [measurement];
8 for (int i = 0; i <measurements.length; i++) measurements [i] = 0;
9 }
10
11 private int berechneMittel () {
12 int sum = 0;
13 for (int i = 0; i <measurements.length; i++) sum + = readings [i];
14 return average = sum / measurements. length;
15 }
16
17 public int addMesswert (int reading) {
18 measurements [current] = reading;
19 current = (current + 1)% measurements. length;
20 return berechneMittel ();
21 }
22
23 public int getMittel () {
24 return medium;
25 }
26 }



The basic idea in building the state machine is a machine part to have the responsibility for the Gerauschmessungen, and a second part vending machines should be used to control the motors.

The Sub-machine for the continuous measurements Gerausch uses intermediaries to smoothed values for the sound to have. He uses a loop trained tion to the measurements at least 200 ms apart to keep.
The Sub-machine consists of a condition, the drive, and a state of the commands ausfuhrt. Between these states is dependent on the current noise (in dBA) are switched over. In the export command
State must be made between high and low distinction between Gerau.
The robot drive to the left, if the difference between the small and the sound right, if this difference is big.
The corresponding state machine is given in Figure 2.14.

Figure 2.14: A dog hort on the commands left and right
Intelligence Unleashed: Creating LEGO NXT Robots with Java
Available September 2011
User avatar
bbagnall
Site Admin
 
Posts: 383
Joined: Fri Aug 04, 2006 4:03 pm

toolkit not dead

Postby ft.zimmermann » Sun Aug 02, 2009 8:19 pm

Hi folks,

just to inform you, the whole topic of the statemachine toolkit is not dead, even though i not not show up for quite a while.

I am using the lejos 0.8 by now and there is a sourceforge project availiable called lsdt (lejos statemachine toolkit).

http://sourceforge.net/projects/lsdt/files/

I have uploaded a complete eclipse distribution (130MB) so that a complex installation is not required. Just execute the setup.exe .


Anyone who wants to play with it can freely contact me, so that I can help in case of trouble.

Frank
ft.zimmermann
Novice
 
Posts: 35
Joined: Sat Sep 01, 2007 7:18 pm
Location: Hamburg, Germany

Previous

Return to NXJ Projects

Who is online

Users browsing this forum: No registered users and 1 guest

cron
more stuff