Presentation is loading. Please wait.

Presentation is loading. Please wait.

The OpenRDK framework: a not-so-short tutorial Part 2: advanced topics Daniele Calisi, Andrea Censi.

Similar presentations


Presentation on theme: "The OpenRDK framework: a not-so-short tutorial Part 2: advanced topics Daniele Calisi, Andrea Censi."— Presentation transcript:

1 The OpenRDK framework: a not-so-short tutorial Part 2: advanced topics Daniele Calisi, Andrea Censi

2 The OpenRDK framework - tutorial part 2 - OpenRDK Workshop - March 20092 In a multithreaded application, all accesses to shared data must be “protected” with a mutex Concurrent access management: locks Thread 1 …; lock(a); a.something(); …; unlock(a); …; Thread 2 …; lock(A); …; a.something(); …; unlock(A); …;

3 The OpenRDK framework - tutorial part 2 - OpenRDK Workshop - March 20093 Concurrent memory access: the session object RAgent Module Repository session

4 The OpenRDK framework - tutorial part 2 - OpenRDK Workshop - March 20094 OpenRDK provides implicit locks/unlocks… …and explicit locks/unlocks (e.g., large objects) Concurrent access management: locks double a = session->getDouble(…) lock() get value unlock() return value session->lock(A) myObject = session->getObject(A) myObject.function1(); myObject.function2(); session->unlock(A)

5 The OpenRDK framework - tutorial part 2 - OpenRDK Workshop - March 20095 The session object Similar to DBMS sessions  Recover locked properties Repository and ModuleManager communication  e.g. session->wait()  URL context (e.g., “ /robot/ ”)  Caching of property names  Starting and ending a session collect statistics (e.g., iteration duration, time between two start, etc.) Sessions and threads  Mutex (lock/unlock) clean management  One session for each thread (you can create other sessions for your own threads)

6 The OpenRDK framework - tutorial part 2 - OpenRDK Workshop - March 20096 Module code class TemplateModule { public: TemplateModule(); virtual ~TemplateModule(); bool initConfigurationProperties(); // bool initInterfaceProperties(); bool init(); void exec(); // void exitRequested(); // void cleanup(); // void asyncAgentCmd(cstr cmd); };

7 The OpenRDK framework - tutorial part 2 - OpenRDK Workshop - March 20097 #define PROPERTY_ALPHA “in/alpha” #define PROPERTY_BETA “in/beta” #define PROPERTY_RESULT “out/result” #define PROPERTY_MY_MAP “out/myMap” bool MyModule::initConfigurationProperties() { SESSION_TRY_START(session) //... session->createDouble(PROPERTY_ALPHA, "Alpha", RDouble::SEC, 10.); session->createDouble(PROPERTY_BETA, "Beta", RDouble::RAD, deg2rad(20.)); session->createDouble(PROPERTY_RESULT, “Result", RDouble::M, 100.); session->createMap(PROPERTY_MY_MAP, “The map", 1., 2., 0., 10., 20, 20); SESSION_END(session) return true; SESSION_CATCH_TERMINATE(session) return false; } initConfigurationProperties()

8 The OpenRDK framework - tutorial part 2 - OpenRDK Workshop - March 20098 bool MyModule::init() { SESSION_TRY_START(session) // open sockets... // connect to hardware... session->listenToTimer(500.); SESSION_END(session) return true; SESSION_CATCH_TERMINATE(session) return false; } Can listen to:  timers  property changes  nothing (non-OpenRDK entities: sockets, drivers,...) init()

9 The OpenRDK framework - tutorial part 2 - OpenRDK Workshop - March 20099 void MyModule::exec() { while (session->wait(), !exiting) { SESSION_TRY_START(session) double alpha = session->getDouble(PROPERTY_ALPHA); double beta = session->getDouble(PROPERTY_BETA); double gamma = alpha * beta; session->setDouble(PROPERTY_RESULT, gamma); session->lock(PROPERTY_MY_MAP, HERE); RMapImage* m = session->getObjectAsL (PROPERTY_MY_MAP); m->setPixelB(0, 0, RImage::C8Red); session->unlock(PROPERTY_MY_MAP); SESSION_END_CATCH_TERMINATE(session) } exec()

10 The OpenRDK framework - tutorial part 2 - OpenRDK Workshop - March 200910 Under the hood: startup order module1 module2 module3 >> Load configuration file << >> Instantiate modules << module1.initConfigurationProperties() module2.initConfigurationProperties() module3.initConfigurationProperties() >> Configure properties (1) << module1.initInterfaceProperties() module2.initInterfaceProperties() module3.initInterfaceProperties() >> Configure properties (2) << module1.init() module2.init() module3.init()

11 The OpenRDK framework - tutorial part 2 - OpenRDK Workshop - March 200911 Under the hood: execution and termination module1 module2 module3 module1.init() module2.init() module3.init() >> Multithreading starts << module2.exec()module1.exec()module3.exec() module1.exitRequested() module2.exitRequested() module3.exitRequested() >> Multithreading ends << module1.cleanup() module2.cleanup() module3.cleanup() >> Agent terminated <<

12 The OpenRDK framework - tutorial part 2 - OpenRDK Workshop - March 200912 Queues as object dispatchers Producer/consumer problem; FIFO Addressed like other properties (URL) Features  multiple consumers (concurrently)‏  no object duplication  automatic garbage collection  filters  passive Can be used for  localization (e.g., laser)  logging Module Queue Module Queue

13 The OpenRDK framework - tutorial part 2 - OpenRDK Workshop - March 200913 The SimpleTcpInterfaceModule Text-based interaction External applicationTELNET > propertyList /robot/enabled /robot/odometryPose /localizer/estimatedPose > getValue /robot/enabled Yes > getValue /robot/estimatedPose 10.4 32.12 45° > setValue /robot/enabled No > getValue /robot/enabled No Example:

14 The OpenRDK framework - tutorial part 2 - OpenRDK Workshop - March 200914 Connection to RT systems RT-Process

15 The OpenRDK framework - tutorial part 2 - OpenRDK Workshop - March 200915 The build system $ cd TheDirectoryOfMyModules $ rdk-create-module-dir.sh –m MyNewModule $ ls mynewmodule $ ls mynewmodule CMakeLists.txt mynewmodule.h mynewmodule.cpp mynewmodule_names.h $ cd mynewmodule $ cat CMakeLists.txt RDK_ADD_RAGENT_MODULE(ALL_FILES) $ … $ cat CMakeLists.txt IF(PALTALIB_FOUND) RDK_ADD_RAGENT_MODULE(ALL_FILES) INCLUDE_DIRECTORIES(${PALTALIB_INCLUDE_DIR}) LINK_DIRECTORIES(${PALTALIB_LINK_DIRECTORIES}) TARGET_LINK_LIBRARIES(${RDK_THIS_MODULE_NAME} ${PALTALIB_LIBRARIES}) ENDIF(PALTALIB_FOUND) $

16 The OpenRDK framework - tutorial part 2 - OpenRDK Workshop - March 200916 OpenRDK current applications Rescue wheeled robots (real robots, USARSim)‏ RoboCare project (assistive robots for the elders) Quadrotor, tarantula (real robots, USARSim)‏ RoboCup Standard Platform League (“Nao league”) HRI experiments (robot side)

17 The OpenRDK framework - tutorial part 2 - OpenRDK Workshop - March 200917 Summary OpenRDK features  Modularity and concurrent engineering  Full multi-thread support  Blackboard-style communication (properties can be shared among different processes)  Tools (Logging/replaying, RConsole, etc.)  Open source (GPL license) Extend the property sharing mechanism  More network QoS (e.g., from DDS: latency budget) On-line fault detection system Configuration file editing and analysis tools  Graphical on-line configuration editor  Detect possible deadlocks  Verify constraints on schedule More connectivity with the rest of the world Scripting (Ruby, Python) support Design a better logo! On-going and future work

18 The OpenRDK framework - tutorial part 2 - OpenRDK Workshop - March 200918 Questions Questions? We are on SourceForge: http://openrdk.sourceforge.net Credits : Prof. Daniele Nardi Developers: Daniele Calisi, Andrea Censi Early contributors: A. Farinelli, G. Grisetti, L. Iocchi Current contributors: F. Giannone, L. Iocchi, M. Leonetti, L. Marchetti, D. Nardi, P. de la Puente, G. Randelli, M. Sbarigia, A. Valero, R. Vicario


Download ppt "The OpenRDK framework: a not-so-short tutorial Part 2: advanced topics Daniele Calisi, Andrea Censi."

Similar presentations


Ads by Google