Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
web-ros3rag
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
JastAdd
web-ros3rag
Commits
a82654a8
Commit
a82654a8
authored
2 years ago
by
René Schöne
Browse files
Options
Downloads
Patches
Plain Diff
expert view
parent
d51a74f1
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
main.py
+43
-40
43 additions, 40 deletions
main.py
with
43 additions
and
40 deletions
main.py
+
43
−
40
View file @
a82654a8
...
...
@@ -36,6 +36,13 @@ max_topic = utils.MaxTopicLength()
# buffer for mqtt log
message_queue
=
queue
.
Queue
()
# buttons to show only in expert-view (additionally to coordinator-div and arm/object divs)
expert_view_buttons
=
[
'
send-place-a-model-details
'
,
'
send-place-b-model-details
'
,
'
send-place-b-demo-initial_scene
'
]
# button-id: (topic, payload)
commands
=
{
'
send-place-a-model
'
:
(
'
place-a/model
'
,
'
1
'
),
...
...
@@ -120,7 +127,13 @@ topics_enabled_once_seen = [
svg_image_topic
=
'
place-b/model/svg/path
'
button_style_normal
=
{
"
marginRight
"
:
"
15px
"
,
"
padding
"
:
"
2px
"
,
"
height
"
:
"
20px
"
,
"
line-height
"
:
"
0
"
,
"
marginTop
"
:
"
5px
"
}
button_style_normal_invisible
=
{
"
marginRight
"
:
"
15px
"
,
"
padding
"
:
"
2px
"
,
"
height
"
:
"
20px
"
,
"
line-height
"
:
"
0
"
,
"
marginTop
"
:
"
5px
"
,
'
display
'
:
'
none
'
}
button_style_exit
=
{
**
button_style_normal
,
"
backgroundColor
"
:
"
red
"
,
"
color
"
:
"
white
"
}
button_style_exit_invisible
=
{
**
button_style_normal_invisible
,
"
backgroundColor
"
:
"
red
"
,
"
color
"
:
"
white
"
}
buttons_style
=
{
"
display
"
:
"
none
"
,
"
border
"
:
"
1px black solid
"
,
"
border-radius
"
:
"
5px
"
,
"
marginTop
"
:
"
5px
"
}
textarea_style_normal
=
{
'
width
'
:
'
100%
'
,
'
height
'
:
'
200px
'
,
'
resize
'
:
'
vertical
'
}
tab_height
=
'
3vh
'
tabs_style
=
{
'
line-height
'
:
tab_height
}
...
...
@@ -195,11 +208,11 @@ app.layout = html.Div([
html
.
Button
(
'
RAG B Ready
'
,
id
=
'
send-place-b-rag-ready
'
,
style
=
button_style_normal
),
html
.
Button
(
'
Dummy Ready
'
,
id
=
'
send-dummy-ready
'
,
style
=
button_style_normal
),
# ], className='row'),
],
className
=
"
four columns
"
),
],
className
=
"
four columns
"
,
id
=
'
coordinator-div
'
,
style
=
{
'
display
'
:
'
none
'
}
),
html
.
Div
([
# Column for commands of place a
html
.
H3
(
"
Commands Place A
"
),
html
.
Button
(
'
Model
'
,
id
=
'
send-place-a-model
'
,
style
=
button_style_normal
),
html
.
Button
(
'
Model (Details)
'
,
id
=
'
send-place-a-model-details
'
,
style
=
button_style_normal
),
html
.
Button
(
'
Model (Details)
'
,
id
=
'
send-place-a-model-details
'
,
style
=
button_style_normal
_invisible
),
html
.
Button
(
'
Rewind
'
,
id
=
'
send-place-a-rewind
'
,
style
=
button_style_normal
),
html
.
Button
(
'
Start
'
,
id
=
'
send-place-a-start
'
,
style
=
button_style_normal
),
html
.
Button
(
'
Exit
'
,
id
=
'
send-place-a-exit
'
,
style
=
button_style_exit
),
...
...
@@ -209,12 +222,12 @@ app.layout = html.Div([
html
.
Div
([
# Column for commands of place b
html
.
H3
(
"
Commands Place B
"
),
html
.
Button
(
'
Model
'
,
id
=
'
send-place-b-model
'
,
style
=
button_style_normal
),
html
.
Button
(
'
Model (Details)
'
,
id
=
'
send-place-b-model-details
'
,
style
=
button_style_normal
),
html
.
Button
(
'
Model (Details)
'
,
id
=
'
send-place-b-model-details
'
,
style
=
button_style_normal
_invisible
),
html
.
Button
(
'
Rewind
'
,
id
=
'
send-place-b-rewind
'
,
style
=
button_style_normal
),
html
.
Button
(
'
Start
'
,
id
=
'
send-place-b-start
'
,
style
=
button_style_normal
),
html
.
Button
(
'
Exit
'
,
id
=
'
send-place-b-exit
'
,
style
=
button_style_exit
),
# html.Button('obj-Red -> Red', id='send-place-b-demo-objRed-red', style=button_style_normal),
html
.
Button
(
'
initial_scene
'
,
id
=
'
send-place-b-demo-initial_scene
'
,
style
=
button_style_normal
),
html
.
Button
(
'
initial_scene
'
,
id
=
'
send-place-b-demo-initial_scene
'
,
style
=
button_style_normal
_invisible
),
# html.Button('arm1-moving', id='send-place-b-demo-arm1-moving', style=button_style_normal),
# html.Button('arm1-idle', id='send-place-b-demo-arm1-idle', style=button_style_normal),
# html.Button('arm2-moving', id='send-place-b-demo-arm2-moving', style=button_style_normal),
...
...
@@ -229,14 +242,14 @@ app.layout = html.Div([
{
'
label
'
:
'
Moving
'
,
'
value
'
:
'
moving
'
}]
,
'
moving
'
,
id
=
'
send-arm-state-state
'
,
inline
=
True
,
style
=
{
"
marginRight
"
:
"
10px
"
,
"
marginTop
"
:
"
5px
"
}),
html
.
Button
(
'
Send
'
,
id
=
'
send-arm-state
'
,
style
=
button_style_normal
)
],
className
=
'
row
'
,
style
=
{
"
display
"
:
"
flex
"
,
"
border
"
:
"
1px black solid
"
,
"
border-radius
"
:
"
5px
"
,
"
marginTop
"
:
"
5px
"
}
),
],
className
=
'
row
'
,
style
=
buttons_style
,
id
=
'
arm-buttons
'
),
html
.
Div
([
dcc
.
RadioItems
([
'
blue1
'
,
'
blue2
'
,
'
green1
'
,
'
green2
'
],
'
blue1
'
,
id
=
'
send-obj-pos-obj
'
,
inline
=
True
,
style
=
{
"
marginRight
"
:
"
10px
"
,
"
marginTop
"
:
"
5px
"
}),
dcc
.
RadioItems
([
'
cz1
'
,
'
G1
'
,
'
G2
'
,
'
B1
'
,
'
B2
'
],
'
cz1
'
,
id
=
'
send-obj-pos-pos
'
,
inline
=
True
,
style
=
{
"
marginRight
"
:
"
10px
"
,
"
marginTop
"
:
"
5px
"
}),
html
.
Button
(
'
Send
'
,
id
=
'
send-obj-pos
'
,
style
=
button_style_normal
)
],
className
=
'
row
'
,
style
=
{
"
display
"
:
"
flex
"
,
"
border
"
:
"
1px black solid
"
,
"
border-radius
"
:
"
5px
"
,
"
marginTop
"
:
"
5px
"
}
)
],
className
=
'
row
'
,
style
=
buttons_style
,
id
=
'
object-buttons
'
)
],
className
=
"
four columns
"
),
],
className
=
'
row
'
),
# dcc.Markdown("---"),
...
...
@@ -266,6 +279,12 @@ app.layout = html.Div([
value
=
[
"
Auto-Scroll
"
],
labelStyle
=
{
"
display
"
:
"
inline-block
"
},
),
dcc
.
Checklist
(
id
=
"
expert-view
"
,
options
=
[{
"
label
"
:
"
Expert View
"
,
"
value
"
:
"
expert-view
"
}],
value
=
[],
labelStyle
=
{
"
display
"
:
"
inline-block
"
},
),
dcc
.
Checklist
(
id
=
"
mqtt-connected
"
,
options
=
[{
"
label
"
:
"
MQTT connected?
"
,
"
value
"
:
"
yes
"
,
"
disabled
"
:
True
}],
...
...
@@ -343,40 +362,24 @@ def send_json_for_object_to_topic(json_content: str, obj, topic: str):
mqttc
.
publish
(
topic
=
topic
,
payload
=
obj
.
SerializeToString
())
# @app.callback(
# Output('hidden-div-scene-a', 'children'),
# Input('send-place-a-update', 'n_clicks'),
# State('place-a-input-json', 'value')
# )
# def send_scene_a(n_clicks, json_content):
# """
# Send scene in place a
# :param n_clicks: button.clicks
# :param json_content: state of place-a-input-json
# :return: no_update
# """
# if n_clicks:
# scene = cgv_connector_pb2.Scene()
# send_json_for_object_to_topic(json_content, scene, 'place-a/scene/update')
# return dash.no_update
#
#
# @app.callback(
# Output('hidden-div-scene-b', 'children'),
# Input('send-place-b-update', 'n_clicks'),
# State('place-b-input-json', 'value')
# )
# def send_scene_a(n_clicks, json_content):
# """
# Send scene in place b
# :param n_clicks: button.clicks
# :param json_content:state of place-b-input-json
# :return:no_update
# """
# if n_clicks:
# scene = cgv_connector_pb2.Scene()
# send_json_for_object_to_topic(json_content, scene, 'place-b/scene/update')
# return dash.no_update
@app.callback
(
[
Output
(
button_id
,
'
style
'
)
for
button_id
in
expert_view_buttons
],
Output
(
'
coordinator-div
'
,
'
style
'
),
Output
(
'
arm-buttons
'
,
'
style
'
),
Output
(
'
object-buttons
'
,
'
style
'
),
Input
(
'
expert-view
'
,
'
value
'
)
)
def
toggle_expert_view
(
visibility_state
):
local_buttons_style
=
dict
(
buttons_style
)
local_buttons_style
[
'
display
'
]
=
'
flex
'
if
visibility_state
else
'
none
'
result
=
[
button_style_normal
if
visibility_state
else
button_style_normal_invisible
for
_
in
expert_view_buttons
]
result
.
append
({
'
display
'
:
'
block
'
if
visibility_state
else
'
none
'
})
result
.
append
(
local_buttons_style
)
result
.
append
(
local_buttons_style
)
print
(
result
)
return
result
@app.callback
(
Output
(
'
hidden-div-scene-b
'
,
'
children
'
),
[
Input
(
button_id
,
'
n_clicks
'
)
for
button_id
in
complex_commands
],
...
...
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