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

Cpp GUI Tutorial

asked 2013-07-29 11:37:02 -0600

invoices gravatar image

updated 2013-07-30 19:35:52 -0600

Hi,

is there any tutorial, how to create a GUI, where I can publish messages on a certain topic for C++? Or can anyone provide a minimal Example, how to read and publish a integer?

Thanks

EDIT: I tried to follow the tutorial : http : // ros.org/wiki/rqt/Tutorials/Writing%20a%20C%2B%2B%20Plugin

But somehow, when I try to load Cmakelists in QT Creator, I get following error:

CMake Error at /opt/ros/groovy/share/catkin/cmake/safe_execute_process.cmake:11 (message):
execute_process(/usr/bin/python
"/opt/ros/groovy/share/catkin/cmake/parse_package_xml.py" "/home/GUITest/rqt_mypkg/package.xml" "/home/GUITest/build/catkin_generated/package.cmake") returned error code 1 Call Stack (most recent call first):
/opt/ros/groovy/share/catkin/cmake/catkin_package_xml.cmake:63 (safe_execute_process)
/opt/ros/groovy/share/catkin/cmake/catkin_package_xml.cmake:39 (_catkin_package_xml)
/opt/ros/groovy/share/catkin/cmake/catkin_package.cmake:95 (catkin_package_xml)
CMakeLists.txt:51 (catkin_package)

return parse_package_string(f.read(),

filename) File "/usr/lib/pymodules/python2.7/catkin_pkg/package.py", line 448, in parse_package_string raise InvalidPackage('Error(s) in %s:%s' % (filename, ''.join(['\n- %s' % e for e in errors]))) catkin_pkg.package.InvalidPackage: Invalid package manifest "/home/GUITest/rqt_mypkg/package.xml": Error(s) in /home/GUITest/rqt_mypkg/package.xml: - The manifest must not contain the following tags: package Traceback (most recent call last): File "/opt/ros/groovy/share/catkin/cmake/parse_package_xml.py", line 98, in <module> main() File "/opt/ros/groovy/share/catkin/cmake/parse_package_xml.py", line 90, in main package = parse_package(args.package_xml) File "/usr/lib/pymodules/python2.7/catkin_pkg/package.py", line 315, in parse_package

Further, I don't get this from the tutorial:

Basically the same step described in previous tutorial. Some unique cases: Replace rqt_gui_py with rqt_gui_cpp C++ binding specific note for xml attribute: /library/class@name The name of the plugin that is exported via the PLUGINLIB_DECLARE_CLASS macro.

I just replaced rqt_gui_py with rqt_gui_cpp. But what is meant with C++ binding specific note for xml atribute? What should I do here exactly?

[EDIT] My plugin.xml looks like this:

<library path="src">
  <class name="MyPlugin" type="my_namespace::MyPlugin" base_class_type="rqt_gui_cpp::Plugin">
    <description>
      An example Python GUI plugin to create a great user interface.
    </description>
    <qtgui>
      <!-- optional grouping...
      <group>
        <label>Group</label>
      </group>
      <group>
        <label>Subgroup</label>
      </group>
      -->
      <label>My first CPP Plugin</label>
      <icon type="theme">system-help</icon>
      <statustip>Great user interface to provide real value.</statustip>
    </qtgui>
  </class>
</library>

I have following files:

  • /home/GUITest/rqt_mypkg/package.xml
  • /home/GUITest/rqt_mypkg/plugin.xml
  • /home/GUITest/rqt_mypkg/CmakeLists.xml
  • /home/GUITest/rqt_mypkg/my_namespace/my_plugin.h
  • /home/GUITest/rqt_mypkg/my_namespace/my_plugin.cpp
edit retag flag offensive close merge delete

Comments

Why are you using QT Creator? The tutorial does not mention this. Why not just try to follow the tutorial and take the example code and see if it compiles?

TommyP gravatar image TommyP  ( 2013-07-30 12:37:38 -0600 )edit

If I try to call CMake in the console, I get the same error. From this tutorial; http://ros.org/wiki/rqt/Tutorials/Create%20your%20new%20rqt%20plugin I dont get the point 6 and below. I dont have a setup.py. Do I need it? Im not using python

invoices gravatar image invoices  ( 2013-07-30 19:26:40 -0600 )edit

@invoices I suppose that your original question is already answered. If so, you better open up a new question so that others can have a better view of what's your problem.

130s gravatar image 130s  ( 2013-07-30 19:49:02 -0600 )edit

Ok, I will create a new question as I still have not understood how to create my C++ RQT GUI

invoices gravatar image invoices  ( 2013-07-31 01:23:40 -0600 )edit

3 Answers

Sort by ยป oldest newest most voted
1

answered 2013-07-30 04:45:06 -0600

TommyP gravatar image

I would put the ros::spin() in its own thread.

This is a good page:

http://www.ros.org/wiki/roscpp/Overview/Callbacks%20and%20Spinning

But what I would do for this problem is to write a rqt plugin in Python but you can also write it in C++:

http://ros.org/wiki/rqt/Tutorials

edit flag offensive delete link more
0

answered 2013-07-29 16:06:44 -0600

Zee-Q gravatar image

To make GUI's there is an API Qt. Ros has its wrapper can be found here qt_ros. Here is the tutorial to make Qt enabled ros package. For Qt you have to see its documentation on Qt website and there are some very good beginners' tutorials.

edit flag offensive delete link more
0

answered 2013-07-30 01:45:05 -0600

invoices gravatar image

updated 2013-07-30 01:52:30 -0600

Hey, thank you for your answer. I'm really new to QT and ROS. I tried to follow your links but was not able to understand it completely.

I've build my example GUI with QT Creator. Right now, it just consists of a button. When it's clicked, then "Hello" is printed on the console. I'm using c++ as I've never used Python before.

My ROS-Programm looks like this:

int main (int argc, char **argv){

ros::init(argc,argv,"my_test");
ros::NodeHandle subscriber;
ros::NodeHandle publisher("~");

Test myTest(subscriber,publisher);
ros::spin();

return 0;}

Where Test is some Test-Class that publishes and subscribes topics. For creating my ROS-Programm I use QT-Creator with CMakeList.txt, manifest.xml and Makefile.

My GUI-Programm has also a Main-Method:

int main(int argc, char *argv[]){
QApplication a(argc, argv);
MainWindow w;
w.show();    
return a.exec();}

How do I actually integrate my QT-GUI to ROS? What I actually want to do, is to manually update some parameters (setpoint for Robot-Arm) during runtime of my application. What is the best way for doing this?

edit flag offensive delete link more

Comments

Welcome to the site @invoices! The Q&A format tends to work better if you put updates like this as edits to your original question, rather than as answers. That way, everybody who clicks through to see your question will see all of the details at the top.

lindzey gravatar image lindzey  ( 2013-07-30 09:35:43 -0600 )edit

Thank you for your help, I made an edit for further questions.

invoices gravatar image invoices  ( 2013-07-30 10:36:18 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-07-29 11:37:02 -0600

Seen: 2,254 times

Last updated: Jul 30 '13