praveen-palanisamy / macad-gym

Multi-Agent Connected Autonomous Driving (MACAD) Gym environments for Deep RL. Code for the paper presented in the Machine Learning for Autonomous Driving Workshop at NeurIPS 2019:
https://arxiv.org/abs/1911.04175
MIT License
334 stars 74 forks source link

How to set the spectator on the agent #59

Open Panshark opened 2 years ago

Panshark commented 2 years ago

Hi @praveen-palanisamy ,

I am now working on a multi-agent project, and I want to set the env spectator on the agent vehicle. For example, from the rear of the car, a fixed third-person view to the vehicle. Do you know how to do that? Really thanks a lot!

Besides, when the code throws this exception in line 999 of multi_env.py:

except Exception:
            print("Error during step, terminating episode early.",
                  traceback.format_exc())
            self._clear_server_state()

My training step in the code will get cannot unpack non-iterable NoneType object error. I know why it could happen since the step function doesn't have a normal return this time, but I don't know how to handle it. Could you give me some examples about How do people normally deal with this error?

Best regards

Panshark commented 2 years ago

I used this to fix the second problem:

            self.last_obs_dict = obs_dict
            self.last_reward_dict = reward_dict
            self.last_info_dict = info_dict

            return obs_dict, reward_dict, self._done_dict, info_dict
        except Exception:
            print("Error during step, terminating episode early.",
                  traceback.format_exc())
            if not self._done_dict[actor_id]:
                self._done_dict[actor_id] = True
            self._dones.add(actor_id)
            self._clear_server_state()
            return self.last_obs_dict, self.last_reward_dict, self._done_dict, self.last_info_dict

However, I still can see this error:

RuntimeError: time-out of 10000ms while waiting for the simulator, make sure the simulator is ready and connected to localhost:59735

I don't think this mistake is important, isn't it?