1 / 27

Outline Introduction Language Description Examples Liburbi Soft Devices Conclusion

Jean-Christophe Baillie Electronics & Computer Engineering Dpt. Outline Introduction Language Description Examples Liburbi Soft Devices Conclusion. Ecole Nationale Supérieure des Techniques Avancées Paris, France. Introduction. URBI client(s). URBI server. TCP/IP IPC Open-R

elysia
Download Presentation

Outline Introduction Language Description Examples Liburbi Soft Devices Conclusion

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Jean-Christophe Baillie Electronics & Computer Engineering Dpt. • Outline • Introduction • Language Description • Examples • Liburbi • Soft Devices • Conclusion Ecole Nationale Supérieure des Techniques Avancées Paris, France

  2. Introduction URBI client(s) URBI server TCP/IP IPC Open-R … • URBI is an Interface Language to control robots • Key features: • Simplicity: easy to understand, but with high level capabilities • Flexibility: independant of the robot, OS, plateform, interfaced with many languages (C++, Java, Matlab…) • Modularity: soft devices to extend the language • Parallelism: Parallel processing of commands, concurrent variable access policies, event based programming,…

  3. Devices micro headPan camera legRF3 grip wheelR Every sensor, motor, camera or physical hardware in the robot is a device. A device is similar to a C++ object: it has methods and properties. The val property is related to the device value (telnet session, port 54000, with Aibo ERS7) headPan = 15; // or headPan.val = 15 headPan; [136901543:notag] 15.1030265089 accelX; [136901543:notag] 0.002938829104 camera; [145879854:notag] BIN 5347 jpeg 208 160 ############# 5347 bytes ########### speaker = bin 54112 wav 2 16000 16; ####### 54112 bytes #####

  4. Messages All messages from the server are composed with the same standard structure: headTilt; [136901543:notag] 15.1030265089 the command to the server: the message from the server: Time stamp (ms) Command tag Message content mytag: headTilt; [136901543:mytag] 15.1030265089 custom tag: useful to know who is sending what

  5. Advanced Tagging stop / block / freeze mytag: { commands...}; stop mytag; // stops the commands block mytag; // kills any new command with tag "mytag«  unblock mytag; freeze mytag; // freeze any running or new command unfreeze mytag; Flags: tag modifiers +error: command; // reports errors +begin: command; // reports beginning of the command +end: command; // reports ending of the command

  6. Complex Assignments 15 headPan = 15 time:5s; headPan = 15 speed:0.34; -2 5000ms 15 -2 speed = 0.34 unit/s 15 -2 accel = 0.02 unit/s² headPan = 15 accel:0.02; headPan = -2 sin:1s ampli:3; 6 units -2 Any function can be assigned as time parameterized trajectory with the function modifier (v1.0): 1000ms headPan = function(t):sqr(t)+sin(3*t+pi); Simple assignment: headPan = -2; Numerical assignments can be specified via “modifiers” This command never terminates

  7. Time Operators Operators , and ; are also available and have a semantics identical to & and | except that they have looser constraints: gap A | B B.Start == A.end A ; B B.Start >= A.end A B A B A A A & B B.Start == A.start A , B B.Start >= A.start B B gap NB: Brackets can be used to group commands, like in C: { headPan = 15 | headTilt = 23 time:1000 } & neck = 10; Commands can be executed in serial or parallel mode: headPan = 15 & neck = 30; Set headPan to 15 and neck to 30 at the same time headPan = 15 | neck = 30; Set headPan to 15 and after, set neck to 30.

  8. Variable Properties & Extensions Variables can be assigned several properties, using the -> indirection: myvar->rangemin = x; Stores the min range for the variable myvar myvar->rangemax = 145; Stores the max range for the variable myvar device.val->speedmin = 24.4; Speedmin is the minimal speed value (units/s) Variables in URBI are not simple containers like in C or similar languages: they are dynamic structures evolving over time. device->speedmax = 112; Speedmax is a hard limit on the variable derivative. neck.val->unit = "deg"; Variable unit (for information only) neck.val->delta = 12; Variable tolerance used in adapative mode neck.val->blend = normal; Variable blend mode (next slide) Variables evaluation can be specified using “extensions” : myvar’; device.x’’; First/Second order derivative,from assignments First/Second order derivative of device.val,from sensors device.val’d; device.val’dd; neck’n; Normalized value (using rangemin/rangemax) neck’e; Assigned – measured error (approx. torque measure).

  9. Blending modes Conflicting assignments can occur from several clients or inside the same program. How to handle it? Blending modes neck->blend = add; Each assignment occurs at the same time and is added to the others => Used for walk sequences neck->blend = mix; Like add, but they are averaged instead of added neck->blend = queue; Each assignement occurs only when the others are finished neck->blend = discard; Each conflicting assignment is ignored neck->blend = cancel; Each new assignment terminate any other pending assignment neck->blend = normal; The latest assignment has the focus, be the others run in background NB: this is also true for sound devices => simple multiplexer

  10. Device Grouping Devices can be grouped into virtual devices to form a hierarchie: group legLF {lefLF1, legLF2, legLF3}; group legs {legLF, legLH, legRF, legRH}; legs legLF legLH legRF legRH legLF1 legLF2 legLF3 Commands go down the hierarchy, allowing useful factorizations: legs.PGain = 0; // will affect the P Gain of all sub devices

  11. C-like Features Function definition Functions can be defined on devices or virtual devices: Control structures: Standard control structures are available and some more specific to URBI: def robot.walk (x,y) { … /* walk code*/ }; def add (x,y) { return x+y }; def fibo(n) { if (n<2) return 1 else { a = fibo(n-1); b = fibo(n-2); return a+b } }; // the classical for loop for (i=0;i<10;i++) echo i; // soft tests : must be true for 3ms while (headsensor > 0) { instructions… } // loop 10 times loopn (10) legLF1 = legRF1; // Funny average calculation with for& avg = 0; avg->blend = mix;for& (i=0;i<10;i++) avg = tab[i]; no semicolon usage: robot.walk (14,255); myresult = fibo(10); robot.process_mystring("bonjour");

  12. Event catching at (test) { at (test) { instructionsA; instructionsA; }; } onleave { instructionsB; }; whenever (test) { whenever (test) { instructionsA; instructionsA; }; } else { instructionsB; }; Several event catching mechanisms are available: A will be executed once when test becomes true. Then, as soon as test becomes false, B is executed and the server waits for test to be true again. test can be set with an hysteresis on the number of successful test checks or time. When test becomes true, A is executed. When A is finished, it is executed again if test is still true, otherwise, B is executed. waituntil (test); Terminates only when test becomes true. => If given a number, the wait command pauses for this nb of ms. usage: waituntil (test) | instructions…

  13. Event catching (2) timeout (time) command; //example timeout(10s) robot.walk(); command will be executed until time is over. This command runs in the background. stopif (test) command; //example stopif(headSensor) legRF1 = legLF1; command will be executed until the test becomes true. This command runs in the background. freezeif (test) command; //example freezeif(!ball.visible) balltracking(); command will be executed until the test becomes true, then it is freezed. When test becomes false again, it is unfreezed. Also runs in the background. You can control the lifespan of a command:

  14. Event catching(2) emit myevent; emit myevent (1,"hello"); This creates an spiking event with or without parameters. at (myevent) ... whenever (myevent (x,y)) echo x+y; at (myevent (1,s)) echo s; ... You can catch events with a simple test. If there are parameters, you get them together with the event and you can filter on the base of those parameters value. emit(2s) myevent; emit() myevent (1,"hello"); This will add a duration to then event. Possibly, no time limit. You can emit your own events with the emit function:

  15. Advanced Features Important files: URBI.INI CLIENT.INI URBI.INI is executed at start and usualy contains useful device groupings, aliases and an anim sequence. CLIENT.INI is executed when a new client connects to the robot and usualy contains a welcome message or a battery monitor. Many other advanced features: Interconnection commands, variables by name, aliases, load/save files, def checking, debugging options,… None of these are required to move a joint! joint.val = 30;

  16. Examples with Aibo // The ball tracking head program: whenever (ball.visible) { headPan = headPan + camera.xfov * ball.x & headTilt = headTilt + camera.yfov * ball.y }; // Stand up (leg1, leg2 and leg3 are virtual devices defined elsewhere) getup: { { leg2 = 90 time:2s & leg3 = 0 time:2s } | leg1 = 90 time:1s | leg2 = 10 time:1s | { leg1 = -10 time:2s & leg3 = 90 time:2s } }; // record and play a sound for 10s: sound = bin 0; // an empty buffer to store the soundtimeout(10s) loop sound = sound + micro; // record the sound...speaker = sound; // ...play it

  17. Walk Sequence Simple walk: Using an original walk from the robocup, we extracted the two main Fourier coefficients for each joints. With blend = add mode, these two components are added on each joint to reproduce the original periodic oscillation: def robot.walk(duration) { echo "go for " + string(duration) + " secs"; direction = 1; if (duration <0) { duration = - duration, direction = -1 }; walk: timeout(duration) { for &(x=1;x<=2;x++) for &(y=1;y<=2;y++) for &(j=1;j<=3;j++) for &(d=1;d<=2;d++) robot.leg[x][y][j] = walk.mean[x][j] sin:walk.speed*walk.coef[d] ampli:walk.amp[x][j][d]*4 phase:direction*walk.phase[x][y][j][d]+pi*(direction-1)/2 } };

  18. Behavior example speaker = lost; ball.visible == false Track ball Search ball ball.visible == true speaker = found; This example shows how to write behavior graphs with URBI: // Tracking state def tracking() { whenever (ball.visible) { headPan = headPan + camera.xfov * ball.x & headTilt = headTilt + camera.yfov * ball.y } }; // Searching state def searching() { period = 10s; { headPan’n = 0.5 smooth:1s & headTilt’n = 1 smooth:1s } | { headPan’n = 0.5 sin:period ampli:0.5 & headTilt’n = 0.5 cos:period ampli:0.5 } }; // Transitions track_transition: at (ball.visible ~ 400ms) { stop search; speaker = found; track: tracking(); }; search_transition: at (!ball.visible ~ 400ms) { stop track; speaker = lost; search: searching(); };

  19. Liburbi: quick review C++ example: UClient * client = new UClient("myrobot.ensta.fr"); synchronous asynchronous UCallbackAction receiveMyImage(const UMessage &msg) { … /* handles the image contained in UMessage */ } Telnet is of course too limited =>liburbi for C++ programming. Exists also for JAVA, Matlab and OPENR (soon: Python, C) The URBI library (liburbi) give simple methods to send commands to and receive messages from the URBI server. client->send(" headPan = %d", x); client->syncGetDevice("neck",&neckVal); // exists also for binary client->setCallback(&receiveMyImage,"imgtag"); client->send("loop imgtag:camera.val;");

  20. How to use URBI? telnet or urbilab client headPan.val = 15; headPan.val; [136901543:notag] 15.1030265089 ... C++ client // C++ code with liburbi C++ main() { UClient * client = new UClient("myrobot.ensta.fr"); int pos; pos = complex_calculation(x,y); client->send(“neck.val = %d;”,pos); } Java client // Java code with liburbi Java import liburbi.UClient; robotC = new UClient(robotname); robotC.send("motoron;"); robotC.setCallback(image, "cam"); URBI.INI onboard scripts Onboard client // C++ code with liburbi OPEN-R main() { UClient * client = new UClient("localhost"); int pos; pos = complex_calculation(x,y); client->send(“neck.val = %d;”,pos); urbi::execute(); } URBI Server • simple commands • functions definition • complex scripts other integrated clients (matlab, python, . . .)

  21. Making reusable software modules client program or URBI script Make use of the URBI variables constantly updated by the client module. Algorithm results as URBI variables Ex: ball.x, ball.y, ball.size External client module Compute some complex function, algorithm or signal processing task. Example: a ball tracking algorithm. Activity script: loop modulename:camera; Controlled by: block modulename; stop modulename; URBI Server Sensors or variable values Ex: camera.val

  22. Soft Devices Offboard Offboard Extern Soft Device URBI Server Extern Soft Device Extern Soft Device Onboard Extern Soft Device URBI Server Extern Soft Device Extern Soft Device The creation of “soft” devices extends the devices available in the robot. This is done by creating a subclass of USoftDevice. Soft devices can monitor variables, redirect function calls (C++/URBI binding) and events relative to them. Example:ball => ball.x, ball.y voice => voice.say(“hello”), voice.hear(x)

  23. Soft Devices (2) Proxy Extern Soft Device Proxy Server URBI Server Extern Soft Device Extern Soft Device Kernel plugins Integrated Soft Device URBI Server With the URBI Module Library: the same C++ code for all integration possibilities

  24. Demo Short demo video:

  25. Conclusion • URBI Server for Aibo & liburbi are freely available for non commercial use at: • www.urbiforge.com • Next steps: • Support more robots and develop partnership/contracts with robot manufacturers: • Currently: Aibo, HRP-2, Webots5 (robot simulator, Cyberbotics), ENSTAR, • Aldebaran Robotics, Pioneer robots. • Next: Sony, Philips iCat? • Increase the number of languages for the liburbi. • Currently: C++, Java, Matlab, C++/OPENR. • Next: Python, C, perl • Continue to add important features in the kernel: client functions, debugging facilities, multi tagging, kernel 2 with multicore processors support and real-time scheduling. • Develop URBI modules to enhance the language and stimulate the community (GPL) • Develop useful associated software & tutorials: URBI Lab, URBI center, URBI Dev

  26. at (talk.finished == true) echo « Thank you for » + « your attention »;

  27. Performances Performances Test on a wifi 802.11B wireless connections, with a URBI server for ERS7, a linux C++ client and tests with both the client and the server on the robot, and OPEN-R based connection. OPEN-R TCP/IP Latency: 600 µs Bandwidth: ~2Mo/s Latency: 1.5ms ± 0.5 Bandwidth: ~500Ko/s Jpeg compress (90): 10ms for 208x160 3ms for 104x80 ~30 motor commands per second per motor 208x160 jpeg92 = 30fps Good performances in general. For highly demanding low level action/perception loops, the best is to run some URBI Clients on the robot and leave the high level slow control architecture offboard.

More Related