mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-28 02:36:37 +08:00
move get_absolute_path() back to generate_microRTPS_bridge.py
This commit is contained in:
@@ -55,6 +55,23 @@ except ImportError:
|
|||||||
"Failed to import yaml. You may need to install it with 'sudo pip install pyyaml'")
|
"Failed to import yaml. You may need to install it with 'sudo pip install pyyaml'")
|
||||||
|
|
||||||
|
|
||||||
|
def get_absolute_path(arg_parse_dir):
|
||||||
|
"""
|
||||||
|
Get absolute path from dir
|
||||||
|
"""
|
||||||
|
root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
|
if isinstance(arg_parse_dir, list):
|
||||||
|
dir = arg_parse_dir[0]
|
||||||
|
else:
|
||||||
|
dir = arg_parse_dir
|
||||||
|
|
||||||
|
if dir[0] != '/':
|
||||||
|
dir = root_path + "/" + dir
|
||||||
|
|
||||||
|
return dir
|
||||||
|
|
||||||
|
|
||||||
def check_rtps_id_uniqueness(classifier):
|
def check_rtps_id_uniqueness(classifier):
|
||||||
"""
|
"""
|
||||||
Checks if there are no ID's for different msgs repeated on the map
|
Checks if there are no ID's for different msgs repeated on the map
|
||||||
@@ -116,9 +133,9 @@ def check_rtps_id_uniqueness(classifier):
|
|||||||
", ".join('%d' % id for id in px_generate_uorb_topic_helper.check_available_ids(all_ids)))
|
", ".join('%d' % id for id in px_generate_uorb_topic_helper.check_available_ids(all_ids)))
|
||||||
|
|
||||||
|
|
||||||
default_client_out = px_generate_uorb_topic_helper.get_absolute_path(
|
default_client_out = get_absolute_path(
|
||||||
"src/modules/micrortps_bridge/micrortps_client")
|
"src/modules/micrortps_bridge/micrortps_client")
|
||||||
default_agent_out = px_generate_uorb_topic_helper.get_absolute_path(
|
default_agent_out = get_absolute_path(
|
||||||
"src/modules/micrortps_bridge/micrortps_agent")
|
"src/modules/micrortps_bridge/micrortps_agent")
|
||||||
default_uorb_templates_dir = "templates/uorb_microcdr"
|
default_uorb_templates_dir = "templates/uorb_microcdr"
|
||||||
default_urtps_templates_dir = "templates/urtps"
|
default_urtps_templates_dir = "templates/urtps"
|
||||||
@@ -167,7 +184,7 @@ if len(sys.argv) <= 1:
|
|||||||
|
|
||||||
# Parse arguments
|
# Parse arguments
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
msg_folder = px_generate_uorb_topic_helper.get_absolute_path(args.msgdir)
|
msg_folder = get_absolute_path(args.msgdir)
|
||||||
package = args.package
|
package = args.package
|
||||||
agent = args.agent
|
agent = args.agent
|
||||||
client = args.client
|
client = args.client
|
||||||
@@ -176,13 +193,13 @@ cmakelists = args.cmakelists
|
|||||||
del_tree = args.del_tree
|
del_tree = args.del_tree
|
||||||
px_generate_uorb_topic_files.append_to_include_path(
|
px_generate_uorb_topic_files.append_to_include_path(
|
||||||
{msg_folder}, px_generate_uorb_topic_files.INCL_DEFAULT, package)
|
{msg_folder}, px_generate_uorb_topic_files.INCL_DEFAULT, package)
|
||||||
agent_out_dir = px_generate_uorb_topic_helper.get_absolute_path(args.agentdir)
|
agent_out_dir = get_absolute_path(args.agentdir)
|
||||||
client_out_dir = px_generate_uorb_topic_helper.get_absolute_path(
|
client_out_dir = get_absolute_path(
|
||||||
args.clientdir)
|
args.clientdir)
|
||||||
gen_idl = args.gen_idl
|
gen_idl = args.gen_idl
|
||||||
idl_dir = args.idl_dir
|
idl_dir = args.idl_dir
|
||||||
if idl_dir != '':
|
if idl_dir != '':
|
||||||
idl_dir = px_generate_uorb_topic_helper.get_absolute_path(args.idl_dir)
|
idl_dir = get_absolute_path(args.idl_dir)
|
||||||
else:
|
else:
|
||||||
idl_dir = os.path.join(agent_out_dir, "idl")
|
idl_dir = os.path.join(agent_out_dir, "idl")
|
||||||
|
|
||||||
@@ -192,11 +209,11 @@ if args.fastrtpsgen is None or args.fastrtpsgen == "":
|
|||||||
else:
|
else:
|
||||||
# Path to fastrtpsgen is explicitly specified
|
# Path to fastrtpsgen is explicitly specified
|
||||||
fastrtpsgen_path = os.path.join(
|
fastrtpsgen_path = os.path.join(
|
||||||
px_generate_uorb_topic_helper.get_absolute_path(args.fastrtpsgen), "/fastrtpsgen")
|
get_absolute_path(args.fastrtpsgen), "/fastrtpsgen")
|
||||||
fastrtpsgen_include = args.fastrtpsgen_include
|
fastrtpsgen_include = args.fastrtpsgen_include
|
||||||
if fastrtpsgen_include is not None and fastrtpsgen_include != '':
|
if fastrtpsgen_include is not None and fastrtpsgen_include != '':
|
||||||
fastrtpsgen_include = "-I " + \
|
fastrtpsgen_include = "-I " + \
|
||||||
px_generate_uorb_topic_helper.get_absolute_path(
|
get_absolute_path(
|
||||||
args.fastrtpsgen_include) + " "
|
args.fastrtpsgen_include) + " "
|
||||||
|
|
||||||
# If nothing specified it's generated both
|
# If nothing specified it's generated both
|
||||||
|
|||||||
@@ -349,23 +349,6 @@ def print_field_def(field):
|
|||||||
array_size, comment))
|
array_size, comment))
|
||||||
|
|
||||||
|
|
||||||
def get_absolute_path(arg_parse_dir):
|
|
||||||
"""
|
|
||||||
Get absolute path from dir
|
|
||||||
"""
|
|
||||||
root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
||||||
|
|
||||||
if isinstance(arg_parse_dir, list):
|
|
||||||
dir = arg_parse_dir[0]
|
|
||||||
else:
|
|
||||||
dir = arg_parse_dir
|
|
||||||
|
|
||||||
if dir[0] != '/':
|
|
||||||
dir = root_path + "/" + dir
|
|
||||||
|
|
||||||
return dir
|
|
||||||
|
|
||||||
|
|
||||||
def check_available_ids(used_msg_ids_list):
|
def check_available_ids(used_msg_ids_list):
|
||||||
"""
|
"""
|
||||||
Checks the available RTPS ID's
|
Checks the available RTPS ID's
|
||||||
|
|||||||
Reference in New Issue
Block a user