Projects/RCLL-SS2018: summer_school2018.clp

File summer_school2018.clp, 5.1 KB (added by thofmann, 2 years ago)
Line 
1;---------------------------------------------------------------------------
2;  rcll2016.clp - Main file for the rcll2016 agent
3;
4;  Created: Mon Feb 10 16:09:26 2014
5;  Copyright  2012  Tim Niemueller [www.niemueller.de]
6;             2014 Frederik Zwilling
7;  Licensed under GPLv2+ license, cf. LICENSE file
8;---------------------------------------------------------------------------
9
10; LLSF2014 agent includes
11(path-load  rcll2016/priorities.clp)
12(path-load  rcll2016/globals.clp)
13(path-load  rcll2016/facts.clp)
14
15(defrule load-config
16  "Load configration for initialization."
17  (init)
18  =>
19  (config-load "/clips-agent")
20  (config-load "/hardware/robotino")
21)
22
23(deffacts init
24  "Initializes clips agent."
25  (init)
26)
27 
28; Request clips-features
29(defrule enable-blackboard
30  "If blackboard feature is set load the blackboard, if it is not yet loaded."
31  (ff-feature blackboard)
32  (not (ff-feature-loaded blackboard))
33  =>
34  (printout t "Requesting blackboard feature" crlf)
35  (ff-feature-request "blackboard")
36  (path-load "rcll2016/blackboard-init.clp")
37)
38
39(defrule enable-motor-switch
40  "If motor-switch feature is set load the motor-switch, if it is not yet loaded."
41  (ff-feature motor-switch)
42  (not (ff-feature-loaded motor-switch))
43  =>
44  (printout t "Requesting motor-switch feature" crlf)
45  (ff-feature-request "motor-switch")
46)
47
48(defrule enable-protobuf
49  "If protobuf feature is set load the protobuf, if it is not yet loaded."
50  (ff-feature protobuf)
51  (not (ff-feature-loaded protobuf))
52  =>
53  (printout t "Requesting protobuf feature" crlf)
54  (ff-feature-request "protobuf")
55)
56
57(defrule enable-navgraph
58  "If navgraph feature is set load the navgraph, if it is not yet loaded and init fact is set."
59  (init) ;because we want to load the navgraph after the (reset), which would delete all navgraph facts
60  (ff-feature navgraph)
61  (not (ff-feature-loaded navgraph))
62  =>
63  (printout t "Requesting navgraph feature" crlf)
64  (ff-feature-request "navgraph")
65  (path-load  rcll2016/navgraph.clp)
66)
67
68(defrule enable-tf
69  "If transform feature is set load it, if it is not yet loaded."
70  (ff-feature tf)
71  (not (ff-feature-loaded tf))
72  =>
73  (printout t "Requesting transform feature" crlf)
74  (ff-feature-request "tf")
75)
76
77(deffunction unwatch-rules-facts ()
78  ;unwatch some rules to reduce debug output
79  ;this is not possible in the config, because the defrules and deffacts are loaded later
80  ; (unwatch rules worldmodel-sync-receive-worldmodel)
81  ; (unwatch rules worldmodel-sync-publish-worldmodel)
82  ; (unwatch rules wm-update-puck-in-gripper)
83  (unwatch rules wm-update-pose)
84  (unwatch rules net-send-BeaconSignal)
85  (unwatch rules net-recv-BeaconSignal)
86  (unwatch rules net-recv-GameState)
87  (unwatch rules lock-send-message)
88  (unwatch rules lock-receive-message)
89  (unwatch rules worldmodel-sync-receive-worldmodel)
90  (unwatch rules skill-update-nochange)
91  (unwatch rules time-retract)
92  (unwatch facts protobuf-msg)
93  (unwatch facts active-robot)
94  (unwatch facts pose)
95  (unwatch facts timer)
96  (unwatch facts time)
97  (unwatch facts skill-update)
98)
99
100(defrule initialize
101  "Actual initialization rule. Loads the need rule-files for skills and inter-robot communication."
102  ;when all clips features are available and the init file is loaded
103  (declare (salience ?*PRIORITY-HIGH*))
104  (agent-init)
105  (ff-feature-loaded blackboard)
106  (loaded interfaces)
107  (ff-feature-loaded motor-switch)
108  (ff-feature-loaded protobuf)
109  (ff-feature-loaded tf)
110  (ff-feature navgraph)
111  =>
112  (path-load  rcll2016/utils.clp)
113  (path-load  rcll2016/worldmodel-synchronization.clp)
114  (path-load  rcll2016/net.clp)
115  (path-load  rcll2016/worldmodel.clp)
116  (path-load  rcll2016/skills.clp)
117  (path-load  rcll2016/lock-managing.clp)
118  (path-load  rcll2016/lock-usage.clp)
119  (path-load  rcll2016/game.clp)
120  (if
121    (any-factp ((?conf confval))
122      (and (eq ?conf:path "/clips-agent/rcll2016/enable-sim")
123           (eq ?conf:type BOOL) (eq ?conf:value TRUE)))
124  then
125    (printout t "Loading simulation" crlf)
126    (path-load  rcll2016/sim.clp)
127  )
128  (path-load  rcll2016/mps-instructions.clp)
129  (path-load  rcll2016/config.clp)
130  (path-load  summer_school2018/task1.clp)
131  (reset)
132  ;(facts)
133
134  (unwatch-rules-facts)
135)
136
137(defrule late-silence-debug-facts
138  "Disables watching of facts configured in clips-agent/rcll2016/unwatch-facts for debug mode."
139  (declare (salience -1000))
140  (init)
141  (protobuf-available)
142  (confval (path "/clips-agent/clips-debug") (type BOOL) (value true))
143  (confval (path "/clips-agent/rcll2016/unwatch-facts") (type STRING) (is-list TRUE) (list-value $?lv))
144  =>
145  (printout t "Disabling watching of the following facts: " ?lv crlf)
146  (foreach ?v ?lv (unwatch facts (sym-cat ?v)))
147)
148
149(defrule late-silence-debug-rules
150  "Disables watching of rules configured in clips-agent/rcll2016/unwatch-rules for debug mode."
151  (declare (salience -1000))
152  (init)
153  (protobuf-available)
154  (confval (path "/clips-agent/clips-debug") (type BOOL) (value true))
155  (confval (path "/clips-agent/rcll2016/unwatch-rules") (type STRING) (is-list TRUE) (list-value $?lv))
156  =>
157  (printout t "Disabling watching of the following rules: " ?lv crlf)
158  (foreach ?v ?lv (unwatch rules (sym-cat ?v)))
159)