Using Smalltalk for controlling robotics systems
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
3,271
On Slideshare
3,260
From Embeds
11
Number of Embeds
1

Actions

Shares
Downloads
35
Comments
0
Likes
3

Embeds 11

https://twitter.com 11

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • Arduino <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • Les structures conditionnelles n&#x2019;existent pas en Smalltalk, ce sont &#xE9;galement des envois de messages ! <br /> <br /> <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • step est une m&#xE9;thode abstraite &#xE0; red&#xE9;finir dans les sous-classes <br />
  • <br />
  • Sous-classe de SimpleReactiveWifiBot <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />

Transcript

  • 1. Using Smalltalk for controlling robotics systems Serge.Stinckwich@doesNotUnderstand.org ESUG (European Smalltalk User Group)
  • 2. Introduction to Smalltalk&Embedded System
  • 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).
  • 6. Resilient Smalltalk • Resilient Smalltalk Embedded Platform (OOVM) (2004) • Used in Bang&Olufsen (B&O) digital speakers prototypes GPIO = Object ( | io | ) initialize = ( io := Memory at: 16r90040000 size: 16r20. ) setOutput: pins = ( io longAt: 16r08 put: pins. ) clearOutput: pins = ( io longAt: 16r0C put: pins. )
  • 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)
  • 9. sujet verbe complément.
  • 10. album joue.
  • 11. album joue. album jouePiste: 3.
  • 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, ...)
  • 21. Smalltalk an ubiquitous application developement environment (years before Java) !
  • 22. 1 WifiBotST: controling WifiBot from Smalltalk
  • 23. WifiBot
  • 24. myMission := WifiBotMission new. arena := ArenaForMorphicWifiBot new. arena mission: myMission. arena width: 1000. arena height: 600. arena openInWorld. obstacle := RectangleMorph new. obstacle width: 100. obstacle height: 50. obstacle color: Color black. arena addMorph: obstacle. obstacle position: 400@300.
  • 25. bot1 := ObstacleAvoiderWifiBot morphic. bot1 body openIn: arena. bot1 body positionInArena: 400@200. bot1 forwardSpeed: 40. bot1 rotationSpeed: 20. bot2 := ObstacleAvoiderWifiBot morphic. bot2 body openIn: arena. bot2 body positionInArena: 400@500. bot2 forwardSpeed: 30. myMission start.
  • 26. Main abstract classes • WifiBot (body) • #body, #body:, #step • WifiBotBody (bot)
  • 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
  • 30. Demo WifibotST
  • 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.
  • 37. The Design Patterns Smalltalk Companion
  • 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
  • 40. libUrbi.st demo
  • 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.
  • 44. PlayerST Demo
  • 45. PlayerST • http://www1.ifi.auf.org/mediawiki/ index.php/Smalltalk_Player_Client • http://www.squeaksource.com/ PlayerST.html • MIT Licence
  • 46. 4 SqueakBot: pedagogical robotics with Etoys
  • 47. SqueakBot • Educational platform developed in Squeak Smalltalk, • Allow childrens to visually script and simulate various kinds of robots, • In partnership with Planète Sciences.
  • 48. Exploration robot
  • 49. Robotic Caterpillar
  • 50. Walking Robot
  • 51. Demo Etoys
  • 52. SqueakBot • Linux+ paper (September 2007) • http://wiki.laptop.org/go/Projects/ SqueakBot • Licence MIT
  • 53. Other personal projects • ROAR: RObotics AlgoRithms (exploration strategy, occupancy grids), • Calder: Multi-robots visualization engine with domain-specific scripting language based on Mondrian.
  • 54. 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
  • 55. http://www.esug.org/