@@ -58,6 +58,7 @@ def __init__(
5858 # angle_threshold_perp: float = 0.52,
5959 # angle_threshold_point: float = 0.52,
6060 pbutils : PyBUtils ,
61+ sensor_config : dict ,
6162 # cam_width: int = 424,
6263 # cam_height: int = 240,
6364 evaluate : bool = False ,
@@ -106,23 +107,7 @@ def __init__(
106107 self .tree_count = tree_count
107108 self .is_goal_state = False
108109
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+
126111
127112 # self.cam_width = cam_width
128113 # self.cam_height = cam_height
@@ -149,24 +134,47 @@ def __init__(
149134 "SUPPORT" : None ,
150135 }
151136
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-
161137 self .trees = {}
162138 self .debouce_time = 0.5
163139 self .last_button_push_time = time .time ()
164140
165- # UR5 Robot
141+ # Load Robot
166142 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' ]
170178 return
171179
172180 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
182190 # randomize_pose=randomize_pose,
183191 # verbose=self.verbose,
184192 # )
185- robot = Robot ()
193+ robot = Robot (pbclient = self . pbutils . pbclient )
186194
187195 else :
188196 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.
208216 if tree_urdf_path is not None :
209217 if not os .path .exists (tree_urdf_path ):
210218 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 } "
212220 )
213221
214222 # Get tree object
@@ -567,10 +575,6 @@ def get_key_action(self, keys_pressed: list) -> np.ndarray:
567575 keys_pressed = []
568576 return action
569577
570- def run_sim (self ) -> int :
571-
572- return 0
573-
574578
575579def main ():
576580 # data = np.zeros((cam_width, cam_height), dtype=float)
0 commit comments