Giter VIP home page Giter VIP logo

bt_lite's Introduction

BT_Lite

BT_Lite is made to use light-weight Behavior Tree with embedded systems. Visualize, Edit, Generate XML flie with Groot(github). Using generated XML BT structure file, generator/BT_Generator.py will generate Custom Header-Only Library optimized for BT structure. Therefore we cannot support dynamical changes of Behavior Tree structure on runtime. As wee want to use Behavior Tree in Embedded environment, there's no 'new' or 'delete' for memory allocation. All memories needed for custom generated header-only library is specifically calulated at complile time. We use Delegate.h(github) to use pass the custom tick actions of custom behavior tree nodes.

How To Use

  1. Make Behavior Tree XML Using Groot.
    Parameter means
    3__uint8_t : const param 3, typename uint8_t
    {name1__float} parameter name : name1, typename : float, blackboard param

  2. Make Custom Header-Only BT Library Using generate/BT_Gen.py

    • arg -b : Behavior tree namespace name WIP
    • arg -o : output directory WIP
    • arg -x : input XML behavior tree structure file path WIP
  3. Integrate to CMake
    WIP

  4. Use Example
    Use at main.cpp

#include <stdio.h>

#include <BT_TEST/BT_TEST.h>

namespace MY
{
    using namespace BT_TEST;

    class testTick
    {
    public:
        NodeStatus TickDelegate(const float &f, int *i, NODE::NodeBase *node)
        {
            printf("this is node : %s , customActionTick\n", node->getName());
            printf("now state : %s\n", Cvt::getNodeStatusName(node->getStatus()));
            printf("%f, %d\n", f, *i);
            *i = f * 10;
            printf("%f, %d\n", f, *i);
            return NodeStatus::SUCCESS;
        }

        NodeStatus TickDelegate2(const float &f, float *i, NODE::NodeBase *node)
        {
            printf("this is node : %s , customActionTick\n", node->getName());
            printf("now state : %s\n", Cvt::getNodeStatusName(node->getStatus()));
            printf("%f, %f\n", f, *i);
            *i = f * 10;
            printf("%f, %f\n", f, *i);
            return NodeStatus::SUCCESS;
        }

        delegate<NodeStatus(const float &, int *, NODE::NodeBase *)> makeTickDel()
        {
            delegate<NodeStatus(const float &, int *, NODE::NodeBase *)> del;
            del.set<testTick, &testTick::TickDelegate>(*this);
            return del;
        }

        delegate<NodeStatus(const float &, float *, NODE::NodeBase *)> makeTickDel2()
        {
            delegate<NodeStatus(const float &, float *, NODE::NodeBase *)> del;
            del.set<testTick, &testTick::TickDelegate2>(*this);
            return del;
        }

    private:
    };
}

int main(int argc, char **argv)
{
    MY::testTick tickk;

    BT_TEST::RootTree.set_CustomAction1_tickDel(tickk.makeTickDel());
    BT_TEST::RootTree.set_CustomAction2_tickDel(tickk.makeTickDel2());

    BT_TEST::RootTree.build();

    BT_TEST::StatusChangeLog_t *logs;
    int logCount = 0;
    for (int i = 0; i < 3; i++)
    {
        BT_TEST::logger.clearLogs();
        BT_TEST::RootTree.Tick();
        BT_TEST::logger.getLogs();
        logCount = BT_TEST::logger.getLogSize();
    }
    return 0;
}

UML Diagram

Inspired from BehaviorTree.CPP(github)
UML

Header Include Diagram

No Circular Dependancies Header

bt_lite's People

Contributors

lightaxis avatar

Stargazers

 avatar Patrick Lafleur avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.