从零开始搭建自己的ROS机器人(turtlebot3)一、安装ROS环境.
可以安装脚本一键安装,之后直接跳至第5步
make_turtlebot3.sh下载链接.
1.安装环境
pip3 install catkin_pkg empy rospkg
sudo apt -y install libsdl1.2-dev libsdl-image1.2-dev qt4-default libusb-dev libspnav-dev libbluetooth-dev libcwiid-dev
2.创建ROS工作空间
创建文件夹并编译
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws && catkin_make
mkdir -p ~/turtlebot3_ws/src
cd ~/turtlebot3_ws && catkin_make
添加ROS_PACKAGE_PATH环境变量
echo -e "\nsource ~/catkin_ws/devel/setup.bash\nsource ~/turtlebot3_ws/devel/setup.bash" >> ~/.bashrc
echo -e "\nexport TURTLEBOT3_MODEL=waffle\nexport TURTLEBOT3_3D_SENSOR=kinetic\nexport TURTLEBOT3_LASER_SENSOR=rplidar" >> ~/.bashrc
source ~/.bashrc
3.创建catkin软件包
将 turtlebot3 文件放入src
- 方法1:git 克隆
cd ~/catkin_ws/src
git clone -b melodic-devel https://github.com/ros-drivers/rosserial.git
git clone -b melodic-devel https://github.com/ros-planning/navigation.git
git clone -b ros1 https://github.com/ros-planning/navigation_msgs.git
git clone -b melodic-devel https://github.com/ros/geometry2.git
git clone -b melodic-devel https://github.com/hrnr/m-explore.git
git clone -b melodic-devel https://github.com/tu-darmstadt-ros-pkg/hector_slam.git
git clone -b melodic-devel https://github.com/ros-perception/slam_gmapping.git
git clone -b melodic-devel https://github.com/ros-perception/openslam_gmapping.git
git clone -b melodic-devel https://github.com/ROBOTIS-GIT/hls_lfcd_lds_driver.git
git clone -b melodic-devel https://github.com/ros-drivers/joystick_drivers.git
git clone https://github.com/Slamtec/rplidar_ros.git
cd ~/catkin_ws && catkin_make
cd ~/turtlebot3_ws/src
git clone -b melodic-devel https://github.com/ROBOTIS-GIT/turtlebot3.git
git clone -b melodic-devel https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
cd ~/turtlebot3_ws && catkin_make
4.创建一个工作空间以管理其他的工作空间
mkdir -p ~/my_ws/src
cd ~/my_ws && catkin_make
sed -i "s@'.split(';')@;/home/$USER/catkin_ws/devel;/home/$USER/turtlebot3_ws/devel'.split(';')@" ~/my_ws/devel/_setup_util.py
catkin_make
echo -e "\nsource ~/my_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
5.映射USB,编写udev规则
cd /etc/udev/rules.d/
sudo vi opencr.rules
sudo vi rplidar.rules
sudo service udev reload
sudo service udev restart
opencr.rules:
KERNEL=="ttyACM*", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5740", MODE:="0777", SYMLINK+="opencr"
rplidar.rules:
KERNEL=="ttyUSB*", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", MODE:="0777", SYMLINK+="rplidar"