检测 roscore 是否启动
Python 检测 roscore 是否启动很简单,监听 ROS_MASTER_URI 端口即可,有内容就说明已启动
- check_roscore.py
#!/usr/bin/env python # encoding: utf-8 import os import xmlrpclib caller_id = '/rosout' m = xmlrpclib.ServerProxy(os.environ.get('ROS_MASTER_URI', 'http://localhost:11311')) try: m.getSystemState(caller_id) except : print("roscore not run")