Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Cooperative Cuisine Environment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Social Cognitive Systems
CoCoSy
Cooperative Cuisine Environment
Commits
a4fe5a07
Commit
a4fe5a07
authored
1 year ago
by
Annika Österdiekhoff
Browse files
Options
Downloads
Patches
Plain Diff
fix interaction error
parent
6ba1f773
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!45
Resolve "Controller Support"
Pipeline
#46219
passed
1 year ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
overcooked_simulator/gui_2d_vis/overcooked_gui.py
+9
-11
9 additions, 11 deletions
overcooked_simulator/gui_2d_vis/overcooked_gui.py
with
9 additions
and
11 deletions
overcooked_simulator/gui_2d_vis/overcooked_gui.py
+
9
−
11
View file @
a4fe5a07
...
...
@@ -258,7 +258,6 @@ class PyGameGUI:
if
np
.
linalg
.
norm
(
move_vec
)
!=
0
:
move_vec
=
move_vec
/
np
.
linalg
.
norm
(
move_vec
)
print
(
"
move vector keys
"
,
move_vec
)
action
=
Action
(
current_player_name
,
ActionType
.
MOVEMENT
,
...
...
@@ -276,6 +275,7 @@ class PyGameGUI:
# Axis 1: joy stick left: -1 = up, ~0 = center, 1 = down
# see control stuff here (at the end of the page): https://www.pygame.org/docs/ref/joystick.html
for
key_set
in
self
.
key_sets
:
current_player_name
=
str
(
key_set
.
current_player
)
# if a joystick is connected for current player
if
joysticks
[
key_set
.
joystick
]:
# Usually axis run in pairs, up/down for one, and left/right for the other. Triggers count as axes.
...
...
@@ -297,9 +297,8 @@ class PyGameGUI:
if
np
.
linalg
.
norm
(
move_vec
)
!=
0
:
move_vec
=
move_vec
/
np
.
linalg
.
norm
(
move_vec
)
print
(
"
move_vec
"
,
move_vec
)
action
=
Action
(
str
(
key_set
.
joystick
)
,
ActionType
.
MOVEMENT
,
move_vec
,
duration
=
1
/
self
.
FPS
current_player_name
,
ActionType
.
MOVEMENT
,
move_vec
,
duration
=
1
/
self
.
FPS
)
self
.
send_action
(
action
)
...
...
@@ -344,26 +343,25 @@ class PyGameGUI:
"""
for
key_set
in
self
.
key_sets
:
current_player_name
=
str
(
key_set
.
current_player
)
# if a joystick is connected for current player
if
joysticks
[
key_set
.
joystick
]:
# pickup = Button A <-> 0
if
joysticks
[
key_set
.
joystick
].
get_button
(
0
):
action
=
Action
(
str
(
key_set
.
joystick
)
,
ActionType
.
PUT
,
"
pickup
"
)
if
joysticks
[
key_set
.
joystick
].
get_button
(
0
)
and
event
.
type
==
pygame
.
JOYBUTTONDOWN
:
action
=
Action
(
current_player_name
,
ActionType
.
PUT
,
"
pickup
"
)
self
.
send_action
(
action
)
# FIXME: when clicking X without cutboard and then A to lay it on the cutboard,
# it is automatically cutted when laying down
# FIXME: does it work with button up and down?
# interact = Button X <-> 2
if
joysticks
[
key_set
.
joystick
].
get_
button
(
2
)
:
if
event
.
button
==
2
:
if
event
.
type
==
pygame
.
JOYBUTTONDOWN
:
action
=
Action
(
str
(
key_set
.
joystick
)
,
ActionType
.
INTERACT
,
InterActionData
.
START
current_player_name
,
ActionType
.
INTERACT
,
InterActionData
.
START
)
self
.
send_action
(
action
)
# stop interaction if last pressed button was X <-> 2
elif
event
.
type
==
pygame
.
JOYBUTTONUP
:
action
=
Action
(
str
(
key_set
.
joystick
)
,
ActionType
.
INTERACT
,
InterActionData
.
STOP
current_player_name
,
ActionType
.
INTERACT
,
InterActionData
.
STOP
)
self
.
send_action
(
action
)
...
...
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