说明:
相关设备
前提说明
对于在创客智造上购买的foxy版系统的tb3是已经配置好系统,不需要重复安装配置
若是创客智造上购买的默认是Noetic系统的tb3且想要切换到Foxy环境,则需要进行环境切换
[Remote PC] 若当前需要从Noetic切换到Foxy环境,需要将文档末端的两项环境变量全部注释,保存退出关闭此终端
- $ vim ~/.bashrc
-
- #source ~/tools/environment/noetic/setRosNoeticEnvironment.sh
- #source ~/tools/environment/foxy/setRos2FoxyEnvironment.sh
- $ exit
打开新终端
,将文档末端Foxy的环境变量的注释标志
去掉,再保存退出- $ vim ~/.bashrc
-
- #source ~/tools/environment/noetic/setRosNoeticEnvironment.sh
- source ~/tools/environment/foxy/setRos2FoxyEnvironment.sh
- $ source ~/.bashrc && rosversion -d
- foxy
系统安装
ROS2 Foxy Fitzroy安装
- # 设置编码
- $ locale # check for UTF-8
- $ sudo apt update && sudo apt install locales
- $ sudo locale-gen en_US en_US.UTF-8
- $ sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
- $ export LANG=en_US.UTF-8
- $ locale # verify settings
-
- # 添加key
- $ sudo apt update && sudo apt install curl gnupg2 lsb-release
- $ sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
- # ros2源
- $ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
- # 安装ros2
- $ sudo apt update
- $ sudo apt install ros-foxy-desktop
- # 设置环境
- $ echo "source /opt/ros/foxy/setup.bash" >> ~/.bashrc
- # 新终端,订阅话题
- $ ros2 run demo_nodes_py listener
- [INFO] [1634527167.275393800] [listener]: I heard: [Hello World: 1]
- [INFO] [1634527168.204285069] [listener]: I heard: [Hello World: 2]
- [INFO] [1634527169.204316087] [listener]: I heard: [Hello World: 3]
-
- # 新终端,发布话题
- $ ros2 run demo_nodes_cpp talker
- [INFO] [1634527098.551044682] [talker]: Publishing: 'Hello World: 1'
- [INFO] [1634527099.550897311] [talker]: Publishing: 'Hello World: 2'
- [INFO] [1634527100.550894548] [talker]: Publishing: 'Hello World: 3'
安装TurtleBot3及相关依赖包
- $ sudo apt install -y python3-argcomplete python3-colcon-common-extensions python3-vcstool git
- $ sudo apt-get install ros-foxy-gazebo-* ros-foxy-cartographer ros-foxy-cartographer-ros \
- ros-foxy-nav2-bringup ros-foxy-navigation2 ros-foxy-slam-toolbox
- $ mkdir -p ~/turtlebot3_ws2/src
- $ cd ~/turtlebot3_ws2/src/
- $ git clone -b foxy-devel https://github.com/ROBOTIS-GIT/DynamixelSDK.git
- $ git clone -b foxy-devel https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
- $ git clone -b foxy-devel https://github.com/ROBOTIS-GIT/turtlebot3.git
- $ git clone -b foxy-devel https://github.com/ROBOTIS-GIT/hls_lfcd_lds_driver.git
- $ cd ~/turtlebot3_ws2
- $ colcon build --symlink-install
- $ echo 'source ~/turtlebot3_ws2/install/setup.bash' >> ~/.bashrc
- $ source ~/.bashrc
- $ echo 'export ROS_DOMAIN_ID=30 #TURTLEBOT3' >> ~/.bashrc
- $ source ~/.bashrc