main.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2009 by Ulrich Friedrich Klank <klank@in.tum.de>
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 3 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 
00019 #include "CollisionInterface.h"
00020 
00021 #define STD_CONFIG_FILENAME "bla.xml"
00022 
00023 #include <ros/ros.h>
00024 
00025 using namespace cop;
00026 
00027 
00028 int main(int argc, char* argv[])
00029 {
00030 #ifndef USE_YARP_COMM
00031     std::string nodename = "cop";
00032     if(argc > 2)
00033       nodename = argv[2];
00034     ros::init(argc, argv, nodename);
00035 #endif
00036     try
00037     {
00038     if(argc > 0)
00039     {
00040         XMLTag* config = NULL;
00041         if(argc > 1)
00042             config = XMLTag::ReadFromFile(argv[1]);
00043         else
00044             config = XMLTag::ReadFromFile(STD_CONFIG_FILENAME);
00045         if(config == NULL)
00046             config = new XMLTag("config");
00047         /*Blob* blob = new Blob(235, 255, 0, 35, 0, 40, 750, 5000, 0.4, 0.095, 0.05);*/
00048 
00049         printf("Init start:\n");
00050         ros::NodeHandle nh;
00051         cop_world copWorld(config, nodename);
00052         CollisionInterface collision(copWorld, nh);
00053         /*XMLTag tag(XML_NODE_CAMERADRIVER);
00054         tag.AddProperty(XML_ATTRIBUTE_GRABBERNAME, "DirectShow");
00055         tag.AddProperty(XML_ATTRIBUTE_EXTERNALTRIGGER, "false");
00056         tag.AddProperty(XML_ATTRIBUTE_CAMERATYPE, "RGB24 (640x480)");
00057         tag.AddProperty(XML_ATTRIBUTE_DEVICE, "USB PC Camera (SN9C102)");
00058         tag.AddProperty(XML_ATTRIBUTE_CALIBFILE, "C:/__CODE/radigsvn/cop/bin/fakeparam_usbwebcam.dat");
00059         tag.AddProperty(XML_ATTRIBUTE_CAMPORT, "0");
00060         tag.AddProperty(XML_ATTRIBUTE_COLORSPACE, "rgb");
00061         copWorld.s_inputSystem->AddCamera(new CameraDriver(&tag));
00062         copWorld.s_visFinder->AddAlgorithm(new ShapeBased3D());   */
00063 /*        copWorld.s_visFinder->AddAlgorithm(new BlobLocalizer());
00064         Signature* sig = new Signature();
00065         Class* cl = new Class();
00066         Class* clOra = new Class();
00067         cl->SetName("EasterEgg");
00068         clOra->SetName("Orange");
00069         sig->SetClass(cl);
00070         sig->SetClass(clOra);
00071         sig->SetElem(blob);
00072         copWorld.s_sigDb->AddSignature(sig);*/
00073         printf("Inited\n");
00074 #ifdef USE_YARP_COMM
00075         copWorld.StartListeningYarpPort((char*)"/tracking/in");
00076 #else
00077         if(copWorld.s_visFinder != NULL)
00078         {
00079           if(copWorld.s_visFinder->CountAlgorithms() == 0)
00080              printf("Warning: no algorithm loaded\n");
00081           copWorld.StartNodeSubscription((char*)"in");
00082 
00083           printf("Returned successfully\n");
00084   #endif
00085           if(g_stopall == true)
00086           {
00087             if(argc > 1)
00088             {
00089               copWorld.SaveCop(STD_CONFIG_FILENAME);
00090               exit(0);
00091             }
00092             else
00093             {
00094               copWorld.SaveCop(STD_CONFIG_FILENAME);
00095               exit(0);
00096             }
00097           }
00098         }
00099         else
00100         {
00101             ROS_ERROR("cop: Loading of main modules failed. Check the configuration and the folder cop is executed in!");
00102         }
00103       }
00104     }
00105     catch(char* text)
00106     {
00107       printf("Error in cop_main: %s\n", text);
00108       return 1;
00109 
00110     }
00111     //catch(...)
00112     //{
00113     //  printf("Unhandled Exception: stopping program\n");
00114     //  return 1;
00115     //}
00116     printf("exiting %s\n", argv[0]);
00117     return 0;
00118 }
00119 


cop_collision_interface
Author(s): Ulrich Friedrich Klank
autogenerated on Mon Oct 6 2014 11:01:54