def rosnode(): if roscore_is_running(): p = subprocess.Popen('rosnode list', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=comp.env()) nodes = [] for line in p.stdout.readlines(): nodes.append([line[1:-1]]) return jsonify(nodes=nodes) raise JsonError(description='roscore not running')
def get_rostopic(): system_topics = ['/rosout', '/rosout_agg'] p = subprocess.Popen('rostopic list', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=comp.env()) topics = [] info = [] for line in p.stdout.readlines(): t = line.rstrip() if t not in system_topics: topics.append([t]) print topics, len(topics) for i in range(0, len(topics)): pt = subprocess.Popen('rostopic info ' + topics[i][0], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=comp.env()) for line in pt.stdout.readlines(): topics[i].append(line.split(': ')[1].rstrip()) break return topics
def rostopic_kill(node): subprocess.Popen(['rosnode', 'kill', node], env=comp.env()) return json_response( response='ok')
def rosnode(): if roscore_is_running(): p = subprocess.Popen('rosnode list', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=comp.env()) nodes = [] for line in p.stdout.readlines(): nodes.append([line[1:-1] ]) return jsonify(nodes=nodes) raise JsonError(description='roscore not running')
def rostopic_kill(node): env = comp.env() env["ROS_NAMESPACE"] = '' subprocess.Popen(['rosnode', 'kill', node], env=env) return json_response(response='ok')