Skip to content

when run ‘env.load_task(tasks.ScrewNail)’ in playground.ipynb,something wrong “NameError: name 'gripper_map' is not defined” #31

@git183nuozhe

Description

@git183nuozhe

playground.ipynb,the modified parts are as follows:
env.load_task(tasks.ScrewNail)

task_object_names.json,the modified parts are as follows:add
"screw_nail": [["screw", "screw"], ["screwdriver", "screw_driver"], ["block", "block"]]

the error is as follows:
{{{
(using cache) *** OpenAI API call took 0.00s ***
########################################

"planner" generated code

context: "objects = ['screw', 'screwdriver', 'block']"

########################################
objects = ['screw', 'screwdriver', 'block']

Query: screw the nail in to the block.

composer("grasp the screwdriver")
composer("back to default pose")
composer("move to the top of the screw")
composer("grasp the screw")
composer("back to default pose")
composer("move to the top of the block")
composer("rotate the screwdriver to screw the screw into the block")
composer("open gripper")
composer("back to default pose")

(using cache) *** OpenAI API call took 0.00s ***
########################################

"composer" generated code

########################################

Query: grasp the screwdriver.

movable = parse_query_obj('gripper')
affordance_map = get_affordance_map('a point at the center of the screwdriver handle')
gripper_map = get_gripper_map('open everywhere except 1cm around the screwdriver handle')
execute(movable, affordance_map=affordance_map, gripper_map=gripper_map)

(using cache) *** OpenAI API call took 0.00s ***
########################################

"parse_query_obj" generated code

context: "objects = ['screw', 'screwdriver', 'block']"

########################################
objects = ['screw', 'screwdriver', 'block']

Query: gripper.

gripper = detect('gripper')
ret_val = gripper

(using cache) *** OpenAI API call took 0.00s ***
########################################

"get_affordance_map" generated code

########################################

Query: a point at the center of the screwdriver handle.

affordance_map = get_empty_affordance_map()
screwdriver_handle = parse_query_obj('screwdriver handle')
x, y, z = screwdriver_handle.position
affordance_map[x, y, z] = 1
ret_val = affordance_map

(using cache) *** OpenAI API call took 0.00s ***
########################################

"get_gripper_map" generated code

########################################

Query: open everywhere except 1cm around the screwdriver handle.

screwdriver_handle = parse_query_obj('screwdriver handle')
set_voxel_by_radius(gripper_map, screwdriver_handle.position, radius_cm=1, value=0)
ret_val = gripper_map

(using cache) *** OpenAI API call took 0.00s ***
########################################

"parse_query_obj" generated code

context: "objects = ['screw', 'screwdriver', 'block']"

########################################
objects = ['screw', 'screwdriver', 'block']

Query: screwdriver handle.

screwdriver = detect('screwdriver')
ret_val = screwdriver

(using cache) *** OpenAI API call took 0.00s ***
########################################

"parse_query_obj" generated code

context: "objects = ['screw', 'screwdriver', 'block']"

########################################
objects = ['screw', 'screwdriver', 'block']

Query: screwdriver handle.

screwdriver = detect('screwdriver')
ret_val = screwdriver

Error executing code:
movable = parse_query_obj('gripper')
affordance_map = get_affordance_map('a point at the center of the screwdriver handle')
gripper_map = get_gripper_map('open everywhere except 1cm around the screwdriver handle')
execute(movable, affordance_map=affordance_map, gripper_map=gripper_map)
Error executing code:
objects = ['screw', 'screwdriver', 'block']
composer("grasp the screwdriver")
composer("back to default pose")
composer("move to the top of the screw")
composer("grasp the screw")
composer("back to default pose")
composer("move to the top of the block")
composer("rotate the screwdriver to screw the screw into the block")
composer("open gripper")
composer("back to default pose")

NameError Traceback (most recent call last)
Cell In[15], line 1
----> 1 voxposer_ui(instruction)
File ~/VoxPoser/src/LMP.py:146, in LMP.call(self, query, **kwargs)
144 import pdb ; pdb.set_trace()
145 else:
--> 146 exec_safe(to_exec, gvars, lvars)
148 self.exec_hist += f'\n{to_log.strip()}'
150 if self._cfg['maintain_session']:

File ~/VoxPoser/src/LMP.py:189, in exec_safe(code_str, gvars, lvars)
187 except Exception as e:
188 print(f'Error executing code:\n{code_str}')
--> 189 raise e

File ~/VoxPoser/src/LMP.py:186, in exec_safe(code_str, gvars, lvars)
181 custom_gvars = merge_dicts([
182 gvars,
183 {'exec': empty_fn, 'eval': empty_fn}
184 ])
185 try:
--> 186 exec(code_str, custom_gvars, lvars)
187 except Exception as e:
188 print(f'Error executing code:\n{code_str}')

File :2

File ~/VoxPoser/src/LMP.py:146, in LMP.call(self, query, **kwargs)
144 import pdb ; pdb.set_trace()
145 else:
--> 146 exec_safe(to_exec, gvars, lvars)
148 self.exec_hist += f'\n{to_log.strip()}'
150 if self._cfg['maintain_session']:

File ~/VoxPoser/src/LMP.py:189, in exec_safe(code_str, gvars, lvars)
187 except Exception as e:
188 print(f'Error executing code:\n{code_str}')
--> 189 raise e

File ~/VoxPoser/src/LMP.py:186, in exec_safe(code_str, gvars, lvars)
181 custom_gvars = merge_dicts([
182 gvars,
183 {'exec': empty_fn, 'eval': empty_fn}
184 ])
185 try:
--> 186 exec(code_str, custom_gvars, lvars)
187 except Exception as e:
188 print(f'Error executing code:\n{code_str}')

File :4

File ~/VoxPoser/src/interfaces.py:112, in LMP_interface.execute(self, movable_obs_func, affordance_map, avoidance_map, rotation_map, velocity_map, gripper_map)
110 _rotation_map = rotation_map()
111 _velocity_map = velocity_map()
--> 112 _gripper_map = gripper_map()
113 # preprocess avoidance map
114 _avoidance_map = self._preprocess_avoidance_map(_avoidance_map, _affordance_map, movable_obs)

File :3, in ret_val()

NameError: name 'gripper_map' is not defined
在当前单元格或上一个单元格中执行代码时 Kernel 崩溃。
请查看单元格中的代码,以确定故障的可能原因。
单击此处了解详细信息。
有关更多详细信息,请查看 Jupyter log。

WARNING: QApplication was not created in the main() thread.
##################################################

voxel resolution: [0.0105 0.0131 0.01 ]

##################################################
}}}

It should be noted that,If we force ‘gripper_map = self._get_default_voxel_map('gripper')’ to be assigned a value in line 112 of ‘interfaces.py’, another error will still occur.

Please give me some help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions