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
eb810f7c
Commit
eb810f7c
authored
4 years ago
by
René Schöne
Browse files
Options
Downloads
Patches
Plain Diff
more log formatting
parent
5882c973
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
main.py
+14
-20
14 additions, 20 deletions
main.py
utils.py
+26
-3
26 additions, 3 deletions
utils.py
with
40 additions
and
23 deletions
main.py
+
14
−
20
View file @
eb810f7c
...
@@ -59,26 +59,15 @@ complex_commands = {
...
@@ -59,26 +59,15 @@ complex_commands = {
(
'
place-b/reachability/arm2
'
,
'
place-b-reachability-2-json
'
,
cgv_connector_pb2
.
Reachability
()),
(
'
place-b/reachability/arm2
'
,
'
place-b-reachability-2-json
'
,
cgv_connector_pb2
.
Reachability
()),
}
}
def
format_scene
(
scene
:
cgv_connector_pb2
.
Scene
):
result
=
""
for
obj
in
scene
.
objects
:
if
obj
.
type
==
cgv_connector_pb2
.
Object
.
Type
.
BOX
:
pos
=
obj
.
pos
result
+=
f
"
\n
<obj
{
obj
.
id
:
15
}
at (
{
pos
.
x
:
6.2
}
{
pos
.
y
:
6.2
}
{
pos
.
z
:
6.2
}
)>
"
return
result
conversion_topics
=
{
conversion_topics
=
{
'
place-a/scene/update
'
:
(
cgv_connector_pb2
.
Scene
(),
format_scene
),
'
place-a/scene/update
'
:
(
cgv_connector_pb2
.
Scene
(),
utils
.
format_scene
),
'
place-b/scene/update
'
:
(
cgv_connector_pb2
.
Scene
(),
format_scene
),
'
place-b/scene/update
'
:
(
cgv_connector_pb2
.
Scene
(),
utils
.
format_scene
),
'
place-b/command
'
:
(
cgv_connector_pb2
.
MergedSelection
(),
utils
.
format_command
),
'
place-b/reachability/arm1
'
:
(
cgv_connector_pb2
.
Reachability
(),
utils
.
format_reachability
),
'
place-b/reachability/arm2
'
:
(
cgv_connector_pb2
.
Reachability
(),
utils
.
format_reachability
),
}
}
bytes_topics
=
[
bytes_topics
=
[
'
place-a/scene/update
'
,
'
place-b/scene/update
'
,
'
place-b/reachability/arm1
'
,
'
place-b/reachability/arm2
'
,
'
place-b/command
'
,
]
]
button_style_normal
=
{
"
marginRight
"
:
"
15px
"
}
button_style_normal
=
{
"
marginRight
"
:
"
15px
"
}
...
@@ -292,10 +281,15 @@ def append_to_mqtt_log(_n_intervals, clear_n_clicks, value, should_scroll):
...
@@ -292,10 +281,15 @@ def append_to_mqtt_log(_n_intervals, clear_n_clicks, value, should_scroll):
:param should_scroll: checkbox value whether to scroll to the end after update
:param should_scroll: checkbox value whether to scroll to the end after update
:return: new content of mqtt log
:return: new content of mqtt log
"""
"""
global
last_clear_n_clicks
ctx
=
dash
.
callback_context
if
clear_n_clicks
and
clear_n_clicks
>
last_clear_n_clicks
:
if
not
ctx
.
triggered
:
value
=
""
return
dash
.
no_update
last_clear_n_clicks
=
clear_n_clicks
trigger_id
=
ctx
.
triggered
[
0
][
'
prop_id
'
].
split
(
'
.
'
)[
0
]
if
trigger_id
==
'
clear-mqtt-log
'
:
return
""
,
""
# assume trigger_id == 'every-1-second'
local_messages
=
[]
local_messages
=
[]
while
not
message_queue
.
empty
():
while
not
message_queue
.
empty
():
local_messages
.
append
(
message_queue
.
get_nowait
())
local_messages
.
append
(
message_queue
.
get_nowait
())
...
...
This diff is collapsed.
Click to expand it.
utils.py
+
26
−
3
View file @
eb810f7c
import
threading
import
threading
from
datetime
import
datetime
from
datetime
import
datetime
from
google.protobuf
import
json_format
import
cgv_connector_pb2
class
MaxTopicLength
:
class
MaxTopicLength
:
...
@@ -10,7 +12,7 @@ class MaxTopicLength:
...
@@ -10,7 +12,7 @@ class MaxTopicLength:
def
process_topic
(
self
,
topic
):
def
process_topic
(
self
,
topic
):
if
len
(
topic
)
>
self
.
max_mqtt_topic_length
:
if
len
(
topic
)
>
self
.
max_mqtt_topic_length
:
self
.
max_mqtt_topic_length
=
len
(
topic
)
self
.
max_mqtt_topic_length
=
len
(
topic
)
print
(
f
'
new long topic length:
{
self
.
max_mqtt_topic_length
}
'
)
print
(
f
"
new long topic length:
{
self
.
max_mqtt_topic_length
}
"
)
self
.
mqtt_log_reformat_event
.
set
()
self
.
mqtt_log_reformat_event
.
set
()
return
self
.
max_mqtt_topic_length
return
self
.
max_mqtt_topic_length
...
@@ -30,5 +32,26 @@ def format_log_msg(topic: str, max_mqtt_topic_length: int, message: str, timesta
...
@@ -30,5 +32,26 @@ def format_log_msg(topic: str, max_mqtt_topic_length: int, message: str, timesta
def
parse_log_msg
(
entry
:
str
):
def
parse_log_msg
(
entry
:
str
):
print
(
"
Parsing >
"
,
entry
,
"
<
"
)
print
(
"
Parsing >
"
,
entry
,
"
<
"
)
at_index
=
entry
.
index
(
'
@
'
)
at_index
=
entry
.
index
(
'
@
'
)
closing_bracket_index
=
entry
.
index
(
'
]
'
)
bracket_index
=
entry
.
index
(
'
]
'
)
return
entry
[
1
:
at_index
].
strip
(),
entry
[
at_index
+
1
:
closing_bracket_index
].
strip
(),
entry
[
closing_bracket_index
+
2
:]
return
entry
[
1
:
at_index
].
strip
(),
entry
[
at_index
+
1
:
bracket_index
].
strip
(),
entry
[
bracket_index
+
2
:]
def
format_scene
(
scene
:
cgv_connector_pb2
.
Scene
):
result
=
""
for
obj
in
scene
.
objects
:
if
obj
.
type
==
cgv_connector_pb2
.
Object
.
Type
.
BOX
:
pos
=
obj
.
pos
result
+=
f
"
\n
<obj
{
obj
.
id
:
15
}
at (
{
pos
.
x
:
6.2
}
{
pos
.
y
:
6.2
}
{
pos
.
z
:
6.2
}
)>
"
return
result
def
format_command
(
command
:
cgv_connector_pb2
.
MergedSelection
):
return
f
"
<cmd by
{
command
.
idRobot
}
of
{
command
.
idPick
}
to
{
command
.
idPlace
}
"
def
_get_reach_objects
(
r
):
return
[
objReach
.
idObject
+
'
'
+
(
'
✔
'
if
objReach
.
reachable
else
'
✖
'
)
for
objReach
in
r
.
objects
]
def
format_reachability
(
r
:
cgv_connector_pb2
.
Reachability
):
return
f
"
<reach of
{
r
.
idRobot
}
: [
{
'
,
'
.
join
(
_get_reach_objects
(
r
))
}
]>
"
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