Contents
- Update
- Environment
- Installing Qt Creator
- Configuring Qt Creator for
rosbuild
- Configuring Qt Creator for
catkin_make
- References:
Update
Please note that there is now a Qt Creator plugin for ROS development ROS Qt Creator Plug-in wiki. Please use this plugin instead, rather than using the method in the following sections.
Note that the debugger may be not permitted to attached to your ROS nodes. In such cases, try revising the /etc/sysctl.d/10-ptrace.conf
file by changing
kernel.yama.ptrace_scope = 1
to
kernel.yama.ptrace_scope = 0
Reference: stack overflow
updated at 2017-05-11
Environment
Ubuntu 14.04, ROS Indigo (Newer versions should be okay). Qt Creator is an open source IDE for C++ project development, which not only supports its native C/C++ project management, but also provides CMake project building and debugging by just openning the main CMakeLists file.
Installing Qt Creator
In terminal:
sudo apt-get install qtcreator
To launch Qt Creator, in terminal:
qtcreator
Note: Qt Creator should be launched in the terminal, rather than clicking the software icon. That’s because terminal will source .bashrc, which contains environmental setup of ROS. Also, according to the ROS Wiki, you can use the following desktop file qtcreator.desktop
and use it in your launcher (remember to use chmod
to make executable):
[Desktop Entry]
Exec=bash -i -c qtcreator %F
Icon=qtcreator
Type=Application
Terminal=false
Name=Qt Creator
GenericName=Integrated Development Environment
MimeType=text/x-c++src;text/x-c++hdr;text/x-xsrc;application/x-designer;application/vnd.nokia.qt.qmakeprofile;application/vnd.nokia.xml.qt.resource;
Categories=Qt;Development;IDE;
InitialPreference=9
Configuring Qt Creator for rosbuild
rosbuild
is an old-fashioned building system of ROS. Yet, there are still some packages built with it, for example ORB-SLAM. We use ORB-SLAM as an example.
Preparation:
-
Clone the source code files from ORB-SLAM’s main page.
-
Append ORB-SLAM directory to the
ROS_PACKAGE_PATH
, according to the instructions in the main page. -
Build the Thirdparty libraries according to the instructions in the main page.
To open the package:
-
Launch Qt Creator through terminal.
-
Type
Ctrl + O
and selectCMakeLists.txt
in the root folder of ORB-SLAM to open. -
Qt Creator will automatically parse the source files of the package. You can use the keyboard shortcuts to navigate through the code implementation (like F2 to go to a class declaration).
To build the package:
-
In the project configuration, set the build directory and assign CMake argument as
.. -DROS_BUILD_TYPE=Release
(or.. -DROS_BUILD_TYPE=Debug
if you want to debug the program), as figure below. -
Right click on the project directory, and
Run CMake
, as Figure below. -
Click
Build
either in right-click menu or on the hammer icon in the left-bottom corner. The action ofBuild
is equivalent to commandmake
in terminal.
Configuring Qt Creator for catkin_make
catkin_make
is a new and more recommended built-in tool for ROS project management. As we know, individual packages files are put in the /src
directory of a workspace directory. The key step in using Qt Creator to configure catkin workspace is to open the CMakeLists.txt
file in the /src
root directory. Here the tricky thing is, the initialized workspace contains a symlink of CMakeLists.txt
which links to a file in the installed directory of ROS. In order to avoid driving QtCreator mad, we must replace the symlink’ed CMakeLists.txt in catkin_ws/src
with a physical copy of the actual stuff:
cd ~/catkin_ws/src
ls -l # Take note of the actual symlink target
sed -i '' CMakeLists.txt
ls -l # The symlink should have gone away
After openning the CMakeLists file, configure the build dir to be catkin_ws/build/
, right click on the project directory and run CMake (like in rosbuild
part), and you can see all your source files being parsed and listed in the project management panel. In the building settings, declare the CMake arguments as
-DCMAKE_INSTALL_PREFIX=../install -DCATKIN_DEVEL_PREFIX=../devel
And now we are ready to go. Happy coding.