update bt_path param

This commit is contained in:
shalenikol 2025-05-16 11:15:29 +03:00
parent c4cb3f2141
commit ac265f74a3
4 changed files with 34 additions and 16 deletions

View file

@ -8,6 +8,7 @@
@shalenikol release 0.3 synchronize
@shalenikol release 0.4 mode:="benchmark"
@shalenikol release 0.5 bt_path # included as default path (in __init__)
@shalenikol release 0.6
"""
import os
import json
@ -40,12 +41,14 @@ SERVER_NAME = "rbs_interface_a"
FILE_SKILLS = "skills.json"
PARAM_SUFFIX = "_cfg"
KEY_BTPARAM = "BTAction"
KEY_SIDPATH = "@path@" # prefix for filepath
class rbsInterface(Node):
def __init__(self, node_name):
"""Construct the node."""
# self.bt_path = "" # path to the current BehaviorTree
# self._mode = "" # run mode of the interface node
self.file_skills = FILE_SKILLS
self.cfg_data = None # config for current action
super().__init__(node_name)
self.declare_parameter(BT_PARAM, rclpy.Parameter.Type.STRING)
@ -62,7 +65,7 @@ class rbsInterface(Node):
# self.client = AsyncParameterClient(self.client_node, 'test_parameter_client_target') # only Iron
self.add_on_set_parameters_callback(self._on_set_btpath_param)
def get_transfer_path(self):
def get_skillcfg_file(self):
if self.bt_path:
return self.bt_path
return os.path.join(get_package_share_directory("rbs_bt_executor"), "config")
@ -119,9 +122,12 @@ class rbsInterface(Node):
assert False, f"Error: sid not valid '{sid}'"
def _load_config(self, sid: str):
p = os.path.join(self.get_transfer_path(), FILE_SKILLS) # action+".json")
if sid.startswith(KEY_SIDPATH):
p = sid[len(KEY_SIDPATH):]
else:
p = self.get_skillcfg_file() #os.path.join(self.get_transfer_path(), self.file_skills)
# load config
return self._deserialize(p,sid)
return self._deserialize(p, sid)
def run_action(self, command_data: dict) -> bool:
p_list = command_data["param"]