gauges.cpp
Go to the documentation of this file.
00001 
00002 #include <mainwindow.h>
00003 #include <QApplication>
00004 
00005 namespace gauges
00006 {
00007   QcNeedleItem *theNeedle; // Get access to this Qt member
00008 }
00009 
00010 void newDataCallback(const std_msgs::Float64& msg);
00011 
00012 int main(int argc, char** argv) {
00013   ros::init(argc, argv, "gauge_node");
00014   ros::NodeHandle nh;
00015   ros::AsyncSpinner* spinner;
00016   spinner = new ros::AsyncSpinner(1);
00017   spinner->start();
00018   
00019   // Subscribe to new data
00020   std::string topicName;
00021   nh.getParam("topic", topicName);
00022   ros::Subscriber listener = nh.subscribe(topicName, 1, newDataCallback);
00023   
00024   QApplication qtApp(argc, argv);
00025   MainWindow window(0, &nh);
00026   window.show();
00027   gauges::theNeedle = window.mSpeedNeedle; // Get access to this Qt member
00028   
00029   // Show the graphic. This is blocking and it must be in the main thread,
00030   // so I used multithreaded ROS spinners to get around it.
00031   qtApp.exec();
00032   
00033   // Multithreaded spinner
00034   ros::waitForShutdown();
00035 
00036   ros::shutdown();
00037   return 0;
00038 }
00039 
00040 void newDataCallback(const std_msgs::Float64& msg)
00041 {
00042   gauges::theNeedle -> setCurrentValue(msg.data);
00043 }


gauges
Author(s): alexvs
autogenerated on Mon Nov 14 2016 03:32:20