rosjava / android_core

Android libraries for rosjava
145 stars 166 forks source link

how to listen/publish from/to a service #277

Closed vmoysiadis closed 6 years ago

vmoysiadis commented 6 years ago

Good evening :) i am trying to make a service client to my app and i cant figure out how to. the example with addTwoInts does not cover needs since i got a custom service on my remote PC.

i tryed the examples/answers from ros.answers website but still....

Any ideas ?

jubeira commented 6 years ago

Hi @vmoisiadis, I think this is a rosjava question more than an Android one, and perhaps ROS Answers is a better place for this. Yes, the documentation is certainly outdated.

I haven't done this myself in a while, but here's some hints:

Does that make sense? Sorry for the brief explanation; I will try to make some time myself to write a proper tutorial about this.

You can see an example of all of this working here: https://github.com/intermodalics/tango_ros.

In particular, here are the messages: https://github.com/Intermodalics/tango_ros/tree/master/tango_ros_common/tango_ros_messages (take a look at the package and CMakelists) and here's the build.gradle using the generated artifacts: https://github.com/Intermodalics/tango_ros/blob/master/TangoRosStreamer/app/build.gradle#L30. With that example and a bit of patience you should get going :)

To use the messages in the code, it's pretty much like the tutorial. Your messages will have different fields and responses, but the concept is the same.

vmoysiadis commented 6 years ago

Thank you so much, you saved me. I followed your instruction and with a little adjustment into my app i was able to import a custom service client

jubeira commented 6 years ago

Cool, I'm glad to hear that! This should be a tutorial, right next to the basic publisher/ subscriber one. I will try to do it when I have some time; please feel free to review it or to comment about it once it's done, so that anyone can follow the same steps properly :smiley: