├── fkie_behavior_tree_manager
├── .gitignore
├── scripts
│ └── run_groot.sh
├── config
│ ├── dummy_nav_tree.xml
│ └── bt_default.yaml
├── launch
│ └── behavior_tree.launch
├── src
│ ├── BehaviorTreeNodes.cpp
│ ├── behavior_tree_manager_node.cpp
│ ├── BehaviorTreeManager.h
│ └── BehaviorTreeParameters.hpp
├── package.xml
├── cmake
│ └── FindZMQ.cmake
├── include
│ └── fkie_behavior_tree_manager
│ │ ├── conditions
│ │ ├── checkBooleanPort.hpp
│ │ ├── ValidPose.hpp
│ │ ├── checkCommand.hpp
│ │ ├── CheckTimeoutAsync.hpp
│ │ ├── GenericMsgReceived.hpp
│ │ ├── BoolCondition.hpp
│ │ ├── TFTransformCondition.hpp
│ │ ├── PoseReceived.hpp
│ │ ├── PoseStampedReceived.hpp
│ │ ├── TFTransformAsyncCondition.hpp
│ │ └── CheckPoseReachedAsync.hpp
│ │ ├── actions
│ │ ├── DelayAction.hpp
│ │ ├── PoseStampedToPose2D.hpp
│ │ ├── ServiceEmptyAction.hpp
│ │ ├── PublishPathAction.hpp
│ │ ├── PublishPoseAction.hpp
│ │ ├── PublishPoseStampedAction.hpp
│ │ ├── BoolAction.hpp
│ │ ├── Relative3DPoseAction.hpp
│ │ └── WaitForGenericMsgAsyncAction.hpp
│ │ ├── loggers
│ │ └── RosMsgLogger.hpp
│ │ ├── decorators
│ │ ├── RunOnlyOnce.hpp
│ │ ├── ConditionalLoop.hpp
│ │ ├── CommandTrigger.hpp
│ │ ├── CommandSwitch.hpp
│ │ └── RateController.hpp
│ │ ├── utils.hpp
│ │ └── BTPublisherRosSingleton.hpp
└── CMakeLists.txt
├── fkie_bt_move_base_actions
├── .gitignore
├── msg
│ └── NavigationResult.msg
├── config
│ ├── tree_move_base_parallel.xml
│ └── tree_move_base_simple.xml
├── src
│ ├── MoveBaseActions.cpp
│ ├── MoveBaseUtils.h
│ ├── Recovery.h
│ ├── NavigateToGoal.h
│ ├── CancelExePathSync.h
│ ├── NavigateToGoalSync.h
│ ├── CancelExePathSync.cpp
│ ├── GetPath.h
│ ├── MoveBaseActions.h
│ ├── ExePathAsync.h
│ ├── ExePathSync.h
│ ├── Recovery.cpp
│ ├── NotifyNavigationResult.h
│ ├── NavigateToGoalSync.cpp
│ └── NavigateToGoal.cpp
├── package.xml
└── CMakeLists.txt
├── fkie_behavior_tree_msgs
├── msg
│ ├── BTLogging.msg
│ ├── BTStatus.msg
│ └── BTNodeStatus.msg
├── CMakeLists.txt
└── package.xml
├── fkie_bt_moveit_actions
├── config
│ ├── bt_moveit_demo.yaml
│ ├── bt_moveit_default.yaml
│ ├── trees
│ │ ├── tree_moveit_simple.xml
│ │ └── tree_moveit_demo.xml
│ └── bt_default.yaml
├── src
│ ├── MoveitActions.cpp
│ └── MoveitActions.h
├── package.xml
├── CMakeLists.txt
└── include
│ └── fkie_bt_moveit_actions
│ └── MoveitErrorCodeInterface.hpp
├── fkie_behavior_trees
├── CMakeLists.txt
└── package.xml
├── fkie_bt_visualization
├── plugin_description.xml
├── package.xml
├── CMakeLists.txt
├── src
│ ├── rviz_bt_logger.h
│ ├── rviz_bt_status.h
│ └── randomcolor
│ │ └── randomcolor.h
└── include
│ └── fkie_bt_visualization
│ └── TreeItem.hpp
├── fkie_bt_tutorials
├── config
│ ├── hello_world_tree.xml
│ └── hello_world_config.yaml
├── launch
│ └── 1_hello_world_tutorial.launch
├── package.xml
├── src
│ ├── TutorialActions.cpp
│ └── TutorialActions.h
├── CMakeLists.txt
└── include
│ └── fkie_bt_tutorials
│ └── actions
│ └── HelloWorldAction.hpp
└── README.md
/fkie_behavior_tree_manager/.gitignore:
--------------------------------------------------------------------------------
1 | *.json
2 |
--------------------------------------------------------------------------------
/fkie_bt_move_base_actions/.gitignore:
--------------------------------------------------------------------------------
1 | *.json
2 |
--------------------------------------------------------------------------------
/fkie_behavior_tree_msgs/msg/BTLogging.msg:
--------------------------------------------------------------------------------
1 | Header header
2 | string source
3 | string level
4 | string data
--------------------------------------------------------------------------------
/fkie_behavior_tree_manager/scripts/run_groot.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | ~/ros/external/Groot/build/Groot --mode monitor
--------------------------------------------------------------------------------
/fkie_behavior_tree_msgs/msg/BTStatus.msg:
--------------------------------------------------------------------------------
1 | Header header
2 | string tree_file
3 | string tree_xml
4 | bool tree_is_running
--------------------------------------------------------------------------------
/fkie_bt_move_base_actions/msg/NavigationResult.msg:
--------------------------------------------------------------------------------
1 | Header header
2 | uint16 nav_error_code
3 | string origin
4 | string description
--------------------------------------------------------------------------------
/fkie_bt_moveit_actions/config/bt_moveit_demo.yaml:
--------------------------------------------------------------------------------
1 | MoveitActions:
2 | planning_group: "robot_arm"
3 | execute_trajectory: true
4 |
--------------------------------------------------------------------------------
/fkie_behavior_tree_msgs/msg/BTNodeStatus.msg:
--------------------------------------------------------------------------------
1 | Header header
2 | string node_name
3 | string node_type
4 | string node_id
5 | string node_status
--------------------------------------------------------------------------------
/fkie_bt_moveit_actions/config/bt_moveit_default.yaml:
--------------------------------------------------------------------------------
1 | MoveitActions:
2 | planning_group: "arm"
3 | execute_trajectory: false
4 | ExecuteWaypoints:
5 | radius: 0.5
6 | x_init: 0.4
7 | y_init: 0.0
8 | z_init: 1.0
--------------------------------------------------------------------------------
/fkie_bt_moveit_actions/config/trees/tree_moveit_simple.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/fkie_behavior_trees/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.0.2)
2 | project(fkie_behavior_trees)
3 |
4 | find_package(catkin REQUIRED COMPONENTS)
5 |
6 | catkin_package()
7 |
8 | ###########
9 | ## Build ##
10 | ###########
11 |
12 | include_directories(
13 | ${catkin_INCLUDE_DIRS}
14 | )
15 |
--------------------------------------------------------------------------------
/fkie_behavior_tree_manager/config/dummy_nav_tree.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/fkie_bt_moveit_actions/config/bt_default.yaml:
--------------------------------------------------------------------------------
1 | tree:
2 | static_xml: ""
3 | # static_file: ""
4 | rate: 10.0
5 |
6 | logging:
7 | #logger_type: "ZMQ_LOGGER"
8 | #logger_type: "MINITRACE_LOGGER"
9 | #logger_type: "STD_COUNT_LOGGER"
10 | file_logger_path: "bt_trace.fbl"
11 | minitrace_logger_path: "/home/garcia/Documents/logging/bt_trace.json"
12 | zmq_max_msg_per_second: 25
13 |
14 | action_plugins:
15 | ["libMoveitActions_dyn.so"]
16 |
--------------------------------------------------------------------------------
/fkie_behavior_tree_manager/launch/behavior_tree.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/fkie_bt_visualization/plugin_description.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | A panel widget to visualize the current execution state of a Behavior Tree
6 |
7 |
8 |
9 |
10 |
11 | A panel widget to visualize logs from Behavior Tree running nodes
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/fkie_behavior_tree_manager/config/bt_default.yaml:
--------------------------------------------------------------------------------
1 | tree:
2 | static_xml: ""
3 | # static_file: ""
4 | rate : 2.0
5 | start_tree_at_init: True
6 |
7 | logging:
8 | RosMsgLogger:
9 | enabled: true
10 | StdCoutLogger:
11 | enabled: false
12 | PublisherZMQ:
13 | enabled: true
14 | max_msg_per_second: 25
15 | publisher_port: 1666
16 | server_port: 1667
17 | FileLogger:
18 | enabled: false
19 | file_path: "bt_trace.fbl"
20 | MinitraceLogger:
21 | enabled: false
22 | file_path: "bt_trace.json"
23 |
24 | # logger_type: "ZMQ_LOGGER" # deprecated
25 |
26 | # Example of loading an action pluging
27 | #action_plugins:
28 | # ["libMoveBaseActions_dyn.so"]
29 |
30 |
31 |
--------------------------------------------------------------------------------
/fkie_behavior_tree_msgs/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.0.2)
2 | project(fkie_behavior_tree_msgs)
3 |
4 | find_package(catkin REQUIRED COMPONENTS roscpp std_msgs geometry_msgs message_generation message_runtime)
5 |
6 | ## Generate messages in the 'msg' folder
7 | add_message_files(
8 | FILES
9 | BTNodeStatus.msg
10 | BTStatus.msg
11 | BTLogging.msg
12 | )
13 |
14 | ## Generate added messages and services with any dependencies listed here
15 | generate_messages(
16 | DEPENDENCIES
17 | geometry_msgs
18 | std_msgs
19 | )
20 |
21 | catkin_package(
22 | CATKIN_DEPENDS geometry_msgs std_msgs message_runtime roscpp
23 | )
24 |
25 | include_directories(
26 | ${catkin_INCLUDE_DIRS}
27 | )
28 |
--------------------------------------------------------------------------------
/fkie_bt_visualization/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | fkie_bt_visualization
4 | 0.0.0
5 | The fkie_bt_visualization package
6 |
7 | Francisco Garcia
8 | Francisco Garcia
9 |
10 | Apache License 2.0
11 |
12 | catkin
13 |
14 | roscpp
15 | rviz
16 | fkie_behavior_tree_msgs
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/fkie_bt_moveit_actions/config/trees/tree_moveit_demo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/fkie_bt_tutorials/config/hello_world_tree.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/fkie_behavior_tree_msgs/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | fkie_behavior_tree_msgs
5 | 0.0.1
6 | Messages used for behavior tree interfaces
7 |
8 | Francisco Garcia
9 | Francisco Garcia
10 |
11 | Apache License 2.0
12 |
13 | catkin
14 |
15 | roscpp
16 | message_generation
17 | std_msgs
18 | geometry_msgs
19 | message_runtime
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/fkie_bt_tutorials/launch/1_hello_world_tutorial.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/fkie_bt_move_base_actions/config/tree_move_base_parallel.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/fkie_bt_tutorials/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | fkie_bt_tutorials
4 | 0.0.0
5 | Tutorial package for fkie_behavior_tree_manager
6 |
7 | Francisco Garcia
8 | Francisco Garcia
9 |
10 | Apache License 2.0
11 |
12 | catkin
13 |
14 | fkie_behavior_tree_manager
15 |
16 | roscpp
17 | rospy
18 | std_msgs
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/fkie_bt_tutorials/src/TutorialActions.cpp:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "TutorialActions.h"
16 |
17 | // This function must be implemented in the .cpp file to create
18 | // a plugin that can be loaded at run-time
19 | BT_REGISTER_NODES(factory)
20 | {
21 | BTTutorialGroup::RegisterNodes(factory);
22 | }
23 |
--------------------------------------------------------------------------------
/fkie_bt_moveit_actions/src/MoveitActions.cpp:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "MoveitActions.h"
16 |
17 | // This function must be implemented in the .cpp file to create
18 | // a plugin that can be loaded at run-time
19 | BT_REGISTER_NODES(factory)
20 | {
21 | MoveitActionsGroup::RegisterNodes(factory);
22 | }
23 |
--------------------------------------------------------------------------------
/fkie_behavior_tree_manager/src/BehaviorTreeNodes.cpp:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "BehaviorTreeNodes.h"
16 |
17 | // This function must be implemented in the .cpp file to create
18 | // a plugin that can be loaded at run-time
19 | BT_REGISTER_NODES(factory)
20 | {
21 | BehaviorTreeNodes::RegisterNodes(factory);
22 | }
--------------------------------------------------------------------------------
/fkie_bt_move_base_actions/src/MoveBaseActions.cpp:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "MoveBaseActions.h"
16 |
17 | // This function must be implemented in the .cpp file to create
18 | // a plugin that can be loaded at run-time
19 | BT_REGISTER_NODES(factory)
20 | {
21 | MoveBaseActionsGroup::RegisterNodes(factory);
22 | }
23 |
--------------------------------------------------------------------------------
/fkie_bt_tutorials/config/hello_world_config.yaml:
--------------------------------------------------------------------------------
1 | tree:
2 | rate: 5.0 # rate from main root tree
3 | start_tree_at_init: true # Defines if tree must run automatically or wait for start message
4 |
5 | # loggin examples
6 | logging:
7 | # RosMsgLogger: Send ros messages with current BT status
8 | RosMsgLogger:
9 | enabled: true
10 |
11 | # StdCoutLogger: print BT node transitions to the console
12 | StdCoutLogger:
13 | enabled: false
14 |
15 | # PublisherZMQ: allows us to use Groot as monitor tool
16 | PublisherZMQ:
17 | enabled: true
18 | max_msg_per_second: 25
19 | publisher_port: 1666
20 | server_port: 1667
21 |
22 | FileLogger:
23 | enabled: false
24 | file_path: "bt_trace.fbl"
25 |
26 | MinitraceLogger:
27 | enabled: false
28 | file_path: "bt_trace.json"
29 |
30 | # load required libraries:
31 | # Hint: we generate [TutorialActions_dyn] and we can use it as [libTutorialActions_dyn.so]
32 | action_plugins: ["libTutorialActions_dyn.so"]
33 |
--------------------------------------------------------------------------------
/fkie_behavior_trees/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | fkie_behavior_trees
4 | 0.0.0
5 | fkie_behavior_trees meta package
6 |
7 | Francisco Garcia
8 | Francisco Garcia
9 |
10 | Apache License 2.0
11 |
12 | catkin
13 |
14 | fkie_behavior_tree_msgs
15 | fkie_behavior_tree_manager
16 | fkie_bt_move_base_actions
17 | fkie_bt_moveit_actions
18 | fkie_bt_tutorials
19 | fkie_bt_visualization
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/fkie_behavior_tree_manager/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | fkie_behavior_tree_manager
4 | 0.0.0
5 | The fkie_behavior_tree_manager package
6 |
7 | Francisco Garcia
8 | Francisco Garcia
9 |
10 | Apache License 2.0
11 |
12 | catkin
13 |
14 | roscpp
15 | rospy
16 | std_msgs
17 | geometry_msgs
18 | nav_msgs
19 | behaviortree_cpp_v3
20 | tf
21 | topic_tools
22 | tf2_ros
23 | fkie_behavior_tree_msgs
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/fkie_bt_move_base_actions/config/tree_move_base_simple.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/fkie_bt_tutorials/src/TutorialActions.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef TUTORIAL_ACTIONS_H
16 | #define TUTORIAL_ACTIONS_H
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | #include "fkie_bt_tutorials/actions/HelloWorldAction.hpp"
24 |
25 | namespace BTTutorialGroup
26 | {
27 | inline void RegisterNodes(BT::BehaviorTreeFactory& factory)
28 | {
29 | // Register the action [HelloWorldAction] with the same name
30 | factory.registerNodeType("HelloWorldAction");
31 | }
32 | } // namespace BTTutorialGroup
33 |
34 | #endif // TUTORIAL_ACTIONS_H
--------------------------------------------------------------------------------
/fkie_bt_moveit_actions/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | fkie_bt_moveit_actions
4 | 0.0.0
5 | The fkie_bt_moveit_actions package
6 |
7 | Francisco Garcia
8 | Francisco Garcia
9 |
10 | Apache License 2.0
11 |
12 | catkin
13 |
14 | roscpp
15 | rospy
16 | std_msgs
17 | actionlib
18 | actionlib_msgs
19 | fkie_behavior_tree_manager
20 | pluginlib
21 | eigen
22 | moveit_core
23 | moveit_ros_planning
24 | moveit_ros_planning_interface
25 | moveit_ros_perception
26 | geometric_shapes
27 | moveit_visual_tools
28 | tf2_ros
29 | tf2_eigen
30 | tf2_geometry_msgs
31 | tf_conversions
32 | tf
33 | eigen_conversions
34 |
35 | behaviortree_cpp_v3
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/fkie_bt_tutorials/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.0.2)
2 | project(fkie_bt_tutorials)
3 |
4 | find_package(catkin REQUIRED COMPONENTS
5 | fkie_behavior_tree_manager
6 | )
7 |
8 | find_package(BehaviorTreeV3)
9 |
10 | catkin_package(
11 | CATKIN_DEPENDS fkie_behavior_tree_manager
12 | )
13 |
14 | include_directories(
15 | include
16 | ${catkin_INCLUDE_DIRS}
17 | ${CMAKE_CURRENT_SOURCE_DIR}
18 | )
19 |
20 | ###########
21 | ## Build ##
22 | ###########
23 |
24 | # static
25 | add_library(TutorialActions STATIC src/TutorialActions.cpp )
26 | target_link_libraries(TutorialActions PRIVATE ${catkin_LIBRARIES} BT::behaviortree_cpp_v3)
27 | set_target_properties(TutorialActions PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} )
28 | target_compile_features(TutorialActions PRIVATE cxx_std_17)
29 |
30 | # plugin
31 | add_library(TutorialActions_dyn SHARED src/TutorialActions.cpp )
32 | target_link_libraries(TutorialActions_dyn PRIVATE ${catkin_LIBRARIES} BT::behaviortree_cpp_v3)
33 | target_compile_definitions(TutorialActions_dyn PRIVATE BT_PLUGIN_EXPORT)
34 | set_target_properties(TutorialActions_dyn PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} )
35 | target_compile_features(TutorialActions_dyn PRIVATE cxx_std_17)
36 |
37 | #############
38 | ## Install ##
39 | #############
40 |
41 | install(
42 | TARGETS TutorialActions TutorialActions_dyn
43 | ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
44 | LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
45 | RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
46 | )
--------------------------------------------------------------------------------
/fkie_behavior_tree_manager/cmake/FindZMQ.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find ZMQ
2 | # Once done this will define
3 | #
4 | # ZMQ_FOUND - system has ZMQ
5 | # ZMQ_INCLUDE_DIRS - the ZMQ include directory
6 | # ZMQ_LIBRARIES - Link these to use ZMQ
7 | # ZMQ_DEFINITIONS - Compiler switches required for using ZMQ
8 | #
9 | # Copyright (c) 2011 Lee Hambley
10 | #
11 | # Redistribution and use is allowed according to the terms of the New
12 | # BSD license.
13 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
14 | #
15 |
16 | if (ZMQ_LIBRARIES AND ZMQ_INCLUDE_DIRS)
17 | # in cache already
18 | set(ZMQ_FOUND TRUE)
19 | else (ZMQ_LIBRARIES AND ZMQ_INCLUDE_DIRS)
20 |
21 | find_path(ZMQ_INCLUDE_DIR
22 | NAMES
23 | zmq.h
24 | PATHS
25 | /usr/include
26 | /usr/local/include
27 | /opt/local/include
28 | )
29 |
30 | find_library(ZMQ_LIBRARY
31 | NAMES
32 | zmq
33 | PATHS
34 | /usr/lib
35 | /usr/local/lib
36 | /opt/local/lib
37 | /sw/lib
38 | )
39 |
40 | set(ZMQ_INCLUDE_DIRS
41 | ${ZMQ_INCLUDE_DIR}
42 | )
43 |
44 | if (ZMQ_LIBRARY)
45 | set(ZMQ_LIBRARIES
46 | ${ZMQ_LIBRARIES}
47 | ${ZMQ_LIBRARY}
48 | )
49 | endif (ZMQ_LIBRARY)
50 |
51 | include(FindPackageHandleStandardArgs)
52 | find_package_handle_standard_args(ZMQ DEFAULT_MSG ZMQ_LIBRARIES ZMQ_INCLUDE_DIRS)
53 |
54 | # show the ZMQ_INCLUDE_DIRS and ZMQ_LIBRARIES variables only in the advanced view
55 | mark_as_advanced(ZMQ_INCLUDE_DIRS ZMQ_LIBRARIES)
56 |
57 | endif (ZMQ_LIBRARIES AND ZMQ_INCLUDE_DIRS)
58 |
59 |
--------------------------------------------------------------------------------
/fkie_behavior_tree_manager/include/fkie_behavior_tree_manager/conditions/checkBooleanPort.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef CHECK_BOOLEAN_PORT_H
16 | #define CHECK_BOOLEAN_PORT_H
17 |
18 | #include
19 |
20 | #include "behaviortree_cpp_v3/behavior_tree.h"
21 | #include "behaviortree_cpp_v3/bt_factory.h"
22 |
23 | #include
24 | #include
25 |
26 | namespace BehaviorTreeNodes
27 | {
28 | BT::NodeStatus CheckBooleanPort(BT::TreeNode& self)
29 | {
30 | bool port_value = false;
31 | bool success_value = false;
32 |
33 | auto res = self.getInput("port_value", port_value);
34 | if (!res)
35 | {
36 | BT_ROS_ERROR_STREAM(self.name() << " Error at reading [port_value]: " << res.error());
37 | return BT::NodeStatus::FAILURE;
38 | }
39 |
40 | res = self.getInput("success_value", success_value);
41 | if (!res)
42 | {
43 | BT_ROS_ERROR_STREAM(self.name() << " Error at reading [success_value]: " << res.error());
44 | return BT::NodeStatus::FAILURE;
45 | }
46 |
47 | if (port_value == success_value)
48 | return BT::NodeStatus::SUCCESS;
49 | else
50 | return BT::NodeStatus::FAILURE;
51 | };
52 |
53 | } // namespace BehaviorTreeNodes
54 |
55 | #endif // CHECK_BOOLEAN_PORT_H
--------------------------------------------------------------------------------
/fkie_bt_move_base_actions/src/MoveBaseUtils.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef MOVE_BASE_SIMPLE_ACTIONS_H
16 | #define MOVE_BASE_SIMPLE_ACTIONS_H
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | #include
24 | #include
25 | #include
26 |
27 | #include "behaviortree_cpp_v3/behavior_tree.h"
28 | #include "behaviortree_cpp_v3/blackboard.h"
29 | #include "behaviortree_cpp_v3/bt_factory.h"
30 | #include "behaviortree_cpp_v3/xml_parsing.h"
31 |
32 | #include
33 | #include
34 |
35 | #include
36 |
37 | typedef actionlib::SimpleActionClient ClientUtilsExePathAction;
38 |
39 | namespace MoveBaseActionsGroup
40 | {
41 | BT::NodeStatus moveBaseHeartbeat(BT::TreeNode& self);
42 |
43 | BT::NodeStatus newTargetPoseReceived(BT::TreeNode& self);
44 |
45 | BT::NodeStatus CancelCurrentPoseAction(BT::TreeNode& self);
46 |
47 | BT::NodeStatus hasValidGoal(BT::TreeNode& self);
48 |
49 | } // namespace MoveBaseActionsGroup
50 |
51 | #endif // MOVE_BASE_SIMPLE_ACTIONS_H
--------------------------------------------------------------------------------
/fkie_behavior_tree_manager/include/fkie_behavior_tree_manager/conditions/ValidPose.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef VALID_POSE_H
16 | #define VALID_POSE_H
17 |
18 | #include
19 | #include
20 |
21 | #include "behaviortree_cpp_v3/behavior_tree.h"
22 | #include "behaviortree_cpp_v3/bt_factory.h"
23 |
24 | #include
25 | #include
26 |
27 | namespace BehaviorTreeNodes
28 | {
29 | BT::NodeStatus ValidPose(BT::TreeNode& self)
30 | {
31 | Pose2D target_pose;
32 | auto res = self.getInput("target_pose", target_pose);
33 | if (!res)
34 | {
35 | self.setOutput("target_pose", Pose2D());
36 | return BT::NodeStatus::FAILURE;
37 | }
38 |
39 | if (target_pose.frame_id.empty())
40 | {
41 | BT_ROS_WARN_STREAM(self.name() << ": Frame_id is empty, returning Failure");
42 | return BT::NodeStatus::FAILURE;
43 | }
44 |
45 | if (!std::isfinite(target_pose.x) || !std::isfinite(target_pose.y))
46 | {
47 | BT_ROS_WARN_STREAM(self.name() << ": invalid (x,y):" << target_pose.toString());
48 | return BT::NodeStatus::FAILURE;
49 | }
50 |
51 | BT_ROS_DEBUG_STREAM(self.name() << ": pose is valid");
52 | return BT::NodeStatus::SUCCESS;
53 | };
54 |
55 | } // namespace BehaviorTreeNodes
56 |
57 | #endif // VALID_POSE_H
--------------------------------------------------------------------------------
/fkie_behavior_tree_manager/src/behavior_tree_manager_node.cpp:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "BehaviorTreeManager.h"
16 |
17 | int main(int argc, char** argv)
18 | {
19 | ros::init(argc, argv, "behavior_tree_manager");
20 |
21 | // initializes ROS NodeHandles - Please do not remove!
22 | ros::NodeHandle public_node = ros::NodeHandle("");
23 | ros::NodeHandle private_node = ros::NodeHandle("~");
24 |
25 | BehaviorTreeManager bt_manager;
26 |
27 | // Update ros parameters
28 | bt_manager.params.readParameters();
29 |
30 | // register available action plugins
31 | BT_ROS_INFO_STREAM("Registered plugins:");
32 | for (std::string ap : bt_manager.params.action_plugins)
33 | BT_ROS_INFO_STREAM(" - " << ap);
34 |
35 | bt_manager.registerActionPlugins();
36 | bt_manager.reportBTState();
37 |
38 | // initialize static tree
39 | if (!bt_manager.params.tree_static_xml.empty())
40 | {
41 | bt_manager.initializeTreeFromText(bt_manager.params.tree_static_xml);
42 | }
43 | else if (!bt_manager.params.tree_static_file.empty())
44 | {
45 | bt_manager.initializeTreeFromFile(bt_manager.params.tree_static_file);
46 | }
47 | else
48 | {
49 | BT_ROS_ERROR("No tree is available. Check parameters [tree/static_xml] or [tree/static_file]");
50 | return 0;
51 | }
52 |
53 | // initialize loggin system
54 | bt_manager.initializeLoggers();
55 |
56 | bt_manager.spin();
57 |
58 | return 0;
59 | }
--------------------------------------------------------------------------------
/fkie_bt_moveit_actions/src/MoveitActions.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef MOVEIT_ACTIONS_H
16 | #define MOVEIT_ACTIONS_H
17 |
18 | #include "behaviortree_cpp_v3/behavior_tree.h"
19 | #include "behaviortree_cpp_v3/bt_factory.h"
20 | #include "fkie_bt_moveit_actions/actions/MoveitCartesianPathPlanning.hpp"
21 | #include "fkie_bt_moveit_actions/actions/MoveitExecuteWaypoints.hpp"
22 | #include "fkie_bt_moveit_actions/actions/MoveitMoveToFixConfiguration.hpp"
23 | #include "fkie_bt_moveit_actions/actions/MoveitMoveToPose.hpp"
24 | #include "fkie_bt_moveit_actions/actions/MoveitPlanToPose.hpp"
25 | #include "fkie_bt_moveit_actions/actions/MoveitExecutePlan.hpp"
26 | #include
27 | #include
28 |
29 | namespace MoveitActionsGroup
30 | {
31 | inline void RegisterNodes(BT::BehaviorTreeFactory& factory)
32 | {
33 | // moveit actions
34 | factory.registerNodeType("MoveitCartesianPathPlanning");
35 | factory.registerNodeType("MoveitExecuteWaypoints");
36 | factory.registerNodeType("MoveitMoveToPose");
37 | factory.registerNodeType("MoveitPlanToPose");
38 | factory.registerNodeType("MoveitExecutePlan");
39 | factory.registerNodeType("MoveitMoveToFixConfiguration");
40 | }
41 | } // namespace MoveitActionsGroup
42 |
43 | #endif // MOVEIT_ACTIONS_H
44 |
--------------------------------------------------------------------------------
/fkie_behavior_tree_manager/include/fkie_behavior_tree_manager/actions/DelayAction.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef DELAY_ACTION_NODE_H
16 | #define DELAY_ACTION_NODE_H
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | namespace BehaviorTreeNodes
24 | {
25 | class DelayAction : public BT::SyncActionNode
26 | {
27 | public:
28 | std::string name;
29 |
30 | static BT::PortsList providedPorts()
31 | {
32 | BT::PortsList ports = { BT::InputPort("delay_time") };
33 | return ports;
34 | }
35 |
36 | DelayAction(const std::string& _name, const BT::NodeConfiguration& config)
37 | : BT::SyncActionNode(_name, config), name("[" + _name + "] ")
38 | {
39 | BT_ROS_INFO_STREAM(name << " initialized");
40 | }
41 |
42 | BT::NodeStatus tick() override
43 | {
44 | setStatus(BT::NodeStatus::RUNNING);
45 |
46 | double delay_time = 0.0;
47 | auto res = BT::TreeNode::getInput("delay_time", delay_time);
48 | if (!res)
49 | {
50 | ROS_ERROR_STREAM("DelayAction: Could not load delay_time, resetting variable. Error: " << res.error());
51 | BT::TreeNode::setOutput("delay_time", 0.0);
52 | return BT::NodeStatus::FAILURE;
53 | }
54 |
55 | BT_ROS_INFO_STREAM(name << ": Waiting for: " << delay_time << " (s)");
56 |
57 | ros::Duration(delay_time).sleep();
58 | return BT::NodeStatus::SUCCESS;
59 | }
60 | };
61 |
62 | } // namespace BehaviorTreeNodes
63 |
64 | #endif // DELAY_ACTION_NODE_H
--------------------------------------------------------------------------------
/fkie_behavior_tree_manager/include/fkie_behavior_tree_manager/loggers/RosMsgLogger.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef BT_ROS_MSG_LOGGER_H
16 | #define BT_ROS_MSG_LOGGER_H
17 |
18 | #include
19 |
20 | #include "fkie_behavior_tree_msgs/BTNodeStatus.h"
21 | #include "fkie_behavior_tree_manager/logging.h"
22 | #include
23 | #include
24 |
25 | namespace BehaviorTreeNodes
26 | {
27 | class RosMsgLogger : public BT::StatusChangeLogger
28 | {
29 | protected:
30 | ros::Publisher pub_bt_status;
31 | fkie_behavior_tree_msgs::BTNodeStatus status_msg;
32 |
33 | public:
34 | RosMsgLogger(const BT::Tree& tree, const std::string topic) : BT::StatusChangeLogger(tree.rootNode())
35 | {
36 | ros::NodeHandle nh("~");
37 | pub_bt_status = nh.advertise(topic, 10, false);
38 | }
39 |
40 | void callback(BT::Duration timestamp, const BT::TreeNode& node, BT::NodeStatus prev_status, BT::NodeStatus status)
41 | {
42 | status_msg.header.stamp = ros::Time::now();
43 | status_msg.node_name = node.name();
44 | status_msg.node_id = node.registrationName();
45 | status_msg.node_type = toStr(node.type());
46 | status_msg.node_status = toStr(status, false);
47 | pub_bt_status.publish(status_msg);
48 |
49 | BT_ROS_DEBUG_STREAM("New callback: Node [" << node.name() << "]: " << toStr(prev_status, true) << " -> "
50 | << toStr(status, true));
51 | }
52 |
53 | void flush() override
54 | {
55 | }
56 | };
57 |
58 | } // namespace BehaviorTreeNodes
59 |
60 | #endif // BT_ROS_MSG_LOGGER_H
61 |
--------------------------------------------------------------------------------
/fkie_behavior_tree_manager/include/fkie_behavior_tree_manager/decorators/RunOnlyOnce.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef RUN_ONLY_ONCE_H
16 | #define RUN_ONLY_ONCE_H
17 |
18 | #include "behaviortree_cpp_v3/decorator_node.h"
19 | #include
20 | #include
21 | #include
22 |
23 | namespace BehaviorTreeNodes
24 | {
25 | /*
26 | RunOnlyOnce: This decorator ticks its children only once, useful for initializing states/poses.
27 | */
28 | class RunOnlyOnce : public BT::DecoratorNode
29 | {
30 | public:
31 | std::string name;
32 | bool already_executed = false;
33 |
34 | static BT::PortsList providedPorts()
35 | {
36 | BT::PortsList ports;
37 | return ports;
38 | }
39 |
40 | RunOnlyOnce(const std::string& _name, const BT::NodeConfiguration& config)
41 | : BT::DecoratorNode(_name, config), name("[" + _name + "] ")
42 | {
43 | BT_ROS_INFO_STREAM(name << " initialized");
44 | }
45 |
46 | inline BT::NodeStatus tick() override
47 | {
48 | setStatus(BT::NodeStatus::RUNNING);
49 |
50 | if (already_executed)
51 | return BT::NodeStatus::SUCCESS;
52 |
53 | BT_ROS_DEBUG_STREAM(name << "Ticking node [" << child_node_->name() << "]");
54 | const BT::NodeStatus child_state = child_node_->executeTick();
55 |
56 | if (child_state == BT::NodeStatus::FAILURE)
57 | {
58 | BT_ROS_WARN_STREAM(name << "Node [" << child_node_->name() << "] returns FAILURE, will be ticked again!");
59 | }
60 | else
61 | {
62 | already_executed = true;
63 | }
64 |
65 | return child_state;
66 | }
67 | };
68 |
69 | } // namespace BehaviorTreeNodes
70 |
71 | #endif // RUN_ONLY_ONCE_H
--------------------------------------------------------------------------------
/fkie_bt_move_base_actions/src/Recovery.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef MOVE_BASE_RECOVERY_H
16 | #define MOVE_BASE_RECOVERY_H
17 |
18 | #include
19 |
20 | #include
21 |
22 | #include
23 | #include
24 | #include
25 |
26 | #include
27 | #include
28 |
29 | #include "behaviortree_cpp_v3/behavior_tree.h"
30 | #include "behaviortree_cpp_v3/bt_factory.h"
31 |
32 | #include
33 | #include
34 |
35 | typedef actionlib::SimpleActionClient ClientRecoveryAction;
36 |
37 | namespace MoveBaseActionsGroup
38 | {
39 | class Recovery : public BT::ActionNodeBase
40 | {
41 | public:
42 | std::string name;
43 | std::string topic_recovery_action;
44 | bool init = false;
45 |
46 | Recovery(const std::string& name, const BT::NodeConfiguration& config);
47 | ~Recovery();
48 |
49 | static BT::PortsList providedPorts()
50 | {
51 | static BT::PortsList ports = { BT::InputPort("strategy") };
52 | return ports;
53 | }
54 |
55 | BT::NodeStatus tick() override;
56 | void halt() override;
57 |
58 | void doneCallback(const actionlib::SimpleClientGoalState& state, const mbf_msgs::RecoveryResultConstPtr& result);
59 | void activeCallback();
60 | void feedbackCallback();
61 | bool checkValidState(const int outcome);
62 |
63 | private:
64 | std::atomic_bool exe_result;
65 | std::unique_ptr ac;
66 | };
67 |
68 | } // namespace MoveBaseActionsGroup
69 |
70 | #endif // MOVE_BASE_RECOVERY_H
71 |
--------------------------------------------------------------------------------
/fkie_bt_move_base_actions/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | fkie_bt_move_base_actions
4 | 0.0.0
5 | The fkie_bt_move_base_actions package
6 |
7 | Francisco Garcia
8 | Francisco Garcia
9 |
10 | Apache License 2.0
11 |
12 | catkin
13 |
14 | roscpp
15 | rospy
16 | std_msgs
17 | mbf_msgs
18 | actionlib
19 | actionlib_msgss
20 | geometry_msgs
21 | nav_msgs
22 | fkie_behavior_tree_manager
23 | behaviortree_cpp_v3
24 | tf
25 | message_generation
26 |
27 | roscpp
28 | rospy
29 | std_msgs
30 |
31 | mbf_msgs
32 | actionlib
33 | actionlib_msgs
34 | geometry_msgs
35 | nav_msgs
36 | fkie_behavior_tree_manager
37 | tf
38 |
39 | roscpp
40 | rospy
41 | std_msgs
42 | mbf_msgs
43 | actionlib
44 | actionlib_msgs
45 | geometry_msgs
46 | nav_msgs
47 | fkie_behavior_tree_manager
48 | tf
49 | message_runtime
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/fkie_behavior_tree_manager/include/fkie_behavior_tree_manager/conditions/checkCommand.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef CHECK_COMMAND_H
16 | #define CHECK_COMMAND_H
17 |
18 | #include
19 | #include
20 |
21 | #include "behaviortree_cpp_v3/behavior_tree.h"
22 | #include "behaviortree_cpp_v3/bt_factory.h"
23 |
24 | #include
25 | #include
26 |
27 | namespace BehaviorTreeNodes
28 | {
29 | BT::NodeStatus checkCommand(BT::TreeNode& self)
30 | {
31 | std::string cmd;
32 | auto res = self.getInput("cmd", cmd);
33 | if (!res)
34 | {
35 | BT_ROS_ERROR_STREAM(self.name() << " Error at reading [cmd]: " << res.error());
36 | return BT::NodeStatus::FAILURE;
37 | }
38 |
39 | ros::NodeHandle private_node("~");
40 | std::string check_string_topic;
41 | float check_string_timeout = 2.0;
42 | private_node.param("checkCommand/check_string_topic", check_string_topic, std::string(""));
43 | private_node.param("checkCommand/check_string_timeout", check_string_timeout, 1.0f);
44 |
45 | if (check_string_topic.empty())
46 | {
47 | BT_ROS_ERROR_STREAM(self.name() << " check_string_topic is empty");
48 | return BT::NodeStatus::FAILURE;
49 | }
50 |
51 | // wait [timeout_target_pose] for first message
52 | std_msgs::StringConstPtr cmd_once =
53 | ros::topic::waitForMessage(check_string_topic, ros::Duration(check_string_timeout));
54 | if (!cmd_once)
55 | {
56 | return BT::NodeStatus::FAILURE;
57 | }
58 |
59 | if (cmd == cmd_once->data)
60 | return BT::NodeStatus::SUCCESS;
61 | else
62 | return BT::NodeStatus::FAILURE;
63 | };
64 |
65 | } // namespace BehaviorTreeNodes
66 |
67 | #endif // CHECK_COMMAND_H
--------------------------------------------------------------------------------
/fkie_bt_visualization/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.0.2)
2 | project(fkie_bt_visualization)
3 |
4 | set(CMAKE_CXX_STANDARD 17)
5 |
6 | find_package(catkin REQUIRED COMPONENTS
7 | roscpp
8 | rviz
9 | fkie_behavior_tree_msgs
10 | )
11 |
12 | catkin_package(
13 | LIBRARIES ${PROJECT_NAME}
14 | CATKIN_DEPENDS roscpp rviz fkie_behavior_tree_msgs
15 | )
16 |
17 | include_directories(include ${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR})
18 | link_directories(${catkin_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS})
19 |
20 | ## This setting causes Qt's "MOC" generation to happen automatically.
21 | set(CMAKE_AUTOMOC ON)
22 | set(CMAKE_INCLUDE_CURRENT_DIR ON)
23 |
24 | ## This plugin includes Qt widgets, so we must include Qt.
25 | ## We'll use the version that rviz used so they are compatible.
26 | if(rviz_QT_VERSION VERSION_LESS "5")
27 | message(STATUS "Using Qt4 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
28 | find_package(Qt4 ${rviz_QT_VERSION} EXACT REQUIRED QtCore QtGui QtXml)
29 | ## pull in all required include dirs, define QT_LIBRARIES, etc.
30 | include(${QT_USE_FILE})
31 | else()
32 | message(STATUS "Using Qt5 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
33 | find_package(Qt5 ${rviz_QT_VERSION} EXACT REQUIRED Core Widgets Xml)
34 | set(QT_LIBRARIES Qt5::Widgets Qt5::Xml)
35 | endif()
36 |
37 | add_definitions(-DQT_NO_KEYWORDS)
38 |
39 | #############
40 | ## Build ##
41 | #############
42 |
43 | set(SOURCE_FILES
44 | src/rviz_bt_status.cpp
45 | src/rviz_bt_logger.cpp
46 | include/${PROJECT_NAME}/TreeModel.hpp
47 | src/randomcolor/randomcolor.cpp
48 | )
49 |
50 | add_library(${PROJECT_NAME} ${SOURCE_FILES})
51 | target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${catkin_LIBRARIES})
52 | target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
53 |
54 | #############
55 | ## Install ##
56 | #############
57 |
58 | install(TARGETS
59 | ${PROJECT_NAME}
60 | ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
61 | LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
62 | RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
63 | )
64 |
65 | install(TARGETS
66 | ${PROJECT_NAME}
67 | ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
68 | LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
69 | RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
70 | )
71 |
72 | install(FILES
73 | plugin_description.xml
74 | DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
75 |
--------------------------------------------------------------------------------
/fkie_bt_move_base_actions/src/NavigateToGoal.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef MOVE_BASE_NAVIGATE_TO_GOAL_H
16 | #define MOVE_BASE_NAVIGATE_TO_GOAL_H
17 |
18 | #include
19 |
20 | #include "behaviortree_cpp_v3/behavior_tree.h"
21 | #include "behaviortree_cpp_v3/bt_factory.h"
22 |
23 | #include
24 | #include
25 | #include
26 |
27 | namespace MoveBaseActionsGroup
28 | {
29 | /*
30 |
31 | Publishes a goal to the bt_navigation, and wait for a [fkie_bt_move_base_actions/NavigationResult] message.
32 | Used to encapsulate the navigation from other applications
33 | It returns [nav_error_code] > 0 if navigation errors occurred
34 |
35 | */
36 | class NavigateToGoal : public BT::CoroActionNode
37 | {
38 | public:
39 | bool is_initialized = false;
40 | bool new_message_received = false;
41 | std::string topic_goal_pose_out;
42 | std::string topic_notify_result;
43 |
44 | ros::Publisher pub_pose;
45 |
46 | NavigateToGoal(const std::string& name, const BT::NodeConfiguration& config);
47 | ~NavigateToGoal();
48 | BT::NodeStatus tick() override;
49 | virtual void halt() override;
50 |
51 | static BT::PortsList providedPorts()
52 | {
53 | BT::PortsList ports = { BT::InputPort("target_pose"), BT::OutputPort("nav_error_code"),
54 | BT::OutputPort("navigation_result") };
55 | return ports;
56 | }
57 |
58 | void callbackNavigationResult(const fkie_bt_move_base_actions::NavigationResult& msg);
59 |
60 | private:
61 | ros::Subscriber sub_notify;
62 | fkie_bt_move_base_actions::NavigationResult last_msg;
63 | };
64 | } // namespace MoveBaseActionsGroup
65 | #endif // MOVE_BASE_NAVIGATE_TO_GOAL_H
66 |
--------------------------------------------------------------------------------
/fkie_bt_move_base_actions/src/CancelExePathSync.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef MOVE_BASE_CANCEL_EXE_PATH_SYNC_H
16 | #define MOVE_BASE_CANCEL_EXE_PATH_SYNC_H
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | #include "behaviortree_cpp_v3/behavior_tree.h"
23 | #include "behaviortree_cpp_v3/bt_factory.h"
24 |
25 | #include
26 | #include
27 |
28 | #include
29 | #include
30 | #include
31 |
32 | #include
33 | #include
34 |
35 | typedef actionlib::SimpleActionClient ClientExePathSyncAction;
36 |
37 | namespace MoveBaseActionsGroup
38 | {
39 | class CancelExePathSync : public BT::ActionNodeBase
40 | {
41 | public:
42 | std::string topic_exe_path;
43 | bool is_initialized = false;
44 |
45 | CancelExePathSync(const std::string& name, const BT::NodeConfiguration& config);
46 | ~CancelExePathSync();
47 |
48 | BT::NodeStatus tick() override;
49 |
50 | static BT::PortsList providedPorts()
51 | {
52 | static BT::PortsList ports = { BT::OutputPort("target_pose"), BT::OutputPort("path") };
53 |
54 | return ports;
55 | }
56 |
57 | void doneCallback(const actionlib::SimpleClientGoalState& state, const mbf_msgs::ExePathResultConstPtr& result);
58 | void activeCallback();
59 | void feedbackCallback(const mbf_msgs::ExePathFeedbackConstPtr& feedback);
60 |
61 | void cancelGoals();
62 |
63 | void halt() override;
64 |
65 | private:
66 | std::unique_ptr ac;
67 | };
68 |
69 | } // namespace MoveBaseActionsGroup
70 |
71 | #endif // MOVE_BASE_CANCEL_EXE_PATH_SYNC_H
72 |
--------------------------------------------------------------------------------
/fkie_bt_move_base_actions/src/NavigateToGoalSync.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef MOVE_BASE_NAVIGATE_TO_GOAL_SYNC_H
16 | #define MOVE_BASE_NAVIGATE_TO_GOAL_SYNC_H
17 |
18 | #include
19 |
20 | #include "behaviortree_cpp_v3/behavior_tree.h"
21 | #include "behaviortree_cpp_v3/bt_factory.h"
22 |
23 | #include
24 | #include
25 | #include
26 |
27 | namespace MoveBaseActionsGroup
28 | {
29 | /*
30 |
31 | Publishes a goal to the bt_navigation, and wait for a [fkie_bt_move_base_actions/NavigationResult] message.
32 | Used to encapsulate the navigation from other applications
33 | It returns [nav_error_code] > 0 if navigation errors occurred
34 |
35 | */
36 | class NavigateToGoalSync : public BT::ActionNodeBase
37 | {
38 | public:
39 | bool is_initialized = false;
40 | bool new_message_received = false;
41 | std::string topic_goal_pose_out;
42 | std::string topic_notify_result;
43 |
44 | ros::Publisher pub_pose;
45 |
46 | NavigateToGoalSync(const std::string& name, const BT::NodeConfiguration& config);
47 | ~NavigateToGoalSync();
48 | BT::NodeStatus tick() override;
49 | virtual void halt() override;
50 |
51 | static BT::PortsList providedPorts()
52 | {
53 | BT::PortsList ports = { BT::InputPort("target_pose"), BT::OutputPort("nav_error_code"),
54 | BT::OutputPort("navigation_result") };
55 | return ports;
56 | }
57 |
58 | void callbackNavigationResult(const fkie_bt_move_base_actions::NavigationResult& msg);
59 |
60 | private:
61 | ros::Subscriber sub_notify;
62 | fkie_bt_move_base_actions::NavigationResult last_msg;
63 | };
64 | } // namespace MoveBaseActionsGroup
65 | #endif // MOVE_BASE_NAVIGATE_TO_GOAL_SYNC_H
66 |
--------------------------------------------------------------------------------
/fkie_behavior_tree_manager/include/fkie_behavior_tree_manager/utils.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef UTILS_H
16 | #define UTILS_H
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | /**
24 | * @brief Extract string content from a given [fileName]
25 | */
26 | inline std::string readContentFile(const std::string& fileName)
27 | {
28 | std::ifstream ifs(fileName.c_str(), std::ios::in | std::ios::binary | std::ios::ate);
29 |
30 | std::ifstream::pos_type fileSize = ifs.tellg();
31 | ifs.seekg(0, std::ios::beg);
32 |
33 | std::vector bytes(fileSize);
34 | ifs.read(bytes.data(), fileSize);
35 |
36 | return std::string(bytes.data(), fileSize);
37 | }
38 |
39 | /**
40 | * @brief Read a ROS parameter
41 | */
42 | template
43 | bool getROSParameter(std::string name, T& param, bool print = true)
44 | {
45 | ros::NodeHandle private_node = ros::NodeHandle("~");
46 | const T default_value = param;
47 | bool r = private_node.param(name, param, default_value);
48 |
49 | if (print)
50 | {
51 | BT_ROS_INFO_STREAM(name << ": [" << param << "]");
52 | }
53 |
54 | return r;
55 | }
56 |
57 | /**
58 | * @brief Read ROS parameter (array-like)
59 | */
60 | template
61 | bool getROSParameterVector(std::string name, T& param, bool print = true)
62 | {
63 | ros::NodeHandle private_node = ros::NodeHandle("~");
64 | const T default_value = param;
65 | bool r = private_node.param(name, param, default_value);
66 |
67 | if (print)
68 | {
69 | std::string s =
70 | std::accumulate(param.begin(), param.end(), std::string{},
71 | [](std::string& s, const std::string& piece) -> decltype(auto) { return s += piece + ", "; });
72 |
73 | BT_ROS_INFO_STREAM(name << ": [" << s << "]");
74 | }
75 |
76 | return r;
77 | }
78 |
79 | #endif // UTILS_H
--------------------------------------------------------------------------------
/fkie_bt_tutorials/include/fkie_bt_tutorials/actions/HelloWorldAction.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef HELLO_WORLD_ACTION_H
16 | #define HELLO_WORLD_ACTION_H
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 |
24 | namespace BTTutorialGroup
25 | {
26 | class HelloWorldAction : public BT::SyncActionNode
27 | {
28 | public:
29 | static BT::PortsList providedPorts()
30 | {
31 | BT::PortsList ports = { BT::InputPort("message_in"), BT::OutputPort("message_out") };
32 |
33 | return ports;
34 | }
35 |
36 | HelloWorldAction(const std::string& name, const BT::NodeConfiguration& config) : BT::SyncActionNode(name, config)
37 | {
38 | }
39 |
40 | ~HelloWorldAction() = default;
41 |
42 | BT::NodeStatus tick() override
43 | {
44 | setStatus(BT::NodeStatus::RUNNING);
45 |
46 | std::string message_in;
47 | auto res = BT::TreeNode::getInput("message_in", message_in);
48 | if (!res)
49 | {
50 | // if no message available, greet the world again :)
51 | message_in = "Hello World";
52 |
53 | // optionally, you can print error message and stop execution by returning [BT::NodeStatus::FAILURE]
54 | // BT_ROS_ERROR_STREAM("Could not load port [message_in]: " << res.error());
55 | // return BT::NodeStatus::FAILURE;
56 | }
57 |
58 | // print the message to console log and wait 2 secs.
59 | BT_ROS_INFO_STREAM("message_in: " << message_in);
60 |
61 | // Write something to the [OutputPort] called [message_out]:
62 | BT::TreeNode::setOutput("message_out", std::string("BT Tutorials: HelloWorldAction"));
63 |
64 | ros::Duration(2.0).sleep();
65 |
66 | return BT::NodeStatus::SUCCESS;
67 | }
68 | };
69 | } // namespace BTTutorialGroup
70 | #endif // HELLO_WORLD_ACTION_H
--------------------------------------------------------------------------------
/fkie_bt_move_base_actions/src/CancelExePathSync.cpp:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "CancelExePathSync.h"
16 |
17 | namespace MoveBaseActionsGroup
18 | {
19 | CancelExePathSync::CancelExePathSync(const std::string& name, const BT::NodeConfiguration& config)
20 | : BT::ActionNodeBase(name, config)
21 | {
22 | // Get ros parameters
23 | ros::NodeHandle private_node("~");
24 | private_node.param("MoveBaseActions/topic_exe_path", topic_exe_path, std::string("exe_path"));
25 | private_node.param("MoveBaseActions/topic_exe_path", topic_exe_path, std::string(""));
26 |
27 | if (topic_exe_path.empty())
28 | {
29 | BT_ROS_ERROR("Missing param [MoveBaseActions/topic_exe_path]");
30 | return;
31 | }
32 |
33 | bool spin_thread = false;
34 | ac = std::make_unique(topic_exe_path, spin_thread);
35 | BT_ROS_INFO_STREAM("Waiting for action server [" << topic_exe_path << "]");
36 |
37 | while (ros::ok() && !ac->waitForServer(ros::Duration(0.1)))
38 | {
39 | ros::spinOnce();
40 | }
41 | BT_ROS_INFO_STREAM("Action client started");
42 |
43 | is_initialized = true;
44 | BT_ROS_INFO_STREAM("Successfully initialized");
45 | }
46 |
47 | CancelExePathSync::~CancelExePathSync()
48 | {
49 | cancelGoals();
50 | }
51 |
52 | BT::NodeStatus CancelExePathSync::tick()
53 | {
54 | setStatus(BT::NodeStatus::RUNNING);
55 |
56 | cancelGoals();
57 |
58 | return BT::NodeStatus::SUCCESS;
59 | }
60 |
61 | void CancelExePathSync::halt()
62 | {
63 | cancelGoals();
64 |
65 | setStatus(BT::NodeStatus::FAILURE);
66 | }
67 |
68 | void CancelExePathSync::cancelGoals()
69 | {
70 | if (ac->isServerConnected())
71 | {
72 | ac->cancelAllGoals();
73 | }
74 |
75 | BT::TreeNode::setOutput("path", nav_msgs::Path()); // reset current path
76 | BT::TreeNode::setOutput("target_pose", Pose2D()); // reset current target_pose
77 | BT_ROS_DEBUG_STREAM("CancelExePathSync: all goals were cancelled");
78 | }
79 |
80 | void CancelExePathSync::activeCallback()
81 | {
82 | }
83 |
84 | void CancelExePathSync::feedbackCallback(const mbf_msgs::ExePathFeedbackConstPtr& feedback)
85 | {
86 | }
87 |
88 | } // namespace MoveBaseActionsGroup
89 |
--------------------------------------------------------------------------------
/fkie_bt_move_base_actions/src/GetPath.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef MOVE_BASE_GET_PATH_H
16 | #define MOVE_BASE_GET_PATH_H
17 |
18 | #include
19 | #include
20 |
21 | #include
22 | #include
23 | #include
24 |
25 | #include
26 | #include
27 |
28 | #include "behaviortree_cpp_v3/behavior_tree.h"
29 | #include "behaviortree_cpp_v3/bt_factory.h"
30 |
31 | #include
32 | #include
33 |
34 | typedef actionlib::SimpleActionClient ClientGetPathAction;
35 | typedef actionlib::SimpleActionClient ClientExePathAction;
36 |
37 | namespace MoveBaseActionsGroup
38 | {
39 | class GetPath : public BT::SyncActionNode
40 | {
41 | public:
42 | bool is_initialized = false;
43 | std::string topic_get_path, frame_id_get_path;
44 | std::string topic_exe_path;
45 | std::string frame_id_target_pose;
46 |
47 | tf::TransformListener mytf;
48 |
49 | GetPath(const std::string& name, const BT::NodeConfiguration& config);
50 | ~GetPath();
51 | BT::NodeStatus tick() override;
52 |
53 | static BT::PortsList providedPorts()
54 | {
55 | BT::PortsList ports = { BT::InputPort("target_pose"), BT::InputPort("planner"),
56 | BT::OutputPort("path"), BT::OutputPort("nav_error_code") };
57 | return ports;
58 | }
59 |
60 | void doneCallback(const actionlib::SimpleClientGoalState& state, const mbf_msgs::GetPathResultConstPtr& result);
61 | void activeCallback();
62 | void feedbackCallback(const mbf_msgs::GetPathFeedbackConstPtr& feedback);
63 | bool getTfTransform(const std::string frame_to, const std::string frame_from, tf::StampedTransform& transform);
64 |
65 | private:
66 | std::atomic_bool exe_result;
67 | std::unique_ptr ac;
68 | std::unique_ptr ac_exec;
69 | };
70 | } // namespace MoveBaseActionsGroup
71 | #endif // MOVE_BASE_GET_PATH_H
72 |
--------------------------------------------------------------------------------
/fkie_behavior_tree_manager/include/fkie_behavior_tree_manager/conditions/CheckTimeoutAsync.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef CHECK_TIMEOUT_NODE_H
16 | #define CHECK_TIMEOUT_NODE_H
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 |
24 | namespace BehaviorTreeNodes
25 | {
26 | class CheckTimeoutAsync : public BT::CoroActionNode
27 | {
28 | public:
29 | std::string name;
30 |
31 | double timeout = 0.0;
32 |
33 | ros::Time start;
34 |
35 | static BT::PortsList providedPorts()
36 | {
37 | BT::PortsList ports = { BT::InputPort("timeout") };
38 | return ports;
39 | }
40 |
41 | CheckTimeoutAsync(const std::string& _name, const BT::NodeConfiguration& config)
42 | : BT::CoroActionNode(_name, config), name("[" + _name + "] ")
43 | {
44 | BT_ROS_INFO_STREAM(name << " initialized");
45 | }
46 |
47 | inline BT::NodeStatus tick() override
48 | {
49 | BT::TreeNode::getInput("timeout", timeout);
50 |
51 | if (timeout <= 0)
52 | {
53 | // disable timeout, always running...
54 | return BT::NodeStatus::RUNNING;
55 | }
56 |
57 | // start new timer
58 | if (status() != BT::NodeStatus::RUNNING)
59 | {
60 | start = ros::Time::now();
61 | BT_ROS_INFO_STREAM(name << " starting timer, timeout configured to: " << timeout << " s");
62 | return BT::NodeStatus::RUNNING;
63 | }
64 |
65 | // Determine how long its been since we've started this iteration
66 | ros::Duration elapsed = ros::Time::now() - start;
67 |
68 | if (elapsed.toSec() < timeout)
69 | {
70 | // timer running, not timeout yet
71 | return BT::NodeStatus::RUNNING;
72 | }
73 |
74 | // timeout reached
75 | BT_ROS_INFO_STREAM(name << " timeout reached: " << elapsed.toSec());
76 | return BT::NodeStatus::SUCCESS;
77 | }
78 |
79 | void halt() override
80 | {
81 | BT_ROS_DEBUG_STREAM(name << "node has been halted!");
82 | setStatus(BT::NodeStatus::FAILURE);
83 | CoroActionNode::halt();
84 | }
85 | };
86 |
87 | } // namespace BehaviorTreeNodes
88 |
89 | #endif // CHECK_TIMEOUT_NODE_H
--------------------------------------------------------------------------------
/fkie_bt_moveit_actions/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.0.2)
2 | project(fkie_bt_moveit_actions)
3 |
4 | find_package(catkin REQUIRED COMPONENTS
5 | roscpp
6 | rospy
7 | std_msgs
8 | actionlib
9 | actionlib_msgs
10 | fkie_behavior_tree_manager
11 | moveit_core
12 | moveit_visual_tools
13 | moveit_ros_planning
14 | moveit_ros_planning_interface
15 | moveit_ros_perception
16 | eigen_conversions
17 | tf_conversions
18 | pluginlib
19 | geometric_shapes
20 | tf
21 | tf2_ros
22 | tf2_eigen
23 | tf2_geometry_msgs
24 | )
25 |
26 | # Look for system package
27 | find_package(BehaviorTreeV3)
28 | if(NOT TARGET BT::behaviortree_cpp_v3)
29 | # If not found, look for package in ROS workspace
30 | find_package(behaviortree_cpp_v3 REQUIRED)
31 | #catkin_lint: ignore_once order_violation
32 | add_library(BT::behaviortree_cpp_v3 INTERFACE IMPORTED)
33 | set_target_properties(BT::behaviortree_cpp_v3 PROPERTIES
34 | INTERFACE_INCLUDE_DIRECTORIES "${behaviortree_cpp_v3_INCLUDE_DIRS}"
35 | INTERFACE_LINK_LIBRARIES "${behaviortree_cpp_v3_LIBRARIES}"
36 | )
37 | endif()
38 |
39 | find_package(Eigen3 REQUIRED)
40 | find_package(Boost REQUIRED system filesystem date_time thread)
41 |
42 | catkin_package(
43 | CATKIN_DEPENDS
44 | roscpp rospy std_msgs actionlib_msgs actionlib
45 | moveit_core
46 | moveit_visual_tools
47 | moveit_ros_planning_interface
48 | tf
49 | tf2_geometry_msgs
50 | fkie_behavior_tree_manager
51 | DEPENDS
52 | EIGEN3
53 | )
54 |
55 | include_directories(
56 | include
57 | ${catkin_INCLUDE_DIRS}
58 | ${Boost_INCLUDE_DIRS}
59 | ${CMAKE_CURRENT_SOURCE_DIR}
60 | ${Eigen_INCLUDE_DIRS}
61 | )
62 |
63 | ###########
64 | ## Build ##
65 | ###########
66 |
67 | # static
68 | add_library(MoveitActions STATIC src/MoveitActions.cpp )
69 | target_link_libraries(MoveitActions PRIVATE ${catkin_LIBRARIES} ${Eigen_LIBRARIES} BT::behaviortree_cpp_v3)
70 | set_target_properties(MoveitActions PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} )
71 | target_compile_features(MoveitActions PRIVATE cxx_std_17)
72 |
73 | # plugin
74 | add_library(MoveitActions_dyn SHARED src/MoveitActions.cpp )
75 | target_link_libraries(MoveitActions_dyn PRIVATE ${catkin_LIBRARIES} ${Eigen_LIBRARIES} BT::behaviortree_cpp_v3)
76 | target_compile_definitions(MoveitActions_dyn PRIVATE BT_PLUGIN_EXPORT)
77 | set_target_properties(MoveitActions_dyn PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} )
78 | target_compile_features(MoveitActions_dyn PRIVATE cxx_std_17)
79 |
80 | #############
81 | ## Install ##
82 | #############
83 |
84 | install(
85 | TARGETS MoveitActions MoveitActions_dyn
86 | ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
87 | LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
88 | RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
89 | )
90 |
--------------------------------------------------------------------------------
/fkie_bt_move_base_actions/src/MoveBaseActions.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef MOVE_BASE_ACTIONS_H
16 | #define MOVE_BASE_ACTIONS_H
17 |
18 | #include "behaviortree_cpp_v3/behavior_tree.h"
19 | #include "behaviortree_cpp_v3/bt_factory.h"
20 | #include
21 |
22 | #include
23 | #include
24 |
25 | #include "CancelExePathSync.h"
26 | #include "ExePathAsync.h"
27 | #include "ExePathSync.h"
28 | #include "GetPath.h"
29 | #include "MoveBaseUtils.h"
30 | #include "NavigateToGoal.h"
31 | #include "NavigateToGoalSync.h"
32 | #include "NotifyNavigationResult.h"
33 | #include "Recovery.h"
34 |
35 | namespace MoveBaseActionsGroup
36 | {
37 | inline void RegisterNodes(BT::BehaviorTreeFactory& factory)
38 | {
39 | BT::PortsList newTargetPoseReceivedPorts = { BT::OutputPort("target_pose") };
40 | factory.registerSimpleCondition("MoveBase_newTargetPoseReceived", newTargetPoseReceived, newTargetPoseReceivedPorts);
41 |
42 | BT::PortsList hasValidGoalPorts = { BT::BidirectionalPort("target_pose") };
43 | factory.registerSimpleCondition("MoveBase_hasValidGoal", hasValidGoal, hasValidGoalPorts);
44 |
45 | BT::PortsList CancelCurrentPoseActionPorts = { BT::OutputPort("target_pose") };
46 | factory.registerSimpleAction("CancelCurrentPoseAction", CancelCurrentPoseAction, CancelCurrentPoseActionPorts);
47 |
48 | // BT::PortsList moveBaseHeartbeatPorts = {BT::InputPort("message")};
49 | // factory.registerSimpleAction("MoveBase_heartbeat", moveBaseHeartbeat, moveBaseHeartbeatPorts);
50 |
51 | factory.registerNodeType("MoveBase_ExePathSync");
52 | factory.registerNodeType("MoveBase_ExePathAsync");
53 | factory.registerNodeType("CancelExePathSync");
54 | factory.registerNodeType("MoveBase_GetPath");
55 | factory.registerNodeType("MoveBase_Recovery");
56 | factory.registerNodeType("MoveBase_NotifyNavigationResult");
57 | factory.registerNodeType("MoveBase_NavigateToGoal");
58 | factory.registerNodeType("MoveBase_NavigateToGoalSync");
59 | }
60 |
61 | } // namespace MoveBaseActionsGroup
62 |
63 | #endif // MOVE_BASE_ACTIONS_H
--------------------------------------------------------------------------------
/fkie_behavior_tree_manager/include/fkie_behavior_tree_manager/actions/PoseStampedToPose2D.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef POSE_3D_TO_POSE_2D_NODE_H
16 | #define POSE_3D_TO_POSE_2D_NODE_H
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 |
24 | namespace BehaviorTreeNodes
25 | {
26 | class PoseStampedToPose2D : public BT::SyncActionNode
27 | {
28 | public:
29 | std::string name;
30 |
31 | static BT::PortsList providedPorts()
32 | {
33 | BT::PortsList ports = { BT::InputPort("target_pose_3d"), BT::OutputPort("target"
34 | "_pose_"
35 | "2d") };
36 | return ports;
37 | }
38 |
39 | PoseStampedToPose2D(const std::string& _name, const BT::NodeConfiguration& config)
40 | : BT::SyncActionNode(_name, config), name("[" + _name + "] ")
41 | {
42 | BT_ROS_INFO_STREAM(name << " initialized");
43 | }
44 |
45 | inline BT::NodeStatus tick() override
46 | {
47 | setStatus(BT::NodeStatus::RUNNING);
48 |
49 | geometry_msgs::PoseStamped target_pose_3d;
50 | auto res = BT::TreeNode::getInput("target_pose_3d", target_pose_3d);
51 | if (!res)
52 | {
53 | BT_ROS_ERROR_STREAM(name << " Could not load target_pose_3d, resetting variable. Error: " << res.error());
54 | BT::TreeNode::setOutput("target_pose_3d", geometry_msgs::PoseStamped());
55 | return BT::NodeStatus::FAILURE;
56 | }
57 |
58 | Pose2D target_pose_2d(target_pose_3d);
59 | BT_ROS_DEBUG_STREAM(name << " target_pose_2d: " << target_pose_2d.toString());
60 |
61 | // save current pose to blackboard variable
62 | res = BT::TreeNode::setOutput("target_pose_2d", target_pose_2d);
63 | if (!res)
64 | {
65 | BT_ROS_ERROR_STREAM(name << " Could not set output target_pose_2d: " << res.error());
66 | return BT::NodeStatus::FAILURE;
67 | }
68 | else
69 | {
70 | return BT::NodeStatus::SUCCESS;
71 | }
72 | }
73 | };
74 |
75 | } // namespace BehaviorTreeNodes
76 | #endif // POSE_3D_TO_POSE_2D_NODE_H
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # FKIE Behavior Trees
2 |
3 | This repository contains packages for executing Behavior Trees in ROS. It is powered by [BehaviorTree.CPP](https://github.com/BehaviorTree/BehaviorTree.CPP) and supports navigation and manipulation tasks using [Move Base Flex](http://wiki.ros.org/move_base_flex) and [MoveIt](https://moveit.ros.org/). It also provides RVIZ visualization and debugging tools.
4 |
5 | 
6 |
7 | ## Available Packages
8 |
9 | - ```fkie_behavior_tree_manager``` interfaces with behavior tree engine
10 | - ```fkie_bt_move_base_actions``` contains actions for interfacing with [Move Base Flex](http://wiki.ros.org/move_base_flex)
11 | - ```fkie_bt_moveit_actions``` contains actions for interfacing with [MoveIt](https://moveit.ros.org/)
12 | - ```fkie_bt_visualization``` contains RVIZ plugins for BT visualization
13 | - ```fkie_bt_tutorials``` contains tutorials for creating new BT actions
14 |
15 | ## Documentation
16 |
17 | Check our [Wiki](https://github.com/fkie/fkie_behavior_trees/wiki) for tutorials and examples.
18 |
19 | ## How to Compile
20 |
21 | - Install dependencies:
22 |
23 | ```
24 | sudo apt install ros-noetic-behaviortree-cpp-v3 ros-noetic-mbf-msgs qt5-default ros-noetic-moveit-ros ros-noetic-moveit-visual-tools
25 | ```
26 |
27 | If you want to use all packages, you can compile the meta-package `fkie_behavior_trees`, using [catkin tools](https://catkin-tools.readthedocs.io/en/latest/installing.html)
28 |
29 | ```
30 | cd ros/src
31 | git clone https://github.com/fkie/fkie_behavior_trees
32 | cd fkie_behavior_trees/fkie_behavior_trees/
33 | catkin build --this
34 | ```
35 |
36 | ## Try it out
37 |
38 | - If you want to run a very simple example of Behavior Tree Manager:
39 |
40 | ```
41 | roslaunch fkie_behavior_tree_manager behavior_tree.launch
42 | ```
43 | - You can also try a demo using a simulated husky robot and navigation, available in [fkie_husky_manipulation_simulation](https://github.com/fkie/fkie_husky_manipulation_simulation)
44 |
45 | 
46 |
47 | ## Authors
48 |
49 | - Francisco J. Garcia R. [E-Mail](francisco.garcia.rosas@fkie.fraunhofer.de)
50 | - Menaka Naazare - [E-Mail](menaka.naazare@fkie.fraunhofer.de)
51 |
52 | ## License
53 |
54 | ```
55 | Copyright 2022 Fraunhofer FKIE
56 |
57 | Licensed under the Apache License, Version 2.0 (the "License");
58 | you may not use this file except in compliance with the License.
59 | You may obtain a copy of the License at
60 |
61 | http://www.apache.org/licenses/LICENSE-2.0
62 |
63 | Unless required by applicable law or agreed to in writing, software
64 | distributed under the License is distributed on an "AS IS" BASIS,
65 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
66 | See the License for the specific language governing permissions and
67 | limitations under the License.
68 | ```
69 |
--------------------------------------------------------------------------------
/fkie_bt_move_base_actions/src/ExePathAsync.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef MOVE_BASE_EXE_PATH_ASYNC_H
16 | #define MOVE_BASE_EXE_PATH_ASYNC_H
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | #include "behaviortree_cpp_v3/behavior_tree.h"
23 | #include "behaviortree_cpp_v3/bt_factory.h"
24 |
25 | #include
26 | #include
27 |
28 | #include
29 | #include
30 | #include
31 |
32 | #include
33 | #include
34 |
35 | typedef actionlib::SimpleActionClient ClientExePathAsyncAction;
36 |
37 | namespace MoveBaseActionsGroup
38 | {
39 | class ExePathAsync : public BT::CoroActionNode
40 | {
41 | public:
42 | std::string topic_exe_path;
43 | ros::Subscriber sub_pose, sub_result;
44 | std::string topic_pose_reset, frame_id_target_pose;
45 |
46 | bool clear_pose_and_path_after_execution = true;
47 | bool cancel_goals_on_stop = true;
48 |
49 | bool is_initialized = false;
50 |
51 | ExePathAsync(const std::string& name, const BT::NodeConfiguration& config);
52 | ~ExePathAsync();
53 |
54 | BT::NodeStatus tick() override;
55 |
56 | static BT::PortsList providedPorts()
57 | {
58 | static BT::PortsList ports = { BT::BidirectionalPort("target_pose"),
59 | BT::BidirectionalPort("path"),
60 | BT::InputPort("controller"),
61 | BT::OutputPort("nav_error_code") };
62 |
63 | return ports;
64 | }
65 |
66 | bool sendNewGoal();
67 | void doneCallback(const actionlib::SimpleClientGoalState& state, const mbf_msgs::ExePathResultConstPtr& result);
68 | void activeCallback();
69 | void feedbackCallback(const mbf_msgs::ExePathFeedbackConstPtr& feedback);
70 | void callbackPose(const geometry_msgs::PoseStamped& msg);
71 | bool checkValidState(const int outcome);
72 |
73 | void halt() override;
74 |
75 | private:
76 | std::atomic_bool exe_result, navigation_finished, must_restart, tracking_goal;
77 | std::unique_ptr ac;
78 | };
79 |
80 | } // namespace MoveBaseActionsGroup
81 |
82 | #endif // MOVE_BASE_EXE_PATH_ASYNC_H
83 |
--------------------------------------------------------------------------------
/fkie_behavior_tree_manager/include/fkie_behavior_tree_manager/actions/ServiceEmptyAction.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef SERVICE_EMPTY_NODE_H
16 | #define SERVICE_EMPTY_NODE_H
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | namespace BehaviorTreeNodes
24 | {
25 | class ServiceEmptyAction : public BT::SyncActionNode
26 | {
27 | public:
28 | std::string name;
29 | ros::NodeHandle public_node;
30 | std::string topic_service;
31 | double delay = 0.0;
32 | bool valid_init = false;
33 |
34 | static BT::PortsList providedPorts()
35 | {
36 | BT::PortsList ports;
37 | return ports;
38 | }
39 |
40 | ServiceEmptyAction(const std::string& _name, const BT::NodeConfiguration& config)
41 | : BT::SyncActionNode(_name, config), name("[" + _name + "] ")
42 | {
43 | ros::NodeHandle private_node("~");
44 |
45 | std::string parameter_topic_service = "ServiceEmptyAction/" + _name + "_topic_service";
46 | std::string parameter_delay = "ServiceEmptyAction/" + _name + "_delay";
47 |
48 | private_node.param(parameter_topic_service, topic_service, std::string(""));
49 | private_node.param(parameter_delay, delay, 0.0);
50 |
51 | if (topic_service.empty())
52 | {
53 | BT_ROS_ERROR_STREAM(name << " topic_service is empty. Check parameter [" << parameter_topic_service << "]");
54 | return;
55 | }
56 |
57 | valid_init = true;
58 |
59 | BT_ROS_INFO_STREAM(name << " initialized");
60 | }
61 |
62 | inline BT::NodeStatus tick() override
63 | {
64 | setStatus(BT::NodeStatus::RUNNING);
65 |
66 | if (!valid_init)
67 | return BT::NodeStatus::FAILURE;
68 |
69 | BT_ROS_DEBUG_STREAM(name << " Calling service: " << topic_service);
70 | ros::ServiceClient client = public_node.serviceClient(topic_service);
71 | std_srvs::Empty srv;
72 | if (client.call(srv))
73 | {
74 | BT_ROS_DEBUG_STREAM(name << " Service executed successfully");
75 | ros::Duration(delay).sleep();
76 | return BT::NodeStatus::SUCCESS;
77 | }
78 | else
79 | {
80 | BT_ROS_ERROR_STREAM(name << " Service call to Octomap failed. Is Octomap server running?");
81 | return BT::NodeStatus::FAILURE;
82 | }
83 | }
84 | };
85 |
86 | } // namespace BehaviorTreeNodes
87 |
88 | #endif // SERVICE_EMPTY_NODE_H
89 |
--------------------------------------------------------------------------------
/fkie_bt_visualization/src/rviz_bt_logger.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef BT_LOGGER_PANEL_H
16 | #define BT_LOGGER_PANEL_H
17 |
18 | #include "boost/date_time/posix_time/posix_time.hpp"
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 |
40 | #ifndef Q_MOC_RUN
41 | #include "fkie_bt_visualization/TreeModel.hpp"
42 | #include
43 | #include
44 | #endif
45 |
46 | #include "randomcolor/randomcolor.h"
47 | #include
48 |
49 | class QLineEdit;
50 |
51 | namespace fkie_bt_visualization
52 | {
53 | class BTLoggerPanel : public rviz::Panel
54 | {
55 | Q_OBJECT
56 |
57 | public:
58 | BTLoggerPanel(QWidget* parent = 0);
59 |
60 | void load(const rviz::Config& config) override;
61 | void save(rviz::Config config) const override;
62 |
63 | public Q_SLOTS:
64 |
65 | void updateTopicName();
66 | void setTopicName(const QString& bt_name);
67 |
68 | void clearButton();
69 | void updateScrollToEnd(bool state);
70 |
71 | protected Q_SLOTS:
72 |
73 | // ROS Callbacks
74 | void callbackBTlogging(const fkie_behavior_tree_msgs::BTLoggingConstPtr& msg);
75 | void rosSpin();
76 |
77 | protected:
78 | ros::Subscriber sub_bt_log;
79 | QString bt_current_logging_topic_;
80 |
81 | // GUI Elements
82 | QTextEdit* q_text;
83 | QLineEdit* output_bt_topic_editor_;
84 | QString bt_topic_logging;
85 |
86 | QCheckBox* q_check_info;
87 | QCheckBox* q_check_warn;
88 | QCheckBox* q_check_error;
89 | QCheckBox* q_check_fatal;
90 | QCheckBox* q_check_scroll_to_end;
91 | bool scroll_to_end = true;
92 |
93 | QPushButton* q_button_clear;
94 |
95 | // ROS Elements
96 | ros::Subscriber sub_bt_status;
97 | ros::Subscriber sub_bt_node_status;
98 |
99 | ros::NodeHandle nh_;
100 |
101 | std::map map_color_sources;
102 | std::string generateRandomColor();
103 | int counter = 0;
104 | };
105 | } // namespace fkie_bt_visualization
106 |
107 | #endif // BT_LOGGER_PANEL_H
108 |
--------------------------------------------------------------------------------
/fkie_bt_move_base_actions/src/ExePathSync.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef MOVE_BASE_EXE_PATH_SYNC_H
16 | #define MOVE_BASE_EXE_PATH_SYNC_H
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | #include "behaviortree_cpp_v3/behavior_tree.h"
23 | #include "behaviortree_cpp_v3/bt_factory.h"
24 |
25 | #include
26 | #include
27 |
28 | #include
29 | #include
30 | #include
31 |
32 | #include
33 | #include
34 |
35 | typedef actionlib::SimpleActionClient ClientExePathSyncAction;
36 |
37 | namespace MoveBaseActionsGroup
38 | {
39 | class ExePathSync : public BT::ActionNodeBase
40 | {
41 | public:
42 | std::string topic_exe_path;
43 | ros::Subscriber sub_pose, sub_result;
44 | ros::Publisher pub_bool;
45 | std::string topic_pose_reset, frame_id_target_pose;
46 |
47 | bool is_initialized = false;
48 | bool wait_for_reach_goal = true;
49 | bool clear_pose_and_path_after_execution = true;
50 | bool publish_confirmation = false;
51 | std::string topic_confirmation;
52 |
53 | ExePathSync(const std::string& name, const BT::NodeConfiguration& config);
54 | ~ExePathSync();
55 |
56 | BT::NodeStatus tick() override;
57 |
58 | static BT::PortsList providedPorts()
59 | {
60 | static BT::PortsList ports = { BT::BidirectionalPort("target_pose"),
61 | BT::BidirectionalPort("path"),
62 | BT::InputPort("controller"),
63 | BT::OutputPort("nav_error_code") };
64 |
65 | return ports;
66 | }
67 |
68 | bool sendNewGoal();
69 | void doneCallback(const actionlib::SimpleClientGoalState& state, const mbf_msgs::ExePathResultConstPtr& result);
70 | void activeCallback();
71 | void feedbackCallback(const mbf_msgs::ExePathFeedbackConstPtr& feedback);
72 | void callbackPose(const geometry_msgs::PoseStamped& msg);
73 | void callbackNavigationResult(const mbf_msgs::ExePathActionResult& msg);
74 | bool checkValidState(const int outcome);
75 |
76 | void halt() override;
77 |
78 | private:
79 | std::atomic_bool exe_result, exploration_finished, must_restart, tracking_goal;
80 | std::unique_ptr ac;
81 | };
82 |
83 | } // namespace MoveBaseActionsGroup
84 |
85 | #endif // MOVE_BASE_EXE_PATH_SYNC_H
86 |
--------------------------------------------------------------------------------
/fkie_bt_visualization/include/fkie_bt_visualization/TreeItem.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef TREE_ITEM_H
16 | #define TREE_ITEM_H
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 | class TreeItem
31 | {
32 | public:
33 | std::string node_type;
34 | std::string node_type_view;
35 | std::string node_ID;
36 | std::string node_name;
37 | std::string node_name_view;
38 |
39 | TreeItem(std::string node_type, std::string node_ID, std::string node_name)
40 | : node_type(node_type), node_type_view(node_type), node_ID(node_ID), node_name(node_name), node_name_view(node_name)
41 | {
42 | clearName();
43 | }
44 |
45 | TreeItem(QString node_type, QString node_ID, QString node_name)
46 | : TreeItem(node_type.toStdString(), node_ID.toStdString(), node_name.toStdString())
47 | {
48 | clearName();
49 | }
50 |
51 | TreeItem(QDomNode node)
52 | : TreeItem(node.toElement().tagName(), node.toElement().attribute(QString("ID")),
53 | node.toElement().attribute(QString("name")))
54 | {
55 | clearName();
56 | }
57 |
58 | bool isValid() const
59 | {
60 | return !node_type.empty() || !node_ID.empty() || !node_name.empty();
61 | }
62 |
63 | void clearName()
64 | {
65 | if (node_type == "Action")
66 | {
67 | node_type_view = "|";
68 | node_name_view = "[A] " + node_name;
69 | }
70 |
71 | if (node_type == "Condition")
72 | {
73 | node_type_view = "|";
74 | node_name_view = "[C] " + node_name;
75 | }
76 | }
77 |
78 | /**
79 | * @brief Computes an "unique" string from properties. It might not be unique if the XML tree is not proper configured
80 | */
81 | std::string getStrID() const
82 | {
83 | // return node_type + "_" + node_name + "_" + node_ID;
84 | return node_name; // so far, only name is consistent
85 | }
86 |
87 | QString toQString() const
88 | {
89 | return QString("Node:%0, ID:%1, Name:%2")
90 | .arg(QString(node_type.c_str()))
91 | .arg(QString(node_ID.c_str()))
92 | .arg(QString(node_name.c_str()));
93 | }
94 |
95 | std::string toString() const
96 | {
97 | std::string r;
98 | r += " Type: " + node_type;
99 | r += " Name: " + node_name;
100 | r += " ID: " + node_ID;
101 | return r;
102 | }
103 | };
104 |
105 | #endif // TREE_ITEM_H
106 |
--------------------------------------------------------------------------------
/fkie_behavior_tree_manager/include/fkie_behavior_tree_manager/decorators/ConditionalLoop.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef CONDITIONAL_LOOP_H
16 | #define CONDITIONAL_LOOP_H
17 |
18 | #include "behaviortree_cpp_v3/decorator_node.h"
19 | #include
20 | #include
21 |
22 | namespace BehaviorTreeNodes
23 | {
24 | class ConditionalLoop : public BT::DecoratorNode
25 | {
26 | private:
27 | bool condition = false;
28 |
29 | public:
30 | std::string name;
31 |
32 | static BT::PortsList providedPorts()
33 | {
34 | BT::PortsList ports = { BT::InputPort("condition") };
35 | return ports;
36 | }
37 |
38 | ConditionalLoop(const std::string& _name, const BT::NodeConfiguration& config)
39 | : BT::DecoratorNode(_name, config), name("[" + _name + "] ")
40 | {
41 | BT_ROS_INFO_STREAM(name << " initialized");
42 | }
43 |
44 | inline BT::NodeStatus tick() override
45 | {
46 | setStatus(BT::NodeStatus::RUNNING);
47 |
48 | auto res = BT::TreeNode::getInput("condition", condition);
49 | if (!res)
50 | {
51 | BT_ROS_ERROR_STREAM(name << " Error reading [condition]: " << res.error());
52 | return BT::NodeStatus::FAILURE;
53 | }
54 |
55 | BT::NodeStatus loop_status = BT::NodeStatus::IDLE;
56 |
57 | while (ros::ok() && loop_status != BT::NodeStatus::FAILURE && condition)
58 | {
59 | // tick node and wait
60 |
61 | ros::spinOnce();
62 |
63 | BT_ROS_DEBUG_STREAM(name << "Ticking node [" << child_node_->name() << "]");
64 | const BT::NodeStatus child_state = child_node_->executeTick();
65 |
66 | switch (child_state)
67 | {
68 | case BT::NodeStatus::SUCCESS:
69 | loop_status = BT::NodeStatus::SUCCESS;
70 | break;
71 |
72 | case BT::NodeStatus::RUNNING:
73 | loop_status = BT::NodeStatus::RUNNING;
74 | break;
75 |
76 | case BT::NodeStatus::FAILURE:
77 | loop_status = BT::NodeStatus::FAILURE;
78 | break;
79 |
80 | default:
81 | loop_status = BT::NodeStatus::FAILURE;
82 | break;
83 | }
84 |
85 | res = BT::TreeNode::getInput("condition", condition);
86 | if (!res)
87 | {
88 | BT_ROS_ERROR_STREAM(name << " Error reading [condition]: " << res.error());
89 | return BT::NodeStatus::FAILURE;
90 | }
91 |
92 | if (condition)
93 | {
94 | BT_ROS_DEBUG_STREAM(name << "condition is true, ticking again the node.");
95 | }
96 | }
97 |
98 | return loop_status;
99 | }
100 | };
101 |
102 | } // namespace BehaviorTreeNodes
103 |
104 | #endif // CONDITIONAL_LOOP_H
--------------------------------------------------------------------------------
/fkie_behavior_tree_manager/include/fkie_behavior_tree_manager/actions/PublishPathAction.hpp:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef PUBLISH_PATH_ACTION_NODE_H
16 | #define PUBLISH_PATH_ACTION_NODE_H
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | #include
23 | #include
24 | #include
25 |
26 | namespace BehaviorTreeNodes
27 | {
28 | class PublishPathAction : public BT::SyncActionNode
29 | {
30 | public:
31 | std::string name;
32 | ros::NodeHandle public_node;
33 | std::string topic_path_out;
34 | ros::Publisher pub_path;
35 |
36 | bool valid_init = false;
37 |
38 | static BT::PortsList providedPorts()
39 | {
40 | BT::PortsList ports = { BT::BidirectionalPort("path") };
41 | return ports;
42 | }
43 |
44 | PublishPathAction(const std::string& _name, const BT::NodeConfiguration& config)
45 | : BT::SyncActionNode(_name, config), name("[" + _name + "] ")
46 | {
47 | ros::NodeHandle private_node("~");
48 |
49 | std::string parameter_topic_path_out = "PublishPathAction/" + _name + "_topic_path_out";
50 | private_node.param(parameter_topic_path_out, topic_path_out, std::string(""));
51 |
52 | if (topic_path_out.empty())
53 | {
54 | BT_ROS_ERROR_STREAM(name << " topic_path_out is empty. Check parameter [" << parameter_topic_path_out << "]");
55 | return;
56 | }
57 |
58 | pub_path = public_node.advertise(topic_path_out, 10);
59 | valid_init = true;
60 |
61 | BT_ROS_INFO_STREAM(name << " initialized");
62 | }
63 |
64 | inline BT::NodeStatus tick() override
65 | {
66 | setStatus(BT::NodeStatus::RUNNING);
67 |
68 | if (!valid_init)
69 | return BT::NodeStatus::FAILURE;
70 |
71 | // get target pose
72 | nav_msgs::Path path;
73 | auto res = BT::TreeNode::getInput("path", path);
74 | if (!res)
75 | {
76 | BT_ROS_ERROR_STREAM(name << " Could not load path, resetting variable. Error: " << res.error());
77 | BT::TreeNode::setOutput("path", nav_msgs::Path()); // reset current path
78 | return BT::NodeStatus::FAILURE;
79 | }
80 |
81 | if (path.poses.size() == 0)
82 | {
83 | BT_ROS_ERROR_STREAM(name << "Invalid path with 0 poses. ");
84 | return BT::NodeStatus::FAILURE;
85 | }
86 |
87 | if (path.header.frame_id.empty())
88 | {
89 | BT_ROS_ERROR_STREAM(name << "Empty frame id.");
90 | return BT::NodeStatus::FAILURE;
91 | }
92 |
93 | pub_path.publish(path);
94 | return BT::NodeStatus::SUCCESS;
95 | }
96 | };
97 |
98 | } // namespace BehaviorTreeNodes
99 |
100 | #endif // PUBLISH_PATH_ACTION_NODE_H
--------------------------------------------------------------------------------
/fkie_bt_visualization/src/rviz_bt_status.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 Fraunhofer FKIE - All Rights Reserved
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef BT_STATUS_PANEL_H
16 | #define BT_STATUS_PANEL_H
17 |
18 | #include "boost/date_time/posix_time/posix_time.hpp"
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include