QT Creator__ros of ROS development environment

Source: Internet
Author: User
Tags git clone

Http://my.phirobot.com/blog/2013-12-ros_ide_qtcreator.html

Qtcreator Installation

Qtcreator installation Way Many, this article takes the QT 5.2.0 as an example, I download the offline installation program to install directly. Download Installation

Download Qtcreator installer from http://qt-project.org/downloads. For Ubuntu 32-bit systems, click on the QT 5.2.0 for Linux 32-bit (425 MB) to download the offline installer (QT online Installer for Linux 32-bit (MB) as an on-line installer, not recommended), The file name after download is qt-linux-opensource-5.2.0-x86-offline.run.

Double-click the. Run installation file direct graphical interface installation, default installation under/home/<user>/qt5.2.0 (<user> for your username, here for Viki).

Follow the instructions along the way to complete the installation.

When the installation is complete, click the Dash home in the upper left corner and type "QT" If you see the QT Creator icon, the installation is successful. Set Shortcuts

In this step, you will modify the QT creator shortcuts so that the ROS environment variables are loaded while the QT creator is started from the shortcut.

Open terminal, and enter the following command:

Gedit ~/.local/share/applications/digiaqtopensource-qtcreator.desktop

This command opens the Digiaqtopensource-qtcreator.desktop shortcut file, and you can see the contents of the file as follows:

[Desktop Entry]
Type=application
exec=/home/viki/qt5.2.0/tools/qtcreator/bin/qtcreator
name=qt Creator (Opensource)
Genericname=the IDE of choice for Qt development.
Icon=qtproject-qtcreator
terminal=false
categories=development;ide; Qt;
Mimetype=text/x-c++src;text/x-c++hdr;text/x-xsrc;application/x-designer;application/vnd.qt.qmakeprofile; Application/vnd.qt.xml.resource;text/x-qml;text/x-qt.qml;text/x-qt.qbs;

Modify the Exec variable row, add Bash-i-C in the middle and change to Exec=bash-i-c/home/viki/qt5.2.0/tools/qtcreator/bin/qtcreator, save and exit. Bash-i-C is added to load the ROS environment variable (ROS environment variable load script is configured in the ~/.BASHRC file) while activating the Qt creator via shortcut.

Warning

If the open file is empty, the Digiaqtopensource-qtcreator.desktop file is not found, either the installation path is not in the local user directory, or the file name that is different from the version causes inconsistencies. Can be looked for with the LS *qt* command under the ~/.local/share/applications/and/usr/share/applications/two paths.

Tip

If you do not have the above shortcut file, create a new one, as long as the file content similar to the above class capacity, the path is correct. Shortcuts can be placed in ~/.local/share/applications/and/usr/share/applications/two locations. Of course, it can be placed in any other location, the function is the same as the above two places, but the taskbar on the left does not display the icon correctly. Debugging C + + Engineering with QT creator

Can build their own bags to do experiments, for the sake of simplicity, here directly from the GitHub download the existing source code package, that is familiar with the Ros_tutorials package. new Catkin work space

If you already have your own Catkin workspace, skip it, or create a new Catkin workspace:

Mkdir-p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace
cd ~/catkin_ws/
echo "Source ~/catkin_ws/devel/setup.bash" >> ~/.BASHRC

The corresponding interpretation refers to the configuration of Ros working space Catkin+rosbuild. Turn off all terminal and reopen the environment variable to take effect. Add a source package to the Catkin workspace

Add the Ros_tutorials source package here.

CD ~/catkin_ws/src
git clone git@github.com:ros/ros_tutorials.git-b hydro-devel
ls

You can see the following message that Ros_tutorials has been downloaded to the ~/CATKIN_WS/SRC directory.

viki@ros:~/catkin_ws/src$ ls
CMakeLists.txt  ros_tutorials
Add engineering to QT creator

Starting QT Creator from the Dash home, you will see the following welcome interface:

Here we import the Roscpp_tutorials package to make it the QT creator C + + project. Click the Open Project button to select the CMakeLists.txt in the ~/catkin_ws/src/ros_tutorials/roscpp_tutorials/path in the dialog box that pops up File, as shown below:

When you click Open, the Compile Path selection dialog box appears. Note here that you need Browse to modify the path to the ~/catkin_ws/build/path, as shown in the following figure:

After clicking Next, fill in the-dcmake_build_type=debug in the Arguments of the dialog box that appears (you will not be able to debug without filling it), and then click Run CMake to start compiling, as shown in the following figure:

If there is no error message, click Finish, you can see the project structure in the edit interface, you can start editing the project. Debugging

First open a terminal, and enter the Roscore command to start Ros Master.

In the QT Creator Edit Interface Engineering directory, locate the Talker.cpp file and open it. Then find the location of "Hello World", modify it to "Hello I ' m yuanboshe" and set breakpoints, as shown below:

After saving, select the Talker executable item from the engineering panel in the lower-left corner and press F5 to run debugging. For a moment, Qt creator will take a little time to compile all the programs, and when the compilation is complete, it will stop at the breakpoint:

To cancel the breakpoint, press F5 to continue running, the application Output interface will be able to see the modified information, as follows:

Back to the desktop, and then open a terminal window, enter the Rosrun roscpp_tutorials Listener command, you can see the correct listening message, the following figure: about the debug problem

If the-dcmake_build_type=debug parameter is not filled in before the CMake, the compiled program is not available for debugging. When you press the Debug shortcut key F5 , you may receive the following warning message:

This does isn't seem to is a "Debug" build.
Setting breakpoints by the file name and line number may fail.

Section. Debug_info:not found.
Section. Debug_abbrev:not found.
Section. Debug_line:not found.
Section. Debug_str:not found.
Section. Debug_loc:not found.
Section. Debug_range:not found.
Section. Gdb_index:not found.
Section. Note.gnu.build-id:found.
Section. Gnu.hash:Found.
Section. Gnu_debuglink:not found.

You can reset the parameters by using the "Projects"-> "Run CMake" on the left, and make, as shown below:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.