Skip to content

Commit 155e773

Browse files
author
Sascha Jongebloed
committed
Minor fixes. Query should work now
1 parent 94d35d6 commit 155e773

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

scripts/knowrob_designator_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ def testQueryDesig():
2121
know = KnowRobRosLib()
2222
know.init_clients() # After rospy.init_node()
2323

24-
query = "triple(?d, rdf:type, soma:PyCramActionDesignator)"
24+
query = "triple(?d, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.ease-crc.org/ont/SOMA.owl#PyCramActionDesignator')"
2525
rospy.loginfo(f"asking [{query}] ...")
26-
result = know.ask_one(query, get_default_modalframe())
26+
result = know.ask_all(query, get_default_modalframe())
2727
rospy.loginfo(f"response: [{result}]")
2828

2929
def main():

scripts/knowrob_designator_service.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,22 @@ def handle_resolve_start(self, msg):
6464
# Translate triples to knowrob triples
6565
builder = TripleQueryBuilder()
6666
for s, p, o in triples:
67+
# Remove leading < or trailing > if present
68+
s = s[1:] if s.startswith("<") else s
69+
s = s[:-1] if s.endswith(">") else s
70+
71+
p = p[1:] if p.startswith("<") else p
72+
p = p[:-1] if p.endswith(">") else p
73+
74+
o = o[1:] if o.startswith("<") else o
75+
o = o[:-1] if o.endswith(">") else o
76+
77+
# Add the triple to the builder
6778
builder.add(s, p, o)
6879
# Set the modal frame
6980
modal_frame = get_default_modalframe()
70-
modal_frame.minPastTimestamp = msg.stamp.to_sec()
71-
modal_frame.confidence = 1.0
81+
# modal_frame.minPastTimestamp = msg.stamp.to_sec()
82+
# modal_frame.confidence = 1.0
7283
# Add the designator to knowrob
7384
self.knowrob.tell(builder.get_triples(), modal_frame)
7485
rospy.loginfo(f"Sent {len(triples)} unresolved Action designator triples for {designator_id}")
@@ -102,9 +113,10 @@ def handle_resolve_finished(self, msg):
102113
builder.add(s, p, o)
103114
# Set the modal frame
104115
modal_frame = get_default_modalframe()
105-
modal_frame.minPastTimestamp = msg.stamp.to_sec()
106-
modal_frame.confidence = 1.0
116+
# modal_frame.minPastTimestamp = msg.stamp.to_sec()
117+
# modal_frame.confidence = 1.0
107118
# Add the designator to knowrob
119+
self.knowrob.tell(builder.get_triples(), modal_frame)
108120
rospy.loginfo(f"Sent {len(triples)} resolving triples for Action task {resolving_uri}")
109121
if print_triples:
110122
to_print = ""
@@ -130,8 +142,8 @@ def handle_exec_start(self, msg):
130142
builder.add(s, p, o)
131143
# Set the modal frame
132144
modal_frame = get_default_modalframe()
133-
modal_frame.minPastTimestamp = msg.stamp.to_sec()
134-
modal_frame.confidence = 1.0
145+
# modal_frame.minPastTimestamp = msg.stamp.to_sec()
146+
# modal_frame.confidence = 1.0
135147
# Add the designator to knowrob
136148
self.knowrob.tell(builder.get_triples(), modal_frame)
137149
rospy.loginfo(f"Sent {len(triples)} execution start triples for {msg.designator_id}")

src/knowrob_designator/designator_parser.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
class DesignatorParser:
55
# Define the prefixes
66
PREFIXES = {
7-
"SOMA": "<http://www.ease-crc.org/ont/SOMA.owl#>",
8-
"dul": "<http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#>",
9-
"rdf": "<http://www.w3.org/1999/02/22-rdf-syntax-ns#>",
10-
"owl": "<http://www.w3.org/2002/07/owl#>"
7+
"SOMA": "<http://www.ease-crc.org/ont/SOMA.owl>",
8+
"dul": "<http://www.ontologydesignpatterns.org/ont/dul/DUL.owl>",
9+
"rdf": "<http://www.w3.org/1999/02/22-rdf-syntax-ns>",
10+
"owl": "<http://www.w3.org/2002/07/owl>"
1111
}
1212

1313
# Triple type for readability

0 commit comments

Comments
 (0)