Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "cop.h"
00020
00021 #define STD_CONFIG_FILENAME "bla.xml"
00022
00023
00024 #ifndef USE_YARP_COMM
00025 #include <ros/ros.h>
00026 #endif
00027
00028 using namespace cop;
00029
00030 int main(int argc, char* argv[])
00031 {
00032 #ifndef USE_YARP_COMM
00033 std::string nodename = "cop";
00034 if(argc > 2)
00035 nodename = argv[2];
00036 ros::init(argc, argv, nodename);
00037 #endif
00038 try
00039 {
00040 if(argc > 0)
00041 {
00042 XMLTag* config = NULL;
00043 if(argc > 1)
00044 config = XMLTag::ReadFromFile(argv[1]);
00045 else
00046 config = XMLTag::ReadFromFile(STD_CONFIG_FILENAME);
00047 if(config == NULL)
00048 config = new XMLTag("config");
00049
00050
00051 printf("Init start:\n");
00052 cop_world copWorld(config, nodename);
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
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
00112
00113
00114
00115
00116 printf("exiting %s\n", argv[0]);
00117 return 0;
00118 }
00119