Skip to content

Commit

Permalink
Improve workspace fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
civerachb-cpr committed Sep 9, 2024
1 parent c2d895f commit 76fbeaf
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions robot_upstart/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,18 @@ def __init__(self, name="ros", rmw=None, rmw_config=None, interface=None,
# Fall back on current user as the user to run ROS as.
self.user = user or getpass.getuser()

# Fall back on current workspace setup file if not explicitly specified.
self.workspace_setup = workspace_setup or \
os.environ['CMAKE_PREFIX_PATH'].split(':')[0] + '/../setup.bash'

# Fall back on current distro if not otherwise specified.
self.rosdistro = rosdistro or os.environ['ROS_DISTRO']

# Prioritize specified workspace, falling back to current workspace if possible, or
# system workspace as a last-resort
if workspace_setup:
self.workspace_setup = workspace_setup
elif 'CMAKE_PREFIX_PATH' in os.environ.keys():
self.workspace_setup = os.environ['CMAKE_PREFIX_PATH'].split(':')[0] + '/../setup.bash'
else:
self.workspace_setup = f'/opt/ros/{self.rosdistro}/setup.bash'

self.rmw = rmw or "rmw_fastrtps_cpp"

self.rmw_config = rmw_config or ""
Expand Down

0 comments on commit 76fbeaf

Please sign in to comment.