0
$\begingroup$

Rosanswers logo

When I run rostopic hz <topic-name> inside a docker container to get the publishing rate of a topic via the containers logs I don't get any output. (If I echo the same topic I get what I expect.) Do I miss something here?

In [1]: import docker
In [2]: cli = docker.from_env(version='auto')
In [3]: roscore = cli.containers.run(image='osrf/ros:indigo-desktop-trusty', network='host', command='
   ...: roscore', detach=True)
In [4]: publisher = cli.containers.run(image='osrf/ros:indigo-desktop-trusty', network='host', command
   ...: ='rostopic pub /topic_to_observe std_msgs/UInt8 42 -r 1', detach=True)
In [5]: rostopic = cli.containers.run(image='osrf/ros:indigo-desktop-trusty', network='host', command
    ...: ='rostopic hz /topic_to_observe', detach=True)
In [6]: rostopic.logs()
Out[6]: ''
In [7]: subscriber = cli.containers.run(image='osrf/ros:indigo-desktop-trusty', network='host', comman
   ...: d='rostopic echo /topic_to_observe', detach=True)
In [8]: subscriber.logs()
Out[8]: 'data: 42\n---\ndata: 42\n---\ndata: 42\n---\ndata: 42\n---\ndata: 42\n---\n'

Originally posted by thinwybk on ROS Answers with karma: 468 on 2018-05-03

Post score: 2


Original comments

Comment by gvdhoorn on 2018-05-03:
This looks like the output of an IPython console. Is this what you mean with "manually running"?

Comment by thinwybk on 2018-05-03:
Right, I ran it in a IPython console which was no problem so far. If I run the command in my Ubuntu workstation environment I have the usual output:

❯ rostopic hz /topic_to_observe
subscribed to [/topic_to_observe]
average rate: 1.000
    min: 1.000s max: 1.000s std dev: 0.00000s windo

Comment by thinwybk on 2018-05-04:
... I expected to get something similar with In [6]: rostopic.logs() Out[6]: ''.

Comment by gvdhoorn on 2018-05-04:
I'm not sure I understand what you're asking, but that is probably just me.

Comment by thinwybk on 2018-05-04:
Sorry, probably not clear enough: When I run roscore, a publisher node and rostopic hz I would expect the same output of rostopic hz when (a) I run them on Ubuntu directly or (b) I run them inside Docker containers (like done via the IPython console and docker Python package).

Comment by gvdhoorn on 2018-05-04:
Are they all running in the same container?

Comment by thinwybk on 2018-05-04:
No, each is running in a separate container (via <"docker-container-representation"> = cli.containers.run(...) for all: roscore, publisher, rostopic, subscriber). But they share the same host network. (This was usually sufficient to enable cross-container ROS node communication.)

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Yeah, I just noticed the host bit. That should work, so not sure. I've never really extensively used the Docker Python libs. Perhaps it's doing something strange with TTYs?

A quick google led me to docker/docker-py/issues/390.

Notice the tty=True argument there.


Originally posted by gvdhoorn with karma: 86574 on 2018-05-04

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by thinwybk on 2018-05-04:
Thanks for that hint. It's not urgent right now. I'll have a look at this as soon as I can spend time on it and keep the question open for now.

Comment by thinwybk on 2018-05-04:
Thx. Changing to rostopic = cli.containers.run(image='osrf/ros:indigo-desktop-trusty', network='host', command='rostopic hz /topic_to_observe', detach=True, tty=True) solved this issue.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.