FelixWaiblinger / lsy_drone_racing

Autonomous drone racing course repository from LSY
MIT License
0 stars 0 forks source link

AttributeError: 'FirmwareWrapper' object has no attribute 'NUM_GATES' #1

Closed AminSeffo closed 5 months ago

AminSeffo commented 5 months ago

Hi Martin @amacati

When trying to run python scripts/sim.py --controller examples/ppo_controller.py on "felix-testing" branch, I get:

Traceback (most recent call last):
  File "scripts/sim.py", line 189, in <module>
    fire.Fire(simulate)
  File "/home/amin/miniconda3/envs/drone/lib/python3.8/site-packages/fire/core.py", line 143, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/home/amin/miniconda3/envs/drone/lib/python3.8/site-packages/fire/core.py", line 477, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "/home/amin/miniconda3/envs/drone/lib/python3.8/site-packages/fire/core.py", line 693, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "scripts/sim.py", line 101, in simulate
    ctrl = ctrl_class(obs, info, verbose=config.verbose)
  File "examples/ppo_controller.py", line 83, in __init__
    env = DroneRacingWrapper(initial_info["env"], terminate_on_lap=True)
  File "/home/amin/Documents/repos/lsy_drone_racing/lsy_drone_racing/wrapper.py", line 81, in __init__
    n_gates = env.env.NUM_GATES
AttributeError: 'FirmwareWrapper' object has no attribute 'NUM_GATES'

I cant reproduce why FirmwareWrapper has no NUM_GATES attribute and I think it comes from:

https://github.com/FelixWaiblinger/lsy_drone_racing/blob/bf5c24a610ee813c44bfb2b135a2e170c7bfa2d7/lsy_drone_racing/wrapper.py#L82

amacati commented 5 months ago

The environment passed by initial_info["env"] is already wrapped in an lsy_drone_racing.wrapper.DroneRacingObservationWrapper, so the observations you get from the environment should be the same as for the DroneRacingWrapper. Therefore, you should not wrap it again. I will add runtime checks to the wrappers to make sure nothing is wrapped multiple times.

Also, I think you don't need to pass the environment to PPO.load(...) in case you just want to roll out the policy.

AminSeffo commented 5 months ago

Hi @amacati , thanks for your help. I tried with PPO.load(...) and it seems to work.