Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
ros2-scripts
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Elphel
ros2-scripts
Commits
a508f5b2
Commit
a508f5b2
authored
Jan 04, 2019
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed responses format
parent
ace36ad6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
ros2_master.py
src/init/ros2_master.py
+7
-3
ros2_slave.py
src/init/ros2_slave.py
+2
-2
No files found.
src/init/ros2_master.py
View file @
a508f5b2
...
...
@@ -69,6 +69,10 @@ def cmd_callback(req,res):
print
(
"Parsed command:"
)
print
(
q
)
if
q
[
'cmd'
]
==
'list'
:
res
.
response
=
'<?xml version="1.0"?><document>'
+
'
\n
'
.
join
([
'<target>'
+
c
+
'</target>'
for
c
in
q
[
'targets'
]])
+
'</document>'
return
res
if
q
[
'cmd'
]
==
'state'
:
cmd_func
=
pass_cmd
...
...
@@ -88,7 +92,7 @@ def cmd_callback(req,res):
# if n/a
if
not
cli
.
wait_for_service
(
timeout_sec
=
1.0
):
cmdres
=
"<response><node>"
+
t
gt
+
"</node><state>dead</state></response>"
cmdres
=
"<response><node>"
+
t
+
"</node><state>dead</state></response>"
else
:
# timer?!
timer
=
g_node
.
create_timer
(
0.0
,
cmd_func
,
callback_group
=
cb_group
)
...
...
@@ -100,12 +104,12 @@ def cmd_callback(req,res):
# spin until it gets "blue"
while
rclpy
.
ok
()
and
not
did_get_result
:
rclpy
.
spin_once
(
g_node
)
cmdres
=
cmd_result
.
response
cmdres
=
"<response><node>"
+
t
+
"</node>"
+
cmd_result
.
response
+
"</response>"
# store response
reslist
.
append
(
cmdres
)
# convert to string
res
.
response
=
'
\n
'
.
join
(
reslist
)
res
.
response
=
'
<?xml version="1.0"?><document>'
+
'
\n
'
.
join
(
reslist
)
+
'</document>'
return
res
...
...
src/init/ros2_slave.py
View file @
a508f5b2
...
...
@@ -32,7 +32,7 @@ def cmd_callback(req,res):
print
(
q
)
if
q
[
'cmd'
]
==
'state'
:
res
.
response
=
'<
response><node>'
+
nodename
+
'</node><state>idle</state></respons
e>'
res
.
response
=
'<
state>idle</stat
e>'
else
:
# call to localhost here, get response and send it back
try
:
...
...
@@ -40,7 +40,7 @@ def cmd_callback(req,res):
except
subprocess
.
CalledProcessError
:
output
=
"<error>CalledProcessError</error>"
.
encode
()
res
.
response
=
'<
response><node>'
+
nodename
+
'</node><state>'
+
output
.
decode
()
+
'</state></respons
e>'
res
.
response
=
'<
state>'
+
output
.
decode
()
+
'</stat
e>'
print
(
'Slave sending: '
+
res
.
response
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment