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
04fdca7c
Commit
04fdca7c
authored
4 years ago
by
Armin Co
Browse files
Options
Downloads
Patches
Plain Diff
Simplified reward function
Reduced the problem to just, drive to a position.
parent
ba4d8e61
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
carla_environment.py
+25
-33
25 additions, 33 deletions
carla_environment.py
with
25 additions
and
33 deletions
carla_environment.py
+
25
−
33
View file @
04fdca7c
...
@@ -174,9 +174,9 @@ class World:
...
@@ -174,9 +174,9 @@ class World:
if
self
.
player
is
not
None
:
if
self
.
player
is
not
None
:
pos
=
self
.
player
.
get_transform
()
pos
=
self
.
player
.
get_transform
()
vel
=
self
.
player
.
get_velocity
()
vel
=
self
.
player
.
get_velocity
()
return
[
pos
.
location
.
x
,
pos
.
location
.
y
,
vel
.
x
,
vel
.
y
,
pos
.
rotation
.
yaw
]
return
[
pos
.
location
.
x
,
pos
.
location
.
y
,
vel
.
x
,
vel
.
y
,
(
pos
.
rotation
.
yaw
/
180
)
]
else
:
else
:
return
[
0
,
0
,
0
]
return
[
0
,
0
,
0
,
0
,
0
]
def
spawn_player
(
self
,
transform
):
def
spawn_player
(
self
,
transform
):
"""
Add a vehicle to the world.
"""
"""
Add a vehicle to the world.
"""
...
@@ -188,9 +188,10 @@ class World:
...
@@ -188,9 +188,10 @@ class World:
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
)
def
spawn_on_sidewalk
(
self
):
def
spawn_on_sidewalk
(
self
,
with_obstacles
=
False
):
position
=
carla
.
Transform
(
carla
.
Location
(
x
=-
13
,
y
=
5
7
.5
,
z
=
0.2
),
carla
.
Rotation
(
pitch
=
0.0
,
yaw
=-
1
8
0
,
roll
=
0.0
))
position
=
carla
.
Transform
(
carla
.
Location
(
x
=-
13
,
y
=
5
8
.5
,
z
=
0.2
),
carla
.
Rotation
(
pitch
=
0.0
,
yaw
=-
1
9
0
,
roll
=
0.0
))
self
.
spawn_player
(
position
)
self
.
spawn_player
(
position
)
if
with_obstacles
:
self
.
spawn_actors
(
self
.
sidewalk_parking_cars_transforms
())
self
.
spawn_actors
(
self
.
sidewalk_parking_cars_transforms
())
...
@@ -238,42 +239,33 @@ class World:
...
@@ -238,42 +239,33 @@ class World:
return
reward
return
reward
def
reward
(
self
,
action
):
def
reward
(
self
,
action
):
target
=
carla
.
Transform
(
carla
.
Location
(
x
=-
25.534311
,
y
=
54.460903
,
z
=
0.112781
),
carla
.
Rotation
(
pitch
=
0.000000
,
yaw
=-
175.922913
,
roll
=-
6.221135
))
x
,
y
,
vx
,
vy
,
yaw
=
self
.
observation
()
pos
=
self
.
player
.
get_transform
()
pos_diff
=
math
.
sqrt
((
target
.
location
.
x
-
pos
.
location
.
x
)
**
2
+
(
target
.
location
.
y
-
pos
.
location
.
y
)
**
2
)
target
=
carla
.
Transform
(
\
rot_diff
=
(
target
.
rotation
.
yaw
-
pos
.
rotation
.
yaw
)
carla
.
Location
(
x
=-
25.534311
,
y
=
54.460903
,
z
=
0.112781
),
\
velocity
=
self
.
player
.
get_velocity
()
carla
.
Rotation
(
pitch
=
0.000000
,
yaw
=-
175.922913
,
roll
=-
6.221135
))
v
=
math
.
sqrt
((
velocity
.
x
)
**
2
+
(
velocity
.
y
)
**
2
)
pos_diff
=
math
.
sqrt
((
target
.
location
.
x
-
x
)
**
2
+
(
target
.
location
.
y
-
y
)
**
2
)
r
=
((
-
pos_diff
/
10
)
+
1
)
/
5
rot_diff
=
((
target
.
rotation
.
yaw
/
180
)
-
yaw
)
if
v
<
0.01
:
v
=
math
.
sqrt
((
vx
)
**
2
+
(
vy
)
**
2
)
r
-=
0.5
if
v
>
15.0
:
r
=
-
0.1
r
-=
10
r
+=
-
0.01
*
pos_diff
at_final_position
=
False
if
pos_diff
<
1.8
:
if
self
.
was_big_reward
==
False
:
r
+=
50
self
.
was_big_reward
=
True
if
abs
(
rot_diff
)
<
5
and
v
<
0.01
:
at_final_position
=
True
else
:
if
self
.
was_big_reward
==
True
:
self
.
was_big_reward
=
False
r
-=
50
done
=
False
done
=
False
if
at_final_position
:
print
(
"
Success
"
)
if
pos_diff
<
1.5
:
r
+=
100
done
=
True
done
=
True
r
+=
100
if
self
.
collision_sensor
.
collision
is
not
None
:
if
self
.
collision_sensor
.
collision
is
not
None
:
r
-=
250
r
-=
100
done
=
True
if
pos_diff
>
15
:
done
=
True
done
=
True
if
action
==
IDLE
:
r
-=
100
r
-=
0.3
return
self
.
observation
(),
r
,
done
,
None
return
self
.
observation
(),
r
,
done
,
None
class
ActionSpace
:
class
ActionSpace
:
...
...
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