Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'NoneType' object has no attribute 'robot_action' #27

Open
ll7 opened this issue May 29, 2024 · 1 comment
Open

'NoneType' object has no attribute 'robot_action' #27

ll7 opened this issue May 29, 2024 · 1 comment

Comments

@ll7
Copy link
Owner

ll7 commented May 29, 2024

python scripts/debug_random_policy.py 
2024-05-29 09:44:18.757 | INFO     | robot_sf.render.sim_view:__post_init__:86 - Initializing the simulation view.
Traceback (most recent call last):
  File "/workspaces/robot_sf_ll7/scripts/debug_random_policy.py", line 34, in <module>
    benchmark()
  File "/workspaces/robot_sf_ll7/scripts/debug_random_policy.py", line 11, in benchmark
    env.render()
  File "/workspaces/robot_sf_ll7/robot_sf/gym_env/robot_env.py", line 206, in render
    self.sim_ui.render(state)
  File "/workspaces/robot_sf_ll7/robot_sf/render/sim_view.py", line 253, in render
    self._add_text(state.timestep, state)
  File "/workspaces/robot_sf_ll7/robot_sf/render/sim_view.py", line 389, in _add_text
    f'RobotAction: {state.action.robot_action}',
AttributeError: 'NoneType' object has no attribute 'robot_action'
@ll7
Copy link
Owner Author

ll7 commented May 29, 2024

The error message 'NoneType' object has no attribute 'robot_action' suggests that state.action is None at the time when state.action.robot_action is being accessed.

To fix this issue, you should add a check to ensure that state.action is not None before trying to access its robot_action attribute. Here's a proposed fix:

# Before
f'RobotAction: {state.action.robot_action}',

# After
f'RobotAction: {state.action.robot_action if state.action is not None else "None"}',

This change will print "None" for the RobotAction if state.action is None, preventing the AttributeError.

If state.action should not be None at this point in your code, you may have a bug elsewhere that is causing state.action to be None. In that case, you should debug your code to find out why state.action is None.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant