Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LearningEnvironment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Armin Co
LearningEnvironment
Commits
99d658ff
Commit
99d658ff
authored
Mar 10, 2021
by
Armin Co
Browse files
Options
Downloads
Patches
Plain Diff
Integrated manual control into env
parent
0f51360d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
carla_environment.py
+8
-4
8 additions, 4 deletions
carla_environment.py
run_scripts/manual_carla.py
+26
-24
26 additions, 24 deletions
run_scripts/manual_carla.py
run_scripts/start_carla.sh
+8
-0
8 additions, 0 deletions
run_scripts/start_carla.sh
with
42 additions
and
28 deletions
carla_environment.py
+
8
−
4
View file @
99d658ff
...
@@ -185,7 +185,6 @@ class World:
...
@@ -185,7 +185,6 @@ class World:
position
=
transform
position
=
transform
self
.
player
=
self
.
world
.
try_spawn_actor
(
blueprint
,
position
)
self
.
player
=
self
.
world
.
try_spawn_actor
(
blueprint
,
position
)
start_location
=
self
.
player
.
get_location
()
start_location
=
self
.
player
.
get_location
()
print
(
str
(
start_location
))
self
.
collision_sensor
=
CollisionSensor
(
self
.
world
,
self
.
player
)
self
.
collision_sensor
=
CollisionSensor
(
self
.
world
,
self
.
player
)
self
.
obstacle_sensor
=
ObstacleSensor
(
self
.
world
,
self
.
player
)
self
.
obstacle_sensor
=
ObstacleSensor
(
self
.
world
,
self
.
player
)
...
@@ -290,12 +289,12 @@ class CarlaEnvironment:
...
@@ -290,12 +289,12 @@ class CarlaEnvironment:
client
=
None
client
=
None
camera
=
None
camera
=
None
allow_render
=
False
allow_render
=
False
manual
=
False
def
__init__
(
self
,
host
=
"
127.0.0.1
"
,
port
=
2000
,
render
=
False
):
def
__init__
(
self
,
host
=
"
127.0.0.1
"
,
port
=
2000
,
render
=
False
,
manual
=
False
):
pygame
.
init
()
pygame
.
init
()
self
.
client
=
carla
.
Client
(
host
,
port
)
self
.
client
=
carla
.
Client
(
host
,
port
)
self
.
client
.
set_timeout
(
5.0
)
self
.
client
.
set_timeout
(
3.0
)
time
.
sleep
(
1.0
)
self
.
client
.
load_world
(
'
Town07
'
)
self
.
client
.
load_world
(
'
Town07
'
)
time
.
sleep
(
1.0
)
time
.
sleep
(
1.0
)
self
.
world
=
World
(
self
.
client
.
get_world
())
self
.
world
=
World
(
self
.
client
.
get_world
())
...
@@ -303,6 +302,9 @@ class CarlaEnvironment:
...
@@ -303,6 +302,9 @@ class CarlaEnvironment:
self
.
allow_render
=
True
self
.
allow_render
=
True
self
.
camera
=
Camera
(
self
.
world
,
camera_type
=
'
semantic_segmentation
'
)
self
.
camera
=
Camera
(
self
.
world
,
camera_type
=
'
semantic_segmentation
'
)
# self.camera = Camera(self.world, camera_type='rgb')
# self.camera = Camera(self.world, camera_type='rgb')
if
manual
:
self
.
manual
=
False
self
.
cntrl
=
Controller
()
def
reset
(
self
):
def
reset
(
self
):
self
.
world
.
reset
()
self
.
world
.
reset
()
...
@@ -315,6 +317,8 @@ class CarlaEnvironment:
...
@@ -315,6 +317,8 @@ class CarlaEnvironment:
def
step
(
self
,
action
,
render
=
False
):
def
step
(
self
,
action
,
render
=
False
):
if
render
:
if
render
:
self
.
render
()
self
.
render
()
if
self
.
manual
:
action
=
self
.
cntrl
.
get_action
()
return
self
.
world
.
step
(
action
)
return
self
.
world
.
step
(
action
)
def
__del__
(
self
):
def
__del__
(
self
):
...
...
This diff is collapsed.
Click to expand it.
run_scripts/manual_carla.py
+
26
−
24
View file @
99d658ff
...
@@ -2,41 +2,43 @@ import main
...
@@ -2,41 +2,43 @@ import main
import
environment_wrapper
as
ew
import
environment_wrapper
as
ew
import
gym
import
gym
import
copy
import
copy
from
agents
import
QAgent
as
QAgent
from
agents
import
QAgent
,
D
QAgent
from
carla_environment
import
CarlaEnvironment
from
carla_environment
import
CarlaEnvironment
c
=
ew
.
Config
()
c
=
ew
.
Config
()
c
.
name
=
'
Base
'
c
.
name
=
'
2
'
c
.
render
=
True
c
.
render
=
True
c
.
env_type
=
'
Carla
'
c
.
env_type
=
'
Carla
'
c
.
net_layout
=
[
256
,
128
]
c
.
net_layout
=
[
256
,
128
,
128
]
c
.
eps_decay
=
0.9995
c
.
eps_decay
=
0.9995
c
.
learn_rate
=
0.001
c
.
learn_rate
=
0.001
c
.
run_episodes
=
2
0
c
.
run_episodes
=
10
0
c
.
save_to
=
'
test/
'
c
.
save_to
=
'
test/
'
c
.
load_from
=
'
Carla_1_256__128__128_0.9995_0.001_1
'
c
.
load_mem
=
True
t
=
copy
.
deepcopy
(
c
)
#
t = copy.deepcopy(c)
t
.
render
=
True
#
t.render = True
t
.
net_layout
=
[
1024
,
1024
,
256
,
32
]
#
t.net_layout = [1024, 1024, 256, 32]
t
.
eps_decay
=
0.9993
#
t.eps_decay = 0.9993
t
.
learn_rate
=
0.0005
#
t.learn_rate = 0.0005
t
.
force_cpu
=
False
#
t.force_cpu = False
t
.
load_mem
=
True
#
t.load_mem = True
t
.
load_ann
=
False
#
t.load_ann = False
t
.
save_to
=
'
test/
'
#
t.save_to = 'test/'
t
.
load_from
=
'
Carla_CarlaOffline_1024__1024__256__32_0.9993_0.0005_50
'
#
t.load_from = 'Carla_CarlaOffline_1024__1024__256__32_0.9993_0.0005_50'
t
.
name
=
'
Offline
'
#
t.name = 'Offline'
t
.
learn_offline
=
True
#
t.learn_offline = True
t
.
learn_online
=
True
#
t.learn_online = True
t
.
run_episodes
=
500
#
t.run_episodes = 500
t
.
offline_epochs
=
100
#
t.offline_epochs = 100
t
.
learn_iterations
=
100
#
t.learn_iterations = 100
t
.
offline_validate_every_x_iteration
=
-
1
#
t.offline_validate_every_x_iteration = -1
configuration
=
t
configuration
=
c
configuration
.
env
=
CarlaEnvironment
(
render
=
configuration
.
render
)
configuration
.
env
=
CarlaEnvironment
(
render
=
configuration
.
render
,
manual
=
True
)
configuration
.
conf_to_name
()
configuration
.
conf_to_name
()
configuration
.
agent
=
QAgent
(
configuration
)
configuration
.
agent
=
D
QAgent
(
configuration
)
main
.
run
(
configuration
)
main
.
run
(
configuration
)
This diff is collapsed.
Click to expand it.
run_scripts/start_carla.sh
0 → 100755
+
8
−
0
View file @
99d658ff
# Start CARLA
#
# You may have to change the path to the CarlaUE4.sh
# The simulator could be installed with your package manager:
# apt install carla-simulator
#
DISPLAY
=
/opt/carla-simulator/CarlaUE4.sh
-benchmark
-fps
=
15
-quality-level
=
Low
-opengl
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment