united rbs_interface with rbs_bt_executor

This commit is contained in:
shalenikol 2024-09-24 18:02:35 +03:00 committed by Bill Finger
parent 910232983c
commit 6ea2eefc42
12 changed files with 39 additions and 139 deletions

@ -0,0 +1 @@
Subproject commit 997acf2a9353b0015523577b1525579590dce3fb

View file

@ -6,6 +6,8 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_python REQUIRED)
find_package(rclpy REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(geometry_msgs REQUIRED)
@ -17,6 +19,7 @@ find_package(ament_index_cpp REQUIRED)
find_package(rbs_skill_interfaces REQUIRED)
# find_package(behavior_tree REQUIRED)
find_package(behaviortree_ros2 REQUIRED)
find_package(behaviortree_cpp REQUIRED)
find_package(control_msgs REQUIRED)
find_package(lifecycle_msgs REQUIRED)
find_package(rcl_interfaces REQUIRED)
@ -41,6 +44,7 @@ set(dependencies
rbs_skill_interfaces
# behavior_tree
behaviortree_ros2
btcpp_ros2_interfaces
control_msgs
lifecycle_msgs
rcl_interfaces
@ -85,11 +89,14 @@ list(APPEND plugin_libs rbs_skill_move_topose_array_bt_action_client)
add_library(rbs_get_workspace SHARED src/GetWorkspace.cpp)
list(APPEND plugin_libs rbs_get_workspace)
add_library(rbs_act SHARED src/rbsBTAction.cpp)
list(APPEND plugin_libs rbs_act)
add_executable(rbs_bt_executor src/TreeRunner.cpp)
ament_target_dependencies(rbs_bt_executor ${dependencies})
add_library(rbs_act SHARED src/rbsBTAction.cpp)
list(APPEND plugin_libs rbs_act)
add_executable(bt_exec src/BTExec.cpp)
ament_target_dependencies(bt_exec ${dependencies})
foreach(bt_plugin ${plugin_libs})
ament_target_dependencies(${bt_plugin} ${dependencies})
@ -98,7 +105,7 @@ endforeach()
install(DIRECTORY launch bt_trees config DESTINATION share/${PROJECT_NAME})
# INSTAL PLUGIN TARGETS https://github.com/BehaviorTree/BehaviorTree.CPP/pull/804
# INSTALL PLUGIN TARGETS https://github.com/BehaviorTree/BehaviorTree.CPP/pull/804
install(TARGETS
${plugin_libs}
ARCHIVE DESTINATION share/${PROJECT_NAME}/bt_plugins
@ -106,14 +113,22 @@ install(TARGETS
RUNTIME DESTINATION share/${PROJECT_NAME}/bt_plugins
)
install(TARGETS
rbs_bt_executor
rbs_bt_executor bt_exec
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION lib/${PROJECT_NAME}
)
# Install Python modules
ament_python_install_package(${PROJECT_NAME})
# Install Python executables
install(PROGRAMS
scripts/rbs_interface.py
scripts/bt_param.py
DESTINATION lib/${PROJECT_NAME}
)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)

View file

@ -3,15 +3,11 @@
"name": "Robossembler", "version": "1.0", "format": "1"
},
"Module": {
"name": "Interface", "description": "Interface node for the Robossembler skills"
"name": "Interface", "description": "Interface node for the Robossembler skills", "node_name": "rbs_interface"
},
"Launch": {
"package": "rbs_interface",
"package": "rbs_bt_executor",
"executable": "rbs_interface.py",
"param": ["bt_path"]
},
"ROS2": {
"node_name": "rbs_interface", "comment": "!!! no change !!!"
},
"Settings": []
}
}

View file

@ -51,7 +51,7 @@ def launch_setup(context, *args, **kwargs):
skills = get_skill_list_(bt_path)
rbs_interface = Node(
package="rbs_interface",
package="rbs_bt_executor",
executable="rbs_interface.py",
# parameters = [{"bt_path": bt_path}] # can be included as default path
)

View file

@ -5,50 +5,37 @@
@shalenikol release 0.1
@shalenikol release 0.2 BT v.4
"""
import os
# import json
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import DeclareLaunchArgument, OpaqueFunction, RegisterEventHandler
from launch.substitutions import LaunchConfiguration
from launch.event_handlers import OnExecutionComplete
# FILE_BT = "bt.xml"
def launch_setup(context, *args, **kwargs):
# Initialize Arguments
bt_path = LaunchConfiguration("bt_path")
bt_path = bt_path.perform(context)
# rbs_bt = Node(
# package = "behavior_tree",
# executable = "bt_engine",
# package = "rbs_bt_executor",
# executable = "rbs_bt_executor",
# parameters = [
# {"bt_file_path": os.path.join(bt_path, FILE_BT)},
# {"plugins": ["rbs_interface"]}
# {
# "plugins": ["rbs_bt_executor/bt_plugins"]
# # "behavior_trees": [bt_path]
# }
# ]
# )
rbs_bt = Node(
package = "rbs_bt_executor",
executable = "rbs_bt_executor",
parameters = [
{
"plugins": ["rbs_bt_executor/bt_plugins"]
# "behavior_trees": [bt_path]
}
]
)
bt_exec = Node(
package="rbs_interface",
package="rbs_bt_executor",
executable="bt_exec",
arguments=[bt_path]
# prefix=['gdbserver localhost:3000'],
)
bt_param = Node(
package="rbs_interface",
package="rbs_bt_executor",
executable="bt_param.py",
parameters=[{"bt_path": bt_path}]
)

View file

@ -8,10 +8,14 @@
<license>TODO: License declaration</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ament_cmake_python</buildtool_depend>
<depend>rclpy</depend>
<depend>rbs_utils</depend>
<depend>rbs_skill_interfaces</depend>
<depend>env_manager_interfaces</depend>
<depend>behaviortree_ros2</depend>
<depend>behaviortree_cpp</depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

View file

@ -23,11 +23,9 @@ from lifecycle_msgs.srv import ChangeState, GetState
from lifecycle_msgs.msg import Transition, State
from rbs_skill_interfaces.srv import RbsBt
from rbs_skill_interfaces.action import RbsBt as RbsBtAction
# from btcpp_ros2_interfaces.action import ExecuteTree
# from rclpy.parameter_client import AsyncParameterClient # only Iron
# BT_SERVER = "bt_execution"
CONDITION_SRV_NAME = "/condition"
BT_PARAM = "bt_path"
NODE_NAME = "rbs_interface"
@ -35,7 +33,7 @@ SERVICE_NAME = "rbs_interface_s"
SERVER_NAME = "rbs_interface_a"
FILE_SKILLS = "skills.json"
PARAM_SUFFIX = "_cfg"
KEY_BTPARAM = "BTAction" # TODO "bt_param"
KEY_BTPARAM = "BTAction"
class rbsInterface(Node):
def __init__(self, node_name):
@ -50,7 +48,6 @@ class rbsInterface(Node):
self._service = self.create_service(RbsBt, SERVICE_NAME, self.service_callback, callback_group=self.cb_group)
# for Action
self._action = ActionServer(self, RbsBtAction, SERVER_NAME, self.action_callback, callback_group=self.cb_group)
# self.bt_client = ActionClient(self, ExecuteTree, BT_SERVER, callback_group=self.cb_group)
# self.client = AsyncParameterClient(self.client_node, 'test_parameter_client_target') # only Iron
self.add_on_set_parameters_callback(self._on_set_btpath_param)
@ -58,7 +55,7 @@ class rbsInterface(Node):
def get_transfer_path(self):
if self.bt_path:
return self.bt_path
return os.path.join(get_package_share_directory("rbs_interface"), "config")
return os.path.join(get_package_share_directory("rbs_bt_executor"), "config")
def _on_set_btpath_param(self, parameter_list):
for parameter in parameter_list:
@ -95,7 +92,6 @@ class rbsInterface(Node):
self.executor.spin_until_future_complete(future)
res = future.result()
# self.get_logger().info(f"{res}")
return res.results[0].successful
def _deserialize(self, file_path: str, sid: str):
@ -108,7 +104,6 @@ class rbsInterface(Node):
if skill["sid"] == sid:
return skill
assert False, f"Error: sid not valid '{sid}'"
# return {"result": f"Error: sid not valid '{sid}'"}
def _load_config(self, sid: str):
p = os.path.join(self.get_transfer_path(), FILE_SKILLS) # action+".json")

View file

@ -1,70 +0,0 @@
cmake_minimum_required(VERSION 3.8)
project(rbs_interface)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_python REQUIRED)
find_package(rclpy REQUIRED)
find_package(rclcpp REQUIRED)
find_package(image_transport REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(rbs_skill_interfaces REQUIRED)
find_package(PCL 1.12 REQUIRED)
find_package(pcl_conversions REQUIRED)
find_package(pcl_ros REQUIRED)
# find_package(tf2_ros REQUIRED)
# find_package(tf2_msgs REQUIRED)
find_package(visualization_msgs REQUIRED)
find_package(behaviortree_ros2 REQUIRED)
find_package(btcpp_ros2_interfaces REQUIRED)
# Install Python modules
ament_python_install_package(${PROJECT_NAME})
# Install Python executables
install(PROGRAMS
scripts/rbs_interface.py
scripts/bt_param.py
DESTINATION lib/${PROJECT_NAME}
)
set(THIS_PACKAGE_DEPS
rbs_skill_interfaces
behaviortree_ros2
# std_msgs
# std_srvs
btcpp_ros2_interfaces )
add_executable(bt_exec src/BTExec.cpp)
ament_target_dependencies(bt_exec ${THIS_PACKAGE_DEPS})
install(TARGETS
bt_exec
DESTINATION lib/${PROJECT_NAME}
)
install(
DIRECTORY launch config
DESTINATION share/${PROJECT_NAME}
)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# comment the line when a copyright and license is added to all source files
set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# comment the line when this package is in a git repo and when
# a copyright and license is added to all source files
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()
ament_package()

View file

@ -1,28 +0,0 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>rbs_interface</name>
<version>0.0.1</version>
<description>The interface node</description>
<maintainer email="shaniks77s@gmail.com">shalenikol</maintainer>
<license>Apache License 2.0</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ament_cmake_python</buildtool_depend>
<depend>rclpy</depend>
<depend>rclcpp</depend>
<depend>image_transport</depend>
<depend>cv_bridge</depend>
<depend>sensor_msgs</depend>
<depend>std_msgs</depend>
<depend>rbs_skill_interfaces</depend>
<depend>behaviortree_ros2</depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>