-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DTSW-5002 Remapped gazebo camera topics
- Loading branch information
Showing
7 changed files
with
74 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" This script reads the `gazebo-bridge-config.yml` file and replaces the value of the `veh` | ||
key with the `VEH` environment variables. The string is of the format: | ||
`$(env veh)/virtual_camera_node` where the `env` keys are taken from the shell environment. """ | ||
|
||
import yaml | ||
import os | ||
import jinja2 | ||
|
||
# Read the environment variables | ||
file_name = "gazebo-bridge-config.yaml" | ||
|
||
def substitute_env_variables(file_name): | ||
env = jinja2.Environment(loader=jinja2.FileSystemLoader('/data/config')) | ||
template = env.get_template(file_name + '.j2') | ||
# Read the environment variables | ||
substitution_variables = {'veh': os.getenv('VEH')} | ||
|
||
env = jinja2.Environment(loader=jinja2.FileSystemLoader('/data/config')) | ||
template = env.get_template(file_name + '.j2') | ||
data = template.render(substitution_variables) | ||
|
||
with open(f"/data/config/{file_name}", 'w') as stream: | ||
try: | ||
# Parse the data as YAML | ||
yaml.dump(yaml.safe_load(data), stream) | ||
except yaml.YAMLError as exc: | ||
print(exc) | ||
|
||
substitute_env_variables("gazebo-bridge-config.yaml") |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
""" This script reads the `bridge.yml` file and replaces the value of the `topic` key in the first two elements of the list with a string that uses environment variables. The string is of the format: `$(env veh)/$(env ROBOT_HARDWARE)_camera_node` where the `env` keys are taken from the shell environment. """ | ||
|
||
import yaml | ||
import os | ||
import jinja2 | ||
|
||
# Read the environment variables | ||
file_name = 'bridge.yml' | ||
|
||
def substitute_env_variables(file_name): | ||
env = jinja2.Environment(loader=jinja2.FileSystemLoader('/data/config')) | ||
template = env.get_template(file_name + '.j2') | ||
# Read the environment variables | ||
substitution_variables = {'veh': os.getenv('VEH')} | ||
|
||
env = jinja2.Environment(loader=jinja2.FileSystemLoader('/data/config')) | ||
template = env.get_template(file_name + '.j2') | ||
data = template.render(substitution_variables) | ||
|
||
with open(f"/data/config/{file_name}", 'w') as stream: | ||
try: | ||
# Parse the data as YAML | ||
yaml.dump(yaml.safe_load(data), stream) | ||
except yaml.YAMLError as exc: | ||
print(exc) | ||
|
||
substitute_env_variables(file_name) |
This file contains 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 characters