wheeltec轮趣ROS教育机器人(树莓派4B版)的网络连接

一、术语解析

宿主机:宿主机是指物理主机,比如用于开发测试的笔记本电脑和台式机电脑。

虚拟机:虚拟机是指安装在宿主机的VMware,推荐在宿主机上安装虚拟机,官方提供虚拟机的镜像以及配套的开发环境

ROS主机:是指ROS小车上的主机;

二、相关介绍

0. ROS教育机器人-树莓派4B版(麦克纳姆轮)

在这里插入图片描述

在这里插入图片描述

1. 虚拟机信息

配置项配置信息
主机名ubuntu
账户名wheeltec_client
登录密码dongguan
静态IP192.168.0.136
Ubuntu版本18.04.6 LTS

在这里插入图片描述

2. ROS主机信息

硬件配置信息

配置项配置信息
主控名称树莓派
CPU型号四核Cortex-A72@1.8GHz
系统架构aarch64
内存4GB
内存卡32G(MicroSD卡)

软件配置信息

配置项配置信息
主机名wheeltec
账户名wheeltec
密码dongguan
静态IP192.168.0.100
WiFi名称WHEELTEC_RASPBERRY_NOETIC
WiFi密码dongguan
WIFI协议Wi-Fi 4 (802.11n)
网络频带2.4 GHz
OS版本Ubuntu 20.04.4 LTS
ROS版本Melodic

设备资源占用情况

# 安装htop工具
sudo apt-get install htop

# 查看设备资源信息
htop

在这里插入图片描述

CPU信息

wheeltec@wheeltec:~$ lscpu
Architecture:                    aarch64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
CPU(s):                          4
On-line CPU(s) list:             0-3
Thread(s) per core:              1
Core(s) per socket:              4
Socket(s):                       1
Vendor ID:                       ARM
Model:                           3
Model name:                      Cortex-A72
Stepping:                        r0p3
CPU max MHz:                     1800.0000
CPU min MHz:                     600.0000
BogoMIPS:                        108.00
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Mmio stale data:   Not affected
Vulnerability Spec store bypass: Vulnerable
Vulnerability Spectre v1:        Mitigation; __user pointer sanitization
Vulnerability Spectre v2:        Vulnerable
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected
Flags:                           fp asimd evtstrm crc32 cpuid
wheeltec@wheeltec:~$ cat /proc/cpuinfo
processor	: 0
BogoMIPS	: 108.00
Features	: fp asimd evtstrm crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd08
CPU revision	: 3

processor	: 1
BogoMIPS	: 108.00
Features	: fp asimd evtstrm crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd08
CPU revision	: 3

processor	: 2
BogoMIPS	: 108.00
Features	: fp asimd evtstrm crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd08
CPU revision	: 3

processor	: 3
BogoMIPS	: 108.00
Features	: fp asimd evtstrm crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd08
CPU revision	: 3

Hardware	: BCM2835
Revision	: c03115
Serial		: 10000000c4e51e14
Model		: Raspberry Pi 4 Model B Rev 1.5

CPU性能测试

# 下载
sudo apt-get update
sudo apt-get install sysbench

# 使用4个线程,计算 0 到 20000 中最大的素数
sysbench --test=cpu --cpu-max-prime=20000 --threads=4 run 
wheeltec@wheeltec:~$ sysbench --test=cpu --cpu-max-prime=20000 --threads=4 run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.18 (using system LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 4
Initializing random number generator from current time


Prime numbers limit: 20000

Initializing worker threads...

Threads started!

CPU speed:
    events per second:  2318.67

General statistics:
    total time:                          10.0011s
    total number of events:              23196

Latency (ms):
         min:                                    1.41
         avg:                                    1.72
         max:                                   27.13
         95th percentile:                        2.71
         sum:                                39975.27

Threads fairness:
    events (avg/stddev):           5799.0000/75.26
    execution time (avg/stddev):   9.9938/0.00

内存信息

内存资源信息

wheeltec@wheeltec:~$ free -h
              total        used        free      shared  buff/cache   available
Mem:          3.7Gi       465Mi       550Mi       4.0Mi       2.7Gi       3.1Gi
Swap:            0B          0B          0B

内存性能测试

# 下载
wget https://pyropus.ca./software/memtester/old-versions/memtester-4.6.0.tar.gz --no-check-certificate

# 解压
tar -xvzf memtester-4.6.0.tar.gz

# 编译
cd memtester-4.6.0
make

# 对1G内存测试1次
time ./memtester 1G 1

输出结果

Loop 1/1:
  Stuck Address       : ok         
  Random Value        : ok
  Compare XOR         : ok
  Compare SUB         : ok
  Compare MUL         : ok
  Compare DIV         : ok
  Compare OR          : ok
  Compare AND         : ok
  Sequential Increment: ok
  Solid Bits          : ok         
  Block Sequential    : ok         
  Checkerboard        : ok         
  Bit Spread          : ok         
  Bit Flip            : ok         
  Walking Ones        : ok         
  Walking Zeroes      : ok         
  8-bit Writes        : ok
  16-bit Writes       : ok

Done.

real	1m28.064s
user	1m12.617s
sys	0m14.530s

microSD卡信息

wheeltec@wheeltec:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1.9G     0  1.9G   0% /dev
tmpfs           380M  4.4M  375M   2% /run
/dev/mmcblk0p2   29G   21G  7.6G  73% /
tmpfs           1.9G     0  1.9G   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/loop2       62M   62M     0 100% /snap/lxd/22761
/dev/loop0       60M   60M     0 100% /snap/core20/1627
/dev/loop1       60M   60M     0 100% /snap/core20/1977
/dev/loop4       47M   47M     0 100% /snap/snapd/19459
/dev/loop3       92M   92M     0 100% /snap/lxd/24065
/dev/mmcblk0p1  253M  129M  124M  52% /boot/firmware
tmpfs           380M  8.0K  380M   1% /run/user/1001
tmpfs           380M   32K  380M   1% /run/user/128

microSD卡读取速度

wheeltec@wheeltec:~$ sudo hdparm -t /dev/mmcblk0p2
[sudo] password for wheeltec:

/dev/mmcblk0p2:
 HDIO_DRIVE_CMD(identify) failed: Invalid argument
 Timing buffered disk reads: 144 MB in  3.03 seconds =  47.56 MB/sec

系统信息

wheeltec@wheeltec:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.4 LTS
Release:        20.04
Codename:       focal

三、常用操作

1. 宿主机ssh连接ROS小车

1.1 连接WiFi

在宿主机上连接ROS小车自带的WiFi。

在这里插入图片描述

连接成功后,查看WiFi信息:

在这里插入图片描述

1.2 ping测试网络

ROS小车的静态IP是:192.168.0.100,在宿主机上ping ROS小车的iP是否连通。

在这里插入图片描述

能ping通,说明宿主机与ROS小车的网络连通。

1.3 ssh登录

IP192.168.0.100
用户名wheeltec
密码dongguan
ssh wheeltec@192.168.0.100

在这里插入图片描述

2. 虚拟机与ROS小车通信

ROS小车发出WiFi,虚拟机连接该WiFi,即可实现虚拟机与ROS小车的通信。

默认情况下,ROS小车的静态IP为 192.168.0.100。只有当虚拟机与ROS小车在同一个网络才能进行通信,因此需要设置虚拟机为静态IP。关于设置虚拟机的静态IP的方法,请参见下文【 设置虚拟机的静态IP】。

ip
ROS小车192.168.0.100
虚拟机192.168.0.136
宿主机192.168.0.190

3. 设置虚拟机的静态IP

默认情况下,虚拟机使用的是动态分配的IP地址,使用的过程中可能会出现IP地址不停变化的情况,因此设置静态IP地址可以为后续减少很多麻烦。

3.1 设置网络适配器

关闭虚拟机,设置网络适配器,将网络连接设置为“桥接模式”。

在这里插入图片描述

3.2 设置虚拟网络

设置虚拟网络,将网络连接模式为“桥接模式”。

在这里插入图片描述

特别注意,如果使用windows系统在连通网线的同时又使用无线网卡(WiFi),可能会出现网络配置修改之后虚拟机的网络无法使用的情况,因此官方建议只使用无线网卡。

3.3 设置静态IP

新配置一个“有线配置”。为了区分其他有线配置,需要自定义“新配置名称”

新配置名称Static IP
地址192.168.0.136
子网掩码225.225.225.0
网关192.168.0.1

在这里插入图片描述

配置完成后,查看配置信息。

在这里插入图片描述

3.4 ping ROS小车

在虚拟机上ping ROS小车的ip。

在这里插入图片描述

4. ROS小车连接外部网络

最简单的方式就是,通过一根RJ45网线连接ROS小车和路由器,即ROS小车可连接外部网络,无需额外操作。

在这里插入图片描述

四、FAQ

1. ping ROS小车不通

wheeltec-client@ubuntu:~$ ping 192.168.0.100
PING 192.168.0.100 (192.168.0.100) 56(84) bytes of data.
From 192.168.0.136 icmp_seq=1 Destination Host Unreachable
From 192.168.0.136 icmp_seq=2 Destination Host Unreachable
From 192.168.0.136 icmp_seq=3 Destination Host Unreachable
From 192.168.0.136 icmp_seq=4 Destination Host Unreachable
From 192.168.0.136 icmp_seq=5 Destination Host Unreachable
# 错误原因
虚拟机与ROS小车不在同一个网段,导致无法通信

# 解决办法
参考上文的【设置虚拟机的静态IP】

2. 虚拟机ssh连接ROS小车失败

wheeltec-client@ubuntu:~$ ssh wheeltec@192.168.0.100
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:U0UQNK4E3/QW4/AT4Zt3SaBUqz1f/dkQA3edjdmg2x4.
Please contact your system administrator.
Add correct host key in /home/wheeltec-client/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/wheeltec-client/.ssh/known_hosts:1
  remove with:
  ssh-keygen -f "/home/wheeltec-client/.ssh/known_hosts" -R "192.168.0.100"
ECDSA host key for 192.168.0.100 has changed and you have requested strict checking.
Host key verification failed.
# 解决办法
ssh-keygen -f "/home/wheeltec-client/.ssh/known_hosts" -R "192.168.0.100"

输出结果

wheeltec-client@ubuntu:~$ ssh-keygen -f "/home/wheeltec-client/.ssh/known_hosts" -R "192.168.0.100"
# Host 192.168.0.100 found: line 1
/home/wheeltec-client/.ssh/known_hosts updated.
Original contents retained as /home/wheeltec-client/.ssh/known_hosts.old
wheeltec-client@ubuntu:~$ ssh wheeltec@192.168.0.100
The authenticity of host '192.168.0.100 (192.168.0.100)' can't be established.
ECDSA key fingerprint is SHA256:U0UQNK4E3/QW4/AT4Zt3SaBUqz1f/dkQA3edjdmg2x4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.100' (ECDSA) to the list of known hosts.
wheeltec@192.168.0.100's password: 
Welcome to Ubuntu 20.04.4 LTS (GNU/Linux 5.4.0-1069-raspi aarch64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Sun Jul 16 09:37:46 UTC 2023

  System load:  2.85               Processes:                265
  Usage of /:   70.0% of 28.94GB   Users logged in:          1
  Memory usage: 14%                IPv4 address for docker0: 172.17.0.1
  Swap usage:   0%                 IPv4 address for wlan0:   192.168.0.100
  Temperature:  39.4 C


673 updates can be applied immediately.
299 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable

New release '22.04.2 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Last login: Sun Jul 16 08:53:50 2023 from 192.168.0.190
  • 9
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

花花少年

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值