Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cocobotdemo
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastiano Gigliobianco
cocobotdemo
Commits
d6288865
Commit
d6288865
authored
1 year ago
by
seba
Browse files
Options
Downloads
Patches
Plain Diff
working with 7x7
parent
54fa5305
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/blueprints/home.py
+13
-15
13 additions, 15 deletions
app/blueprints/home.py
app/templates/home.html
+8
-7
8 additions, 7 deletions
app/templates/home.html
start_docker.sh
+15
-14
15 additions, 14 deletions
start_docker.sh
with
36 additions
and
36 deletions
app/blueprints/home.py
+
13
−
15
View file @
d6288865
...
...
@@ -20,7 +20,7 @@ with open("piece_variables.json", encoding="utf-8") as infile:
PIECE_VARIABLES
=
json
.
load
(
infile
)
CONFIG
=
{
"
width
"
:
4
.0
,
"
height
"
:
4
.0
,
"
move_step
"
:
1
,
"
prevent_overlap
"
:
False
}
CONFIG
=
{
"
width
"
:
7
.0
,
"
height
"
:
7
.0
,
"
move_step
"
:
1
,
"
prevent_overlap
"
:
False
}
OBJS
=
{
"
bridge
"
:
{
"
id_n
"
:
0
,
...
...
@@ -61,9 +61,10 @@ OBJS = {
}
COLORS
=
{
"
GREEN
"
:
[
"
green
"
,
"
#008000
"
,
[
0
,
128
,
0
]],
"
PURPLE
"
:
[
"
purple
"
,
"
#800080
"
,
[
128
,
0
,
128
]],
"
PINK
"
:
[
"
pink
"
,
"
#ffc0cb
"
,
[
255
,
192
,
203
]]
"
green
"
:
[
"
green
"
,
"
#008000
"
,
[
0
,
128
,
0
]],
"
red
"
:
[
"
red
"
,
"
#ff0000
"
,
[
255
,
0
,
0
]],
"
yellow
"
:
[
"
yellow
"
,
"
#ffa500
"
,
[
255
,
165
,
0
]],
"
blue
"
:
[
"
blue
"
,
"
#1b4ccd
"
,
[
27
,
76
,
205
]]
}
...
...
@@ -81,7 +82,7 @@ NAME_GEN = name_generator()
@socketio.on
(
'
click
'
)
def
sample_preview_board
(
config
):
golmi_server
=
f
'
http://
{
current_app
.
config
[
"
golmi_host
"
]
}
:
{
current_app
.
config
[
"
golmi_port
"
]
}
'
golmi_server
=
f
'
{
current_app
.
config
[
"
golmi_host
"
]
}
:
{
current_app
.
config
[
"
golmi_port
"
]
}
'
room_id
=
config
[
"
room_id
"
]
...
...
@@ -91,8 +92,6 @@ def sample_preview_board(config):
f
"
{
golmi_server
}
/slurk/
{
room_id
}
/state
"
)
print
(
f
"
{
golmi_server
}
/slurk/
{
room_id
}
/state
"
)
state
=
req
.
json
()
obj
=
OBJS
[
config
[
"
shape
"
]]
obj
[
"
color
"
]
=
COLORS
[
config
[
"
color
"
]]
...
...
@@ -110,8 +109,7 @@ def sample_preview_board(config):
client
=
clients
[
room_id
]
client
.
load_state
(
state
)
print
(
client
)
print
(
room_id
)
else
:
req
=
requests
.
get
(
f
'
{
golmi_server
}
/slurk/
{
room_id
}
/
{
config
[
"
coordinates
"
][
"
x
"
]
}
/
{
config
[
"
coordinates
"
][
"
y
"
]
}
/
{
config
[
"
coordinates
"
][
"
block_size
"
]
}
'
...
...
@@ -123,14 +121,14 @@ def sample_preview_board(config):
if
piece
:
piece
=
list
(
piece
.
values
())[
0
]
socketio
.
emit
(
"
gripped
"
,
{
"
color
"
:
piece
[
"
color
"
][
0
]
.
upper
()
,
"
color
"
:
piece
[
"
color
"
][
0
],
"
shape
"
:
piece
[
"
type
"
],
})
@socketio.on
(
'
change
'
)
def
change
(
data
):
golmi_server
=
f
'
http://
{
current_app
.
config
[
"
golmi_host
"
]
}
:
{
current_app
.
config
[
"
golmi_port
"
]
}
'
golmi_server
=
f
'
{
current_app
.
config
[
"
golmi_host
"
]
}
:
{
current_app
.
config
[
"
golmi_port
"
]
}
'
room_id
=
data
[
"
room_id
"
]
req
=
requests
.
get
(
f
"
{
golmi_server
}
/slurk/
{
room_id
}
/state
"
...
...
@@ -147,12 +145,10 @@ def change(data):
obj
=
piece
[
id_n
]
if
data
[
"
color
"
]
in
COLORS
:
print
(
"
change color
"
)
new_color
=
COLORS
[
data
[
"
color
"
]]
obj
[
"
color
"
]
=
new_color
if
data
[
"
shape
"
]
in
OBJS
:
print
(
"
change shape
"
)
new_shape
=
data
[
"
shape
"
]
new_matrix
=
OBJS
[
data
[
"
shape
"
]][
"
block_matrix
"
]
obj
[
"
block_matrix
"
]
=
new_matrix
...
...
@@ -174,8 +170,8 @@ def disconnection():
@home.route
(
'
/
'
)
def
main
():
room_id
=
str
(
uuid
.
uuid4
())
golmi_address
=
f
'
http://
{
current_app
.
config
[
"
golmi_host
"
]
}
:
{
current_app
.
config
[
"
golmi_port
"
]
}
'
room_id
=
str
(
uuid
.
uuid4
())
.
split
(
"
-
"
)[
0
]
golmi_address
=
f
'
{
current_app
.
config
[
"
golmi_host
"
]
}
:
{
current_app
.
config
[
"
golmi_port
"
]
}
'
golmi_pswd
=
current_app
.
config
[
"
golmi_pswd
"
]
client
=
GolmiClient
()
...
...
@@ -187,6 +183,8 @@ def main():
client
.
load_config
(
CONFIG
)
print
(
f
"
Your room id:
{
room_id
}
"
)
return
render_template
(
"
home.html
"
,
room_id
=
room_id
,
...
...
This diff is collapsed.
Click to expand it.
app/templates/home.html
+
8
−
7
View file @
d6288865
...
...
@@ -54,10 +54,10 @@
<a>
Shape:
</a>
<select
class=
"ui selection dropdown"
id=
"shape"
>
<option
value=
""
>
</option>
<option
value=
"nut"
>
NUT
</option>
<option
value=
"washer"
>
WASHER
</option>
<option
value=
"screw"
>
SCREW
</option>
<option
value=
"bridge"
>
BRIDGE
</option>
<option
value=
"nut"
>
nut
</option>
<option
value=
"washer"
>
washer
</option>
<option
value=
"screw"
>
screw
</option>
<option
value=
"bridge"
>
bridge
</option>
</select>
</div>
...
...
@@ -65,9 +65,10 @@
<a>
Color:
</a>
<select
class=
"ui selection dropdown"
id=
"color"
>
<option
value=
""
>
</option>
<option
value=
"GREEN"
>
GREEN
</option>
<option
value=
"PURPLE"
>
PURPLE
</option>
<option
value=
"PINK"
>
PINK
</option>
<option
value=
"green"
>
green
</option>
<option
value=
"yellow"
>
yellow
</option>
<option
value=
"red"
>
red
</option>
<option
value=
"blue"
>
blue
</option>
</select>
</div>
...
...
This diff is collapsed.
Click to expand it.
start_docker.sh
+
15
−
14
View file @
d6288865
...
...
@@ -10,18 +10,19 @@ docker run --network host \
-e
GOLMI_PORT
=
$GOLMI_PORT
\
-d
$GOLMI_NAME
#
cd ../cocobotdemo
#
GUI_NAME="cocobotdemo"
#
GUI_ADDRESS="127.0.0.1"
#
GUI_PORT=5000
#
GOLMI_PSWD="GiveMeTheBigBluePasswordOnTheLeft"
cd
../cocobotdemo
GUI_NAME
=
"cocobotdemo"
GUI_ADDRESS
=
"127.0.0.1"
GUI_PORT
=
5000
GOLMI_PSWD
=
"GiveMeTheBigBluePasswordOnTheLeft"
# docker build --tag "$GUI_NAME" -f dockerfile .
# docker run --network host \
# --restart unless-stopped \
# -e ADDRESS=$GUI_ADDRESS \
# -e PORT=$GUI_PORT \
# -e GOLMI_PSWD=$GOLMI_PSWD \
# -e GOLMI_HOST=$GOLMI_HOST \
# -e GOLMI_PORT=$GOLMI_PORT \
# -d $GUI_NAME
docker build
--tag
"
$GUI_NAME
"
-f
dockerfile
.
docker run
\
--restart
unless-stopped
\
-e
ADDRESS
=
$GUI_ADDRESS
\
-e
PORT
=
$GUI_PORT
\
-e
GOLMI_PSWD
=
$GOLMI_PSWD
\
-e
GOLMI_HOST
=
$GOLMI_HOST
\
-e
GOLMI_PORT
=
$GOLMI_PORT
\
--net
host
\
-d
$GUI_NAME
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