# prob-ff **Repository Path**: xiaozq22/prob-ff ## Basic Information - **Project Name**: prob-ff - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-05-15 - **Last Updated**: 2025-05-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 基于概率规划的行为树生成算法设计及实现 ## 项目下载 ``` git clone https://gitee.com/xiaozq22/prob-ff.git cd prob-ff ``` **项目克隆下来后首先要将Cachet-1.21-wmc项目中的cachet文件拷贝到`~/CACHET/`目录下,并为其添加可执行权限** ``` mkdir -p ~/CACHET cp ./Cachet-1.21-wmc/cachet ~/CACHET/ chmod +x ~/CACHET/cachet ``` ## 编译及运行 1. 编译 ``` cd <当前目录> make ``` 如果不报错的话,会在当前目录下生成名为`ff`的可执行文件,接着可以运行如下示例进行检验: 2. 运行 以`tests`目录中的block任务为例,domain文件如下: ``` (define (domain blocksworld) (:predicates (clear ?x) (on-table ?x) (on ?x ?y) ) (:action move-b-to-b :parameters (?bm ?bf ?bt) :precondition (and (clear ?bm) (clear ?bt) (on ?bm ?bf)) :effect (and (not (clear ?bt)) (not (on ?bm ?bf)) (on ?bm ?bt) (clear ?bf)) ) (:action move-bstack-to-t :parameters (?b ?bl) :effect (and (when (on ?b ?bl) (and (not (on ?b ?bl)) (on-table ?b) (clear ?bl)))) ) (:action move-t-to-b :parameters (?bm ?bt) :effect (and (when (and (clear ?bt) (on-table ?bm)) (and (not (clear ?bt)) (not (on-table ?bm)) (on ?bm ?bt)))) ) ) ``` 表示可执行的动作有`move-b-to-b`(将物块从一个物块移动到另一个物块上), `move-bstack-to-t`(将物块从一个物块移动到桌子上), `move-t-to-b`(将物块从桌子移动到另一个五块上)三个。 problem文件定义如下: ``` (define (problem BW-simple-3) (:domain blocksworld) (:objects b1 b2 ) (:init ;; 核心确定性事实 (on-table b1) (clear b1) ;; 概率化初始状态配置 (cpt (on-table b2) 0.6) ; b2有60%概率在table上 (cpt (clear b2) 0.6) ; b2有60%概率clear ) (:goal 0.6 ; 目标状态概率 (and (on b1 b2) ; 目标堆叠结构,b1位于b2上 (clear b1) ; b1顶部保持clear ) ) ) ``` 初始状态下,b1位于桌面上,b2有60%的可能性位于桌面上;目标状态下,需要有至少60%的概率实现:b1位于b2上。 使用如下命令运行: ``` ./ff -o tests/block_domain.pddl -f tests/block_problem_2.pddl ``` 可以得到如下输出结果: ``` ff: parsing domain file domain 'BLOCKSWORLD' defined ... done. ff: parsing problem file problem 'BW-SIMPLE-2' defined ... done. initial BN is cross-product of independent multi-state vars! enabling special case treatment! Cueing down from goal distance: 2 into depth [1] 0 ff: found legal plan as follows step 0: MOVE-T-TO-B B1 B2 statistics: 0.00 seconds instantiating 16 easy, 0 hard action templates 0.00 seconds reachability analysis, yielding 16 facts and 16 actions 0.00 seconds creating final representation with 16 relevant 16 final facts (16 max U, 8 CNF max U) 0.00 seconds building connectivity graph 0.00 pure seconds ( 0.00 combined) evaluating 2 states, to a max depth of 1 0.00 sec ( 0.01 setup), 1 calls to external Cachet, 0 lits removed in 0 WMC calls, 1 ``fast-simulated'' calls 0.00 seconds in DP for 0 RPG ini state implication checks 0.00 seconds in DP for 0 RPlan extract ini state implication checks (0 lits removed) 0.00 seconds generating, 0.00 seconds encoding 1 state transition base CNFs 0.00 seconds in DP solving 3 state transition CNFs 0.00 seconds checking for stagnating states (0 hits), including 0 DP calls 3 total DP calls, 0 total UP calls, 0.00 sec membership 0.00 seconds for remaining searching duties 0.01 seconds total time (+ 0.00 secs for CNF-SAT communication; + 0.00 secs for CNF-WMC communication; + 0.00 secs for CNF memory allocation; there may be further overhead for Cachet WMC-CNF parsing, which is not included, and/or for file creation times) ``` 观察上述结果可知:为了实现60%的成功概率,只需执行一步(ff: found legal plan as follows后面内容):`MOVE-T-TO-B B1 B2`即可。 3. 将结果转化为行为树(以[BehaviorTree.CPP](https://www.behaviortree.dev/docs/learn-the-basics/xml_format)给出的xml格式为例): ``` ``` 画成图,即为一个`Sequence`节点下面接一个名为`MOVE-T-TO-B B1 B2`的动作节点。