carla-simulator / leaderboard

CARLA Autonomous Driving leaderboard
MIT License
156 stars 76 forks source link

No module named 'leaderboard.autoagents' #142

Closed marcusvinicius178 closed 1 year ago

marcusvinicius178 commented 1 year ago

Hi I have installed CARLA with Autoware Universe using this tutorial: https://www.youtube.com/watch?v=dxwwNacez7o

I have cloned and installed the requirments.txt from leaderboard as this tutorial recommends: https://leaderboard.carla.org/get_started_v1/

I am using python3, eggfile 3.7, ubuntu20.04, ROS2 - Foxy, source installation

When I try to launch the file op_bridge_ros2.py I get the error:

Traceback (most recent call last):
  File "op_bridge_ros2.py", line 17, in <module>
    from op_bridge.agent_wrapper import AgentWrapper
  File "/home/rota2030/hatem-repos/op_bridge/op_bridge/op_bridge.py", line 15, in <module>
    from leaderboard.autoagents.agent_wrapper import  AgentWrapper
ModuleNotFoundError: No module named 'leaderboard.autoagents'

This is very strange because I was able to load the scenario runner modules, but the leaderboard modules, no matter what I try they don't get recognized. I have already assigned the PythonPath in my bash file, exported the right environment variables for the LEADERBOARD_ROOT. But no success. Could you please assist me?

Snippet of my attempts to load this module is below:

openplanner bridge

Hatem Darweesh January 2022

import imp

import importlib import math import signal import os import sys import importlib import time import traceback import carla from srunner.scenariomanager.carla_data_provider import *

from op_bridge.leaderboard.autoagents.agent_wrapper import AgentWrapper

from op_bridge.agent_wrapper import AgentWrapper

"""
#Line below didn't work
#sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__), '..','agent_wrapper.py'))
#import AgentWrapper

#import sys
#sys.path.append("/home/rota2030/hatem-repos/leaderboard/leaderboard/autoagents/")
#import AgentWrapper

#imp.load_source(AgentWrapper, 'home/rota2030/hatem-repos/leaderboard/leaderboard/autoagents/')

#LINE BELOW WORKED WITH FULL PATH
from importlib.machinery import SourceFileLoader

auto_agents = SourceFileLoader("agent_wrapper", "/home/rota2030/hatem-repos/leaderboard/leaderboard/autoagents/agent_wrapper.py").load_module()
auto_agents.AgentWrapper()
"""

My bash file is below:

#!/bin/bash
export PYTHONPATH=$PYTHONPATH:/opt/carla-simulator/PythonAPI/carla/dist/carla-0.9.13-py3.7-linux-x86_64.egg
export PYTHONPATH=$PYTHONPATH:/opt/carla-simulator/PythonAPI/carla
export PYTHONPATH=$PYTHONPATH:/opt/carla-simulator/PythonAPI
export PYTHONPATH=$PYTHONPATH:${CARLA_ROOT}/PythonAPI/util
export PYTHONPATH=$PYTHONPATH:${CARLA_ROOT}/PythonAPI/carla
export PYTHONPATH=$PYTHONPATH:${CARLA_ROOT}/PythonAPI/carla/agents
#export PYTHONPATH=$PYTHONPATH:${LEADERBOARD_ROOT}/autoagents
#export PYTHONPATH=$PYTHONPATH:/home/user/hatem-repos/scenario_runner
export PYTHONPATH="${CARLA_ROOT}/PythonAPI/carla/":"${SCENARIO_RUNNER_ROOT}":"${LEADERBOARD_ROOT}":"${CARLA_ROOT}/PythonAPI/carla/dist/carla-0.9.10-py3.7-linux-x86_64.egg":${PYTHONPATH}

export CARLA_ROOT=/opt/carla-simulator
export LEADERBOARD_ROOT=/home/rota2030/hatem-repos/leaderboard
export TEAM_CODE_ROOT=/home/user/hatem-repos/op_agent
export SCENARIO_RUNNER_ROOT=/home/user/hatem-repos/scenario_runner

#source /opt/ros/galactic/setup.bash 
#I have uninstalled ros galactic and installed foxy. Because Leaderboard modules just work with ros2 foxy according to https://leaderboard.carla.org/get_started/
source ~/ros2_foxy/install/local_setup.bash
source /home/rota2030/hatem-repos/carla-autoware-universe/autoware.universe.openplanner/install/setup.bash

I checked similar issues: https://github.com/carla-simulator/leaderboard/issues/77, https://github.com/carla-simulator/leaderboard/issues/84

but they did not work for me

xpharry commented 1 year ago

I don't think you set your PYTHONPATH successfully if you put those definitions for "CARLA_ROOT", "LEADERBOARD_ROOT" ... after setting PYTHONPATH.

marcusvinicius178 commented 1 year ago

ok @xpharry that is the picture

image

what do you suggest?

xpharry commented 1 year ago

Firstly, did you source ~/.bashrc again in your trrminal after you modified?

Secondly, how about put all "export PYTHONPATH=.." after "export SCENARIO_RUNNER_ROOT..."?

marcusvinicius178 commented 1 year ago

Asnwering the first question: Yes The second: Yes it was wrong. Now I changed the order, however the same issue persists (also after source the bash and my "customized bash" or close the terminal and export the variables manually....the result is the same error as you can see

image

marcusvinicius178 commented 1 year ago

Hi @xpharry it seems we have advanced a little bit, thanks a lot!

Actually I needed to unisntall the ros2 galactic and install ros2 foxy (as the CARLA documentation suggested it is the only ROS2 that works with this bridge). However I have not installed it completely (at least it was not in /opt/ros/foxy) now I have fixed this and sourced the /opt/ros/foxy/setup.bash instead to source the ros2_foxy/install/local_setup.bash Just changing this line the leaderboard modules were found.

However in this moment Python3 is not finding the agents modules from the Carla simulator, which are installed in /op/carla-simulator/PythonAPI/carla/agents/navigation. Please check the right side of figure below (The agents.navigation.global_route_planner_dao is not found.

Could you mind why?

image

I belive if I fix this I will be able to run the ros2 bridge with CARLA and Autoware Universe

xpharry commented 1 year ago

For me I successfully reproduced Dr. Hatem's result a couple days ago. The question should be better discussed in his repos.

I tested it under Ubuntu 20.04, and ROS2 galactic.

Multiple things you can try.

  1. Follow exactly what the instruction describes in his tutorial video and in the README file (https://github.com/hatem-darweesh/op_bridge):
export CARLA_ROOT=/home/user/carla-0.9.13/CARLA_0.9.13_RSS
export SCENARIO_RUNNER_ROOT=/home/user/carla-0.9.13/scenario_runner
export LEADERBOARD_ROOT=/home/user/carla-0.9.13/op_bridge
export TEAM_CODE_ROOT=/home/user/carla-0.9.13/op_agent
export PYTHONPATH=$PYTHONPATH:${CARLA_ROOT}/PythonAPI
export PYTHONPATH=$PYTHONPATH:${CARLA_ROOT}/PythonAPI/util
export PYTHONPATH=$PYTHONPATH:${CARLA_ROOT}/PythonAPI/carla
export PYTHONPATH=$PYTHONPATH:${CARLA_ROOT}/PythonAPI/carla/agents
export PYTHONPATH=$PYTHONPATH:${CARLA_ROOT}/PythonAPI/carla/dist/carla-0.9.13-py2.7-linux-x86_64.egg

I notice you didn't follow it for LEADERBOARD_ROOT. Not sure how it will differ.

And

  1. If you installed multiple versions of ROS which is fine, make sure you only source one of them.

  2. Not sure if you have set the path of CARLA_ROOT correctly.

marcusvinicius178 commented 1 year ago

Ok thanks for the reply....Actually my lab's friend has installed CARLA for me, before I try the tutorial. He installed CARLA release 0.9.13 however it seems the installation was different from Mr. Darweesh, because the simulador was put in /opt/carla-simulator/CarlaUE4 and I believe your simulator and from Mr.Darweesh was put in the user directory, inside the folder name carla-0.9.13. I thought that would not make any difference, however a lot of issues raised. Maybe my friend has installed a kind of MASTER CARLA version and not 0.9.13 as he said...I am not sure.

About the Leaderboard folder, I have removed the one that was inside op_bridge (cloned by Darweesh's repo) and cloned another one directly from CARLA tutorial...which I guess it also wouldn't lead to any difference. At first I tried use the one inside op_bridge, and as it was not working I cloned a new one...

I will try to reinstall the simulator...However it seems my simulator is the 9.13 too image

Thanks

xpharry commented 1 year ago

If it is Carla 0.9.13 then that is fine. Not sure why your program could not find agents.navigation.

Another thing which confuses me is that you have another version of Carla in your PYTHONPATH. Try to remove carla-0.9.10 in your PYTHONPATH.

marcusvinicius178 commented 1 year ago

Hi @xpharry I was able to import the modules, my solution is here https://github.com/hatem-darweesh/op_bridge/issues/8.

Could you please read my last comment in this link that I have shared? I runned the bridge with the Simulator, however I had a Runtime/Timestamp issue. So I would like to heard from you and get an opinion.

I am not sure if is a hardware requirement issue, or internet bandwidth from my university, distance to the server (I know CARLA is a Spanish project but I live in South America) or code issue?

The specifications are in this link. Thanks a lot for your assistance. At least I have solved the environment variables and import error!

marcusvinicius178 commented 1 year ago

Hi Mr. @xpharry I have answered you in your reply in the other git issues. I would be very glad if you could take a look. Does this CARLA- Autoware_Universe integration just work with Python2.7, or were you able to run with Python3.7 as well?