Exemplo n.º 1
0
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')
Exemplo n.º 2
0
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
Exemplo n.º 3
0
def rostopic_kill(node):
	subprocess.Popen(['rosnode', 'kill', node], env=comp.env())
	return json_response( response='ok')
Exemplo n.º 4
0
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')
Exemplo n.º 5
0
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
Exemplo n.º 6
0
def rostopic_kill(node):
    env = comp.env()
    env["ROS_NAMESPACE"] = ''
    subprocess.Popen(['rosnode', 'kill', node], env=env)
    return json_response(response='ok')