fix: update robot IP address in configuration and improve process termination handling in run script

This commit is contained in:
Даниил Грабарь
2026-05-21 07:56:11 +03:00
parent fd576dc27a
commit bdb5fb2418
2 changed files with 15 additions and 4 deletions
+1 -1
View File
@@ -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
View File
@@ -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",
] ]