ROS常用命令及多机(TX2 与虚拟机)通信步骤

目录

ROS常用命令

常用命令

ROS多机通信步骤

虚拟机中添加镜像源

TX2中添加镜像源

ROS常用命令

rostopic list 命令查看当前系统中有哪些 topic。

rostopic info 命令查看该 topic 的信息,包括它的数据类型、发布者数量等。

rostopic hz 命令查看该 topic 的发布频率。

rosnode list 命令查看当前系统中有哪些节点。

rosnode info 命令查看该节点的信息,包括它的 PID、运行状态等。

rqt_graph 命令查看当前系统中节点之间的连接关系。

rostopic+echo+/chatter:查看话题chatter消息。

rosrun+功能包名+节点名:运行ROS节点。

创建工作空间

mkdir -p ~/catkin_ws/src

cd ~/catkin_ws/src

catkin_init_workspace

编译工作空间

cd ~/catkin_ws

catkin_make

source devel/setup.bash 设置环境变量

创建功能包

cd ~/catkin_ws/src

catkin_create_pkg learning_topic std_msgs rospy roscpp geometry_msgs

编译功能包

cd ~/catkin_ws

catkin_make

source devel/setup.bash

或 采用

echo "source /home/sps/sps/catkin_sps_ws/devel/setup.bash">>~/.bashrc

检查环境变量

echo $ROS_PACKAGE_PATH

Ubuntu常用命令

hostname:查看本机名称。

ifconfig:查看网络ip。

ssh远程登陆: ssh 用户名@IP地址

文件权限:sudo chmod 777 file。

df -h:查看磁盘空间。

ROS多机通信步骤

需求:TX2 发布话题,虚拟机订阅话题,采用ROS分布式方式。设备:TX2 ubuntu18.04.6、虚拟机ubuntu18.04.6。

1、配置网络

a、将虚拟机网络设置为桥接模式,其他模式均不可。

虚拟机设置-->网络适配器-->桥接模式 虚拟机菜单栏:编辑-->虚拟网络编辑器-->添加网络-->选择桥接模式-->选择对应的网卡(例如Inter(R) Ethernet Connection(23) I219-V)即可。

b、设置网络名称

查看本机与从机的hostname与ip,其命令分别为:hostname、ifconfig。

修改虚拟机hosts文件:sudo vim /etc/hosts,虚拟机中添加TX2的ip和hostname,如ip+ hostname,10.46.10.60 ubuntu,TX2中添加虚拟机的hostname和ip,如ip + hostname,10.46.10.61 virtual-machine。

c、修改bash

修改bash命令:sudo vim ~/.bashrc,添加:export ROS_MASTER_URI=http://tx2:11311,source生效:source ~/.bashrc。

d、互ping虚拟机与tx2

在虚拟机中: ping tx2 ;在TX2中:ping virtual-machine,如果能ping通,则表明网络正常。

e、tx2中启动master

在tx2中启动master:roscore,在虚拟机中查看话题:rostopic list,若能看到话题列表说明配置成功。

虚拟机中添加镜像源

运行命令:sudo vim /etc/apt/sources.list

bash 复制代码
# deb cdrom:[Ubuntu 18.04.6 LTS _Bionic Beaver_ - Release amd64 (20210915)]/ bionic main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic universe
# deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates universe
# deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.

TX2中添加镜像源

运行命令:sudo vim /etc/apt/sources.list

bash 复制代码
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
#deb http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted universe multiverse
# deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu bionic partner
# deb-src http://archive.canonical.com/ubuntu bionic partner

#deb http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted
# deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted
#deb http://ports.ubuntu.com/ubuntu-ports/ bionic-security universe
# deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-security universe
#deb http://ports.ubuntu.com/ubuntu-ports/ bionic-security multiverse
# deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-security multiverse

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe
相关推荐
地平线开发者21 小时前
征程 6 | 征程 6 工具链如何支持 Matmul/Conv 双 int16 输入量化?
算法·自动驾驶
万俟淋曦1 天前
【论文速递】2025年第28周(Jul-06-12)(Robotics/Embodied AI/LLM)
人工智能·ai·机器人·大模型·论文·robotics·具身智能
视觉语言导航1 天前
CoRL-2025 | SocialNav-SUB:用于社交机器人导航场景理解的视觉语言模型基准测试
人工智能·机器人·具身智能
万俟淋曦1 天前
【论文速递】2025年第29周(Jul-13-19)(Robotics/Embodied AI/LLM)
人工智能·ai·机器人·论文·robotics·具身智能
地平线开发者1 天前
新版 perf 文件解读与性能分析
算法·自动驾驶
ARM+FPGA+AI工业主板定制专家2 天前
【JETSON+FPGA+GMSL】实测分享 | 如何实现激光雷达与摄像头高精度时间同步?
人工智能·数码相机·机器学习·fpga开发·机器人·自动驾驶
武子康2 天前
AI-调查研究-105-具身智能 机器人学习数据采集:从示范视频到状态-动作对的流程解析
人工智能·深度学习·机器学习·ai·系统架构·机器人·具身智能
ARM+FPGA+AI工业主板定制专家2 天前
Jetson AGX Orin+GMSL+AI视觉开发套件,支持自动驾驶,机器人,工业视觉等应用
人工智能·机器学习·fpga开发·机器人·自动驾驶
天天讯通2 天前
任务型与聊天型语音机器人有什么区别
人工智能·机器人
LeeZhao@2 天前
【具身智能】具身机器人VLA算法入门及实战(四):具身智能VLA技术行业进展
人工智能·算法·机器人