加入本机订阅话题的隔离机制,修改话题名字避免被内网透传消息引发冲突
This commit is contained in:
@@ -10,6 +10,11 @@ LOG_FILE="${WS_DIR}/log/linker_hand_control.log"
|
||||
CAN_INTERFACES=(can0 can1)
|
||||
CAN_BITRATE=1000000
|
||||
|
||||
# Keep this driver isolated from ROS 2 nodes on other machines in the same LAN.
|
||||
# Without this, DDS discovery can pick up stale linker_hand_sdk nodes from the
|
||||
# subnet and make the same topic appear to have multiple publishers.
|
||||
export ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 {start|stop|status}"
|
||||
}
|
||||
@@ -45,6 +50,11 @@ source_workspace() {
|
||||
set -u
|
||||
}
|
||||
|
||||
restart_ros_daemon_localhost() {
|
||||
ros2 daemon stop >/dev/null 2>&1 || true
|
||||
ros2 daemon start >/dev/null 2>&1 || true
|
||||
}
|
||||
|
||||
start_can() {
|
||||
for can_if in "${CAN_INTERFACES[@]}"; do
|
||||
if ! ip link show "${can_if}" >/dev/null 2>&1; then
|
||||
@@ -77,13 +87,14 @@ start_driver() {
|
||||
fi
|
||||
|
||||
source_workspace
|
||||
restart_ros_daemon_localhost
|
||||
start_can
|
||||
|
||||
echo "Starting linker_hand service..."
|
||||
echo "Log: ${LOG_FILE}"
|
||||
|
||||
: > "${LOG_FILE}"
|
||||
setsid bash -lc "set +u; source '${WS_DIR}/install/setup.bash'; set -u; exec ros2 launch linker_hand_ros2_sdk linker_hand_double.launch.py" \
|
||||
setsid bash -lc "export ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST; set +u; source '${WS_DIR}/install/setup.bash'; set -u; exec ros2 launch linker_hand_ros2_sdk linker_hand_double.launch.py" \
|
||||
>> "${LOG_FILE}" 2>&1 &
|
||||
|
||||
local pid=$!
|
||||
@@ -151,6 +162,8 @@ status_driver() {
|
||||
echo "linker_hand service is not running"
|
||||
fi
|
||||
|
||||
echo "ROS_AUTOMATIC_DISCOVERY_RANGE=${ROS_AUTOMATIC_DISCOVERY_RANGE}"
|
||||
|
||||
for can_if in "${CAN_INTERFACES[@]}"; do
|
||||
if ip link show "${can_if}" >/dev/null 2>&1; then
|
||||
ip -details link show "${can_if}" | sed -n '1,2p'
|
||||
|
||||
Reference in New Issue
Block a user