catalogue
1. Corresponding ubuntu version of ros1:
2.ros2 corresponding ubuntu version:
2. Installation steps of ROS # melody:
(7) after installation, try to run
(8) run the Little Turtle program
(1) setting the language environment
(3) add the source library of ros2 to the source list of the system
(7) configure environment variables
(8) after installation, try to run
(9) run the Little Turtle program
(10) install additional function packs
I have just finished the one week ROS summer training. It should be very difficult to install ROS. However, after your group's encounter and discussion, I have summarized a lot of experience. I am still relatively smooth in installing ROS, so I write a tutorial to record my installation tutorial. I hope it will be helpful to you.
1, Preparatory work
1. Corresponding ubuntu version of ros1:
2.ros2 corresponding ubuntu version:
ROS Foxy Ubuntu20.04
ROS Dashing Ubuntu18.04
ROS Crystal Ubuntu16.04
Here, ROS ^ melody and ROS2 ^ Foxy, which are relatively stable, have a long life cycle and complete functions, are selected for explanation
Ubuntu20.04 download address: https://ubuntu.com/download/desktop/thank-you?version=20.04.2.0&architecture=amd64
Ubuntu18.04 download address: https://releases.ubuntu.com/18.04.5/ubuntu-18.04.5-desktop-amd64.iso
3. Installation of Ubuntu
After downloading the image, you can choose three methods: virtual machine, dual system and u disk startup.
It is suggested that readers who have no experience in installing dual systems should not easily try dual systems, because it may cause irreversible errors to the original win system; If the computer has excellent performance, it is recommended to use Vmare virtual machine for automatic installation. All options are filled in by default. After loading the image, go online and wait for the automatic installation to complete; The best solution is to use the u disk to operate the startup disk, because on the one hand, even if the system is damaged due to misoperation, it will not lead to unnecessary errors in the computer's own system, on the other hand, it can fully call the computer performance, which is convenient to call the more performance software such as gazebo simulation software in the later stage.
2, Installation of ROS1
Compared with ros2, the installation process of ros1 is more complicated, especially the last step of ROS update. Due to network problems, most people do not know how to solve this error when they first contact ROS. This paper will give an answer.
1. Instructions for official installation of ROS: http://wiki.ros.org/Installation/Ubuntu?distro=melodic
2. Installation steps of ROS # melody:
(1) install ros source
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
(2) set key
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
Note: without this step, a bunch of errors will pop up when sudo apt get update is executed. This is a GPG error, indicating that the following signatures cannot be verified. We need to obtain the public key in the system and obtain the key number from the information.
The public key will pop up at the end of the error. If the above key fails, you can replace it by yourself.
(3) update
sudo apt-get update
(4) installation
sudo apt-get install ros-melodic-desktop-full #This is the installation of the ros body sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential #This is to install some commonly used function packs
The full version of the desktop is directly installed here, and contains ros, rqt, rviz, robot generic libraries, 2D / 3D simulators, navigation and 2D / 3D perception and rosinstall. These commonly used ros tools, of course, catkin the function package downloaded on github_ If an error is reported during make compilation and there is no library, you can install it according to the prompt and compile it.
(5) ROSdep initialization
According to the official tutorial, you can directly execute the following code
sudo rosdep init rosdep update
However, due to network reasons, most small partners will report an error when executing sudo # rosdep # init and cannot access the link, because rosdepc uses domestic sources, and rosdep initialization fails because it uses github and cannot be accessed in China.
This problem can be solved by replacing the domestic image rosdepc made by Xiaoyu dalao.
sudo apt-get install python3-pip #Installing pip3 sudo pip install rosdepc #Install rosdepc sudo rosdepc init #rosdep initialization rosdepc update #Update ros source
The depc library is responsible for dalao, and here is also welcome to WeChat's official account: fish flavor ROS
(6) environment configuration
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc source ~/.bashrc
(7) after installation, try to run
Executing on the terminal: roscore
If the following information appears, the installation is successful
... logging to /home/pi/.ros/log/96bf3f3c-fca3-11eb-ad36-000c29aa8d4a/roslaunch-ubuntu-2076.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:43097/ ros_comm version 1.14.11 SUMMARY ======== PARAMETERS * /rosdistro: melodic * /rosversion: 1.14.11 NODES auto-starting new master process[master]: started with pid [2087] ROS_MASTER_URI=http://ubuntu:11311/ setting /run_id to 96bf3f3c-fca3-11eb-ad36-000c29aa8d4a process[rosout-1]: started with pid [2098] started core service [/rosout]
(8) run the Little Turtle program
Open the two terminals and input the following commands respectively
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key
You can open the operation interface of the little turtle
Running rosrun turnlesim turnle_ teleop_ The movement of the little turtle can be controlled by using the up, down, left and right keys on the key terminal, as shown in the figure
It should be noted that after the function package downloaded on github is compiled, if the roslaunch cannot be started, it needs to be executed once in the project folder
source devel/setup.bash
You can use roslaunch to start the corresponding function package.
At this point, the installation process of ROS # melody is over.
2, Installation of ROS2
1. Installation of ROS} Foxy
(1) setting the language environment
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 #This step is to transpose the default character encoding of ubuntu system into utf-8 format
(2) add the key of ros2
sudo apt update && sudo apt install curl gnupg2 lsb-release curl http://repo.ros2.org/repos.key | sudo apt-key add -
(3) add the source library of ros2 to the source list of the system
sudo sh -c 'echo "deb [arch=amd64,arm64] http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
(4) update list
sudo apt update
(5) install the body of ros2
sudo apt install ros-foxy-desktop
(6) install argcomplete
sudo apt install python3-argcomplete
(7) configure environment variables
echo "source /opt/ros/dashing/setup.bash" >> ~/.bashrc
(8) after installation, try to run
Here, take talker and listener, two typical examples of Ross 2 communication based on dds, as examples. After discovering each other based on the discover mechanism, they establish topic and transmit message
Execute first
ros2 run demo_nodes_cpp talker
The implementation effect is as follows
Re execution
ros2 run demo_nodes_cpp listener
As shown in the figure, the two nodes have been connected based on the discover mechanism
(9) run the Little Turtle program
Similarly, we can also run the Little Turtle program in ros2
Execute in two terminals respectively
ros2 run turtlesim turtlesim_node
ros2 run turtlesim turtle_teleop_key
(10) install additional function packs
sudo apt update sudo apt install ros-foxy-rmw-opensplice-cpp sudo apt install ros-foxy-rmw-connext-cpp
At this point, both ros1 and ros2 are installed and ready for use.
For the first time, I hope you can give me more advice.