% aibo planner v. 1.2 beta % Jul 8 2004 % by Christian Nastasi nastasichr@yahoo.it % Alessio Guerrieri tarlosk@libero.it % typical call: lparse planXaibo2.sm | smodels % lparse planXaibo12_f1.sm planXaibo12_f2.sm planXaibo12_f3.sm | smodels % This planner is based on the work of Luca Padovani % % File name: planXaibo12_f2.sm % Descrition: This File implements the second part of aibo_planner % it defines mainly "fluent", "executable" and "finally". % Note: This Section will change seldom, only to add or modify ability to your code! %%% General rules %%% % simmetry of adjacent... adjacent(P1, P2, Orient_inv) :- passage_way_point(P1), passage_way_point(P2), orientation(Orient_inv), orientation(Orient), opposite_orientation(Orient, Orient_inv), adjacent(P2, P1, Orient). adjacent(P, R, Orient_inv) :- passage_way_point(P), room_point(R), orientation(Orient_inv), orientation(Orient), opposite_orientation(Orient, Orient_inv), adjacent(R, P, Orient). %%% Rules for redefining the way_point... way_point(Position) :- passage_way_point(Position). way_point(Position) :- room_point(Position). % opposite orientation opposite_orientation(north, south). opposite_orientation(south, north). opposite_orientation(east, west). opposite_orientation(west, east). %%% Fluents Declaration % -> Battery fluent(battery_level(Level)) :- level_kind(Level). % -> Robot position fluent(is_at(Rob,Pos)) :- robot(Rob), way_point(Pos). % -> Robot sense fluent(accessible(Pos)) :- way_point(Pos). fluent(is_oriented(Rob,Ver)) :- robot(Rob), orientation(Ver). %%% Actions Declaration % -> Robot motion action(move_from_to(Rob, From, To)) :- robot(Rob), way_point(From), way_point(To), From!=To. action(turn_towards(Rob, Old_orient, New_orient)) :- orientation(Old_orient), orientation(New_orient), robot(Rob), Old_orient!=New_orient. % -> Robot interaction action(open_door(Rob, Room)) :- robot(Rob), room_point(Room). action(wait_on_goal). %%% executable(Action,Time) % determines if an action can be executed at time T % move_from_to can be executed only when: % 1. From and To are adjacents % 2. There is not a door between From end To (accessible) % 3. Rob is in From at time T in the correct orientation % 4. The battery is not at low level executable(move_from_to(Rob,From,To), T) :- time(T), T < length, robot(Rob), way_point(From), way_point(To), orientation(Orient), level_kind(Level), Level != low, adjacent(From,To, Orient), holds(accessible(To),T), holds(is_oriented(Rob,Orient),T), holds(is_at(Rob,From),T), holds(battery_level(Level),T). % open_door can be executed only when: % 1. The door is closed and robot is in front of the door % 2. The battery is not at low level executable(open_door(Rob, Room), T) :- time(T), T < length, robot(Rob), room_point(Room), level(Level), Level != low, passage_way_point(InFrontOf), orientation(Orient), holds(is_at(Rob,InFrontOf), T), holds(is_oriented(Rob,InFrontOf,Orient),T), adjacent(InFrontOf,Room,Orient), holds(battery_level(Level),T), holds(neg(accessible(Room)),T). % robot can turn around, but only to directions where there's % someplace to go to executable(turn_towards(Rob, Old_orient, New_orient) , T) :- time(T), T < length, robot(Rob), orientation(Old_orient), orientation(New_orient), New_orient != Old_orient, way_point(To), holds(is_at(Rob, From),T), adjacent(From, To, New_orient), holds(is_oriented(Rob, Old_orient),T). %%% causes(Action,Fluent,Time) % Describes actions consequences on fluents %% neg() function inplements the negation action %%% Moving let the old location fluent become false and the new % one true causes(move_from_to(Rob,From,To), is_at(Rob, To),T) :- time(T), robot(Rob), way_point(From), way_point(To). causes(move_from_to(Rob,From,To), neg(is_at(Rob,From)),T) :- time(T), robot(Rob), way_point(From), way_point(To). %%% Open a door means that the door is now not closed causes(open_door(Rob,Room), accessible(Room),T) :- time(T), robot(Rob), room_point(Room). %%% Make a back rotation means the versus are changed... causes(turn_towards(Rob, Old_orient, New_orient), is_oriented(Rob, New_orient),T) :- time(T), robot(Rob), orientation(Old_orient), orientation(New_orient), Old_orient != New_orient. causes(turn_towards(Rob, Old_orient, New_orient), neg(is_oriented(Rob, Old_orient)),T) :- time(T), robot(Rob), orientation(Old_orient), orientation(New_orient), Old_orient != New_orient.