ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

qtcreator ros

asked 2012-12-11 11:58:09 -0600

leva87x gravatar image

updated 2014-04-20 14:09:43 -0600

ngrennan gravatar image

Hi, i try to combine ros with qt. I want to develop some GUI including ros. I created a package with roscreate-pkg then i’ve created a QTProject copy whole cpp, h and ui files into the main folder of my package. Then i edit the CMakeLists.txt and tipped in the whole cpp h and ui files. When i launch CMakeLists.txt from qtcreator i’ve got: C

Make Error at CMakeLists.txt:2 (include):
  include could not find load file:

    /core/rosbuild/rosbuild.cmake


CMake Error at CMakeLists.txt:12 (rosbuild_init):
  Unknown CMake command "rosbuild_init".


-- Configuring incomplete, errors occurred!

This is my CmakeLists.txt

cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

# Set the build type.  Options are:aaa
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
#  Debug          : w/ debug symbols, w/o optimization
#  Release        : w/o debug symbols, w/ optimization
#  RelWithDebInfo : w/ debug symbols, w/ optimization
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
#set(ROS_BUILD_TYPE RelWithDebInfo)

rosbuild_init()

find_package(Qt4 REQUIRED)
# enable/disable some Qt features
set( QT_USE_QTGUI TRUE )
set( QT_USE_QTOPENGL TRUE )
set( QT_USE_QTXML TRUE )
include(${QT_USE_FILE})

ADD_DEFINITIONS(-DQT_NO_KEYWORDS)

Qt specific files might need to be moc'd. This includes the headers, so put those here:

set(qt_srcs
      main.cpp
      mainwindow.cpp)
set(qt_hdrs
      mainwindow.h)
qt4_automoc(${qt_srcs})
QT4_WRAP_CPP(qt_moc_srcs ${qt_hdrs})

QT4_WRAP_UI(uis_h mainwindow.ui)
# include this for ui_h
include_directories(${CMAKE_CURRENT_BINARY_DIR})


#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

#uncomment if you have defined messages
#rosbuild_genmsg()
#uncomment if you have defined services
#rosbuild_gensrv()

#common commands for building c++ executables and libraries
#rosbuild_add_library(${PROJECT_NAME} src/example.cpp)
#target_link_libraries(${PROJECT_NAME} another_library)
#rosbuild_add_boost_directories()
#rosbuild_link_boost(${PROJECT_NAME} thread)
#rosbuild_add_executable(example examples/example.cpp)
#target_link_libraries(example ${PROJECT_NAME})

Where is the problem? I spend 3 days trying to make it run, i cracking up.

edit retag flag offensive close merge delete

Comments

Please provide OS, ROS distro you are using whenever you ask a question (without them it's hard for others to narrow down your problem).

130s gravatar image 130s  ( 2012-12-11 17:15:04 -0600 )edit

SORRY GUYS MY FAULT. Im using ubuntu 12.04 and fuerte

leva87x gravatar image leva87x  ( 2012-12-11 20:45:52 -0600 )edit

4 Answers

Sort by » oldest newest most voted
5

answered 2012-12-12 01:55:09 -0600

ddimarco gravatar image

The error message stating that rosbuild.cmake could not be found occurs when the ROS environment variables are not set (i.e. when setup.bash/zsh/whatever is not sourced).

So if you start qtcreator from your terminal where the ROS variables are set, it should work as expected.

edit flag offensive delete link more
1

answered 2012-12-11 19:13:51 -0600

Alireza gravatar image

if you are using Fuerte:

I recommend you to download and install "ros-fuerte-qt-ros" package from ROS repositories. then create a ROS package using following command:

roscreate-qt-pkg yourpackagename

The created ROS package has a Qt based default GUI which you can modify or even remove it completely.

Also if you are using ROS Electric:

you can have a look at eros_python_tools.

edit flag offensive delete link more
0

answered 2012-12-11 22:00:32 -0600

leva87x gravatar image

updated 2012-12-16 21:25:51 -0600

Hello,

i get hopefully my last error. When i try to run my application.

[FATAL] [1355735900.735429071]: You must call ros::init() before creating the first NodeHandle
[FATAL] [1355735900.735536083]: BREAKPOINT HIT
    file = /tmp/buildd/ros-fuerte-ros-comm-1.8.15-0precise-20120908-1740/clients/cpp/roscpp/src/libros/node_handle.cpp
    line=151

this ist my main.cpp

#include <QtGui/QApplication>
#include "../include/robot/robot.hpp"
#include "ros/ros.h"

int main(int argc, char *argv[])
{
    ros::init(argc, argv, "RobotControl");
    QApplication a(argc, argv);
    Robot w;
    w.show();

    return a.exec();
}

and my Robot.cpp

#include "../include/robot/robot.hpp"

#include <math.h>
#define PI 3.14159265

#include "ros/ros.h"

#include "../ssc32py/srv_gen/cpp/include/ssc32py/MoveAng.h"
#include "../ssc32py/srv_gen/cpp/include/ssc32py/None_Float.h"
#include "../ssc32py/srv_gen/cpp/include/ssc32py/None_Int32.h"



int i_joint , status;
double t1, t2, t3, t4, t5, v_xy, x, y, z, l1, l2, field[8][8][3], angle, ttime;

bool endgroup;
ros::NodeHandle n;
ros::ServiceClient client;
ssc32py::MoveAng service_MoveAng;
ssc32py::None_Int32 service_IsMove;

Robot::Robot(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Robot)
{
    ui->setupUi(this);
}

Robot::~Robot()
{
    delete ui;
}
edit flag offensive delete link more
0

answered 2012-12-12 02:47:06 -0600

PerkinsJames gravatar image

updated 2012-12-12 02:49:06 -0600

I used QT Creator in the past (and decided the code completion was either bad or required magic that I couldn’t figure out). I did not have problems with cmake, though. I followed the following steps, which are slightly different it seems than yours. With an existing ros package:

Go to File->New File or Project->Import Project->Import Existing Projects, click choose Create a project name (I used the ROS package name), then select (navigate inside) the folder of the package. Click next. Select ALL checkboxes to include all files.

I think these steps are also on the ROS IDE's page. Edit: And make sure to run qtcreator from the command line as the previous reply said. To make sure you command line environment is ok, try commands like $roscd PACKAGENAME and ensure they work.

edit flag offensive delete link more

Comments

I thought there is a problem wirh environment too. Even when I start qtcreator from command line its not work. I checked all environments they all set right. Any ideas?

leva87x gravatar image leva87x  ( 2012-12-12 04:25:21 -0600 )edit

ros::init error

leva87x gravatar image leva87x  ( 2012-12-12 06:54:03 -0600 )edit

Question Tools

Stats

Asked: 2012-12-11 11:58:09 -0600

Seen: 3,552 times

Last updated: Dec 16 '12