Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add path parameter #3

Merged
merged 3 commits into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions launch_param_builder/launch_param_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,9 @@ def parameter(self, parameter_name: str, parameter_value: ParameterValueType):
self._parameters[parameter_name] = parameter_value
return self

def path_parameter(self, parameter_name: str, file_path: str):
self._parameters[parameter_name] = str(self._package_path / file_path)
return self

def to_dict(self):
return self._parameters
5 changes: 4 additions & 1 deletion launch_param_builder/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from pathlib import Path
from typing import List, Union
import xacro

from ament_index_python.packages import get_package_share_directory

class ParameterBuilderFileNotFoundError(KeyError):
pass
Expand Down Expand Up @@ -80,3 +80,6 @@ def load_xacro(file_path: Path, mappings: dict = None):

file = xacro.process_file(file_path, mappings=mappings)
return file.toxml()

def get_path(package_name: str, file_path: str):
return str(Path(get_package_share_directory(package_name)) / file_path)