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

How to run the RIP agent on CARLA? #25

Open
JaiChandak opened this issue Jun 15, 2024 · 0 comments
Open

How to run the RIP agent on CARLA? #25

JaiChandak opened this issue Jun 15, 2024 · 0 comments

Comments

@JaiChandak
Copy link

I tried to run the script below, based off the README of the oatomobile repository, but I am unable to get a driving agent that runs on the RIP algorithm in CARLA. I am using python3.5 and CARLA 0.9.6.

import oatomobile
import oatomobile.envs
import torch
import oatomobile.baselines.torch

env = oatomobile.envs.CARLAEnv(town="Town01")
observation = env.reset()

models = [oatomobile.baselines.torch.ImitativeModel() for _ in range(4)]
ckpts = ["/path/to/output_dir"]

for model, ckpt in zip(models, ckpts):
  model.load_state_dict(torch.load(ckpt, map_location=torch.device('cpu')), strict=False)

agent = oatomobile.baselines.torch.RIPAgent(
  environment=env,
  models=models,
  algorithm="WCM",
)

action = agent.act(observation)

The agent instance doesn't get created. This is the error message I get for that line.

lib/python3.5/site-packages/oatomobile/baselines/base.py", line 64, in __init__
    self._world = self._vehicle.get_world()
AttributeError: 'NoneType' object has no attribute 'get_world'

I also tried modifying the script from oatomobile.baselines.rulebased.blind.run.py because I was able to run the Blind model. I replaced the environment loop inside the main function to cater for the RIPAgent but still I couldn't run it.

# Runs the environment 
oatomobile.EnvironmentLoop(
    agent_fn=functools.partial(RIPAgent, models=models, algorithm="WCM"),
    environment=env,
    render_mode="human" if render else "none",
).run()

So, my question is how can I run the RIP agent on CARLA?

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