Ide: Difference between revisions

From Control Systems Technology Group
Jump to navigation Jump to search
(Created page with '= Qt Creator = == Installation == '''Don't use the software center or apt-get to install Qt, then all this will not work properly. Just follow the steps below.''' # Download Q…')
 
(No difference)

Latest revision as of 14:53, 11 April 2014

Qt Creator

Installation

Don't use the software center or apt-get to install Qt, then all this will not work properly. Just follow the steps below.

  1. Download Qt Creator for Linux:
  2. Open a terminal, cd to the folder where you downloaded the file (probably ~/Downloads)
  3. Make the file executable:
    chmod +x <INSTALL_FILE>
  4. Run the installation:
    ./<INSTALL_FILE>
  5. Make sure Qt Creator launches with the ROS environment available:
    1. Open the launcher properties (right-click Applications -> Edit Menus -> Programming -> Qt Creator -> Properties
    2. In the 'Command' field, add bash -i -c in front of the existing command.

Now you can correctly launch Qt Creator from the menu.

Use with ROS

Creating a ROS package

To create a ROS package, follow the usual steps, i.e., use the roscreate-pkg command and add the package to the SVN.

Open an existing ROS package

  1. Make sure your package is in the ROS_PACKAGE_PATH, you can check this by navigating to your package using:
 roscd <your_package_name>
  1. Start Qt Creator
  2. File -> Open File or Project
  3. Navigate to and open the CMakeLists.txt file of your package
  4. Change the build directory into <YOUR_PACKAGE_DIR>/build (that is: a / instead of a -). Click 'Next'.
  5. Click 'Run CMake'. This will automatically look for and include dependencies in the manifest.xml file, see which .cpp files you use, etc, based on your CMakeLists.txt.
  6. Click 'Finish'

Now you are ready to start developing your code. Pressing Ctrl-b will build the active project. If you change the manifest.xml or CMakeLists.txt file, you only have to run CMake again (Build -> Run CMake). After compiling your package, Qt will show the warnings and errors in a much more user friendly way then your terminal!

Show header files in the 'Projects View'

Qt Creator only shows your .cpp files in the 'Project View', which can be a bit of a nuisance. Often you would also like to see header files (.h) if you have them. To also show your header files, perform the following trick:

  1. Open CMakeLists.txt
  2. Add the following line before rosbuild_add_executable:
    file(GLOB_RECURSE HEADER_FILES include/*.h)
    This looks for all .h files in the include folder of your package, and stores them in the variable HEADER_FILES.
  3. Add ${HEADER_FILES} to your rosbuid_add_executable list. For example:
    rosbuild_add_executable(my_program src/program.cpp ${HEADER_FILES})
  4. Within Qt Creator, run CMake (Build -> Run CMake)

You should now be able to see all .h files in the include folder of your package.

Troubleshoot

CMake Error

If you try to open your project in Qt Creator and you get the following message when running CMake:

CMake Error: The current CMakeCache.txt directory <YOUR_PACKAGE>/build/CMakeCache.txt is different
than the directory <OTHER_DIR>/build where CMakeCache.txt was created. This may result in binaries
being created in the wrong place. If you are not sure, reedit the CMakeCache.txt

you have probably moved your package without cleaning it (make clean). This means the absolute paths that where generated during building do not make sense anymore. To solve this, do the following:

  • Clean your project, i.e., type make clean
  • Make sure there is no CmakeLists.txt.user in your package (it is auto-generated by Qt Creator and should notbe on the SVN)
  • Try to open your project again


Eclipse

Eclipse is an IDE widely used for Java, C, C++ and many more languages. This section explains how it can be configured to be easily used with ROS packages.

To install Eclipse, do the following:

  1. Go to the Eclipse download site
  2. Find Eclipse IDE for C/C++ Developers and select the appropriate version on the right (32-Bit or 64-Bit Linux).
  3. Extract Eclipse into a folder of your choice
  4. You can create a launcher to Eclipse to your panel by alt + right clicking the panel, choosing 'Add to panel' and selecting 'Custom Application Launcher'. Then browse to the Eclipse executable, and enter a name. If you want you can add the Eclipse icon by clicking the image on the left and browsing to the icon in the Eclipse folder.


Now, to make sure your package can be viewed properly in Eclipse, do the following:

  1. Create a custom package in your ~/ros directory with optional dependencies:
    cd ~/ros/emc
    roscreate-pkg <package-name> [dependencies...]
  2. Enter in a terminal:
    roscd <package name>
    make eclipse-project
  3. Open Eclipse
    • You will be prompted to select a path for the workspace. The default (/home/YOUR_NAME/workspace) is fine here. This folder will not contain the software (that is stored in ~/ros), but simply pointers to the software and some administration files for Eclipse.
  4. Go to “file” → “Import”
  5. Click “General”
  6. Then “Existing Projects into Workspace”
  7. Click “next”
  8. Browse for the package

All environment settings should be set automatically. You can build the package using ctrl-b. Note that you have to remake the eclipse-project in your package every time you change the manifest or if you switch to a new version of ROS. If you're having trouble or want to know more about the possibilities of using eclipse with ROS, check the ROS wiki.