ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

rosjava: Get List of Parameters

asked 2013-02-13 00:37:19 -0600

dberm22 gravatar image

updated 2013-02-14 01:14:53 -0600

I am developing with ros on an android tablet, and I am trying to change parameters using the device (as a remote, so to speak). However, I am having trouble doing so. Has anyone done this?

Here is my attempt:

    NodeConfiguration nodeConfiguration = NodeConfiguration.newPublic( InetAddressFactory.newNonLoopback().getHostAddress());
    ListView ParamListView = (ListView) findViewById(;
    final String[] NodeName = url.split("=");
    ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(Integer.MAX_VALUE);
    NodeFactory nodeFactory = new DefaultNodeFactory(scheduledExecutorService);
    Node node = nodeFactory.newNode(nodeConfiguration);
    ConnectedNode connectednode = (ConnectedNode) node;
    final ParameterTree ParamList = connectednode.getParameterTree();
    //final ParameterTree ParamList = (ParameterTree) new ArrayList<String>();
    List<String> ParamJavaList = (List<String>) ParamList.getList(NodeName[1]);
    final ArrayAdapter<String> ParamListAdapter = new ArrayAdapter<String>(this,, ParamJavaList);

What am I doing wrong? I am not sure how to copy and paste my error log, but the error is is occurring before my call of getList().

If I uncomment the commented line and comment out the 5 lines before it, I get an error saying I cannot cast from ArrayList to ParameterTree. That is how I got to this convoluted point of trying to initialize the ParamList using getParameterTree(), which requires access to the connected node.

I am sure there is an easier way to do this, but I am not aware of it.

Thanks in advance!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-02-14 08:26:14 -0600

dberm22 gravatar image

updated 2013-02-20 04:39:26 -0600

I was able to solve it by going the route of ssh-ing into the host machine (using Jsch). This code did the bulk of the work from an AsyncTask.

            JSch jsch=new JSch();  

            Properties config = new Properties();
            config.put("StrictHostKeyChecking", "no");
            config.put("compression.s2c", "zlib,none");
            config.put("compression.c2s", "zlib,none");

            this.user = params[0];
   = params[1];
            this.pwd = params[2];
            this.cmd = params[3];

            session=jsch.getSession(user, host, 22);   

            StringBuffer result = new StringBuffer();

            channelexec = (ChannelExec) session.openChannel("exec");
            String setPATH = "source /opt/ros/fuerte/setup.bash;export ROS_PACKAGE_PATH=/home/YOURCOMPNAME/ros_workspace:/opt/ros/fuerte/share:/opt/ros/fuerte/stacks;";

            InputStream stdout = channelexec.getInputStream();
            InputStream stderr = channelexec.getErrStream();

            msg = "Connected to Host";

            String aux = "";
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(stdout));
            while ((aux=bufferedReader.readLine()) != null) {

        }catch(Exception e){
            msg = "Cannot Retrieve Param List";
        return builder.toString().substring(1);

And the cmd I called was:

String cmd = "rosparam list "+NodeName
edit flag offensive delete link more


This is more of a workaround then a solution, please consider removing "selected answer"

OzzieTheHead gravatar image OzzieTheHead  ( 2018-08-09 12:54:40 -0600 )edit

Question Tools


Asked: 2013-02-13 00:37:19 -0600

Seen: 838 times

Last updated: Feb 20 '13