Table of contents
1. Build a Ros environment under the virtual machine Ubuntu18.04
1. About the ROS robot operating system
2. ROS installation and configuration
3. Run the sample program of the little turtle
2. Rviz completes the video capture of the camera (camera)
3. USB camera operation and calibration
1. Calibration environment configuration
2. Calibration program running
1. Build a Ros environment under the virtual machine Ubuntu18.04
1. About the ROS robot operating system
· concept
ROS is the abbreviation of Robot Operating System , commonly known as "Robot Operating System". But it is not a real operating system, but an open source meta-operating system for robots, which provides many functions similar to traditional operating systems: hardware abstraction, underlying device control, common function implementation, inter-process Messaging, package management, and more. And provide related tools and libraries for obtaining, compiling, editing code, and running programs among multiple computers to complete distributed computing.
· Advantages of ROS
- Distributed computing: peer-to-peer, solving inter-process communication problems
- Software reuse: algorithms, communication interfaces, avoiding repeated wheel creation
- Quick Test: Tools, Modularity, Data Recording and Playback
- Free and open source: The development of ROS software adopts the open BSD protocol from beginning to end, and the open source community
2. ROS installation and configuration
- Add software source
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
- add key
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
Successfully added software sources and keys
- Install Ros-melodic desktop full version
Update system software sources
sudo apt-get update
install ros
sudo apt-get install ros-melodic-desktop-full
Successful installation
- Initialize rostep
sudo rosdep init
rosdep update
If the command cannot be found as shown below
After executing the following command, repeat the above initialization work
sudo apt-get install python-rosdep
rosdep init initialization encounters the following error, which can be solved by the following operations
#Open the hosts file
sudo gedit /etc/hosts
#Add
151.101.84.133 raw.githubusercontent.com at the end of the file
#Or 151.101.76.133 raw.githubusercontent.com
#Save and exit and try again
- set environment variables
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
- install rosinstall
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
Successfully installed rosinstall
- View information about ros installation
By command roscore, run ros, you can view ros related information
3. Run the sample program of the little turtle
Open a new terminal window and enter the following command to run the sample program of the little turtle
rosrun turtlesim turtlesim_node
At this point, you can see a small turtle window appearing
Then open a terminal window and enter the following command to control the movement of the little turtle
rosrun turtlesim turtle_teleop_key
Keep the above window, and then you can control the movement of the little turtle through the arrow keys, the running effect is as shown in the figure below
At this point, the installation and configuration of the ROS environment is over.
2. Rviz completes the video capture of the camera (camera)
1. Configure the camera
- The configuration of USB compatibility here should be 3.1.
- Connect host camera
Click the camera icon in the lower right corner of the desktop to connect to the PC host camera
- Check the use and screen of the camera through the cheese command
2. Download related packages
- Download the UVC Camera library package corresponding to ros
sudo apt-get install ros-melodic-uvc-camera
The uvc Camera library is successfully installed
- The terminal runs the camera node
First, a terminal roscore runs ros, and then opens a new terminal and enters the following command to run the camera node
rosrun uvc_camera uvc_camera_node
- View Newsletter Topics
Open another terminal and type rostopic list to view message topics
- Print camera information
Print camera information via rostopic echo /camera_info
- Open Rviz to configure the camera
Type the command rviz to open the RVIz interface
- Configure RVIZ
Add Image window
So far, the download of relevant packages and the configuration of Rviz have been completed.
3. USB camera operation and calibration
1. Calibration environment configuration
- Install the usb_cam device driver node function package
sudo apt-get install ros-melodic-usb-cam
- Install the camera calibration function package camera_calibration
sudo apt-get install ros-melodic-camera-calibration
2. Calibration program running
- The calibration target is as follows, which can be replaced by downloading, printing or flat-bed photos
First, a terminal window roscore starts ros
Then open another window to turn on the camera
roslaunch usb_cam usb_cam-test.launch
- Start the calibration procedure
rosrun camera_calibration cameracalibrator.py --size 8x6 --square 0.02 image:=/usb_cam/image_raw camera:=/usb_cam
Parameter meaning:
1) size: Calibrate the number of internal corners of the checkerboard. The chessboard used here has a total of 6 rows, and each row has 8 internal corners.
2) square: This parameter corresponds to the side length of each checkerboard, in meters
3) image and camera: set the topic of the image released by the camera
At this point, align the prepared calibration target image with the camera until the CALIBRATE button changes color, which means that the parameters of the calibration program have been collected. At this time, click the CALIBRATE button again, and the calibration program will automatically calculate the calibration parameters of the camera. This process needs to wait for a while .
Start Calibration Acquisition
Calibration collection completed
Calibration completed
Click SAVE to save the calibration parameters
Four. Summary
Above we have completed the construction and configuration of the ROS robot operating system, as well as the video acquisition and calibration of the Rviz camera. This is just the real-time positioning and construction of the SLAM operating environment. The process is quite interesting. If you want to further run the open source project of SLAM , It is also necessary to install the corresponding library source code, such as VINS_Fusion and ORB-SLAM, etc., and the follow-up authors will further try to run the corresponding open source projects.
References
Install ROS on Ubuntu20.04 system