0
$\begingroup$

Rosanswers logo

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
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * 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 {  
  
  @Override  
  public GraphName getDefaultNodeName() {  
    return new GraphName("rosjava_tutorial_service/client");  
  }  
  
  @Override  
  public void onStart(Node node) {  
    try {  
      ServiceClient<AddTwoInts.Request, AddTwoInts.Response> client =  
          node.newServiceClient("/add_two_ints", "test_ros/AddTwoInts");  
      Thread.sleep(100);  
      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);  
       
      client.call(srv, new ServiceResponseListener<AddTwoInts.Response>() {  
            @Override  
                public void onSuccess(AddTwoInts.Response res) {  
              log.info("call service success! " + res.sum);  
            }  
            @Override  
                public void onFailure(RemoteException arg) {  
              log.info("call service fail");  
            }  
        });  
    } catch (Exception e) {  
      if (node != null) {  
        node.getLog().fatal(e);  
      } else {  
        e.printStackTrace();  
      }  
    }  
  }  
  
  @Override  
  public void onShutdown(Node node) {  
  }  
  
  @Override  
  public void onShutdownComplete(Node node) {  
  }  
}  

Originally posted by hamada on ROS Answers with karma: 43 on 2018-07-25

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Hi @hamada! First of all, take a look into https://wiki.ros.org/rosjava; 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:


Originally posted by jubeira with karma: 1054 on 2018-08-01

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.