机器人多设备局域网可通调试

作者: Herman Ye @Auromix
版本: V1.0
测试环境: Ubuntu20.04
更新日期: 2023/09/13
1 @Auromix 是一个机器人爱好者开源组织。
2 本文在更新日期经过测试,确认有效。

使用情景

同一机器人不同硬件设备通过局域网有线通信,但存在通信异常,通过命令或脚本来查找各设备。

命令行查看当前局域网段下的其他设备

提示: HWaddress 值为incomplete 是不正常的设备

bash 复制代码
arp -n

脚本查看当前局域网段下可Ping通的所有设备

bash 复制代码
#!/bin/bash
#
# Copyright 2023 Herman Ye @Auromix
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Description: This script finds your device in the specified network segment, such as robot arm, lidar.
# Version: 1.0
# Date: 2023-09-13
# Author: Herman Ye @Auromix
#
# set -x


# Prompt the user to enter a network segment
read -p "Please enter a network segment (press Enter for default value 192.168.1): " network

# Set a default value if the user presses Enter
network="${network:-192.168.1}"

echo "Finding devices from $network.1 to $network.254"
# Initialize an array to store reachable devices
reachable_devices=()

# Iterate through all IP addresses in the specified network segment
for ip in ${network}.{1..254}; do
    # Use the ping command to check if the device is reachable
    # -c 1 means send only one ICMP request, -W 1 means wait for 1 second
    if ping -c 1 -W 1 $ip >/dev/null; then
        echo "Device at $ip is reachable"
        # Add reachable devices to the array
        reachable_devices+=("$ip")
    else
        echo "Device at $ip is not reachable"
    fi
done

# Print information about all reachable devices
echo "All reachable devices:"
for device in "${reachable_devices[@]}"; do
    echo "$device"
done
相关推荐
珂朵莉MM2 小时前
2021 RoboCom 世界机器人开发者大赛-高职组(初赛)解题报告 | 珂学家
java·开发语言·人工智能·算法·职场和发展·机器人
遨博学院8 小时前
机器人编程界面
机器人
曹勖之1 天前
在 UE5 蓝图中配置Actor类型的Asset以作为位置和旋转设置目标
ue5·机器人
曹勖之1 天前
UE 5 和simulink联合仿真,如果先在UE5这一端结束Play,过一段时间以后**Unreal Engine 5** 中会出现显存不足错误
matlab·ue5·机器人
曹勖之1 天前
撰写脚本,通过发布/joint_states话题改变机器人在Rviz中的关节角度
开发语言·python·机器人·ros2
奔跑吧邓邓子1 天前
DeepSeek 赋能智能养老:情感陪伴机器人的温暖革新
人工智能·机器人·deepseek·智能养老·情感陪伴
VR最前沿1 天前
全新Xsens Animate版本是迄今为止最大的软件升级,提供更清晰的数据、快捷的工作流程以及从录制开始就更直观的体验
人工智能·科技·机器人·自动化
CHOTEST中图仪器1 天前
激光干涉仪:解锁协作机器人DD马达的精度密码
机器人·激光干涉仪
Tisfy1 天前
LeetCode 2434.使用机器人打印字典序最小的字符串:贪心(栈)——清晰题解
leetcode·机器人·字符串·题解·贪心·
敢敢のwings1 天前
论文速读《DexWild:野外机器人策略的灵巧人机交互》
机器人·人机交互