Comments (7)
Hi, glad to see this is resolved. Make sure the fixed_delta_seconds
equals the inverse of your desired framerate. In our case we usually leave it as 0.03
to get ~30FPS.
Other than that, check Task manager to see what the bottleneck might be. If all your CPU cores are at 100% then its likely that you spawned too many vehicle's, similar situation with memory. In this case you might want to spawn fewer vehicles.
from dreyevr.
It seems like the car breaks as soon as the ego vehicle attains a speed of 20 mph. Moreover, all the other spawned vehicles also have unexpected behavior, and they soon crash into each other.
from dreyevr.
Ah ok yes, this sounds familiar. The other vehicles' erradic behaviour where they crash into each other and so-forth is because the PythonAPI is trying to operate at some asynchronous pace while the server (UE4 instance) is unpredictable with its own variable refresh rate depending on performance.
The easiest way to combat this is to run the controller for the PythonAPI in sync with the server. You can do this by including the --sync
flag in scenario runner (or run_experiment.py
if you're using that). More info here
from dreyevr.
This might be related to the EgoVehicle AI braking, but I'm not sure since I haven't seen this before. Can you try reproducing the issue once all the non-ego vehicles are operating correctly (using --sync
flag)
from dreyevr.
Ah ok yes, this sounds familiar. The other vehicles' erradic behaviour where they crash into each other and so-forth is because the PythonAPI is trying to operate at some asynchronous pace while the server (UE4 instance) is unpredictable with its own variable refresh rate depending on performance.
The easiest way to combat this is to run the controller for the PythonAPI in sync with the server. You can do this by including the
--sync
flag in scenario runner (orrun_experiment.py
if you're using that). More info here
How can I run scripts that use PythonAPI in sync with CARLA if I am not using scenario runner?
from dreyevr.
Okay, so according to Carla's documentation, I can set the synchronous mode using:
settings.synchronous_mode = True # Enables synchronous mode
settings.fixed_delta_seconds = 0.01
Moreover, I also set the synchronous mode for the traffic manager:
traffic_manager.set_synchronous_mode(True)
However, as soon as I run the script the simulator is stuck. I have no clue why. Can you help me out?
Here is the screen capture, if it helps
And, below is the startup.py
I ran alongside when the simulator was running:
import carla
import argparse
import time
import random
def main():
argparser = argparse.ArgumentParser(
description=__doc__)
argparser.add_argument(
'--host',
metavar='H',
default='127.0.0.1',
help='IP of the host server (default: 127.0.0.1)')
argparser.add_argument(
'-p', '--port',
metavar='P',
default=2000,
type=int,
help='TCP port to listen to (default: 2000)')
argparser.add_argument(
'-n', '--number-of-vehicles',
metavar='N',
default=150,
type=int,
help='Number of vehicles (default: 150)')
argparser.add_argument(
'-w', '--number-of-walkers',
metavar='W',
default=50,
type=int,
help='Number of walkers (default: 50)')
argparser.add_argument(
'--tm-port',
metavar='P',
default=8000,
type=int,
help='Port to communicate with TM (default: 8000)')
args = argparser.parse_args()
try:
client = carla.Client(args.host, args.port)
client.set_timeout(10.0) # seconds
world = client.get_world()
traffic_manager = client.get_trafficmanager(args.tm_port)
traffic_manager.set_global_distance_to_leading_vehicle(2.5)
traffic_manager.set_respawn_dormant_vehicles(True)
settings = world.get_settings()
settings.synchronous_mode = True # Enables synchronous mode
settings.fixed_delta_seconds = 0.01
world.apply_settings(settings)
traffic_manager.set_synchronous_mode(True)
print(f"Spawning {args.number_of_vehicles} in the world.")
spawn_other_avs(client, args.number_of_vehicles, world, traffic_manager)
finally:
print("Programme finished running. Exiting")
time.sleep(5)
def spawn_other_avs(client, max_vehicles, world, traffic_manager):
spawn_points = world.get_map().get_spawn_points()
blueprints = world.get_blueprint_library().filter("vehicle.*")
blueprints = sorted(blueprints, key=lambda bp: bp.id)
vehicle_list = []
batch = []
for n, transform in enumerate(spawn_points):
if n >= max_vehicles:
break
blueprint = random.choice(blueprints)
if blueprint.has_attribute("color"):
color = random.choice(blueprint.get_attribute("color").recommended_values)
blueprint.set_attribute("color", color)
if blueprint.has_attribute("driver_id"):
driver_id = random.choice(
blueprint.get_attribute("driver_id").recommended_values
)
blueprint.set_attribute("driver_id", driver_id)
try:
blueprint.set_attribute("role_name", "autopilot")
except IndexError:
pass
vehicle = world.try_spawn_actor(blueprint, transform)
if vehicle is not None:
vehicle.set_autopilot(True)
vehicle_list.append(vehicle)
else:
n -= 1
print(f"successfully spawned {len(vehicle_list)} vehicles")
return vehicle_list
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
pass
finally:
print('\ndone.')
Edit: On running the stratup.py
multiple times, I found that sometimes, it does not get stuck, and the ego vehicle starts moving autonomously. This behavior is not expected as the startup.py
I am running does not set the ego vehicle on autonomous mode. This issue is being highlighted in #42
from dreyevr.
Update: I fixed the simulator being stuck. It was because I was not calling world.tick()
after spawning the vehicles as recommended here. I apologize for not doing my due diligence.
Now, the spawned vehicles do not crash into each other, however, the simulator is really slow now. Is there a way to optimize that? Moreover, #42 still remains a problem.
from dreyevr.
Related Issues (20)
- How to set a custom path for autonomous vehicle using PythonAPI? HOT 10
- Custom props in dreyevr HOT 4
- Autopilot vehicles crashing into ego vehicle HOT 11
- scenario_runner error HOT 14
- Certain controls not available after exiting spectator mode HOT 3
- Getting EgoSensor data when the EgoVehicle hasn't spawned yet HOT 9
- UE4 Editor crashed after 'make launch' HOT 2
- Display sim-time in replay; synchronization discussion HOT 6
- make package fails after merging with dev branch HOT 2
- How to specify 2 arguments simultaneously for make import HOT 4
- make: Nothing to be done for 'PythonAPI' // installation issues // parser-issues HOT 58
- FileNotFound error when running the scenario runner HOT 12
- Cannot find vehicle config (.ini) files when adding my own EgoVehicle HOT 2
- DReyeVR Parser data output HOT 9
- "Fatal Error" while using start_replaying.py HOT 7
- "git checkout" command for supported version gives error HOT 1
- getting fatal error HOT 1
- make package not working for the UnrealCarla fork HOT 6
- I have got a new error while I want to make launch after making PythonAPI HOT 19
- Cannot connect with Steam VR HOT 3
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 dreyevr.