3. Development on
Embedded Systems
• Pourcentage of micro-processors used for
embedded systems are increasing,
• Time development of embedded systems is
very-time consuming,
• Lack of support of incremental
development, dynamic updates of deployed
systems.
4. Embedded Smalltalk -
a long story ...
• 1989 - Canadian NAVY CANEWS-2 ESM System (Passive
Radar Receiver) - 130K code (90% Smalltalk) - Multi-
processor Smalltalk
• Process control: Allen Bradley Network Manager - Network
configuration (Smalltalk+C)
• 1992 - Integrated Manufacturing: TI Works - Integrated Wafer
Fabrication Facility
• 1998 - Automotive: IBM Network Vehicle (Smalltalk) -
Control bus device interfacing + wireless communication
• Now - AMD production chain
5. Tektronix Smalltalk
• Tektronix TDS 500 Series
Oscilloscopes (1987)
• Multiprocessor
MC68020&DSP
• Smalltalk + C (legacy)
+Assembler (DSP)
• Approx. 250 classes (all in
ROM, use less than 64K
DRAM).
7. Why Smalltalk for
robotics ?
• Simple Syntax: easy to generate code from
Smalltalk + DSL for robotics&WSN
• Portable & small VM (Squeak+Pharo VM)
• Uniformity: Everything is written in
Smalltalk
• Highly dynamic language
8. Simple syntax
• Uniform: only message sending,
• Only 6 keywords: nil, true, false, self, super,
thisContext
• Simple AST: 11 different nodes
• Accessible by a non-specialist
• Very simple to define embedded Domain-
Specific Languages (DSL)
12. album joue.
album jouePiste: 3.
album répèteLesPistesDe:2
àLaPiste:5.
13. album play.
album playTrack: 3.
album repeatTracksFrom:2
to:5.
14. exampleWithNumber: x
"Ceci est une méthode qui illustre chacun des aspects de
la syntaxe de Smalltalk."
|y|
true & false not & (nil isNil) ifFalse: [self halt].
y := self size + super size.
#($a #a 'a' 1 1.0)
do: [:each | Transcript
show: (each class name);
show: (each printString);
show: ' '].
^x<y
15. Turtles all the way
down
• All systems objects are
accessible
• Fix it yourself !
• Learn how things work
• See how the master code
16. Integer>>factorial
"Answer the factorial of the receiver."
self = 0 ifTrue: [^ 1].
self > 0 ifTrue: [^ self * (self - 1) factorial].
self error: 'Not valid for negative integers'
6 factorial.
17. ifTrue:ifFalse:
True>>ifTrue: trueAlternativeBlock ifFalse: falseAlternativeBlock
"Answer with the value of trueAlternativeBlock. Execution does not
actually reach here because the expression is compiled in-line."
^trueAlternativeBlock value
18. <primitive: x>
SmallInteger>>+ aNumber
"Primitive. Add the receiver to the argument and
answer with the result
if it is a SmallInteger. Fail if the argument or the
result is not a
SmallInteger Essential No Lookup. See Object
documentation whatIsAPrimitive."
<primitive: 1>
^ super + aNumber
19. Portable Smalltalk
VM
• Original embedded Smalltalk VM assumed
less than 12 basic platform functions
(clock, memory, interrupts)
• Most function supplied by dynamically
installable modules (don’t assume you can
reboot !)
• You only need to port the VM
20. VM
• Pharo written in Slang (a subset of Smalltalk),
then translated in C to be executed at full
speed
• VM can be simulate in the Smalltalk
environment !
• FFI
• Plugins are coded in Slang (mp3, ogg, serial
port, ...)
27. SimpleReactiveWifiBot
step
self body updateSensorValues.
self computeActuatorValues.
self body commitActuatorValues
computeActuatorValues
"Subclasses may redefine this method"
self body forwardSpeed: self
forwardSpeed rotationSpeed: self rotationSpeed
28. ObstacleAvoiderWifiBot
computeActuatorValues
"Move forward or turn to avoid obstacles"
self body distanceToRightObstacles < 50
ifTrue: [^ self body forwardSpeed: 0 rotationSpeed: -30].
self body distanceToLeftObstacles < 50
ifTrue: [^ self body forwardSpeed: 0 rotationSpeed: 30].
super computeActuatorValues.
29. Graphical vs Physical
bodies
• Graphical body: MorphicWifiBotBody
• Physical body: RealWifiBotBody
• Same API
31. WifiBotST
• Control&Simulation of WifiBot in Smalltalk
• http://vst.ensm-douai.fr/WifiBotST
• http://www.squeaksource.com/WifiBotST
• MIT licence
• Autonomous version (WifiBot embedded
VM)
32. 2
libUrbi.st:
urbiscript code
generation from
Smalltalk
33. urbiscript
• Prototype-based event-based object-
oriented script language,
• Support for several robots platforms &
simulation engines (Webots, AIBO, NAO,
Bioloid, Mindstorms NXT, Spykee)
34. libUrbi.st
• Write&debug a Smalltalk program,
• Generate urbiscript code to deploy the
program on the robot,
• Generation done with the help of
Refactoring Browser (RB) AST & Visitor
Pattern.
35. 11 main RB AST
nodes
• RBMethodNode, RBPragmaNode,
RBReturnNode, RBArrayNode,
RBAssignementNode, RBBlockNode,
RBCascadeNode, RBLiteralArrayNode,
RBLiteralValueNode, RBMessageNode,
RBVariableNode
• All subclasses of RBProgramNode
• Implement all the method acceptVisitor:
36. Visitor Pattern
Represent an operation to be
performed on the elements of an
object structure in a class
separate from the elements
themselves.
Visitors lets you define a new
operation without changing the
classes of the elements on which
it operates.
38. Conversion examples
UrbiScriptConverterTest>>testEcho
| tree result |
tree := RBParser parseExpression: '1 echo'.
result := UrbiScriptConverter new
visitNode: tree.
self assert: result contents = 'echo(1)'.
tree := RBParser
parseExpression: '1 to:10 do:[:i| i echo]'.
result := UrbiScriptConverter new
visitNode: tree.
self assert: result
contents = 'for(var i=1;i<=10;i+=1){echo(i)}'
39. One acceptXXXNode:
for each RB AST node
UrbiScriptConverter>>acceptRetu
rnNode: aReturnNode
stream nextPutAll: 'return '.
self visitNode: aReturnNode
value
41. libUrbi.st
• urbiscript code generation from a subset of
Smalltalk
• http://www.squeaksource.com/libUrbi
• MIT licence
42. 3
PlayerST:
client for Player/
Stage robotic device
server
43. Player/Stage
• Player provide an interface to a
variety of robot and sensor
hardware (lasers, sonars, IR sensors,
camera). Player’s client/server
architecture allows to robot control
programs to be written in any
programming language.
• Stage simulates a population of
mobile robots and sensing a two-
dimensional bitmapped environment.
48. SqueakBot
• Educational platform developed in Squeak
Smalltalk,
• Allow childrens to visually script and
simulate various kinds of robots,
• In partnership with Planète Sciences.
56. SqueakBot
• Linux+ paper (September 2007)
• http://wiki.laptop.org/go/Projects/
SqueakBot
• Licence MIT
57. Other personal
projects
• ROAR: RObotics AlgoRithms (exploration
strategy, occupancy grids),
• Calder: Multi-robots visualization engine
with domain-specific scripting language
based on Mondrian.
58. Conclusion
• Simple Syntax: easy to generate code from
Smalltalk + DSL for robotics&WSN
• Portable & small VM (Pharo VM)
• Uniformity: Everything is written in
Smalltalk
• Highly dynamic language