update bt_path param
This commit is contained in:
parent
c4cb3f2141
commit
ac265f74a3
4 changed files with 34 additions and 16 deletions
|
@ -1,10 +1,13 @@
|
|||
"""
|
||||
Launching interface node with connecting skills
|
||||
ROS 2 launch program for Robossembler
|
||||
```bash
|
||||
ros2 launch rbs_bt_executor bt_path:=</path/to/skills_json> mode:=benchmark
|
||||
|
||||
@shalenikol release 0.1
|
||||
@shalenikol release 0.2 mode
|
||||
@shalenikol release 0.3 {"bt_path": bt_path} # included as default path
|
||||
@shalenikol release 0.4 bt_path : either name of skills config file or path to default skills config file
|
||||
"""
|
||||
import os
|
||||
import json
|
||||
|
@ -17,15 +20,12 @@ from launch import LaunchDescription
|
|||
FILE_SKILLS = "skills.json"
|
||||
PARAM_SUFFIX = "_cfg"
|
||||
|
||||
def get_skill_list_(path: str) -> list:
|
||||
f = os.path.join(path, FILE_SKILLS)
|
||||
def get_skill_list(f: str) -> list:
|
||||
if not os.path.isfile(f):
|
||||
return []
|
||||
|
||||
with open(f, "r") as fh:
|
||||
data = json.load(fh)
|
||||
# str_data = fh.read()
|
||||
# data = json.loads(str_data)
|
||||
|
||||
nn_skills = 0
|
||||
excluding = {}
|
||||
|
@ -49,16 +49,17 @@ def launch_setup(context, *args, **kwargs):
|
|||
# Initialize Arguments
|
||||
bt_path = LaunchConfiguration("bt_path")
|
||||
bt_path = bt_path.perform(context)
|
||||
skills_cfg_file = bt_path if bt_path.endswith(".json") else os.path.join(bt_path, FILE_SKILLS)
|
||||
|
||||
mode = LaunchConfiguration("mode")
|
||||
mode = mode.perform(context)
|
||||
|
||||
skills = get_skill_list_(bt_path)
|
||||
skills = get_skill_list(skills_cfg_file)
|
||||
|
||||
rbs_interface = Node(
|
||||
package="rbs_bt_executor",
|
||||
executable="rbs_interface.py",
|
||||
parameters = [{"bt_path": bt_path},{"mode": mode},{"use_sim_time": True}]
|
||||
# parameters = [{"bt_path": bt_path}] # can be included as default path
|
||||
parameters = [{"bt_path": skills_cfg_file},{"mode": mode},{"use_sim_time": True}]
|
||||
)
|
||||
nodes_to_start = [rbs_interface]
|
||||
return nodes_to_start + skills
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue