obj_rec.cpp
Go to the documentation of this file.
00001 #include <ros/ros.h>
00002 #include <ros/package.h>
00003 
00004 #include <iostream>
00005 #include <fstream>
00006 
00007 #include "Modules/ORControlModule.h"
00008 #include "Modules/ORLoaderModule.h"
00009 #include "Modules/ORMatchingModule.h"
00010 
00011 #include "Architecture/Config/Config.h"
00012 
00013 int main(int argc, char **argv)
00014 {
00015     ros::init(argc, argv, "obj_rec");
00016     ros::NodeHandle nh;
00017 
00018     // load config
00019     std::string path = ros::package::getPath("or_nodes");
00020     std::vector<std::string> fileNames;
00021     std::vector<std::string> profilesToLoad;
00022     // read params from parameter server
00023     if(ros::param::has("/OrNodes/sConfigFile") && ros::param::has("/OrNodes/sProfile"))
00024     {
00025         std::string configFile;
00026         ros::param::get("/OrNodes/sConfigFile", configFile);
00027         fileNames.push_back(path + configFile);
00028 
00029         std::string profile;
00030         ros::param::get("/OrNodes/sProfile", profile);
00031         profilesToLoad.push_back(profile);
00032     }
00033     else
00034     {
00035         std::string defaultConf = path + "/config/custom.xml";
00036         std::string defaultProfile = "drinks";
00037         ROS_WARN_STREAM("No Parameter \"/OrNodes/sConfigFile\" or \"/OrNodes/sProfile\" found.\nLoading default config file: \""+defaultConf+"\" and default profile: \""+defaultProfile+"\"");
00038         fileNames.push_back(defaultConf);
00039         profilesToLoad.push_back(defaultProfile);
00040     }
00041     Config::loadConfig(fileNames, profilesToLoad, path);
00042 
00043 
00044     // read input image topic
00045     std::string inputTopic;
00046     if(ros::param::has("/OrNodes/sInputImageTopic"))
00047     {
00048         ros::param::get("/OrNodes/sInputImageTopic", inputTopic);
00049         ROS_INFO_STREAM("Using topic " + inputTopic + " for image input.");
00050     }
00051     else
00052     {
00053         inputTopic = "/camera/rgb/image_color";
00054         ROS_WARN_STREAM("No parameter \"/OrNodes/sInputImageTopic\" found. Using default topic " + inputTopic + " for image input.");
00055     }
00056 
00057 
00058     ORMatchingModule* objRecMatchingModule = new ORMatchingModule(&nh, inputTopic);
00059     ORControlModule* objRecControlModule = new ORControlModule(&nh, objRecMatchingModule);
00060     ORLoaderModule* objRecLoaderModule = new ORLoaderModule(&nh, objRecMatchingModule);
00061 
00062     ros::Rate loop_rate(10);
00063     while (ros::ok())
00064     {
00065         ros::spinOnce();
00066         loop_rate.sleep();
00067     }
00068 
00069     delete objRecLoaderModule;
00070     delete objRecControlModule;
00071     delete objRecMatchingModule;
00072 
00073     return 0;
00074 }


or_nodes
Author(s): Viktor Seib
autogenerated on Tue Jan 7 2014 11:24:09