Installation of ROS Melodic on version 18.04 of ubuntu system (perfect pit avoidance)
foreword
Recently, ROS Melodic needs to be used for course experiments. There are many such blogs on the Internet. After searching and comparing a large number of blogs, this blog is summarized. I believe that 99% of the students can succeed at the first time.
1. Work preparation before installation
Change the software source in the software and update to domestic, such as Tsinghua
Tsinghua:
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
Set the latest key:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654
2. Installation process
Next to install
sudo apt-get update
sudo apt-get install ros-melodic-desktop-full
sudo apt-get install ros-melodic-rqt*
Initialize rosdep, most people follow other blogs and start to have various problems here, all kinds of metaphysics come here, and talk about the network, here is a perfect way to avoid pitfalls. The
terminal program executes the following three commands in sequence:
sudo apt-get install python3-pip
sudo pip3 install 6-rosdep
sudo 6-rosdep
Three commands to solve rosdep update time out
Next
sudo rosdep init
rosdep update
absolute success
Now install rosinstall
sudo apt-get install python-rosinstall
3. Configuration changes
Load environment settings file
source /opt/ros/melodic/setup.bash
Create and initialize a working directory
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace
cd ~/catkin_ws/
catkin_make
Set environment variables:
sudo apt install net-tools
gedit ~/.bashrc
Add the following content to the end of the file, save and exit
# Set ROS melodic
source /opt/ros/melodic/setup.bash
source ~/catkin_ws/devel/setup.bash
# Set ROS Network
#ifconfig查看你的电脑ip地址
export ROS_HOSTNAME=(添自己的ip)
export ROS_MASTER_URI=http://${ROS_HOSTNAME}:11311
# Set ROS alias command 快捷指令
alias cw='cd ~/catkin_ws'
alias cs='cd ~/catkin_ws/src'
alias cm='cd ~/catkin_ws && catkin_make'
View ip (the third line starts with 10.61.249.218)
ifconfig
4. Little Turtle Test
Open three terminals:
roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key
You're done!
5. References
https://blog.csdn.net/qq_41450811/article/details/99079041#commentBox