Skip to main content
edited body
Source Link

Using this in launch backends helps with conditional statements tied in with launch file generation that are not intrinsic properties of the sub-launch files themselves (i.e.g. how many launch files are you spawning).
In nodes, this allows your nodes to access configurations rather than node parameters, according to the distinction made in the previously given answer
Hope this helps anyone else who is stumped!

Using this in launch backends helps with conditional statements tied in with launch file generation that are not intrinsic properties of the sub-launch files themselves (i.e. how many launch files are you spawning).
In nodes, this allows your nodes to access configurations rather than node parameters, according to the distinction made in the previously given answer
Hope this helps anyone else who is stumped!

Using this in launch backends helps with conditional statements tied in with launch file generation that are not intrinsic properties of the sub-launch files themselves (e.g. how many launch files are you spawning).
In nodes, this allows your nodes to access configurations rather than node parameters, according to the distinction made in the previously given answer
Hope this helps anyone else who is stumped!

added 8 characters in body
Source Link
import yaml
from ament_index_python.packages import get_package_share_directory
...
share_dir = get_package_share_directory(PKG_NAME) # modify this accordingly
fname = share_dir + f"/config/load_params.yaml" # use os.path.join if you want
with open(fname, 'r') as file:
  configs = yaml.safe_load(file)
# # note that you will most likely extract a field as the following
# # or, using ['<ns>/<node>'] instead of ['/**'] 
# # you can also simply discard the typical ros2 param syntax 
# # # if you won't use any of the fields in a parameter declaration
# config_field = configs['/**']['ros__parameters']['field_name']
import yaml
from ament_index_python.packages import get_package_share_directory
...
share_dir = get_package_share_directory(PKG_NAME) # modify this accordingly
fname = share_dir + f"/config/load_params.yaml" # use os.path.join if you want
with open(fname, 'r') as file:
  configs = yaml.safe_load(file)
# # note that you will most likely extract a field as the following
# # or, using ['<ns>/<node>'] instead of ['/**'] 
# # you can also simply discard the typical ros2 param syntax if you won't use any of the fields in a parameter declaration
# config_field = configs['/**']['ros__parameters']['field_name']
import yaml
from ament_index_python.packages import get_package_share_directory
...
share_dir = get_package_share_directory(PKG_NAME) # modify this accordingly
fname = share_dir + f"/config/load_params.yaml" # use os.path.join if you want
with open(fname, 'r') as file:
  configs = yaml.safe_load(file)
# # note that you will most likely extract a field as the following
# # or, using ['<ns>/<node>'] instead of ['/**'] 
# # you can also simply discard the typical ros2 param syntax 
# # # if you won't use any of the fields in a parameter declaration
# config_field = configs['/**']['ros__parameters']['field_name']
added 125 characters in body
Source Link
import yaml
from ament_index_python.packages import get_package_share_directory
...
share_dir = get_package_share_directory(PKG_NAME) # modify this accordingly
fname = share_dir + f"/config/load_params.yaml" # use os.path.join if you want
with open(fname, 'r') as file:
  configs = yaml.safe_load(file)
# # note that you will most likely extract a field as the following
# # or, using ['<ns>/<node>'] instead of ['/**'] 
# # you can also simply discard the typical ros2 param syntax if you won't use any of the fields in a parameter declaration
# config_field = configs['/**']['ros__parameters']['field_name']
import yaml
from ament_index_python.packages import get_package_share_directory
...
share_dir = get_package_share_directory(PKG_NAME) # modify this accordingly
fname = share_dir + f"/config/load_params.yaml" # use os.path.join if you want
with open(fname, 'r') as file:
  configs = yaml.safe_load(file)
# # note that you will most likely extract a field as the following
# # or, using ['<ns>/<node>'] instead of ['/**'] 
# config_field = configs['/**']['ros__parameters']['field_name']
import yaml
from ament_index_python.packages import get_package_share_directory
...
share_dir = get_package_share_directory(PKG_NAME) # modify this accordingly
fname = share_dir + f"/config/load_params.yaml" # use os.path.join if you want
with open(fname, 'r') as file:
  configs = yaml.safe_load(file)
# # note that you will most likely extract a field as the following
# # or, using ['<ns>/<node>'] instead of ['/**'] 
# # you can also simply discard the typical ros2 param syntax if you won't use any of the fields in a parameter declaration
# config_field = configs['/**']['ros__parameters']['field_name']
Source Link
Loading