Main.cpp
Go to the documentation of this file.
00001 /*
00002  * Main.cpp
00003  *
00004  *  Created on: Nov 23, 2011
00005  *      Author: mriedel
00006  */
00007 
00008 
00009 // Main Function for mk_interface
00010 
00011 #include <telekyb_base/TeleKyb.hpp>
00012 #include <telekyb_base/Options.hpp>
00013 
00014 
00015 #include "SerialIMUDevice.hpp"
00016 #include "IMUDataProcessor.hpp"
00017 #include "SmurfInterfaceOptions.hpp"
00018 
00019 #include "SerialCommandDevice.hpp"
00020 
00021 using namespace telekyb;
00022 
00023 int main(int argc, char **argv) {
00024 
00025         // Receiving is threaded out by itself.
00026         RawOptionsContainer::addOption("tRosNrSpinnerThreads","2");
00027         TeleKyb::init(argc,argv,"smurf_interface", ros::init_options::AnonymousName);
00028 
00029         SmurfInterfaceOptions *options = new SmurfInterfaceOptions();
00030         //SerialIMUDeviceOptions *options = new SerialIMUDeviceOptions();
00031 
00032         IMUDataProcessor* processor = new IMUDataProcessor();
00033 
00034         SerialIMUDevice *siDevice = NULL;
00035         SerialCommandDevice *scDevice = NULL;
00036         try {
00037                 siDevice = new SerialIMUDevice();
00038                 siDevice->setRawImuDataListener(processor);
00039         } catch (SerialException &e) {
00040                 e.process();
00041         }
00042 
00043         if (options->sendCommands->getValue()){
00044                 try{
00045                         scDevice = new SerialCommandDevice();
00046                 } catch (SerialException &e) {
00047                         e.process();
00048                 }
00049         }
00050 
00051         if (siDevice) {
00052                 if (scDevice || !options->sendCommands->getValue()) {
00053                         if (processor->init()) {
00054                                 ros::waitForShutdown();
00055                         }
00056                         if (scDevice) delete scDevice;
00057                 }
00058                 delete siDevice;
00059         }
00060 
00061         delete processor;
00062 
00063         TeleKyb::shutdown();
00064         return 0;
00065 }
00066 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Defines


tk_smurf_interface
Author(s): Martin Riedel
autogenerated on Mon Nov 11 2013 11:14:12