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

Tell me how to use parameter server with rosjava

asked 2018-07-25 02:37:20 -0500

hamada gravatar image

I want to make parameter server with rosjava. But I can not. As far as I've looked up, I can not find the latest information on parameter server anywhere. That's why I want you to help me

I want to use AddTwoInts. However, when executing catkin_make, it says that the package of AddTwolnts can not be found. I guessed I had to edit build.gradle. But I do not know how to edit it

che License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
package com.github.rosjava.test;
import org.apache.commons.logging.Log;  
import org.ros.node.Node;  
import org.ros.node.NodeMain;  
import org.ros.node.service.ServiceClient;  
import org.ros.node.service.ServiceResponseListener;  
import org.ros.exception.RemoteException;  
import org.ros.service.test_ros.AddTwoInts;  
import org.ros.namespace.GraphName;  

// add for parameter  
import org.ros.node.parameter.ParameterTree;  

 * @author OTL 
public class Parameters implements NodeMain {  

  public GraphName getDefaultNodeName() {  
    return new GraphName("rosjava_tutorial_service/client");  

  public void onStart(Node node) {  
    try {  
      ServiceClient<AddTwoInts.Request, AddTwoInts.Response> client =  
          node.newServiceClient("/add_two_ints", "test_ros/AddTwoInts");  
      AddTwoInts.Request srv = new AddTwoInts.Request();  

      // add for parameter  
      ParameterTree params = node.newParameterTree();  
      srv.a = params.getInteger("/a", 1);  
      srv.b = params.getInteger("/b", 5);, new ServiceResponseListener<AddTwoInts.Response>() {  
                public void onSuccess(AddTwoInts.Response res) {  
    "call service success! " + res.sum);  
                public void onFailure(RemoteException arg) {  
    "call service fail");  
    } catch (Exception e) {  
      if (node != null) {  
      } else {  

  public void onShutdown(Node node) {  

  public void onShutdownComplete(Node node) {  
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-08-01 08:33:04 -0500

jubeira gravatar image

Hi @hamada! First of all, take a look into ; that's the entry point for the most up-to-date tutorials (see Kinetic version).

Regarding this question in particular, I see two different issues: - AddTwoInts is a service; take a look around here for reference: . - About the parameter server, you can check this link for reference: . The API hasn't changed since then.

edit flag offensive delete link more

Question Tools


Asked: 2018-07-25 02:37:20 -0500

Seen: 258 times

Last updated: Aug 01 '18