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

How to create a Service with ROSJava [closed]

asked 2012-01-01 01:11:09 -0500

When you install latest release of ROSJava you have an example named: rosjava_tutorial_pubsub. This example is really useful to understand how to publish topcs and how to subscribe, but in the release, I didn't have any example to create a service with rosjava.

Anybody can help me?

Juan Antonio

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by damonkohler
close date 2012-02-02 01:59:34

2 Answers

Sort by » oldest newest most voted
2

answered 2012-01-05 01:00:45 -0500

damonkohler gravatar image

Services are also created from nodes just as publishers and subscribers are. Have a look at the javadoc for Node.newServiceClient and Node.newServiceServer.

edit flag offensive delete link more
0

answered 2012-01-31 03:15:25 -0500

Markus Eich gravatar image

I have the same problem here. I ended up with modifying the pubsub example. I read the javadoc and I ended at the node.newServiceServer part. I started to write my first service with empty request and empty response.

  ServiceServer<org.ros.message.std_msgs.Empty, org.ros.message.std_msgs.Empty> server = node.newServiceServer("callme",)

According to the javadoc, the params are

  • Type Parameters:
    • RequestType - type for the request
    • ResponseType - type for the response
  • Parameters:
    • serviceName - the name of the service
    • serviceType - the type of the service (e.g. "test_ros/AddTwoInts")
    • responseBuilder - called for every request to build a response

Now I am lost. What is the serviceType and what the responseBuilder?????? Can anyone complete my simple line if I want to have a simple service printing "hello world" if the service /callme is called? Thank you.

edit flag offensive delete link more

Comments

Please ask new questions instead of extending an existing question with a new answer. serviceType is the type of the service (e.g. test_ros/AddTwoInts). The responserBuilder is the ServiceResponseBuilder and generates a response for a given request. I've updated the javadoc to be more explicit.
damonkohler gravatar image damonkohler  ( 2012-02-02 01:59:23 -0500 )edit

Question Tools

Stats

Asked: 2012-01-01 01:11:09 -0500

Seen: 381 times

Last updated: Jan 31 '12