Skip to content

How to run the RIP agent on CARLA? #25

@JaiChandak

Description

@JaiChandak

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions