Ask Your Question

Revision history [back]

Related question (almost a duplicate): #q10499.

Relevant part of the answer there (from ros_comm/tools/rostopic/src/rostopic):

def _check_master():
    try:
        rosgraph.Master('/rostopic').getPid()
    except socket.error:
        raise ROSTopicIOException("Unable to communicate with master!")

_check_master() is not part of the public API of rostopic, but you should be able to use it.