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

ROSJava communication with outside program

asked 2013-02-15 05:26:48 -0500

jforkey gravatar image

updated 2013-02-15 09:25:44 -0500

130s gravatar image

Hi,

I have another application that manages task execution, similar to Collagen. I would like to build a link between this application and ROSJava. I am very new to ROS and ROSJava. I have gone through most of the tutorials and have a primitive understanding. To start, I would like something like a proof of concept. The application sends a task to be executed, ROSJava sends a confirmation (just a string for now), repeat. It should be something similar to the pubsub talk/listener tutorial, except that there is a talk / listener on both sides. Any idea on how I could achieve this?

Thanks!

edit retag flag offensive close merge delete

Comments

How does your application that manages task execution present information. I'm no java programmer, but if you can establish a message pipeline between your management application and a java class, then your halfway there.

PeterMilani gravatar image PeterMilani  ( 2013-02-17 12:57:17 -0500 )edit

Thanks for your reply. The task manager uses javascript to call the functions the robot should execute. IE, task manager decides it's time to execute task, executes a javascript function - which are sent to ROS as a java method that ROS interprets, executes, returns state, and waits for next task.

jforkey gravatar image jforkey  ( 2013-02-18 06:59:38 -0500 )edit

In ROSJAVA each node (that implements pubs and subs etc) is written as a java class that implements nodeMain. These are executed by a nodemainexecutor in your main Java Activity. Now your taskmanager has to pass a javascript statement to the class.

PeterMilani gravatar image PeterMilani  ( 2013-02-18 11:34:33 -0500 )edit

That's what I have been trying to do, but I think I am making an error somewhere along the line. I call a java method from javascript with something like Packages.org.example.Send("SetObject"), where send is the java method passing the instruction to the node. Your comments much appreciated.

jforkey gravatar image jforkey  ( 2013-02-18 12:02:43 -0500 )edit

you might need to post your code. Though I may not be able to help so much with the Java Script.

PeterMilani gravatar image PeterMilani  ( 2013-02-18 13:02:11 -0500 )edit

I'm having difficulty even creating the talker/listener from a separate java class. How would I invoke the Talker and Listener node from a separate java class? The talker/listener nodes compile and run with ./build/.. .org.ros..Talker. How would I make them run from a separate java class?

jforkey gravatar image jforkey  ( 2013-02-19 06:04:12 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2013-02-18 10:15:06 -0500

allenh1 gravatar image

updated 2013-02-18 10:15:28 -0500

I recommend you look into TCP communication. For the lab down the hall, I had to write a system that allows them to communicate from generic python code to some ROS C++ code I've written. This way, they can move the robot by just sending a command to a specific port, like "Set Speed (0.5, 0)."

The way I accomplished this is by constructing two threads, one to listen for messages and one to control the robot.

edit flag offensive delete link more
2

answered 2013-02-18 13:03:35 -0500

updated 2013-02-18 15:52:34 -0500

The only time I've been able to pass information to a Java node from a java activity (and beyond) is during initialisation of the class that is the node.

Your java program could accept an argument that is your message that could then be passed to the node, sent as a serviceclient, or published once or so, and then shutdown the complete program. This may be slow, but might be acceptable.

I've posted a question about dynamically sending data to nodes from within their activities.

cheers Peter

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-02-15 05:26:48 -0500

Seen: 674 times

Last updated: Feb 18 '13