Comments (5)
We need more context. Which map are you using, Which gpu are you using, which NVIDIA Drivers are you using?
from carla.
Before the crash it seems you have tried to close server without closing the client which creates issue.
from carla.
I`m using town 01
GPU Type: NVIDIA GeForce RTX 4070 Ti
Driver Version: 550.54.15
and here is the environment I made:
class CarEnv(gym.Env):
SHOW_CAM = SHOW_PREVIEW
STEER_AMT = 1.0
im_width = WIDTH
im_height = HEIGHT
front_camera = None
CAMERA_POS_Z = 1.3
CAMERA_POS_X = 1.4
PREFERRED_SPEED = 60
SPEED_THRESHOLD = 2
def __init__(self):
super(CarEnv, self).__init__()
self.action_space = spaces.Discrete(9)
self.observation_space = spaces.Box(low=0.0, high=255.0,
shape=(HEIGHT, WIDTH, N_CHANNELS), dtype=np.uint8)
self.client = carla.Client("localhost", 2000)
self.client.set_timeout(4.0)
self.client.load_world('Town01')
self.world = self.client.get_world()
self.settings = self.world.get_settings()
self.settings.no_rendering_mode = True
#self.settings.synchronous_mode = False
self.settings.fixed_delta_seconds = FIXED_DELTA_SECONDS
self.world.apply_settings(self.settings)
self.blueprint_library = self.world.get_blueprint_library()
self.model_3 = self.blueprint_library.filter("model3")[0]
def maintain_speed(self,s):
if s >= self.PREFERRED_SPEED:
return 0
elif s < self.PREFERRED_SPEED - self.SPEED_THRESHOLD:
return 0.7 # think of it as % of "full gas"
else:
return 0.3 # tweak this if the car is way over or under preferred speed
def reset(self, seed=None, options=None):
self.collision_hist = []
self.actor_list = []
self.spawn_points = self.world.get_map().get_spawn_points()
#print(type(self.spawn_points[2]))
#print(type(random.choice(self.spawn_points)))
self.vehicle = self.world.try_spawn_actor(self.model_3, random.choice(self.spawn_points))
self.actor_list.append(self.vehicle)
self.initial_location = self.vehicle.get_location()
self.sem_cam = self.blueprint_library.find('sensor.camera.semantic_segmentation')
self.sem_cam.set_attribute("image_size_x", f"{self.im_width}")
self.sem_cam.set_attribute("image_size_y", f"{self.im_height}")
self.sem_cam.set_attribute("fov", f"90")
camera_init_trans = carla.Transform(carla.Location(z=self.CAMERA_POS_Z,x=self.CAMERA_POS_X))
self.sensor = self.world.spawn_actor(self.sem_cam, camera_init_trans, attach_to=self.vehicle)
self.actor_list.append(self.sensor)
self.sensor.listen(lambda data: self.process_img(data))
self.vehicle.apply_control(carla.VehicleControl(throttle=0.0, brake=0.0))
time.sleep(2) #not detect a collision when the car spawns/falls from sky.
# showing camera at the spawn point
if self.SHOW_CAM:
cv2.namedWindow('Sem Camera',cv2.WINDOW_AUTOSIZE)
cv2.imshow('Sem Camera', self.front_camera)
cv2.waitKey(1)
colsensor = self.blueprint_library.find("sensor.other.collision")
self.colsensor = self.world.spawn_actor(colsensor, camera_init_trans, attach_to=self.vehicle)
self.actor_list.append(self.colsensor)
self.colsensor.listen(lambda event: self.collision_data(event))
while self.front_camera is None:
time.sleep(0.01)#Just in case car takes any longer, because we need to be certain the car is done falling from the sky on spawn.
self.episode_start = time.time()
#self.steering_lock = False
#self.steering_lock_start = None # this is to count time in steering lock and start penalising for long time in steering lock
self.step_counter = 0
self.vehicle.apply_control(carla.VehicleControl(throttle=0.0, brake=0.0))
observation = self.front_camera
return observation.astype(np.uint8), {}
def step(self, action):
self.step_counter +=1
steer = action
# map steering actions
if steer ==0:
steer = - 0.9
elif steer ==1:
steer = -0.25
elif steer ==2:
steer = -0.1
elif steer ==3:
steer = -0.05
elif steer ==4:
steer = 0.0
elif steer ==5:
steer = 0.05
elif steer ==6:
steer = 0.1
elif steer ==7:
steer = 0.25
elif steer ==8:
steer = 0.9
v = self.vehicle.get_velocity()
kmh = int(3.6 * math.sqrt(v.x**2 + v.y**2 + v.z**2))
estimated_throttle = self.maintain_speed(kmh)
self.vehicle.apply_control(carla.VehicleControl(throttle=estimated_throttle, steer=steer, brake = 0.0))
#distance_travelled = self.initial_location.distance(self.vehicle.get_location())
# storing camera to return at the end in case the clean-up function destroys it
cam = self.front_camera
# showing image
if self.SHOW_CAM:
cv2.imshow('Sem Camera', cam)
cv2.waitKey(1)
# start defining reward from each step
reward = 0
done = False
#punish for collision
if len(self.collision_hist) != 0:
done = True
reward = reward - 300
self.cleanup()
#reward for acceleration
if kmh < 15:
reward = reward - 3
elif kmh <25:
reward = reward - 2
elif kmh <50:
reward = reward - 1
elif kmh>120:
reward = reward - 10 #punish for going too fast
else:
reward = reward + 1
# check for episode duration
if self.episode_start + SECONDS_PER_EPISODE < time.time():
done = True
self.cleanup()
observation = cam
return observation.astype(np.uint8), reward, done, False, {}
def cleanup(self):
for sensor in self.world.get_actors().filter('*sensor*'):
sensor.destroy()
for actor in self.world.get_actors().filter('*vehicle*'):
actor.destroy()
cv2.destroyAllWindows()
def process_img(self, image):
image.convert(carla.ColorConverter.CityScapesPalette)
i = np.array(image.raw_data)
i = i.reshape((self.im_height, self.im_width, 4))[:, :, :3] # this is to ignore the 4th Alpha channel - up to 3
self.front_camera = i/255.0
def collision_data(self, event):
self.collision_hist.append(event)
from carla.
I tried to run ./CarlaUE4.sh -RenderOffScreen
and the server didn`t crash, is that right to stop the render screen ?
from carla.
Yes, the RenderScreen used for CARLA server is only debug purpouses. Latest NVIDIA drivers are unstable for Vulkan. We recommend what UE recommend for UE4 which is 4XX
from carla.
Related Issues (20)
- Setup.sh: Implement a work around when apt update not works
- No CarlaUE4.sh file HOT 4
- launch error HOT 2
- How to replay and record from a driving perspective HOT 5
- ShaderCompileWorker directory not found error when launching the Editor HOT 2
- CARLA C++ client example/easy_import_cmake_include HOT 3
- destroying actors from a list HOT 2
- CarlaUnreal repository not found HOT 9
- BuildLibCarla.sh: Building LibCarla "Client.Release" configuration.
- Using the manual_control.py script, pygame displays a black screen HOT 5
- Create OptiX UE5 Plugin
- Import Static object to OptiX Scene
- Import Dynamic Objects to OptiX Scene
- Test Ray tracing capabilities from OptiX
- Add to Spawn Actor Function Attributes Map HOT 3
- Create mechanisim to get post process volume values into camera sensor
- Fix Pedestrians colision/DeathAnim Gen3 HOT 1
- Sensors in CARLA unaffected by weather conditions HOT 1
- How to acquire intensity and angle when using LiDAR? HOT 1
- Carla crash with quality mode low and RenderOffScreen HOT 8
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.