ROS版本號判斷、ubuntu20.04安裝ROS_noetic-修改鏡像源


判斷ROS版本號-ROS安裝-修改鏡像源 linux版本:ubuntu20.04 ROS版本:noetic

    • 判斷ROS版本號
    • 安裝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。

安裝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基本上配置好了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM