Cannot set params from rosrun #293
Description
I would like to set a parameter (in the parameter server) for a node using rosrun,
because I need to run a lot of nodes, each one with a different configuration.
Running the command:
rosrun PACKAGE PROJECT com.github.rosjava.PACKAGE.PROJECT.CLASS __myParam:=55
I'd expect to see the parameter myParam in the parameter server, with the value of 55.
But it doesn't work.
(With _myParam:=55
and myParam:=55
I got RosRuntimeException: Invalid graph name: 55
)
In fact, with the commandrosparam list
, myParam doesn't show up
and I cannot even get it with the code inside the class of the node:
public void onStart(final ConnectedNode connectedNode) {
DefaultParameterTree params = (DefaultParameterTree) connectedNode.getParameterTree();
int myParam = params.getInteger(connectedNode.resolveName("~myParam").toString());
// doesn't work: throws ParameterNotFoundException
int myParam = params.getInteger("myParam");
// doesn't work: throws ParameterNotFoundException
int myParam = params.getInteger("/myParam");
// doesn't work: throws ParameterNotFoundException
}
I also tried to look in the rosjava code, starting from RosRun.java
and I found out that in CommandLineLoader.java
the params defined as __myParam:=55
are collected:
- in the Map remappingArguments by the method parseArgv() and
- in the Map specialRemappings by the method parseRemappingArguments() called by build()
but then only the ones corresponding to the command line variables defined in CommandLineVariables.java are considered.
So I'm also asking if I'm missing something in the code, or if it's missing something in the code, or if I'm totally wrong.
So, is there a way to make it work?