Merge branch 'dev' of gitverse.ru:daniel-robotics/lightweight-cobot into dev
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
robot:
|
robot:
|
||||||
name: "iiwa7"
|
name: "iiwa7"
|
||||||
ip: "192.170.10.10"
|
ip: "192.170.10.2"
|
||||||
port: 30200
|
port: 30200
|
||||||
command_mode: "position" # torque, position
|
command_mode: "position" # torque, position
|
||||||
fri_cycle_ms: 10 # период FRI-цикла: 5 мс (200 Гц) или 10 мс (100 Гц)
|
fri_cycle_ms: 10 # период FRI-цикла: 5 мс (200 Гц) или 10 мс (100 Гц)
|
||||||
|
|||||||
+14
-3
@@ -4,6 +4,7 @@ import argparse
|
|||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
import shutil
|
import shutil
|
||||||
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Callable, List, Optional
|
from typing import Callable, List, Optional
|
||||||
@@ -195,9 +196,18 @@ def _task_run_local(screen: RunScreen, mode: str) -> None:
|
|||||||
start_new_session=True,
|
start_new_session=True,
|
||||||
)
|
)
|
||||||
screen.set_proc(proc)
|
screen.set_proc(proc)
|
||||||
# Kill the entire process group so all child processes (nodes) are terminated together.
|
# Kill the entire session so all ROS2 nodes are terminated together.
|
||||||
# Убиваем всю группу процессов, чтобы все дочерние процессы (узлы) завершились вместе.
|
# ros2 launch puts each node in its own process group (setpgrp), so killpg on the
|
||||||
screen.set_kill_fn(lambda: os.killpg(os.getpgid(proc.pid), signal.SIGTERM))
|
# bash pgid only reaches bash/launch itself. All nodes share the session started
|
||||||
|
# with start_new_session=True, so pkill -s reaches every one of them.
|
||||||
|
# Убиваем всю сессию, чтобы все ROS2-узлы завершились вместе.
|
||||||
|
# ros2 launch помещает каждый узел в отдельную группу процессов (setpgrp), поэтому
|
||||||
|
# killpg по pgid bash достигает только bash/launch. Все узлы разделяют сессию,
|
||||||
|
# созданную через start_new_session=True, поэтому pkill -s достигает каждого из них.
|
||||||
|
sid = os.getsid(proc.pid)
|
||||||
|
screen.set_kill_fn(lambda: subprocess.run(
|
||||||
|
["pkill", "-TERM", "-s", str(sid)], capture_output=True
|
||||||
|
))
|
||||||
|
|
||||||
for line in proc.stdout:
|
for line in proc.stdout:
|
||||||
s = line.rstrip()
|
s = line.rstrip()
|
||||||
@@ -230,6 +240,7 @@ def _task_run_docker(screen: RunScreen, image: str, mode: str, gpu: str) -> None
|
|||||||
"docker", "run", "--rm",
|
"docker", "run", "--rm",
|
||||||
"--name", container,
|
"--name", container,
|
||||||
"--network", "host",
|
"--network", "host",
|
||||||
|
"--hostname", socket.gethostname(),
|
||||||
"-e", "USER=root",
|
"-e", "USER=root",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user