PDA

View Full Version : How to get parameter from ros launch file and use it in Qt?



astronaut
16th July 2014, 07:48
Im using ROS Fuerte and qt_ros so can integrate ROS in Qt GUI. I would like to use

some parameters from the ROS launch file in my Qt GUI. in the main.cpp file of the GUI Im using the ROS launch file to start the process like this:


int main(int argc, char **argv) {
//Roslaunch
QProcess process;
process.start("roslaunch", QStringList() << "/home/launch/pow.launch");
//GUI
QApplication app(argc, argv);
pow_gui::MainWindow w(argc,argv);
w.show();
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
int result = app.exec();
std::cout << "q application finished" << std::endl;
return result;
}

So in my pow.launch


<launch>
<param name="/use_sim_time" value="true"/>
<node name="hector_mapping" pkg="hector_mapping" type="hector_mapping" output="screen">
<param name="pub_map_odom_transform" value="false"/>
<remap from="scan" to="scan_2"/>
<param name="map_frame" value="map"/>

</node>

<node name="foo_throttler" type="throttle" pkg="topic_tools" args="messages /scan 10/scan_throttle" />
<node name="foo_throttler1" type="throttle" pkg="topic_tools" args="messages /raw_imu 10/raw_imu_throttle" />

<node name="rosplay" pkg="rosbag" type="play" args="/home/10m_forward5.bag --clock"/>
<node pkg="tf" type="static_transform_publisher" name="corner_duhhu" args="-0.17 -0.2 0 0 0 0 base_link laser 20"/>

<node pkg="tf" type="static_transform_publisher" name="raw_tf" args="0 0 0 0 0 0 /map /raw_frame 10"/>

<!--node pkg="analyzer" type="parking" name="parking" output="screen"/> -->
<node pkg="analyzer" type="wst_forward10m" name="wst_forward10m" output="screen"/>
<!--node pkg="analyzer" type="wst_turn" name="wst_turn" output="screen"/> -->

</launch>

when Im using the node pkg="analyzer" type="wst_forward10m" name="wst_forward10m" I would like to have a tab in QT saying that Im using that node and when using node pkg="analyzer" type="wst_turn" name="wst_turn" would like to have that displayed in QT.

Any help?

anda_skoa
16th July 2014, 08:40
Since the file's format is XML, have a look at QXmlStreamReader.

Cheers,
_