By chance, I came into contact with an open source project ROS. It is easy to build a 3D development environment according to the operation of Yijun. It is very interesting and I would like to share with you.

What is ROS

ROS (Robot Operating System, hereinafter referred to as “ROS”) is a highly flexible software architecture for writing Robot software programs. It is an open source meta-operating System. The ROS prototype comes from STanford Artificial Intelligence Robot (STAIR) and Personal Robotics (PR) projects at STanford University.

It provides the services that an operating system should provide, including hardware abstraction, low-level device control, implementation of common functions, interprocess messaging, and package management. It also provides the tools and library functions needed to get, compile, write, and run code across computers.

ROS designers describe ROS as “ROS = Plumbing + Tools + Capabilities + Ecosystem”, that is, ROS is a collection of communication mechanisms, tool packages, high-level skills of robots, and robot ecosystems.

1. The ROS installation

ROS Kinetic only supports Debian packages for Wily (Ubuntu 15.10), Xenial (Ubuntu 16.04) and Jessie (Debian 8).

Ubuntu 16.04 installation, please refer to the article “Linux Environment Setup – Ubuntu 16.04 Installation”.

1.1 Configuring the Ubuntu Repository

Configure your Ubuntu Repository to allow access to the restricted, Universe and Multiverse repositories. You can follow the Ubuntu Software Repository guide to do this.

1.2 set the sources. The list

Set up your computer to install the software from Packages.ros.org.

Open the terminal and enter the following command:

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
Copy the code

If the download speed is slow, you are advised to replace the preceding command with the nearest image source. For example, Tsinghua University is:

sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
Copy the code

If you continue to experience connection problems, try switching to Ubuntu Apt (a non-ROS site).

1.3 Setting a Key

sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
Copy the code

If unable to connect to the key server, can try to replace the above command the hkp://keyserver.ubuntu.com: 80 to hkp://pgp.mit.edu: 80.

You can also use curl to replace apt-key with curl, which is useful if you are using a proxy server:

curl -sSL 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC1CF6E31E6BADE8868B172B4F42ED6FBAB17C654' | sudo apt-key add -
Copy the code

1.4 installation

First, make sure your Debian package index is up to date:

sudo apt-get update
Copy the code

In ROS, there are many different libraries and tools. We provide the default configuration to get started. You can also install ROS packages separately.

If problems occur with the following steps, the following repositories can be used instead of the ros-shadow-fixed ones mentioned above

Desktop Full Edition: (recommended) : includes ROS, RQT, RVIZ, robot Universal library, 2D/3D simulator, navigation, and 2D/3D perception

sudo apt-get install ros-kinetic-desktop-full
Copy the code

The actual operation may be wrong, just try a few times.

1.5 Initializing Rosdep

You also need to initialize Rosdep before you can start using ROS. Rosdep makes it easy to install system dependencies on source code when you need to compile it, and is a necessary tool for some of the core ROS functional components.

sudo rosdep init
Copy the code

However, initialization often fails. Solution:

sudo su
sudo gedit /etc/hosts
Copy the code

Add the following content to hosts, save it, and continue rosdep update when you are done

199.232.28.133 raw.githubusercontent.com
151.101.228.133 raw.github.com
Copy the code

In this implementationsudo rosdep init

1.6 update rosdep

This step is optional. To update rosdep, run the following command:

rosdep update
Copy the code

But because the server is unstable, it usually takes a few more tries,

Or download the corresponding update file uav_ros.tar and copy it to Ubuntu.Then copy it to /etc/ros/rosdep/

cd ~/ros
sudo cp * /etc/ros/rosdep/
Copy the code

2. Compile

1. Download and decompress hw_1

tar zxvf hw_1.tar
Copy the code

2. Create a workspace

Ctrl+ Alt + T, open the terminal, copy and run the following commands one by one

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
Copy the code

Then copy the three hw_1/ SRC folders to /catkin_ws/ SRC:

cp ~/hw_1/src/*  ~/catkin_ws/src -r
cd ~/catkin_ws/src
Copy the code

Continue executing the command on the terminal:

catkin_init_workspace
cd ~/catkin_ws/
catkin_make
Copy the code

Success!

Declare environment variables:

source devel/setup.bash
Copy the code

3. Open the rviz

Run commands on the terminal

roscore
Copy the code

CTRL + Shift + T to open a new terminal page, execute the following command

rviz
Copy the code

The RVIZ initial page is displayed

The final interface is as follows:

4. Open the RVIz configuration file

Place the mouse in the upper left and click Open Config.

The configuration file path is:

~/catkin_ws/src/grid_path_searcher/launch/rviz_config/demo.rviz
Copy the code

Click Open to enter the following dialog:

After clicking Save, the following screen will be displayed. At this time, since the program has not been run, the map has not been initialized and the 3D map of point cloud cannot be seen.

5. Run the program and load the map

CTRL + Shift + T to open a new terminal page, execute the following command

cd ~/catkin_ws
source devel/setup.bash
roslaunch grid_path_searcher demo.launch
Copy the code

Cut to Rivz and you can see that the program automatically loads the point cloud map

Success!

The installation packages uav_ros.tar and hw_1.tar mentioned in the article can be obtained by clicking on the public account of Linux and replying to ros from the background.