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

GUI creation through rqt

asked 2018-05-25 16:16:17 -0500

Vinni gravatar image

Hi,

First things first: I'm very new to the whole ROS story.

I am trying to create a GUI for my ROS application. I would like to view system states in the GUI, stream video and send ROS messages. Therefore I though it would be neat to use some existing rqt plugins and then write a plugin on my own that covers all other functions that I can't accomplish. Let's say I would like to send a specific rosmsg when I press a button (rostopic pub --once ...). It does not sound very hard.

First approach: I created a package with catkin_create_qt_pkg. That worked well. The plugin is behaving as it should. On clicking the button, my message is sent with system("rostopic pub --once .... But I have now trouble getting this plugin to be discovered and working in rqt. I am very unsure how to set up all the extra files correctly.

Second approach: I created a package with catkin_create_rqt. That worked as well, took a little longer. The plugin was found by rqt right away but I am struggling getting a connection to the system. When I press my button, nothing happens. I send system("echo test".c_str()); and system("nautilus".c_str()); but nothing happens. Of course, my rostopic is not working either.

Unfortunately, combining the two methods is also very very hard as the entire file structure and CMakeLists.txt are very different. Can anyone help me out? Or do you have a different solution in mind for my problem?

Thanks a lot, Vincenz

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-06-28 04:10:23 -0500

TifferPelode gravatar image

Hello Vincenz,

I suggest you use connect, with SIGNAL and SLOT. here is a part of my code.

In constructor :

QPushButton* stop_button = new QPushButton(QObject::trUtf8("Stop"));

connect(stop_button, SIGNAL(clicked()), this, SLOT(stopCallback()));

nav_stop_pub_ = nh_.advertise<actionlib_msgs::GoalID>("/move_base/cancel", 1, true);

and then declare stopCallback():

void YourClassName::stopCallback(){
    actionlib_msgs::GoalID stop_msg;
    nav_stop_pub_.publish(stop_msg);
}

Hope there can help you, bset wish.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2018-05-25 16:16:17 -0500

Seen: 526 times

Last updated: Jun 28 '18