How can I create a service on ROS java? Details?

asked 2016-01-29 01:28:31 -0500

piet.delaney@gmail.com gravatar image

updated 2016-01-30 08:43:55 -0500

gvdhoorn gravatar image

I looked over the question: How can I create a service on rosjava?

but it seemed to be a bit dated and I wasn't able to add a new service.

I'm able to implement the AddTwoInts service but having difficulty on creating a new Service 'SendSmsMessage'.

I added a SendSmsMessage.srv to my local ~/rosjava_test_msgs git repo. I did a:

cmake .

but don't see any files to use else where.

I added SendSmsMessage.srv to my local ~/rosjava_bootstrap git repo:

 ~/rosjava_bootstrap/message_generation/src/test/resources/test_msgs/srv/
    AddTwoInts.srv               EmptyReqSrv.srv     EmptySrv.srv    
    MultipleAddTwoInts.srv    StringString.srv         ConstantsMultiplex.srv 
    EmptyRespSrv.srv          ListReturn.srv           SendSmsMessage.srv     <<<----
    TransitiveSrv.srv

and ran gradle which updated /opt/ros/indigo/share/maven/

I expected it to update: /opt/ros/indigo/share/rosjava_test_msgs/srv

but it still only has AddTwoInts.srv. Why is that?

I don't see any code for SendSms in /opt/ros/indigo but there are logs of files for AddTwoInts:

$ find . -name "SendSms*" -print

$ find . -name "AddTwo*" -print
./include/rosjava_test_msgs/AddTwoInts.h
./include/rosjava_test_msgs/AddTwoIntsResponse.h
./include/rosjava_test_msgs/AddTwoIntsRequest.h
./include/rospy_tutorials/AddTwoInts.h
./include/rospy_tutorials/AddTwoIntsResponse.h
./include/rospy_tutorials/AddTwoIntsRequest.h
./share/rosjava_test_msgs/srv/AddTwoInts.srv
./share/common-lisp/ros/rosjava_test_msgs/srv/AddTwoInts.lisp
./share/common-lisp/ros/rospy_tutorials/srv/AddTwoInts.lisp
/share/rospy_tutorials/srv/AddTwoInts.srv

in rosjava_core/rosjava/build.gradle whe have:

rosjava_core/rosjava/build.gradle:
      compile 'org.ros.rosjava_messages:rosjava_test_msgs:[0.2,0.3)'

I assume that get a jar file from:

/opt/ros/indigo/share/maven/org/ros/rosjava_messages/rosjava_test_msgs/0.2.1/rosjava_test_msgs-0.2.1.jar!/

but that jar file still only has AddTwoInts.class and not my new SendSmsMessage class:

AddTwoInts.class               AddTwoIntsResponse.class 
CompositeB.class              TestArrays.class                      TestPrimitives.class
AddTwoIntsRequest.class       CompositeA.class         
Composite.class                TestHeader.class                     TestString.class

There is are two .idea files referring to rosjava_test_msgs-0.2.1.jar:

 .idea/workspace.xml
   <option value="/opt/ros/indigo/share/maven/org/ros/rosjava_messages/rosjava_test_msgs/0.2.1/rosjava_test_msgs-0.2.1.jar" />

and

   ./.idea/libraries/Gradle__org_ros_rosjava_messages_rosjava_test_msgs_0_2_1.xml
     jar:///opt/ros/indigo/share/maven/org/ros/rosjava_messages/rosjava_test_msgs/0.2.1/rosjava_test_msgs-0.2.1.jar!/

So I suppose the most important problem is ~/rosjava_bootstrap not generating a java file for SendSmsMessage.srv. I do see a message_generation/src/test/java/org/ros/internal/message/Md5GeneratorTest.java mentioning testAddTwoInts but I doubt a bit this is the problem.

$ git grep AddTwoInts 
message_generation/src/test/java/org/ros/internal/message/Md5GeneratorTest.java:  public void testAddTwoInts() {
message_generation/src/test/java/org/ros/internal/message/Md5GeneratorTest.java:             serviceDescriptionFactory.newFromType("test_msgs/AddTwoInts");

I'd appreciate some enlightenment on this. Seems a bit complicate and I haven't seen any documentation on this whole process of adding a service that seems to go into this stuff that I'm seeing.

edit retag flag offensive close merge delete