Created
September 29, 2020 18:42
-
-
Save ibraEssam/4c6f7d17a0373f82a95c70e9e1f6a19a to your computer and use it in GitHub Desktop.
Revisions
-
ibraEssam created this gist
Sep 29, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ import subprocess import os import time class Gazebo: def on_start(self): """This block is used to launch gazebo in noVNC it builds the ros workspace, source it , then run a launch file which run gazebo ros and load the appropriate world file. """ self.ws_path = self.get_property("ws_path") # Workspace Path self.pkg_name = self.get_property("pkg_name") # ROS package name self.launch_file = self.get_property("launch_file") # ROS launch file name subprocess.Popen("sh /usr/local/bin/start_desktop.sh", shell=True) # Start the desktop time.sleep(5) # sleep for some seconds until the desktop is started self.alert("Building the ROS Workspace", "INFO") subprocess.run( "cd {} && . /opt/ros/melodic/setup.sh && catkin_make".format(self.ws_path), shell=True, ) # build the ROS workspace self.alert("Starting Gazebo", "INFO") subprocess.Popen( "vglrun bash -c 'source {}devel/setup.bash && roslaunch {} {}'".format( os.path.join(self.ws_path, ""), self.pkg_name, self.launch_file ), shell=True, ) #run the launch file