Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: C++ CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build-and-test:
runs-on: ubuntu-latest
container:
image: ros:noetic-ros-base

steps:
- uses: actions/checkout@v2
- name: Setup Environment
run: |
sudo apt-get update
sudo apt-get install -y cmake g++ ninja-build

- name: Configure and Build
run: |
./opt/ros/noetic/setup.sh
mkdir build
cd build
cmake -DBUILD_TESTS=ON -DCATKIN_BUILD_BINARY_PACKAGE=OFF ..
cmake --build . -j8

- name: Run tests
run: |
cd build
ctest
61 changes: 61 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
.vscode
__pycache__
*.pyc
*idea
*dist*
*egg-info
devel/
build/
*.bag
*.bj
doxygen/
*cmake-build-debug*
*cmake-build-release*
*cmake-build*

# Folders
BUILD/
Debug/
Realese/

# Thirdparty folders which are
# downloaded during build (not submodules)

# Build results
*.user

# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

# OS X specific
*.DS_Store
.DS_Store
.DS_Store?

install_script.zsh
20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 3.11)
project(behavior_tree)

if(BUILD_TESTS)
message(STATUS "Tests building is enabled.")
enable_testing()
endif()

include(CMakePackageConfigHelpers)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

####################################################################
## ADD ALL THE SUB-PROJECTS ##
####################################################################

add_subdirectory(behavior_tree)
add_subdirectory(evo_behavior_tree)
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
# behavior_tree
# Behavior Tree Framework Libraries

Behavior Tree is a framework for writing a control architecture for any mission
execution system.

## Provided packages

1. **`evo-behavior-tree`** - behavior tree library package. No dependencies except for STL.
2. **`ros-melodic-evo-behavior-tree`** - ROS wrapper library for the behavior
tree framework. Created as a static library.

> See _behavior-tree_ and _evo-behavior-tree_ folders for more information about
> the libraries and the installation process.

## License

MIT

## Maintainers

- Evgeniy Safronov <evgeniy.safronov@evocargo.com>
- Maksim Kulikov <maksim.kulikov@evocargo.com>
109 changes: 109 additions & 0 deletions behavior_tree/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
cmake_minimum_required(VERSION 3.10)
file(STRINGS VERSION CURRENT_VERSION)
project(behavior_tree VERSION ${CURRENT_VERSION})


file(GLOB_RECURSE SOURCES_CPP_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
file(GLOB_RECURSE SOURCES_C_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c)

list(APPEND SOURCES_LIBRARY ${SOURCES_C_LIBRARY})
list(APPEND SOURCES_LIBRARY ${SOURCES_CPP_LIBRARY})

add_library(${PROJECT_NAME} SHARED ${SOURCES_LIBRARY})

target_include_directories(
${PROJECT_NAME}
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/evocargo>
)

####################################################################
## INSTALL LIBRARY ##
####################################################################

string(TOUPPER ${PROJECT_NAME} COMPONENT_NAME)
string(REPLACE "_" "" COMPONENT_NAME ${COMPONENT_NAME})

install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION lib/evocargo
COMPONENT ${COMPONENT_NAME}
RUNTIME DESTINATION bin
COMPONENT ${COMPONENT_NAME}
)

install(
DIRECTORY include/${PROJECT_NAME}
DESTINATION include/evocargo
COMPONENT ${COMPONENT_NAME}
)

####################################################################
## CREATE / INSTALL CMAKE CONFIGS ##
####################################################################

configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/conf/${PROJECT_NAME}Config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION "lib/cmake/${PROJECT_NAME}"
)

write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)

install(
EXPORT ${PROJECT_NAME}Targets
FILE ${PROJECT_NAME}Targets.cmake
DESTINATION lib/cmake/${PROJECT_NAME}
COMPONENT ${COMPONENT_NAME}
)

install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION lib/cmake/${PROJECT_NAME}
COMPONENT ${COMPONENT_NAME}
)

####################################################################
## CPACK CONFIGURATION ##
####################################################################

set(CPACK_GENERATOR "DEB")
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})

string(REPLACE "_" "-" DASH_PROJECT_NAME ${PROJECT_NAME})

set(CPACK_PACKAGE_NAME ${DASH_PROJECT_NAME})
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})

set(CPACK_COMPONENTS_ALL ${COMPONENT_NAME})
set(CPACK_DEBIAN_${COMPONENT_NAME}_PACKAGE_NAME ${DASH_PROJECT_NAME})

set(CPACK_DEBIAN_PACKAGE_MAINTAINER
"Evgeniy Safronov <evgeniy.safronov@evocargo.com>"
)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
"Behavior Tree framework."
)
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.md)

set(CPACK_OUTPUT_CONFIG_FILE
"${CMAKE_BINARY_DIR}/configs/${PROJECT_NAME}_Config.cmake"
)

include(CPack)

####################################################################
## ASSEMBLE LIBRARY WITH TESTS ##
####################################################################

if(BUILD_TESTS)
add_subdirectory(test)
endif()
29 changes: 29 additions & 0 deletions behavior_tree/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# ROS-independent BehaviorTree library

Behavior Tree framework for building mission execution systems.

## Installation

Before installation add Evocargo repository to system source list. Then install
the _behavior-tree_ package:

```
sudo apt update
sudo apt install behavior-tree
```

## Usage example

Install the library and write your own wrapper on it. As an example you can look
at the provided ROS wrapper - the evo_behavior_tree package (in the directory
with the same name).

## License

Copyright (c) Evocargo LLC, all rights reserved.

## Maintainers

- Evgeniy Safronov <evgeniy.safronov@evocargo.com>
- Tamash Fazli <tamash.fazli@evocargo.com>
- Alexey Ratnikov <alexey.ratnikov@evocargo.com>
1 change: 1 addition & 0 deletions behavior_tree/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0
10 changes: 10 additions & 0 deletions behavior_tree/conf/behavior_treeConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file exports CMake target which should be passed to the
# target_link_libraries command.

@PACKAGE_INIT@

include(CMakeFindDependencyMacro)

include("${CMAKE_CURRENT_LIST_DIR}/behavior_treeTargets.cmake")

set (behavior_tree_FOUND 1)
53 changes: 53 additions & 0 deletions behavior_tree/include/behavior_tree/behavior_tree.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#pragma once

#include "nodes/behavior_node.h" // Ensure correct path to the behavior node header
#include "nodes/status.h" // Include the Status class for handling node statuses
#include <memory>

namespace evo::behavior {

/**
* @brief Represents a behavior tree, managing the execution of a hierarchical
* structure of nodes that control decision making and behavior.
*/
class BehaviorTree {
public:
/**
* @brief Constructs a new BehaviorTree object with a specified root node.
*
* @param root The root node of the behavior tree, where execution starts.
*/
explicit BehaviorTree(BehaviorPtr root);

/**
* @brief Default constructor for an empty BehaviorTree, intended for delayed
* initialization.
*/
BehaviorTree() = default;

/**
* @brief Sets the root node of the behavior tree.
*
* @param root The root node to set, starting point for tree execution.
*/
virtual void set_root(BehaviorPtr root);

/**
* @brief Runs the behavior tree starting from the root node.
*
* @return Status The status of the behavior tree execution. Returns
* Status::Failure if no root is set.
*/
Status run();

/**
* @brief Virtual destructor to ensure proper cleanup in derived classes.
*/
virtual ~BehaviorTree() = default;

private:
/// The root node of the behavior tree.
BehaviorPtr root_;
};

} // namespace evo::behavior
5 changes: 5 additions & 0 deletions behavior_tree/include/behavior_tree/bt_base.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include "behavior_tree.h"
#include "bt_factory.h"
#include "nodes/status.h"
Loading