Introspection
Introspection is the foundation of robot API, capabilities, monitoring and action on monitored functions. The robot knows all the available API functions. Unloading a library will automatically remove the corresponding API functions. A function defined in a module can be added in the API with a BIND_METHOD (defined in almodule.h).
If you bind a function - just three source code lines - you automatically benefit from the following features:
- Call function in both C++ and Python
- Know function if the function is being executed
- Execute function locally or remotely (from a computer or another robot)
- Call wait, stop, isRunning on functions
ALModule::functionName(std::string functionName,std::string moduleName,std::string methodDescription") | Add new function in the module |
ALModule::addParam(std::string parameterName, std::string parameterDescription) | Parameter description |
ALModule::setReturn(std::string returnName, std::string returnDescription) | Add return value |
// C++ sample functionName("myFonction", "myModuleName", "function description"); addParam("paramName", "parameter description"); setReturn( "value", "description the value returned"); BIND_METHOD( myModuleName::myFonction );
#python sample # warning: this sample can only be executed in pythonBridge interpreter or Choregraphe class myModule(ALModule): def myMethodToAddToAPI(self): "" modulePython = myModule("modulePython") modulePython.BIND_PYTHON("modulePython","myMethodToAddToAPI")
The API is displayed on a web browser. Just type in the robot url and port 9559 - for example http://127.0.01:9559. The Robot will display its modules list, method list, method parameters, descriptions and examples. The browser also displays parallel methods that can be monitored, made to wait, stopped.