[TeamTalk 24]: [561] TeamTalk/Agents: more interesting fake treasure location

tk@edam.speech.cs.cmu.edu tk at edam.speech.cs.cmu.edu
Thu Dec 14 12:49:22 EST 2006


An HTML attachment was scrubbed...
URL: http://mailman.srv.cs.cmu.edu/pipermail/teamtalk-developers/attachments/20061214/ae4ae744/attachment.html
-------------- next part --------------
Modified: TeamTalk/Agents/PrimitiveComm/PrimitiveComm.vcproj
===================================================================
--- TeamTalk/Agents/PrimitiveComm/PrimitiveComm.vcproj	2006-12-13 19:04:17 UTC (rev 560)
+++ TeamTalk/Agents/PrimitiveComm/PrimitiveComm.vcproj	2006-12-14 17:49:21 UTC (rev 561)
@@ -274,10 +274,6 @@
 				>
 			</File>
 			<File
-				RelativePath=".\robot_packet.hpp"
-				>
-			</File>
-			<File
 				RelativePath=".\robot_packet2.h"
 				>
 			</File>

Modified: TeamTalk/Agents/PrimitiveComm/robot_client.cpp
===================================================================
--- TeamTalk/Agents/PrimitiveComm/robot_client.cpp	2006-12-13 19:04:17 UTC (rev 560)
+++ TeamTalk/Agents/PrimitiveComm/robot_client.cpp	2006-12-14 17:49:21 UTC (rev 561)
@@ -88,7 +88,10 @@
 	for(;;) {
     bool gotAMessage = false;
     const Boeing::MsgRobot* mesg = me->getNextMessage();
-    if(mesg == NULL) continue;
+    if(mesg == NULL) {
+      Sleep(500);
+      continue;
+    }
     try {
       Msg* m = Msg::interpretBoeingPacket(string(mesg->buff, sizeof(Boeing::MsgRobot)), me->getName());
       if(!m) throw MalformedPacketException("RobotClient::readMessages", 

Modified: TeamTalk/Agents/PrimitiveComm/robot_packet2.cpp
===================================================================
--- TeamTalk/Agents/PrimitiveComm/robot_packet2.cpp	2006-12-13 19:04:17 UTC (rev 560)
+++ TeamTalk/Agents/PrimitiveComm/robot_packet2.cpp	2006-12-14 17:49:21 UTC (rev 561)
@@ -25,6 +25,24 @@
 
 // Msg ****************************************************************
 
+int Msg::boeingStatus(Msg::Status x) 
+{
+  switch(x) {
+    case FAILED: return Boeing::FAILED;
+    case IN_PROGRESS: return Boeing::INPROGRESS;
+    case SUCCEEDED: return Boeing::SUCCEEDED;
+    default: error << "unknown status " << (int)x;
+  }
+  return 0;
+}
+
+Msg::Status Msg::statusOfBoeing(int x) 
+{
+  if(x <= Boeing::FAILED) return FAILED;
+  if(x >= Boeing::SUCCEEDED) return SUCCEEDED;
+  return IN_PROGRESS;
+}
+
 int Msg::taskIDCounter = 0;
 const int Msg::defaultPriority = 1;
 
@@ -103,9 +121,12 @@
     return new MsgRobAck(sender, tstamp, 
       reinterpret_cast<const Boeing::MsgRobAck*>(m.c_str())->taskid);
   }
-//    case Boeing::ROB_ACTION_ACK:
-//      warn("packet") << "unhandled type: ROB_ACTION_ACK " << h->type << endl;
-//      break;
+  if(type == Boeing::ROB_ACTION_ACK) {
+    warn("packet") << "unhandled type: ROB_ACTION_ACK " << h->type << endl;
+    debug("packet") << "got: ROB_ACTION_ACK" << endl; 
+    const Boeing::MsgActionAck* bp = reinterpret_cast<const Boeing::MsgActionAck*>(m.c_str());
+    return new MsgRobActionAck(sender, tstamp, bp->taskid, (bp->status == Boeing::SUCCEEDED));
+  }
   if(type == Boeing::ROB_DONE) {
     debug("packet") << "got: ROB_DONE" << endl;
     const Boeing::MsgRobDone* bp = reinterpret_cast<const Boeing::MsgRobDone*>(m.c_str());
@@ -127,10 +148,10 @@
 //      warn("packet") << "unhandled type: TASK_CANCEL " << endl;
 //      break;
     //messages from trader
-  if(type == Boeing::INFO) {
-    warn("packet") << "unhandled type: INFO " << endl;
-    return NULL;
-  }
+//  if(type == Boeing::INFO) {
+//    warn("packet") << "unhandled type: INFO " << endl;
+//    return NULL;
+//  }
 //    case Boeing::TASK_ACK:
 //      warn("packet") << "unhandled type: TASK_ACK " << endl;
 //      break;
@@ -440,6 +461,39 @@
   return string(reinterpret_cast<char *>(&packet), packet.len);
 }
 
+// MsgRobActionAck ****************************************************
+
+//normal instantiation
+MsgRobActionAck::MsgRobActionAck(int taskID, Status status, string sender)
+: Msg(sender), taskID_(taskID), status_(status) {}
+  
+//instantiation from a Boeing packet
+MsgRobActionAck::MsgRobActionAck(string sender, double tstamp, int taskID, int status)
+: Msg(sender, tstamp), taskID_(taskID) {
+  if(status <= Boeing::FAILED) status_ = FAILED;
+  else if(status = Boeing::INPROGRESS) status_ = IN_PROGRESS;
+  else status = SUCCEEDED;
+}
+  
+int MsgRobActionAck::getTaskID() const {return taskID_;}
+
+Msg::Status MsgRobActionAck::getStatus() const {return status_;}
+
+bool MsgRobActionAck::isSuccess() const {return status_ == SUCCEEDED;}
+bool MsgRobActionAck::isInprogress() const {return status_ == IN_PROGRESS;}
+bool MsgRobActionAck::isFailure() const {return status_ == FAILED;}
+  
+string MsgRobActionAck::render() const {
+  ostringstream out;
+  out << "robactionack: " << taskID_ << status_;
+  return out.str();
+}
+
+string MsgRobActionAck::renderBoeingPacket() const {
+  Boeing::MsgActionAck packet = Boeing::MsgActionAck::factory(taskID_, statusOfBoeing(status_));
+  return string(reinterpret_cast<char *>(&packet), packet.len);
+}
+
 // MsgRobDone *********************************************************
 
 //normal instantiation
@@ -589,7 +643,26 @@
 
 // Stream Operators ***************************************************
 
-ostream& operator<<(ostream& out, const Msg* m) {
+ostream& operator<<(ostream& out, const Msg* m) 
+{
   return out << m->render();
 }
 
+ostream& operator<<(ostream& out, const Msg::Status& x)
+{
+  switch(x) 
+  {
+  case Msg::FAILED:
+    out << "FAILED";
+    break;
+  case Msg::IN_PROGRESS:
+    out << "IN PROGRESS";
+    break;
+  case Msg::SUCCEEDED:
+    out << "SUCCEEDED";
+    break;
+  default:
+    error << "unknown status: " << (int)x << endl;
+  }
+  return out;
+}

Modified: TeamTalk/Agents/PrimitiveComm/robot_packet2.h
===================================================================
--- TeamTalk/Agents/PrimitiveComm/robot_packet2.h	2006-12-13 19:04:17 UTC (rev 560)
+++ TeamTalk/Agents/PrimitiveComm/robot_packet2.h	2006-12-14 17:49:21 UTC (rev 561)
@@ -45,6 +45,11 @@
 
 
 class Msg {
+public:
+  enum Status {FAILED, IN_PROGRESS, SUCCEEDED};
+  static int boeingStatus(Status x);
+  static Status statusOfBoeing(int x);
+
 protected:
   static const int defaultPriority;
   string sender_;
@@ -211,6 +216,24 @@
   string renderBoeingPacket() const;
 };
 
+class MsgRobActionAck : public Msg {
+protected:
+  int taskID_; 
+  Status status_;
+public:
+  //normal instantiation
+  MsgRobActionAck(int taskID, Status status, string sender=string());
+  //instantiation from a Boeing packet
+  MsgRobActionAck(string sender, double tstamp, int taskID, int status);
+  int getTaskID() const;
+  Status getStatus() const;
+  bool isSuccess() const;
+  bool isFailure() const;
+  bool isInprogress() const;
+  string render() const;
+  string renderBoeingPacket() const;
+};
+
 class MsgRobDone : public Msg {
 protected:
   int taskID_; 
@@ -289,5 +312,6 @@
 };
 
 ostream& operator<<(ostream& out, const Msg* m);
+ostream& operator<<(ostream& out, const Msg::Status& x);
 
 #endif

Modified: TeamTalk/Agents/PrimitiveComm/utils.cpp
===================================================================
--- TeamTalk/Agents/PrimitiveComm/utils.cpp	2006-12-13 19:04:17 UTC (rev 560)
+++ TeamTalk/Agents/PrimitiveComm/utils.cpp	2006-12-14 17:49:21 UTC (rev 561)
@@ -195,7 +195,7 @@
   char* temppath = new char[cmdline.str().length()+1];
   cmdline.str().copy(temppath, cmdline.str().length());
   temppath[cmdline.str().length()] = '\0';
-  debug << "fixin' to spawn: " << temppath << endl;
+  debug << "fixin' to spawn: " << temppath << " from dir: " << wdir << endl;
   
   STARTUPINFO si;
   PROCESS_INFORMATION pi;

Modified: TeamTalk/Agents/TeamTalkBackend/backendstub/backendstub.cpp
===================================================================
--- TeamTalk/Agents/TeamTalkBackend/backendstub/backendstub.cpp	2006-12-13 19:04:17 UTC (rev 560)
+++ TeamTalk/Agents/TeamTalkBackend/backendstub/backendstub.cpp	2006-12-14 17:49:21 UTC (rev 561)
@@ -94,7 +94,7 @@
 	for(int c=1;;c++) {
     if(!(c%500)) { //find treasure every 50 seconds
       ostringstream info_string;
-      info_string << "object unknown at (0, 0)";
+      info_string << "object unknown at (10, -5)";
       debug << "sending: " << info_string.str() << endl;
       tserver->sendInfo(c/10, info_string.str().c_str());
     }

Modified: TeamTalk/Agents/TeamTalkBackend/gal_be.cpp
===================================================================
--- TeamTalk/Agents/TeamTalkBackend/gal_be.cpp	2006-12-13 19:04:17 UTC (rev 560)
+++ TeamTalk/Agents/TeamTalkBackend/gal_be.cpp	2006-12-14 17:49:21 UTC (rev 561)
@@ -38,7 +38,7 @@
 {
 	debug << "sending restart_decoder" << endl;
 	Gal_Frame gfInput = Gal_MakeFrame("restart_decoder", GAL_CLAUSE);
-  galaxyRobots->writeFrameAllHubs(gfInput);
+  galaxyRobots->writeFrameSkeletonHub(gfInput);
 };
 
 BOOL WINAPI ConsoleHandler(DWORD CEvent) 

Modified: TeamTalk/Agents/TeamTalkBackend/robot-galaxy_adapter.cpp
===================================================================
--- TeamTalk/Agents/TeamTalkBackend/robot-galaxy_adapter.cpp	2006-12-13 19:04:17 UTC (rev 560)
+++ TeamTalk/Agents/TeamTalkBackend/robot-galaxy_adapter.cpp	2006-12-14 17:49:21 UTC (rev 561)
@@ -63,14 +63,17 @@
     subs);
 
 	PROCESS_INFORMATION lm_build_proc = 
-    spawn("Language Build", "..\\..\\Resources\\MakeLM", "perl", "makelm.pl");
-	WaitForSingleObject(lm_build_proc.hProcess, INFINITE);
+    spawn(true, "Language Build", "..\\..\\Resources\\MakeLM", "perl", "makelm.pl");
 }
 
 void GalaxyRobots::traderlistener(void *p) 
 {
   GalaxyRobots* me = (GalaxyRobots *)p;
   Boeing::TraderClient* t_client = me->t_client;
+  
+  //this is bogus, but need to ping trader to get on its client list
+  t_client->sendCancel(0);
+
 	for(;;) {
 		const Boeing::MsgTraderClient* msg = t_client->getNextMessage();
 		if(!msg) {
@@ -203,10 +206,11 @@
 
 void GalaxyRobots::writeFrameAllHubs(Gal_Frame f) 
 {
-  debug << "writing to all hubs";
+  debug << "writing to all hubs" << endl;
 	for(set<Agent>::iterator i = agents_.begin(); i != agents_.end(); i++) {
     i->writeFrame(f);
   }
+  writeFrameSkeletonHub(f);
 };
 
 void GalaxyRobots::writeFrameSkeletonHub(Gal_Frame f) 
@@ -229,10 +233,7 @@
 
   debug << "about to get the p_client" << endl;
   try {
-    //startup trader client
     t_client = new Boeing::TraderClient();
-
-    //startup map client
     m_client = new Boeing::MapClient();
 
     //startup robot client
@@ -278,11 +279,13 @@
 
 void GalaxyRobots::setRobotVoices() 
 {
-  for(set<Agent>::const_iterator i = agents_.begin(); i != agents_.end(); i++) {
-    string name(toupper(i->getName()));
-		string voice(tolower(i->getRobotClient()->getVoice()));
-		debug << "adding voice " << voice << " to name " << name << endl;
-		SendRobotConfigMessage(name, voice);
+  debug << "attempting to set robot voices" << endl;
+  for(TeamTalk::RobotsClient::const_iterator i = r_client->begin();
+    i != r_client->end(); i++) {
+      string name(toupper((*i)->getName()));
+      string voice(toupper((*i)->getVoice()));
+      debug << "adding voice " << voice << " to name " << name << endl;
+      SendRobotConfigMessage(name, voice);
 	}
 }
 

Modified: TeamTalk/Agents/boeingLib/boeing/boeing_robot_packet.h
===================================================================
--- TeamTalk/Agents/boeingLib/boeing/boeing_robot_packet.h	2006-12-13 19:04:17 UTC (rev 560)
+++ TeamTalk/Agents/boeingLib/boeing/boeing_robot_packet.h	2006-12-14 17:49:21 UTC (rev 561)
@@ -214,6 +214,12 @@
   struct MsgActionAck : public MsgHeader {
     TaskID taskid;
     int16_t status;
+    static MsgActionAck factory(TaskID taskID, int16_t status) {
+      MsgActionAck m;
+      m.MsgHeaderFill(ROB_ACTION_ACK, sizeof(MsgActionAck));
+      m.taskid = taskID; m.status = status;
+      return m;
+    };
   } PACKED;
  
   /** robot done status message


More information about the TeamTalk-developers mailing list