00001 #include "Robots/SeaBeeIII/SeaBeeInjector.H" 00002 00003 #include "Component/ModelParam.H" 00004 #include "Component/ModelOptionDef.H" 00005 00006 #ifndef SeaBeeInjector_C 00007 #define SeaBeeInjector_C 00008 00009 // ###################################################################### 00010 SeaBeeInjector::SeaBeeInjector(int id, OptionManager& mgr, 00011 const std::string& descrName, const std::string& tagName) : 00012 RobotBrainComponent(mgr, descrName, tagName) 00013 { 00014 00015 } 00016 00017 // ###################################################################### 00018 SeaBeeInjector::~SeaBeeInjector() 00019 { 00020 00021 } 00022 00023 void SeaBeeInjector::registerTopics() 00024 { 00025 registerPublisher("SeaBeePositionMessageTopic"); 00026 registerPublisher("SeaBeeStateConditionMessageTopic"); 00027 } 00028 00029 void SeaBeeInjector::evolve() 00030 { 00031 int input; 00032 00033 RobotSimEvents::SeaBeeStateConditionMessagePtr msg; 00034 00035 // This is a menu that will appear every evolve cycle 00036 printf("\n\n::::::SeaBeeInjector Menu:::::\n"); 00037 printf("What Type of Message Do You Want To Send SeaBee?\n"); 00038 printf("\t0) Start Over From Beginning\n"); 00039 printf("\t1) Gate Finished\n"); 00040 printf("\t2) Flare Finished\n"); 00041 printf("\t3) Barbwire Finished\n"); 00042 printf("\t4) Bombing Run Finished\n"); 00043 printf("\t5) Briefcase Found\n"); 00044 cout << "\nMock Message to Send SeaBee: "; 00045 cin >> input; 00046 00047 switch(input) 00048 { 00049 case 0: 00050 LINFO("\n\n1: Starting Over...\n\n"); 00051 msg = new RobotSimEvents::SeaBeeStateConditionMessage; 00052 send_message(msg,1,0,0,0,0,0,0,0,0,0,0); 00053 publish("SeaBeeStateConditionMessageTopic",msg); 00054 break; 00055 case 1: 00056 //this is the Condition for Gate Finished 00057 LINFO("\n\n1: Sending Gate Finished Message...\n\n"); 00058 msg = new RobotSimEvents::SeaBeeStateConditionMessage; 00059 send_message(msg,0,0,0,1,0,0,0,0,0,0,0); 00060 publish("SeaBeeStateConditionMessageTopic",msg); 00061 break; 00062 case 2: 00063 //this is our Flare Finished Condition 00064 LINFO("\n\n2: Sending Flare Done Message...\n\n"); 00065 msg = new RobotSimEvents::SeaBeeStateConditionMessage; 00066 send_message(msg,0,0,0,0,0,1,0,0,0,0,0); 00067 publish("SeaBeeStateConditionMessageTopic",msg); 00068 break; 00069 case 3: 00070 //this is our message for Barbwire Finished 00071 LINFO("\n\n3: Sending Barbwire Finished Message...\n\n"); 00072 msg = new RobotSimEvents::SeaBeeStateConditionMessage; 00073 send_message(msg,0,0,0,1,0,0,0,0,0,0,0); 00074 publish("SeaBeeStateConditionMessageTopic",msg); 00075 break; 00076 case 4: 00077 //this is our Bombing Done Condition 00078 LINFO("\n\n4: Sending Bombing Run Done Message...\n\n"); 00079 msg = new RobotSimEvents::SeaBeeStateConditionMessage; 00080 send_message(msg,0,0,0,0,0,0,0,0,0,1,0); 00081 publish("SeaBeeStateConditionMessageTopic",msg); 00082 break; 00083 case 5: 00084 //this is message for Briefcase Found 00085 LINFO("\n\n5: Sending Briefcase Found Message...\n\n"); 00086 msg = new RobotSimEvents::SeaBeeStateConditionMessage; 00087 send_message(msg,0,0,0,0,0,0,0,0,0,0,1); 00088 publish("SeaBeeStateConditionMessageTopic",msg); 00089 break; 00090 default: 00091 break; 00092 00093 } 00094 } 00095 00096 // ###################################################################### 00097 void SeaBeeInjector::updateMessage(const RobotSimEvents::EventMessagePtr& eMsg, 00098 const Ice::Current&) 00099 { 00100 if(eMsg->ice_isA("::RobotSimEvents::XBox360RemoteControlMessage")) 00101 { 00102 RobotSimEvents::JoyStickControlMessagePtr msg = RobotSimEvents::JoyStickControlMessagePtr::dynamicCast(eMsg); 00103 00104 LINFO("Got A XBox Message! Axis: %d AxisVal: %d Button: %d ButtonVal: %d", msg->axis, msg->axisVal, msg->button, msg->butVal); 00105 00106 } 00107 } 00108 00109 void SeaBeeInjector::send_message(RobotSimEvents::SeaBeeStateConditionMessagePtr msg, int s, int path, int a, int b, int c, int d, int e, int f, int g, int h, int i) 00110 { 00111 msg->StartOver = s; 00112 msg->PathFollowFinished = path; 00113 msg->InitDone = a; 00114 msg->GateDone = b; 00115 msg->ContourFoundFlare = c; 00116 msg->FlareDone = d; 00117 msg->ContourFoundBarbwire = e; 00118 msg->BarbwireDone = f; 00119 msg->ContourFoundBoxes = g; 00120 msg->BombingRunDone = h; 00121 msg->BriefcaseFound = i; 00122 00123 msg->TimeUp = 0; 00124 00125 } 00126 00127 #endif