3939from predicators .spot_utils .skills .spot_navigation import go_home , \
4040 navigate_to_absolute_pose
4141from predicators .spot_utils .skills .spot_stow_arm import stow_arm
42- from predicators .spot_utils .spot_localization import SpotLocalizer
42+ from predicators .spot_utils .spot_localization import OdomLocalizer , \
43+ SpotLocalizer
4344from predicators .spot_utils .utils import _base_object_type , _broom_type , \
4445 _container_type , _cup_type , _dustpan_type , _immovable_object_type , \
4546 _juicer_type , _movable_object_type , _robot_type , _table_type , \
@@ -176,7 +177,6 @@ def get_robot(
176177 return None , None , None
177178 setup_logging (False )
178179 hostname = CFG .spot_robot_ip
179- path = get_graph_nav_dir ()
180180 sdk = create_standard_sdk ("PredicatorsClient-" )
181181 robot = sdk .create_robot (hostname )
182182 authenticate (robot )
@@ -187,9 +187,14 @@ def get_robot(
187187 must_acquire = True ,
188188 return_at_exit = True )
189189 localizer = None
190- assert path .exists ()
191190 if use_localizer :
192- localizer = SpotLocalizer (robot , path , lease_client , lease_keepalive )
191+ if CFG .spot_mapless_mode :
192+ localizer = OdomLocalizer (robot )
193+ else :
194+ path = get_graph_nav_dir ()
195+ assert path .exists ()
196+ localizer = SpotLocalizer (robot , path , lease_client ,
197+ lease_keepalive )
193198 return robot , localizer , lease_client
194199
195200
@@ -1178,25 +1183,28 @@ def _actively_construct_initial_object_views(
11781183 assert self ._localizer is not None
11791184 self ._localizer .localize ()
11801185
1181- # Capture images from the current position and run detection
1182- # without moving the robot.
1183- # rgbds = capture_images(self._robot, self._localizer)
1184- # detection_ids = set(self._detection_id_to_obj.keys())
1185- # detections, artifacts = detect_objects(
1186- # detection_ids, rgbds, self._allowed_regions)
1187-
1188- # if CFG.spot_render_perception_outputs:
1189- # outdir = Path(CFG.spot_perception_outdir)
1190- # time_str = time.strftime("%Y%m%d-%H%M%S")
1191- # detections_outfile = outdir / f"detections_{time_str}.png"
1192- # no_detections_outfile = outdir / f"no_detections_{time_str}.png"
1193- # visualize_all_artifacts(artifacts, detections_outfile,
1194- # no_detections_outfile)
1195-
1196- # Detection is currently disabled (commented out above), so default
1197- # to empty so the fallback to known poses below still works.
1198- detections : Dict [ObjectDetectionID , math_helpers .SE3Pose ] = {}
1199- artifacts : Dict [str , Any ] = {}
1186+ if CFG .spot_mapless_mode :
1187+ # In mapless mode, we must actually run object detection since
1188+ # there are no metadata poses to fall back on. Use the init
1189+ # search procedure which spins the robot to find objects.
1190+ detection_ids = set (self ._detection_id_to_obj .keys ())
1191+ # Filter out KnownStaticObjectDetectionIDs (e.g. floor) since
1192+ # those don't need searching.
1193+ search_ids = {
1194+ d for d in detection_ids
1195+ if not isinstance (d , KnownStaticObjectDetectionID )
1196+ }
1197+ detections , artifacts = self ._run_init_search_for_objects (
1198+ search_ids )
1199+ # Also include known static objects (e.g. floor).
1200+ for d in detection_ids :
1201+ if isinstance (d , KnownStaticObjectDetectionID ):
1202+ detections [d ] = d .pose
1203+ else :
1204+ # Detection is currently disabled for map-based mode; fall back
1205+ # to known poses from metadata below.
1206+ detections = {}
1207+ artifacts = {}
12001208
12011209 obj_to_se3_pose = {
12021210 self ._detection_id_to_obj [det_id ]: val
@@ -4422,49 +4430,50 @@ def get_name(cls) -> str:
44224430 @property
44234431 def _detection_id_to_obj (self ) -> Dict [ObjectDetectionID , Object ]:
44244432 detection_id_to_obj : Dict [ObjectDetectionID , Object ] = {}
4425- # detection_id_to_obj[LanguageObjectDetectionID(
4426- # "bottle/clear_cup/clear_trashcan")] = Object(
4427- # "clear_plastic_container", _trash_can_type)
4428- # detection_id_to_obj[LanguageObjectDetectionID(
4429- # "apple/red_ball")] = Object("apple", _movable_object_type)
4430- # detection_id_to_obj[LanguageObjectDetectionID(
4431- # "soda_can")] = Object(
4432- # "soda_can", _movable_object_type)
4433- # detection_id_to_obj[LanguageObjectDetectionID(
4434- # "fluffy_toy/flower_arrangement")] = Object(
4435- # "fluffy_green_toy_eraser", _movable_object_type)
4436- # detection_id_to_obj[LanguageObjectDetectionID(
4437- # "blue_block")] = Object("blue_block", _movable_object_type)
4438-
4439- # detection_id_to_obj[LanguageObjectDetectionID(
4440- # "cardboard_box")] = Object("cardboard_box_bin", _trash_can_type)
4441- # detection_id_to_obj[LanguageObjectDetectionID(
4442- # "blue_coffee_cup")] = Object("blue_coffee_cup",
4443- # _movable_object_type)
4444- for obj , pose in get_known_movable_objects ().items ():
4445- if obj .name == "pink_furry_eraser" :
4446- eraser_obj = Object ("pink_furry_eraser" ,
4447- _movable_object_type )
4448- detection_id = LanguageObjectDetectionID ("toy/flower_arrangement" )
4449- detection_id_to_obj [detection_id ] = eraser_obj
4450- elif obj .name == "clear_plastic_container" :
4451- container_obj = Object ("clear_plastic_container" ,
4452- _trash_can_type )
4453- detection_id = LanguageObjectDetectionID ("bottle/clear_cup/clear_trashcan" )
4454- detection_id_to_obj [detection_id ] = container_obj
4455- else :
4456- detection_id = LanguageObjectDetectionID (obj .name )
4457- detection_id_to_obj [detection_id ] = obj
4458- for obj , pose in get_known_immovable_objects ().items ():
4459- stat_detection_id = KnownStaticObjectDetectionID (obj .name , pose )
4460- if obj .name == "short_round_coffee_table" :
4461- table_obj = Object ("short_round_coffee_table" , _table_type )
4462- detection_id_to_obj [stat_detection_id ] = table_obj
4463- elif obj .name == "childs_play_table" :
4464- table_obj = Object ("childs_play_table" , _table_type )
4465- detection_id_to_obj [stat_detection_id ] = table_obj
4466- else :
4433+
4434+ if CFG .spot_mapless_mode :
4435+ # In mapless mode, hardcode the objects to detect via
4436+ # language rather than relying on metadata.
4437+ detection_id_to_obj [LanguageObjectDetectionID (
4438+ "green_and_blue_furry_eraser" )] = Object (
4439+ "green_and_blue_furry_eraser" , _movable_object_type )
4440+ detection_id_to_obj [LanguageObjectDetectionID (
4441+ "childs_play_table" )] = Object (
4442+ "childs_play_table" , _table_type )
4443+ # Floor is always a known static object.
4444+ for obj , pose in get_known_immovable_objects ().items ():
4445+ stat_detection_id = KnownStaticObjectDetectionID (
4446+ obj .name , pose )
44674447 detection_id_to_obj [stat_detection_id ] = obj
4448+ else :
4449+ for obj , pose in get_known_movable_objects ().items ():
4450+ if obj .name == "pink_furry_eraser" :
4451+ eraser_obj = Object ("pink_furry_eraser" ,
4452+ _movable_object_type )
4453+ detection_id = LanguageObjectDetectionID (
4454+ "toy/flower_arrangement" )
4455+ detection_id_to_obj [detection_id ] = eraser_obj
4456+ elif obj .name == "clear_plastic_container" :
4457+ container_obj = Object ("clear_plastic_container" ,
4458+ _trash_can_type )
4459+ detection_id = LanguageObjectDetectionID (
4460+ "bottle/clear_cup/clear_trashcan" )
4461+ detection_id_to_obj [detection_id ] = container_obj
4462+ else :
4463+ detection_id = LanguageObjectDetectionID (obj .name )
4464+ detection_id_to_obj [detection_id ] = obj
4465+ for obj , pose in get_known_immovable_objects ().items ():
4466+ stat_detection_id = KnownStaticObjectDetectionID (
4467+ obj .name , pose )
4468+ if obj .name == "short_round_coffee_table" :
4469+ table_obj = Object ("short_round_coffee_table" ,
4470+ _table_type )
4471+ detection_id_to_obj [stat_detection_id ] = table_obj
4472+ elif obj .name == "childs_play_table" :
4473+ table_obj = Object ("childs_play_table" , _table_type )
4474+ detection_id_to_obj [stat_detection_id ] = table_obj
4475+ else :
4476+ detection_id_to_obj [stat_detection_id ] = obj
44684477
44694478 return detection_id_to_obj
44704479
0 commit comments