Ask Your Question
2

pubsub tutorial change string

asked 2014-08-04 04:00:43 -0500

stefan gravatar image

updated 2014-08-05 09:15:06 -0500

Hello,

i successfully ran the pubsub Tutorial. This Q helped me to see the message in RQT on my Computer.

How can i change the text hello world?

rosTextView.setMessageToStringCallable ((message) -> {return message.getData();});

what is this doing exactly?

when executing the Talker, how does the node know what to publish?

nodeMainExecuter.execute(talker, nodeConfiguration)

Edit:

Thanks for your short explanation.


Edit:

in rosjava - tutorial pubsub i can change the talker.java

Then i do

cd rosjava_core-hydro
./gradlew install

This builds the new libraries. Now i have my lib in

home/user/rosjava_core-hydro/build/libs

i think i ve installed rosjava like this

The referenced libs in the android project are in

opt/ros/hydro/share/maven/org/ros/rosjava_core/    .../rosjava_tutorial_pubsub

How do i get my libs to this root-folder?

Edit: in my android project i can change the root of this lib in

.idea/rosjava_tutorial_pubsub_0_1_6.xml 

root url="jar://$USER_HOME$/rosjava_core-hydro/build/libs/rosjava_tutorial_pubsub-0.1.6.jar!/"

still saying hello world



Final Edit:

Changing something in talker.class in your rosjava

where do i have to do catkin_make or ./gradle install ???? to create the lib

Then using nautilus with sudo to copy the generated lib into the root folder

opt/ros/hydro/share/maven/org/ros/rosjava_core/    .../rosjava_tutorial_pubsub

here exchange the -jar through your new .jar (with talker and listener class) in it

And now the app publishes the text you wrote in the talker.java file

edit retag flag offensive close merge delete

Comments

maybe someone can extend the pubsub tutorial with a section for changing the text of "hello world" to my custom text - could be useful

stefan gravatar imagestefan ( 2014-08-05 07:00:41 -0500 )edit

@stefan: changing it should not have been so involved. All that should be needed is to build the rosjava repository from source, and have your ros android projects depend on that, instead of overwriting binary dists in '/opt/ros/..'.

gvdhoorn gravatar imagegvdhoorn ( 2014-08-05 08:18:06 -0500 )edit

maybe i got smthing wrong with rosandroid and rosjava folders

stefan gravatar imagestefan ( 2014-08-05 09:12:48 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-08-04 04:28:26 -0500

gvdhoorn gravatar image

updated 2014-08-05 08:21:34 -0500

If you haven't already, I suggest you read through the available ros java documentation. Especially the rosjava_core documentation should be helpful. The java ROS client and interaction works a little different from the other client libraries (such as roscpp and rospy).

Both your questions should be answered after this.


Edit: for completeness:

what is this doing exactly?

rosTextView.setMessageToStringCallable ((message) -> {return message.getData();});

This is most likely a 'collapsed' view of (so your editor is collapsing this, look for a 'plus' in the gutter or margin):

rosTextView.setMessageToStringCallable(new MessageCallable<String, std_msgs.String>() {
  @Override
  public String call(std_msgs.String message) {
    return message.getData();
  }
});

In short: the class RosTextView extends a specialised View, which can update (append) its contents whenever a message comes in over a certain topic (in this case chatter, set by invoking rosTextView.setTopicName("chatter")). The method setMessageToStringCallable(..) just registers a callback (anonymous MessageCallable here) which will be invoked upon reception of a message. In this case it just returns the data within the message (which is a String), which RosTextView will use to update its view.

Your other questions can also be answered by reading the sources of the relevant classes.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-08-04 04:00:43 -0500

Seen: 740 times

Last updated: Aug 05 '14