Documentation
¶
Index ¶
- Constants
- Variables
- func AssignDefaultRemapping(config *NodeConfig, value IGetProvidedPorts)
- func ConvFromString(str string, value any) error
- func ConvertBoolFromString(str string) bool
- func ConvertFloat64FromString(str string) (res float64, err error)
- func ConvertFloat64sFromString(str string) (res []float64, err error)
- func ConvertInt64FromString(str string) (res int64, err error)
- func ConvertInt64sFromString(str string) (res []int64, err error)
- func GetRemappedKey(portName string, remappedPort string) (res string, err error)
- func IsAllowedPortName(str string) bool
- func IsAlpha(c uint8) bool
- func IsBlackboardPointer(str string) (res string, ok bool)
- func IsPrivateKey(str string) bool
- func IsStatusCompleted(status NodeStatus) bool
- func SetPorts(descType any, ps ...*PortInfo)
- func StripBlackboardPointer(str string) string
- type ActionNodeBase
- type BehaviorTreeFactory
- func (f *BehaviorTreeFactory) CreateTree(treeName string) (*Tree, error)
- func (f *BehaviorTreeFactory) CreateTreeFromFile(file_path string) (*Tree, error)
- func (f *BehaviorTreeFactory) CreateTreeFromText(text string) (*Tree, error)
- func (f *BehaviorTreeFactory) Init()
- func (f *BehaviorTreeFactory) InstantiateTreeNode(name, ID string, config *NodeConfig) (node ITreeNode, err error)
- func (f *BehaviorTreeFactory) RegisterBehaviorTreeFromFile(filename string) error
- func (f *BehaviorTreeFactory) RegisterBehaviorTreeFromText(xml_text string) error
- func (f *BehaviorTreeFactory) RegisterNodeType(id string, cons NodeBuilderFn, args ...any)
- func (f *BehaviorTreeFactory) RegisterScriptingEnum(name string, value int)
- func (f *BehaviorTreeFactory) RegisterSimpleAction(ID string, tickFunctor TickFunctor, ports ...*PortInfo)
- func (f *BehaviorTreeFactory) RegisterSimpleCondition(ID string, tickFunctor TickFunctor, ports ...*PortInfo)
- func (f *BehaviorTreeFactory) RegisterSimpleDecorator(ID string, tickFunctor TickFunctor, ports ...*PortInfo)
- func (f *BehaviorTreeFactory) RegisteredBehaviorTrees() []string
- type Blackboard
- func (n *Blackboard) AddSubtreeRemapping(internal, external string)
- func (n *Blackboard) Clear()
- func (n *Blackboard) CreateEntry(key string, info *PortInfo) *Entry
- func (n *Blackboard) DebugMessage()
- func (n *Blackboard) Get(key string) any
- func (n *Blackboard) GetAnyLocked(key string) func() *Entry
- func (n *Blackboard) GetEntry(key string) *Entry
- func (n *Blackboard) GetKeys() (res []string)
- func (n *Blackboard) Set(key string, value any)
- func (n *Blackboard) Unset(key string)
- type CallableFunction
- type ConditionNode
- type ControlNode
- type CoroActionNode
- type DecoratorNode
- type Entry
- type IFromStr
- type IGetProvidedPorts
- type IMetadata
- type INodeType
- type IStatefulActionNode
- type ITreeNode
- type LeafNode
- type NodeBuilder
- type NodeBuilderFn
- type NodeConfig
- type NodeStatus
- type NodeType
- type Parser
- type PortDirection
- type PortInfo
- func BidirectionalPort(name string, desc ...string) *PortInfo
- func BidirectionalPortWithDefaultValue(name string, defaultValue any, desc ...string) *PortInfo
- func GetPorts(name string) (res *PortInfo, ok bool)
- func InputPort(name string, desc ...string) *PortInfo
- func InputPortWithDefaultValue(name string, defaultValue any, desc ...string) *PortInfo
- func NewPortInfo(direction PortDirection, name string, desc ...string) *PortInfo
- func OutPort(name string, desc ...string) *PortInfo
- func OutputPortWithDefaultValue(name string, defaultValue any, desc ...string) *PortInfo
- type PostCond
- type PostTickCallback
- type PreCond
- type PreTickCallback
- type ProtectedQueue
- type ScriptFunction
- type Signal
- type SimpleActionNode
- type SimpleConditionNode
- type SimpleDecoratorNode
- type SortMap
- func (s *SortMap[T1, T2]) Delete(key T1)
- func (s *SortMap[T1, T2]) Front() (value T2, ok bool)
- func (s *SortMap[T1, T2]) Get(key T1) (value T2, ok bool)
- func (s *SortMap[T1, T2]) Range(fn func(key T1, value T2) (stop bool))
- func (s *SortMap[T1, T2]) Reset()
- func (s *SortMap[T1, T2]) Set(key T1, value T2)
- type StatefulActionNode
- type Subtree
- type SubtreeModel
- type SyncActionNode
- type TestNodeConfig
- type ThreadedAction
- type TickFunctor
- type TickOption
- type Tree
- func (t *Tree) GetUID() uint16
- func (t *Tree) Init()
- func (t *Tree) Root() ITreeNode
- func (t *Tree) Sleep(timeout time.Duration)
- func (t *Tree) TickExactlyOnce() NodeStatus
- func (t *Tree) TickOnce() NodeStatus
- func (t *Tree) TickRoot(opt TickOption, sleepTime time.Duration) NodeStatus
- func (t *Tree) TickWhileRunning(sleepTimes ...time.Duration) NodeStatus
- type TreeNode
- func (n *TreeNode) Config() *NodeConfig
- func (n *TreeNode) EmitWakeUpSignal()
- func (n *TreeNode) ExecuteTick() NodeStatus
- func (n *TreeNode) FullPath() string
- func (n *TreeNode) GetInput(key string, destination any) (res any, err error)
- func (n *TreeNode) GetLockedPortContent(key string) func() *Entry
- func (n *TreeNode) GetRawPortValue(key string) string
- func (n *TreeNode) Halt()
- func (n *TreeNode) HaltNode()
- func (n *TreeNode) ModifyPortsRemapping(newRemapping map[string]string)
- func (n *TreeNode) Name() string
- func (n *TreeNode) PostConditionsScripts() []ScriptFunction
- func (n *TreeNode) PreConditionsScripts() []ScriptFunction
- func (n *TreeNode) RequiresWakeUp() bool
- func (n *TreeNode) ResetStatus()
- func (n *TreeNode) SetOutput(key string, value any)
- func (n *TreeNode) SetPostTickFunction(callback func(node *TreeNode, status NodeStatus) NodeStatus)
- func (n *TreeNode) SetPreTickFunction(callback func(node *TreeNode) NodeStatus)
- func (n *TreeNode) SetRegistrationID(ID string)
- func (n *TreeNode) SetStatus(status NodeStatus)
- func (n *TreeNode) SetWakeUpInstance(instance *WakeUpSignal)
- func (n *TreeNode) Status() NodeStatus
- func (n *TreeNode) Tick() NodeStatus
- func (n *TreeNode) UID() uint16
- type TreeNodeManifest
- type WakeUpSignal
- type XmlTag
Constants ¶
View Source
const ( EXACTLY_ONCE = iota ONCE_UNLESS_WOKEN_UP WHILE_RUNNING )
Variables ¶
View Source
var (
DefaultNodeConfig = &NodeConfig{}
)
View Source
var (
ErrorsInvalidTag = errors.New("invalid tag")
)
Functions ¶
func AssignDefaultRemapping ¶
func AssignDefaultRemapping(config *NodeConfig, value IGetProvidedPorts)
func ConvFromString ¶
func ConvertBoolFromString ¶
func ConvertInt64FromString ¶
func ConvertInt64sFromString ¶
func GetRemappedKey ¶
func IsAllowedPortName ¶
func IsBlackboardPointer ¶
func IsPrivateKey ¶
func IsStatusCompleted ¶
func IsStatusCompleted(status NodeStatus) bool
func StripBlackboardPointer ¶
Types ¶
type ActionNodeBase ¶
type ActionNodeBase struct {
*LeafNode
}
func NewActionNodeBase ¶
func NewActionNodeBase(name string, config *NodeConfig) *ActionNodeBase
func (ActionNodeBase) NodeType ¶
func (ActionNodeBase) NodeType() NodeType
type BehaviorTreeFactory ¶
type BehaviorTreeFactory struct { Builders map[string]*NodeBuilder // contains filtered or unexported fields }
func NewBehaviorTreeFactory ¶
func NewBehaviorTreeFactory() *BehaviorTreeFactory
func (*BehaviorTreeFactory) CreateTree ¶
func (f *BehaviorTreeFactory) CreateTree(treeName string) (*Tree, error)
func (*BehaviorTreeFactory) CreateTreeFromFile ¶
func (f *BehaviorTreeFactory) CreateTreeFromFile(file_path string) (*Tree, error)
func (*BehaviorTreeFactory) CreateTreeFromText ¶
func (f *BehaviorTreeFactory) CreateTreeFromText(text string) (*Tree, error)
func (*BehaviorTreeFactory) Init ¶
func (f *BehaviorTreeFactory) Init()
func (*BehaviorTreeFactory) InstantiateTreeNode ¶
func (f *BehaviorTreeFactory) InstantiateTreeNode(name, ID string, config *NodeConfig) (node ITreeNode, err error)
func (*BehaviorTreeFactory) RegisterBehaviorTreeFromFile ¶
func (f *BehaviorTreeFactory) RegisterBehaviorTreeFromFile(filename string) error
func (*BehaviorTreeFactory) RegisterBehaviorTreeFromText ¶
func (f *BehaviorTreeFactory) RegisterBehaviorTreeFromText(xml_text string) error
func (*BehaviorTreeFactory) RegisterNodeType ¶
func (f *BehaviorTreeFactory) RegisterNodeType(id string, cons NodeBuilderFn, args ...any)
func (*BehaviorTreeFactory) RegisterScriptingEnum ¶
func (f *BehaviorTreeFactory) RegisterScriptingEnum(name string, value int)
func (*BehaviorTreeFactory) RegisterSimpleAction ¶
func (f *BehaviorTreeFactory) RegisterSimpleAction(ID string, tickFunctor TickFunctor, ports ...*PortInfo)
func (*BehaviorTreeFactory) RegisterSimpleCondition ¶
func (f *BehaviorTreeFactory) RegisterSimpleCondition( ID string, tickFunctor TickFunctor, ports ...*PortInfo)
func (*BehaviorTreeFactory) RegisterSimpleDecorator ¶
func (f *BehaviorTreeFactory) RegisterSimpleDecorator( ID string, tickFunctor TickFunctor, ports ...*PortInfo)
func (*BehaviorTreeFactory) RegisteredBehaviorTrees ¶
func (f *BehaviorTreeFactory) RegisteredBehaviorTrees() []string
type Blackboard ¶
type Blackboard struct {
// contains filtered or unexported fields
}
func NewBlackboard ¶
func NewBlackboard(parent *Blackboard) *Blackboard
func (*Blackboard) AddSubtreeRemapping ¶
func (n *Blackboard) AddSubtreeRemapping(internal, external string)
func (*Blackboard) Clear ¶
func (n *Blackboard) Clear()
func (*Blackboard) CreateEntry ¶
func (n *Blackboard) CreateEntry(key string, info *PortInfo) *Entry
func (*Blackboard) DebugMessage ¶
func (n *Blackboard) DebugMessage()
func (*Blackboard) Get ¶
func (n *Blackboard) Get(key string) any
func (*Blackboard) GetAnyLocked ¶
func (n *Blackboard) GetAnyLocked(key string) func() *Entry
func (*Blackboard) GetEntry ¶
func (n *Blackboard) GetEntry(key string) *Entry
func (*Blackboard) GetKeys ¶
func (n *Blackboard) GetKeys() (res []string)
func (*Blackboard) Set ¶
func (n *Blackboard) Set(key string, value any)
func (*Blackboard) Unset ¶
func (n *Blackboard) Unset(key string)
type CallableFunction ¶
type CallableFunction func(args ...any)
type ConditionNode ¶
type ConditionNode struct {
*LeafNode
}
func NewConditionNode ¶
func NewConditionNode(name string, config *NodeConfig) *ConditionNode
func (*ConditionNode) NodeType ¶
func (n *ConditionNode) NodeType() NodeType
type ControlNode ¶
func NewControlNode ¶
func NewControlNode(name string, config *NodeConfig) *ControlNode
func (*ControlNode) AddChild ¶
func (n *ControlNode) AddChild(child ITreeNode)
func (*ControlNode) Halt ¶
func (n *ControlNode) Halt()
func (*ControlNode) HaltChild ¶
func (n *ControlNode) HaltChild(i int)
func (*ControlNode) HaltChildren ¶
func (n *ControlNode) HaltChildren()
func (*ControlNode) NodeType ¶
func (n *ControlNode) NodeType() NodeType
func (*ControlNode) ResetChildren ¶
func (n *ControlNode) ResetChildren()
type CoroActionNode ¶
type CoroActionNode struct {
*ActionNodeBase
}
type DecoratorNode ¶
type DecoratorNode struct { *TreeNode // contains filtered or unexported fields }
以自定义的方式修改孩子结点的行为。比如Invert类型的装饰结点,可以反转其孩子结点返回的状态信息。为了方便他人理解,应该尽可能使用比较常见的装饰结点。
func NewDecoratorNode ¶
func NewDecoratorNode(name string, config *NodeConfig) *DecoratorNode
func (*DecoratorNode) Child ¶
func (n *DecoratorNode) Child() ITreeNode
func (*DecoratorNode) ExecuteTick ¶
func (n *DecoratorNode) ExecuteTick() NodeStatus
func (*DecoratorNode) Halt ¶
func (n *DecoratorNode) Halt()
func (*DecoratorNode) HaltChild ¶
func (n *DecoratorNode) HaltChild()
func (*DecoratorNode) NodeType ¶
func (n *DecoratorNode) NodeType() NodeType
func (*DecoratorNode) ResetChild ¶
func (n *DecoratorNode) ResetChild()
func (*DecoratorNode) SetChild ¶
func (n *DecoratorNode) SetChild(child ITreeNode) error
type IGetProvidedPorts ¶
type IStatefulActionNode ¶
type IStatefulActionNode interface { OnStart() NodeStatus OnRunning() NodeStatus OnHalted() }
type ITreeNode ¶
type ITreeNode interface { Tick() NodeStatus Config() *NodeConfig PreConditionsScripts() []ScriptFunction PostConditionsScripts() []ScriptFunction SetRegistrationID(ID string) NodeType() NodeType UID() uint16 HaltNode() SetWakeUpInstance(instance *WakeUpSignal) ExecuteTick() NodeStatus ResetStatus() Status() NodeStatus }
func NewSimpleActionNode ¶
func NewSimpleActionNode(name string, config *NodeConfig, args ...interface{}) ITreeNode
func NewSimpleConditionNode ¶
func NewSimpleConditionNode(name string, config *NodeConfig, args ...interface{}) ITreeNode
func NewSimpleDecoratorNode ¶
func NewSimpleDecoratorNode(name string, config *NodeConfig, args ...interface{}) ITreeNode
type LeafNode ¶
type LeafNode struct {
*TreeNode
}
func NewLeafNode ¶
func NewLeafNode(name string, config *NodeConfig) *LeafNode
type NodeBuilder ¶
type NodeBuilder struct { Cons NodeBuilderFn DefaultArgs []any //默认参数 *TreeNodeManifest }
type NodeBuilderFn ¶
type NodeBuilderFn func(name string, config *NodeConfig, args ...interface{}) ITreeNode //构造函数
type NodeConfig ¶
type NodeStatus ¶
type NodeStatus int
const ( NodeStatus_IDLE NodeStatus = iota NodeStatus_RUNNING NodeStatus_SUCCESS NodeStatus_FAILURE NodeStatus_SKIPPED )
func (*NodeStatus) FromString ¶
func (n *NodeStatus) FromString(str string) error
func (NodeStatus) IsActive ¶
func (n NodeStatus) IsActive() bool
func (NodeStatus) IsCompleted ¶
func (n NodeStatus) IsCompleted() bool
func (*NodeStatus) String ¶
func (n *NodeStatus) String() string
func (*NodeStatus) StringColor ¶
func (n *NodeStatus) StringColor(colored bool) string
type Parser ¶
type Parser interface { LoadFromFile(fileName string, addIncludes ...bool) error LoadFromText(xmlText string, addIncludes ...bool) error RegisteredBehaviorTrees() []string InstantiateTree(rootBlackboard *Blackboard, mainTreeId string) (tree *Tree, err error) ClearInternalState() }
func NewXmlParser ¶
func NewXmlParser() Parser
type PortDirection ¶
type PortDirection int
const ( PortDirection_INPUT PortDirection = iota PortDirection_OUTPUT PortDirection_INOUT )
func (*PortDirection) FromString ¶
func (p *PortDirection) FromString(str string) error
func (*PortDirection) String ¶
func (p *PortDirection) String() string
type PortInfo ¶
type PortInfo struct { Name string // contains filtered or unexported fields }
func BidirectionalPort ¶
func NewPortInfo ¶
func NewPortInfo(direction PortDirection, name string, desc ...string) *PortInfo
func (*PortInfo) DefaultValue ¶
func (*PortInfo) DefaultValueString ¶
func (*PortInfo) Description ¶
func (*PortInfo) Direction ¶
func (p *PortInfo) Direction() PortDirection
func (*PortInfo) SetDefaultValue ¶
func (*PortInfo) SetDescription ¶
type PostTickCallback ¶
type PostTickCallback func(node *TreeNode, status NodeStatus) NodeStatus
type PreTickCallback ¶
type PreTickCallback func(node *TreeNode) NodeStatus
type ScriptFunction ¶
type ScriptFunction func(args ...interface{}) bool
func ParseScript ¶
func ParseScript(s string) (ScriptFunction, error)
type Signal ¶
type Signal struct {
// contains filtered or unexported fields
}
func (*Signal) Subscribe ¶
func (c *Signal) Subscribe(fn CallableFunction) CallableFunction
type SimpleActionNode ¶
type SimpleActionNode struct { *SyncActionNode // contains filtered or unexported fields }
func (*SimpleActionNode) Tick ¶
func (n *SimpleActionNode) Tick() NodeStatus
type SimpleConditionNode ¶
type SimpleConditionNode struct { *ConditionNode // contains filtered or unexported fields }
func (*SimpleConditionNode) Tick ¶
func (s *SimpleConditionNode) Tick() NodeStatus
type SimpleDecoratorNode ¶
type SimpleDecoratorNode struct { *DecoratorNode // contains filtered or unexported fields }
func (*SimpleDecoratorNode) Tick ¶
func (n *SimpleDecoratorNode) Tick() NodeStatus
type StatefulActionNode ¶
type StatefulActionNode struct { *ActionNodeBase IStatefulActionNode // contains filtered or unexported fields }
func NewStatefulActionNode ¶
func NewStatefulActionNode(name string, config *NodeConfig) *StatefulActionNode
func (*StatefulActionNode) Halt ¶
func (n *StatefulActionNode) Halt()
func (*StatefulActionNode) IsHaltRequested ¶
func (n *StatefulActionNode) IsHaltRequested() bool
func (*StatefulActionNode) Tick ¶
func (n *StatefulActionNode) Tick() NodeStatus
type Subtree ¶
type Subtree struct { TreeId string InstanceName string Blackboard *Blackboard Nodes []ITreeNode Subtree *Subtree }
type SubtreeModel ¶
type SubtreeModel struct {
// contains filtered or unexported fields
}
type SyncActionNode ¶
type SyncActionNode struct {
*ActionNodeBase
}
func NewSyncActionNode ¶
func NewSyncActionNode(name string, config *NodeConfig) *SyncActionNode
func (*SyncActionNode) ExecuteTick ¶
func (s *SyncActionNode) ExecuteTick() NodeStatus
type TestNodeConfig ¶
type TestNodeConfig struct { Id string /// status to return when the action is completed ReturnStatus NodeStatus /// script to execute when actions is completed PostScript string //毫秒 AsyncDelay time.Duration PreFunc func() PostFunc func() }
func NewTestNodeConfig ¶
func NewTestNodeConfig() *TestNodeConfig
type ThreadedAction ¶
type ThreadedAction struct { *ActionNodeBase // contains filtered or unexported fields }
func NewThreadedAction ¶
func NewThreadedAction(name string, config *NodeConfig) *ThreadedAction
func (*ThreadedAction) ExecuteTick ¶
func (n *ThreadedAction) ExecuteTick() NodeStatus
This method spawn a new thread. Do NOT remove the "final" keyword.
func (*ThreadedAction) Halt ¶
func (n *ThreadedAction) Halt()
func (*ThreadedAction) IsHaltRequested ¶
func (n *ThreadedAction) IsHaltRequested() bool
type TickFunctor ¶
type TickFunctor func(node ITreeNode, status ...NodeStatus) NodeStatus
type TickOption ¶
type TickOption int
type Tree ¶
type Tree struct { Subtrees []*Subtree // contains filtered or unexported fields }
func (*Tree) TickExactlyOnce ¶
func (t *Tree) TickExactlyOnce() NodeStatus
func (*Tree) TickOnce ¶
func (t *Tree) TickOnce() NodeStatus
func (*Tree) TickRoot ¶
func (t *Tree) TickRoot(opt TickOption, sleepTime time.Duration) NodeStatus
func (*Tree) TickWhileRunning ¶
func (t *Tree) TickWhileRunning(sleepTimes ...time.Duration) NodeStatus
type TreeNode ¶
type TreeNode struct {
// contains filtered or unexported fields
}
func NewTreeNode ¶
func NewTreeNode(name string, cfg *NodeConfig) *TreeNode
func (*TreeNode) Config ¶
func (n *TreeNode) Config() *NodeConfig
func (*TreeNode) EmitWakeUpSignal ¶
func (n *TreeNode) EmitWakeUpSignal()
func (*TreeNode) ExecuteTick ¶
func (n *TreeNode) ExecuteTick() NodeStatus
func (*TreeNode) GetLockedPortContent ¶
func (*TreeNode) GetRawPortValue ¶
func (*TreeNode) Halt ¶
func (n *TreeNode) Halt()
/ The method used to interrupt the execution of a RUNNING node. / Only Async nodes that may return RUNNING should implement it.
func (*TreeNode) ModifyPortsRemapping ¶
func (*TreeNode) PostConditionsScripts ¶
func (n *TreeNode) PostConditionsScripts() []ScriptFunction
func (*TreeNode) PreConditionsScripts ¶
func (n *TreeNode) PreConditionsScripts() []ScriptFunction
func (*TreeNode) RequiresWakeUp ¶
func (*TreeNode) ResetStatus ¶
func (n *TreeNode) ResetStatus()
func (*TreeNode) SetPostTickFunction ¶
func (n *TreeNode) SetPostTickFunction(callback func(node *TreeNode, status NodeStatus) NodeStatus)
func (*TreeNode) SetPreTickFunction ¶
func (n *TreeNode) SetPreTickFunction(callback func(node *TreeNode) NodeStatus)
func (*TreeNode) SetRegistrationID ¶
func (*TreeNode) SetStatus ¶
func (n *TreeNode) SetStatus(status NodeStatus)
func (*TreeNode) SetWakeUpInstance ¶
func (n *TreeNode) SetWakeUpInstance(instance *WakeUpSignal)
func (*TreeNode) Status ¶
func (n *TreeNode) Status() NodeStatus
func (*TreeNode) Tick ¶
func (n *TreeNode) Tick() NodeStatus
type TreeNodeManifest ¶
type TreeNodeManifest struct { Type NodeType RegistrationID string Ports map[string]*PortInfo Metadata []map[string]string }
func NewTreeNodeManifest ¶
func NewTreeNodeManifest(value any) *TreeNodeManifest
type WakeUpSignal ¶
type WakeUpSignal struct {
// contains filtered or unexported fields
}
func NewWakeUpSignal ¶
func NewWakeUpSignal() *WakeUpSignal
func (*WakeUpSignal) EmitSignal ¶
func (s *WakeUpSignal) EmitSignal()
Click to show internal directories.
Click to hide internal directories.