From tk at edam.speech.cs.cmu.edu Thu Apr 5 12:56:50 2007 From: tk at edam.speech.cs.cmu.edu (tk@edam.speech.cs.cmu.edu) Date: Thu, 5 Apr 2007 12:56:50 -0400 Subject: [TeamTalk 32]: [569] TeamTalk: 1. Message-ID: <200704051656.l35Guorh000800@edam.speech.cs.cmu.edu> An HTML attachment was scrubbed... URL: http://mailman.srv.cs.cmu.edu/pipermail/teamtalk-developers/attachments/20070405/e94c6f10/attachment-0001.html -------------- next part -------------- Property changes on: TeamTalk ___________________________________________________________________ Name: svn:externals + Tools http://edam.speech.cs.cmu.edu/repos/olympus/Tools Modified: TeamTalk/Agents/Agents.sln =================================================================== --- TeamTalk/Agents/Agents.sln 2007-02-25 14:08:57 UTC (rev 568) +++ TeamTalk/Agents/Agents.sln 2007-04-05 16:56:50 UTC (rev 569) @@ -1,24 +1,6 @@ ? Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Audio_Server", "MultiDecoder\Audio_Server\Audio_Server.vcproj", "{C31484B0-179B-432D-AE1E-75FB90591F23}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Helios3", "Helios3\Helios3.vcproj", "{93C8F5F8-6C43-4179-9B9F-A31AA6438513}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Kalliope", "Kalliope\Kalliope.vcproj", "{9CDBFBA5-F7EB-432F-A7CF-2E80322FE2ED}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NlgServer2", "NlgServer2\NlgServer2.vcproj", "{AB3C8BF7-BF9D-4A80-A956-E969B9D8542D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "phoenix2", "Phoenix2\phoenix2.vcproj", "{7022E28A-B15B-4A61-876A-5962C8EC1219}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PrimitiveComm", "PrimitiveComm\PrimitiveComm.vcproj", "{4051C912-8C55-442F-9AF8-3F3AE9859776}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ProcessMonitor", "ProcessMonitor\ProcessMonitor.vcproj", "{73E306B4-6227-4843-8A59-9B85C382790C}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RavenClaw", "RavenClaw\RavenClaw.vcproj", "{538B76FD-E289-4CF7-A7FF-1ACB429B4F63}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sphinx_Engine", "MultiDecoder\Sphinx_Engine\Sphinx_Engine.vcproj", "{6A7673C4-08F4-4490-93A5-5F7211B406CF}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "backendstub", "TeamTalkBackend\backendstub\backendstub.vcproj", "{596C5D37-C409-4C46-BA28-B7F5EFB96851}" ProjectSection(ProjectDependencies) = postProject {4051C912-8C55-442F-9AF8-3F3AE9859776} = {4051C912-8C55-442F-9AF8-3F3AE9859776} @@ -30,87 +12,15 @@ EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TeamTalkDM", "TeamTalkDM\TeamTalkDM.vcproj", "{8AD2EDB1-F154-40E3-8317-6799592E8B34}" - ProjectSection(ProjectDependencies) = postProject - {538B76FD-E289-4CF7-A7FF-1ACB429B4F63} = {538B76FD-E289-4CF7-A7FF-1ACB429B4F63} - EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PrimitiveComm", "PrimitiveComm\PrimitiveComm.vcproj", "{4051C912-8C55-442F-9AF8-3F3AE9859776}" +EndProject Global - GlobalSection(SourceCodeControl) = preSolution - SccNumberOfProjects = 8 - SccProjectUniqueName0 = MultiDecoder\\Audio_Server\\Audio_Server.vcproj - SccProjectName0 = \u0022$/CommonAgents-2005/MultiDecoder/Audio_Server\u0022,\u0020ONACAAAA - SccLocalPath0 = MultiDecoder\\Audio_Server - SccProvider0 = MSSCCI:Microsoft\u0020Visual\u0020SourceSafe - SccProjectUniqueName1 = Helios3\\Helios3.vcproj - SccProjectName1 = \u0022$/CommonAgents-2005/Helios3\u0022,\u0020ZJACAAAA - SccLocalPath1 = Helios3 - SccProvider1 = MSSCCI:Microsoft\u0020Visual\u0020SourceSafe - SccProjectUniqueName2 = Kalliope\\Kalliope.vcproj - SccProjectName2 = \u0022$/CommonAgents-2005/Kalliope\u0022,\u0020MLACAAAA - SccLocalPath2 = Kalliope - SccProvider2 = MSSCCI:Microsoft\u0020Visual\u0020SourceSafe - SccProjectUniqueName3 = NlgServer2\\NlgServer2.vcproj - SccProjectName3 = \u0022$/CommonAgents-2005/NlgServer2\u0022,\u0020JOACAAAA - SccLocalPath3 = NlgServer2 - SccProvider3 = MSSCCI:Microsoft\u0020Visual\u0020SourceSafe - SccProjectUniqueName4 = Phoenix2\\phoenix2.vcproj - SccProjectName4 = \u0022$/CommonAgents-2005/Phoenix2\u0022,\u0020APACAAAA - SccLocalPath4 = Phoenix2 - SccProvider4 = MSSCCI:Microsoft\u0020Visual\u0020SourceSafe - SccProjectUniqueName5 = ProcessMonitor\\ProcessMonitor.vcproj - SccProjectName5 = \u0022$/CommonAgents-2005/ProcessMonitor\u0022,\u0020VPACAAAA - SccLocalPath5 = ProcessMonitor - SccProvider5 = MSSCCI:Microsoft\u0020Visual\u0020SourceSafe - SccProjectUniqueName6 = RavenClaw\\RavenClaw.vcproj - SccProjectName6 = \u0022$/CommonAgents-2005/RavenClaw\u0022,\u0020PRACAAAA - SccLocalPath6 = RavenClaw - SccProvider6 = MSSCCI:Microsoft\u0020Visual\u0020SourceSafe - SccProjectUniqueName7 = MultiDecoder\\Sphinx_Engine\\Sphinx_Engine.vcproj - SccProjectName7 = \u0022$/CommonAgents-2005/MultiDecoder/Sphinx_Engine\u0022,\u0020BOACAAAA - SccLocalPath7 = MultiDecoder\\Sphinx_Engine - SccProvider7 = MSSCCI:Microsoft\u0020Visual\u0020SourceSafe - EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C31484B0-179B-432D-AE1E-75FB90591F23}.Debug|Win32.ActiveCfg = Debug|Win32 - {C31484B0-179B-432D-AE1E-75FB90591F23}.Debug|Win32.Build.0 = Debug|Win32 - {C31484B0-179B-432D-AE1E-75FB90591F23}.Release|Win32.ActiveCfg = Debug|Win32 - {C31484B0-179B-432D-AE1E-75FB90591F23}.Release|Win32.Build.0 = Debug|Win32 - {93C8F5F8-6C43-4179-9B9F-A31AA6438513}.Debug|Win32.ActiveCfg = Debug|Win32 - {93C8F5F8-6C43-4179-9B9F-A31AA6438513}.Debug|Win32.Build.0 = Debug|Win32 - {93C8F5F8-6C43-4179-9B9F-A31AA6438513}.Release|Win32.ActiveCfg = Release|Win32 - {93C8F5F8-6C43-4179-9B9F-A31AA6438513}.Release|Win32.Build.0 = Release|Win32 - {9CDBFBA5-F7EB-432F-A7CF-2E80322FE2ED}.Debug|Win32.ActiveCfg = SwiftDebug|Win32 - {9CDBFBA5-F7EB-432F-A7CF-2E80322FE2ED}.Debug|Win32.Build.0 = SwiftDebug|Win32 - {9CDBFBA5-F7EB-432F-A7CF-2E80322FE2ED}.Release|Win32.ActiveCfg = SwiftRelease|Win32 - {9CDBFBA5-F7EB-432F-A7CF-2E80322FE2ED}.Release|Win32.Build.0 = SwiftRelease|Win32 - {AB3C8BF7-BF9D-4A80-A956-E969B9D8542D}.Debug|Win32.ActiveCfg = Debug|Win32 - {AB3C8BF7-BF9D-4A80-A956-E969B9D8542D}.Debug|Win32.Build.0 = Debug|Win32 - {AB3C8BF7-BF9D-4A80-A956-E969B9D8542D}.Release|Win32.ActiveCfg = Release|Win32 - {AB3C8BF7-BF9D-4A80-A956-E969B9D8542D}.Release|Win32.Build.0 = Release|Win32 - {7022E28A-B15B-4A61-876A-5962C8EC1219}.Debug|Win32.ActiveCfg = Debug|Win32 - {7022E28A-B15B-4A61-876A-5962C8EC1219}.Debug|Win32.Build.0 = Debug|Win32 - {7022E28A-B15B-4A61-876A-5962C8EC1219}.Release|Win32.ActiveCfg = Release|Win32 - {7022E28A-B15B-4A61-876A-5962C8EC1219}.Release|Win32.Build.0 = Release|Win32 - {4051C912-8C55-442F-9AF8-3F3AE9859776}.Debug|Win32.ActiveCfg = Debug|Win32 - {4051C912-8C55-442F-9AF8-3F3AE9859776}.Debug|Win32.Build.0 = Debug|Win32 - {4051C912-8C55-442F-9AF8-3F3AE9859776}.Release|Win32.ActiveCfg = Release|Win32 - {4051C912-8C55-442F-9AF8-3F3AE9859776}.Release|Win32.Build.0 = Release|Win32 - {73E306B4-6227-4843-8A59-9B85C382790C}.Debug|Win32.ActiveCfg = Debug|Win32 - {73E306B4-6227-4843-8A59-9B85C382790C}.Debug|Win32.Build.0 = Debug|Win32 - {73E306B4-6227-4843-8A59-9B85C382790C}.Release|Win32.ActiveCfg = Release|Win32 - {73E306B4-6227-4843-8A59-9B85C382790C}.Release|Win32.Build.0 = Release|Win32 - {538B76FD-E289-4CF7-A7FF-1ACB429B4F63}.Debug|Win32.ActiveCfg = DebugGalaxy|Win32 - {538B76FD-E289-4CF7-A7FF-1ACB429B4F63}.Debug|Win32.Build.0 = DebugGalaxy|Win32 - {538B76FD-E289-4CF7-A7FF-1ACB429B4F63}.Release|Win32.ActiveCfg = ReleaseGalaxy|Win32 - {538B76FD-E289-4CF7-A7FF-1ACB429B4F63}.Release|Win32.Build.0 = ReleaseGalaxy|Win32 - {6A7673C4-08F4-4490-93A5-5F7211B406CF}.Debug|Win32.ActiveCfg = Debug|Win32 - {6A7673C4-08F4-4490-93A5-5F7211B406CF}.Debug|Win32.Build.0 = Debug|Win32 - {6A7673C4-08F4-4490-93A5-5F7211B406CF}.Release|Win32.ActiveCfg = Release|Win32 - {6A7673C4-08F4-4490-93A5-5F7211B406CF}.Release|Win32.Build.0 = Release|Win32 {596C5D37-C409-4C46-BA28-B7F5EFB96851}.Debug|Win32.ActiveCfg = Debug|Win32 {596C5D37-C409-4C46-BA28-B7F5EFB96851}.Debug|Win32.Build.0 = Debug|Win32 {596C5D37-C409-4C46-BA28-B7F5EFB96851}.Release|Win32.ActiveCfg = Release|Win32 @@ -123,6 +33,10 @@ {8AD2EDB1-F154-40E3-8317-6799592E8B34}.Debug|Win32.Build.0 = Debug|Win32 {8AD2EDB1-F154-40E3-8317-6799592E8B34}.Release|Win32.ActiveCfg = Release|Win32 {8AD2EDB1-F154-40E3-8317-6799592E8B34}.Release|Win32.Build.0 = Release|Win32 + {4051C912-8C55-442F-9AF8-3F3AE9859776}.Debug|Win32.ActiveCfg = Debug|Win32 + {4051C912-8C55-442F-9AF8-3F3AE9859776}.Debug|Win32.Build.0 = Debug|Win32 + {4051C912-8C55-442F-9AF8-3F3AE9859776}.Release|Win32.ActiveCfg = Release|Win32 + {4051C912-8C55-442F-9AF8-3F3AE9859776}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Modified: TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/BotShape.java =================================================================== --- TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/BotShape.java 2007-02-25 14:08:57 UTC (rev 568) +++ TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/BotShape.java 2007-04-05 16:56:50 UTC (rev 569) @@ -47,9 +47,18 @@ * robot goal location in robot's coordinate system (in centimeters) */ protected float goalx, goaly; - protected boolean goal_seeking; /** + * current goal taskid + */ + protected int taskid; + + /** + * current goal status + */ + protected TaskStatus goal_status; + + /** * last known good position and orientation of robot (in centimeters and radians) * when the uncertainty about the robots position and orientation reach some threashhold * we just keep showing this last known good postition @@ -68,6 +77,7 @@ protected static Color unselected_color = Color.RED; protected static Color selected_color = Color.YELLOW; + protected static Color failed_color = Color.WHITE; protected Color distinct_color = null; public static final Font labelFont = new Font("Lucida Sans", Font.BOLD, 14); public static final Font uncertainFont = new Font("Lucida Sans", Font.ITALIC, 14); @@ -76,7 +86,7 @@ public BotShape(String name, ColorGenerator cg) { super(unselected_color, name); if(cg != null) distinct_color = cg.getNextDistinctColor(); - goal_seeking = false; + goal_status = null; makeIcon(); setLocation(0F, 0F, 0F); try { @@ -89,7 +99,7 @@ public BotShape(String name, ColorGenerator cg, int x, int y, float rad) { super(unselected_color, name); if(cg != null) distinct_color = cg.getNextDistinctColor(); - goal_seeking = false; + goal_status = null; makeIcon(); setLocation(0F, 0F, 0F); try { @@ -134,7 +144,7 @@ placedUncertaintyRing = move.createTransformedShape(uncertaintyRing); //reset goal - goal_seeking = false; + goal_status = null; //reset composite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER); @@ -153,7 +163,8 @@ } protected java.awt.Shape getPlacedArrowShape(int dist, float angle) { - int[] xs = new int[] {50, dist-30, dist-30, dist, dist-30, dist-30, 50}; + int tail = (dist > 50? 50: dist-50); + int[] xs = new int[] {tail, dist-30, dist-30, dist, dist-30, dist-30, tail}; int[] ys = new int[] {12, 12, 24, 0, -24, -12, -12}; AffineTransform move = new AffineTransform(placement); move.translate(x,y); @@ -183,22 +194,19 @@ g.setColor(Color.black); g.fill(placedDot); - //draw goal arrow if distance to goal is greater than 1 meter (100 cm) - if(goal_seeking) { + //draw goal arrow + if(goal_status == TaskStatus.FAILED || goal_status == TaskStatus.IN_PROGRESS) { int distance = (int)Math.sqrt((goalx-x)*(goalx-x)+(goaly-y)*(goaly-y)); - if(distance < 100) { - goal_seeking = false; + java.awt.Shape arrow = getPlacedArrowShape(distance, (float)Math.atan2(goaly-y, goalx-x)); + if(goal_status == TaskStatus.FAILED) { + g.setColor(failed_color); + } else if(selected) { + g.setColor(selected_color); } else { - System.err.println("Drawing arrow"); - java.awt.Shape arrow = getPlacedArrowShape(distance, (float)Math.atan2(goaly-y, goalx-x)); - if(selected) { - g.setColor(selected_color); - } else { - g.setColor(unselected_color); - } - if(alpha > 0.5F) g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5F)); - g.fill(arrow); + g.setColor(unselected_color); } + if(alpha > 0.5F) g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5F)); + g.fill(arrow); } //reset graphics context @@ -311,19 +319,38 @@ * @param y y coordinate of robot's frame goal location (in centimeters) */ - public void setGoal(boolean relative, float x, float y) { - System.err.println("Setting goal for bot " + x + ' ' + y); - if(relative) { - float a = (float)Math.atan2(y, x) + rad; - int dist = (int)Math.sqrt(x*x+y*y); - goalx = this.x + (float)Math.cos(a)*dist; - goaly = this.y + (float)Math.sin(a)*dist; - } else { - goalx = x; - goaly = y; + public void setGoal(boolean relative, float x, float y, TaskStatus status, int taskid) { + System.err.println("Setting goal for bot " + x + ' ' + y + ' ' + status); + switch(status) { + case UNSENT: + break; + case UNACKED: + case IN_PROGRESS: + if(relative) { + float a = (float)Math.atan2(-y, x) + rad; + int dist = (int)Math.sqrt(x*x+y*y); + goalx = this.x + (float)Math.cos(a)*dist; + goaly = this.y + (float)Math.sin(a)*dist; + } else { + goalx = x; + goaly = y; + } + System.err.println("goalx " + goalx + " goaly " + goaly); + this.taskid = taskid; + goal_status = status; + break; + case ABANDONED: + case SUCCEEDED: + if(taskid == this.taskid) { + goal_status = null; + } + break; + case FAILED: + if(taskid == this.taskid) { + goal_status = status; + } + break; } - goal_seeking = true; - System.err.println("goalx " + goalx + " goaly " + goaly); } /** Modified: TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/BotTracker.java =================================================================== --- TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/BotTracker.java 2007-02-25 14:08:57 UTC (rev 568) +++ TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/BotTracker.java 2007-04-05 16:56:50 UTC (rev 569) @@ -61,14 +61,14 @@ return bot; } - public void setGoal(java.lang.String name, boolean relative, float x, float y) { + public void setGoal(java.lang.String name, boolean relative, float x, float y, TaskStatus status, int taskid) { name.toUpperCase(); Shape s = bots.get(name); if(s == null || !(s instanceof BotShape)) { System.err.println("odd, bot set goal but can't be found: " + name); } else { BotShape bot = (BotShape) s; - bot.setGoal(relative, x, y); + bot.setGoal(relative, x, y, status, taskid); } } Modified: TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/PenDecoderServer.java =================================================================== --- TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/PenDecoderServer.java 2007-02-25 14:08:57 UTC (rev 568) +++ TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/PenDecoderServer.java 2007-04-05 16:56:50 UTC (rev 569) @@ -92,20 +92,20 @@ return (GFrame)null; } boolean bstatus = (status != 0); - if(bstatus) frame.taskKeeper.succeedtask(taskid); - else frame.taskKeeper.failtask(taskid); + if(bstatus) + frame.taskKeeper.changePendingTaskState(taskid, TaskStatus.SUCCEEDED); + else frame.taskKeeper.changePendingTaskState(taskid, TaskStatus.FAILED); } else if(type.equalsIgnoreCase("ack")) { - frame.taskKeeper.addTask(taskid); + frame.taskKeeper.addTask(taskid, TaskStatus.IN_PROGRESS); } else { System.err.println("unhandled trader message type: " + type); return (GFrame)null; } //String active_rendering = null; - String active_rendering = tk.utils.Utils.join(frame.taskKeeper.getActive(), " "); - //for(Integer i : frame.taskKeeper.getActive()) active_rendering += i.toString() + ' '; - //String succeeded_rendering = null; - String succeeded_rendering = tk.utils.Utils.join(frame.taskKeeper.getSucceeded(), " "); - //for(Integer i : frame.taskKeeper.getSucceeded()) succeeded_rendering += i.toString() + ' '; + String active_rendering = + tk.utils.Utils.join(frame.taskKeeper.get(TaskStatus.IN_PROGRESS), " "); + String succeeded_rendering = + tk.utils.Utils.join(frame.taskKeeper.get(TaskStatus.SUCCEEDED), " "); frame.getInterpreter().print_bot("active tasks", active_rendering); frame.getInterpreter().print_bot("succeeded tasks", succeeded_rendering); return (GFrame) null; @@ -117,8 +117,14 @@ //message come in meters. we operate in centimeter space float x = 100*((Float)f.getProperty(":x")).floatValue(); float y = 100*((Float)f.getProperty(":y")).floatValue(); - - botTracker.setGoal(name, relative, x, y); + int taskid = ((Integer)f.getProperty(":taskid")).intValue(); + TaskStatus status; + try { + status = TaskStatus.valueOf((String)f.getProperty(":status")); + botTracker.setGoal(name, relative, x, y, status, taskid); + } catch (IllegalArgumentException e) { + System.err.println("Can't parse status: " + f.getProperty(":status")); + } return (GFrame) null; } @@ -344,7 +350,6 @@ } pgoNets.addElement(gfNet); } - //pgoNets.setSize(1); //then construct the encompassing slot gfSlot.setProperty(":nets", pgoNets); @@ -353,7 +358,6 @@ gfSlot.setProperty(":contents", hyp); //this is bogus but so what? gfSlot.setProperty(":frame", frame); pgoSlots.addElement(gfSlot); - //pgoSlots.setSize(1); // then construct the encompassing parse gfParse.setProperty(":slots", pgoSlots); @@ -373,11 +377,9 @@ gfParse.setProperty(":avg_validwordconf", 0.0F); gfParse.setProperty(":min_validwordconf", 0.0F); gfParse.setProperty(":max_validwordconf", 0.0F); - gfParse.setProperty(":parsestring", - //frame + "\n" + slot + " ( " + net + " ( " + val + " ) )\n\n"); + gfParse.setProperty(":parsestring", frame + "\n" + slot + " " + parse + "\n\n"); pgoParses.addElement(gfParse); - //pgoParses.setSize(1); f.setProperty(":parses", pgoParses); f.setProperty(":total_numparses", 1); Modified: TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/TaskKeeper.java =================================================================== --- TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/TaskKeeper.java 2007-02-25 14:08:57 UTC (rev 568) +++ TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/TaskKeeper.java 2007-04-05 16:56:50 UTC (rev 569) @@ -10,6 +10,7 @@ package edu.cmu.ravenclaw.pendecoder; +import java.util.EnumMap; import java.util.LinkedList; import java.util.List; @@ -17,53 +18,30 @@ * * @author tkharris */ -public class TaskKeeper { - private List activetasks = new LinkedList(); - private List failedtasks = new LinkedList(); - private List succeededtasks = new LinkedList(); - private List cancelledtasks = new LinkedList(); +public class TaskKeeper extends EnumMap> { /** Creates a new instance of TaskKeeper */ - public TaskKeeper() {} - - public void addTask(Integer taskid) { - activetasks.add(taskid); + public TaskKeeper() { + super(TaskStatus.class); } - public void succeedtask(Integer taskid) { - activetasks.remove(taskid); - succeededtasks.add(taskid); + public void addTask(Integer taskid, TaskStatus status) { + get(status).add(taskid); } - public void failtask(Integer taskid) { - activetasks.remove(taskid); - failedtasks.add(taskid); - } - - //boolean cancelLastTask() { - // if(activetasks.isEmpty()) return false; - // cancelledtasks.add(activetasks.remove(0)); - // return true; - //} - - public List getActive() { - return activetasks; - } - - public List getSucceeded() { - return succeededtasks; - } - - public List getFailed() { - return failedtasks; - } - - public List getCancelled() { - return cancelledtasks; - } - + public void changePendingTaskState(Integer taskid, TaskStatus status) { + if(!get(TaskStatus.IN_PROGRESS).remove(taskid) + && !get(TaskStatus.UNACKED).remove(taskid) + && !get(TaskStatus.UNSENT).remove(taskid)) + System.err.println("couldn't find: " + taskid); + + get(status).add(taskid); + } + public Integer getLastAdded() { - if(activetasks.isEmpty()) return (Integer)null; - return activetasks.get(activetasks.size()-1); + if(get(TaskStatus.IN_PROGRESS).isEmpty()) return (Integer)null; + return get(TaskStatus.IN_PROGRESS).get(get(TaskStatus.IN_PROGRESS).size()-1); } + + private static final long serialVersionUID = 2916483434314857716L; } Modified: TeamTalk/Agents/PrimitiveComm/robot_client.cpp =================================================================== --- TeamTalk/Agents/PrimitiveComm/robot_client.cpp 2007-02-25 14:08:57 UTC (rev 568) +++ TeamTalk/Agents/PrimitiveComm/robot_client.cpp 2007-04-05 16:56:50 UTC (rev 569) @@ -68,7 +68,7 @@ warn << "couldn't reconnect to " << me->getHost() << ':' << me->getPort() << endl; } } - if(!(t%40) && me->hasCamera()) { //send image request every 40 seconds + if(me->hasCamera()) { //send image request every second me->sendReqImage(); } } Modified: TeamTalk/Agents/PrimitiveComm/robot_packet2.cpp =================================================================== --- TeamTalk/Agents/PrimitiveComm/robot_packet2.cpp 2007-02-25 14:08:57 UTC (rev 568) +++ TeamTalk/Agents/PrimitiveComm/robot_packet2.cpp 2007-04-05 16:56:50 UTC (rev 569) @@ -23,26 +23,50 @@ const char* MalformedPacketException::what() throw() {return error.c_str();} -// Msg **************************************************************** +// TaskStatus ********************************************************* -int Msg::boeingStatus(Msg::Status x) +const char* TaskStatus::map_[] = + {"ABANDONED", "FAILED", "UNSENT", "UNACKED", "IN_PROGRESS", "SUCCEEDED"}; + +TaskStatus::TaskStatus() : status_(TaskStatus::UNSENT) {} +TaskStatus::TaskStatus(TaskStatus::Enum x) : status_(x) {} + +int TaskStatus::boeingStatus(TaskStatus x) { - switch(x) { + switch(x.status_) { + case ABORTED: return Boeing::ABORTED; case FAILED: return Boeing::FAILED; + case UNSENT: + case UNACKED: case IN_PROGRESS: return Boeing::INPROGRESS; case SUCCEEDED: return Boeing::SUCCEEDED; - default: error << "unknown status " << (int)x; + default: error << "unknown status " << x; } return 0; } -Msg::Status Msg::statusOfBoeing(int x) +TaskStatus TaskStatus::statusOfBoeing(int x) { - if(x <= Boeing::FAILED) return FAILED; + if(x == Boeing::ABORTED) return TaskStatus(ABORTED); + if(x == Boeing::FAILED) return TaskStatus(FAILED); if(x >= Boeing::SUCCEEDED) return SUCCEEDED; return IN_PROGRESS; } +TaskStatus TaskStatus::operator=(TaskStatus::Enum x) { + status_ = x; + return *this; +} + +TaskStatus::operator const char *() const {return map_[status_];} + +bool TaskStatus::isInProgress() const {return status_ == IN_PROGRESS;} +bool TaskStatus::isFailed() const {return status_ == FAILED;} +bool TaskStatus::isAborted() const {return status_ == ABORTED;} +bool TaskStatus::isSuccess() const {return status_ == SUCCEEDED;} + +// Msg **************************************************************** + int Msg::taskIDCounter = 0; const int Msg::defaultPriority = 1; @@ -130,8 +154,16 @@ if(type == Boeing::ROB_DONE) { debug("packet") << "got: ROB_DONE" << endl; const Boeing::MsgRobDone* bp = reinterpret_cast(m.c_str()); - return new MsgRobDone(sender, tstamp, - bp->taskid, (bp->status == Boeing::SUCCEEDED)); + if(bp->status == Boeing::SUCCEEDED) + return new MsgRobDone(sender, tstamp, bp->taskid, TaskStatus::SUCCEEDED); + else if(bp->status == Boeing::FAILED) + return new MsgRobDone(sender, tstamp, bp->taskid, TaskStatus::FAILED); + else if(bp->status == Boeing::ABORTED) + return new MsgRobDone(sender, tstamp, bp->taskid, TaskStatus::ABORTED); + else { + error << "couldn't get Boeing::ROB_DONE status" << endl; + return NULL; + } } if(type == Boeing::ROB_PLAY_HALT) { warn("packet") << "unhandled type: ROB_PLAY_HALT " << endl; @@ -198,11 +230,19 @@ : Msg(sender), taskID_(taskIDCounter++), priority_(priority) {} //instantiation from Boeing packet MsgCmd::MsgCmd(string sender, double tstamp, int priority, int taskID) -: Msg(sender, tstamp) {} +: Msg(sender, tstamp), taskID_(taskID), priority_(priority), + status_(TaskStatus::IN_PROGRESS) {} int MsgCmd::getTaskID() const {return taskID_;} int MsgCmd::getPriority() const {return priority_;} +void MsgCmd::setStatus(TaskStatus status) {status_ = status;} +void MsgCmd::setStatus(const MsgRobDone* done) { + status_ = done->getStatus(); + sender_ = done->getSender(); +} +TaskStatus MsgCmd::getStatus() const {return status_;} + MsgCmd* MsgCmd::interpretBoeingPlayAction(const Boeing::MsgCmdAction* m, const string& sender, double tstamp) { @@ -239,10 +279,10 @@ string MsgCmd::render() const { ostringstream out; - out << "MsgCmd: "; - out << "sender " << sender_; - out << " priority " << priority_; - out << " tstamp " << tstamp_ << ' '; + out << "MsgCmd: #" << taskID_; + out << " sender(" << sender_; + out << ") priority(" << priority_; + out << ") tstamp(" << tstamp_ << ") "; out << renderBoeingPlayAction(); return out.str(); } @@ -464,21 +504,18 @@ // MsgRobActionAck **************************************************** //normal instantiation -MsgRobActionAck::MsgRobActionAck(int taskID, Status status, string sender) +MsgRobActionAck::MsgRobActionAck(int taskID, TaskStatus 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), status_(statusOfBoeing(status)) {} +: Msg(sender, tstamp), taskID_(taskID), + status_(TaskStatus::statusOfBoeing(status)) {} int MsgRobActionAck::getTaskID() const {return taskID_;} -Msg::Status MsgRobActionAck::getStatus() const {return status_;} +TaskStatus 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_; @@ -486,32 +523,34 @@ } string MsgRobActionAck::renderBoeingPacket() const { - Boeing::MsgActionAck packet = Boeing::MsgActionAck::factory(taskID_, statusOfBoeing(status_)); + Boeing::MsgActionAck packet = + Boeing::MsgActionAck::factory(taskID_, TaskStatus::boeingStatus(status_)); return string(reinterpret_cast(&packet), packet.len); } // MsgRobDone ********************************************************* //normal instantiation -MsgRobDone::MsgRobDone(int taskID, bool success, string sender) -: Msg(sender), taskID_(taskID), success_(success) {} +MsgRobDone::MsgRobDone(int taskID, TaskStatus status, string sender) +: Msg(sender), taskID_(taskID), status_(status) {} //instantiation from a Boeing packet -MsgRobDone::MsgRobDone(string sender, double tstamp, int taskID, bool success) -: Msg(sender, tstamp), taskID_(taskID), success_(success) {} +MsgRobDone::MsgRobDone(string sender, double tstamp, int taskID, TaskStatus status) +: Msg(sender, tstamp), taskID_(taskID), status_(status) {} int MsgRobDone::getTaskID() const {return taskID_;} -bool MsgRobDone::isSuccess() const {return success_;} - +TaskStatus MsgRobDone::getStatus() const {return status_;} + string MsgRobDone::render() const { ostringstream out; - out << "robdone: " << taskID_ << (success_? "SUCCEEDED": "FAILED"); + out << "robdone: " << taskID_ << ' ' << status_; return out.str(); } string MsgRobDone::renderBoeingPacket() const { - Boeing::MsgRobDone packet = Boeing::MsgRobDone::factory(taskID_, success_); + Boeing::MsgRobDone packet = + Boeing::MsgRobDone::factory(taskID_, TaskStatus::boeingStatus(status_)); return string(reinterpret_cast(&packet), packet.len); } @@ -644,6 +683,7 @@ return out << m->render(); } +/* ostream& operator<<(ostream& out, const Msg::Status& x) { switch(x) @@ -662,3 +702,4 @@ } return out; } +*/ \ No newline at end of file Modified: TeamTalk/Agents/PrimitiveComm/robot_packet2.h =================================================================== --- TeamTalk/Agents/PrimitiveComm/robot_packet2.h 2007-02-25 14:08:57 UTC (rev 568) +++ TeamTalk/Agents/PrimitiveComm/robot_packet2.h 2007-04-05 16:56:50 UTC (rev 569) @@ -17,6 +17,8 @@ * * MalformedPacketException -- a packet is unparseble * + * TaskStatus -- task status + * * Msg -- message superclass (abstract) * MsgCmd -- superclass for command messages sent to robots (abstract) * MsgCmdHalt @@ -43,12 +45,26 @@ const char* what() throw(); }; +class TaskStatus { +public: + enum Enum {ABORTED, FAILED, UNSENT, UNACKED, IN_PROGRESS, SUCCEEDED}; +protected: + Enum status_; + static const char* map_[6]; +public: + TaskStatus(); + TaskStatus(TaskStatus::Enum x); + static int boeingStatus(TaskStatus x); + static TaskStatus statusOfBoeing(int x); + TaskStatus operator=(TaskStatus::Enum x); + operator const char*() const; + bool isInProgress() const; + bool isFailed() const; + bool isAborted() const; + bool isSuccess() const; +}; class Msg { -public: - enum Status {FAILED, IN_PROGRESS, SUCCEEDED}; - static int boeingStatus(Status x); - static Status statusOfBoeing(int x); protected: static const int defaultPriority; @@ -72,10 +88,27 @@ virtual string render() const =0; }; +class MsgRobDone : public Msg { +protected: + int taskID_; + TaskStatus status_; +public: + //normal instantiation + MsgRobDone(int taskID, TaskStatus status=TaskStatus::SUCCEEDED, + string sender=string()); + //instantiation from a Boeing packet + MsgRobDone(string sender, double tstamp, int taskID, TaskStatus status); + int getTaskID() const; + TaskStatus getStatus() const; + string render() const; + string renderBoeingPacket() const; +}; + class MsgCmd : public Msg { protected: int taskID_; int priority_; + TaskStatus status_; //normal instantiation MsgCmd(); @@ -88,6 +121,11 @@ int getPriority() const; static MsgCmd* interpretBoeingPlayAction(const Boeing::MsgCmdAction* m, const string& sender, double tstamp); + + void setStatus(TaskStatus status); + void setStatus(const MsgRobDone* done); + TaskStatus getStatus() const; + string renderBoeingPacket() const; virtual string renderBoeingPlayAction() const =0; string render() const; @@ -120,6 +158,7 @@ float getX() const; float getY() const; float getAngle() const; + float getDistance() const; bool useAngle() const; bool isAbsolute() const; bool isRelative() const; @@ -219,36 +258,18 @@ class MsgRobActionAck : public Msg { protected: int taskID_; - Status status_; + TaskStatus status_; public: //normal instantiation - MsgRobActionAck(int taskID, Status status, string sender=string()); + MsgRobActionAck(int taskID, TaskStatus 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; + TaskStatus getStatus() const; string render() const; string renderBoeingPacket() const; }; -class MsgRobDone : public Msg { -protected: - int taskID_; - bool success_; -public: - //normal instantiation - MsgRobDone(int taskID, bool success=true, string sender=string()); - //instantiation from a Boeing packet - MsgRobDone(string sender, double tstamp, int taskID, bool success); - int getTaskID() const; - bool isSuccess() const; - string render() const; - string renderBoeingPacket() const; -}; - class MsgRobLocation : public Msg { protected: static const float tolerance; @@ -312,6 +333,5 @@ }; ostream& operator<<(ostream& out, const Msg* m); -ostream& operator<<(ostream& out, const Msg::Status& x); #endif Modified: TeamTalk/Agents/TeamTalkBackend/agent.cpp =================================================================== --- TeamTalk/Agents/TeamTalkBackend/agent.cpp 2007-02-25 14:08:57 UTC (rev 568) +++ TeamTalk/Agents/TeamTalkBackend/agent.cpp 2007-04-05 16:56:50 UTC (rev 569) @@ -1,10 +1,14 @@ #include "agent.h" #include +#ifdef WIN32 +#include +#endif #include #include #include #include +#include #define USE_TXT_COMMANDS @@ -73,6 +77,13 @@ serverChildren_.push(spawn(false, cfilename, ".", DM, args.str()).hProcess); } +vector::iterator Agent::findMsgById(int taskid) { + vector::iterator i; + for(i = commitments_.begin(); i != commitments_.end(); i++) + if((*i)->getTaskID() == taskid) break; + return i; +} + string Agent::writeSpecializedConfig(const string temp, const string ext, const map& subs, const string name) @@ -127,6 +138,8 @@ Gal_SetProp(f, ":relative", Gal_IntObject(move->isRelative()? 1: 0)); Gal_SetProp(f, ":x", Gal_FloatObject((float)move->getX())); Gal_SetProp(f, ":y", Gal_FloatObject((float)move->getY())); + Gal_SetProp(f, ":status", Gal_StringObject(move->getStatus())); + Gal_SetProp(f, ":taskid", Gal_IntObject(move->getTaskID())); return f; } @@ -148,6 +161,7 @@ Gal_SetProp(f, ":relative", Gal_IntObject(0)); Gal_SetProp(f, ":x", Gal_FloatObject(0)); Gal_SetProp(f, ":y", Gal_FloatObject(0)); + Gal_SetProp(f, ":status", Gal_StringObject(home->getStatus())); return f; } @@ -157,6 +171,7 @@ f = Gal_MakeFrame("robot_message", GAL_CLAUSE); Gal_SetProp(f, ":type", Gal_StringObject("follow")); Gal_SetProp(f, ":robot_name", Gal_StringObject(follow->getSender().c_str())); + Gal_SetProp(f, ":status", Gal_StringObject(follow->getStatus())); //string host = follow->content()->leader; //string::size_type i = host.find(':'); //int port = 0; @@ -183,6 +198,7 @@ } Gal_SetProp(f, ":x", Gal_ListObject(xs, (int)polygon.size())); Gal_SetProp(f, ":y", Gal_ListObject(ys, (int)polygon.size())); + Gal_SetProp(f, ":status", Gal_StringObject(cover->getStatus())); return f; } @@ -227,12 +243,29 @@ void Agent::processMessage(const Msg* m) { + Gal_Frame f; const MsgRobLocation *rloc = dynamic_cast(m); if(rloc != NULL) { if(location_ == *rloc) return; location_ = *rloc; } - Gal_Frame f = galaxyFrame(m); + const MsgCmdGoTo *move = dynamic_cast(m); + if(move != NULL) SendMoveStatusToDM(move); + const MsgRobDone *done = dynamic_cast(m); + if(done != NULL) { + vector::iterator i = findMsgById(done->getTaskID()); + if(i == commitments_.end()) { + error << "Can't fine msg with taskid: " << done->getTaskID() << endl; + return; + } else { + (*i)->setStatus(done); + f = galaxyFrame(*i); + const MsgCmdGoTo* move = dynamic_cast(*i); + if(move != NULL) SendMoveStatusToDM(move); + delete *i; + commitments_.erase(i); + } + } else f = galaxyFrame(m); char *frame_name = Gal_FrameName(f); if(frame_name != NULL && !strcmp(frame_name, "robot_message")) { debug << "sending to '" << name_ << "' hub: " << m->render() << endl; @@ -250,8 +283,18 @@ // message towards the DM: The message will be // emulating a phoenix parse, of the form // RobotMessage [RobotMessage] ( [MsgType] ( Message ) ) -void Agent::SendMessageToDM(string sMsgType, string sMessage) const +void Agent::SendMessageToDM(const string& sMsgType, const string& sMessage) const { + map sMessages; + sMessages[sMsgType] = sMessage; + SendMessageToDM("RobotMessage", sMessages); +} + +// [2007-04-02] (tk): modified to construct a message with multiple nets, i.e.: +// RobotMessage [sMsgType] ( [Var1] ( Val1 ) [Var2] ( Val2 )... ) ) +void Agent::SendMessageToDM(const string& sMsgType, + const map& sMessages) const +{ // variables holding the nested galaxy parse frame Gal_Frame gfInput, gfParse, gfSlot, gfNet; Gal_Object *pgoParses, *pgoSlots, *pgoNets; @@ -265,20 +308,33 @@ pgoSlots = (Gal_Object *)malloc(sizeof(Gal_Object)); gfSlot = Gal_MakeFrame("slot", GAL_CLAUSE); - pgoNets = (Gal_Object *)malloc(sizeof(Gal_Object)); - gfNet = Gal_MakeFrame("net", GAL_CLAUSE); + pgoNets = (Gal_Object *)calloc(sMessages.size(), sizeof(Gal_Object)); - // construct the net - string sNetName = " " + sMsgType + " "; - Gal_SetProp(gfNet, ":name", Gal_StringObject(sNetName.c_str())); - Gal_SetProp(gfNet, ":contents", Gal_StringObject(sMessage.c_str())); - pgoNets[0] = Gal_FrameObject(gfNet); + string hyp; + string parse; + // construct the nets + map::const_iterator smi = sMessages.begin(); + for(int i = 0; smi != sMessages.end(); smi++, i++) { + if(i) { + hyp.append(" "); + parse.append(" "); + } + gfNet = Gal_MakeFrame("net", GAL_CLAUSE); + string sNetName = " " + smi->first + " "; + Gal_SetProp(gfNet, ":name", Gal_StringObject(sNetName.c_str())); + Gal_SetProp(gfNet, ":contents", Gal_StringObject(smi->second.c_str())); + hyp.append(smi->second); + parse.append("( " + smi->first + "( " + smi->second + " ) )"); + pgoNets[i] = Gal_FrameObject(gfNet); + } + // then construct the encompassing slot - Gal_SetProp(gfSlot, ":nets", Gal_ListObject(pgoNets, 1)); - Gal_SetProp(gfSlot, ":numnets", Gal_IntObject(1)); - Gal_SetProp(gfSlot, ":name", Gal_StringObject(" RobotMessage ")); - Gal_SetProp(gfSlot, ":contents", Gal_StringObject(sMessage.c_str())); + Gal_SetProp(gfSlot, ":nets", Gal_ListObject(pgoNets, (int)sMessages.size())); + Gal_SetProp(gfSlot, ":numnets", Gal_IntObject((int)sMessages.size())); + string sNetName = " " + sMsgType + " "; + Gal_SetProp(gfSlot, ":name", Gal_StringObject(sNetName.c_str())); + Gal_SetProp(gfSlot, ":contents", Gal_StringObject(hyp.c_str())); Gal_SetProp(gfSlot, ":frame", Gal_StringObject(" RobotMessage ")); pgoSlots[0] = Gal_FrameObject(gfSlot); @@ -286,7 +342,7 @@ Gal_SetProp(gfParse, ":slots", Gal_ListObject(pgoSlots, 1)); Gal_SetProp(gfParse, ":numslots", Gal_IntObject(1)); Gal_SetProp(gfParse, ":uttid", Gal_StringObject("-1")); - Gal_SetProp(gfParse, ":hyp", Gal_StringObject(sMessage.c_str())); + Gal_SetProp(gfParse, ":hyp", Gal_StringObject(hyp.c_str())); Gal_SetProp(gfParse, ":hyp_index", Gal_IntObject(0)); Gal_SetProp(gfParse, ":hyp_num_parses", Gal_IntObject(1)); Gal_SetProp(gfParse, ":decoder_score", Gal_FloatObject(0)); @@ -300,22 +356,63 @@ Gal_SetProp(gfParse, ":avg_validwordconf", Gal_FloatObject(0)); Gal_SetProp(gfParse, ":min_validwordconf", Gal_FloatObject(0)); Gal_SetProp(gfParse, ":max_validwordconf", Gal_FloatObject(0)); - string sParseString = "RobotMessage [RobotMessage] ( [" + - sMsgType + "] ( " + sMessage + " ) )\n\n"; + string sParseString = "RobotMessage \n" + sMsgType + " " + parse + "\n\n"; Gal_SetProp(gfParse, ":parsestring", Gal_StringObject(sParseString.c_str())); pgoParses[0] = Gal_FrameObject(gfParse); Gal_SetProp(gfInput, ":parses", Gal_ListObject(pgoParses, 1)); Gal_SetProp(gfInput, ":total_numparses", Gal_IntObject(1)); - Gal_SetProp(gfInput, ":input_source", Gal_StringObject("zap2Backend")); + Gal_SetProp(gfInput, ":input_source", Gal_StringObject("TeamTalkBackend")); // finally, write it to the hub - //writeFrameAllHubs(gfInput); writeFrame(gfInput); + + //and free everything + Gal_FreeFrame(gfInput); + free(pgoParses); + free(pgoSlots); + free(pgoNets); } +void Agent::SendMoveStatusToDM(const MsgCmdGoTo* move) const { + ostringstream move_report; + if(move->useAngle()) { + move_report << "Turn in place"; + float angle = abs(fmodf(move->getAngle(), 2*(float)PI)); + const float tol = (float)PI/8; + if(angle < PI-tol/2) move_report << " right"; + else if(angle > PI+tol/2) move_report << " left"; + move_report << ' ' << (int)(angle*180/PI) << " degrees"; + } else if(move->isAbsolute()) { + move_report << "Movement to " << (int)move->getX() << ' ' << (int)move->getY(); + } else { + move_report << "Movement"; + float angle = (float)Point(move->getX(), move->getY()).angle(); + int cardinal = (int)((fmodf(angle + (float)PI/4, (float)PI)+PI)*2/PI); + debug << angle << ' ' << angle + (float)PI/4 << ' ' << fmodf(angle + (float)PI/4, (float)PI) + << ' ' << fmodf(angle + (float)PI/4, (float)PI) + << ' ' << fmodf(angle + (float)PI/4, (float)PI)+PI + << ' ' << (fmodf(angle + (float)PI/4, (float)PI)+PI)*2/PI + << ' ' << cardinal << endl; + const char* dir[4] = {" backward", " to the right", " forward", " to the left"}; + move_report << ' ' << dir[cardinal]; + float distance = round((float)Point(move->getX(), move->getY()).length()*10)/10; + int major_d = (int)distance; + int minor_d = (int)(distance-major_d); + move_report << ' ' << major_d; + if(minor_d) move_report << '.' << minor_d; + move_report << " meters"; + } + if(move->getStatus().isAborted()) move_report << " has been abandoned."; + else if(move->getStatus().isFailed()) move_report << " has failed."; + else if(move->getStatus().isInProgress()) move_report << " is now in progress."; + else if(move->getStatus().isSuccess()) move_report << " has been successfully completed."; + SendMessageToDM("MOVE", move_report.str()); +} + bool Agent::sendAction(const MsgCmd* cmd) { + debug << "sending: " << cmd << endl; return robotClient_->sendAction(cmd->getPriority(), cmd->getTaskID(), cmd->renderBoeingPlayAction().c_str()); @@ -434,6 +531,7 @@ s_direction == "BACKWARDS") go = new MsgCmdGoTo(vec.rotate(PI)); if(go != NULL) { + commitments_.push_back(new MsgCmdGoTo(*go)); #ifdef USE_TXT_COMMANDS sendAction(go); #else Modified: TeamTalk/Agents/TeamTalkBackend/agent.h =================================================================== --- TeamTalk/Agents/TeamTalkBackend/agent.h 2007-02-25 14:08:57 UTC (rev 568) +++ TeamTalk/Agents/TeamTalkBackend/agent.h 2007-04-05 16:56:50 UTC (rev 569) @@ -26,10 +26,13 @@ MsgRobLocation location_; string name_; + vector commitments_; + protected: static void spawnHub(const string& uppername); static void spawnHelios(const string& uppername); static void spawnDM(const string& uppername, const string& safeness); + vector::iterator findMsgById(int taskid); public: static stack serverChildren_; @@ -58,8 +61,15 @@ // message towards the DM: The message will be // emulating a phoenix parse, of the form // RobotMessage [RobotMessage] ( [MsgType] ( Message ) ) - void SendMessageToDM(string sMsgType, string sMessage) const; + void SendMessageToDM(const string& sMsgType, const string& sMessage) const; + // [2007-04-02] (tk): emulate a little more complicated parse + // RobotMessage [RobotMessage] ( [MsgType] ( [Var1] (Val1) [Var2] (Val2)... )) + void SendMessageToDM(const string& sMsgType, + const map& sMessages) const; + + void SendMoveStatusToDM(const MsgCmdGoTo* move) const; + //processing incoming TeamTalk messages void processMessage(const Msg* m); static Gal_Frame galaxyFrame(const Msg* msgp); Modified: TeamTalk/Agents/TeamTalkBackend/gal_be.cpp =================================================================== --- TeamTalk/Agents/TeamTalkBackend/gal_be.cpp 2007-02-25 14:08:57 UTC (rev 568) +++ TeamTalk/Agents/TeamTalkBackend/gal_be.cpp 2007-04-05 16:56:50 UTC (rev 569) @@ -93,12 +93,15 @@ const char *user_id = Gal_GetString(f, ":user_id"); if(!user_id) error << "no user_id" << endl; else if(!strcmp(user_id, "TeamTalk")) { + debug << "reinit: setting skeleton comm" << endl; galaxyRobots->setSkeletonComm(GalSS_EnvComm((GalSS_Environment*)server_data)); restartDecoder(); galaxyRobots->setRobotVoices(); } - else + else { + debug << "reinit: adding robot" << endl; galaxyRobots->addRobot(user_id, GalSS_EnvComm((GalSS_Environment*)server_data)); + } return f; } Modified: TeamTalk/Agents/TeamTalkBackend/robot-galaxy_adapter.cpp =================================================================== --- TeamTalk/Agents/TeamTalkBackend/robot-galaxy_adapter.cpp 2007-02-25 14:08:57 UTC (rev 568) +++ TeamTalk/Agents/TeamTalkBackend/robot-galaxy_adapter.cpp 2007-04-05 16:56:50 UTC (rev 569) @@ -3,8 +3,9 @@ #include //adds undiscoverable robots from a file -void GalaxyRobots::processPeerfile(const string& fname) +vector GalaxyRobots::processPeerfile(const string& fname) { + vector names; debug << "about to add robots" << endl; ifstream Frobotips(fname.c_str()); if(!Frobotips) error << "problem opening " << fname << endl; @@ -40,6 +41,8 @@ info << "adding robot@" << rip << ':' << port << ' ' << voice << ' ' << safeness << endl; if(!r_client->addRobot(rname, rip, voice, safeness, port, this)) { error << "couldn't add " << rname << endl; + } else { + names.push_back(rname); } } } catch(TeamTalk::RobotClientException e) { @@ -47,18 +50,26 @@ error << e.what() << endl; } } + return names; } -void GalaxyRobots::addRobotNamesToGrammar() +void GalaxyRobots::addRobotNamesToGrammar(const vector& names) { + debug << "adding robot names to grammar:"; map subs; { ostringstream gname; + /* for(set::const_iterator i = agents_.begin(); i != agents_.end(); i++) { gname << " (" << tolower(i->getName()) << ')' << endl; + */ + for(vector::const_iterator i = names.begin(); i != names.end(); i++) { + gname << " (" << tolower(*i) << ')' << endl; } subs["%%RobotNames%%"] = gname.str(); + debug << ' ' << gname.str(); } + debug << endl; Agent::writeSpecializedConfig("..\\..\\Resources\\Grammar\\zap2Task", "gra", subs); @@ -241,10 +252,10 @@ //startup robot client TeamTalk::RobotClient::spawnback = &Agent::spawnMinorGalaxy; r_client = new TeamTalk::RobotsClient("tester"); - processPeerfile("peerfile.txt"); + vector names = processPeerfile("peerfile.txt"); if(!testLastConfig("peerfile.txt", "..\\..\\Resources\\DecoderConfig\\LanguageModel\\zap2LM.arpa")) - addRobotNamesToGrammar(); + addRobotNamesToGrammar(names); if(!m_client->isConnected()) { fatal << "mapserver not found" << endl; } else if(!m_client->sendSubscribe(0)) { Modified: TeamTalk/Agents/TeamTalkBackend/robot-galaxy_adapter.h =================================================================== --- TeamTalk/Agents/TeamTalkBackend/robot-galaxy_adapter.h 2007-02-25 14:08:57 UTC (rev 568) +++ TeamTalk/Agents/TeamTalkBackend/robot-galaxy_adapter.h 2007-04-05 16:56:50 UTC (rev 569) @@ -16,8 +16,8 @@ Boeing::MapClient *m_client; //the map server protected: - void processPeerfile(const string& fname); - void addRobotNamesToGrammar(); + vector processPeerfile(const string& fname); + void addRobotNamesToGrammar(const vector&); //static bool testLastConfig(const string& source, const string& target); Modified: TeamTalk/Agents/TeamTalkDM/zap2DialogTask.cpp =================================================================== --- TeamTalk/Agents/TeamTalkDM/zap2DialogTask.cpp 2007-02-25 14:08:57 UTC (rev 568) +++ TeamTalk/Agents/TeamTalkDM/zap2DialogTask.cpp 2007-04-05 16:56:50 UTC (rev 569) @@ -307,6 +307,7 @@ BOOL_USER_CONCEPT(report_command_issued, "") BOOL_USER_CONCEPT(report_location_command_issued, "") STRING_SYSTEM_CONCEPT(location_report) + STRING_SYSTEM_CONCEPT(move_report) BOOL_USER_CONCEPT(move_cardinal_command_issued, "") BOOL_USER_CONCEPT(move_relative_command_issued, "") BOOL_USER_CONCEPT(move_to_goal_command_issued, "") @@ -330,7 +331,8 @@ SUBAGENT(MoveToGoal, CMoveToGoal, "") SUBAGENT(Search, CSearch, "") SUBAGENT(Explore, CExplore, "") - SUBAGENT(MoveRelative, CMoveRelative, "") + SUBAGENT(CommandMoveRelative, CCommandMoveRelative, "") + SUBAGENT(ReportMove, CReportMove, "") SUBAGENT(Halt, CHalt, "") SUBAGENT(Follow, CFollow, "") SUBAGENT(Pause, CPause, "") @@ -452,7 +454,7 @@ DEFINE_AGENCY(CMoveCardinal, DEFINE_CONCEPTS( STRING_USER_CONCEPT(distance, "expl") - STRING_USER_CONCEPT(direction, "expl") + STRING_USER_CONCEPT(direction, "expl") STRING_SYSTEM_CONCEPT(report) ) PRECONDITION(IS_TRUE(move_cardinal_command_issued) @@ -470,27 +472,26 @@ ) //----------------------------------------------------------------------------- -// /zap2/Task/MoveRelative +// /zap2/Task/CommandMoveRelative //----------------------------------------------------------------------------- -DEFINE_AGENCY(CMoveRelative, +DEFINE_AGENCY(CCommandMoveRelative, DEFINE_CONCEPTS( - STRING_USER_CONCEPT(direction, "expl") + STRING_USER_CONCEPT(direction, "expl") STRING_USER_CONCEPT(distance, "expl") STRING_USER_CONCEPT(units, "") - STRING_SYSTEM_CONCEPT(report) + STRING_SYSTEM_CONCEPT(report) ) PRECONDITION(IS_TRUE(move_relative_command_issued) && (UPDATED(distance) || UPDATED(direction)) && - (*C("current_addressee").CreateMergedHistoryConcept() == C("robot_name") || + (*C("current_addressee").CreateMergedHistoryConcept() == C("robot_name") || *C("current_addressee").CreateMergedHistoryConcept() == C("everyone"))) DEFINE_SUBAGENTS( SUBAGENT(ExpectMoveRelativeCommand, CExpectMoveRelativeCommand, "") SUBAGENT(RequestMoveDirection, CRequestMoveDirection, "") SUBAGENT(RequestRelativeDistance, CRequestRelativeDistance, "") SUBAGENT(ExecuteRelativeMove, CExecuteRelativeMove, "") - SUBAGENT(InformReaction2Move, CInformReaction2Move, "") ) - SUCCEEDS_WHEN(COMPLETED(InformReaction2Move) || UPDATED_IN_LAST_TURN(cancel)) + SUCCEEDS_WHEN(COMPLETED(ExecuteRelativeMove) || UPDATED_IN_LAST_TURN(cancel)) ) //----------------------------------------------------------------------------- @@ -574,6 +575,37 @@ ) //----------------------------------------------------------------------------- +// /zap2/Task/ReportMove +//----------------------------------------------------------------------------- +DEFINE_AGENCY(CReportMove, + PRECONDITION(UPDATED(move_report) && + (*C("current_addressee").CreateMergedHistoryConcept() == C("robot_name") || + *C("current_addressee").CreateMergedHistoryConcept() == C("everyone"))) + DEFINE_SUBAGENTS( + SUBAGENT(ExpectReportMove, CExpectReportMove, "") + SUBAGENT(InformMove, CInformMove, "") + ) +) + +//----------------------------------------------------------------------------- +// /zap2/Task/ReportMove/ExpectReportMove +//----------------------------------------------------------------------------- +DEFINE_EXPECT_AGENT(CExpectReportMove, + EXPECT_CONCEPT(move_report) + EXPECT_WHEN( + (*C("current_addressee").CreateMergedHistoryConcept() == C("robot_name") || + *C("current_addressee").CreateMergedHistoryConcept() == C("everyone"))) + GRAMMAR_MAPPING("[RobotMessage.Move]") +) + +//----------------------------------------------------------------------------- +// /zap2/Task/ReportMove/InformMove +//----------------------------------------------------------------------------- +DEFINE_INFORM_AGENT(CInformMove, + PROMPT("inform report_move_status "Roger that!", "report_move_to_goal" => "going to .", - "report_move_relative" => "going meters.", + "report_move" => ["This is . ", + " here. "], # verbal reaction to search command "report_search" => "I am organizing a search party for the specified area.", Modified: TeamTalk/Agents/boeingLib/boeing/boeing_net.h =================================================================== --- TeamTalk/Agents/boeingLib/boeing/boeing_net.h 2007-02-25 14:08:57 UTC (rev 568) +++ TeamTalk/Agents/boeingLib/boeing/boeing_net.h 2007-04-05 16:56:50 UTC (rev 569) @@ -71,6 +71,7 @@ // standard status returns + static const int16_t ABORTED = -2; static const int16_t FAILED = -1; static const int16_t INPROGRESS = 0; static const int16_t SUCCEEDED = 1; Modified: TeamTalk/Agents/boeingLib/coralshared/win32dep.cc =================================================================== --- TeamTalk/Agents/boeingLib/coralshared/win32dep.cc 2007-02-25 14:08:57 UTC (rev 568) +++ TeamTalk/Agents/boeingLib/coralshared/win32dep.cc 2007-04-05 16:56:50 UTC (rev 569) @@ -2,6 +2,8 @@ #include "win32dep.h" +#include + int gettimeofday (struct timeval *tv, void* tz) { union { @@ -15,4 +17,13 @@ return (0); } +float round(float x) { + float major = floor(x); + float minor = x-major; + if(abs(minor >= 0.5)) + if(major >=0) return major+1; + else return major-1; + else return major; +} + #endif Modified: TeamTalk/Agents/boeingLib/coralshared/win32dep.h =================================================================== --- TeamTalk/Agents/boeingLib/coralshared/win32dep.h 2007-02-25 14:08:57 UTC (rev 568) +++ TeamTalk/Agents/boeingLib/coralshared/win32dep.h 2007-04-05 16:56:50 UTC (rev 569) @@ -11,6 +11,7 @@ #define sleep(x) Sleep(1000*(x)) int gettimeofday (struct timeval *tv, void* tz); +float round(float x); #define _USE_MATH_DEFINES Modified: TeamTalk/Configurations/DesktopConfiguration/TeamTalk-hub-desktop-skeleton.pgm =================================================================== --- TeamTalk/Configurations/DesktopConfiguration/TeamTalk-hub-desktop-skeleton.pgm 2007-02-25 14:08:57 UTC (rev 568) +++ TeamTalk/Configurations/DesktopConfiguration/TeamTalk-hub-desktop-skeleton.pgm 2007-04-05 16:56:50 UTC (rev 569) @@ -33,7 +33,7 @@ ;; ------------------------------------------------- SERVER: PenDecoder at localhost:11002 -OPERATIONS: set_bot set_goal set_halt set_follow set_cover speak map_update image info_update task_update +OPERATIONS: set_cover speak map_update info_update task_update INIT: :greeting "Welcome to the CMU zap 2.0 PenDecoder!" ;; ------------------------------------------------- @@ -153,10 +153,6 @@ IN: :robot_name :x :y OUT: -RULE: :type = "image" --> PenDecoder.image -IN: :robot_name :width :height :invoice :jpeg -OUT: - PROGRAM: restart_decoder RULE: --> sphinx.restart_decoder IN: Modified: TeamTalk/Configurations/DesktopConfiguration/TeamTalk-hub-desktop-template.pgm =================================================================== --- TeamTalk/Configurations/DesktopConfiguration/TeamTalk-hub-desktop-template.pgm 2007-02-25 14:08:57 UTC (rev 568) +++ TeamTalk/Configurations/DesktopConfiguration/TeamTalk-hub-desktop-template.pgm 2007-04-05 16:56:50 UTC (rev 569) @@ -33,7 +33,7 @@ ;; ------------------------------------------------- SERVER: PenDecoder at localhost:11002 -OPERATIONS: set_bot speak process_parse select_bot +OPERATIONS: set_bot speak process_parse select_bot image set_goal INIT: :greeting "Welcome to the %%DialogManager%%!" ;; ------------------------------------------------- @@ -240,7 +240,7 @@ OUT: RULE: :type = "goal" --> PenDecoder.set_goal -IN: :robot_name :relative :x :y +IN: :robot_name :relative :x :y :status :taskid OUT: RULE: :type = "halt" --> PenDecoder.set_halt @@ -248,11 +248,11 @@ OUT: RULE: :type = "follow" --> PenDecoder.set_follow -IN: :robot_name :followee +IN: :robot_name :followee :status OUT: RULE: :type = "cover" --> PenDecoder.set_cover -IN: :robot_name :x :y +IN: :robot_name :x :y :status OUT: RULE: :type = "image" --> PenDecoder.image From tk at edam.speech.cs.cmu.edu Thu Apr 5 14:34:29 2007 From: tk at edam.speech.cs.cmu.edu (tk@edam.speech.cs.cmu.edu) Date: Thu, 5 Apr 2007 14:34:29 -0400 Subject: [TeamTalk 33]: [570] TeamTalk/Agents/boeingLib/boeing: Added sendAborted() Message-ID: <200704051834.l35IYTHP000896@edam.speech.cs.cmu.edu> An HTML attachment was scrubbed... URL: http://mailman.srv.cs.cmu.edu/pipermail/teamtalk-developers/attachments/20070405/aa2536e0/attachment.html -------------- next part -------------- Modified: TeamTalk/Agents/boeingLib/boeing/boeing_robot_packet.h =================================================================== --- TeamTalk/Agents/boeingLib/boeing/boeing_robot_packet.h 2007-04-05 16:56:50 UTC (rev 569) +++ TeamTalk/Agents/boeingLib/boeing/boeing_robot_packet.h 2007-04-05 18:34:29 UTC (rev 570) @@ -226,6 +226,7 @@ status - task status [Succeeded,Failed] */ struct MsgRobDone : public MsgHeader { + TaskID taskid; //task that has been completed int16_t status; static MsgRobDone factory(TaskID taskID, int16_t status) { Modified: TeamTalk/Agents/boeingLib/boeing/boeing_robot_server.cc =================================================================== --- TeamTalk/Agents/boeingLib/boeing/boeing_robot_server.cc 2007-04-05 16:56:50 UTC (rev 569) +++ TeamTalk/Agents/boeingLib/boeing/boeing_robot_server.cc 2007-04-05 18:34:29 UTC (rev 570) @@ -246,7 +246,6 @@ { MsgRobDone msg; - // msg.taskid = taskid; if (ok) msg.status = SUCCEEDED; else @@ -262,6 +261,16 @@ return (doSend((MsgHeader *) &msg)); } + bool RobotServer::sendAborted(int taskid) + { + MsgRobDone msg = MsgRobDone::factory(taskid, ABORTED); + + if (server_debug) + printf("sending done %i\n", ABORTED); + + return (doSend((MsgHeader *) &msg)); + } + bool RobotServer::sendLocation(float x, float y, float a, bool moving) { MsgRobLocation msg; @@ -288,7 +297,7 @@ return socket_s->getStatus() == UDPSocket::Server; } - bool RobotServer::sendJPEGImage(const unsigned char *image, int image_size, + bool RobotServer::sendJPEGImage(const void *image, int image_size, int width, int height, int invoice) { MsgMap *msg = (MsgMap *)malloc(sizeof(MsgMap)-sizeof(int)+image_size); Modified: TeamTalk/Agents/boeingLib/boeing/boeing_robot_server.h =================================================================== --- TeamTalk/Agents/boeingLib/boeing/boeing_robot_server.h 2007-04-05 16:56:50 UTC (rev 569) +++ TeamTalk/Agents/boeingLib/boeing/boeing_robot_server.h 2007-04-05 18:34:29 UTC (rev 570) @@ -58,6 +58,7 @@ /// send a task done bool sendDone(int taskid,bool ok); + bool sendAborted(int taskid); /// send the updated robot pose bool sendLocation(float x, float y, float a, bool moving); @@ -66,7 +67,7 @@ the image is a pointer to a jpeg image file the image size is the size of the image file in bytes */ - bool sendJPEGImage(const unsigned char *image, int image_size, + bool sendJPEGImage(const void *image, int image_size, int width, int height, int invoice); //=== Accessors ======================================== From tk at edam.speech.cs.cmu.edu Thu Apr 5 14:44:24 2007 From: tk at edam.speech.cs.cmu.edu (tk@edam.speech.cs.cmu.edu) Date: Thu, 5 Apr 2007 14:44:24 -0400 Subject: [TeamTalk 34]: [571] TeamTalk/Agents/PrimitiveComm: Fixed resume execution. Message-ID: <200704051844.l35IiOf9000913@edam.speech.cs.cmu.edu> An HTML attachment was scrubbed... URL: http://mailman.srv.cs.cmu.edu/pipermail/teamtalk-developers/attachments/20070405/21e7bc1c/attachment.html -------------- next part -------------- Modified: TeamTalk/Agents/PrimitiveComm/Makefile =================================================================== --- TeamTalk/Agents/PrimitiveComm/Makefile 2007-04-05 18:34:29 UTC (rev 570) +++ TeamTalk/Agents/PrimitiveComm/Makefile 2007-04-05 18:44:23 UTC (rev 571) @@ -2,6 +2,10 @@ INCLUDES = -I. -I$(BOEINGLIB_DIR)/boeing -I$(BOEINGLIB_DIR)/coralshared +ifdef $(WIN32) + INCLUDES += -Iwincompat +endif + VERBOSE = 1 DEP_ECHO = @echo Dependency: $@ @@ -24,11 +28,11 @@ LIBRARIES = libboeingrobotserver.a +all: $(LIBRARIES) + # Include the dependencies -include $(OBJECTS:.o=.d) -all: $(LIBRARIES) - libboeingrobotserver.a: $(OBJECTS) $(LINK_ECHO) $(Q)ar cru $@ $(OBJECTS) Modified: TeamTalk/Agents/PrimitiveComm/robot_packet2.cpp =================================================================== --- TeamTalk/Agents/PrimitiveComm/robot_packet2.cpp 2007-04-05 18:34:29 UTC (rev 570) +++ TeamTalk/Agents/PrimitiveComm/robot_packet2.cpp 2007-04-05 18:44:23 UTC (rev 571) @@ -256,7 +256,7 @@ if(action_head == "pause") return new MsgCmdPause(sender, tstamp, m->priority, m->taskid, m->action); if(action_head == "resume") - return new MsgCmdPause(sender, tstamp, m->priority, m->taskid, m->action); + return new MsgCmdResume(sender, tstamp, m->priority, m->taskid, m->action); if(action_head == "follow") return new MsgCmdFollow(sender, tstamp, m->priority, m->taskid, m->action); if(action_head == "cover") @@ -702,4 +702,4 @@ } return out; } -*/ \ No newline at end of file +*/ From tk at edam.speech.cs.cmu.edu Thu Apr 5 15:17:43 2007 From: tk at edam.speech.cs.cmu.edu (tk@edam.speech.cs.cmu.edu) Date: Thu, 5 Apr 2007 15:17:43 -0400 Subject: [TeamTalk 35]: [572] TeamTalk/Agents/TeamTalkSimulator: Added ImageClient exception Message-ID: <200704051917.l35JHhZM000946@edam.speech.cs.cmu.edu> An HTML attachment was scrubbed... URL: http://mailman.srv.cs.cmu.edu/pipermail/teamtalk-developers/attachments/20070405/507b8f35/attachment-0001.html -------------- next part -------------- Property changes on: TeamTalk/Agents/TeamTalkSimulator ___________________________________________________________________ Name: svn:ignore + TeamTalkSimulator *.d Modified: TeamTalk/Agents/TeamTalkSimulator/Makefile =================================================================== --- TeamTalk/Agents/TeamTalkSimulator/Makefile 2007-04-05 18:44:23 UTC (rev 571) +++ TeamTalk/Agents/TeamTalkSimulator/Makefile 2007-04-05 19:17:43 UTC (rev 572) @@ -30,16 +30,16 @@ EXECUTABLES = TeamTalkSimulator +all: $(EXECUTABLES) + # Include the dependencies -include $(OBJECTS:.o=.d) -all: $(EXECUTABLES) - -TeamTalkSimulator: primitivecomm $(OBJECTS) +TeamTalkSimulator: $(PRIMITIVECOMM_DIR)/libboeingrobotserver.a $(OBJECTS) @rm -f TeamTalkSimulatedBot $(CXXLINK) $(OBJECTS) $(PRIMITIVECOMM_DIR)/libboeingrobotserver.a $(LDLIBS) -primitivecomm: +$(PRIMITIVECOMM_DIR)/libboeingrobotserver.a: force $(MAKE) -C $(PRIMITIVECOMM_DIR) all # Compilation rule @@ -64,3 +64,5 @@ clean: $(MAKE) -C $(PRIMITIVECOMM_DIR) clean rm -f *.o $(EXECUTABLES) + +force: ; \ No newline at end of file Modified: TeamTalk/Agents/TeamTalkSimulator/TeamTalkSimulator.cc =================================================================== --- TeamTalk/Agents/TeamTalkSimulator/TeamTalkSimulator.cc 2007-04-05 18:44:23 UTC (rev 571) +++ TeamTalk/Agents/TeamTalkSimulator/TeamTalkSimulator.cc 2007-04-05 19:17:43 UTC (rev 572) @@ -434,12 +434,11 @@ if(robots.empty()) robots[name] = new Robot(&robots, name, 1); //initialize section control - SectMobPLPid = spawn(false, moast_bin, "sectMobPL"); - sleep(20); - debug << " about to init Section Control" << endl; + vector args; + args.push_back("-r.2"); + SectMobPLPid = spawn(false, moast_bin, "sectMobPL", args); + sleep(5); initSectionControl(); - //start dumping map - debug << " about to mapDump" << endl; mapDump(); //start the trader Modified: TeamTalk/Agents/TeamTalkSimulator/imageClient.cc =================================================================== --- TeamTalk/Agents/TeamTalkSimulator/imageClient.cc 2007-04-05 18:44:23 UTC (rev 571) +++ TeamTalk/Agents/TeamTalkSimulator/imageClient.cc 2007-04-05 19:17:43 UTC (rev 572) @@ -4,6 +4,7 @@ #include #include #include +#include //for connect_with_timeout #include @@ -13,6 +14,83 @@ using namespace std; +ImageClientException::ImageClientException() throw() {} +const char* ImageClientException::what() const throw() { + return "can't connect to image server"; +} + +int ImageClient::connect_with_timeout(int sockfd, const struct sockaddr* serv_addr, + socklen_t addrlen, int timeout) { + + // code borrowed from HAL http://www.developerweb.net/forum/showthread.php?p=13486 + + // Set non-blocking + long arg; + if((arg = fcntl(sockfd, F_GETFL, NULL)) < 0) { + error << "Error fcntl(..., F_GETFL) (" << strerror(errno) << ')' << endl; + return errno; + } + arg |= O_NONBLOCK; + if( fcntl(sockfd, F_SETFL, arg) < 0) { + error << "Error fcntl(..., F_SETFL) (" << strerror(errno) << ')' << endl; + return errno; + } + + // Trying to connect with timeout + int res = connect(sockfd, serv_addr, addrlen); + if (res < 0) { + if (errno == EINPROGRESS) { + do { + fd_set myset; + struct timeval tv; + tv.tv_sec = timeout; + tv.tv_usec = 0; + FD_ZERO(&myset); + FD_SET(sockfd, &myset); + res = select(sockfd+1, NULL, &myset, NULL, &tv); + if (res < 0 && errno != EINTR) { + error << "Error connecting " << errno << " - " << strerror(errno) << endl; + return errno; + } + else if (res > 0) { + // Socket selected for write + socklen_t lon = sizeof(int); + int valopt; + if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon) < 0) { + error << "Error in getsockopt() " << errno << " - " << strerror(errno) << endl; + return errno; + } + // Check the value returned... + if (valopt) { + error << "Error in delayed connection() " << errno << " - " << strerror(valopt) << endl; + return errno; + } + break; + } + else { + //error << "Timeout in select() - Cancelling!" << endl; + return ETIMEDOUT; + } + } while (1); + } + else { + error << "Error connecting " << errno << " - " << strerror(errno) << endl; + return errno; + } + } + // Set to blocking mode again... + if( (arg = fcntl(sockfd, F_GETFL, NULL)) < 0) { + error << "Error fcntl(..., F_GETFL) (" << strerror(errno) << ')' << endl; + return errno; + } + arg &= (~O_NONBLOCK); + if( fcntl(sockfd, F_SETFL, arg) < 0) { + error << "Error fcntl(..., F_SETFL) (" << strerror(errno) << ')' << endl; + return errno; + } + return 0; +} + ImageClient::ImageClient(const string& host, unsigned short port) : sockfd(0), image_(NULL), image_size_(0) { @@ -21,7 +99,7 @@ if(!(hostptr = gethostbyname(host.c_str()))) { error << "socket error: cannot find host " << host << endl; - return; + throw ImageClientException(); } memset((char *) &serv_addr, 0, sizeof(serv_addr)); @@ -36,9 +114,9 @@ return; } - if (connect(sockfd, (struct sockaddr*) &serv_addr, sizeof(serv_addr)) < 0) { + if (connect_with_timeout(sockfd, (struct sockaddr*) &serv_addr, sizeof(serv_addr), 3)) { perror("connect"); - return; + throw ImageClientException(); } //getImage_(); @@ -85,27 +163,29 @@ int ImageClient::getImage_() { char iType; + debug << "reading image type" << endl; if(!readn(&iType)) { error << "problem getting image type" << endl; return -1; } - //debug << "Imgage Type is " << (int)iType << endl; + debug << "Image Type is " << (int)iType << endl; if((int)iType < 1 || (int)iType > 5) { error << "can't deal with image of type " << (int)iType << endl; return -1; } - char iName[16]; - if(!readn(&iName)) { - error << "problem reading image name" << endl; - return -1; - } - //cerr << "image name is " << iName << endl; + // for names images -- not yet supported + //char iName[16]; + //if(!readn(&iName)) { + // error << "problem reading image name" << endl; + // return -1; + //} + //debug << "image name is " << iName << endl; if(!readn(&image_size_)) { - error << "problem getting image type" << endl; + error << "problem getting image size" << endl; return -1; } image_size_ = ntohl(image_size_); - //cerr << "image size is " << image_size_ << endl; + debug << "image size is " << image_size_ << endl; if(image_size_ <= 0) { error << "bad image size: " << image_size_ << endl; return -1; @@ -126,7 +206,7 @@ int ImageClient::getImage(const unsigned char*& imagePtr) { char ack[] = {'O', 'k', '\n', '\r'}; - //debug << "sending" << endl; + debug << "sending ack" << endl; send(sockfd, ack, 4, 0); if(getImage_() <= 0) { Modified: TeamTalk/Agents/TeamTalkSimulator/imageClient.h =================================================================== --- TeamTalk/Agents/TeamTalkSimulator/imageClient.h 2007-04-05 18:44:23 UTC (rev 571) +++ TeamTalk/Agents/TeamTalkSimulator/imageClient.h 2007-04-05 19:17:43 UTC (rev 572) @@ -2,6 +2,7 @@ #define IMAGE_CLIENT_H #include +#include #include @@ -11,6 +12,12 @@ #include #endif +class ImageClientException : public exception { + public: + ImageClientException() throw(); + const char* what() const throw(); +}; + class ImageClient { protected: int sockfd; @@ -36,6 +43,8 @@ }; int getImage_(); + static int connect_with_timeout(int sockfd, const struct sockaddr* serv_addr, + socklen_t addrlen, int timeout); public: ImageClient(const string& host, unsigned short port, int* image_size, const unsigned char*& image); ImageClient(const string& host, unsigned short port); Modified: TeamTalk/Agents/TeamTalkSimulator/robot.cc =================================================================== --- TeamTalk/Agents/TeamTalkSimulator/robot.cc 2007-04-05 18:44:23 UTC (rev 571) +++ TeamTalk/Agents/TeamTalkSimulator/robot.cc 2007-04-05 19:17:43 UTC (rev 572) @@ -27,6 +27,50 @@ const unsigned int mask = ~0U << (sizeof(unsigned int)*8 - shift); extern string moast_bin; +void Robot::abortWorkingMsg() +{ + if(!working_msg) return; + server_->sendAborted(working_msg->getTaskID()); + delete working_msg; + working_msg = NULL; +} + +void Robot::checkWorkingMsg() +{ + if(!working_msg) return; + if(work_level == VEHWORK) { + if(statP->echo_serial_number < work_serial) return; + else if(statP->echo_serial_number > work_serial) { + abortWorkingMsg(); + } else if(statP->status == RCS_DONE) { + debug << "trying to send " << working_msg->getTaskID() << " succeeded" << endl; + server_->sendDone(working_msg->getTaskID(), true); + delete working_msg; + working_msg = NULL; + } else if(statP->status == RCS_ERROR) { + server_->sendDone(working_msg->getTaskID(), false); + delete working_msg; + working_msg = NULL; + } + } else if(work_level == AMWORK) { + if(amStatP->echo_serial_number < work_serial) return; + else if(amStatP->echo_serial_number > work_serial) { + abortWorkingMsg(); + } else if(amStatP->status == RCS_DONE) { + server_->sendDone(working_msg->getTaskID(), true); + delete working_msg; + working_msg = NULL; + } else if(amStatP->status == RCS_ERROR) { + server_->sendDone(working_msg->getTaskID(), false); + delete working_msg; + working_msg = NULL; + } + } else { + error << "unknown work level" << endl; + return; + } +} + int Robot::cleanupVehMobPLNmlBuffers(void) { if (NULL != vehMobPLCmdBuf) @@ -82,6 +126,19 @@ { ostringstream chanName; + chanName << AM_MOB_JA_CMD_NAME << bufnum; + amMobJACmdBuf = + new RCS_CMD_CHANNEL(amMobJA_format, chanName.str().c_str(), + THIS_PROCESS, config_file); + } + if (!amMobJACmdBuf->valid()) { + delete amMobJACmdBuf; + amMobJACmdBuf = 0; + return 1; + } + + { + ostringstream chanName; chanName << VEH_MOB_PL_STAT_NAME << bufnum; vehMobPLStatBuf = new RCS_STAT_CHANNEL(vehMobPL_format, chanName.str().c_str(), @@ -108,6 +165,19 @@ { ostringstream chanName; + chanName << AM_MOB_JA_STAT_NAME << bufnum; + amMobJAStatBuf = + new RCS_STAT_CHANNEL(amMobJA_format, chanName.str().c_str(), + THIS_PROCESS, config_file); + } + if (!amMobJAStatBuf->valid()) { + delete amMobJAStatBuf; + amMobJAStatBuf = 0; + return 1; + } + + { + ostringstream chanName; chanName << VEH_MOB_PL_CFG_NAME << bufnum; vehMobPLCfgBuf = new RCS_CMD_CHANNEL(vehMobPL_format, chanName.str().c_str(), @@ -176,6 +246,7 @@ << vehMobPL_symbol_lookup(statP->command_type) << endl << "echo_serial_number: " << statP->echo_serial_number << endl << "prim serial number: " << primStatP->echo_serial_number << endl + << "am serial number: " << amStatP->echo_serial_number << endl << "status: " << rcs_stat_to_string(statP->status) << endl << "state: " << statP->state << endl @@ -235,63 +306,14 @@ Robot* me = (Robot*) thisp; sleep(5); - me->vehMobPLStatBuf->read(); me->vehMobPLSetBuf->read(); me->primMobJAStatBuf->read(); + me->amMobJAStatBuf->read(); + me->navDataExtBuf->read(); - debug << "command initialization" << endl; - VehMobPLCmdInit init = VehMobPLCmdInit(); - init.serial_number = me->statP->echo_serial_number+1; - me->vehMobPLCmdBuf->write(&init); - //i think primMobJA is initted by vehMobPL - - sleep(5); - me->vehMobPLStatBuf->read(); - me->vehMobPLSetBuf->read(); - me->primMobJAStatBuf->read(); - me->printStat(cerr); - /* - print_debugln("try to get image"); - const unsigned char* image; - int image_size; - ImageClient *ic = new ImageClient("192.168.1.100", - (unsigned short)5003, &image_size, image); - cerr << "got some kind of image, size: " << image_size << endl; - */ - /* - sleep(5); - me->vehMobPLStatBuf->read(); - me->vehMobPLSetBuf->read(); - - me->printStat(cerr); - print_debugln("try to move"); - VehMobPLCmdMoveWaypoint move = VehMobPLCmdMoveWaypoint(); - move.p.x = 4; - move.p.y = 0; - move.serial_number = me->statP->echo_serial_number+1; - move.isGlobal = false; - move.neighborhood = 1; - move.startTime = 0; - me->vehMobPLCmdBuf->write(&move); - - sleep(5); - me->vehMobPLStatBuf->read(); - me->vehMobPLSetBuf->read(); - me->printStat(cerr); - */ - - //start dumping the pic - //VehMobPLCfgDumpWM dump = VehMobPLCfgDumpWM(); - //dump.serial_number = me->setP->echo_serial_number + 1; - //dump.skip = 5; - //dump.dumpContinuous = true; - //strcpy(dump.fileName, "../../Agents/PenDecoder/VehMobPLDispOutput.ppm"); - //strcpy(dump.fileName, "/tmp/VehMobPLDispOutput.ppm"); - //me->vehMobPLCfgBuf->write(&dump); - debug << "entering for loop" << endl; //EnterCriticalSection(&me->CriticalSection); for(int i;;i++) { @@ -302,17 +324,30 @@ (bmsg = me->server_->getNextMessage())) { Msg* msg = Msg::interpretBoeingPacket(string(bmsg->buff, 1000)); if(!msg) { - warn << "got NULL message" << endl; + warn << me->sim_index << ": got NULL message" << endl; break; } if(dynamic_cast(msg)) { - //debug << "got message: " << msg->render() << endl; + //debug << me->sim_index << ": got message: " << msg->render() << endl; } else { - info << "got message: " << msg->render() << endl; + info << me->sim_index << ": got message: " << msg->render() << endl; + //me->printStat(cerr); } + me->vehMobPLStatBuf->read(); + me->vehMobPLSetBuf->read(); + me->primMobJAStatBuf->read(); + me->amMobJAStatBuf->read(); + me->navDataExtBuf->read(); me->callback(msg, NULL); + delete msg; } sleep(updatePeriod); + me->vehMobPLStatBuf->read(); + me->vehMobPLSetBuf->read(); + me->primMobJAStatBuf->read(); + me->amMobJAStatBuf->read(); + me->navDataExtBuf->read(); + me->checkWorkingMsg(); //} while(!TryEnterCriticalSection(&me->CriticalSection)); } while(true); /* @@ -391,7 +426,9 @@ string name, int simulator_index, unsigned int port) : action(WAITING), sim_index(simulator_index), robots(robs), imageClient(NULL), vehMobPLCmdBuf(NULL), vehMobPLStatBuf(NULL), - vehMobPLCfgBuf(NULL), vehMobPLSetBuf(NULL) + vehMobPLCfgBuf(NULL), vehMobPLSetBuf(NULL), primMobJACmdBuf(NULL), + amMobJACmdBuf(NULL), primMobJAStatBuf(NULL), amMobJAStatBuf(NULL), + working_msg(NULL) { //InitializeCriticalSection(&CriticalSection); sim_init(); @@ -433,12 +470,13 @@ debug << "set up convenient pointers" << endl; statP = (VehMobPLStat *) vehMobPLStatBuf->get_address(); primStatP = (PrimMobJAStat *) primMobJAStatBuf->get_address(); + amStatP = (AmMobJAStat *) amMobJAStatBuf->get_address(); setP = (VehMobPLSet *) vehMobPLSetBuf->get_address(); navP = (NavDataExt *) navDataExtBuf->get_address(); debug << "new robotserver" << endl; server_ = new Boeing::RobotServer(); - debug << "opening port" << endl; + debug << "opening port: " << port << endl; if (port) server_->open(port); else server_->open(); debug << "starting reading thread" << endl; @@ -457,67 +495,58 @@ } void Robot::callback(const Msg* msgp, const sockaddr* st_remote) { - //print_debugln("got a message"); - vehMobPLStatBuf->read(); - vehMobPLSetBuf->read(); - primMobJAStatBuf->read(); - navDataExtBuf->read(); updatePose(); - //Msg* temp_message; - //if(const MsgCmdActionPP* action = dynamic_cast(msgp)) { - // //print_debugln("got an action"); - // //need to translate txt-based message into typed message - // temp_message = Msg::interpretPlayAction(*action->content()); - //} else { - // temp_message = msgp->clone(); - //} if(const MsgMapReq* req_image = dynamic_cast(msgp)) { - //print_debugln("got an req image"); + debug << "got an req image" << endl; //get the jpeg from the usarsim video socket const unsigned char* image; int image_size = 0; - if(imageClient == NULL) { - imageClient = new ImageClient("sylvester.speech.cs.cmu.edu", - (unsigned short)5333); + try { + if(imageClient == NULL) { + imageClient = new ImageClient("virbot.speech.cs.cmu.edu", + (unsigned short)5003); + } + debug << "getting the image" << endl; + image_size = imageClient->getImage(image); + debug << "got the image" << endl; + + if(image_size > 0) { + //send the image to the robot client + server_->sendJPEGImage(image, image_size, 320, 240, req_image->getInvoice()); + } else { + error << "Image size is 0" << endl; + } + } catch (ImageClientException e) { + error << "ImageClientException: " << e.what() << endl; } - //print_debugln("getting the image"); - image_size = imageClient->getImage(image); - //print_debugln("got the image"); - - if(image_size > 0) { - //send the image to the robot client - server_->sendJPEGImage(image, image_size, 320, 240, req_image->getInvoice()); - } else { - cerr << "Image size is 0" << endl; - } - //delete temp_message; - //print_debugln("done with req image"); + debug << "done with req image" << endl; return; } if(dynamic_cast(msgp)) { - //print_debugln("got an req location"); - server_->sendLocation(getX(), -getY(), canonical_angle(-getYaw()), true); - //delete temp_message; + server_->sendLocation(getX(), getY(), canonical_angle(getYaw()), true); return; } //EnterCriticalSection(&CriticalSection); if(const MsgCmdGoTo* goTo = dynamic_cast(msgp)) { debug << "got: " << goTo << endl; - Point vec(goTo->getX(), goTo->getY()); + Point vec(goTo->getX(), -goTo->getY()); if(goTo->useAngle()) debug << "useAngle" << endl; else debug << "!useAngle" << endl; if(!vec) debug << "!vec" << endl; else debug << "vec" << endl; if(goTo->useAngle() && !vec) { - debug << "interpreting as turn relative" << endl; - PrimMobJACmdRotate rotate = PrimMobJACmdRotate(); - float r = -getYaw(); - rotate.theta = canonical_angle(-(r+goTo->getAngle())); - rotate.thetaTol = PI/20; //9 degrees tolerance - // always make it a new command - rotate.serial_number = primStatP->echo_serial_number + 1; - primMobJACmdBuf->write(&rotate); + debug << "interpreting as turn relative: " << goTo->getAngle() << endl; + float r = getYaw(); + AmMobJACmdSpin spin; + spin.absAngle = canonical_angle(r - goTo->getAngle()); + spin.tolerance = PI/40; + spin.direction = PRIM_MOB_JA_CMD_ROTATE_SHORTEST; + spin.serial_number = amStatP->echo_serial_number + 1; + debug << "spinning: " << spin.absAngle << " tol: " << spin.tolerance + << " SHORTEST" << endl; + amMobJACmdBuf->write(&spin); + setNewWorkingMsg(goTo, AMWORK, spin.serial_number); } else { Point loc(getX(), getY()); Point destination; @@ -537,13 +566,12 @@ move.neighborhood = 1; move.startTime = 0; vehMobPLCmdBuf->write(&move); + setNewWorkingMsg(goTo, VEHWORK, move.serial_number); } - //delete temp_message; return; } else if(const MsgCmdHalt* halt = dynamic_cast(msgp)) { debug << "got: " << halt << endl; action = WAITING; - //delete temp_message; return; } else if(const MsgCmdHome* home = dynamic_cast(msgp)) { debug << "got: " << home << endl; @@ -555,7 +583,6 @@ move.neighborhood = 1; move.startTime = 0; vehMobPLCmdBuf->write(&move); - //delete temp_message; return; } else if(const MsgCmdPause* pause = dynamic_cast(msgp)) { debug << "got: " << pause << endl; @@ -573,7 +600,6 @@ //setFollow(follow->content()->leader); } //LeaveCriticalSection(&CriticalSection); - //delete temp_message; } /** @@ -594,7 +620,7 @@ args.push_back("-p2"); //args.push_back("-v"); spawn(false, moast_bin, "simWare", args); - sleep(20); + sleep(5); args.clear(); { @@ -603,7 +629,7 @@ args.push_back(arg.str()); } pids.push_back(spawn(false, moast_bin, "slamStub", args)); - sleep(2); + sleep(1); args.clear(); { @@ -615,7 +641,6 @@ pids.push_back(spawn(false, moast_bin, "primMobMain", args)); pids.push_back(spawn(false, moast_bin, "primSPMain", args)); //if(sim_index==1) pids.push_back(spawn(false, moast_bin, "primMisMain", args)); - sleep(2); pids.push_back(spawn(false, moast_bin, "amMobMain", args)); args.clear(); @@ -629,7 +654,7 @@ args.clear(); args.push_back("-i"); - args.push_back("-g3"); + args.push_back("-g1"); args.push_back("-r.2"); { ostringstream arg; Modified: TeamTalk/Agents/TeamTalkSimulator/robot.h =================================================================== --- TeamTalk/Agents/TeamTalkSimulator/robot.h 2007-04-05 18:44:23 UTC (rev 571) +++ TeamTalk/Agents/TeamTalkSimulator/robot.h 2007-04-05 19:17:43 UTC (rev 572) @@ -12,6 +12,7 @@ #include // NAV_DATA_BASE, etc. #include // vehMobPL_format() #include // primMobJA_format() +#include // amMobJA_format() #include // navigation data #include "imageClient.h" @@ -39,17 +40,36 @@ //moast/rcs structures RCS_CMD_CHANNEL *vehMobPLCmdBuf; RCS_STAT_CHANNEL *vehMobPLStatBuf; - RCS_CMD_CHANNEL *primMobJACmdBuf; - RCS_STAT_CHANNEL *primMobJAStatBuf; RCS_CMD_CHANNEL *vehMobPLCfgBuf; RCS_STAT_CHANNEL *vehMobPLSetBuf; + RCS_CMD_CHANNEL *primMobJACmdBuf; + RCS_CMD_CHANNEL *amMobJACmdBuf; + RCS_STAT_CHANNEL *primMobJAStatBuf; + RCS_STAT_CHANNEL *amMobJAStatBuf; NML *navDataExtBuf; VehMobPLStat *statP; VehMobPLSet *setP; PrimMobJAStat *primStatP; + AmMobJAStat *amStatP; NavDataExt *navP; Pose pose; + //command status + MsgCmd* working_msg; + typedef enum {VEHWORK, AMWORK} work_level_t; + work_level_t work_level; + int work_serial; + template + void setNewWorkingMsg(const C* wm, work_level_t wl, int sn) + { + if(working_msg) abortWorkingMsg(); + working_msg = new C(*wm); + work_level = wl; + work_serial = sn; + } + void abortWorkingMsg(); + void checkWorkingMsg(); + int cleanupVehMobPLNmlBuffers(); int initVehMobPLNmlBuffers(char *config, int bufnum); static const int updatePeriod = 1; Modified: TeamTalk/Agents/TeamTalkSimulator/runSimulator.sh =================================================================== --- TeamTalk/Agents/TeamTalkSimulator/runSimulator.sh 2007-04-05 18:44:23 UTC (rev 571) +++ TeamTalk/Agents/TeamTalkSimulator/runSimulator.sh 2007-04-05 19:17:43 UTC (rev 572) @@ -13,119 +13,5 @@ MOAST=${CARTOON_HOME}/moast/devel export CONFIG_NML=${MOAST}/etc/moast.nml export CONFIG_INI=${MOAST}/etc/moast.ini -./TeamTalkSimulator --moast $MOAST --peerfile peerfile.txt --mapserver +./TeamTalkSimulator --moast $MOAST --peerfile peerfile.txt -# cd ../../../moast-1.2/bin -# HOME=/net/eucalyptus/usr0/tkharris -# MOAST=$HOME/moast-1.2 -# export RCSLIB_DIR=$HOME/lib/rcslib - -# echo `dirname $0`/.. - -# #set SECT=yes to run section, VEH, AM, prim, and servo, else SECT=no -# SECT=no - -# # if SECT=no, set VEH=yes to run vehicle, AM, prim, and servo, else VEH=no -# VEH=yes - -# # if VEH=no, set AM=yes to run AM, prim, and servo, else AM=no -# AM=yes - -# # if AM=no, set PRIM=yes to run prim, and servo, else PRIM=no -# PRIM=yes - -# # set USARSIM=yes to run usarSim, else USARSIM=no to run simpleSim -# USARSIM=yes - -# CONFIG_NML=$MOAST/etc/moast.nml ; export CONFIG_NML -# CONFIG_INI=$MOAST/etc/moast.ini ; export CONFIG_INI - -# TOP=servoShell -# if [ x$PRIM = xyes ] ; then TOP=primShell ; fi -# if [ x$AM = xyes ] ; then PRIM=yes; TOP=amShell ; fi -# if [ x$VEH = xyes ] ; then AM=yes; PRIM=yes; TOP=vehShell ; fi -# if [ x$SECT = xyes ] ; then VEH=yes; AM=yes; PRIM=yes; TOP=sectShell ; fi -# pid1=0 -# pid2=0 -# pid3=0 -# pid4=0 -# pid5=0 -# pid6=0 -# pid7=0 -# pid8=0 -# pid9=0 - -# kill1=9 -# kill2=9 -# kill3=9 -# kill4=9 -# kill5=9 -# kill6=INT -# kill7=9 -# kill8=9 -# kill9=9 - -# ./ipc-clear - -# #./splash $CONFIG_INI & - -# echo "Starting server..." -# ./moastNmlSvr & -# sleep 2 -# pid1=$! - -# if [ x$USARSIM = xyes ] ; then -# echo "Starting usarsim..." -# ./usarSim -i1 & -# sleep 30 -# kill2=HUP -# else -# ./simpleSim & -# fi -# pid2=$! - -# if [ x$PRIM = xyes ] ; then -# echo "Starting prim..." -# sleep 2 -# ./primMobMain & -# pid3=$! -# ./primSPMain & -# pid4=$! -# ./primMisMain & -# pid5=$! -# fi - -# if [ x$AM = xyes ] ; then -# echo "Starting am..." -# ./amMobMain & -# pid6=$! -# ./amSPMain -z.1& -# pid7=$! -# fi - -# if [ x$VEH = xyes ] ; then -# echo "Starting vehicle..." -# ./vehMobPLMain -i -g3 -r.2& -# pid8=$! -# fi - -# if [ x$SECT = xyes ] ; then -# echo "Starting section..." -# ./sectMobPL & -# pid9=$! -# fi - -# #./$TOP -# sleep 60 - -# if [ ! $pid9 = 0 ] ; then kill -$kill9 $pid9 ; fi -# if [ ! $pid8 = 0 ] ; then kill -$kill8 $pid8 ; fi -# if [ ! $pid7 = 0 ] ; then kill -$kill7 $pid7 ; fi -# if [ ! $pid6 = 0 ] ; then kill -$kill6 $pid6 ; fi -# if [ ! $pid5 = 0 ] ; then kill -$kill5 $pid5 ; fi -# if [ ! $pid4 = 0 ] ; then kill -$kill4 $pid4 ; fi -# if [ ! $pid3 = 0 ] ; then kill -$kill3 $pid3 ; fi -# if [ ! $pid2 = 0 ] ; then kill -$kill2 $pid2 ; fi -# if [ ! $pid1 = 0 ] ; then kill -$kill1 $pid1 ; fi - -# exit 0 From tk at edam.speech.cs.cmu.edu Thu Apr 5 16:11:16 2007 From: tk at edam.speech.cs.cmu.edu (tk@edam.speech.cs.cmu.edu) Date: Thu, 5 Apr 2007 16:11:16 -0400 Subject: [TeamTalk 36]: [573] TeamTalk: Added ignore property for may temp files Message-ID: <200704052011.l35KBGk1001011@edam.speech.cs.cmu.edu> An HTML attachment was scrubbed... URL: http://mailman.srv.cs.cmu.edu/pipermail/teamtalk-developers/attachments/20070405/3fa6cd2f/attachment.html -------------- next part -------------- Property changes on: TeamTalk ___________________________________________________________________ Name: svn:ignore + bin ExternalLibraries logs Property changes on: TeamTalk/Agents ___________________________________________________________________ Name: svn:ignore + Agents.ncb Agents.suo Ankh.Load Property changes on: TeamTalk/Agents/PenDecoder ___________________________________________________________________ Name: svn:ignore - dist build + build dist Property changes on: TeamTalk/Agents/PenDecoder/nbproject/private ___________________________________________________________________ Name: svn:ignore + private.properties private.xml Added: TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/TaskStatus.java =================================================================== --- TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/TaskStatus.java (rev 0) +++ TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/TaskStatus.java 2007-04-05 20:11:16 UTC (rev 573) @@ -0,0 +1,16 @@ +/* + * TaskStatus.java + * + * Created on March 31, 2007, 2:17 PM + * + */ + +package edu.cmu.ravenclaw.pendecoder; + +/** + * + * @author tkharris + */ +public enum TaskStatus { + UNSENT, UNACKED, IN_PROGRESS, ABANDONED, FAILED, SUCCEEDED +} Property changes on: TeamTalk/Agents/PrimitiveComm ___________________________________________________________________ Name: svn:ignore + Debug Release *.user Property changes on: TeamTalk/Agents/TeamTalkBackend ___________________________________________________________________ Name: svn:ignore + Debug Release *.user Property changes on: TeamTalk/Agents/TeamTalkBackend/backendstub ___________________________________________________________________ Name: svn:ignore + Debug Release *.user Property changes on: TeamTalk/Agents/TeamTalkDM ___________________________________________________________________ Name: svn:ignore + Debug Release *.user Property changes on: TeamTalk/Agents/boeingLib ___________________________________________________________________ Name: svn:ignore + _darcs boring darcs-record-* Added: TeamTalk/Agents/boeingLib/bin/cpuflags =================================================================== --- TeamTalk/Agents/boeingLib/bin/cpuflags (rev 0) +++ TeamTalk/Agents/boeingLib/bin/cpuflags 2007-04-05 20:11:16 UTC (rev 573) @@ -0,0 +1,51 @@ +#!/usr/bin/ruby + +def cpuflags() + # read proc file and extract the processor name + lines=IO.readlines("/proc/cpuinfo") + model=String.new + lines.each { |l| + case l + when /model name.*: *(.*)/ + entry=$1 + case entry + when /Athlon.*X2/ + model="-march=athlon-fx -mfpmath=sse -msse2" + when /Athlon.*64/ + model="-march=athlon-xp -mfpmath=sse -msse2" + when /Athlon.*XP/ + model="-march=athlon-xp" + when /Athlon/ + model="-march=athlon" + when /Pentium/ + if (entry=~/M/) + model="-march=pentium-m -mfpmath=sse -msse2 -mmmx" + else + model="-march=pentium4 -mfpmath=sse -msse2 -mmmx" + end + when /VIA Nehemiah/ + # "-march=c3-2" + model="-march=pentium" + end + end + } + return model +end + + +if false + # read proc file and extract the processor name + file = File.open("/proc/cpuinfo","r"); + while(line = file.gets()) + case line + when /model name.*: *(.*)/ + model = $1 + end + end + file.close() +end + + +print cpuflags(),"\n" + +exit 0 Added: TeamTalk/Agents/boeingLib/bin/fixdepend =================================================================== --- TeamTalk/Agents/boeingLib/bin/fixdepend (rev 0) +++ TeamTalk/Agents/boeingLib/bin/fixdepend 2007-04-05 20:11:16 UTC (rev 573) @@ -0,0 +1,45 @@ +#!/usr/bin/ruby + +# /* LICENSE: */ + +dir = ARGV.shift.chomp("/") +#dir.chomp!("/"); + +obj_name = nil +if(!ARGV[0].nil? && ARGV[0]=~/\.o$/) + obj_name = ARGV.shift +end + +generated_h_files = ARGV + +line = $stdin.gets() +parts = line.split(/:/) +if(parts.size < 2) + exit 2 +end + +if(obj_name.nil?) + obj_name = File.join(dir,parts[0].strip()) +end +dep_name = obj_name.clone() +dep_name[-1,1] = "d" + +deps = parts[1] +rest_of_file = $stdin.gets(nil) +if(!rest_of_file.nil?) + deps += rest_of_file +end + +print "#{obj_name} : #{deps}" + +deps.gsub!(%r%([^[:blank:]\\]\S+)%) {|filename| + if(generated_h_files.index(filename).nil?) + "$(wildcard #{filename})" + else + filename + end +} + +print "\n#{dep_name} : #{deps}" + +exit 0 Added: TeamTalk/Agents/boeingLib/bin/flatten =================================================================== --- TeamTalk/Agents/boeingLib/bin/flatten (rev 0) +++ TeamTalk/Agents/boeingLib/bin/flatten 2007-04-05 20:11:16 UTC (rev 573) @@ -0,0 +1,93 @@ +#!/usr/bin/ruby -w + +# This program tries to flatten the code hierarchy into one directory + +def printUsage(eval) + print "USAGE: flatten \n"; + print "This program flattens the directory dirname and puts all\n"; + print "files in the directory tree all into the target directory\n"; + exit eval; +end + +def loadExcludes(exclude_file) + excludes = Array.new; + File::open(exclude_file) {|f| + while (line = f.gets()) + line = line.split('#')[0]; + line.strip!; + # line = line.split()[0]; + if (line.length()>0) + excludes.push(line); + end + end + } + return excludes; +end + +def checkExclude(fname,excludes) + excludes.each {|ex| + if (!fname.index(ex).nil?()) + return false; + end + } + return true; +end + +def copyFiles(files,target,excludes) + files.each { |f| + if (File::file?(f) && checkExclude(f,excludes)) + tfname = target + "/" + File::basename(f); + printf "file '%s' -> '%s'\n",f,tfname; + system("cp "+f+" "+tfname); + end + } +end + +# we expect two parameters +if (ARGV.size < 2) + printUsage(1); +end + +# remove trailing / +verbose=true; +dirname = ARGV[0].chomp("/"); +target = ARGV[1].chomp("/"); + +use_excludes=false; +if (ARGV.size>2) + use_excludes=true; + exclude_file=ARGV[2]; +end + +if (!File::directory?(target)) + printf "ERROR: %s is not a directory!\n",target; + printUsage(1); +end + +if (verbose) + printf "Flattening from '%s' -> '%s'", + dirname,target; + if (use_excludes) + printf " with exclude file '%s'\n",exclude_file; + end +end + +# read the exclude file +excludes = Array.new; +if (use_excludes && File::readable?(exclude_file)) + excludes = loadExcludes(exclude_file); +end + +# find the list of files +files = Dir[dirname+"/**/*"]; + +# apply exclusions +copyFiles(files,target,excludes); + + + + + + + + Added: TeamTalk/Agents/boeingLib/bin/gpp_calc =================================================================== --- TeamTalk/Agents/boeingLib/bin/gpp_calc (rev 0) +++ TeamTalk/Agents/boeingLib/bin/gpp_calc 2007-04-05 20:11:16 UTC (rev 573) @@ -0,0 +1,89 @@ +#!/usr/bin/ruby + +# /* LICENSE: */ + +#dir = ARGV.shift.chomp("/") + +ifname = nil +if(!ARGV[0].nil?) + ifname = ARGV.shift +else + print "USAGE: gpp_calc [outfile]\n"; + exit 1 +end + +ofname="tmp.calc.cfg" +if (!ARGV[0].nil?) + ofname = ARGV.shift +end + +# temp +#print "Using: #{ifname} -> #{ofname}\n"; + +if (!File::file?(ifname)) + print "gpp_calc ERROR: File \'#{ifname}\' does not exist!!!\n"; + exit(1); +end + +File::open(ifname, mode="r") {|ifile| + File::open(ofname, mode="w") {|outf| + while line = ifile.gets() + line = line.gsub(/\;/,' '); +# print line; + line.chomp!(); + line.strip!(); + line2 = line.split(/\/\//,2)[0]; + if (!line2.nil? && line2=~/=/) + if (line2=~/\"/) + l=line2.gsub(/\"/,' '); +# l=line2.replace("\""); + outf.print "#{l}\n"; + elsif (line2=~/[\+\*\/\-\(\)\|\&]/) + (var,eqn) = line2.split('=',2); + eqn.chomp!(); + var.chomp!(); + eqn.strip!(); + var.strip!(); + + # this is ugly... + outf.print "#{var} = "; + + eqn_sub = eqn.gsub(/,/, ' '); + eqn_sub = eqn_sub.gsub(/\s+/, ', '); +# eqn_sub = eqn.delete("\""); + + system("awk \" BEGIN { print \$\* #{eqn_sub} } \">tmp.eval"); + if (!File::file?("tmp.eval")) + print "ERROR: Cannot open temp file tmp.eval!!!"; + exit(1); + end + File::open("tmp.eval", mode="r") {|tmpf| + l=tmpf.gets() + if (l.nil? || ! (l=~/\S/)) + print "ERROR: evaluation failed!!!!\n"; + exit(1); + end + l.chomp!(); + if (0) + t = l.split(); + l.split().each {|x| outf.print "#{x}, "} + outf.print "\n"; + else + l=l.gsub(/\s+/,', '); + outf.print "#{l}\n"; + end + } + else + outf.print "#{line2}\n"; + end + else + outf.print "\n"; + end + end + } +} + + + + + Added: TeamTalk/Agents/boeingLib/bin/gpp_perl =================================================================== --- TeamTalk/Agents/boeingLib/bin/gpp_perl (rev 0) +++ TeamTalk/Agents/boeingLib/bin/gpp_perl 2007-04-05 20:11:16 UTC (rev 573) @@ -0,0 +1,23 @@ +#!/usr/bin/perl + +# /* LICENSE: */ + +#dir = ARGV.shift.chomp("/") + +sub usage +{ + print "USAGE: gpp_perl \n"; +} + + +$ARGV[0] || die usage(); + +open(INFILE, "<$ARGV[0]") || die "Cannot open $ARGV[0]"; +open(OUTFILE, ">$ARGV[1]") || die "Cannot open $ARGV[1]"; + +while ($line = ) { + chomp($line); + $_=$line; + s/[;"]/ /g; + print OUTFILE "$_ \n"; +} Property changes on: TeamTalk/Configurations/DesktopConfiguration ___________________________________________________________________ Name: svn:ignore + peerfile.txt Property changes on: TeamTalk/Resources/DecoderConfig ___________________________________________________________________ Name: svn:ignore + *.log Property changes on: TeamTalk/Resources/DecoderConfig/Dictionary ___________________________________________________________________ Name: svn:ignore + zap2.dict zap2.dict.reduced_phoneset Property changes on: TeamTalk/Resources/DecoderConfig/LanguageModel ___________________________________________________________________ Name: svn:ignore + zap2LM.arpa Property changes on: TeamTalk/Resources/Grammar ___________________________________________________________________ Name: svn:ignore + base.dic log nets zap2.gra zap2.net zap2flat.gra zap2Task.gra From tk at edam.speech.cs.cmu.edu Thu Apr 5 16:17:36 2007 From: tk at edam.speech.cs.cmu.edu (tk@edam.speech.cs.cmu.edu) Date: Thu, 5 Apr 2007 16:17:36 -0400 Subject: [TeamTalk 37]: [574] TeamTalk/Resources: Deleted now redundant MakeLM ( moved to olympus repo) Message-ID: <200704052017.l35KHamB001022@edam.speech.cs.cmu.edu> An HTML attachment was scrubbed... URL: http://mailman.srv.cs.cmu.edu/pipermail/teamtalk-developers/attachments/20070405/07c7999a/attachment.html -------------- next part -------------- Property changes on: TeamTalk/Resources/Grammar ___________________________________________________________________ Name: svn:ignore - base.dic log nets zap2.gra zap2.net zap2flat.gra zap2Task.gra + base.dic forms log nets zap2.gra zap2.net zap2flat.gra zap2Task.gra From tk at edam.speech.cs.cmu.edu Fri Apr 6 16:09:41 2007 From: tk at edam.speech.cs.cmu.edu (tk@edam.speech.cs.cmu.edu) Date: Fri, 6 Apr 2007 16:09:41 -0400 Subject: [TeamTalk 38]: [575] TeamTalk: Made changes to support MakeLM in its new location as an olympus tool. Message-ID: <200704062009.l36K9fpj005871@edam.speech.cs.cmu.edu> An HTML attachment was scrubbed... URL: http://mailman.srv.cs.cmu.edu/pipermail/teamtalk-developers/attachments/20070406/30a0a1d5/attachment-0001.html -------------- next part -------------- Modified: TeamTalk/Agents/PrimitiveComm/robot_packet2.cpp =================================================================== --- TeamTalk/Agents/PrimitiveComm/robot_packet2.cpp 2007-04-05 20:17:36 UTC (rev 574) +++ TeamTalk/Agents/PrimitiveComm/robot_packet2.cpp 2007-04-06 20:09:41 UTC (rev 575) @@ -1,705 +1,705 @@ -#include "robot_packet2.h" -#include "utils.h" -#include "netutils.h" - -//these are for Msg::stamp -#include -#include - -#include - -using namespace std; -using namespace geometry; - -// MalformedPacketException ******************************************* - -MalformedPacketException::MalformedPacketException(const string& context, const string& rep) throw() { - ostringstream e; - e << context << ": " << rep; - error = e.str(); -} - -MalformedPacketException::~MalformedPacketException() throw() {} - -const char* MalformedPacketException::what() throw() {return error.c_str();} - -// TaskStatus ********************************************************* - -const char* TaskStatus::map_[] = - {"ABANDONED", "FAILED", "UNSENT", "UNACKED", "IN_PROGRESS", "SUCCEEDED"}; - -TaskStatus::TaskStatus() : status_(TaskStatus::UNSENT) {} -TaskStatus::TaskStatus(TaskStatus::Enum x) : status_(x) {} - -int TaskStatus::boeingStatus(TaskStatus x) -{ - switch(x.status_) { - case ABORTED: return Boeing::ABORTED; - case FAILED: return Boeing::FAILED; - case UNSENT: - case UNACKED: - case IN_PROGRESS: return Boeing::INPROGRESS; - case SUCCEEDED: return Boeing::SUCCEEDED; - default: error << "unknown status " << x; - } - return 0; -} - -TaskStatus TaskStatus::statusOfBoeing(int x) -{ - if(x == Boeing::ABORTED) return TaskStatus(ABORTED); - if(x == Boeing::FAILED) return TaskStatus(FAILED); - if(x >= Boeing::SUCCEEDED) return SUCCEEDED; - return IN_PROGRESS; -} - -TaskStatus TaskStatus::operator=(TaskStatus::Enum x) { - status_ = x; - return *this; -} - -TaskStatus::operator const char *() const {return map_[status_];} - -bool TaskStatus::isInProgress() const {return status_ == IN_PROGRESS;} -bool TaskStatus::isFailed() const {return status_ == FAILED;} -bool TaskStatus::isAborted() const {return status_ == ABORTED;} -bool TaskStatus::isSuccess() const {return status_ == SUCCEEDED;} - -// Msg **************************************************************** - -int Msg::taskIDCounter = 0; -const int Msg::defaultPriority = 1; - -//normal instantiation -Msg::Msg(string sender) : sender_(sender) {} -//instantiation from Boeing packet -Msg::Msg(string sender, double tstamp) : sender_(sender), tstamp_(tstamp) {} - -Msg::Msg(const Msg& m) : sender_(m.sender_), tstamp_(m.tstamp_) {} - -Msg::~Msg() {} - -Msg* Msg::interpretBoeingPacket(const string& m, const string& sender) -{ - const Boeing::MsgHeader *h = - reinterpret_cast(m.c_str()); - double tstamp = h->tstamp; - int type = h->type; - //messages to robots - if(type == Boeing::ROB_ACTION_ECHO || type == Boeing::CMD_ACTION) { - debug("packet") << "got: CMD_ACTION or ROB_ACTION_ECHO" << endl; - return MsgCmd::interpretBoeingPlayAction( - reinterpret_cast(m.c_str()), sender, tstamp); - } - if(type == Boeing::CMD_COVER) { - warn("packet") << "unhandled type: CMD_COVER " << endl; - return NULL; - } - if(type == Boeing::CMD_FOLLOW) { - warn("packet") << "unhandled type: CMD_FOLLOW " << endl; - return NULL; - } - if(type == Boeing::CMD_GOTO) { - warn("packet") << "unhandled type: CMD_GOTO " << endl; - return NULL; - } - if(type == Boeing::CMD_HALT) { - warn("packet") << "unhandled type: CMD_HALT " << endl; - return NULL; - } - if(type == Boeing::CMD_HOME) { - warn("packet") << "unhandled type: CMD_HOME " << endl; - return NULL; - } - if(type == Boeing::CMD_PAUSE) { - warn("packet") << "unhandled type: CMD_PAUSE " << endl; - return NULL; - } - if(type == Boeing::CMD_RESUME) { - warn("packet") << "unhandled type: CMD_RESUME " << endl; - return NULL; - } - if(type == Boeing::CMD_SETPOS) { - warn("packet") << "unhandled type: CMD_SETPOS " << endl; - return NULL; - } - if(type == Boeing::REQ_LOCATION) { - debug("packet") << "got: REQ_LOCATION" << endl; - return new MsgReqLocation(sender, tstamp); - } - if(type == Boeing::REQ_IMAGE) { - debug("packet") << "got: REQ_IMAGE" << endl; - return new MsgMapReq(sender, tstamp, - reinterpret_cast(m.c_str())->invoice); - } - //messages from robots - if(type == Boeing::ROB_LOCATION) { - debug("packet") << "got ROB_LOCATION" << endl; - const Boeing::MsgRobLocation* brl = - reinterpret_cast(m.c_str()); - return new MsgRobLocation(sender, brl->tstamp, - geometry::Point(brl->x, brl->y), brl->angle, (brl->moving != 0)); - } - if(type == Boeing::ROB_ACK) { - debug("packet") << "got: ROB_ACK" << endl; - return new MsgRobAck(sender, tstamp, - reinterpret_cast(m.c_str())->taskid); - } - 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(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(m.c_str()); - if(bp->status == Boeing::SUCCEEDED) - return new MsgRobDone(sender, tstamp, bp->taskid, TaskStatus::SUCCEEDED); - else if(bp->status == Boeing::FAILED) - return new MsgRobDone(sender, tstamp, bp->taskid, TaskStatus::FAILED); - else if(bp->status == Boeing::ABORTED) - return new MsgRobDone(sender, tstamp, bp->taskid, TaskStatus::ABORTED); - else { - error << "couldn't get Boeing::ROB_DONE status" << endl; - return NULL; - } - } - if(type == Boeing::ROB_PLAY_HALT) { - warn("packet") << "unhandled type: ROB_PLAY_HALT " << endl; - return NULL; - } - if(type == Boeing::ROB_IMAGE) { - debug("packet") << "got: ROB_IMAGE" << endl; - const Boeing::MsgMap* bp = reinterpret_cast(m.c_str()); - return new MsgMap(sender, tstamp, bp->invoice, bp->seq, bp->x, bp->y, - string((const char *)bp->map, bp->array_length), MsgMap::JPEG); - } - //messages to trader -// case Boeing::TASK_CANCEL: -// warn("packet") << "unhandled type: TASK_CANCEL " << endl; -// break; - //messages from trader -// if(type == Boeing::INFO) { -// warn("packet") << "unhandled type: INFO " << endl; -// return NULL; -// } -// case Boeing::TASK_ACK: -// warn("packet") << "unhandled type: TASK_ACK " << endl; -// break; -// case Boeing::TASK_DONE: -// warn("packet") << "unhandled type: TASK_DONE " << endl; -// break; - //messages to mapserver/imageserver -// case Boeing::MAP_ACK: -// warn("packet") << "unhandled type: MAP_ACK " << endl; -// break; -// case Boeing::MAP_KEEPALIVE: -// warn("packet") << "unhandled type: MAP_KEEPALIVE " << endl; -// break; - //messages from mapserver/imageserver -// case Boeing::MAP_DIFF: -// warn("packet") << "unhandled type: MAP_DIFF " << endl; -// break; -// case Boeing::MAP_FULL: -// warn("packet") << "unhandled type: MAP_FULL " << endl; -// break; - warn("packet") << "unknown type: " << h->type << endl; - return NULL; -} - -void Msg::stamp(Boeing::MsgHeader& h) -{ -#ifdef WIN32 - struct __timeb64 timebuffer; - _ftime64(&timebuffer); -#else - struct timeb timebuffer; - ftime(&timebuffer); -#endif - h.tstamp = timebuffer.time + (float)timebuffer.millitm/1000; -} - -string Msg::getSender() const {return sender_;} - -// MsgCmd ************************************************************* - -//normal instantiation -MsgCmd::MsgCmd() : Msg(), taskID_(taskIDCounter++), priority_(defaultPriority) {} -MsgCmd::MsgCmd(int priority, string sender) -: Msg(sender), taskID_(taskIDCounter++), priority_(priority) {} -//instantiation from Boeing packet -MsgCmd::MsgCmd(string sender, double tstamp, int priority, int taskID) -: Msg(sender, tstamp), taskID_(taskID), priority_(priority), - status_(TaskStatus::IN_PROGRESS) {} - -int MsgCmd::getTaskID() const {return taskID_;} -int MsgCmd::getPriority() const {return priority_;} - -void MsgCmd::setStatus(TaskStatus status) {status_ = status;} -void MsgCmd::setStatus(const MsgRobDone* done) { - status_ = done->getStatus(); - sender_ = done->getSender(); -} -TaskStatus MsgCmd::getStatus() const {return status_;} - -MsgCmd* MsgCmd::interpretBoeingPlayAction(const Boeing::MsgCmdAction* m, - const string& sender, double tstamp) -{ - istringstream iaction(m->action); - string action_head; - iaction >> action_head; - if(action_head == "halt") - return new MsgCmdHalt(sender, tstamp, m->priority, m->taskid, m->action); - if(action_head == "goto" || action_head == "home") - return new MsgCmdGoTo(sender, tstamp, m->priority, m->taskid, m->action); - if(action_head == "pause") - return new MsgCmdPause(sender, tstamp, m->priority, m->taskid, m->action); - if(action_head == "resume") - return new MsgCmdResume(sender, tstamp, m->priority, m->taskid, m->action); - if(action_head == "follow") - return new MsgCmdFollow(sender, tstamp, m->priority, m->taskid, m->action); - if(action_head == "cover") - return new MsgCmdCover(sender, tstamp, m->priority, m->taskid, m->action); - if(action_head == "setpos") - return new MsgCmdSetPos(sender, tstamp, m->priority, m->taskid, m->action); - warn("packet") << "unknown action head: " << action_head << endl; - return NULL; -} - -string MsgCmd::renderBoeingPacket() const -{ - string retval; - Boeing::MsgCmdAction bPacket = - Boeing::MsgCmdAction::factory(render().c_str(), priority_, taskID_); - retval.assign(reinterpret_cast(&bPacket), bPacket.len); - return retval; -} - -string MsgCmd::render() const -{ - ostringstream out; - out << "MsgCmd: #" << taskID_; - out << " sender(" << sender_; - out << ") priority(" << priority_; - out << ") tstamp(" << tstamp_ << ") "; - out << renderBoeingPlayAction(); - return out.str(); -} - -// MsgCmdHalt ********************************************************* - -//normal instantiation -MsgCmdHalt::MsgCmdHalt(): MsgCmd() {} -MsgCmdHalt::MsgCmdHalt(int priority): MsgCmd(priority) {} - -//instantiation from Boeing packet -MsgCmdHalt::MsgCmdHalt(string sender, double tstamp, int priority, int taskID, - string action) -: MsgCmd(sender, tstamp, priority, taskID) {} - -string MsgCmdHalt::renderBoeingPlayAction() const {return "halt";} - -// MsgCmdGoTo ********************************************************* - -//normal instantiation -//turn radians -MsgCmdGoTo::MsgCmdGoTo(float rad) -: MsgCmd(), angle_(rad), useAngle_(true), absolute_(false) {} -//move along a relative vector -MsgCmdGoTo::MsgCmdGoTo(Point loc, bool absolute) -: MsgCmd(), loc_(loc), angle_(0), useAngle_(false), absolute_(absolute) {} -MsgCmdGoTo::MsgCmdGoTo(Point loc, float angle, bool useAngle, bool absolute, int priority, string sender) -: MsgCmd(priority, sender), loc_(loc), angle_(angle), useAngle_(useAngle), absolute_(absolute) {} - -//instantiation from a Boeing packet -MsgCmdGoTo::MsgCmdGoTo(string sender, double tstamp, int priority, int taskID, string action) -: MsgCmd(sender, tstamp, priority, taskID) { - MalformedPacketException e("MsgCmdGoTo", action); - istringstream in(action); - string token; - if((in >> token).fail() || token != "goto") throw e; - if((in >> token).fail()) throw e; - if(token == "abs") absolute_ = true; - else if(token == "rel") absolute_ = false; - else throw e; - if((in >> loc_).fail()) throw e; - useAngle_ = !(in >> angle_).fail(); -} - -string MsgCmdGoTo::renderBoeingPlayAction() const { - ostringstream out; - out << "goto "; - if(absolute_) out << "abs "; - else out << "rel "; - out << loc_; - if(useAngle_) out << ' ' << angle_; - return out.str(); -} - -float MsgCmdGoTo::getX() const {return loc_.x;} -float MsgCmdGoTo::getY() const {return loc_.y;} -float MsgCmdGoTo::getAngle() const {return angle_;} -bool MsgCmdGoTo::useAngle() const {return useAngle_;} -bool MsgCmdGoTo::isAbsolute() const {return absolute_;} -bool MsgCmdGoTo::isRelative() const {return !absolute_;} - -// MsgCmdHome ********************************************************* - -//normal instantiation -MsgCmdHome::MsgCmdHome() : MsgCmd() {} -MsgCmdHome::MsgCmdHome(int priority, string sender) : MsgCmd(priority, sender) {} - -//instantiation from a Boeing packet -MsgCmdHome::MsgCmdHome(string sender, double tstamp, int priority, int taskID, string action) -: MsgCmd(sender, tstamp, priority, taskID) {} - -string MsgCmdHome::renderBoeingPlayAction() const {return "home";} - -// MsgCmdPause ******************************************************** - -//normal instantiation -MsgCmdPause::MsgCmdPause(int priority, string sender) : MsgCmd(priority, sender) {} - -//instantiation from a Boeing packet -MsgCmdPause::MsgCmdPause(string sender, double tstamp, int priority, int taskID, string action) -: MsgCmd(sender, tstamp, priority, taskID) {} - -string MsgCmdPause::renderBoeingPlayAction() const {return "pause";} - -// MsgCmdResume ******************************************************* - -//normal instantiation -MsgCmdResume::MsgCmdResume(int priority, string sender) : MsgCmd(priority, sender) {} - -//instantiation from a Boeing packet -MsgCmdResume::MsgCmdResume(string sender, double tstamp, int priority, int taskID, string action) -: MsgCmd(sender, tstamp, priority, taskID) {} - -string MsgCmdResume::renderBoeingPlayAction() const {return "resum,e";} - -// MsgCmdFollow ******************************************************* - -//normal instantiation -MsgCmdFollow::MsgCmdFollow() : MsgCmd() {} -MsgCmdFollow::MsgCmdFollow(int priority, string sender) : MsgCmd(priority, sender) {} - -//instantiation from a Boeing packet -MsgCmdFollow::MsgCmdFollow(string sender, double tstamp, int priority, int taskID, string action) -: MsgCmd(sender, tstamp, priority, taskID) {} - -string MsgCmdFollow::renderBoeingPlayAction() const {return "follow";} - -// MsgCmdCover ******************************************************** - -//normal instantiations -MsgCmdCover::MsgCmdCover(const Point& lower_left, const Point& upper_right, int priority, string sender) -: MsgCmd(priority, sender), polygon_(4) { - polygon_[0] = lower_left; - polygon_[1] = Point(lower_left.x, upper_right.y); - polygon_[2] = upper_right; - polygon_[3] = Point(upper_right.x, lower_left.y); -} - -MsgCmdCover::MsgCmdCover(float x1, float x2, float y1, float y2, int priority, string sender) -: MsgCmd(priority, sender), polygon_(4) { - polygon_[0] = Point(x1, y1); - polygon_[1] = Point(x1, y2); - polygon_[2] = Point(x2, y2); - polygon_[3] = Point(x2, y1); -} - -MsgCmdCover::MsgCmdCover(const geometry::Polygon& polygon, int priority, string sender) -: MsgCmd(priority, sender), polygon_(polygon) {} - -//instantiation from a Boeing packet -MsgCmdCover::MsgCmdCover(string sender, double tstamp, int priority, int taskID, string action) -: MsgCmd(sender, tstamp, priority, taskID) { - MalformedPacketException e("MsgCmdCover", action); - istringstream in(action); - string token; - if((in >> token).fail() || token != "cover") throw e; - Point p; - if((in >> p).fail()) throw e; //there should be at least one cover point - do { - polygon_.push_back(p); - in >> p; - } while(!in.fail()); -} - -geometry::Polygon MsgCmdCover::getPolygon() const {return polygon_;} - -string MsgCmdCover::renderBoeingPlayAction() const { - ostringstream out; - out << "cover "; - for(geometry::Polygon::const_iterator i = polygon_.begin(); i != polygon_.end(); i++) { - if(i != polygon_.begin()) out << ' '; - out << *i; - } - return out.str(); -} - -// MsgCmdSetPos ******************************************************* - -//normal instantiation -MsgCmdSetPos::MsgCmdSetPos(const Point& loc, float angle, int priority, string sender) -: MsgCmd(priority, sender), loc_(loc), angle_(angle) {} -MsgCmdSetPos::MsgCmdSetPos(float x, float y, float angle, int priority, string sender) -: MsgCmd(priority, sender), loc_(x, y), angle_(angle) {} - -//instantiation from a Boeing Packet -MsgCmdSetPos::MsgCmdSetPos(string sender, double tstamp, int priority, int taskID, string action) -: MsgCmd(sender, tstamp, priority, taskID) { - MalformedPacketException e("MsgCmdSetPos", action); - istringstream in(action); - string token; - if((in >> token).fail() || token != "setpos") throw e; - if((in >> loc_).fail()) throw e; - if((in >> angle_).fail()) throw e; -} - -Point MsgCmdSetPos::getLocation() const {return loc_;} -float MsgCmdSetPos::getX() const {return loc_.x;} -float MsgCmdSetPos::getY() const {return loc_.y;} -float MsgCmdSetPos::getAngle() const {return angle_;} - -string MsgCmdSetPos::renderBoeingPlayAction() const { - ostringstream out; - out << "setpos " << loc_ << ' ' << angle_; - return out.str(); -} - -// MsgReqLocation ***************************************************** - -//normal instantiation -MsgReqLocation::MsgReqLocation(string sender) : Msg(sender) {} - -//instatiation from a Boeing packet -MsgReqLocation::MsgReqLocation(string sender, double tstamp) : Msg(sender, tstamp) {} - -string MsgReqLocation::render() const {return "reqlocation";} - -string MsgReqLocation::renderBoeingPacket() const { - Boeing::MsgReqLocation packet = - Boeing::MsgReqLocation::factory(1, taskIDCounter++); - return string(reinterpret_cast(&packet), packet.len); -} - -// MsgRobAck ********************************************************** - -//normal instantiation -MsgRobAck::MsgRobAck(int taskID, string sender) : Msg(sender), taskID_(taskID) {} - -//instatiation from a Boeing packet -MsgRobAck::MsgRobAck(string sender, double tstamp, int taskID) -: Msg(sender, tstamp), taskID_(taskID) {} - -string MsgRobAck::render() const {return "roback";} - -string MsgRobAck::renderBoeingPacket() const { - Boeing::MsgRobAck packet = Boeing::MsgRobAck::factory(taskID_); - return string(reinterpret_cast(&packet), packet.len); -} - -// MsgRobActionAck **************************************************** - -//normal instantiation -MsgRobActionAck::MsgRobActionAck(int taskID, TaskStatus 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), - status_(TaskStatus::statusOfBoeing(status)) {} - -int MsgRobActionAck::getTaskID() const {return taskID_;} - -TaskStatus MsgRobActionAck::getStatus() const {return status_;} - -string MsgRobActionAck::render() const { - ostringstream out; - out << "robactionack: " << taskID_ << status_; - return out.str(); -} - -string MsgRobActionAck::renderBoeingPacket() const { - Boeing::MsgActionAck packet = - Boeing::MsgActionAck::factory(taskID_, TaskStatus::boeingStatus(status_)); - return string(reinterpret_cast(&packet), packet.len); -} - -// MsgRobDone ********************************************************* - -//normal instantiation -MsgRobDone::MsgRobDone(int taskID, TaskStatus status, string sender) -: Msg(sender), taskID_(taskID), status_(status) {} - -//instantiation from a Boeing packet -MsgRobDone::MsgRobDone(string sender, double tstamp, int taskID, TaskStatus status) -: Msg(sender, tstamp), taskID_(taskID), status_(status) {} - -int MsgRobDone::getTaskID() const {return taskID_;} - -TaskStatus MsgRobDone::getStatus() const {return status_;} - -string MsgRobDone::render() const { - ostringstream out; - out << "robdone: " << taskID_ << ' ' << status_; - return out.str(); -} - -string MsgRobDone::renderBoeingPacket() const { - Boeing::MsgRobDone packet = - Boeing::MsgRobDone::factory(taskID_, TaskStatus::boeingStatus(status_)); - return string(reinterpret_cast(&packet), packet.len); -} - -// MsgRobLocation ***************************************************** - -const float MsgRobLocation::tolerance = 0.05F; //5 cm tolerance to change-in position -const float MsgRobLocation::angularTolerance = 0.03F; // ~2 deg tolerance - -//normal instantiation -MsgRobLocation::MsgRobLocation() -: Msg(), angle_(0), moving_(false) {} -MsgRobLocation::MsgRobLocation(Point loc, float angle, bool moving, string sender) -: Msg(sender), loc_(loc), angle_(angle), moving_(moving) {} - -MsgRobLocation::MsgRobLocation(string sender, double tstamp, Point loc, float angle, bool moving) -: Msg(sender, tstamp), loc_(loc), angle_(angle), moving_(moving) {} - -Point MsgRobLocation::getLocation() const {return loc_;} -float MsgRobLocation::getX() const {return loc_.x;} -float MsgRobLocation::getY() const {return loc_.y;} -float MsgRobLocation::getAngle() const {return angle_;} -bool MsgRobLocation::isMoving() const {return moving_;} - -bool MsgRobLocation::operator==(const MsgRobLocation& x) const { - return (loc_-x.loc_).length() <= tolerance && - abs(angle_ - x.angle_) <= angularTolerance; -} - -bool MsgRobLocation::operator!=(const MsgRobLocation& x) const { - return (loc_-x.loc_).length() > tolerance || - abs(angle_ - x.angle_) <= angularTolerance; -} - -string MsgRobLocation::render() const { - ostringstream out; - out << "roblocation: " << loc_ << angle_ << "rad " - << (moving_? "MOVING": "STILL"); - return out.str(); -} - -string MsgRobLocation::renderBoeingPacket() const { - Boeing::MsgRobLocation packet = - Boeing::MsgRobLocation::factory(loc_.x, loc_.y, angle_, moving_); - return string(reinterpret_cast(&packet), packet.len); -} - -// MsgMapReq ********************************************************** - -int MsgMapReq::invoiceCounter_ = 0; - -//normal instantiation -MsgMapReq::MsgMapReq(string sender) : Msg(sender), invoice_(invoiceCounter_++) {} - -//instantiation from a Boeing packet -MsgMapReq::MsgMapReq(string sender, double tstamp, int invoice) -: Msg(sender, tstamp), invoice_(invoice) {} - -int MsgMapReq::getInvoice() const {return invoice_;} - -string MsgMapReq::render() const { - ostringstream out; - out << "mapreq: " << invoice_; - return out.str(); -} - -string MsgMapReq::renderBoeingPacket() const { - Boeing::MsgMapReq packet = Boeing::MsgMapReq::factory(); - return string(reinterpret_cast(&packet), packet.len); -} - -// MsgMap ************************************************************* - -//normal instantiation -MsgMap::MsgMap(short invoice, int sequence, int width, int height, const string& imageData, MsgMap::Encoding encoding, string sender) - : Msg(sender), invoice_(invoice), width_(width), height_(height), sequence_(sequence), encoding_(encoding), imageData_(imageData.begin(), imageData.end()) {} - -//instatiation from a Boeing packet -MsgMap::MsgMap(string sender, double tstamp, short invoice, int sequence, int width, int height, const string& imageData, MsgMap::Encoding encoding) - : Msg(sender, tstamp), invoice_(invoice), width_(width), height_(height), sequence_(sequence), encoding_(encoding), imageData_(imageData) {} - -int MsgMap::getWidth() const {return width_;} -int MsgMap::getHeight() const {return height_;} -short MsgMap::getInvoice() const {return invoice_;} -int MsgMap::getSequence() const {return sequence_;} -string MsgMap::getImageData() const {return imageData_;} -size_t MsgMap::getImageDataSize() const {return imageData_.size();} -MsgMap::Encoding MsgMap::getEncoding() const {return encoding_;} - -string MsgMap::render() const { - ostringstream out; - out << "msgmap: #" << invoice_ << ':' << sequence_ << ' ' << width_ << 'x' << height_; - switch(encoding_) { - case MsgMap::RAW: - out << " RAW"; - break; - case MsgMap::JPEG: - out << " JPEG"; - break; - default: - out << " UNKNOWN(" << encoding_ << ')'; - } - return out.str(); -} - -string MsgMap::renderBoeingPacket() const { - //"compressed" form is potentially 4 times the size of the native form - //this is probably unlikely, but we malloc the space initially - Boeing::MsgMap* packet = - (Boeing::MsgMap*) malloc(sizeof(Boeing::MsgMap)+4*imageData_.size()); - Boeing::MapMsgEncoding e; - switch(encoding_) { - case MsgMap::RAW: - e = Boeing::MAP_RLE; - break; - case MsgMap::JPEG: - e = Boeing::MAP_RAW; - break; - default: throw MalformedPacketException("MsgMap::renderBoeingPacket()", ""); - } - Boeing::MsgMap::MsgMapFactory(e, packet, (const unsigned char*)imageData_.c_str(), (int)imageData_.size(), invoice_, sequence_, width_, height_); - string spacket(reinterpret_cast(packet), packet->getSize()); - free(packet); - return spacket; -} - -// Stream Operators *************************************************** - -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; -} +#include "robot_packet2.h" +#include "utils.h" +#include "netutils.h" + +//these are for Msg::stamp +#include +#include + +#include + +using namespace std; +using namespace geometry; + +// MalformedPacketException ******************************************* + +MalformedPacketException::MalformedPacketException(const string& context, const string& rep) throw() { + ostringstream e; + e << context << ": " << rep; + error = e.str(); +} + +MalformedPacketException::~MalformedPacketException() throw() {} + +const char* MalformedPacketException::what() throw() {return error.c_str();} + +// TaskStatus ********************************************************* + +const char* TaskStatus::map_[] = + {"ABANDONED", "FAILED", "UNSENT", "UNACKED", "IN_PROGRESS", "SUCCEEDED"}; + +TaskStatus::TaskStatus() : status_(TaskStatus::UNSENT) {} +TaskStatus::TaskStatus(TaskStatus::Enum x) : status_(x) {} + +int TaskStatus::boeingStatus(TaskStatus x) +{ + switch(x.status_) { + case ABORTED: return Boeing::ABORTED; + case FAILED: return Boeing::FAILED; + case UNSENT: + case UNACKED: + case IN_PROGRESS: return Boeing::INPROGRESS; + case SUCCEEDED: return Boeing::SUCCEEDED; + default: error << "unknown status " << x; + } + return 0; +} + +TaskStatus TaskStatus::statusOfBoeing(int x) +{ + if(x == Boeing::ABORTED) return TaskStatus(ABORTED); + if(x == Boeing::FAILED) return TaskStatus(FAILED); + if(x >= Boeing::SUCCEEDED) return SUCCEEDED; + return IN_PROGRESS; +} + +TaskStatus TaskStatus::operator=(TaskStatus::Enum x) { + status_ = x; + return *this; +} + +TaskStatus::operator const char *() const {return map_[status_];} + +bool TaskStatus::isInProgress() const {return status_ == IN_PROGRESS;} +bool TaskStatus::isFailed() const {return status_ == FAILED;} +bool TaskStatus::isAborted() const {return status_ == ABORTED;} +bool TaskStatus::isSuccess() const {return status_ == SUCCEEDED;} + +// Msg **************************************************************** + +int Msg::taskIDCounter = 0; +const int Msg::defaultPriority = 1; + +//normal instantiation +Msg::Msg(string sender) : sender_(sender) {} +//instantiation from Boeing packet +Msg::Msg(string sender, double tstamp) : sender_(sender), tstamp_(tstamp) {} + +Msg::Msg(const Msg& m) : sender_(m.sender_), tstamp_(m.tstamp_) {} + +Msg::~Msg() {} + +Msg* Msg::interpretBoeingPacket(const string& m, const string& sender) +{ + const Boeing::MsgHeader *h = + reinterpret_cast(m.c_str()); + double tstamp = h->tstamp; + int type = h->type; + //messages to robots + if(type == Boeing::ROB_ACTION_ECHO || type == Boeing::CMD_ACTION) { + debug("packet") << "got: CMD_ACTION or ROB_ACTION_ECHO" << endl; + return MsgCmd::interpretBoeingPlayAction( + reinterpret_cast(m.c_str()), sender, tstamp); + } + if(type == Boeing::CMD_COVER) { + warn("packet") << "unhandled type: CMD_COVER " << endl; + return NULL; + } + if(type == Boeing::CMD_FOLLOW) { + warn("packet") << "unhandled type: CMD_FOLLOW " << endl; + return NULL; + } + if(type == Boeing::CMD_GOTO) { + warn("packet") << "unhandled type: CMD_GOTO " << endl; + return NULL; + } + if(type == Boeing::CMD_HALT) { + warn("packet") << "unhandled type: CMD_HALT " << endl; + return NULL; + } + if(type == Boeing::CMD_HOME) { + warn("packet") << "unhandled type: CMD_HOME " << endl; + return NULL; + } + if(type == Boeing::CMD_PAUSE) { + warn("packet") << "unhandled type: CMD_PAUSE " << endl; + return NULL; + } + if(type == Boeing::CMD_RESUME) { + warn("packet") << "unhandled type: CMD_RESUME " << endl; + return NULL; + } + if(type == Boeing::CMD_SETPOS) { + warn("packet") << "unhandled type: CMD_SETPOS " << endl; + return NULL; + } + if(type == Boeing::REQ_LOCATION) { + debug("packet") << "got: REQ_LOCATION" << endl; + return new MsgReqLocation(sender, tstamp); + } + if(type == Boeing::REQ_IMAGE) { + debug("packet") << "got: REQ_IMAGE" << endl; + return new MsgMapReq(sender, tstamp, + reinterpret_cast(m.c_str())->invoice); + } + //messages from robots + if(type == Boeing::ROB_LOCATION) { + debug("packet") << "got ROB_LOCATION" << endl; + const Boeing::MsgRobLocation* brl = + reinterpret_cast(m.c_str()); + return new MsgRobLocation(sender, brl->tstamp, + geometry::Point(brl->x, brl->y), brl->angle, (brl->moving != 0)); + } + if(type == Boeing::ROB_ACK) { + debug("packet") << "got: ROB_ACK" << endl; + return new MsgRobAck(sender, tstamp, + reinterpret_cast(m.c_str())->taskid); + } + 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(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(m.c_str()); + if(bp->status == Boeing::SUCCEEDED) + return new MsgRobDone(sender, tstamp, bp->taskid, TaskStatus::SUCCEEDED); + else if(bp->status == Boeing::FAILED) + return new MsgRobDone(sender, tstamp, bp->taskid, TaskStatus::FAILED); + else if(bp->status == Boeing::ABORTED) + return new MsgRobDone(sender, tstamp, bp->taskid, TaskStatus::ABORTED); + else { + error << "couldn't get Boeing::ROB_DONE status" << endl; + return NULL; + } + } + if(type == Boeing::ROB_PLAY_HALT) { + warn("packet") << "unhandled type: ROB_PLAY_HALT " << endl; + return NULL; + } + if(type == Boeing::ROB_IMAGE) { + debug("packet") << "got: ROB_IMAGE" << endl; + const Boeing::MsgMap* bp = reinterpret_cast(m.c_str()); + return new MsgMap(sender, tstamp, bp->invoice, bp->seq, bp->x, bp->y, + string((const char *)bp->map, bp->array_length), MsgMap::JPEG); + } + //messages to trader +// case Boeing::TASK_CANCEL: +// warn("packet") << "unhandled type: TASK_CANCEL " << endl; +// break; + //messages from trader +// if(type == Boeing::INFO) { +// warn("packet") << "unhandled type: INFO " << endl; +// return NULL; +// } +// case Boeing::TASK_ACK: +// warn("packet") << "unhandled type: TASK_ACK " << endl; +// break; +// case Boeing::TASK_DONE: +// warn("packet") << "unhandled type: TASK_DONE " << endl; +// break; + //messages to mapserver/imageserver +// case Boeing::MAP_ACK: +// warn("packet") << "unhandled type: MAP_ACK " << endl; +// break; +// case Boeing::MAP_KEEPALIVE: +// warn("packet") << "unhandled type: MAP_KEEPALIVE " << endl; +// break; + //messages from mapserver/imageserver +// case Boeing::MAP_DIFF: +// warn("packet") << "unhandled type: MAP_DIFF " << endl; +// break; +// case Boeing::MAP_FULL: +// warn("packet") << "unhandled type: MAP_FULL " << endl; +// break; + warn("packet") << "unknown type: " << h->type << endl; + return NULL; +} + +void Msg::stamp(Boeing::MsgHeader& h) +{ +#ifdef WIN32 + struct __timeb64 timebuffer; + _ftime64(&timebuffer); +#else + struct timeb timebuffer; + ftime(&timebuffer); +#endif + h.tstamp = timebuffer.time + (float)timebuffer.millitm/1000; +} + +string Msg::getSender() const {return sender_;} + +// MsgCmd ************************************************************* + +//normal instantiation +MsgCmd::MsgCmd() : Msg(), taskID_(taskIDCounter++), priority_(defaultPriority) {} +MsgCmd::MsgCmd(int priority, string sender) +: Msg(sender), taskID_(taskIDCounter++), priority_(priority) {} +//instantiation from Boeing packet +MsgCmd::MsgCmd(string sender, double tstamp, int priority, int taskID) +: Msg(sender, tstamp), taskID_(taskID), priority_(priority), + status_(TaskStatus::IN_PROGRESS) {} + +int MsgCmd::getTaskID() const {return taskID_;} +int MsgCmd::getPriority() const {return priority_;} + +void MsgCmd::setStatus(TaskStatus status) {status_ = status;} +void MsgCmd::setStatus(const MsgRobDone* done) { + status_ = done->getStatus(); + sender_ = done->getSender(); +} +TaskStatus MsgCmd::getStatus() const {return status_;} + +MsgCmd* MsgCmd::interpretBoeingPlayAction(const Boeing::MsgCmdAction* m, + const string& sender, double tstamp) +{ + istringstream iaction(m->action); + string action_head; + iaction >> action_head; + if(action_head == "halt") + return new MsgCmdHalt(sender, tstamp, m->priority, m->taskid, m->action); + if(action_head == "goto" || action_head == "home") + return new MsgCmdGoTo(sender, tstamp, m->priority, m->taskid, m->action); + if(action_head == "pause") + return new MsgCmdPause(sender, tstamp, m->priority, m->taskid, m->action); + if(action_head == "resume") + return new MsgCmdResume(sender, tstamp, m->priority, m->taskid, m->action); + if(action_head == "follow") + return new MsgCmdFollow(sender, tstamp, m->priority, m->taskid, m->action); + if(action_head == "cover") + return new MsgCmdCover(sender, tstamp, m->priority, m->taskid, m->action); + if(action_head == "setpos") + return new MsgCmdSetPos(sender, tstamp, m->priority, m->taskid, m->action); + warn("packet") << "unknown action head: " << action_head << endl; + return NULL; +} + +string MsgCmd::renderBoeingPacket() const +{ + string retval; + Boeing::MsgCmdAction bPacket = + Boeing::MsgCmdAction::factory(render().c_str(), priority_, taskID_); + retval.assign(reinterpret_cast(&bPacket), bPacket.len); + return retval; +} + +string MsgCmd::render() const +{ + ostringstream out; + out << "MsgCmd: #" << taskID_; + out << " sender(" << sender_; + out << ") priority(" << priority_; + out << ") tstamp(" << tstamp_ << ") "; + out << renderBoeingPlayAction(); + return out.str(); +} + +// MsgCmdHalt ********************************************************* + +//normal instantiation +MsgCmdHalt::MsgCmdHalt(): MsgCmd() {} +MsgCmdHalt::MsgCmdHalt(int priority): MsgCmd(priority) {} + +//instantiation from Boeing packet +MsgCmdHalt::MsgCmdHalt(string sender, double tstamp, int priority, int taskID, + string action) +: MsgCmd(sender, tstamp, priority, taskID) {} + +string MsgCmdHalt::renderBoeingPlayAction() const {return "halt";} + +// MsgCmdGoTo ********************************************************* + +//normal instantiation +//turn radians +MsgCmdGoTo::MsgCmdGoTo(float rad) +: MsgCmd(), angle_(rad), useAngle_(true), absolute_(false) {} +//move along a relative vector +MsgCmdGoTo::MsgCmdGoTo(Point loc, bool absolute) +: MsgCmd(), loc_(loc), angle_(0), useAngle_(false), absolute_(absolute) {} +MsgCmdGoTo::MsgCmdGoTo(Point loc, float angle, bool useAngle, bool absolute, int priority, string sender) +: MsgCmd(priority, sender), loc_(loc), angle_(angle), useAngle_(useAngle), absolute_(absolute) {} + +//instantiation from a Boeing packet +MsgCmdGoTo::MsgCmdGoTo(string sender, double tstamp, int priority, int taskID, string action) +: MsgCmd(sender, tstamp, priority, taskID) { + MalformedPacketException e("MsgCmdGoTo", action); + istringstream in(action); + string token; + if((in >> token).fail() || token != "goto") throw e; + if((in >> token).fail()) throw e; + if(token == "abs") absolute_ = true; + else if(token == "rel") absolute_ = false; + else throw e; + if((in >> loc_).fail()) throw e; + useAngle_ = !(in >> angle_).fail(); +} + +string MsgCmdGoTo::renderBoeingPlayAction() const { + ostringstream out; + out << "goto "; + if(absolute_) out << "abs "; + else out << "rel "; + out << loc_; + if(useAngle_) out << ' ' << angle_; + return out.str(); +} + +float MsgCmdGoTo::getX() const {return loc_.x;} +float MsgCmdGoTo::getY() const {return loc_.y;} +float MsgCmdGoTo::getAngle() const {return angle_;} +bool MsgCmdGoTo::useAngle() const {return useAngle_;} +bool MsgCmdGoTo::isAbsolute() const {return absolute_;} +bool MsgCmdGoTo::isRelative() const {return !absolute_;} + +// MsgCmdHome ********************************************************* + +//normal instantiation +MsgCmdHome::MsgCmdHome() : MsgCmd() {} +MsgCmdHome::MsgCmdHome(int priority, string sender) : MsgCmd(priority, sender) {} + +//instantiation from a Boeing packet +MsgCmdHome::MsgCmdHome(string sender, double tstamp, int priority, int taskID, string action) +: MsgCmd(sender, tstamp, priority, taskID) {} + +string MsgCmdHome::renderBoeingPlayAction() const {return "home";} + +// MsgCmdPause ******************************************************** + +//normal instantiation +MsgCmdPause::MsgCmdPause(int priority, string sender) : MsgCmd(priority, sender) {} + +//instantiation from a Boeing packet +MsgCmdPause::MsgCmdPause(string sender, double tstamp, int priority, int taskID, string action) +: MsgCmd(sender, tstamp, priority, taskID) {} + +string MsgCmdPause::renderBoeingPlayAction() const {return "pause";} + +// MsgCmdResume ******************************************************* + +//normal instantiation +MsgCmdResume::MsgCmdResume(int priority, string sender) : MsgCmd(priority, sender) {} + +//instantiation from a Boeing packet +MsgCmdResume::MsgCmdResume(string sender, double tstamp, int priority, int taskID, string action) +: MsgCmd(sender, tstamp, priority, taskID) {} + +string MsgCmdResume::renderBoeingPlayAction() const {return "resum,e";} + +// MsgCmdFollow ******************************************************* + +//normal instantiation +MsgCmdFollow::MsgCmdFollow() : MsgCmd() {} +MsgCmdFollow::MsgCmdFollow(int priority, string sender) : MsgCmd(priority, sender) {} + +//instantiation from a Boeing packet +MsgCmdFollow::MsgCmdFollow(string sender, double tstamp, int priority, int taskID, string action) +: MsgCmd(sender, tstamp, priority, taskID) {} + +string MsgCmdFollow::renderBoeingPlayAction() const {return "follow";} + +// MsgCmdCover ******************************************************** + +//normal instantiations +MsgCmdCover::MsgCmdCover(const Point& lower_left, const Point& upper_right, int priority, string sender) +: MsgCmd(priority, sender), polygon_(4) { + polygon_[0] = lower_left; + polygon_[1] = Point(lower_left.x, upper_right.y); + polygon_[2] = upper_right; + polygon_[3] = Point(upper_right.x, lower_left.y); +} + +MsgCmdCover::MsgCmdCover(float x1, float x2, float y1, float y2, int priority, string sender) +: MsgCmd(priority, sender), polygon_(4) { + polygon_[0] = Point(x1, y1); + polygon_[1] = Point(x1, y2); + polygon_[2] = Point(x2, y2); + polygon_[3] = Point(x2, y1); +} + +MsgCmdCover::MsgCmdCover(const geometry::Polygon& polygon, int priority, string sender) +: MsgCmd(priority, sender), polygon_(polygon) {} + +//instantiation from a Boeing packet +MsgCmdCover::MsgCmdCover(string sender, double tstamp, int priority, int taskID, string action) +: MsgCmd(sender, tstamp, priority, taskID) { + MalformedPacketException e("MsgCmdCover", action); + istringstream in(action); + string token; + if((in >> token).fail() || token != "cover") throw e; + Point p; + if((in >> p).fail()) throw e; //there should be at least one cover point + do { + polygon_.push_back(p); + in >> p; + } while(!in.fail()); +} + +geometry::Polygon MsgCmdCover::getPolygon() const {return polygon_;} + +string MsgCmdCover::renderBoeingPlayAction() const { + ostringstream out; + out << "cover "; + for(geometry::Polygon::const_iterator i = polygon_.begin(); i != polygon_.end(); i++) { + if(i != polygon_.begin()) out << ' '; + out << *i; + } + return out.str(); +} + +// MsgCmdSetPos ******************************************************* + +//normal instantiation +MsgCmdSetPos::MsgCmdSetPos(const Point& loc, float angle, int priority, string sender) +: MsgCmd(priority, sender), loc_(loc), angle_(angle) {} +MsgCmdSetPos::MsgCmdSetPos(float x, float y, float angle, int priority, string sender) +: MsgCmd(priority, sender), loc_(x, y), angle_(angle) {} + +//instantiation from a Boeing Packet +MsgCmdSetPos::MsgCmdSetPos(string sender, double tstamp, int priority, int taskID, string action) +: MsgCmd(sender, tstamp, priority, taskID) { + MalformedPacketException e("MsgCmdSetPos", action); + istringstream in(action); + string token; + if((in >> token).fail() || token != "setpos") throw e; + if((in >> loc_).fail()) throw e; + if((in >> angle_).fail()) throw e; +} + +Point MsgCmdSetPos::getLocation() const {return loc_;} +float MsgCmdSetPos::getX() const {return loc_.x;} +float MsgCmdSetPos::getY() const {return loc_.y;} +float MsgCmdSetPos::getAngle() const {return angle_;} + +string MsgCmdSetPos::renderBoeingPlayAction() const { + ostringstream out; + out << "setpos " << loc_ << ' ' << angle_; + return out.str(); +} + +// MsgReqLocation ***************************************************** + +//normal instantiation +MsgReqLocation::MsgReqLocation(string sender) : Msg(sender) {} + +//instatiation from a Boeing packet +MsgReqLocation::MsgReqLocation(string sender, double tstamp) : Msg(sender, tstamp) {} + +string MsgReqLocation::render() const {return "reqlocation";} + +string MsgReqLocation::renderBoeingPacket() const { + Boeing::MsgReqLocation packet = + Boeing::MsgReqLocation::factory(1, taskIDCounter++); + return string(reinterpret_cast(&packet), packet.len); +} + +// MsgRobAck ********************************************************** + +//normal instantiation +MsgRobAck::MsgRobAck(int taskID, string sender) : Msg(sender), taskID_(taskID) {} + +//instatiation from a Boeing packet +MsgRobAck::MsgRobAck(string sender, double tstamp, int taskID) +: Msg(sender, tstamp), taskID_(taskID) {} + +string MsgRobAck::render() const {return "roback";} + +string MsgRobAck::renderBoeingPacket() const { + Boeing::MsgRobAck packet = Boeing::MsgRobAck::factory(taskID_); + return string(reinterpret_cast(&packet), packet.len); +} + +// MsgRobActionAck **************************************************** + +//normal instantiation +MsgRobActionAck::MsgRobActionAck(int taskID, TaskStatus 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), + status_(TaskStatus::statusOfBoeing(status)) {} + +int MsgRobActionAck::getTaskID() const {return taskID_;} + +TaskStatus MsgRobActionAck::getStatus() const {return status_;} + +string MsgRobActionAck::render() const { + ostringstream out; + out << "robactionack: " << taskID_ << status_; + return out.str(); +} + +string MsgRobActionAck::renderBoeingPacket() const { + Boeing::MsgActionAck packet = + Boeing::MsgActionAck::factory(taskID_, TaskStatus::boeingStatus(status_)); + return string(reinterpret_cast(&packet), packet.len); +} + +// MsgRobDone ********************************************************* + +//normal instantiation +MsgRobDone::MsgRobDone(int taskID, TaskStatus status, string sender) +: Msg(sender), taskID_(taskID), status_(status) {} + +//instantiation from a Boeing packet +MsgRobDone::MsgRobDone(string sender, double tstamp, int taskID, TaskStatus status) +: Msg(sender, tstamp), taskID_(taskID), status_(status) {} + +int MsgRobDone::getTaskID() const {return taskID_;} + +TaskStatus MsgRobDone::getStatus() const {return status_;} + +string MsgRobDone::render() const { + ostringstream out; + out << "robdone: " << taskID_ << ' ' << status_; + return out.str(); +} + +string MsgRobDone::renderBoeingPacket() const { + Boeing::MsgRobDone packet = + Boeing::MsgRobDone::factory(taskID_, TaskStatus::boeingStatus(status_)); + return string(reinterpret_cast(&packet), packet.len); +} + +// MsgRobLocation ***************************************************** + +const float MsgRobLocation::tolerance = 0.05F; //5 cm tolerance to change-in position +const float MsgRobLocation::angularTolerance = 0.03F; // ~2 deg tolerance + +//normal instantiation +MsgRobLocation::MsgRobLocation() +: Msg(), angle_(0), moving_(false) {} +MsgRobLocation::MsgRobLocation(Point loc, float angle, bool moving, string sender) +: Msg(sender), loc_(loc), angle_(angle), moving_(moving) {} + +MsgRobLocation::MsgRobLocation(string sender, double tstamp, Point loc, float angle, bool moving) +: Msg(sender, tstamp), loc_(loc), angle_(angle), moving_(moving) {} + +Point MsgRobLocation::getLocation() const {return loc_;} +float MsgRobLocation::getX() const {return loc_.x;} +float MsgRobLocation::getY() const {return loc_.y;} +float MsgRobLocation::getAngle() const {return angle_;} +bool MsgRobLocation::isMoving() const {return moving_;} + +bool MsgRobLocation::operator==(const MsgRobLocation& x) const { + return (loc_-x.loc_).length() <= tolerance && + abs(angle_ - x.angle_) <= angularTolerance; +} + +bool MsgRobLocation::operator!=(const MsgRobLocation& x) const { + return (loc_-x.loc_).length() > tolerance || + abs(angle_ - x.angle_) <= angularTolerance; +} + +string MsgRobLocation::render() const { + ostringstream out; + out << "roblocation: " << loc_ << angle_ << "rad " + << (moving_? "MOVING": "STILL"); + return out.str(); +} + +string MsgRobLocation::renderBoeingPacket() const { + Boeing::MsgRobLocation packet = + Boeing::MsgRobLocation::factory(loc_.x, loc_.y, angle_, moving_); + return string(reinterpret_cast(&packet), packet.len); +} + +// MsgMapReq ********************************************************** + +int MsgMapReq::invoiceCounter_ = 0; + +//normal instantiation +MsgMapReq::MsgMapReq(string sender) : Msg(sender), invoice_(invoiceCounter_++) {} + +//instantiation from a Boeing packet +MsgMapReq::MsgMapReq(string sender, double tstamp, int invoice) +: Msg(sender, tstamp), invoice_(invoice) {} + +int MsgMapReq::getInvoice() const {return invoice_;} + +string MsgMapReq::render() const { + ostringstream out; + out << "mapreq: " << invoice_; + return out.str(); +} + +string MsgMapReq::renderBoeingPacket() const { + Boeing::MsgMapReq packet = Boeing::MsgMapReq::factory(); + return string(reinterpret_cast(&packet), packet.len); +} + +// MsgMap ************************************************************* + +//normal instantiation +MsgMap::MsgMap(short invoice, int sequence, int width, int height, const string& imageData, MsgMap::Encoding encoding, string sender) + : Msg(sender), invoice_(invoice), width_(width), height_(height), sequence_(sequence), encoding_(encoding), imageData_(imageData.begin(), imageData.end()) {} + +//instatiation from a Boeing packet +MsgMap::MsgMap(string sender, double tstamp, short invoice, int sequence, int width, int height, const string& imageData, MsgMap::Encoding encoding) + : Msg(sender, tstamp), invoice_(invoice), width_(width), height_(height), sequence_(sequence), encoding_(encoding), imageData_(imageData) {} + +int MsgMap::getWidth() const {return width_;} +int MsgMap::getHeight() const {return height_;} +short MsgMap::getInvoice() const {return invoice_;} +int MsgMap::getSequence() const {return sequence_;} +string MsgMap::getImageData() const {return imageData_;} +size_t MsgMap::getImageDataSize() const {return imageData_.size();} +MsgMap::Encoding MsgMap::getEncoding() const {return encoding_;} + +string MsgMap::render() const { + ostringstream out; + out << "msgmap: #" << invoice_ << ':' << sequence_ << ' ' << width_ << 'x' << height_; + switch(encoding_) { + case MsgMap::RAW: + out << " RAW"; + break; + case MsgMap::JPEG: + out << " JPEG"; + break; + default: + out << " UNKNOWN(" << encoding_ << ')'; + } + return out.str(); +} + +string MsgMap::renderBoeingPacket() const { + //"compressed" form is potentially 4 times the size of the native form + //this is probably unlikely, but we malloc the space initially + Boeing::MsgMap* packet = + (Boeing::MsgMap*) malloc(sizeof(Boeing::MsgMap)+4*imageData_.size()); + Boeing::MapMsgEncoding e; + switch(encoding_) { + case MsgMap::RAW: + e = Boeing::MAP_RLE; + break; + case MsgMap::JPEG: + e = Boeing::MAP_RAW; + break; + default: throw MalformedPacketException("MsgMap::renderBoeingPacket()", ""); + } + Boeing::MsgMap::MsgMapFactory(e, packet, (const unsigned char*)imageData_.c_str(), (int)imageData_.size(), invoice_, sequence_, width_, height_); + string spacket(reinterpret_cast(packet), packet->getSize()); + free(packet); + return spacket; +} + +// Stream Operators *************************************************** + +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/TeamTalkBackend/robot-galaxy_adapter.cpp =================================================================== --- TeamTalk/Agents/TeamTalkBackend/robot-galaxy_adapter.cpp 2007-04-05 20:17:36 UTC (rev 574) +++ TeamTalk/Agents/TeamTalkBackend/robot-galaxy_adapter.cpp 2007-04-06 20:09:41 UTC (rev 575) @@ -59,10 +59,6 @@ map subs; { ostringstream gname; - /* - for(set::const_iterator i = agents_.begin(); i != agents_.end(); i++) { - gname << " (" << tolower(i->getName()) << ')' << endl; - */ for(vector::const_iterator i = names.begin(); i != names.end(); i++) { gname << " (" << tolower(*i) << ')' << endl; } @@ -70,11 +66,12 @@ debug << ' ' << gname.str(); } debug << endl; - Agent::writeSpecializedConfig("..\\..\\Resources\\Grammar\\zap2Task", "gra", + Agent::writeSpecializedConfig("..\\..\\Resources\\Grammar\\TeamTalkTask", "gra", subs); PROCESS_INFORMATION lm_build_proc = - spawn(true, "Language Build", "..\\..\\Resources\\MakeLM", "perl", "makelm.pl"); + spawn(true, "Language Build", "..\\..\\Tools\\MakeLM", "perl", + "makelm.pl TeamTalk ..\\..\\Resources"); } void GalaxyRobots::traderlistener(void *p) Modified: TeamTalk/Resources/DecoderConfig/female-16khz.arg =================================================================== --- TeamTalk/Resources/DecoderConfig/female-16khz.arg 2007-04-05 20:17:36 UTC (rev 574) +++ TeamTalk/Resources/DecoderConfig/female-16khz.arg 2007-04-06 20:09:41 UTC (rev 575) @@ -23,8 +23,8 @@ -fwdflatbeam 1e-8 -fwdflatnwbeam 3e-4 -rescorelw 9.5 - -lmfn LanguageModel\zap2LM.arpa - -dictfn Dictionary\zap2.dict.reduced_phoneset + -lmfn LanguageModel\TeamTalkLM.arpa + -dictfn Dictionary\TeamTalk.dict.reduced_phoneset -ndictfn Dictionary\noise.dict -phnfn HMM-16khz.ss/phone -mapfn HMM-16khz.ss/map Modified: TeamTalk/Resources/DecoderConfig/male-16khz.arg =================================================================== --- TeamTalk/Resources/DecoderConfig/male-16khz.arg 2007-04-05 20:17:36 UTC (rev 574) +++ TeamTalk/Resources/DecoderConfig/male-16khz.arg 2007-04-06 20:09:41 UTC (rev 575) @@ -23,8 +23,8 @@ -fwdflatbeam 1e-8 -fwdflatnwbeam 3e-4 -rescorelw 9.5 - -lmfn LanguageModel\zap2LM.arpa - -dictfn Dictionary\zap2.dict.reduced_phoneset + -lmfn LanguageModel\TeamTalkLM.arpa + -dictfn Dictionary\TeamTalk.dict.reduced_phoneset -ndictfn Dictionary\noise.dict -phnfn HMM-16khz.ss/phone -mapfn HMM-16khz.ss/map Copied: TeamTalk/Resources/Grammar/TeamTalkTask-template.gra (from rev 574, TeamTalk/Resources/Grammar/zap2Task-template.gra) =================================================================== --- TeamTalk/Resources/Grammar/TeamTalkTask-template.gra (rev 0) +++ TeamTalk/Resources/Grammar/TeamTalkTask-template.gra 2007-04-06 20:09:41 UTC (rev 575) @@ -0,0 +1,360 @@ +################################################################### +# +# Z A P T A S K G R A M M A R +# +# HISTORY: ------------------------------------------------------- +# +# [2003-03-08] (sison): started working on this +# +################################################################### + +[RobotName] + (everyone) +%%RobotNames%%; + +[OBJ-Robot] + ([RobotName]) +; + +[HumanFollowCommand] + (*[RobotName] FOLLOW [OBJ-Robot]) + +FOLLOW + (join) + (follow) + (find) +; + +[HumanPauseCommand] + (*[RobotName] pause) +; + +[HumanContinueCommand] + (*[RobotName] continue) +; + +[HumanReportCommand] + (*[RobotName] report) + ([RobotName]) +; + +[HumanLocationQuery] + (*[RobotName] where are you) +; + +[HumanHaltCommand] + (*[RobotName] all stop) +; + +[TurnDirection] + (right *[AngularQualifier]) + (left *[AngularQualifier]) + (around) +; + +[MoveDirection] + (right *[AngularQualifier]) + (left *[AngularQualifier]) + (straight) + (forward) + (forwards) + (back) + (backward) + (backwards) +; + +[AngularQualifier] + ([Number-180-by5] degrees) +; + +[Number-180-by5] + (five) + (ten) + (fifteen) + (twenty *five) + (thirty *five) + (forty *five) + (fifty *five) + (sixty *five) + (seventy *five) + (eighty *five) + (ninety *five) + (HUNDRED) + (HUNDRED *and five) + (HUNDRED *and ten) + (HUNDRED *and fifteen) + (HUNDRED *and twenty *five) + (HUNDRED *and thirty *five) + (HUNDRED *and fourty *five) + (HUNDRED *and fifty *five) + (HUNDRED *and sixty *five) + (HUNDRED *and seventy *five) + (HUNDRED *and eighty) + +HUNDRED + (a hundred) + (one hundred) +; + +[AbsoluteDistance] + ([Number-20] [Units]) +; + +[RelativeDistance] + ([ZapAll] *of the way) + ([ZapHalf] *of *the way) + ([ZapThird] of the way) + ([ZapTwoThird] of the way) + ([ZapOneQuarter] of the way) + ([ZapThreeQuarter] of the way) +; + +[ZapAll] + (all) +; + +[ZapHalf] + (halfway) + (one half) + (a half) + (half) +; + +[ZapThird] + (one third) + (a third) +; + +[ZapTwoThird] + (two third) + (two thirds) +; + +[ZapOneQuarter] + (one quarters) + (one quarter) + (one forth) + (a quarters) + (a quarter) + (a forth) +; + + +[ZapThreeQuarter] + (three quarter) + (three quarters) + (three forth) + (three forths) +; + +[HumanMoveCommand] +# ([MoveVectorCardinal]) + ([MoveVectorRelative]) + ([MoveToGoal]) +; + +[CLYDEJOINBASHFUL] + (*clyde join bashful) +; + +[BASHFULJOINCLYDE] + (*bashful join clyde) +; + +#[MoveVectorCardinal] +# (*[RobotName] MOVE *[CardinalDirection] [AbsoluteDistance]) +# (*[RobotName] MOVE [CardinalDirection]) +# +#MOVE +# (move) +# (go) +#; + +[MoveVectorRelative] + (*[RobotName] MOVE *[MoveDirection] [AbsoluteDistance]) + (*[RobotName] MOVE *[AbsoluteDistance] [MoveDirection]) + +MOVE + (move) + (go) + (drive) +; + +[MoveToGoal] + (*[RobotName] MOVE *[RelativeDistance] PREP *[Side] [Goal]) + (*[RobotName] MOVE [Home]) + +MOVE + (move) + (go) + (drive) + +PREP + (toward) + (towards) + (to) + (down *to) + (down towards) + (up *to) + (up towards) +; + +[Side] + (the=north=end=of) + (the=east=end=of) + (the=south=end=of) + (the=west=end=of) + +[Goal] + ([Home]) + ([Xcoord] [Ycoord]) +; + +[Home] + (home) +; + +[Xcoord] + (*negative [Number-20]) +; + +[Ycoord] + (*negative [Number-20]) +; + +[Units] + (meters) + (meter) +# (feet) +# (foot) +# (yards) +# (yard) +; + +[HumanGoodbyeCommand] + (goodbye) + (bye bye) + (mission complete) + (that's it) +; + +[HumanTurnCommand] + (TURN [TurnDirection]) + +TURN + (turn) + (face) +; + +[Number-20] + (zero) + (one) + (two) + (three) + (four) + (five) + (six) + (seven) + (eight) + (nine) + (ten) + (eleven) + (twelve) + (thirteen) + (fourteen) + (fifteen) + (sixteen) + (seventeen) + (eighteen) + (nineteen) + (twenty) +; + +################################################################### +# YES/NO grammar +################################################################### + +[Yes] + (YES *MOD) + (STRONG_MOD) + (OKAY) + (WEAK_MOD) +YES + (yes) + (yeah) + (yep) + (yup) +MOD + (STRONG_MOD) + (WEAK_MOD) +STRONG_MOD + (you betcha) +#tk hack: interferes with "go forward" (*let's go for it) + (absolutely) + (definitely) + (OKAY OKAY) +WEAK_MOD + (why not) + (i think so) + (i guess so) +OKAY + (sure) + (of course) + (ok) + (okay) + (correct) + (fine) + (perfect) + (great) + (wonderful) + (acceptable) + (good *enough) + (right) + (alright) + (cool) +; + +[No] + (no *MOD) + (*no absolutely not) + (nope) + (nah) + (no way) + (*no i DONT) + (*no i DONT think so) + (never mind) + (nevermind) + (*no not really) + (nowhere) + (negative) +DONT + (don't) + (do not) +MOD + (thanks) + (thank you) + (not really) + (i *really don't want to) + (it's not) + (i'm not) +NO + (no) + (not) +GOOD + (right) + (correct) + (good) + (okay) +; + + +################################################################### +# CANCEL grammar +################################################################### + +[Cancel] + (cancel *COMMAND) +COMMAND + (*that command) + (that) +; \ No newline at end of file Copied: TeamTalk/Resources/Grammar/TeamTalkTask.forms (from rev 574, TeamTalk/Resources/Grammar/zap2Task.forms) =================================================================== --- TeamTalk/Resources/Grammar/TeamTalkTask.forms (rev 0) +++ TeamTalk/Resources/Grammar/TeamTalkTask.forms 2007-04-06 20:09:41 UTC (rev 575) @@ -0,0 +1,82 @@ +################################################################### +# +# ZAP Grammar +# +# Written by: June Sison +# +# This is the forms file corresponding to the phoenix grammar for +# the Zap system +# +# +# HISTORY ------------------------------------------------------- +# +# [2005-09-21] (dbohus): added cancel +# [2005-09-21] (tk): added yes/no +# [2003-03-08] (sison): started working on this +# +################################################################### + +FUNCTION: Commands + NETS: + [HumanReportCommand] + [HumanLocationQuery] + [HumanMoveCommand] +# [MoveVectorCardinal] + [MoveVectorRelative] + [MoveToGoal] + [HumanGoodbyeCommand] + [HumanTurnCommand] + [HumanHaltCommand] + [HumanFollowCommand] + [HumanPauseCommand] + [HumanContinueCommand] +; + +FUNCTION: Features + NETS: + [AbsoluteDistance] + [TurnDirection] + [MoveDirection] + [Units] +; + +FUNCTION: YesNo + NETS: +# [Neither] + [Yes] + [No] +; + +FUNCTION: Cancel + NETS: + [Cancel] +; + +#FUNCTION: Queries +# NETS: +# [QueryProjector] +# [QueryWhiteboard] +# [QueryComputer] +# [QueryNetworking] +# [QueryLocation] +# [QueryRoomSize] +# [QueryRoomSizeSpec] +# [QueryOtherRooms] +# [QueryRoomDetails] +#; + +#FUNCTION: Responses +# NETS: +# [Indifferent] +# [Satisfied] +# [SomewhatSatisfied] +# [FirstOne] +# [SecondOne] +#; + +# these auxiliaries are defined in order to capture some parses like +# next, this that, which o/w would parse as date-time +#FUNCTION: Auxiliaries +# NETS: +# [__datetime_junk] +#; \ No newline at end of file Modified: TeamTalk/Resources/Grammar/cmp.bat =================================================================== --- TeamTalk/Resources/Grammar/cmp.bat 2007-04-05 20:17:36 UTC (rev 574) +++ TeamTalk/Resources/Grammar/cmp.bat 2007-04-06 20:09:41 UTC (rev 575) @@ -1,7 +1,7 @@ -'copy Generic.gra + zap2Task.gra zap2.gra -copy zap2Task.gra zap2.gra -'copy Generic.forms + zap2Task.forms forms -copy zap2Task.forms forms -perl mk_nets2.pl zap2.gra -compile -g . -f zap2 > log -concept_leaf -grammar zap2.net +'copy Generic.gra + TeamTalkTask.gra TeamTalk.gra +copy TeamTalkTask.gra TeamTalk.gra +'copy Generic.forms + TeamTalkTask.forms forms +copy TeamTalkTask.forms forms +perl mk_nets2.pl TeamTalk.gra +compile -g . -f TeamTalk > log +concept_leaf -grammar TeamTalk.net Deleted: TeamTalk/Resources/Grammar/zap2Task-template.gra @@ Diff output truncated at 60000 characters. @@ From tk at edam.speech.cs.cmu.edu Fri Apr 13 17:15:13 2007 From: tk at edam.speech.cs.cmu.edu (tk@edam.speech.cs.cmu.edu) Date: Fri, 13 Apr 2007 17:15:13 -0400 Subject: [TeamTalk 39]: [576] TeamTalk: 1) Bug: turn reporting reports wrong direction: fixed Message-ID: <200704132115.l3DLFDka010717@edam.speech.cs.cmu.edu> An HTML attachment was scrubbed... URL: http://mailman.srv.cs.cmu.edu/pipermail/teamtalk-developers/attachments/20070413/8c97bc52/attachment.html -------------- next part -------------- Modified: TeamTalk/Agents/PrimitiveComm/robot_client.cpp =================================================================== --- TeamTalk/Agents/PrimitiveComm/robot_client.cpp 2007-04-06 20:09:41 UTC (rev 575) +++ TeamTalk/Agents/PrimitiveComm/robot_client.cpp 2007-04-13 21:15:12 UTC (rev 576) @@ -68,7 +68,7 @@ warn << "couldn't reconnect to " << me->getHost() << ':' << me->getPort() << endl; } } - if(me->hasCamera()) { //send image request every second + if(!(t%3) && me->hasCamera()) { //send image request every 3 seconds me->sendReqImage(); } } Modified: TeamTalk/Agents/TeamTalkBackend/agent.cpp =================================================================== --- TeamTalk/Agents/TeamTalkBackend/agent.cpp 2007-04-06 20:09:41 UTC (rev 575) +++ TeamTalk/Agents/TeamTalkBackend/agent.cpp 2007-04-13 21:15:12 UTC (rev 576) @@ -377,24 +377,29 @@ void Agent::SendMoveStatusToDM(const MsgCmdGoTo* move) const { ostringstream move_report; if(move->useAngle()) { - move_report << "Turn in place"; - float angle = abs(fmodf(move->getAngle(), 2*(float)PI)); - const float tol = (float)PI/8; - if(angle < PI-tol/2) move_report << " right"; - else if(angle > PI+tol/2) move_report << " left"; - move_report << ' ' << (int)(angle*180/PI) << " degrees"; + move_report << "Turn "; + float angle = + fmodf(fmodf(move->getAngle(), 2*(float)PI)+2*(float)PI, 2*(float)PI)-(float)PI; + const float tol = (float)PI/16; + if(angle < tol) + move_report << " left " << (int)round((angle+PI)*180/PI) << " degrees"; + else if(angle > tol) + move_report << " right " << (int)round((PI-angle)*180/PI) << " degrees"; + else + move_report << "around"; } else if(move->isAbsolute()) { move_report << "Movement to " << (int)move->getX() << ' ' << (int)move->getY(); } else { move_report << "Movement"; float angle = (float)Point(move->getX(), move->getY()).angle(); - int cardinal = (int)((fmodf(angle + (float)PI/4, (float)PI)+PI)*2/PI); + int cardinal = (int)(fmodf(fmodf(angle + (float)PI/4, 2*(float)PI)+2*(float)PI, 2*(float)PI)*2/PI); debug << angle << ' ' << angle + (float)PI/4 << ' ' << fmodf(angle + (float)PI/4, (float)PI) - << ' ' << fmodf(angle + (float)PI/4, (float)PI) - << ' ' << fmodf(angle + (float)PI/4, (float)PI)+PI - << ' ' << (fmodf(angle + (float)PI/4, (float)PI)+PI)*2/PI + << ' ' << fmodf(angle + (float)PI/4, 2*(float)PI) + << ' ' << fmodf(angle + (float)PI/4, 2*(float)PI)+2*PI + << ' ' << fmodf(fmodf(angle + (float)PI/4, 2*(float)PI)+2*(float)PI, 2*(float)PI) + << ' ' << fmodf(fmodf(angle + (float)PI/4, 2*(float)PI)+2*(float)PI, 2*(float)PI)*2/PI << ' ' << cardinal << endl; - const char* dir[4] = {" backward", " to the right", " forward", " to the left"}; + const char* dir[4] = {" forward", " to the left", " backward", " to the right"}; move_report << ' ' << dir[cardinal]; float distance = round((float)Point(move->getX(), move->getY()).length()*10)/10; int major_d = (int)distance; @@ -728,4 +733,4 @@ const TeamTalk::RobotClient* Agent::getRobotClient() const {return robotClient_;} bool Agent::operator<(const Agent& rhs) const {return name_ < rhs.name_;} -bool Agent::operator==(const Agent& rhs) const {return name_ == rhs.name_;} \ No newline at end of file +bool Agent::operator==(const Agent& rhs) const {return name_ == rhs.name_;} Modified: TeamTalk/Agents/TeamTalkBackend/robot-galaxy_adapter.cpp =================================================================== --- TeamTalk/Agents/TeamTalkBackend/robot-galaxy_adapter.cpp 2007-04-06 20:09:41 UTC (rev 575) +++ TeamTalk/Agents/TeamTalkBackend/robot-galaxy_adapter.cpp 2007-04-13 21:15:12 UTC (rev 576) @@ -1,5 +1,7 @@ #include "robot-galaxy_adapter.h" +#include + #include //adds undiscoverable robots from a file @@ -251,8 +253,9 @@ r_client = new TeamTalk::RobotsClient("tester"); vector names = processPeerfile("peerfile.txt"); if(!testLastConfig("peerfile.txt", - "..\\..\\Resources\\DecoderConfig\\LanguageModel\\zap2LM.arpa")) + "..\\..\\Resources\\DecoderConfig\\LanguageModel\\TeamTalkLM.arpa")) { addRobotNamesToGrammar(names); + } if(!m_client->isConnected()) { fatal << "mapserver not found" << endl; } else if(!m_client->sendSubscribe(0)) { Modified: TeamTalk/Agents/boeingLib/coralshared/win32dep.cc =================================================================== --- TeamTalk/Agents/boeingLib/coralshared/win32dep.cc 2007-04-06 20:09:41 UTC (rev 575) +++ TeamTalk/Agents/boeingLib/coralshared/win32dep.cc 2007-04-13 21:15:12 UTC (rev 576) @@ -17,13 +17,4 @@ return (0); } -float round(float x) { - float major = floor(x); - float minor = x-major; - if(abs(minor >= 0.5)) - if(major >=0) return major+1; - else return major-1; - else return major; -} - #endif Modified: TeamTalk/Agents/boeingLib/coralshared/win32dep.h =================================================================== --- TeamTalk/Agents/boeingLib/coralshared/win32dep.h 2007-04-06 20:09:41 UTC (rev 575) +++ TeamTalk/Agents/boeingLib/coralshared/win32dep.h 2007-04-13 21:15:12 UTC (rev 576) @@ -11,7 +11,15 @@ #define sleep(x) Sleep(1000*(x)) int gettimeofday (struct timeval *tv, void* tz); -float round(float x); + +template C round(C x) { + C major = floor(x); + C minor = x-major; + if(abs(minor >= 0.5)) + if(major >=0) return major+1; + else return major-1; + else return major; +} #define _USE_MATH_DEFINES Modified: TeamTalk/Configurations/DesktopConfiguration/TeamTalk-hub-desktop-skeleton.pgm =================================================================== --- TeamTalk/Configurations/DesktopConfiguration/TeamTalk-hub-desktop-skeleton.pgm 2007-04-06 20:09:41 UTC (rev 575) +++ TeamTalk/Configurations/DesktopConfiguration/TeamTalk-hub-desktop-skeleton.pgm 2007-04-13 21:15:12 UTC (rev 576) @@ -1,7 +1,7 @@ DOMAIN: cmu LOG_DIR: ..\..\logs -TIMESTAMP: start_listening stop_listening set_lm setattr speak reset resetlast phoenixparse add_value choose_parse launch_query begin_session process_parse start_inactivity_timeout cancel_inactivity_timeout end_session new_session end_session increment_utterance nop goto_page notify_output_manager relay_input_source restart_decoder add_voice +TIMESTAMP: start_listening stop_listening set_lm setattr speak reset resetlast restart_decoder add_value choose_parse launch_query begin_session process_parse start_inactivity_timeout cancel_inactivity_timeout end_session new_session end_session increment_utterance nop goto_page notify_output_manager relay_input_source restart_decoder add_voice ;; This is used as a toplevel subdir in LOG_DIR, if not specified ;; its default is "sls" @@ -47,6 +47,16 @@ INIT: :greeting "Welcome to the CMU zap2 1.0!" ;; ------------------------------------------------- +;; The phoenix server will parse utterances +;; emitted by the sphinx server +;; this is connected in the skeleton just to get the restart message +;; ------------------------------------------------- + +SERVER: phoenix at localhost:13000 +OPERATIONS: restart_decoder +INIT: :greeting "Welcome to the %%DialogManager%%!" + +;; ------------------------------------------------- ;; Backend - Server (gal_be) ;; ------------------------------------------------- @@ -154,10 +164,15 @@ OUT: PROGRAM: restart_decoder + RULE: --> sphinx.restart_decoder IN: OUT: +RULE: --> phoenix.restart_decoder +IN: +OUT: + PROGRAM: robot_config LOG_IN: :name :voice RULE: :voice --> kalliope.add_voice Modified: TeamTalk/Configurations/DesktopConfiguration/TeamTalk-hub-desktop-template.pgm =================================================================== --- TeamTalk/Configurations/DesktopConfiguration/TeamTalk-hub-desktop-template.pgm 2007-04-06 20:09:41 UTC (rev 575) +++ TeamTalk/Configurations/DesktopConfiguration/TeamTalk-hub-desktop-template.pgm 2007-04-13 21:15:12 UTC (rev 576) @@ -1,7 +1,7 @@ DOMAIN: cmu LOG_DIR: ..\..\logs -TIMESTAMP: start_listening stop_listening set_lm setattr speak reset resetlast phoenixparse add_value choose_parse launch_query begin_session process_parse start_inactivity_timeout cancel_inactivity_timeout end_session new_session end_session increment_utterance nop goto_page notify_output_manager relay_input_source restart_decoder +TIMESTAMP: start_listening stop_listening set_lm setattr speak reset resetlast phoenixparse add_value choose_parse launch_query begin_session process_parse start_inactivity_timeout cancel_inactivity_timeout end_session new_session end_session increment_utterance nop goto_page notify_output_manager relay_input_source ;; This is used as a toplevel subdir in LOG_DIR, if not specified ;; its default is "sls" @@ -52,7 +52,7 @@ ;; ------------------------------------------------- SERVER: phoenix at localhost:13000 -OPERATIONS: phoenixparse restart_decoder +OPERATIONS: phoenixparse INIT: :greeting "Welcome to the %%DialogManager%%!" ;; ------------------------------------------------- @@ -224,11 +224,6 @@ IN: OUT: destroy! -PROGRAM: restart_decoder -RULE: --> phoenix.restart_decoder -IN: -OUT: - PROGRAM: robot_message ;;RULE: :goal | --> PenDecoder.speak Modified: TeamTalk/Configurations/DesktopConfiguration/startlist-desktop.config =================================================================== --- TeamTalk/Configurations/DesktopConfiguration/startlist-desktop.config 2007-04-06 20:09:41 UTC (rev 575) +++ TeamTalk/Configurations/DesktopConfiguration/startlist-desktop.config 2007-04-13 21:15:12 UTC (rev 576) @@ -33,7 +33,7 @@ PROCESS: $BIN\NlgServer2.exe -maxconns 6 -nlghost localhost PROCESS_TITLE: NLGServer -PROCESS: $BIN\phoenix2.exe -maxconns 6 -grammardir $GRAMMAR -grammarfn $GRAMMAR\zap2.net +PROCESS: $BIN\phoenix2.exe -maxconns 6 -grammardir $GRAMMAR -grammarfn $GRAMMAR\TeamTalk.net PROCESS_TITLE: Phoenix PROCESS: $BIN\Audio_Server-DEBUG.exe -maxconns 6 -sps 16000 -engine_list sphinx_engines.txt Modified: TeamTalk/Resources/Grammar/cmp.bat =================================================================== --- TeamTalk/Resources/Grammar/cmp.bat 2007-04-06 20:09:41 UTC (rev 575) +++ TeamTalk/Resources/Grammar/cmp.bat 2007-04-13 21:15:12 UTC (rev 576) @@ -1,6 +1,6 @@ -'copy Generic.gra + TeamTalkTask.gra TeamTalk.gra +REM copy Generic.gra + TeamTalkTask.gra TeamTalk.gra copy TeamTalkTask.gra TeamTalk.gra -'copy Generic.forms + TeamTalkTask.forms forms +REM copy Generic.forms + TeamTalkTask.forms forms copy TeamTalkTask.forms forms perl mk_nets2.pl TeamTalk.gra compile -g . -f TeamTalk > log From tk at edam.speech.cs.cmu.edu Mon Apr 16 12:17:09 2007 From: tk at edam.speech.cs.cmu.edu (tk@edam.speech.cs.cmu.edu) Date: Mon, 16 Apr 2007 12:17:09 -0400 Subject: [TeamTalk 40]: [577] TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder: Bug: zoom-in reverts to full screen at next refresh in virtual environment: fixed Message-ID: <200704161617.l3GGH9VA020772@edam.speech.cs.cmu.edu> An HTML attachment was scrubbed... URL: http://mailman.srv.cs.cmu.edu/pipermail/teamtalk-developers/attachments/20070416/c169caa6/attachment.html -------------- next part -------------- Modified: TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/DrawingPad.java =================================================================== --- TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/DrawingPad.java 2007-04-13 21:15:12 UTC (rev 576) +++ TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/DrawingPad.java 2007-04-16 16:17:08 UTC (rev 577) @@ -97,7 +97,6 @@ public void mapUpdate(int type, int x_dim, int y_dim, float x_origin, float y_origin, int resolution, int[] encoded_map) { canvas.mapUpdate(type, x_dim, y_dim, x_origin, y_origin, resolution, encoded_map); - //if(type == MapBufferedImage.FULL) drawingCanvas.zoomOut(); } public void addServer(PenDecoderServer server) { Modified: TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/scribble3/ScribbleCanvas.java =================================================================== --- TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/scribble3/ScribbleCanvas.java 2007-04-13 21:15:12 UTC (rev 576) +++ TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/scribble3/ScribbleCanvas.java 2007-04-16 16:17:08 UTC (rev 577) @@ -164,23 +164,9 @@ public void mapUpdate(int type, int x_dim, int y_dim, float x_origin, float y_origin, int resolution, int[] encoded_map) { byte[] decoded_map = new byte[x_dim*y_dim]; decodeMap(decoded_map, x_dim, y_dim, encoded_map); - /* - for(int j=0; j