@@ -58,6 +58,7 @@ def __init__(
58
58
# angle_threshold_perp: float = 0.52,
59
59
# angle_threshold_point: float = 0.52,
60
60
pbutils : PyBUtils ,
61
+ sensor_config : dict ,
61
62
# cam_width: int = 424,
62
63
# cam_height: int = 240,
63
64
evaluate : bool = False ,
@@ -106,23 +107,7 @@ def __init__(
106
107
self .tree_count = tree_count
107
108
self .is_goal_state = False
108
109
109
- # sensor types
110
- self .sensor_attributes = {} # TODO: Load sensor types from config files
111
- camera_configs_path = os .path .join (CONFIG_PATH , "camera" )
112
- camera_configs_files = glob .glob (os .path .join (camera_configs_path , "*.yaml" ))
113
- for file in camera_configs_files :
114
- yamlcontent = yutils .load_yaml (file )
115
- for key , value in yamlcontent .items ():
116
- self .sensor_attributes [key ] = value
117
-
118
- tof_configs_path = os .path .join (CONFIG_PATH , "tof" )
119
- tof_configs_files = glob .glob (os .path .join (tof_configs_path , "*.yaml" ))
120
- for file in tof_configs_files :
121
- yamlcontent = yutils .load_yaml (file )
122
- for key , value in yamlcontent .items ():
123
- self .sensor_attributes [key ] = value
124
-
125
- # log.warning(self.sensor_attributes)
110
+
126
111
127
112
# self.cam_width = cam_width
128
113
# self.cam_height = cam_height
@@ -149,24 +134,47 @@ def __init__(
149
134
"SUPPORT" : None ,
150
135
}
151
136
152
- # Tree parameters
153
- # self.tree_goal_pos = None
154
- # self.tree_goal_or = None
155
- # self.tree_goal_normal = None
156
- # self.tree_urdf_path: str | None = None
157
- # self.tree_pos = np.zeros(3, dtype=float)
158
- # self.tree_orientation = np.zeros(3, dtype=float)
159
- # self.tree_scale: float = 1.0
160
-
161
137
self .trees = {}
162
138
self .debouce_time = 0.5
163
139
self .last_button_push_time = time .time ()
164
140
165
- # UR5 Robot
141
+ # Load Robot
166
142
if load_robot :
167
- self .ur5 = self .load_robot (
168
- type = robot_type , robot_pos = robot_pos , robot_orientation = robot_orientation , randomize_pose = False
169
- )
143
+ self .robot = Robot (pbclient = self .pbutils .pbclient )
144
+ # self.ur5 = self.load_robot(
145
+ # type=robot_type, robot_pos=robot_pos, robot_orientation=robot_orientation, randomize_pose=False
146
+ # )
147
+
148
+ # Load all sensor attributes. # TODO: Load only the required sensor attributes
149
+ self ._load_sensor_attributes ()
150
+
151
+ self .sensor_config = sensor_config
152
+ self ._assign_tf_frame_to_sensors (self .sensor_config )
153
+ # log.warning(self.sensor_attributes)
154
+ return
155
+
156
+ def _load_sensor_attributes (self ):
157
+ self .sensor_attributes = {}
158
+ camera_configs_path = os .path .join (CONFIG_PATH , "camera" )
159
+ camera_configs_files = glob .glob (os .path .join (camera_configs_path , "*.yaml" ))
160
+ for file in camera_configs_files :
161
+ yamlcontent = yutils .load_yaml (file )
162
+ for key , value in yamlcontent .items ():
163
+ self .sensor_attributes [key ] = value
164
+ tof_configs_path = os .path .join (CONFIG_PATH , "tof" )
165
+ tof_configs_files = glob .glob (os .path .join (tof_configs_path , "*.yaml" ))
166
+ for file in tof_configs_files :
167
+ yamlcontent = yutils .load_yaml (file )
168
+ for key , value in yamlcontent .items ():
169
+ self .sensor_attributes [key ] = value
170
+ return
171
+
172
+ def _assign_tf_frame_to_sensors (self , sensor_config : dict ):
173
+ for sensor_name , conf in sensor_config .items ():
174
+ sensor = conf ['sensor' ]
175
+ sensor .tf_frame = conf ['tf_frame' ]
176
+ log .warn (f"{ sensor .params } " )
177
+ sensor .tf_frame_index = self .robot .robot_conf ['joint_info' ]['mock_pruner__base--camera0' ]['id' ]
170
178
return
171
179
172
180
def load_robot (self , type : str , robot_pos : ArrayLike , robot_orientation : ArrayLike , randomize_pose : bool = False ):
@@ -182,7 +190,7 @@ def load_robot(self, type: str, robot_pos: ArrayLike, robot_orientation: ArrayLi
182
190
# randomize_pose=randomize_pose,
183
191
# verbose=self.verbose,
184
192
# )
185
- robot = Robot ()
193
+ robot = Robot (pbclient = self . pbutils . pbclient )
186
194
187
195
else :
188
196
raise NotImplementedError (f"Robot type { type } not implemented" )
@@ -208,7 +216,7 @@ def load_tree( # TODO: Clean up Tree init vs create_tree, probably not needed.
208
216
if tree_urdf_path is not None :
209
217
if not os .path .exists (tree_urdf_path ):
210
218
raise OSError (
211
- f"There do not seem to be any files of that name, please check your path. Given path was { tree_urdf_path } "
219
+ f"There do not seem to be any files of that name, please check your path: { tree_urdf_path } "
212
220
)
213
221
214
222
# Get tree object
@@ -567,10 +575,6 @@ def get_key_action(self, keys_pressed: list) -> np.ndarray:
567
575
keys_pressed = []
568
576
return action
569
577
570
- def run_sim (self ) -> int :
571
-
572
- return 0
573
-
574
578
575
579
def main ():
576
580
# data = np.zeros((cam_width, cam_height), dtype=float)
0 commit comments