mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 06:03:34 +08:00
move parse_yaml_msg_id_file() definition to generate_microRTPS_bridge.py
This commit is contained in:
@@ -47,6 +47,11 @@ import px_generate_uorb_topic_helper
|
||||
import subprocess
|
||||
import glob
|
||||
import errno
|
||||
try:
|
||||
import yaml
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"Failed to import yaml. You may need to install it with 'sudo pip install pyyaml'")
|
||||
|
||||
|
||||
def get_absolute_path(arg_parse_dir):
|
||||
@@ -63,6 +68,20 @@ def get_absolute_path(arg_parse_dir):
|
||||
return dir
|
||||
|
||||
|
||||
def parse_yaml_msg_id_file(yaml_file):
|
||||
"""
|
||||
Parses a yaml file into a dict
|
||||
"""
|
||||
try:
|
||||
with open(yaml_file, 'r') as f:
|
||||
return yaml.load(f)
|
||||
except OSError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
raise IOError(errno.ENOENT, os.strerror(errno.ENOENT), yaml_file)
|
||||
else:
|
||||
raise
|
||||
|
||||
|
||||
default_client_out = get_absolute_path(
|
||||
"src/modules/micrortps_bridge/micrortps_client")
|
||||
default_agent_out = get_absolute_path(
|
||||
@@ -186,8 +205,7 @@ if agent and os.path.isdir(os.path.join(agent_out_dir, "idl")):
|
||||
uorb_templates_dir = os.path.join(msg_folder, args.uorb_templates)
|
||||
urtps_templates_dir = os.path.join(msg_folder, args.urtps_templates)
|
||||
# parse yaml file into a map of ids
|
||||
rtps_ids = px_generate_uorb_topic_helper.parse_yaml_msg_id_file(
|
||||
os.path.join(msg_folder, args.yaml_file))
|
||||
rtps_ids = parse_yaml_msg_id_file(os.path.join(msg_folder, args.yaml_file))
|
||||
|
||||
|
||||
uRTPS_CLIENT_TEMPL_FILE = 'microRTPS_client.cpp.template'
|
||||
|
||||
Reference in New Issue
Block a user