|
4 | 4 |
|
5 | 5 | mem_clear_memory() :-
|
6 | 6 | drop_graph(user),
|
7 |
| - tf_mem_clear, mng_drop(roslog, tf), |
8 |
| - wrench_mem_clear, wrench_mng_drop. |
| 7 | + tf_mem_clear, |
| 8 | + mng_drop(roslog, tf). |
9 | 9 |
|
10 |
| -mem_episode_start(Action, TaskType, EnvOwl, EnvOwlIndiName, EnvUrdf, AgentOwl, AgentOwlIndiName, AgentUrdf) :- |
| 10 | +mem_episode_start(Action, EnvOwl, EnvOwlIndiName, EnvUrdf, EnvUrdfPrefix, AgentOwl, AgentOwlIndiName, AgentUrdf) :- |
11 | 11 | get_time(StartTime),
|
12 |
| - mem_episode_start(Action, TaskType, EnvOwl, EnvOwlIndiName, EnvUrdf, AgentOwl, AgentOwlIndiName, AgentUrdf, StartTime). |
| 12 | + mem_episode_start(Action, EnvOwl, EnvOwlIndiName, EnvUrdf, EnvUrdfPrefix, AgentOwl, AgentOwlIndiName, AgentUrdf, StartTime). |
13 | 13 |
|
14 |
| -mem_episode_start(Action, TaskType, EnvOwl, EnvOwlIndiName, EnvUrdf, AgentOwl, AgentOwlIndiName, AgentUrdf, |
15 |
| - StartTime) :- |
| 14 | +mem_episode_start(Action, EnvOwl, EnvOwlIndiName, EnvUrdf, EnvUrdfPrefix, AgentOwl, AgentOwlIndiName, AgentUrdf, StartTime) :- |
16 | 15 | retractall(execution_agent(_)),
|
17 |
| - tf_logger_disable, wrench_logger_disable, |
| 16 | + tf_logger_disable, |
18 | 17 | mem_clear_memory,
|
19 |
| - tf_logger_enable, wrench_logger_enable, |
20 |
| - % load_owl('package://knowrob/owl/knowrob.owl',[namespace(knowrob)]), % Is always loaded when knowrob starts |
| 18 | + tf_logger_enable, |
21 | 19 | load_owl(EnvOwl),
|
22 | 20 | load_owl(AgentOwl),
|
23 | 21 | urdf_load(AgentOwlIndiName, AgentUrdf, [load_rdf]),
|
24 |
| - urdf_load(EnvOwlIndiName, EnvUrdf, [load_rdf]), |
| 22 | + urdf_load(EnvOwlIndiName, EnvUrdf, [load_rdf,prefix(EnvUrdfPrefix)]), |
25 | 23 | assertz(execution_agent(AgentOwlIndiName)),
|
26 | 24 | execution_agent(Agent),
|
27 | 25 | kb_project([
|
28 | 26 | new_iri(Episode, soma:'Episode'), is_episode(Episode), % Using new_iri here and below is a hideous workaround for a KnowRob bug, see https://github.com/knowrob/knowrob/issues/299
|
29 | 27 | new_iri(Action, dul:'Action'), is_action(Action),
|
30 | 28 | new_iri(TimeInterval, dul:'TimeInterval'), holds(Action, dul:'hasTimeInterval', TimeInterval), holds(TimeInterval, soma:'hasIntervalBegin', StartTime),
|
31 |
| - new_iri(Task, dul:'Task'), instance_of(Task,TaskType), executes_task(Action,Task), |
| 29 | + new_iri(Task, dul:'Task'), has_type(Task,soma:'PhysicalTask'), executes_task(Action,Task), |
32 | 30 | is_setting_for(Episode,Action),
|
33 | 31 | is_performed_by(Action,Agent),
|
34 | 32 | new_iri(Role, soma:'AgentRole'), has_type(Role, soma:'AgentRole'), has_role(Agent,Role)
|
|
48 | 46 | is_episode(Episode), is_action(Action), is_setting_for(Episode,Action),
|
49 | 47 | holds(Action, dul:'hasTimeInterval', TimeInterval)
|
50 | 48 | ]),
|
| 49 | + ignore(kb_unproject(triple(TimeInterval, soma:'hasIntervalEnd', double('Infinity')))), |
51 | 50 | kb_project([
|
52 | 51 | holds(TimeInterval, soma:'hasIntervalEnd', EndTime)
|
53 | 52 | ]),
|
|
59 | 58 |
|
60 | 59 | mem_event_add_diagnosis(Situation, Diagnosis) :- kb_project(satisfies(Situation, Diagnosis)).
|
61 | 60 |
|
62 |
| -mem_add_subaction_with_task(ParentAction,SubActionType,TaskType,SubAction) :- |
| 61 | +add_subaction_with_task(ParentAction,SubAction,TaskType) :- |
63 | 62 | execution_agent(Agent),
|
64 | 63 | kb_project([
|
65 |
| - new_iri(SubAction, SubActionType), is_individual(SubAction), instance_of(SubAction,SubActionType), |
66 |
| - new_iri(Task, TaskType), is_individual(Task), instance_of(Task,TaskType), executes_task(SubAction,Task), |
67 |
| - % % has_subevent(ParentAction,SubAction), <-- has_subevent is currently broken in KnowRob (https://github.com/knowrob/knowrob/issues/300) |
| 64 | + new_iri(SubAction, dul:'Action'), has_type(SubAction,soma:'Action'), |
| 65 | + new_iri(Task, TaskType), has_type(Task,TaskType), executes_task(SubAction,Task), |
68 | 66 | holds(ParentAction,dul:hasConstituent,SubAction), % replacement for has_subevent
|
69 | 67 | is_performed_by(SubAction,Agent)
|
70 | 68 | ]),!.
|
71 | 69 |
|
72 |
| -% mem_event_end(Event) :- execution_agent(Agent), get_time(CurrentTime), kb_call([triple(Event,dul:'hasTimeInterval',TimeInterval), triple(TimeInterval,soma:'hasIntervalBegin', Start), executes_task(Event,Task)]),kb_unproject(TimeInterval, soma:'hasIntervalEnd', _),kb_project([holds(TimeInterval, soma:'hasIntervalEnd', CurrentTime),has_type(Role, soma:'AgentRole'), has_role(Agent,Role) during Event,task_role(Task, Role)]),!. |
73 |
| - |
74 |
| -% mem_event_begin(Event) :- get_time(CurrentTime),kb_project(occurs(Event) since CurrentTime),!. |
| 70 | +mem_event_end(Event) :- execution_agent(Agent), |
| 71 | + get_time(CurrentTime), |
| 72 | + kb_call([ |
| 73 | + triple(Event,dul:'hasTimeInterval',TimeInterval), |
| 74 | + triple(TimeInterval,soma:'hasIntervalBegin', Start), executes_task(Event,Task)]), |
| 75 | + ignore(kb_unproject(triple(TimeInterval, soma:'hasIntervalEnd', double('Infinity')))), |
| 76 | + kb_project([holds(TimeInterval, soma:'hasIntervalEnd', CurrentTime),new_iri(Role, soma:'AgentRole'),has_type(Role, soma:'AgentRole')]), |
| 77 | + kb_project([has_role(Agent,Role) during Event, task_role(Task, Role)]),!. |
| 78 | + mem_event_begin(Event) :- get_time(CurrentTime),kb_project(occurs(Event) since CurrentTime),!. |
75 | 79 |
|
76 | 80 | %belief_perceived_at(ObjectType, Frame, Object) :- get_time(CurrentTime),execution_agent(Agent),kb_project([has_type(Object,ObjectType),is_at(Object,Frame) since CurrentTime]).
|
77 | 81 |
|
78 |
| -belief_perceived_at(ObjectType, Mesh, Rotation, Object) :- kb_project([has_type(Object,ObjectType),has_type(ShapeRegion, soma:'MeshShape'), has_type(Shape, soma:'Shape'), triple(Object, soma:'hasShape', Shape), triple(Shape, dul:'hasRegion', ShapeRegion), triple(ShapeRegion, soma:'hasFilePath', Mesh),has_type(Origin,soma:'Origin'),triple(ShapeRegion,'http://knowrob.org/kb/urdf.owl#hasOrigin',Origin),triple(Origin, 'http://www.ease-crc.org/ont/SOMA.owl#hasPositionVector', term([0.0,0.0,0.0])),triple(Origin, 'http://www.ease-crc.org/ont/SOMA.owl#hasOrientationVector',term(Rotation))]). |
| 82 | +belief_perceived_at(ObjectType, Mesh, Rotation, Object) :- kb_project([ |
| 83 | + has_type(Object,ObjectType), |
| 84 | + new_iri(ShapeRegion,soma:'MeshShape'), has_type(ShapeRegion, soma:'MeshShape'), |
| 85 | + new_iri(Shape, soma:'Shape'), has_type(Shape, soma:'Shape'), |
| 86 | + triple(Object, soma:'hasShape', Shape), |
| 87 | + triple(Shape, dul:'hasRegion', ShapeRegion), |
| 88 | + triple(ShapeRegion, soma:'hasFilePath', Mesh), |
| 89 | + new_iri(Origin, soma:'Origin'), has_type(Origin,soma:'Origin'), |
| 90 | + triple(ShapeRegion,'http://knowrob.org/kb/urdf.owl#hasOrigin',Origin), |
| 91 | + triple(Origin, 'http://www.ease-crc.org/ont/SOMA.owl#hasPositionVector', term([0.0,0.0,0.0])), |
| 92 | + triple(Origin, 'http://www.ease-crc.org/ont/SOMA.owl#hasOrientationVector', term(Rotation))]). |
79 | 93 |
|
80 | 94 | belief_perceived_at(ObjectType, Object) :- kb_project([has_type(Object,ObjectType)]).
|
81 | 95 |
|
82 |
| -mem_tf_set(Object, Pose, Timestamp) :- |
| 96 | +mem_tf_set(Object, ReferenceFrame, Position, Rotation, Timestamp) :- |
83 | 97 | time_scope(=(Timestamp), =<('Infinity'), FScope),
|
84 |
| - tf_set_pose(Object, Pose, FScope). |
| 98 | + tf_set_pose(Object, [ReferenceFrame, Position, Rotation], FScope). |
85 | 99 |
|
86 |
| -mem_tf_get(Object, Pose) :- |
| 100 | +mem_tf_get(Object, ReferenceFrame, Position, Rotation) :- |
87 | 101 | current_scope(QScope),
|
88 |
| - tf_get_pose(Object, Pose, QScope, _). |
| 102 | + tf_get_pose(Object, [ReferenceFrame, Position, Rotation], QScope, _). |
89 | 103 |
|
90 |
| -mem_tf_get(Object, Pose, Timestamp) :- |
| 104 | +mem_tf_get(Object, ReferenceFrame, Position, Rotation, Timestamp) :- |
91 | 105 | time_scope(=(Timestamp), =(Timestamp), QScope),
|
92 |
| - tf_get_pose(Object, Pose, QScope, _). |
93 |
| - |
94 |
| -mem_wrench_set(Object, Force, Torque, Timestamp) :- |
95 |
| - write('mem_wrench_set, object: '), |
96 |
| - write(Object), |
97 |
| - write('\n'), |
98 |
| - time_scope(=(Timestamp), =<('Infinity'), FScope), |
99 |
| - wrench_set(Object, [Force, Torque], FScope), |
100 |
| - write('wrench_set succeeded\n'). |
101 |
| - |
102 |
| -mem_add_participant_with_role(Action, ObjectId, RoleType) :- |
103 |
| - kb_call(executes_task(Action, Task)), |
104 |
| - kb_project([ |
105 |
| - has_participant(Action,ObjectId), |
106 |
| - new_iri(Role, dul:'Role'), is_individual(Role), instance_of(Role, RoleType), |
107 |
| - has_task_role(Task, Role), |
108 |
| - has_role(ObjectId, Role) |
109 |
| - ]). |
110 |
| - |
111 |
| -add_parameter(Task, ParameterType, RegionType, Parameter) :- |
112 |
| - kb_project([ |
113 |
| - new_iri(Parameter, dul:Parameter), |
114 |
| - has_type(Parameter, ParameterType), |
115 |
| - has_parameter(Task, Parameter), |
116 |
| - new_iri(Region, dul:Region), |
117 |
| - has_type(Region, RegionType), |
118 |
| - has_assignment(Parameter, Region) |
119 |
| - ]). |
120 |
| - |
121 |
| -add_named_parameter(Task, ParameterType, ParameterName, RegionType, Parameter) :- |
122 |
| - add_parameter(Task, ParameterType, RegionType, Parameter), |
123 |
| - kb_project(holds(Parameter, soma:hasNameString, ParameterName)). |
124 |
| - |
125 |
| -% set_parameter_value_during_interval(Parameter, ParameterValue, Begin, End) :- |
126 |
| -% has_assignment(Parameter, Region), |
127 |
| -% kb_project(holds(Region, dul:hasRegionDataValue, ParameterValue) during [Begin, End]). |
128 |
| - |
129 |
| -set_parameter_value(Parameter, ParameterValue) :- |
130 |
| - has_assignment(Parameter, Region), |
131 |
| - kb_project(holds(Region, dul:hasRegionDataValue, ParameterValue)). |
132 |
| - |
133 |
| -add_grasping_parameter(Action,GraspingOrientationType) :- kb_call(executes_task(Action, Task)), kb_project([has_type(GraspingOrientation,GraspingOrientationType), has_type(GraspingOrientationConcept,'http://www.ease-crc.org/ont/SOMA.owl#GraspingOrientation'), has_parameter(Task,GraspingOrientationConcept),holds(GraspingOrientationConcept, dul:classifies, GraspingOrientation),has_region(Action,GraspingOrientation)]),!. |
| 106 | + tf_get_pose(Object, [ReferenceFrame, Position, Rotation], QScope, _). |
| 107 | + |
| 108 | +add_participant_with_role(Action, ObjectId, RoleType) :- |
| 109 | + kb_call([executes_task(Action, Task), |
| 110 | + triple(Event,dul:'hasTimeInterval',TimeInterval), |
| 111 | + triple(TimeInterval,soma:'hasIntervalBegin',Start), |
| 112 | + triple(TimeInterval,soma:'hasIntervalEnd',End)]), |
| 113 | + kb_project([has_participant(Action,ObjectId), |
| 114 | + has_type(Role, RoleType), |
| 115 | + has_role(ObjectId,Role) during Action,task_role(Task, Role)]). |
| 116 | + %kb_project([holds(TimeInterval, soma:'hasIntervalEnd', CurrentTime),new_iri(Role, soma:'AgentRole'),has_type(Role, soma:'AgentRole')]), |
| 117 | + %kb_project([has_role(Agent,Role) during Event, task_role(Task, Role)]),!. |
| 118 | + |
| 119 | +%add_participant_with_role(Action, ObjectId, RoleType) :- kb_call(executes_task(Action, Task)), kb_project([has_participant(Action,ObjectId), has_type(Role, RoleType), has_role(ObjectId,Role) during [0.0,0.0]]). |
| 120 | + |
| 121 | + add_parameter(Task,ParameterType,RegionType) :- kb_project([new_iri(Parameter, ParameterType), has_type(Parameter, ParameterType), |
| 122 | + new_iri(Region,RegionType),has_type(Region,RegionType), |
| 123 | + has_assignment(Parameter,Region) during [0.0,0.1], |
| 124 | + has_parameter(Task, Parameter)]). |
| 125 | + |
| 126 | +add_grasping_parameter(Action,GraspingOrientationType) :- kb_call(executes_task(Action, Task)), |
| 127 | + kb_project([new_iri(GraspingOrientation,GraspingOrientationType), has_type(GraspingOrientation,GraspingOrientationType), |
| 128 | + new_iri(GraspingOrientationConcept,'http://www.ease-crc.org/ont/SOMA.owl#GraspingOrientation'), |
| 129 | + has_type(GraspingOrientationConcept,'http://www.ease-crc.org/ont/SOMA.owl#GraspingOrientation'), |
| 130 | + has_parameter(Task,GraspingOrientationConcept), |
| 131 | + holds(GraspingOrientationConcept, dul:classifies, GraspingOrientation), |
| 132 | + has_region(Action,GraspingOrientation)]),!. |
134 | 133 |
|
135 | 134 | add_comment(Entity,Comment) :- kb_project(triple(Entity, 'http://www.w3.org/2000/01/rdf-schema#comment', Comment)).
|
136 | 135 | ros_logger_start :- process_create(path('rosrun'),['mongodb_log', 'mongodb_log.py','__name:=topic_logger', '--mongodb-name', 'roslog', '/tf_projection', '/tf'],[process(PID)]),asserta(ros_logger_pid(PID)).
|
|
143 | 142 | [stdin(pipe(In)), detached(true), process(TLPID)]),
|
144 | 143 | writeln(In,'y'),flush_output(In), process_wait(TLPID, _),
|
145 | 144 | print_message(informational,'Topic Logger stopped').
|
146 |
| - |
147 |
| - |
148 |
| - |
149 |
| -% test_tf_query :- kb_call([triple('http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#Action_DCJBWPIE',dul:'hasTimeInterval',_O), triple(_O, soma:'hasIntervalBegin', _T2)]),time_scope(=<(_T2), >=(_T2), QScope),writeln(_T2),tf_get_pose('base_footprint', ['map',Position,Orientation], QScope, _),!. |
0 commit comments