Comments (7)
If I understand correctly that line launches the server, if you are launching the server using make launch
(and presumably hitting play in UE4) can't you just remove that line?
Alternatively, you could build a packaged version of CARLA using make package
(it'll be built in the Dist
folder) and then use that.
from carla.
It is a variable taken as a argument in many file like this one file.
import carla
import numpy as np
import transforms3d.euler
from absl import logging
logging.set_verbosity(logging.DEBUG)
def setup(
town: str,
fps: int = 20,
server_timestop: float = 30.0,
client_timeout: float = 20.0,
num_max_restarts: int = 10,
):
"""Returns the CARLA
server
, client
and world
.
Args:
town: The `CARLA` town identifier.
fps: The frequency (in Hz) of the simulation.
server_timestop: The time interval between spawing the server
and resuming program.
client_timeout: The time interval before stopping
the search for the carla server.
num_max_restarts: Number of attempts to connect to the server.
Returns:
client: The `CARLA` client.
world: The `CARLA` world.
frame: The synchronous simulation time step ID.
server: The `CARLA` server.
"""
assert town in ("Town01", "Town02", "Town03", "Town04", "Town05")
# The attempts counter.
attempts = 0
while attempts < num_max_restarts:
logging.debug("{} out of {} attempts to setup the CARLA simulator".format(
attempts + 1, num_max_restarts))
# Random assignment of port.
port = np.random.randint(2000, 3000)
# Start CARLA server.
env = os.environ.copy()
env["SDL_VIDEODRIVER"] = "offscreen"
env["SDL_HINT_CUDA_DEVICE"] = "0"
logging.debug("Inits a CARLA server at port={}".format(port))
server = subprocess.Popen(f'DISPLAY= ' + str(os.path.join(os.environ.get("CARLA_ROOT"), "CarlaUE4.sh")) + f' -opengl '+ f' -carla-rpc-port={port}' + f" -quality-level=Epic ", stdout=None, stderr=subprocess.STDOUT, preexec_fn=os.setsid, env=env, shell=True)
atexit.register(os.killpg, server.pid, signal.SIGKILL)
time.sleep(server_timestop)
# Connect client.
logging.debug("Connects a CARLA client at port={}".format(port))
try:
client = carla.Client("localhost", port) # pylint: disable=no-member
client.set_timeout(client_timeout)
client.load_world(map_name=town)
world = client.get_world()
world.set_weather(carla.WeatherParameters.ClearNoon) # pylint: disable=no-member
frame = world.apply_settings(
carla.WorldSettings( # pylint: disable=no-member
synchronous_mode=True,
fixed_delta_seconds=1.0 / fps,
))
logging.debug("Server version: {}".format(client.get_server_version()))
logging.debug("Client version: {}".format(client.get_client_version()))
return client, world, frame, server
except RuntimeError as msg:
logging.debug(msg)
attempts += 1
logging.debug("Stopping CARLA server at port={}".format(port))
os.killpg(server.pid, signal.SIGKILL)
atexit.unregister(lambda: os.killpg(server.pid, signal.SIGKILL))
logging.debug(
"Failed to connect to CARLA after {} attempts".format(num_max_restarts))
sys.exit()
So as per my understanding I cannot remove that line.
Second option may work out. But would it launch the Carla server like CarlaUE4.sh command? Do you know that?
Thanks for your help.
from carla.
The server
object returned by Popen
is a system process. If you are using make launch
I think you can change your code to get it from the system process list using something like
processes = [p for p in psutil.process_iter() if 'carla' in p.name().lower()]
The second option generates a packaged version of CARLA, similar to the ones available for download. It includes a CarlaUE4.sh
file that launches the server.
from carla.
Okay. Thanks. Let me try and I get back to you.
from carla.
Hi,
I use the packaged version of carla and from .sh file I am able to open a server. So I change line like this:
server = subprocess.Popen(f'DISPLAY= ' + str(os.path.join("/home/local/carla0914/","CarlaUE4.sh")) + f' -opengl '+ f' -carla-rpc-port={port}' + f" -quality-level=Epic ", stdout=None, stderr=subprocess.STDOUT, preexec_fn=os.setsid, env=env, shell=True)
It started like this:
4.26.2-0+++UE4+Release-4.26 522 0
Disabling core dumps.
But then I got this error.
Error in atexit._run_exitfuncs:
ProcessLookupError: [Errno 3] No such process
Where I am making mistake? How to resolve this now?
from carla.
Hi,
I'm not really sure. At least the beginning (4.26.2-0+++UE4+Release-4.26 522 0 Disabling core dumps.
) is what you'd expect. This is helpful in explaining what the error means, and you may need to do some more debugging around the atexit
line(s) to figure out the root cause of the problem. I suspect for whatever reason the atexit
after the server
line cannot find server.pid
, but I may be wrong.
from carla.
Okay.
Thanks
from carla.
Related Issues (20)
- make launch failed
- cant launch scenario runner HOT 2
- Set traffic lights into customized map HOT 2
- Does existing DVS Event sesnor simulator in Carla solely rely on RGB images to generate events, or it uses other data like depth?
- How can I enable the autopilot system in CARLA without allowing it to control the vehicle?
- make import failed HOT 1
- LightManager Not Working Properly in Large Maps
- Create Custom Collision for the Town10 Road
- Skyscraper - Bottom Mall
- Skyscraper - Bottom Shops
- Skyscraper - Bottom Shops Columns
- Construction Building
- how to understand fps and delta seconds
- Carla Command Issue in Matlab
- Directly use the acceleration as the control command in Behavior_agent.py and Basic_agent.py.
- Carla crushes out after exactly a minute
- Correct Way to Modify Building Blueprints?
- carla leaderboard question?
- cant link port 2000 and cant start carlaUE4
- Make issues
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from carla.