Ask Your Question

Unable to run simultaneous rosserial publisher and subscriber

asked 2020-02-18 05:30:55 -0600

broomstick gravatar image

I'm working through the rosserial_embeddedlinux tutorials:

Both the publisher and subscriber tutorials work as described in isolation.

For the publisher: I can run rosrun rosserial_python tcp, run the HelloROS publisher example, run rostopic echo chatter, and see the expected output on the host.

For the subscriber: I can run rosrun rosserial_python tcp, run the ExampleSubscriber subscriber example, run rostopic pub chatter std_msgs/String -1 -- "Hello Embedded Linux", and see the expected output printed by the subscriber node.

When I try to run them together though (as described by the subscriber tutorial). I am not successful.

Whichever executable I start first (publisher or subscriber) connects to the rosserial_python server and behaves as expected. When I try to start the other executable, it doesn't connect to the server. If I kill the first application while the second is still running, the second one automatically connects to the rosserial_python server and then behaves as expected.

I assume there is some resource conflict here, but I don't understand the setup well enough to diagnose and correct it. The two executables connect from different ports (though they both connect to the server on port 11411).

I am also running everything on the same host machine (i.e., roscore, rosserial_python server, publisher, and subscriber). It's running Ubuntu 18.04. This may be my problem, but as each executable worked individually, it seemed easier to continue with the tutorials on my host machine before moving the embedded executables to a separate device which may be harder to debug.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-04-02 11:43:42 -0600

broomstick gravatar image

updated 2020-04-02 11:44:24 -0600

The easiest way I have found to overcome this is to run two nodes listening on two different ports. You have to rename one of them, to avoid namespace collisions.

At the command line:

[in terminal 1] rosrun rosserial_python tcp 11411 __name:=server_one
[in terminal 2] rosrun rosserial_python tcp 11412 __name:=server_two

You can verify the renaming worked correctly with: rosnode list

You can also do this in a launch file:

<node pkg="rosserial_python" type="" name="server_one" output="screen" args="tcp 11411">
    <param name="port" value="tcp" />

<node pkg="rosserial_python" type="" name="server_two" output="screen" args="tcp 11412">
    <param name="port" value="tcp" />

In either case, you need to make sure your rosserial applications are conneting to the correct port.

node_handle::initNode() will accept either an IP address or an IP address and a port number. In this case, then we would initialise one rosserial application with HOST_IP:11411 and the other with HOST_IP:11412. For example:

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


Asked: 2020-02-18 05:30:55 -0600

Seen: 156 times

Last updated: Apr 02 '20