Skip to content

Instantly share code, notes, and snippets.

@Tutorgaming
Created February 20, 2020 11:31
Show Gist options
  • Save Tutorgaming/87fcedb20b7daf18013155be687ecae6 to your computer and use it in GitHub Desktop.
Save Tutorgaming/87fcedb20b7daf18013155be687ecae6 to your computer and use it in GitHub Desktop.
Playing with Subprocess
#!/usr/bin/python
import subprocess
import time
def bash_command(cmd):
subprocess.Popen(cmd)
def gnome_terminal_open_tab(cmd_list):
"""
Open The Command in tabs
"""
final_cmd = ["gnome-terminal"]
prefix = ["--tab", "-e"]
for cmd in cmd_list:
bash_cmd = ["/bin/bash -c \'" + str(cmd) + "\'"]
final_cmd = final_cmd + prefix + bash_cmd
return final_cmd
def rosmon_launch(package, launch_name):
return "rosrun rosmon rosmon " + str(package) + " " + str(launch_name)
com = gnome_terminal_open_tab(["roscore"])
com2 = gnome_terminal_open_tab([rosmon_launch("sr1_docking_worker", "docking_worker.launch"), "rostopic echo /rosout", "rqt"])
bash_command(com)
time.sleep(3)
bash_command(com2)
class Launcher(object):
"""
SR1 Node Launcher
"""
def __init__(self):
pass
def sleep(self, seconds):
"""
WAIT FOR A SPECIFIC SECONDS
"""
time.sleep(seconds)
def check_roscore(self):
"""
Check if ROSCORE IS ONLINE OR NOT
"""
pass
def launch(self, yaml_doc):
"""Launch by YAML DOC
"""
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment