Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 658ffb3

Browse files
author
Davide Faconti
committed
Merge branch 'master' into ros2
2 parents d5bd186 + a6e58fe commit 658ffb3

File tree

6 files changed

+94
-68
lines changed

6 files changed

+94
-68
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ If you are looking for a more fancy graphical user interface, check
3232

3333
![Groot screenshot](groot-screenshot.png)
3434

35+
## Watch Groot and BehaviorTree.CPP in action
36+
37+
Click on the following image to see a short video of how the C++ library and
38+
the graphic user interface are used to design and monitor a Behavior Tree.
39+
40+
[![MOOD2Be](video_MOOD2Be.png)](https://vimeo.com/304651183)
41+
3542
# How to compile
3643

3744
The only (optional, but recommended) dependency of BehaviorTree.CPP is ZeroMQ.

conanfile.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
"""Conan recipe package for BehaviorTree.CPP
5+
"""
6+
from conans import ConanFile, CMake, tools
7+
8+
9+
class BehaviorTreeConan(ConanFile):
10+
name = "BehaviorTree.CPP"
11+
license = "MIT"
12+
url = "https://github.com/BehaviorTree/BehaviorTree.CPP"
13+
author = "Davide Faconti <[email protected]>"
14+
topics = ("conan", "behaviortree", "ai", "robotics", "games", "coordination")
15+
description = "This C++ library provides a framework to create BehaviorTrees. It was designed to be flexible, easy to use and fast."
16+
settings = "os", "compiler", "build_type", "arch"
17+
options = {"shared": [True, False]}
18+
default_options = {"shared": False}
19+
generators = "cmake"
20+
exports = "LICENSE"
21+
exports_sources = ("cmake/*", "include/*", "src/*", "3rdparty/*", "CMakeLists.txt")
22+
23+
def requirements(self):
24+
25+
self.requires("cppzmq/4.3.0@bincrafters/stable")
26+
27+
def _configure_cmake(self):
28+
"""Create CMake instance and execute configure step
29+
"""
30+
cmake = CMake(self)
31+
cmake.definitions["BUILD_EXAMPLES"] = False
32+
cmake.definitions["BUILD_UNIT_TESTS"] = False
33+
cmake.configure()
34+
return cmake
35+
36+
def build(self):
37+
"""Configure, build and install BehaviorTree using CMake.
38+
"""
39+
tools.replace_in_file("CMakeLists.txt",
40+
"project(behaviortree_cpp)",
41+
"""project(behaviortree_cpp)
42+
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
43+
conan_basic_setup()""")
44+
cmake = self._configure_cmake()
45+
cmake.build()
46+
47+
def package(self):
48+
"""Copy BehaviorTree artifacts to package folder
49+
"""
50+
self.copy(pattern="LICENSE", dst="licenses")
51+
cmake = self._configure_cmake()
52+
cmake.install()
53+
54+
def package_info(self):
55+
"""Collect built libraries names and solve pthread path.
56+
"""
57+
self.cpp_info.libs = tools.collect_libs(self)
58+
if self.settings.os == "Linux":
59+
self.cpp_info.libs.append("pthread")

include/behaviortree_cpp/blackboard/blackboard.h

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
#include <unordered_map>
99

1010
#include "behaviortree_cpp/blackboard/safe_any.hpp"
11-
#include "behaviortree_cpp/optional.hpp"
1211

13-
template <typename T>
14-
T convertFromString(const std::string& str);
1512

1613
namespace BT
1714
{
@@ -74,18 +71,27 @@ class Blackboard
7471
return false;
7572
}
7673

77-
if (!std::is_same<std::string, T>::value &&
78-
(val->type() == typeid(SafeAny::SimpleString) || val->type() == typeid(std::string)))
74+
value = val->cast<T>();
75+
return true;
76+
}
77+
78+
template <typename T>
79+
bool get(const std::string& key, const SafeAny::Any* value) const
80+
{
81+
if (!impl_)
7982
{
80-
value = convertFromString<T>(val->cast<std::string>());
83+
return false;
8184
}
82-
else
85+
const SafeAny::Any* val = impl_->get(key);
86+
if (!val)
8387
{
84-
value = val->cast<T>();
88+
return false;
8589
}
90+
value = val;
8691
return true;
8792
}
8893

94+
8995
template <typename T>
9096
T get(const std::string& key) const
9197
{

include/behaviortree_cpp/tree_node.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,20 @@ class TreeNode
147147
if ( bb_ && bb_pattern)
148148
{
149149
const std::string stripped_key(&str[2], str.size() - 3);
150-
bool found = bb_->get(stripped_key, destination);
150+
const SafeAny::Any* val;
151+
bool found = bb_->get(stripped_key, val);
152+
if( found )
153+
{
154+
if( std::is_same<T,std::string>::value == false &&
155+
(val->type() == typeid (std::string) ||
156+
val->type() == typeid (SafeAny::SimpleString)))
157+
{
158+
destination = convertFromString<T>(val->cast<std::string>());
159+
}
160+
else{
161+
destination = val->cast<T>();
162+
}
163+
}
151164
return found;
152165
}
153166
else{

src/tree.cpp

Lines changed: 0 additions & 59 deletions
This file was deleted.

video_MOOD2Be.png

168 KB
Loading

0 commit comments

Comments
 (0)