53
54actionNum(clearEvents, clear).
55actionNum(events, events).
56
57
62actionNum(gripper(A), X) :-
63 ground(A),
64 concat_atom(['gripper ', A], X).
65
66
71actionNum(move(D,U), X) :-
72 ground(D), ground(U),
73 concat_atom(['move ', D, ' ',U], X).
74actionNum(move(D), X) :-
75 ground(D),
76 concat_atom(['move ', D, ' cm'], X).
77
79actionNum(moveFwd(D), X) :-
80 ground(D),
81 concat_atom(['move ', D, ' cm'], X).
82actionNum(moveBack(D), X) :-
83 ground(D),
84 D2 is (-1*D),
85 concat_atom(['move ', D2, ' cm'], X).
86
88actionNum(turnAround, 'move 360 degrees').
89actionNum(turnComplete, 'move 180 degrees').
90actionNum(turnLeft, 'move 90 degrees').
91actionNum(turnRight, 'move -90 degrees').
92
93actionNum(rotateTowardsObject(O), X) :-
94 ground(O),
95 concat_atom(['move rotate toward object', O], X).
96actionNum(rotateTowardsColor(R, G, B), X) :-
97 ground(R), ground(G), ground(B),
98 concat_atom(['move rotate toward color', R, ' ', G, ' ', B], X).
99
100actionNum(moveDriveObject(O), X) :-
101 ground(O),
102 concat_atom(['move drive toward object', O], X).
103actionNum(moveDriveColor(R, G, B), X) :-
104 ground(R), ground(G), ground(B),
105 concat_atom(['move drive toward color', R, ' ', G, ' ', B], X).
106
107actionNum(stop, stop).
108actionNum(freeze, stop).
109
113actionNum(speakOn, 'speak on').
114actionNum(speakOff, 'speak off').
115actionNum(playFile(F), X) :-
116 ground(F),
117 concat_atom(['play file ', '\'', F, '\''], X).
118actionNum(say(P), X) :-
119 ground(P),
120 (is_list(P) -> concat_atom(P, Phrase) ; Phrase=P),
121 concat_atom(['play phrase ', '\"', Phrase, '\"'], X).
122actionNum(say(P,V), X) :-
123 ground(P), ground(V),
124 (is_list(P) -> concat_atom(P, Phrase) ; Phrase=P),
125 concat_atom(['play phrase ', '\"', Phrase, '\"',
126 ' voice \"Microsoft ',V,'\"'], X).
127
128actionNum(selectVoice(V), X) :-
129 ground(V),
130 concat_atom(['set voice ', '\'', V, '\''], X).
131
132
136actionNum(position, 'position').
137
139actionNum(senseOn(S), X) :-
140 ground(S),
141 concat_atom(['sense ', S], X).
142actionNum(senseOff(S), X) :-
143 ground(S),
144 concat_atom(['sense ', S, ' off'], X).
145
146actionNum(senseGripper ,'sense gripper').
147
148actionNum(setIR_oa(on), 'set ir oa on all 50').
149actionNum(setIR_oa(off), 'set ir oa off').
150actionNum(setIR_oa(N, D), X) :-
151 ground(N), ground(D),
152 concat_atom(['set ir oa on all ',N,' disable distance ', D], X).
153
155actionNum(senseIR(A), X) :-
156 ground(A),
157 concat_atom(['ir ', A], X).
158
159
163actionNum(setLinearVelocity(V), X) :-
164 ground(V),
165 concat_atom(['set linear velocity ', V], X).
166actionNum(setAngularVelocity(V), X) :-
167 ground(V),
168 concat_atom(['set angular velocity ', V], X).
169
170actionNum(setPower(stopped, P), X) :-
171 ground(P),
172 concat_atom(['set power stopped ', P], X).
173actionNum(setPower(moving, P), X) :-
174 ground(P),
175 concat_atom(['set power moving ', P], X).
176
177actionNum(setObjectConfidence(P), X) :-
178 ground(P),
179 concat_atom(['set confidence threshold ', P], X).
180
181
186actionNum(arrive, 'move done').
187actionNum(finishSaying, 'play done').
188actionNum(finishSaying, X) :- sub_atom(X,_,_,_,'play error'), !.
189actionNum(getStuck, X) :- sub_atom(X,_,_,_,'move error'), !.
190
191actionNum(spotObject(Object), X) :-
192 get_object_event(X, Object, _, _, _, _).
193
195actionNum(lostObject(Object), A) :-
196 string_to_atom(S, A),
197 emptyString(Empty),
198 string_to_atom(Space,' '),
199 split_string(S, Space, Empty, List),
200 List=[Type|RList],
201 string_to_atom(Type, lostObject), 202 join_string(RList, Space, SObject),
203 string_to_atom(SObject, Object).
204
205
209get_object_event(AString, Object, Rate, X, Y, Distance) :-
210 string_to_atom(String, AString),
211 string_to_atom(Quote,'\"'),
212 string_to_atom(Space,' '),
213 split_string(String, Space, Quote, List),
214 List=[Type|RList],
215 string_to_atom(Type, object), 216 reverse(RList, [SDistance, SY, SX, SFT, SFM|LObject]),
217 string_to_number(SX, X), 218 string_to_number(SY, Y), 219 string_to_number(SFT, FT), 220 string_to_number(SFM, FM), 221 Rate is (100*FM)/FT, 222 string_to_number(SDistance, Distance), 223 reverse(LObject, LObject2),
224 join_string(LObject2, Space, SObject), 225 string_to_atom(SObject, Object)