This post is written for ubuntu 18.04, ros-melodic
If your ubuntu version is 16.04, ros-version is kinetic
or your ubuntu version is 20.04, ros-version is noetic
https://velog.io/@korkhg15/Install-Opencv-3.4.0-on-Ubuntu-18.04
sudo apt install curl -y
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo apt update
sudo apt install -y ros-melodic-desktop-full
sudo apt install -y ros-melodic-rviz* ros-melodic-rqt*
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
or
echo "source /opt/ros/melodic/setup.bash" >> ~/.zshrc
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
sudo rosdep init
rosdep update
Optional settings from here, not necessary
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace
cd ~/catkin_ws && catkin_make
If you met error on catkin_make, see my ubuntu error series or find in google, or ask to my e-mail
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
or
echo "source ~/catkin_ws/devel/setup.zsh" >> ~?.zshrc
echo "export ROS_MASTER_URI=http://localhost:11311" >> ~/.bashrc
echo "export ROS_HOSTNAME=localhost" >> ~/.bashrc
or
echo "export ROS_MASTER_URI=http://localhost:11311" >> ~/.zshrc
echo "export ROS_HOSTNAME=localhost" >> ~/.zshrc
gedit ~/.bash_aliases
alias cm='catkin_make'
alias cw='cd ~/catkin_ws'
alias cs='cd ~/catkin_ws/src'
save the file and leave
source ~/.bashrc
or
source ~/.zshrc