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

作者: 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
相关推荐
云卓科技4 小时前
无人机之控制距离篇
科技·安全·机器人·无人机·制造
云卓科技4 小时前
无人机之飞行高度篇
科技·安全·机器人·无人机·制造
Java追光着20 小时前
扣子智能体实战-汽车客服对话机器人(核心知识:知识库和卡片)
人工智能·机器人·汽车·智能体
夜幕龙21 小时前
robomimic基础教程(三)——自带算法
人工智能·python·算法·机器人
v_JULY_v1 天前
ReKep——李飞飞团队提出的新一代机器人操作方法:基于视觉语言模型和关键点约束
机器人·具身智能·视觉语言大模型·rekep·关键点约束
Java追光着2 天前
基于扣子(Coze)打造第一个智能体——个性化对话机器人
人工智能·机器人·扣子
shuxianshrng2 天前
鹰眼降尘模型
大数据·服务器·人工智能·经验分享·机器人
范范08252 天前
基于NLP的对话系统开发:从零构建智能客服机器人
人工智能·自然语言处理·机器人
网易足已3 天前
机器人的静力分析与动力学
机器人
Karen_bluu3 天前
ROS2 Humble如何初步使用Livox-mid-360激光雷达 (viewer/rviz)以及解决一些问题
ubuntu·机器人