ROS版本号判断、ubuntu20.04安装ROS_noetic-修改镜像源
2022-01-12 00:49 jym蒟蒻 阅读(1645) 评论(0) 编辑 收藏 举报判断ROS版本号-ROS安装-修改镜像源 linux版本:ubuntu20.04 ROS版本:noetic
- 判断ROS版本号
- 安装ROS
- 改镜像源
机器人用的是树莓派、stm32、ros。
首先要配置网络,把机器人上的sd卡插到树莓派开发板上,然后配置连接的热点。
接下来,把sd卡插回机器人上的树莓派,开启热点,机器人将自动连接到热点。
使用MobaXterm_Personal软件,创建ssh连接。
首先开启一个终端,里面输入roscore:
┌──────────────────────────────────────────────────────────────────────┐
│ • MobaXterm Personal Edition v21.3 • │
│ (SSH client, X server and network tools) │
│ │
│ ➤ SSH session to lemon@192.168.137.189 │
│ • Direct SSH : ✔ │
│ • SSH compression : ✔ │
│ • SSH-browser : ✔ │
│ • X11-forwarding : ✔ (remote display is forwarded through SSH) │
│ │
│ ➤ For more info, ctrl+click on help or visit our website. │
└──────────────────────────────────────────────────────────────────────┘
Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-1035-raspi aarch64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Last login: Sun Oct 24 12:03:52 2021 from 192.168.137.1
lemon@lemon:~$ roscore
... logging to /home/lemon/.ros/log/93e79cda-3486-11ec-a274-e94615cd611d/roslaunch-lemon-1399.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://lemon:40829/
ros_comm version 1.15.9
SUMMARY
========
PARAMETERS
* /rosdistro: noetic
* /rosversion: 1.15.9
NODES
auto-starting new master
process[master]: started with pid [1436]
ROS_MASTER_URI=http://lemon:11311/
setting /run_id to 93e79cda-3486-11ec-a274-e94615cd611d
process[rosout-1]: started with pid [1462]
started core service [/rosout]
在开启另一个终端,里面输入rosparam list
再输入rosparam get /rosdistro
┌──────────────────────────────────────────────────────────────────────┐
│ • MobaXterm Personal Edition v21.3 • │
│ (SSH client, X server and network tools) │
│ │
│ ➤ SSH session to lemon@192.168.137.189 │
│ • Direct SSH : ✔ │
│ • SSH compression : ✔ │
│ • SSH-browser : ✔ │
│ • X11-forwarding : ✔ (remote display is forwarded through SSH) │
│ │
│ ➤ For more info, ctrl+click on help or visit our website. │
└──────────────────────────────────────────────────────────────────────┘
Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-1035-raspi aarch64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Last login: Sun Oct 24 12:45:37 2021 from 192.168.137.1
lemon@lemon:~$ rosparam list
/rosdistro
/roslaunch/uris/host_lemon__40829
/rosversion
/run_id
lemon@lemon:~$ rosparam get /rosdistro
'noetic
'
然后就可以发现当前的ros版本是noetic。noetic是ROS1的最后一个长期支持版。
那么接下来,对ros进行研究,就继续在linux-ubuntu20.04版本下配置noetic版本的ros。
在VMware-linux-ubuntu20.04中,打开终端,按以下步骤输入指令。
1.添加ros源
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
2.增加key
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
3.上面如果添加不成功,可以如下增加key
curl -sSL 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC1CF6E31E6BADE8868B172B4F42ED6FBAB17C654' | sudo apt-key add -
4.更新软件
sudo apt update
5.安装ros
sudo apt install ros-noetic-desktop-full
6.把ros环境加载脚本添加到bashrc
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
测试ROS:
开三个终端,分别写roscore、rosrun turtlesim turtlesim_node、rosrun turtlesim turtle_teleop_key
jym@ubuntu:~$ roscore
... logging to /home/jym/.ros/log/5b2a055c-34a1-11ec-b36c-ed0dd69260d5/roslaunch-ubuntu-32694.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://ubuntu:42685/
ros_comm version 1.15.13
SUMMARY
========
PARAMETERS
* /rosdistro: noetic
* /rosversion: 1.15.13
NODES
auto-starting new master
process[master]: started with pid [32705]
ROS_MASTER_URI=http://ubuntu:11311/
setting /run_id to 5b2a055c-34a1-11ec-b36c-ed0dd69260d5
process[rosout-1]: started with pid [32715]
started core service [/rosout]
jym@ubuntu:~$ rosrun turtlesim turtlesim_node
[ INFO] [1635062998.850703821]: Starting turtlesim with node name /turtlesim
[ INFO] [1635062998.852881006]: Spawning turtle [turtle1] at x=[5.544445], y=[5.544445], theta=[0.000000]
jym@ubuntu:~$ rosrun turtlesim turtle_teleop_key
Reading from keyboard
---------------------------
Use arrow keys to move the turtle. 'q' to quit.
可以通过鼠标控制乌龟说明安装成功:
上面安装ros用了三个小时,太久了,所以现在就改一下镜像源。
提前安装好vim。
首先设置进入root权限:
输入sudo passwd root (注意passwd的拼写),再输入用户密码,接下来会让你设置root密码,并再次确认。
接下来输入su,再输入刚刚设置的root密码就可以进入root了。
之后想要退出输入exit即可。
然后设置完之后,开始:
1.备份原始文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
2.编辑镜像源文件
vim /etc/apt/sources.list
在vim里面
删除所有代码 :0,$d
然后粘贴进去:
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
保存并退出代码 :wq!
更新源:
sudo apt-get update
更新软件:
sudo apt-get dist-upgrade
sudo apt-get upgrade
可以看到速度很快。
使用ros的话,通过pip安装一下rospy包
pip install rospkg
pip install catkin-tools
至此,ros基本上配置好了。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义