RoboWaiter/robowaiter/scene/tasks/AEM.py

50 lines
1.6 KiB
Python
Raw Normal View History

"""
环境主动探索和记忆
要求输出探索结果语义地图对环境重点信息记忆生成环境的语义拓扑地图和不少于10个环境物品的识别和位置记忆可以是图片或者文字或者格式化数据
"""
2023-11-16 16:37:11 +08:00
import pickle
from robowaiter.scene.scene import Scene
class SceneAEM(Scene):
def __init__(self, robot):
super().__init__(robot)
2023-11-15 12:04:49 +08:00
def _reset(self):
pass
def _run(self):
2023-11-15 15:09:51 +08:00
cur_objs = []
2023-11-16 16:37:11 +08:00
objs_name_set = set()
file_name = '../../proto/map_1.pkl'
if os.path.exists(file_name):
with open(file_name, 'rb') as file:
map = pickle.load(file)
2023-11-15 15:09:51 +08:00
print('------------ 自主探索 ------------')
2023-11-16 16:37:11 +08:00
# cur_objs = self.semantic_map.navigation_move(cur_objs, 0, 11)
# print("物品列表如下:")
# print(cur_objs)
# cur_pos = [int(scene.location.X), int(scene.location.Y)]
# print(reachable([237,490]))
# navigation_move([[237,490]], i, map_id)
# navigation_test(i,map_id)
while True:
goal = self.explore(map, 120) # cur_pos 指的是当前机器人的位置,场景中应该也有接口可以获取
if goal is None:
break
cur_objs, objs_name_set = self.navigation_move(cur_objs, objs_name_set, [[goal[0], goal[1]]], 0, 11)
print("------------物品信息--------------")
2023-11-15 15:09:51 +08:00
print(cur_objs)
2023-11-15 14:56:03 +08:00
2023-11-15 12:04:49 +08:00
pass
if __name__ == '__main__':
import os
from robowaiter.robot.robot import Robot
robot = Robot()
# create task
task = SceneAEM(robot)
task.reset()
2023-11-15 15:09:51 +08:00
task.run()