Skip to content

Commit 35fd1f6

Browse files
author
Andrew Lui
committed
task_scene.py has a revampled and simplified API based on a revised config file format on how scenes are defined and the removal of the subscene concept. modify the create_array_marker function in rviz_tool that the arrow can indicate changes in pitch
1 parent b8474f4 commit 35fd1f6

36 files changed

+1139
-783
lines changed

demos/gridscan/behaviours_gridscan.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,20 @@ def __init__(self, name, arm_commander=None, scene=None):
4343
self.the_blackboard.register_key(key='tank', access=py_trees.common.Access.WRITE)
4444
# attach robot agent
4545
self.arm_commander = arm_commander
46-
self.the_scene = scene
46+
self.the_scene:GridScanScene = scene
4747

4848
# the concrete implementation that contains the logic of the simulated calibration
4949
def update(self):
5050
logger.info(f'SimCalibrate: found tank at pose: ')
5151
# setup objects
52-
for object_name in self.the_scene.list_object_names():
53-
the_object = self.the_scene.get_object_config(object_name)
54-
if the_object.type == 'box':
55-
self.arm_commander.add_box_to_scene(object_name, the_object.dimensions, the_object.xyz, the_object.rpy, the_object.frame)
56-
if the_object.name == 'tank':
57-
self.the_blackboard.set('tank', the_object)
52+
for scene_name in self.the_scene.list_scene_names():
53+
link_of_scene = self.the_scene.get_link_of_scene(scene_name)
54+
if link_of_scene is None:
55+
continue
56+
if link_of_scene.type == 'box':
57+
self.arm_commander.add_box_to_scene(scene_name, link_of_scene.dimensions, link_of_scene.xyz, link_of_scene.rpy, link_of_scene.parent_frame)
58+
if link_of_scene.name == 'tank':
59+
self.the_blackboard.set('tank', link_of_scene)
5860
self.the_blackboard.task.result = '12'
5961
return Status.SUCCESS
6062

demos/gridscan/task_scene.yaml

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,23 @@
11
---
2-
scene:
3-
named_poses:
4-
stow: [3.110, -0.5467, -2.692, -1.473, 1.570, 0.000] # from base to wrist_3
5-
home: [2.524, -1.241, -2.101, -1.370, 1.570, 0.000] # from base to wrist_3
6-
regions:
7-
workspace: [-1.2, -0.97, -0.1, 1.5, 0.6, 1.2] # min_x, min_y, min_z, max_x, max_y, max_z
8-
inner: [-1.2, -0.3, 1.2, 0.6] # min_x, min_y, max_x, max_y
9-
work: [-1.2, -0.6, 1.2, -0.3] # min_x, min_y, max_x, max_y
10-
work3d: [-1.2, -0.6, 0.15, 1.2, -0.3, 0.6] # min_x, min_y, min_z, max_x, max_y, max_z
11-
objects:
12-
tank:
2+
scenes:
3+
root:
4+
named_poses:
5+
stow: [3.110, -0.5467, -2.692, -1.473, 1.570, 0.000] # from base to wrist_3
6+
home: [2.524, -1.241, -2.101, -1.370, 1.570, 0.000] # from base to wrist_3
7+
regions:
8+
workspace: [-1.2, -0.97, -0.1, 1.5, 0.6, 1.2] # min_x, min_y, min_z, max_x, max_y, max_z
9+
inner: [-1.2, -0.3, 1.2, 0.6] # min_x, min_y, max_x, max_y
10+
work: [-1.2, -0.6, 1.2, -0.3] # min_x, min_y, max_x, max_y
11+
work3d: [-1.2, -0.6, 0.15, 1.2, -0.3, 0.6] # min_x, min_y, min_z, max_x, max_y, max_z
12+
13+
tank:
14+
link:
1315
type: box
1416
model_file: null
1517
dimensions: [0.4, 1.8, 0.10]
1618
xyz: [0.0, -0.5, 0.05]
1719
rpy: [0, 0, 1.57]
1820
frame: null
19-
side_1:
20-
type: box
21-
model_file: null
22-
dimensions: [0.005, 1.8, 0.20]
23-
xyz: [0.0, -0.3, 0.10]
24-
rpy: [0, 0, 1.57]
25-
frame: null
26-
side_2:
27-
type: box
28-
model_file: null
29-
dimensions: [0.005, 1.8, 0.20]
30-
xyz: [0.0, -0.7, 0.10]
31-
rpy: [0, 0, 1.57]
32-
side_3:
33-
type: box
34-
model_file: null
35-
dimensions: [0.4, 0.005, 0.20]
36-
xyz: [-0.9, -0.5, 0.10]
37-
rpy: [0, 0, 1.57]
38-
side_4:
39-
type: box
40-
model_file: null
41-
dimensions: [0.4, 0.005, 0.20]
42-
xyz: [0.9, -0.5, 0.10]
43-
rpy: [0, 0, 1.57]
44-
45-
subscenes:
46-
tank:
4721
bbox: [-0.2, -0.9, 0.2, 0.9] # min_x, min_y, max_x, max_y
4822
positions:
4923
default: [null, null, 0.35]
@@ -85,6 +59,37 @@ subscenes:
8559
tile_y: 0
8660
origin_position: [-0.1, 0.45]
8761
ee_rotation: tank.rotations.beta
62+
side_1:
63+
link:
64+
type: box
65+
model_file: null
66+
dimensions: [0.005, 1.8, 0.20]
67+
xyz: [0.0, -0.3, 0.10]
68+
rpy: [0, 0, 1.57]
69+
frame: null
70+
side_2:
71+
link:
72+
type: box
73+
model_file: null
74+
dimensions: [0.005, 1.8, 0.20]
75+
xyz: [0.0, -0.7, 0.10]
76+
rpy: [0, 0, 1.57]
77+
side_3:
78+
link:
79+
type: box
80+
model_file: null
81+
dimensions: [0.4, 0.005, 0.20]
82+
xyz: [-0.9, -0.5, 0.10]
83+
rpy: [0, 0, 1.57]
84+
side_4:
85+
link:
86+
type: box
87+
model_file: null
88+
dimensions: [0.4, 0.005, 0.20]
89+
xyz: [0.9, -0.5, 0.10]
90+
rpy: [0, 0, 1.57]
91+
92+
8893

8994

9095

demos/gridscan/task_scene_gridscan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __init__(self, scene_config_file:str = None):
2828
super(GridScanScene, self).__init__(scene_config_file)
2929
# -- prepare internal data structures for efficiency
3030
# tank configuration
31-
self.tank_config = self.subscene_config['tank']
31+
self.tank_config = self.scenes_branch['tank']
3232
# tile_step size
3333
self.step_size_x = self.tank_config['tile']['step_size_x']
3434
self.step_size_y = self.tank_config['tile']['step_size_y']

demos/gridscan/task_trees_manager_gridscan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def wrong_xy_at_tank(self) -> bool:
189189

190190
def at_angle(self, rotation_pose) -> bool:
191191
current_xyzrpy = self.arm_commander.pose_in_frame_as_xyzrpy(reference_frame='tank')
192-
rotation_rpy = self.the_scene.query_rotation_as_rpy(rotation_pose)
192+
rotation_rpy = self.the_scene.query_config(rotation_pose)
193193
for index in range(len(rotation_rpy)):
194194
if rotation_rpy[index] is None:
195195
continue

demos/pickndrop/task_scene.yaml

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
1-
scene:
2-
named_poses:
3-
stow: [0.0, -1.244, 0.0, -2.949, 0.0, 1.704, 0.785] # from base
4-
home: [0.0, -0.785, 0.0, -2.36, 0.0, 1.57, 0.785] # from base
5-
regions:
6-
workspace: [-0.5, -0.75, -0.1, 1.0, 0.5, 1.0] # min_x, min_y, min_z, max_x, max_y, max_z
7-
inner: [-0.5, -0.2, 1.0, 0.5] # min_x, min_y, max_x, max_y
8-
positions:
9-
drop: [0.5, 0.3, 0.4]
10-
objects:
11-
the_table:
1+
scenes:
2+
root:
3+
named_poses:
4+
stow: [0.0, -1.244, 0.0, -2.949, 0.0, 1.704, 0.785] # from base
5+
home: [0.0, -0.785, 0.0, -2.36, 0.0, 1.57, 0.785] # from base
6+
regions:
7+
workspace: [-0.5, -0.75, -0.1, 1.0, 0.5, 1.0] # min_x, min_y, min_z, max_x, max_y, max_z
8+
inner: [-0.5, -0.2, 1.0, 0.5] # min_x, min_y, max_x, max_y
9+
positions:
10+
drop: [0.5, 0.3, 0.4]
11+
gripper_offset: [0, 0, 0.12]
12+
grip_prepare_offset: [0, 0, 0.20]
13+
14+
the_table:
15+
link:
16+
parent_frame: root
1217
type: box
1318
model_file: null
1419
dimensions: [0.5, 0.2, 0.3]
1520
xyz: [0.2, -0.35, 0.15]
16-
rpy: [0, 0, 0]
17-
the_bin:
18-
type: box
19-
model_file: null
20-
dimensions: [0.1, 0.1, 0.2]
21-
xyz: [0.5, 0.3, 0.1]
22-
rpy: [0, 0, 0]
23-
gripper_offset: [0, 0, 0.12]
24-
grip_prepare_offset: [0, 0, 0.20]
25-
26-
subscenes:
27-
the_table:
21+
rpy: [0, 0, 0]
2822
positions:
2923
start: [0, 0, null]
3024
scan_z_level: [null, null, 0.45]
@@ -33,5 +27,12 @@ subscenes:
3327
scan_step_size: [0.05, 0.05]
3428

3529
the_bin:
30+
link:
31+
parent_frame: root
32+
type: box
33+
model_file: null
34+
dimensions: [0.1, 0.1, 0.2]
35+
xyz: [0.5, 0.3, 0.1]
36+
rpy: [0, 0, 0]
3637
regions:
37-
dropzone: [-0.05, -0.05, 0.05, 0.05]
38+
dropzone: [-0.05, -0.05, 0.05, 0.05]

demos/pickndrop/task_trees_manager_pnd.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,16 @@ def __init__(self, arm_commander:GeneralCommander, spin_period_ms:int=10):
121121
# Functions for the simulation (demo)
122122
def setup_objects(self):
123123
# setup objects
124-
for object_name in self.the_scene.list_object_names():
125-
the_object = self.the_scene.get_object_config(object_name)
126-
if the_object.type == 'box':
127-
self.arm_commander.add_box_to_scene(object_name, the_object.dimensions, the_object.xyz, the_object.rpy)
124+
for scene_name in self.the_scene.list_scene_names():
125+
the_link = self.the_scene.get_link_of_scene(scene_name)
126+
if the_link is None:
127+
continue
128+
if the_link.type == 'box':
129+
self.arm_commander.add_box_to_scene(scene_name, the_link.dimensions, the_link.xyz, the_link.rpy)
128130

129131
# Generate a new ball on the table
130132
def generate_a_ball(self):
131-
the_table = self.the_scene.get_object_config('the_table')
133+
the_table = self.the_scene.get_link_of_scene('the_table')
132134
x, y = the_table.dimensions[0] * random.random() * 0.9, the_table.dimensions[1] * random.random() * 0.9 # position in the box frame
133135
z = the_table.xyz[2] + the_table.dimensions[2] / 2 + 0.035
134136
xyz = [x, y, z]
Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
1-
scene:
2-
named_poses:
3-
stow: [0.0, -1.244, 0.0, -2.949, 0.0, 1.704, 0.785] # from base
4-
home: [0.0, -0.785, 0.0, -2.36, 0.0, 1.57, 0.785] # from base
5-
regions:
6-
workspace: [-0.5, -0.75, -0.1, 1.0, 0.5, 1.0] # min_x, min_y, min_z, max_x, max_y, max_z
7-
inner: [-0.5, -0.2, 1.0, 0.5] # min_x, min_y, max_x, max_y
8-
positions:
9-
drop: [0.5, 0.3, 0.4]
10-
objects:
11-
the_table:
1+
scenes:
2+
root:
3+
named_poses:
4+
stow: [0.0, -1.244, 0.0, -2.949, 0.0, 1.704, 0.785] # from base
5+
home: [0.0, -0.785, 0.0, -2.36, 0.0, 1.57, 0.785] # from base
6+
regions:
7+
workspace: [-0.5, -0.75, -0.1, 1.0, 0.5, 1.0] # min_x, min_y, min_z, max_x, max_y, max_z
8+
inner: [-0.5, -0.2, 1.0, 0.5] # min_x, min_y, max_x, max_y
9+
positions:
10+
drop: [0.5, 0.3, 0.4]
11+
gripper_offset: [0, 0, 0.12]
12+
grip_prepare_offset: [0, 0, 0.20]
13+
14+
the_table:
15+
link:
16+
parent_frame: root
1217
type: box
1318
model_file: null
1419
dimensions: [0.5, 0.2, 0.3]
15-
xyz: [0.2, -0.3, 0.15]
16-
rpy: [0, 0, 0]
17-
the_bin:
18-
type: box
19-
model_file: null
20-
dimensions: [0.1, 0.1, 0.2]
21-
xyz: [0.5, 0.3, 0.1]
22-
rpy: [0, 0, 0]
23-
gripper_offset: [0, 0, 0.12]
24-
grip_prepare_offset: [0, 0, 0.20]
25-
26-
subscenes:
27-
the_table:
20+
xyz: [0.2, -0.35, 0.15]
21+
rpy: [0, 0, 0]
2822
positions:
2923
start: [0, 0, null]
3024
scan_z_level: [null, null, 0.45]
@@ -33,5 +27,12 @@ subscenes:
3327
scan_step_size: [0.05, 0.05]
3428

3529
the_bin:
30+
link:
31+
parent_frame: root
32+
type: box
33+
model_file: null
34+
dimensions: [0.1, 0.1, 0.2]
35+
xyz: [0.5, 0.3, 0.1]
36+
rpy: [0, 0, 0]
3637
regions:
37-
dropzone: [-0.05, -0.05, 0.05, 0.05]
38+
dropzone: [-0.05, -0.05, 0.05, 0.05]

demos/pickndrop_estop/task_trees_manager_pnd.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,16 @@ def __init__(self, arm_commander:GeneralCommander, spin_period_ms:int=10):
115115
# Functions for the simulation (demo)
116116
def setup_objects(self):
117117
# setup objects
118-
for object_name in self.the_scene.list_object_names():
119-
the_object = self.the_scene.get_object_config(object_name)
120-
if the_object.type == 'box':
121-
self.arm_commander.add_box_to_scene(object_name, the_object.dimensions, the_object.xyz, the_object.rpy)
118+
for scene_name in self.the_scene.list_scene_names():
119+
the_link = self.the_scene.get_link_of_scene(scene_name)
120+
if the_link is None:
121+
continue
122+
if the_link.type == 'box':
123+
self.arm_commander.add_box_to_scene(scene_name, the_link.dimensions, the_link.xyz, the_link.rpy)
122124

123125
# Generate a new ball on the table
124126
def generate_a_ball(self):
125-
the_table = self.the_scene.get_object_config('the_table')
127+
the_table = self.the_scene.get_link_of_scene('the_table')
126128
x, y = the_table.dimensions[0] * random.random() * 0.9, the_table.dimensions[1] * random.random() * 0.9 # position in the box frame
127129
z = the_table.xyz[2] + the_table.dimensions[2] / 2 + 0.035
128130
xyz = [x, y, z]

0 commit comments

Comments
 (0)