Skip to content

Commit

Permalink
Merge pull request #57 from JdeRobot/issue-56
Browse files Browse the repository at this point in the history
Xserver starts before Gazebo
  • Loading branch information
ReyDoran authored Jul 19, 2023
2 parents 19c7a4b + 0c4cd8f commit 31a90af
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions manager/manager/launcher/launcher_ros_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import time
from typing import List, Any
from src.manager.manager.docker_thread.docker_thread import DockerThread
import roslaunch
import rospy

Expand Down Expand Up @@ -28,6 +29,7 @@ class LauncherRosApi(ILauncher):
plugin_folders: List[str]
parameters: List[str]
launch_file: str
threads: List[Any] = []

# holder for roslaunch process
launch: Any = None
Expand All @@ -36,6 +38,13 @@ class LauncherRosApi(ILauncher):
def run(self, callback: callable = None):
logging.getLogger("roslaunch").setLevel(logging.CRITICAL)

# Start X server in display
xserver_cmd = f"/usr/bin/Xorg -quiet -noreset +extension GLX +extension RANDR +extension RENDER -logfile ./xdummy.log -config ./xorg.conf :0"
xserver_thread = DockerThread(xserver_cmd)
xserver_thread.start()
self.threads.append(xserver_thread)
time.sleep(1)

# expand variables in configuration paths
self._set_environment()
launch_file = os.path.expandvars(self.launch_file)
Expand Down Expand Up @@ -63,6 +72,9 @@ def wait_for_shutdown(self, timeout=30):

def terminate(self):
try:
for thread in self.threads:
thread.terminate()
thread.join()
self.launch.shutdown()
self.wait_for_shutdown()
except roslaunch.RLException:
Expand Down

0 comments on commit 31a90af

Please sign in to comment.