-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
importing peers in functions #149
Comments
@meyerj gentle ping on this issue. |
There is not much you can do about that without refactoring the whole scripting engine. Orocos does not evaluate every line of a function or program on the fly. In a first step it parses the function and already creates all the necessary data sources, operation callers etc., in order to be able to execute it with real-time constraints (under some additional assumptions and depending on the data types involved). At the time the parser sees the line It might be possible to automatically delay the evaluation of a line until the function is actually executed in case of an error during the initial parsing step, so basically to interpret the first definition of Your use case looks like |
I'm trying to get to a sort-of-dynamic deployment, where you load a big orocos lib that allows users to create components in one line (instead of the whole loadComponent, setActivity, configure, start, connect to the provided component etc). Something like : import("rtt_rospack")
ros.import("components_lib.ops") // <-- Defines loadComp1(), loadComp2() etc
loadComp1() And global void loadComp1()
{
loadComponent("hello","OCL::HelloWorld")
hello.do_stuff()
} This code returns :
Now I get why I have this behavior and I think i'm using the scripting service the wrong way. scripting.runScript("import_comp1.ops")
scripting.runScript("import_comp2.ops") But I'd like to have arguments to the functions, and that is difficult to achieve without ros. Maybe something like : scripting.runScriptWithArgs("import_comp.ops", strings("is_sim","my_robot","/link_0")) |
There are some possibilities how to fix this, but the by far simplest solution is to use export void myLoadComponent(string package, string type, string name)
{
import("rtt_ros")
scripting.eval("ros.import(\"" + package + "\")")
loadComponent(name, type)
// configure component...
} That approach works for me. Use
|
Thanks for the detailed answer. I think having Regarding the script arguments, something like |
The following code causes an error :
deployer -s import_test.ops
:import_test.ops :Parse error at line 5: Service or Task "Deployer" has no Peer or Service ros (or Deployer was not found at all).
But this does not :
Whenever a function ran into runScript, it does not accept newly created services/peers.
Why is it necessary to check for existing peers/services inside functions ?
The text was updated successfully, but these errors were encountered: