Robotics StackExchange | Archived questions

Run QT project with ROS publisher/subscriber

Hi all,

I'm new to ROS. I have used the tutorials to make a catkin workspace with a publisher and subscriber cpp file. I have run these via terminal and they work fine. I have also created QT projects for them, and ran and they communicate.

My project involves a high speed vision system using QT for ball detection and tracking. I need to run a ROS publisher in this project on my laptop, and via wifi communicate with the subscriber in a QT project on an Odroid board (or vice versa), to send information about the located ball position/size/distance.

My questions are: 1. how can i put my ROS publisher into my existing QT project? 2. can I run QT after ssh into wifi? I get display errors. 3. can i send images from publisher to subscriber? 4. Everytime I want to run my current publisher/subscriber I have to remake my CMakeLists.txt file otherwise I get 'no executable specified' error - is this normal?

Thanks! :)


[EDIT]:

I'll try my best to explain it all.

I have simply put in the #includes (eg ros/ros.h) and added a ros::intit() statement into my current project main, I get 'undefined reference to ros::init()'

My vision project is a normal .pro with header and sources. The ros qt project built off the CMakeLists.txt so its layout is different.. I get many many errors when I put my ros talker.cpp code into my vision project so I'm guessing I'm missing some includes or libs in my pro file :/

I have ssh into the odroid and run a publisher/subscriber using terminal command line like rosrun and this does work. I just cant run qtcreator apparently and get a display warning.

Thank you for the information on images! I have also been shown cv_bridge.

I've setup my publisher project following the ros IDE instructions, remaking the CMakeLists.txt and using this to build a new project. When I googled the error it comes up as an Ubuntu bug that hasn't been fixed. It doesnt appear if I remake the .txt file each time I open qtcreator. A huge pain!

Asked by JaneSheard on 2016-04-14 05:06:04 UTC

Comments

Answers

1). There is nothing special about ROS code, you can just take the code you did in your tutorials and copy and paste it into your QT project, the ROS stuff can be thought of as just a regular CMake project. Is there a specific problem you're having?

2). Yes, you can ssh into the Odroid using wifi. Another option would be to setup the Odroid to launch your programs at startup.

3). Yes, sending images is something people do with ROS all the time. Here is a link with plenty of information.

4). That is not normal, but I'm not sure how you're running it and don't have enough information to help.

Asked by Airuno2L on 2016-04-14 05:45:28 UTC

Comments

My reply was too big, so I had to write a new answer but don't know how to quote/tag you in it :)

Asked by JaneSheard on 2016-04-14 06:21:55 UTC

Don't I have to open the ros package in QT using my CMakeLists.txt? How can I just add ros code to an existing QT project without first making a ros package and using CMake?

Asked by JaneSheard on 2016-04-14 07:22:07 UTC

Ah, I'm using qmake for my qt project.. I'm guessing I need to change this to CMake and it'll be in the right direction?

Asked by JaneSheard on 2016-04-14 07:42:40 UTC

I had a similar problem. And, for me, it was easier to create a ROS catkin package, then open it with QT creator and all the previous code in there. It is not ideal, but it worked fine for me.

Asked by Mario Garzon on 2016-04-14 09:37:07 UTC

@ Mario so once you've created your catkin package, do you move/copy all your existing QT cpp and header files into the package and add them to the CMake file? I am considering trying this, but also wondering if I modify my current QT project to use CMake and not qmake whether I can then ~

Asked by JaneSheard on 2016-04-14 14:31:30 UTC

~ configure the cmake file to include the ros package?

Asked by JaneSheard on 2016-04-14 14:32:26 UTC

Yes, you need to move/copy your files and then define libraries and executables in the CMakelist to include all your previous code, even if they don't use ROS. I've never tried to modify the QT project, but I guess you can do that as well.

Asked by Mario Garzon on 2016-04-19 12:24:54 UTC

My project supervisor has recommended using the qmake project, so I now need to figure out how to run ros code in a qmake project and cant find much help online. Something about including paths to roscpp and rospy?

Asked by JaneSheard on 2016-04-20 04:33:19 UTC

I also encountered such a problem, can you tell me how do you solve?

Asked by rosWang on 2016-04-29 02:30:02 UTC

Comments

@rosWang you're using qmake with ros? The solution is actually quite simple - I was surprised. Install ROS as normal, if ubuntu desktop-full should install all your packages. Ubuntu ARM boards may need packages installing separately so make sure all your packages are good to go.

Asked by JaneSheard on 2016-04-29 04:46:19 UTC

Right click on your project header or .pro file (like you would to add a new file) and choose add library. Choose the last option for system package, and add roscpp. I would check that this works by calling ros::init and if this works then you should be able to use ros!

Asked by JaneSheard on 2016-04-29 04:48:14 UTC

Obviously remember to #include "ros/ros.h" and any other includes you may need. But all I needed was about 6 ros packages added in my .pro file and everything built.

If you're using an image publisher and using cv_bridge you may need to re-cmake your opencv build directory without openCL

Asked by JaneSheard on 2016-04-29 04:50:17 UTC