Skip to content

Instantly share code, notes, and snippets.

@HemaZ
Last active September 17, 2020 11:24
Show Gist options
  • Save HemaZ/a5dad68b3a6155fbc3d01c8492535a81 to your computer and use it in GitHub Desktop.
Save HemaZ/a5dad68b3a6155fbc3d01c8492535a81 to your computer and use it in GitHub Desktop.
import subprocess
import os
import time
class Gazebo:
def on_start(self):
# Get the world file path form block's properties
self.world_file = self.get_property("world_file")
# Get the models files path form block's properties
self.models_path = self.get_property("models_path")
if len(self.models_path) > 0:
self.alert("setting models path to {}".format(self.models_path), "INFO")
subprocess.Popen("cp -r {} .".format(self.models_path), shell=True)
os.environ["GAZEBO_MODEL_PATH"] = self.models_path.split("/")[-1]
self.alert("Starting noVNC", "INFO")
# start desktop
subprocess.Popen("sh /usr/local/bin/start_desktop.sh", shell=True)
# Wait for desktop to start
time.sleep(5)
self.alert("Starting Gazebo", "INFO")
# Run gazebo
subprocess.Popen(
"vglrun bash -c 'gazebo {} --verbose'".format(self.world_file), shell=True
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment