Skip to content

Commit fa31f1c

Browse files
committed
Merge pull request #177 from yianni/todos2
Todos2
2 parents 7b78137 + 6c37846 commit fa31f1c

32 files changed

+403
-421
lines changed

docs/rsts/handwritten/usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ MWE source code:
4848
4949
# ****************************************************************************************************
5050
# parse command line arguments
51-
options = sorted(qsrlib.get_qsrs_registry().keys())
51+
options = sorted(qsrlib.qsrs_registry.keys())
5252
parser = argparse.ArgumentParser()
5353
parser.add_argument("qsr", help="choose qsr: %s" % options, type=str)
5454
args = parser.parse_args()

qsr_lib/dbg/dbg_cardinal_directions.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ class Dbg(object):
88
def __init__(self):
99
pass
1010

11-
def return_bounding_box_2d(self, x, y, width, length):
11+
def return_bounding_box_2d(self, x, y, xsize, ysize):
1212
"""Return the bounding box
1313
1414
:param x: x center
1515
:param y: y center
16-
:param width: x size
17-
:param length: y size
16+
:param xsize: x size
17+
:param ysize: y size
1818
:return: list(x1, y1, x2, y2) where (x1, y1) and (x2, y2) are the coordinates of the diagonal points of the
1919
bounding box depending on your coordinates frame
2020
"""
2121

22-
if width <= 0 or length <= 0:
23-
print("ERROR: can't compute bounding box, width or height has no positive value")
22+
if xsize <= 0 or ysize <= 0:
23+
print("ERROR: can't compute bounding box, xsize or height has no positive value")
2424
return []
25-
return [x-width/2, y-length/2, x+width/2, y+length/2]
25+
return [x-xsize/2, y-ysize/2, x+xsize/2, y+ysize/2]
2626

2727

2828
def compute_qsr(self, bb1, bb2):
@@ -93,7 +93,7 @@ def plot_bbs(bb1, bb2):
9393
if __name__ == '__main__':
9494
dbg = Dbg()
9595

96-
# Play with these to test (x_center, y_center, width(i.e. x-size), length(i.e. y-size))
96+
# Play with these to test (x_center, y_center, xsize(i.e. x-size), ysize(i.e. y-size))
9797
o1 = (2.0, 2.0, 1., 1.)
9898
o2 = (1., 3., 1., 1.)
9999

qsr_lib/dbg/dbg_rcc3.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
from matplotlib.patches import Rectangle
66

77

8-
def return_bounding_box_2d(x, y, width, length):
8+
def return_bounding_box_2d(x, y, xsize, ysize):
99
"""Return the bounding box
1010
1111
:param x: x center
1212
:param y: y center
13-
:param width: x size
14-
:param length: y size
13+
:param xsize: x size
14+
:param ysize: y size
1515
:return: list(x1, y1, x2, y2) where (x1, y1) and (x2, y2) are the coordinates of the diagonal points of the
1616
bounding box depending on your coordinates frame
1717
"""
18-
if width <= 0 or length <= 0:
19-
print("ERROR: can't compute bounding box, width or height has no positive value")
18+
if xsize <= 0 or ysize <= 0:
19+
print("ERROR: can't compute bounding box, xsize or height has no positive value")
2020
return []
21-
return [x-width/2, y-length/2, x+width/2, y+length/2]
21+
return [x-xsize/2, y-ysize/2, x+xsize/2, y+ysize/2]
2222

2323

2424
def compute_qsr(bb1, bb2):
@@ -120,18 +120,18 @@ def plot_bbs(bb1, bb2):
120120
plt.show()
121121

122122

123-
# o1 = [Object_State(name="o1", timestamp=0, x=1., y=1., width=5., length=8.),
124-
# Object_State(name="o1", timestamp=1, x=1., y=2., width=5., length=8.),
125-
# Object_State(name="o1", timestamp=2, x=1., y=3., width=5., length=8.)]
123+
# o1 = [Object_State(name="o1", timestamp=0, x=1., y=1., xsize=5., ysize=8.),
124+
# Object_State(name="o1", timestamp=1, x=1., y=2., xsize=5., ysize=8.),
125+
# Object_State(name="o1", timestamp=2, x=1., y=3., xsize=5., ysize=8.)]
126126
#
127-
# o2 = [Object_State(name="o2", timestamp=0, x=11., y=1., width=5., length=8.),
128-
# Object_State(name="o2", timestamp=1, x=11., y=2., width=5., length=8.),
129-
# Object_State(name="o2", timestamp=2, x=11., y=3., width=5., length=8.),
130-
# Object_State(name="o2", timestamp=3, x=11., y=4., width=5., length=8.)]
127+
# o2 = [Object_State(name="o2", timestamp=0, x=11., y=1., xsize=5., ysize=8.),
128+
# Object_State(name="o2", timestamp=1, x=11., y=2., xsize=5., ysize=8.),
129+
# Object_State(name="o2", timestamp=2, x=11., y=3., xsize=5., ysize=8.),
130+
# Object_State(name="o2", timestamp=3, x=11., y=4., xsize=5., ysize=8.)]
131131
#
132-
# o3 = [Object_State(name="o3", timestamp=0, x=1., y=11., width=5., length=8.),
133-
# Object_State(name="o3", timestamp=1, x=2., y=11., width=5., length=8.),
134-
# Object_State(name="o3", timestamp=2, x=3., y=11., width=5., length=8.)]
132+
# o3 = [Object_State(name="o3", timestamp=0, x=1., y=11., xsize=5., ysize=8.),
133+
# Object_State(name="o3", timestamp=1, x=2., y=11., xsize=5., ysize=8.),
134+
# Object_State(name="o3", timestamp=2, x=3., y=11., xsize=5., ysize=8.)]
135135

136136
o1 = (2.0, 2.0, 2., 2.)
137137
o2 = (4.0, 3.0, 1., 1.)

qsr_lib/dbg/dbg_rcc8.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ class Dbg(object):
88
def __init__(self):
99
pass
1010

11-
def return_bounding_box_2d(self, x, y, width, length):
11+
def return_bounding_box_2d(self, x, y, xsize, ysize):
1212
"""Return the bounding box
1313
1414
:param x: x center
1515
:param y: y center
16-
:param width: x size
17-
:param length: y size
16+
:param xsize: x size
17+
:param ysize: y size
1818
:return: list(x1, y1, x2, y2) where (x1, y1) and (x2, y2) are the coordinates of the diagonal points of the
1919
bounding box depending on your coordinates frame
2020
"""
21-
if width <= 0 or length <= 0:
22-
print("ERROR: can't compute bounding box, width or height has no positive value")
21+
if xsize <= 0 or ysize <= 0:
22+
print("ERROR: can't compute bounding box, xsize or height has no positive value")
2323
return []
24-
return [x-width/2, y-length/2, x+width/2, y+length/2]
24+
return [x-xsize/2, y-ysize/2, x+xsize/2, y+ysize/2]
2525

2626

2727
def compute_qsr(self, bb1, bb2):
@@ -160,7 +160,7 @@ def plot_bbs(bb1, bb2):
160160
+-------------+ +-------------+
161161
"""
162162

163-
# Play with these to test (x_center, y_center, width(i.e. x-size), length(i.e. y-size))
163+
# Play with these to test (x_center, y_center, xsize(i.e. x-size), ysize(i.e. y-size))
164164
o1 = (3., 3., 2., 2.)
165165
o2 = (3., 2., 1., 1.)
166166

qsr_lib/dbg/dbg_template_bounding_boxes_qsrs.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ class Dbg(object):
88
def __init__(self):
99
pass
1010

11-
def return_bounding_box_2d(self, x, y, width, length):
11+
def return_bounding_box_2d(self, x, y, xsize, ysize):
1212
"""Return the bounding box
1313
1414
:param x: x center
1515
:param y: y center
16-
:param width: x size
17-
:param length: y size
16+
:param xsize: x size
17+
:param ysize: y size
1818
:return: list(x1, y1, x2, y2) where (x1, y1) and (x2, y2) are the coordinates of the diagonal points of the
1919
bounding box depending on your coordinates frame
2020
"""
2121

22-
if width <= 0 or length <= 0:
23-
print("ERROR: can't compute bounding box, width or height has no positive value")
22+
if xsize <= 0 or ysize <= 0:
23+
print("ERROR: can't compute bounding box, xsize or height has no positive value")
2424
return []
25-
return [x-width/2, y-length/2, x+width/2, y+length/2]
25+
return [x-xsize/2, y-ysize/2, x+xsize/2, y+ysize/2]
2626

2727

2828
def compute_qsr(self, bb1, bb2):
@@ -65,7 +65,7 @@ def plot_bbs(bb1, bb2):
6565
if __name__ == '__main__':
6666
dbg = Dbg()
6767

68-
# Play with these to test (x_center, y_center, width(i.e. x-size), length(i.e. y-size))
68+
# Play with these to test (x_center, y_center, xsize(i.e. x-size), ysize(i.e. y-size))
6969
o1 = (2.0, 2.0, 2., 2.)
7070
o2 = (4.0, 3.0, 1., 1.)
7171

qsr_lib/dbg/dbg_world_qsr_trace_slicing_methods.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def print_world_trace(world_trace):
99
for t in world_trace.get_sorted_timestamps():
1010
print("-t:", t)
1111
for oname, o in world_trace.trace[t].objects.items():
12-
print("%s\t%f\t%f\t%f\t%f\t%f\t%f" % (oname, o.x, o.y, o.z, o.width, o.length, o.width))
12+
print("%s\t%f\t%f\t%f\t%f\t%f\t%f" % (oname, o.x, o.y, o.z, o.xsize, o.ysize, o.xsize))
1313

1414
def pretty_print_world_qsr_trace(which_qsr, qsrlib_response_message):
1515
print(which_qsr, "request was made at ", str(qsrlib_response_message.req_made_at)
@@ -26,21 +26,21 @@ def pretty_print_world_qsr_trace(which_qsr, qsrlib_response_message):
2626

2727
def print_world_state(world_state):
2828
for oname, o in world_state.objects.items():
29-
print("%s\t%f\t%f\t%f\t%f\t%f\t%f" % (oname, o.x, o.y, o.z, o.width, o.length, o.width))
29+
print("%s\t%f\t%f\t%f\t%f\t%f\t%f" % (oname, o.x, o.y, o.z, o.xsize, o.ysize, o.xsize))
3030

3131
if __name__ == "__main__":
3232
world = World_Trace()
33-
o1 = [Object_State(name="o1", timestamp=0, x=1., y=1., width=5., length=8.),
34-
Object_State(name="o1", timestamp=1, x=1., y=2., width=5., length=8.),
35-
Object_State(name="o1", timestamp=2, x=1., y=3., width=5., length=8.),
36-
Object_State(name="o1", timestamp=3, x=1., y=4., width=5., length=8.),
37-
Object_State(name="o1", timestamp=4, x=1., y=5., width=5., length=8.)]
33+
o1 = [Object_State(name="o1", timestamp=0, x=1., y=1., xsize=5., ysize=8.),
34+
Object_State(name="o1", timestamp=1, x=1., y=2., xsize=5., ysize=8.),
35+
Object_State(name="o1", timestamp=2, x=1., y=3., xsize=5., ysize=8.),
36+
Object_State(name="o1", timestamp=3, x=1., y=4., xsize=5., ysize=8.),
37+
Object_State(name="o1", timestamp=4, x=1., y=5., xsize=5., ysize=8.)]
3838

39-
o2 = [Object_State(name="o2", timestamp=0, x=11., y=1., width=5., length=8.),
40-
Object_State(name="o2", timestamp=1, x=11., y=2., width=5., length=8.),
41-
Object_State(name="o2", timestamp=2, x=11., y=3., width=5., length=8.),
42-
Object_State(name="o2", timestamp=3, x=11., y=4., width=5., length=8.),
43-
Object_State(name="o2", timestamp=4, x=11., y=5., width=5., length=8.)]
39+
o2 = [Object_State(name="o2", timestamp=0, x=11., y=1., xsize=5., ysize=8.),
40+
Object_State(name="o2", timestamp=1, x=11., y=2., xsize=5., ysize=8.),
41+
Object_State(name="o2", timestamp=2, x=11., y=3., xsize=5., ysize=8.),
42+
Object_State(name="o2", timestamp=3, x=11., y=4., xsize=5., ysize=8.),
43+
Object_State(name="o2", timestamp=4, x=11., y=5., xsize=5., ysize=8.)]
4444
world.add_object_state_series(o1)
4545
world.add_object_state_series(o2)
4646

qsr_lib/dbg/dbg_world_trace_slicing_methods.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@ def print_world_trace(world_trace):
88
for t in world_trace.get_sorted_timestamps():
99
print("-t:", t)
1010
for oname, o in world_trace.trace[t].objects.items():
11-
print("%s\t%f\t%f\t%f\t%f\t%f\t%f" % (oname, o.x, o.y, o.z, o.width, o.length, o.width))
11+
print("%s\t%f\t%f\t%f\t%f\t%f\t%f" % (oname, o.x, o.y, o.z, o.xsize, o.ysize, o.xsize))
1212

1313
def print_world_state(world_state):
1414
for oname, o in world_state.objects.items():
15-
print("%s\t%f\t%f\t%f\t%f\t%f\t%f" % (oname, o.x, o.y, o.z, o.width, o.length, o.width))
15+
print("%s\t%f\t%f\t%f\t%f\t%f\t%f" % (oname, o.x, o.y, o.z, o.xsize, o.ysize, o.xsize))
1616

1717
if __name__ == "__main__":
1818
world = World_Trace()
19-
o1 = [Object_State(name="o1", timestamp=0, x=1., y=1., width=5., length=8.),
20-
Object_State(name="o1", timestamp=1, x=1., y=2., width=5., length=8.),
21-
Object_State(name="o1", timestamp=2, x=1., y=3., width=5., length=8.),
22-
Object_State(name="o1", timestamp=3, x=1., y=4., width=5., length=8.),
23-
Object_State(name="o1", timestamp=4, x=1., y=5., width=5., length=8.)]
19+
o1 = [Object_State(name="o1", timestamp=0, x=1., y=1., xsize=5., ysize=8.),
20+
Object_State(name="o1", timestamp=1, x=1., y=2., xsize=5., ysize=8.),
21+
Object_State(name="o1", timestamp=2, x=1., y=3., xsize=5., ysize=8.),
22+
Object_State(name="o1", timestamp=3, x=1., y=4., xsize=5., ysize=8.),
23+
Object_State(name="o1", timestamp=4, x=1., y=5., xsize=5., ysize=8.)]
2424

25-
o2 = [Object_State(name="o2", timestamp=0, x=11., y=1., width=5., length=8.),
26-
Object_State(name="o2", timestamp=1, x=11., y=2., width=5., length=8.),
27-
Object_State(name="o2", timestamp=2, x=11., y=3., width=5., length=8.),
28-
Object_State(name="o2", timestamp=3, x=11., y=4., width=5., length=8.),
29-
Object_State(name="o2", timestamp=4, x=11., y=5., width=5., length=8.)]
25+
o2 = [Object_State(name="o2", timestamp=0, x=11., y=1., xsize=5., ysize=8.),
26+
Object_State(name="o2", timestamp=1, x=11., y=2., xsize=5., ysize=8.),
27+
Object_State(name="o2", timestamp=2, x=11., y=3., xsize=5., ysize=8.),
28+
Object_State(name="o2", timestamp=3, x=11., y=4., xsize=5., ysize=8.),
29+
Object_State(name="o2", timestamp=4, x=11., y=5., xsize=5., ysize=8.)]
3030
world.add_object_state_series(o1)
3131
world.add_object_state_series(o2)
3232

qsr_lib/scripts/basic_qsr_visualiser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def __compute_qsr(self, bb1, bb2):
3838

3939
qsrlib = QSRlib()
4040
world = World_Trace()
41-
world.add_object_state_series([Object_State(name="red", timestamp=0, x=((ax+bx)/2.0), y=((ay+by)/2.0), width=abs(bx-ax), length=abs(by-ay)),
42-
Object_State(name="yellow", timestamp=0, x=((cx+dx)/2.0), y=((cy+dy)/2.0), width=abs(dx-cx), length=abs(dy-cy))])
41+
world.add_object_state_series([Object_State(name="red", timestamp=0, x=((ax+bx)/2.0), y=((ay+by)/2.0), xsize=abs(bx-ax), ysize=abs(by-ay)),
42+
Object_State(name="yellow", timestamp=0, x=((cx+dx)/2.0), y=((cy+dy)/2.0), xsize=abs(dx-cx), ysize=abs(dy-cy))])
4343
dynamic_args = {"argd": {"qsr_relations_and_values": self.distance}}
4444
qsrlib_request_message = QSRlib_Request_Message(which_qsr=self.qsr, input_data=world, dynamic_args=dynamic_args)
4545
qsrlib_response_message = qsrlib.request_qsrs(req_msg=qsrlib_request_message)
@@ -165,4 +165,4 @@ def processArgs(self):
165165
if __name__ == "__main__":
166166
vis = qsr_gui()
167167
vis.processArgs()
168-
vis.initWindow()
168+
vis.initWindow()

0 commit comments

Comments
 (0)