Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Robomaster_pi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Emil Harlan
Robomaster_pi
Commits
dc701378
Commit
dc701378
authored
1 year ago
by
Emil Harlan
Browse files
Options
Downloads
Patches
Plain Diff
a
parent
dfda6187
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
robomaster_pi/launch_node.py
+14
-6
14 additions, 6 deletions
robomaster_pi/launch_node.py
with
14 additions
and
6 deletions
robomaster_pi/launch_node.py
+
14
−
6
View file @
dc701378
...
...
@@ -4,6 +4,7 @@ from std_msgs.msg import String
import
subprocess
import
threading
import
signal
import
asyncio
class
Launch_Node
(
Node
):
def
__init__
(
self
):
...
...
@@ -41,19 +42,26 @@ class Launch_Node(Node):
else
:
self
.
get_logger
().
info
(
f
"
Command executed:
{
command
}
"
)
def
kill_node
(
self
,
name
):
async
def
kill_node
(
self
,
name
):
if
name
in
self
.
running_processes
:
try
:
process_handle
=
self
.
running_processes
[
name
]
process_handle
.
send_signal
(
signal
.
SIGINT
)
process_handle
.
wait
(
timeout
=
30
)
except
subprocess
.
TimeoutExpired
:
process_handle
.
kill
(
)
process_handle
.
wait
()
self
.
get_logger
().
info
(
f
"
Node
'
{
name
}
'
killed.
"
)
await
self
.
wait_process_termination
(
process_handle
)
except
Exception
as
e
:
self
.
get_logger
().
error
(
f
"
Failed to kill node
'
{
name
}
'
:
{
e
}
"
)
else
:
self
.
get_logger
().
info
(
f
"
Node
'
{
name
}
'
killed.
"
)
else
:
self
.
get_logger
().
info
(
f
"
No active node with name
'
{
name
}
'
to kill.
"
)
async
def
wait_process_termination
(
self
,
process_handle
):
try
:
await
asyncio
.
to_thread
(
process_handle
.
wait
)
except
subprocess
.
TimeoutExpired
:
process_handle
.
kill
()
await
asyncio
.
to_thread
(
process_handle
.
wait
)
def
main
(
args
=
None
):
rclpy
.
init
(
args
=
args
)
node
=
Launch_Node
()
...
...
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