From tk at edam.speech.cs.cmu.edu Mon Nov 6 17:51:13 2006 From: tk at edam.speech.cs.cmu.edu (tk@edam.speech.cs.cmu.edu) Date: Mon, 6 Nov 2006 17:51:13 -0500 Subject: [TeamTalk 3]: [540] Fixed include directories for debug version of the PrimitiveComm library. Message-ID: <200611062251.kA6MpDwY011679@edam.speech.cs.cmu.edu> Revision: 540 Author: tk Date: 2006-11-06 17:51:13 -0500 (Mon, 06 Nov 2006) Log Message: ----------- Fixed include directories for debug version of the PrimitiveComm library. Modified Paths: -------------- TeamTalk/Agents/PrimitiveComm/PrimitiveComm.vcproj From tk at edam.speech.cs.cmu.edu Wed Nov 8 10:54:47 2006 From: tk at edam.speech.cs.cmu.edu (tk@edam.speech.cs.cmu.edu) Date: Wed, 8 Nov 2006 10:54:47 -0500 Subject: [TeamTalk 4]: [541] TeamTalk/Agents/PenDecoder/: Ignore build targets. Message-ID: <200611081554.kA8FslJc017727@edam.speech.cs.cmu.edu> An HTML attachment was scrubbed... URL: http://mailman.srv.cs.cmu.edu/pipermail/teamtalk-developers/attachments/20061108/4bcb1049/attachment.html -------------- next part -------------- Property changes on: TeamTalk/Agents/PenDecoder ___________________________________________________________________ Name: svn:ignore + dist build From tk at edam.speech.cs.cmu.edu Wed Nov 8 11:59:52 2006 From: tk at edam.speech.cs.cmu.edu (tk@edam.speech.cs.cmu.edu) Date: Wed, 8 Nov 2006 11:59:52 -0500 Subject: [TeamTalk 5]: [542] tags/BTH-0.1: Merged bugfixes from main branch into BTH-0.1. Message-ID: <200611081659.kA8Gxqqw017842@edam.speech.cs.cmu.edu> An HTML attachment was scrubbed... URL: http://mailman.srv.cs.cmu.edu/pipermail/teamtalk-developers/attachments/20061108/c4b77d46/attachment-0001.html -------------- next part -------------- Property changes on: tags/BTH-0.1/TeamTalk/Agents/PenDecoder ___________________________________________________________________ Name: svn:ignore + dist build Modified: tags/BTH-0.1/TeamTalk/Agents/PenDecoder/.nbintdb =================================================================== (Binary files differ) Deleted: tags/BTH-0.1/TeamTalk/Agents/PenDecoder/Untitled =================================================================== (Binary files differ) Deleted: tags/BTH-0.1/TeamTalk/Agents/PenDecoder/corp5aStage.jpg =================================================================== (Binary files differ) Modified: tags/BTH-0.1/TeamTalk/Agents/PenDecoder/map.properties =================================================================== --- tags/BTH-0.1/TeamTalk/Agents/PenDecoder/map.properties 2006-11-08 15:54:45 UTC (rev 541) +++ tags/BTH-0.1/TeamTalk/Agents/PenDecoder/map.properties 2006-11-08 16:59:50 UTC (rev 542) @@ -1,4 +1,4 @@ # Sample ResourceBundle properties file -edu.cmu.ravenclaw.pendecoder.mapfile = cmu_wordmark1r-boeing.PNG +edu.cmu.ravenclaw.pendecoder.mapfile = highbay.png edu.cmu.ravenclaw.pendecoder.mapwidth = 6200 edu.cmu.ravenclaw.pendecoder.mapheight = 4650 \ No newline at end of file Deleted: tags/BTH-0.1/TeamTalk/Agents/PenDecoder/nbproject/private/private.properties =================================================================== --- tags/BTH-0.1/TeamTalk/Agents/PenDecoder/nbproject/private/private.properties 2006-11-08 15:54:45 UTC (rev 541) +++ tags/BTH-0.1/TeamTalk/Agents/PenDecoder/nbproject/private/private.properties 2006-11-08 16:59:50 UTC (rev 542) @@ -1,5 +0,0 @@ -application.args=-port 11002 -#file.reference.galaxy.jar=D:\\Projects\\zap2\\ExternalLibraries\\Galaxy\\contrib\\MITRE\\bindings\\java\\lib\\galaxy.jar -javac.debug=false -javadoc.preview=false -user.properties.file=C:\\Documents and Settings\\tkharris.SCS\\.netbeans\\4.1\\build.properties Modified: tags/BTH-0.1/TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/BotTracker.java =================================================================== --- tags/BTH-0.1/TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/BotTracker.java 2006-11-08 15:54:45 UTC (rev 541) +++ tags/BTH-0.1/TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/BotTracker.java 2006-11-08 16:59:50 UTC (rev 542) @@ -1,95 +1,90 @@ package edu.cmu.ravenclaw.pendecoder; import java.util.*; -import java.awt.*; -import java.io.*; import edu.cmu.ravenclaw.pendecoder.scribble3.*; +import java.awt.Graphics; -public class BotTracker extends Thread { - protected ScribbleCanvas canvas; - protected float bot1x, bot1y, bot2x, bot2y, bot1r, bot2r; - protected int size = 3; +public class BotTracker { + protected ScribbleCanvas canvas; + protected final static int size = 3; + + protected HashMap bots = new HashMap(); + protected HashMap names = new HashMap(); + + BotTracker(ScribbleCanvas c) { + canvas = c; + } + + public boolean setObject(String name, float x, float y) { + name.toUpperCase(); //names are always case insensitive + boolean obj_created = false; + ObjShape obj = getObj(name); + obj.setLocation(x, y); + canvas.repaint(); + return obj_created; + } + + public boolean setBot(String name, float x, float y, float r) { + name.toUpperCase(); //names are always case insensitive + boolean bot_created = false; + BotShape bot = getBot(name); + bot.setLocation(x, y, r); + canvas.repaint(); + return bot_created; + } - BotTracker(ScribbleCanvas c) { - canvas = c; - bot1x = 0; bot1y = 0; - bot2x = 0; bot2y = 0; - bot1r = 0; bot2r = 0; + private synchronized ObjShape getObj(String name) { + ObjShape obj = objOf(name); + if(obj == null) { + System.err.println("adding bot named: " + name); + //int botplace = 1000 + bots.size()*20; + //bot = new BotShape(name, botplace, -botplace, r); + obj = new ObjShape(name, canvas.colorGenerator); + bots.put(name, obj); + names.put(obj, name); + canvas.addShape(obj); } + return obj; + } - public void run() { - File botlocs = null; - try { - botlocs = new File("botlocs.txt"); - } catch (Exception e) { - System.err.println("bottracker: " + e.toString()); - System.exit(1); - } - - HashMap bots = new HashMap(); - - /* - BotShape bot1, bot2; - bot1 = new BotShape("dot", 3000, 3000, 0F); - bot2 = new BotShape("brain", 3000, 3500, (float) Math.PI); - - bot1.x = bot1x; - bot1.y = bot1y; - bot1.rad = bot1r; - canvas.addShape(bot1); - bot2.x = bot2x; - bot2.y = bot2y; - bot2.rad = bot2r; - canvas.addShape(bot2); - */ - //Random movement = new Random((new Date()).getTime()); - for(;;) { - Graphics g = canvas.getGraphics(); - g.setPaintMode(); - canvas.repaint(); - - try { - sleep(500); - } catch(InterruptedException e) { - } - BufferedReader reader = null; - try { - reader = new BufferedReader(new FileReader(botlocs)); - String line; - while(reader.ready()) { - line = reader.readLine(); - String [] stuff = line.split(":"); - String name = stuff[0]; - float botx = Float.parseFloat(stuff[1]); - float boty = Float.parseFloat(stuff[2]); - float botr = Float.parseFloat(stuff[3]); - BotShape bot = bots.get(name); - if(bot == null) { - int botplace = 1000 + bots.size()*20; - bot = new BotShape(name, botplace, botplace, 0F); - bots.put(name, bot); - canvas.addShape(bot); - } - bot.setLocation(botx, boty, botr); - } - } catch (Exception e) { - System.err.println("tracker: problem reading"); - continue; - } - -/* - float speed = 33*movement.nextFloat(); - bot1x += speed*Math.cos(bot1.rad); - bot1y += speed*Math.sin(bot1.rad); - bot1r += (movement.nextFloat() - 0.5)/4; - bot1.setLocation(bot1x, bot1y, bot1r); - - speed = 33*movement.nextFloat(); - bot2x += speed*Math.cos(bot2.rad); - bot2y += speed*Math.sin(bot2.rad); - bot2r += (movement.nextFloat() - 0.5)/4; - bot2.setLocation(bot2x, bot2y, bot2r); - */ - } + private synchronized BotShape getBot(String name) { + BotShape bot = botOf(name); + if(bot == null) { + System.err.println("adding bot named: " + name); + //int botplace = 1000 + bots.size()*20; + //bot = new BotShape(name, botplace, -botplace, r); + bot = new BotShape(name, canvas.colorGenerator); + bots.put(name, bot); + names.put(bot, name); + canvas.addShape(bot); } + return bot; + } + + public void setGoal(java.lang.String name, boolean relative, float x, float y) { + 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); + } + } + + public String nameOf(BotShape bot) { + return names.get(bot); + } + + public ObjShape objOf(String name) { + Shape s = bots.get(name); + if(s instanceof ObjShape) return (ObjShape)s; + else return null; + } + + public BotShape botOf(String name) { + Shape s = bots.get(name); + if(s instanceof BotShape) return (BotShape)s; + else return null; + } } Deleted: tags/BTH-0.1/TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/BotTracker_2.java =================================================================== --- tags/BTH-0.1/TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/BotTracker_2.java 2006-11-08 15:54:45 UTC (rev 541) +++ tags/BTH-0.1/TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/BotTracker_2.java 2006-11-08 16:59:50 UTC (rev 542) @@ -1,90 +0,0 @@ -package edu.cmu.ravenclaw.pendecoder; - -import java.util.*; -import edu.cmu.ravenclaw.pendecoder.scribble3.*; -import java.awt.Graphics; - -public class BotTracker_2 { - protected ScribbleCanvas canvas; - protected final static int size = 3; - - protected HashMap bots = new HashMap(); - protected HashMap names = new HashMap(); - - BotTracker_2(ScribbleCanvas c) { - canvas = c; - } - - public boolean setObject(String name, float x, float y) { - name.toUpperCase(); //names are always case insensitive - boolean obj_created = false; - ObjShape obj = getObj(name); - obj.setLocation(x, y); - canvas.repaint(); - return obj_created; - } - - public boolean setBot(String name, float x, float y, float r) { - name.toUpperCase(); //names are always case insensitive - boolean bot_created = false; - BotShape bot = getBot(name); - bot.setLocation(x, y, r); - canvas.repaint(); - return bot_created; - } - - private synchronized ObjShape getObj(String name) { - ObjShape obj = objOf(name); - if(obj == null) { - System.err.println("adding bot named: " + name); - //int botplace = 1000 + bots.size()*20; - //bot = new BotShape(name, botplace, -botplace, r); - obj = new ObjShape(name, canvas.colorGenerator); - bots.put(name, obj); - names.put(obj, name); - canvas.addShape(obj); - } - return obj; - } - - private synchronized BotShape getBot(String name) { - BotShape bot = botOf(name); - if(bot == null) { - System.err.println("adding bot named: " + name); - //int botplace = 1000 + bots.size()*20; - //bot = new BotShape(name, botplace, -botplace, r); - bot = new BotShape(name, canvas.colorGenerator); - bots.put(name, bot); - names.put(bot, name); - canvas.addShape(bot); - } - return bot; - } - - public void setGoal(java.lang.String name, boolean relative, float x, float y) { - 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); - } - } - - public String nameOf(BotShape bot) { - return names.get(bot); - } - - public ObjShape objOf(String name) { - Shape s = bots.get(name); - if(s instanceof ObjShape) return (ObjShape)s; - else return null; - } - - public BotShape botOf(String name) { - Shape s = bots.get(name); - if(s instanceof BotShape) return (BotShape)s; - else return null; - } -} Modified: tags/BTH-0.1/TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/PenDecoderServer.java =================================================================== --- tags/BTH-0.1/TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/PenDecoderServer.java 2006-11-08 15:54:45 UTC (rev 541) +++ tags/BTH-0.1/TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/PenDecoderServer.java 2006-11-08 16:59:50 UTC (rev 542) @@ -27,7 +27,7 @@ public static final int PORT = 11002; protected static DrawingPad frame = null; protected static int lastUttID = 0; - public static BotTracker_2 botTracker = null; + public static BotTracker botTracker = null; /** Creates a new instance of PenDecoderServer */ public PenDecoderServer(MainServer mainserver, java.net.Socket socket) throws IOException { @@ -38,7 +38,7 @@ frame.setVisible(true); //start tracking bots - botTracker = new BotTracker_2(frame.getCanvas()); + botTracker = new BotTracker(frame.getCanvas()); } frame.addServer(this); } Modified: tags/BTH-0.1/TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/scribble3/ScribbleTool.java =================================================================== --- tags/BTH-0.1/TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/scribble3/ScribbleTool.java 2006-11-08 15:54:45 UTC (rev 541) +++ tags/BTH-0.1/TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/scribble3/ScribbleTool.java 2006-11-08 16:59:50 UTC (rev 542) @@ -33,6 +33,7 @@ public void mouseClickedAt(Point p) {} public void mouseDoubleClickedAt(Point p) {} + public void mouseRightClickedAt(Point p) {} public void mouseMovedTo(Point p) {} public Icon getIcon() { Modified: tags/BTH-0.1/TeamTalk/Agents/PrimitiveComm/PrimitiveComm.vcproj =================================================================== --- tags/BTH-0.1/TeamTalk/Agents/PrimitiveComm/PrimitiveComm.vcproj 2006-11-08 15:54:45 UTC (rev 541) +++ tags/BTH-0.1/TeamTalk/Agents/PrimitiveComm/PrimitiveComm.vcproj 2006-11-08 16:59:50 UTC (rev 542) @@ -41,7 +41,7 @@ /dev/null),) -SCTP_FLAGS := -DUSE_SCTP -SCTP_LIBS := -lsctp -endif - -SRC_LIBS := $(patsubst %,lib/lib%.a,$(LIB_MODULES)) - - -#======================================================================# -# Common Includes -#======================================================================# - -INC_DIRS += $(ALL_MODULES) - -#======================================================================# -# Build Rules -#======================================================================# - -# all includes should be relative to top level, or in one of the -# following directories. They should *not* include "../" -CFLAGS += $(SCTP_FLAGS) $(GSL_FLAGS) $(XML_FLAGS) - -# sort and uniquefy them -CFLAGS := $(sort $(CFLAGS)) - -CFLAGS += -I. $(addprefix -I,$(INC_DIRS)) - - -# start with empty libraries -LIBS += $(MATH_LIBS) $(COMPRESS_LIBS) $(SCTP_LIBS) - - -# Each module will add to this -ALL_SRC := -ALL_BIN_TARGETS := -ALL_LIB_TARGETS := - -all: all_real - -# Include the description for each module -include $(patsubst %,%/Makefile.sub,$(BIN_MODULES) $(LIB_MODULES)) - -# Remove duplicates -ALL_SRC := $(sort $(ALL_SRC)) - -# Determine the object files -OBJ := \ - $(patsubst %.cc,%.o,$(filter %.cc,$(ALL_SRC))) \ - $(patsubst %.c,%.o,$(filter %.c,$(ALL_SRC))) \ - $(patsubst %.java,%.class,$(filter %.java,$(ALL_SRC))) - -# Determine the target files -ALL_BIN_TARGETS := $(addprefix $(BIN)/,$(ALL_BIN_TARGETS)) -ALL_LIB_TARGETS := $(addprefix $(LIB)/,$(ALL_LIB_TARGETS)) - -# Include the dependencies --include $(OBJ:.o=.d) - -# ignore implicit rules (I think) -.SUFFIXES: - -# rules to run unconditionally -# (i.e. those which do not generate a file the same name as the target) -.PHONY: doc - -# Compilation rule -%.o: %.cc - $(CC_ECHO) - $(Q)$(CC) $(CFLAGS) $(DEF) $(INC) -c $< -o $@ - -# Dependency generation rule -%.d: %.cc - $(DEP_ECHO) - $(Q)$(CC) $(CFLAGS) -MM $< | ./bin/fixdepend $(dir $<) > $@ - -all_real: $(ALL_BIN_TARGETS) $(ALL_LIB_TARGETS) - -doc: - doxygen doc/doxygen.cfg - -sloc: - find . -type f | grep -E ".*\.[ch]c?$$" | grep -v _darcs | xargs wc -l - -strip: - strip -v --strip-unneeded $(ALL_BIN_TARGETS) - -tarball: - $(Q)echo "Tarring up the project to $(ROOTDIR)" - $(Q)tar -czf ../$(ROOTDIR).tgz -C .. -X tarball_excludes $(ROOTDIR) - -ifdef INSTALLDIR -INSTALLDIR_LIB=$(INSTALLDIR)/lib -INSTALLDIR_INCLUDE=$(INSTALLDIR)/include -install: all_real - @echo "Installing to $(INSTALLDIR)" - @echo "Coping library files to $(INSTALLDIR_LIB)" - - @if [ ! -d $(INSTALLDIR_LIB) ] ; then \ - echo "Creating $(INSTALLDIR_LIB)"; \ - mkdir $(INSTALLDIR_LIB) ; \ - fi; - @cp $(LIB)/* $(INSTALLDIR_LIB) - - @if [ ! -d $(INSTALLDIR_INCLUDE) ] ; then \ - echo "Creating $(INSTALLDIR_INCLUDE)"; \ - mkdir $(INSTALLDIR_INCLUDE) ; \ - fi; - - @for d in $(LIB_MODULES) ; do \ - if [ ! -d $(INSTALLDIR_INCLUDE)/$$d ] ; then \ - echo "Creating $(INSTALLDIR_INCLUDE)/$$d" ; \ - mkdir $(INSTALLDIR_INCLUDE)/$$d ; \ - fi; \ - echo "Coping header files to $(INSTALLDIR_INCLUDE)/$$d" ; \ - cp $$d/*.h $(INSTALLDIR_INCLUDE)/$$d ; \ - done -else -install: - @echo "Please specify an install directory in Makefile.config" -endif - -clean: - $(CLEAN_ECHO) - $(Q)find . -type f -name "*.[od]" | xargs rm -f - $(Q)find . -type f -name "*~" | xargs rm -f - $(Q)find . -type f -name "*.class" | xargs rm -f - -cleanbin: - rm -f $(ALL_BIN_TARGETS) - -cleanlib: - rm -f $(ALL_LIB_TARGETS) - -cleandoc: - (cd doc/html; rm -f doxygen.css *.html *.png *.map *.md5 *.dot) - -cleandepend: - find . -name *.d -exec rm {} \; - -distclean: clean cleanbin cleanlib cleandoc cleandepend - -# don't need to do anything extra since dependencies are built automatically -depend: Copied: tags/BTH-0.1/TeamTalk/Agents/boeingLib/Makefile (from rev 541, TeamTalk/Agents/boeingLib/Makefile) =================================================================== --- tags/BTH-0.1/TeamTalk/Agents/boeingLib/Makefile (rev 0) +++ tags/BTH-0.1/TeamTalk/Agents/boeingLib/Makefile 2006-11-08 16:59:50 UTC (rev 542) @@ -0,0 +1,211 @@ +# This makefile is derived from James Bruces make file +# which is avialable under GPL as: +# +# (C) 2003-2005 James Bruce, Carnegie Mellon University +# Licensed under the GPL, version 2. See "doc/License.txt" or visit +# "http://www.gnu.org/copyleft/gpl.html" for details. +# +# Modifications by Brett Browning, Marc Zinck, Carnegie Mellon University + +include Makefile.config + +BIN_MODULES := utils +LIB_MODULES := boeing coralshared +OTHER_MODULES := +ALL_MODULES := $(OTHER_MODULES) $(LIB_MODULES) $(BIN_MODULES) +BIN := bin +LIB := lib + +# Get the cpu settings +CPU := $(shell ./bin/cpuflags) + +ROOTDIR=$(shell basename `pwd`) + +#======================================================================# +# Compilation options +#======================================================================# + +CC := g++-3.4 + +# CFlags base +CFLAGS += -Wall -D_GNU_SOURCE +CFLAGS += $(CPU) +CFLAGS += -ffast-math +CFLAGS += -g -O3 + +# uncomment to turn off asserts +# CFLAGS += -DNDEBUG + +# Definitions +DEF := + +#======================================================================# + +DEP_ECHO = @echo Dependency: $@ +CC_ECHO = @echo Compiling: $@ +LINK_ECHO = @echo Linking: $@ +CLEAN_ECHO = @echo Cleaning. + +ifneq ($(VERBOSE), 1) + Q := @ +endif + + +#======================================================================# +# Library settings + +GSL_LIBS := $(shell pkg-config --libs gsl --silence-errors) +GSL_FLAGS := $(shell pkg-config --cflags gsl --silence-errors) + +X_LIBS := -L/usr/X11R6/lib -lX11 +COMPRESS_LIBS := -lz -ljpeg +THREAD_LIBS := -lpthread +MATH_LIBS := -lm + +#XML_FLAGS := $(shell xml2-config --cflags) +#XML_LIBS := $(shell xml2-config --libs) + + +ifneq ($(shell ls /usr/lib/libsctp.a 2>/dev/null),) +SCTP_FLAGS := -DUSE_SCTP +SCTP_LIBS := -lsctp +endif + +SRC_LIBS := $(patsubst %,lib/lib%.a,$(LIB_MODULES)) + + +#======================================================================# +# Common Includes +#======================================================================# + +INC_DIRS += $(ALL_MODULES) + +#======================================================================# +# Build Rules +#======================================================================# + +# all includes should be relative to top level, or in one of the +# following directories. They should *not* include "../" +CFLAGS += $(SCTP_FLAGS) $(GSL_FLAGS) $(XML_FLAGS) + +# sort and uniquefy them +CFLAGS := $(sort $(CFLAGS)) + +CFLAGS += -I. $(addprefix -I,$(INC_DIRS)) + + +# start with empty libraries +LIBS += $(MATH_LIBS) $(COMPRESS_LIBS) $(SCTP_LIBS) + + +# Each module will add to this +ALL_SRC := +ALL_BIN_TARGETS := +ALL_LIB_TARGETS := + +all: all_real + +# Include the description for each module +include $(patsubst %,%/Makefile.sub,$(BIN_MODULES) $(LIB_MODULES)) + +# Remove duplicates +ALL_SRC := $(sort $(ALL_SRC)) + +# Determine the object files +OBJ := \ + $(patsubst %.cc,%.o,$(filter %.cc,$(ALL_SRC))) \ + $(patsubst %.c,%.o,$(filter %.c,$(ALL_SRC))) \ + $(patsubst %.java,%.class,$(filter %.java,$(ALL_SRC))) + +# Determine the target files +ALL_BIN_TARGETS := $(addprefix $(BIN)/,$(ALL_BIN_TARGETS)) +ALL_LIB_TARGETS := $(addprefix $(LIB)/,$(ALL_LIB_TARGETS)) + +# Include the dependencies +-include $(OBJ:.o=.d) + +# ignore implicit rules (I think) +.SUFFIXES: + +# rules to run unconditionally +# (i.e. those which do not generate a file the same name as the target) +.PHONY: doc + +# Compilation rule +%.o: %.cc + $(CC_ECHO) + $(Q)$(CC) $(CFLAGS) $(DEF) $(INC) -c $< -o $@ + +# Dependency generation rule +%.d: %.cc + $(DEP_ECHO) + $(Q)$(CC) $(CFLAGS) -MM $< | ./bin/fixdepend $(dir $<) > $@ + +all_real: $(ALL_BIN_TARGETS) $(ALL_LIB_TARGETS) + +doc: + doxygen doc/doxygen.cfg + +sloc: + find . -type f | grep -E ".*\.[ch]c?$$" | grep -v _darcs | xargs wc -l + +strip: + strip -v --strip-unneeded $(ALL_BIN_TARGETS) + +tarball: + $(Q)echo "Tarring up the project to $(ROOTDIR)" + $(Q)tar -czf ../$(ROOTDIR).tgz -C .. -X tarball_excludes $(ROOTDIR) + +ifdef INSTALLDIR +INSTALLDIR_LIB=$(INSTALLDIR)/lib +INSTALLDIR_INCLUDE=$(INSTALLDIR)/include +install: all_real + @echo "Installing to $(INSTALLDIR)" + @echo "Coping library files to $(INSTALLDIR_LIB)" + + @if [ ! -d $(INSTALLDIR_LIB) ] ; then \ + echo "Creating $(INSTALLDIR_LIB)"; \ + mkdir $(INSTALLDIR_LIB) ; \ + fi; + @cp $(LIB)/* $(INSTALLDIR_LIB) + + @if [ ! -d $(INSTALLDIR_INCLUDE) ] ; then \ + echo "Creating $(INSTALLDIR_INCLUDE)"; \ + mkdir $(INSTALLDIR_INCLUDE) ; \ + fi; + + @for d in $(LIB_MODULES) ; do \ + if [ ! -d $(INSTALLDIR_INCLUDE)/$$d ] ; then \ + echo "Creating $(INSTALLDIR_INCLUDE)/$$d" ; \ + mkdir $(INSTALLDIR_INCLUDE)/$$d ; \ + fi; \ + echo "Coping header files to $(INSTALLDIR_INCLUDE)/$$d" ; \ + cp $$d/*.h $(INSTALLDIR_INCLUDE)/$$d ; \ + done +else +install: + @echo "Please specify an install directory in Makefile.config" +endif + +clean: + $(CLEAN_ECHO) + $(Q)find . -type f -name "*.[od]" | xargs rm -f + $(Q)find . -type f -name "*~" | xargs rm -f + $(Q)find . -type f -name "*.class" | xargs rm -f + +cleanbin: + rm -f $(ALL_BIN_TARGETS) + +cleanlib: + rm -f $(ALL_LIB_TARGETS) + +cleandoc: + (cd doc/html; rm -f doxygen.css *.html *.png *.map *.md5 *.dot) + +cleandepend: + find . -name *.d -exec rm {} \; + +distclean: clean cleanbin cleanlib cleandoc cleandepend + +# don't need to do anything extra since dependencies are built automatically +depend: Deleted: tags/BTH-0.1/TeamTalk/Agents/boeingLib/Makefile.config =================================================================== --- TeamTalk/Agents/boeingLib/Makefile.config 2006-11-08 15:54:45 UTC (rev 541) +++ tags/BTH-0.1/TeamTalk/Agents/boeingLib/Makefile.config 2006-11-08 16:59:50 UTC (rev 542) @@ -1,4 +0,0 @@ -# Directory where lib and include directories will be placed -# For system wide usual use /usr/local/ - -INSTALLDIR=~/software/external/boeingLib Copied: tags/BTH-0.1/TeamTalk/Agents/boeingLib/Makefile.config (from rev 541, TeamTalk/Agents/boeingLib/Makefile.config) =================================================================== --- tags/BTH-0.1/TeamTalk/Agents/boeingLib/Makefile.config (rev 0) +++ tags/BTH-0.1/TeamTalk/Agents/boeingLib/Makefile.config 2006-11-08 16:59:50 UTC (rev 542) @@ -0,0 +1,4 @@ +# Directory where lib and include directories will be placed +# For system wide usual use /usr/local/ + +INSTALLDIR=~/software/external/boeingLib Deleted: tags/BTH-0.1/TeamTalk/Agents/boeingLib/README =================================================================== --- TeamTalk/Agents/boeingLib/README 2006-11-08 15:54:45 UTC (rev 541) +++ tags/BTH-0.1/TeamTalk/Agents/boeingLib/README 2006-11-08 16:59:50 UTC (rev 542) @@ -1,48 +0,0 @@ -INTRODUCTION ------------- - -This is the Boeing repository for storing the interfaces between the -Boeing Robot server/client and the Traderbot server/client. To compile -the code just run make in the base directory. This will produce -(hopefully) a library in the lib directory called libboeing.a for static -linkage with your program. It will also create a set of testing -utilities that can be used to test or interact with each of hte various -servers/clients. - -Testing Binaries: - -test_robot_server - runs a fake robot server on the default port -test_robot_client - runs a simple shell to talk to robot servers -test_trader_server - runs a fake traderbot server -test_trader_client - runs a simple shell to talk to the trader server - - -Known Dependencies: - -The code was compiled under gcc 3.3 on a debian x86 system. It has been -tested on Pentium 2, 3, 4, and M class machines. It makes use of the g++ -STL, and the configuration system uses the cpp pre processor. - -The robot client command line utility requires libreadline to be installed and the corresponding development packages (header + library). -In debian these can be installed with: - apt-get install libreadline5-dev -We are using version 5.1. - - -Directories: - -bin/ - output location for the testing binaries, and script files -lib/ - output location for the library libboeing.a -boeing/ - contains all of the boeing files (.h and .cc) -utils/ - testing files (.cc) -shared/ - shared utility files from the Coral research group (these are GPLed) - - -DEVELOPMENT TEAM ----------------- - -Brett Browning, M. Bernardine Dias, E. Gil Jones, Thomas Harris, Brenna Argall, Marc Zinck, Manuela Veloso, Tony Stentz, Alex Rudnicky - -Carnegie Mellon University - - Copied: tags/BTH-0.1/TeamTalk/Agents/boeingLib/README (from rev 541, TeamTalk/Agents/boeingLib/README) =================================================================== --- tags/BTH-0.1/TeamTalk/Agents/boeingLib/README (rev 0) +++ tags/BTH-0.1/TeamTalk/Agents/boeingLib/README 2006-11-08 16:59:50 UTC (rev 542) @@ -0,0 +1,48 @@ +INTRODUCTION +------------ + +This is the Boeing repository for storing the interfaces between the +Boeing Robot server/client and the Traderbot server/client. To compile +the code just run make in the base directory. This will produce +(hopefully) a library in the lib directory called libboeing.a for static +linkage with your program. It will also create a set of testing +utilities that can be used to test or interact with each of hte various +servers/clients. + +Testing Binaries: + +test_robot_server - runs a fake robot server on the default port +test_robot_client - runs a simple shell to talk to robot servers +test_trader_server - runs a fake traderbot server +test_trader_client - runs a simple shell to talk to the trader server + + +Known Dependencies: + +The code was compiled under gcc 3.3 on a debian x86 system. It has been +tested on Pentium 2, 3, 4, and M class machines. It makes use of the g++ +STL, and the configuration system uses the cpp pre processor. + +The robot client command line utility requires libreadline to be installed and the corresponding development packages (header + library). +In debian these can be installed with: + apt-get install libreadline5-dev +We are using version 5.1. + + +Directories: + +bin/ - output location for the testing binaries, and script files +lib/ - output location for the library libboeing.a +boeing/ - contains all of the boeing files (.h and .cc) +utils/ - testing files (.cc) +shared/ - shared utility files from the Coral research group (these are GPLed) + + +DEVELOPMENT TEAM +---------------- + +Brett Browning, M. Bernardine Dias, E. Gil Jones, Thomas Harris, Brenna Argall, Marc Zinck, Manuela Veloso, Tony Stentz, Alex Rudnicky + +Carnegie Mellon University + + Copied: tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing (from rev 541, TeamTalk/Agents/boeingLib/boeing) Deleted: tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/Makefile.sub =================================================================== --- TeamTalk/Agents/boeingLib/boeing/Makefile.sub 2006-11-08 15:54:45 UTC (rev 541) +++ tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/Makefile.sub 2006-11-08 16:59:50 UTC (rev 542) @@ -1,24 +0,0 @@ -DIR := boeing - -#==== lib ===================================================================# - - -#==== boeing_server =========================================================# - -SRC += $(wildcard $(DIR)/*.cc) - -SRC := $(filter-out test%.cc , $(SRC)) -SRC := $(shell ls -t $(sort $(SRC))) - -TARGET := libboeing.a - -LIB_BOEING_OBJ := $(SRC:.cc=.o) - -ALL_SRC += $(SRC) -ALL_LIB_TARGETS += $(TARGET) - -$(TARGET): $(LIB)/$(TARGET) - -$(LIB)/$(TARGET): $(LIB_BOEING_OBJ) - $(LINK_ECHO) - $(Q)$(AR) -r $@ $(LIB_BOEING_OBJ) Copied: tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/Makefile.sub (from rev 541, TeamTalk/Agents/boeingLib/boeing/Makefile.sub) =================================================================== --- tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/Makefile.sub (rev 0) +++ tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/Makefile.sub 2006-11-08 16:59:50 UTC (rev 542) @@ -0,0 +1,24 @@ +DIR := boeing + +#==== lib ===================================================================# + + +#==== boeing_server =========================================================# + +SRC += $(wildcard $(DIR)/*.cc) + +SRC := $(filter-out test%.cc , $(SRC)) +SRC := $(shell ls -t $(sort $(SRC))) + +TARGET := libboeing.a + +LIB_BOEING_OBJ := $(SRC:.cc=.o) + +ALL_SRC += $(SRC) +ALL_LIB_TARGETS += $(TARGET) + +$(TARGET): $(LIB)/$(TARGET) + +$(LIB)/$(TARGET): $(LIB_BOEING_OBJ) + $(LINK_ECHO) + $(Q)$(AR) -r $@ $(LIB_BOEING_OBJ) Deleted: tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_converter.cc =================================================================== --- TeamTalk/Agents/boeingLib/boeing/boeing_converter.cc 2006-11-08 15:54:45 UTC (rev 541) +++ tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_converter.cc 2006-11-08 16:59:50 UTC (rev 542) @@ -1,189 +0,0 @@ -#include "boeing_converter.h" -#include "util.h" -#include "error_check.h" - -#include "string_helper.h" - -static const int debug=false; - -using namespace Boeing; - -//==== Basic Parsing methods ============================ - -//==== Conversion methods =============================== - -/** convert from an action message into one of the predefined - command message packets. Returns the type of the message, - or -1 on failure to match a message. The result is put in the - union msgcmd -*/ -int Boeing::convert(MsgCmdAction *mca,MsgCmd &result) -{ - // first set up the message header - mzero(result); - result.hdr.tstamp = mca->tstamp; - result.msg_cmdtask.taskid = mca->taskid; - - // take initial guess to save some typing - result.hdr.len = sizeof(MsgCmdTask); - - // string of leading characters - string name; - string action=mca->action; - char *params; - int pi = extractWord(mca->action,name); - if (pi<0) { - if (debug) { - printf(" %s: Failed to extract action name from %s\n", - __PRETTY_FUNCTION__,mca->action); - } - return -1; - } - - params=NULL; - if (pi>0 && pi<(int)strlen(mca->action)) { - params = mca->action + pi; - params = (char*)(stripBraces(params).c_str()); - } - - if (debug) - printf(" Got %s message\n", name.c_str()); - - int rv; - - // now work out what message it is - if (name == "halt") { - if (debug) - printf(" Got halt message\n"); - result.hdr.type = CMD_HALT; - - } else if (name == "goto") { - if (debug) - printf(" Goto message\n"); - if (!params) { - fprintf(stderr, " Malformed goto message '%s'\n",mca->action); - return -1; - } - - result.hdr.type = CMD_GOTO; - result.hdr.len = sizeof(MsgCmdGoTo); - - result.msg_goto.attr = 0; - - char temp[1024]; - - rv=sscanf(params, " %s %f%*[,: ] %f%*[,: ] %f", - temp,&result.msg_goto.x,&result.msg_goto.y, - &result.msg_goto.angle); - - if (rv<3) { - fprintf(stderr, " Malformed goto message '%s'\n",mca->action); - return -1; - } else if (rv==4) { - result.msg_goto.attr |= MsgCmdGoTo::UseAngle; - } - - if(strncasecmp(temp,"rel",64) == 0) { - result.msg_goto.attr |= MsgCmdGoTo::Relative; - } - } else if (name == "home") { - if (debug) - printf(" Got home message\n"); - result.hdr.type = CMD_HOME; - } else if (name == "pause") { - if (debug) - printf(" Got pause message\n"); - result.hdr.type = CMD_PAUSE; - } else if (name == "resume") { - if (debug) - printf(" Got resume message\n"); - result.hdr.type = CMD_RESUME; - } else if (name == "follow") { - if (debug) - printf(" Got follow message\n"); - result.hdr.type = CMD_FOLLOW; - result.hdr.len = sizeof(MsgCmdFollow); - - memset(result.msg_follow.ip,0,MAX_STRING_LENGTH); - memset(result.msg_follow.search,0,MAX_STRING_LENGTH); - - if (params) { - Strings param_array; - extractParameterArray(params,param_array); - - char temp[1024]; - for (size_t j=0; j0) { - strncpy(result.msg_follow.ip,temp,MAX_STRING_LENGTH-1); - } else if (sscanf(param_array[j].c_str(),"SEARCH=%1023s",temp)>0) { - strncpy(result.msg_follow.search,temp,MAX_STRING_LENGTH-1); - } - } - } - - } else if (name == "cover") { - if (debug) - printf(" Got cover message\n"); - if (!params) { - printf(" Malformed cover message\n"); - return -1; - } - - result.hdr.type = CMD_COVER; - result.hdr.len = sizeof(MsgCmdCover); - - printf("str='%s'\n",params); - - Strings param_array; - extractParameterArray(params,param_array); - - printf("str='%s'\n",params); - for (size_t j=0; jaction); - } - - return (result.hdr.type); -} - -/** - * strip off the brackets so that we are compatable with the language - * syntax. We just replace them with spaces - */ -string Boeing::stripBraces(char const *msg) -{ - string s=msg; - - // really nasty way of doing it... - char *cp; - for (cp=(char *)s.c_str(); cp && *cp; cp++) { - if (*cp=='(' || *cp==')') - *cp=' '; - } - return s; -} - Copied: tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_converter.cc (from rev 541, TeamTalk/Agents/boeingLib/boeing/boeing_converter.cc) =================================================================== --- tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_converter.cc (rev 0) +++ tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_converter.cc 2006-11-08 16:59:50 UTC (rev 542) @@ -0,0 +1,189 @@ +#include "boeing_converter.h" +#include "util.h" +#include "error_check.h" + +#include "string_helper.h" + +static const int debug=false; + +using namespace Boeing; + +//==== Basic Parsing methods ============================ + +//==== Conversion methods =============================== + +/** convert from an action message into one of the predefined + command message packets. Returns the type of the message, + or -1 on failure to match a message. The result is put in the + union msgcmd +*/ +int Boeing::convert(MsgCmdAction *mca,MsgCmd &result) +{ + // first set up the message header + mzero(result); + result.hdr.tstamp = mca->tstamp; + result.msg_cmdtask.taskid = mca->taskid; + + // take initial guess to save some typing + result.hdr.len = sizeof(MsgCmdTask); + + // string of leading characters + string name; + string action=mca->action; + char *params; + int pi = extractWord(mca->action,name); + if (pi<0) { + if (debug) { + printf(" %s: Failed to extract action name from %s\n", + __PRETTY_FUNCTION__,mca->action); + } + return -1; + } + + params=NULL; + if (pi>0 && pi<(int)strlen(mca->action)) { + params = mca->action + pi; + params = (char*)(stripBraces(params).c_str()); + } + + if (debug) + printf(" Got %s message\n", name.c_str()); + + int rv; + + // now work out what message it is + if (name == "halt") { + if (debug) + printf(" Got halt message\n"); + result.hdr.type = CMD_HALT; + + } else if (name == "goto") { + if (debug) + printf(" Goto message\n"); + if (!params) { + fprintf(stderr, " Malformed goto message '%s'\n",mca->action); + return -1; + } + + result.hdr.type = CMD_GOTO; + result.hdr.len = sizeof(MsgCmdGoTo); + + result.msg_goto.attr = 0; + + char temp[1024]; + + rv=sscanf(params, " %s %f%*[,: ] %f%*[,: ] %f", + temp,&result.msg_goto.x,&result.msg_goto.y, + &result.msg_goto.angle); + + if (rv<3) { + fprintf(stderr, " Malformed goto message '%s'\n",mca->action); + return -1; + } else if (rv==4) { + result.msg_goto.attr |= MsgCmdGoTo::UseAngle; + } + + if(strncasecmp(temp,"rel",64) == 0) { + result.msg_goto.attr |= MsgCmdGoTo::Relative; + } + } else if (name == "home") { + if (debug) + printf(" Got home message\n"); + result.hdr.type = CMD_HOME; + } else if (name == "pause") { + if (debug) + printf(" Got pause message\n"); + result.hdr.type = CMD_PAUSE; + } else if (name == "resume") { + if (debug) + printf(" Got resume message\n"); + result.hdr.type = CMD_RESUME; + } else if (name == "follow") { + if (debug) + printf(" Got follow message\n"); + result.hdr.type = CMD_FOLLOW; + result.hdr.len = sizeof(MsgCmdFollow); + + memset(result.msg_follow.ip,0,MAX_STRING_LENGTH); + memset(result.msg_follow.search,0,MAX_STRING_LENGTH); + + if (params) { + Strings param_array; + extractParameterArray(params,param_array); + + char temp[1024]; + for (size_t j=0; j0) { + strncpy(result.msg_follow.ip,temp,MAX_STRING_LENGTH-1); + } else if (sscanf(param_array[j].c_str(),"SEARCH=%1023s",temp)>0) { + strncpy(result.msg_follow.search,temp,MAX_STRING_LENGTH-1); + } + } + } + + } else if (name == "cover") { + if (debug) + printf(" Got cover message\n"); + if (!params) { + printf(" Malformed cover message\n"); + return -1; + } + + result.hdr.type = CMD_COVER; + result.hdr.len = sizeof(MsgCmdCover); + + printf("str='%s'\n",params); + + Strings param_array; + extractParameterArray(params,param_array); + + printf("str='%s'\n",params); + for (size_t j=0; jaction); + } + + return (result.hdr.type); +} + +/** + * strip off the brackets so that we are compatable with the language + * syntax. We just replace them with spaces + */ +string Boeing::stripBraces(char const *msg) +{ + string s=msg; + + // really nasty way of doing it... + char *cp; + for (cp=(char *)s.c_str(); cp && *cp; cp++) { + if (*cp=='(' || *cp==')') + *cp=' '; + } + return s; +} + Deleted: tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_converter.h =================================================================== --- TeamTalk/Agents/boeingLib/boeing/boeing_converter.h 2006-11-08 15:54:45 UTC (rev 541) +++ tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_converter.h 2006-11-08 16:59:50 UTC (rev 542) @@ -1,30 +0,0 @@ -#ifndef __BOEING_CONVERTER_H__ -#define __BOEING_CONVERTER_H__ - -#include -#include -#include -#include "boeing_robot_packet.h" - -using std::string; -using std::vector; - -namespace Boeing { - - //==== Conversion methods =============================== - - /** convert from an action message into one of the predefined - command message packets. Returns the type of the message, - or -1 on failure to match a message. The result is put in the - union msgcmd - */ - int convert(Boeing::MsgCmdAction *mcpa,Boeing::MsgCmd &result); - - /** - * strip off the brackets so that we are compatable with the language - * syntax. We just replace them with spaces - */ - string stripBraces(char const *msg); -}; - -#endif Copied: tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_converter.h (from rev 541, TeamTalk/Agents/boeingLib/boeing/boeing_converter.h) =================================================================== --- tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_converter.h (rev 0) +++ tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_converter.h 2006-11-08 16:59:50 UTC (rev 542) @@ -0,0 +1,30 @@ +#ifndef __BOEING_CONVERTER_H__ +#define __BOEING_CONVERTER_H__ + +#include +#include +#include +#include "boeing_robot_packet.h" + +using std::string; +using std::vector; + +namespace Boeing { + + //==== Conversion methods =============================== + + /** convert from an action message into one of the predefined + command message packets. Returns the type of the message, + or -1 on failure to match a message. The result is put in the + union msgcmd + */ + int convert(Boeing::MsgCmdAction *mcpa,Boeing::MsgCmd &result); + + /** + * strip off the brackets so that we are compatable with the language + * syntax. We just replace them with spaces + */ + string stripBraces(char const *msg); +}; + +#endif Deleted: tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_map_client.cc =================================================================== --- TeamTalk/Agents/boeingLib/boeing/boeing_map_client.cc 2006-11-08 15:54:45 UTC (rev 541) +++ tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_map_client.cc 2006-11-08 16:59:50 UTC (rev 542) @@ -1,179 +0,0 @@ -#include - -#include -#include -#include -#include -#include - -#ifndef WIN32 -#include -#endif - -#include "boeing_map_client.h" - -#include -#include - -using namespace Boeing; -using namespace std; - -static const bool debug_flag = false; - - -//=== Debugging ================================ -static void debug(char const *fmt,...) -{ - if (debug_flag) { - va_list ap; - va_start(ap,fmt); - printf("BOEING Map CLIENT: "); - vprintf(fmt,ap); - va_end(ap); - } -} - -MapClient::MapClient() { - sock = new UDPSocket(); -} - -MapClient::~MapClient(){ - close(); - delete sock; -} - -int MapClient::open(char const *h, int p) -{ - sock->set(-1,-1); - - // open the socket - if (sock->connectClient(h,p) <= 0) { - fprintf(stderr, "ERROR: Cannot open client socket %s:%i\n", h,p); - return false; - } - return true; -} - -void MapClient::close() -{ - debug("closing\n"); - sock->disconnect(); -} - - -//=== Sending ========================================== - -bool MapClient::sendPacket(MsgHeader *msg) -{ - if (!isConnected()) { - printf("Not connected!\n"); - return false; - } - - debug("Sending msg type %x len %i\n",msg->type,msg->len); - - // set time info - msg->tstamp = Profiler::getTimeOfDay(); - sock->send(msg, msg->len); - - // return the status - return (true); -} - -bool MapClient::sendSubscribe(short invoice) { - MsgMapReq msg; - - msg.type = MAP_SUBSCRIBE; - msg.invoice = invoice; - msg.len = sizeof(MsgMapReq); - - return sendPacket(&msg); -} - -bool MapClient::sendUnsubscribe(short invoice) { - MsgMapReq msg; - - msg.type = MAP_UNSUBSCRIBE; - msg.invoice = invoice; - msg.len = sizeof(MsgMapReq); - - return sendPacket(&msg); -} - -bool MapClient::sendKeepAlive(short invoice) { - MsgMapReq msg; - - msg.type = MAP_KEEPALIVE; - msg.invoice = invoice; - msg.len = sizeof(MsgMapReq); - - return sendPacket(&msg); -} - -bool MapClient::sendAck(short invoice, int seq) { - MsgMapReq msg; - - msg.type = MAP_ACK; - msg.invoice = invoice; - msg.seq = seq; - msg.len = sizeof(MsgMapReq); - - return sendPacket(&msg); -} - -//=== Receiving ====================================== - -const MsgMapClient *MapClient::getNextMessage() -{ - // block for something, then read your socket - - int fd; - fd_set rfds; - int retval; - - if (!isConnected()) { - printf("WARNING: Not connected\n"); - return NULL; - } - - fd = sock->getFD(); - FD_ZERO(&rfds); - FD_SET(fd, &rfds); - retval = select(fd+1,&rfds,NULL,NULL,NULL); - if(retval < 0){ - fprintf(stderr, "ERROR: select(...) : %s\n",strerror(errno)); - return NULL; - } - - // receive the header... - int rv = sock->recv(rxdata.buff,sizeof(rxdata)); - - debug("Got message rv %i, type %x len %u\n",rv, - rxdata.hdr.type,rxdata.hdr.len); - - if (rv!=rxdata.hdr.len) { - printf("WARNING: size mismatch! %i, but packet says %i\n", - rv,rxdata.hdr.len); - } else { - sendAck(rxdata.map.invoice, rxdata.map.seq); - cerr << "acked invoice " << rxdata.map.invoice << " seq " << rxdata.map.seq << endl; - } - - if (0 && debug_flag) { - printf("received = "); - for (int i=0; i0 && rv==rxdata.hdr.len) ? &rxdata : NULL); -} - -int MapClient::isConnected(){ - return sock->isConnected(); -} - -int MapClient::getFD(){ - return sock->getFD(); -} Copied: tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_map_client.cc (from rev 541, TeamTalk/Agents/boeingLib/boeing/boeing_map_client.cc) =================================================================== --- tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_map_client.cc (rev 0) +++ tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_map_client.cc 2006-11-08 16:59:50 UTC (rev 542) @@ -0,0 +1,179 @@ +#include + +#include +#include +#include +#include +#include + +#ifndef WIN32 +#include +#endif + +#include "boeing_map_client.h" + +#include +#include + +using namespace Boeing; +using namespace std; + +static const bool debug_flag = false; + + +//=== Debugging ================================ +static void debug(char const *fmt,...) +{ + if (debug_flag) { + va_list ap; + va_start(ap,fmt); + printf("BOEING Map CLIENT: "); + vprintf(fmt,ap); + va_end(ap); + } +} + +MapClient::MapClient() { + sock = new UDPSocket(); +} + +MapClient::~MapClient(){ + close(); + delete sock; +} + +int MapClient::open(char const *h, int p) +{ + sock->set(-1,-1); + + // open the socket + if (sock->connectClient(h,p) <= 0) { + fprintf(stderr, "ERROR: Cannot open client socket %s:%i\n", h,p); + return false; + } + return true; +} + +void MapClient::close() +{ + debug("closing\n"); + sock->disconnect(); +} + + +//=== Sending ========================================== + +bool MapClient::sendPacket(MsgHeader *msg) +{ + if (!isConnected()) { + printf("Not connected!\n"); + return false; + } + + debug("Sending msg type %x len %i\n",msg->type,msg->len); + + // set time info + msg->tstamp = Profiler::getTimeOfDay(); + sock->send(msg, msg->len); + + // return the status + return (true); +} + +bool MapClient::sendSubscribe(short invoice) { + MsgMapReq msg; + + msg.type = MAP_SUBSCRIBE; + msg.invoice = invoice; + msg.len = sizeof(MsgMapReq); + + return sendPacket(&msg); +} + +bool MapClient::sendUnsubscribe(short invoice) { + MsgMapReq msg; + + msg.type = MAP_UNSUBSCRIBE; + msg.invoice = invoice; + msg.len = sizeof(MsgMapReq); + + return sendPacket(&msg); +} + +bool MapClient::sendKeepAlive(short invoice) { + MsgMapReq msg; + + msg.type = MAP_KEEPALIVE; + msg.invoice = invoice; + msg.len = sizeof(MsgMapReq); + + return sendPacket(&msg); +} + +bool MapClient::sendAck(short invoice, int seq) { + MsgMapReq msg; + + msg.type = MAP_ACK; + msg.invoice = invoice; + msg.seq = seq; + msg.len = sizeof(MsgMapReq); + + return sendPacket(&msg); +} + +//=== Receiving ====================================== + +const MsgMapClient *MapClient::getNextMessage() +{ + // block for something, then read your socket + + int fd; + fd_set rfds; + int retval; + + if (!isConnected()) { + printf("WARNING: Not connected\n"); + return NULL; + } + + fd = sock->getFD(); + FD_ZERO(&rfds); + FD_SET(fd, &rfds); + retval = select(fd+1,&rfds,NULL,NULL,NULL); + if(retval < 0){ + fprintf(stderr, "ERROR: select(...) : %s\n",strerror(errno)); + return NULL; + } + + // receive the header... + int rv = sock->recv(rxdata.buff,sizeof(rxdata)); + + debug("Got message rv %i, type %x len %u\n",rv, + rxdata.hdr.type,rxdata.hdr.len); + + if (rv!=rxdata.hdr.len) { + printf("WARNING: size mismatch! %i, but packet says %i\n", + rv,rxdata.hdr.len); + } else { + sendAck(rxdata.map.invoice, rxdata.map.seq); + cerr << "acked invoice " << rxdata.map.invoice << " seq " << rxdata.map.seq << endl; + } + + if (0 && debug_flag) { + printf("received = "); + for (int i=0; i0 && rv==rxdata.hdr.len) ? &rxdata : NULL); +} + +int MapClient::isConnected(){ + return sock->isConnected(); +} + +int MapClient::getFD(){ + return sock->getFD(); +} Deleted: tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_map_client.h =================================================================== --- TeamTalk/Agents/boeingLib/boeing/boeing_map_client.h 2006-11-08 15:54:45 UTC (rev 541) +++ tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_map_client.h 2006-11-08 16:59:50 UTC (rev 542) @@ -1,61 +0,0 @@ -/** - Boeing Map client == -*/ - -#ifndef __BOEING_MAP_CLIENT_H__ -#define __BOEING_MAP_CLIENT_H__ - -#include -#include -using std::vector; -using std::string; - -#include "boeing_map_packet.h" - -class UDPSocket; - -// client class to manage UDP connections to robots -namespace Boeing { - - class MapClient { - private: - UDPSocket *sock; - MsgMapClient rxdata; - - public: - //=== Initiialization =================================== - - // fill out any constructor/destructor info you need - MapClient(); - ~MapClient(); - - /// returns the target client number - int open(char const *h, int p = MAP_PORT); - void close(); - - //=== Sending ========================================== - - bool sendSubscribe(short invoice); - bool sendUnsubscribe(short invoice); - bool sendKeepAlive(short invoice); - bool sendAck(short invoice, int seq); - - //=== Receiving ====================================== - - /** returns a pointer to the next received message. - REturns NULL on failure. Sets the client to be - the id of the sending client */ - const MsgMapClient *getNextMessage(); - - int isConnected(); - int getFD(); - - private: - //=== Local methods ========================== - // private method to actually send stuff out the socket - bool sendPacket(MsgHeader *msg); - - }; -}; - -#endif Copied: tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_map_client.h (from rev 541, TeamTalk/Agents/boeingLib/boeing/boeing_map_client.h) =================================================================== --- tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_map_client.h (rev 0) +++ tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_map_client.h 2006-11-08 16:59:50 UTC (rev 542) @@ -0,0 +1,61 @@ +/** + Boeing Map client == +*/ + +#ifndef __BOEING_MAP_CLIENT_H__ +#define __BOEING_MAP_CLIENT_H__ + +#include +#include +using std::vector; +using std::string; + +#include "boeing_map_packet.h" + +class UDPSocket; + +// client class to manage UDP connections to robots +namespace Boeing { + + class MapClient { + private: + UDPSocket *sock; + MsgMapClient rxdata; + + public: + //=== Initiialization =================================== + + // fill out any constructor/destructor info you need + MapClient(); + ~MapClient(); + + /// returns the target client number + int open(char const *h, int p = MAP_PORT); + void close(); + + //=== Sending ========================================== + + bool sendSubscribe(short invoice); + bool sendUnsubscribe(short invoice); + bool sendKeepAlive(short invoice); + bool sendAck(short invoice, int seq); + + //=== Receiving ====================================== + + /** returns a pointer to the next received message. + REturns NULL on failure. Sets the client to be + the id of the sending client */ + const MsgMapClient *getNextMessage(); + + int isConnected(); + int getFD(); + + private: + //=== Local methods ========================== + // private method to actually send stuff out the socket + bool sendPacket(MsgHeader *msg); + + }; +}; + +#endif Deleted: tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_map_packet.cc =================================================================== --- TeamTalk/Agents/boeingLib/boeing/boeing_map_packet.cc 2006-11-08 15:54:45 UTC (rev 541) +++ tags/BTH-0.1/TeamTalk/Agents/boeingLib/boeing/boeing_map_packet.cc 2006-11-08 16:59:50 UTC (rev 542) @@ -1,118 +0,0 @@ -#include - -#include "boeing_map_packet.h" - -using namespace Boeing; -using namespace std; - -void MsgMap::MsgMapFactory(MapMsgEncoding encoding, - MsgMap *buf, const unsigned char* raw_map, int raw_map_size, - short invoice, int seq, - int x_in, int y_in, int resolution_in) { - buf->invoice = invoice; buf->seq = seq; - buf->x = x_in; buf->y = y_in; - buf->resolution = resolution_in; - unsigned char *msgMapData = ((unsigned char*)buf)+sizeof(MsgMap)-sizeof(int); - buf->array_length = encodeMap(encoding, msgMapData, raw_map, raw_map_size); - buf->encoding = encoding; -} - -int MsgMap::getSize() const { - switch(encoding) { - case MAP_RLE: - return sizeof(MsgMap)+sizeof(int)*(array_length-1); - case MAP_RAW: - case MAP_JPEG: - return sizeof(MsgMap)-sizeof(int)+array_length; - default: - cerr << "unknown encoding" << endl; - } - return 0; -} - -int MsgMap::getBuffSize() const { - switch(encoding) { - case MAP_RAW: - case MAP_JPEG: - return array_length; - case MAP_RLE: - return x*y; - default: cerr << "unknown encoding" << endl; - } - return 0; -} - -void MsgMap::unencodeMap(MapMsgEncoding encoding, - unsigned char *raw_map, - const unsigned char* compressed_map, - int compressed_map_size) { - switch(encoding) { - case MAP_RAW: - case MAP_JPEG: - memcpy(raw_map, compressed_map, compressed_map_size); - break; - case MAP_RLE: - unencodeMap_RLE(raw_map, compressed_map, compressed_map_size); - break; - default: cerr << "unknown encoding" << endl; - } -} - -void MsgMap::decode(unsigned char *raw_map) const { - unencodeMap((MapMsgEncoding)encoding, raw_map, (const unsigned char *)map, array_length); -} - -void MsgMap::unencodeMap_RLE(unsigned char *raw_map, - const unsigned char* compressed_map, - int compressed_map_size) { - int j=0, k=0; - for(int i=0; i>8; - char run_value = (char) (compressed_map[i]&0x000000FF); - for(; j + +#include "boeing_map_packet.h" + +using namespace Boeing; +using namespace std; + +void MsgMap::MsgMapFactory(MapMsgEncoding encoding, @@ Diff output truncated at 60000 characters. @@ From tk at edam.speech.cs.cmu.edu Wed Nov 8 15:05:26 2006 From: tk at edam.speech.cs.cmu.edu (tk@edam.speech.cs.cmu.edu) Date: Wed, 8 Nov 2006 15:05:26 -0500 Subject: [TeamTalk 6]: [543] TeamTalk/Agents/PrimitiveComm: Added MsgCmdSetPos class. Message-ID: <200611082005.kA8K5Q6j017978@edam.speech.cs.cmu.edu> An HTML attachment was scrubbed... URL: http://mailman.srv.cs.cmu.edu/pipermail/teamtalk-developers/attachments/20061108/8fab39ae/attachment.html -------------- next part -------------- Modified: TeamTalk/Agents/PrimitiveComm/robot_packet.cpp =================================================================== --- TeamTalk/Agents/PrimitiveComm/robot_packet.cpp 2006-11-08 16:59:50 UTC (rev 542) +++ TeamTalk/Agents/PrimitiveComm/robot_packet.cpp 2006-11-08 20:05:26 UTC (rev 543) @@ -195,7 +195,8 @@ }; */ -MsgCmdActionPP::MsgCmdActionPP(MsgCmdAction c) : content_(c) {} +MsgCmdActionPP::MsgCmdActionPP() {} +MsgCmdActionPP::MsgCmdActionPP(const MsgCmdAction& c) : content_(c) {} MsgHeader* MsgCmdActionPP::header() {return (MsgHeader*)&content_;}; string MsgCmdActionPP::render() const { return content_.action; @@ -607,3 +608,30 @@ retval.len = retval.getSize(); return retval; } + +const char *const MsgCmdSetPos::scan_template = "setpos (%d %d) %d"; + +bool MsgCmdSetPos::parse() { + int numscanned = sscanf(content_.action, scan_template, x_, y_, angle_); + if(numscanned != 3) { + cerr << "problem parsing setpos: \"" << content_.action + << "\" with scan template: " << scan_template << endl; + cerr << "got only " << numscanned << " tokens" << endl; + return false; + } + return true; +} + +MsgCmdSetPos::MsgCmdSetPos(const Boeing::MsgCmdAction& x) : MsgCmdActionPP(x) { + parse(); +} + +MsgCmdSetPos::MsgCmdSetPos(double x, double y, double a) : x_(x), y_(y), angle_(a) { + ostringstream cmd_string; + cmd_string << "setpos (" << x << ' ' << y << ") " << a; + content_ = construct_MsgCmdAction(cmd_string.str()); +} + +double MsgCmdSetPos::getX() const {return x_;} +double MsgCmdSetPos::getY() const {return y_;} +double MsgCmdSetPos::getAngle() const {return angle_;} \ No newline at end of file Modified: TeamTalk/Agents/PrimitiveComm/robot_packet.hpp =================================================================== --- TeamTalk/Agents/PrimitiveComm/robot_packet.hpp 2006-11-08 16:59:50 UTC (rev 542) +++ TeamTalk/Agents/PrimitiveComm/robot_packet.hpp 2006-11-08 20:05:26 UTC (rev 543) @@ -73,15 +73,30 @@ class MsgCmdActionPP : public Msg { friend class Msg; protected: - Boeing::MsgCmdAction content_; + Boeing::MsgCmdAction content_; Boeing::MsgHeader* header(); + MsgCmdActionPP(); public: - MsgCmdActionPP(Boeing::MsgCmdAction c); + MsgCmdActionPP(const Boeing::MsgCmdAction& c); MsgCmdActionPP(const string& play, int _taskid); string render() const; const Boeing::MsgCmdAction* content() const; }; +class MsgCmdSetPos : public MsgCmdActionPP { +private: + double x_, y_, angle_; +protected: + static const char *const scan_template; + bool parse(); +public: + MsgCmdSetPos(const Boeing::MsgCmdAction& c); + MsgCmdSetPos(double x, double y, double a); + double getX() const; + double getY() const; + double getAngle() const; +}; + class MsgCmdHaltPP : public Msg { friend class Msg; protected: From tk at edam.speech.cs.cmu.edu Thu Nov 9 14:17:31 2006 From: tk at edam.speech.cs.cmu.edu (tk@edam.speech.cs.cmu.edu) Date: Thu, 9 Nov 2006 14:17:31 -0500 Subject: [TeamTalk 7]: [544] TeamTalk/Agents: Added setpos interpretation for Action message class . Message-ID: <200611091917.kA9JHVPU025391@edam.speech.cs.cmu.edu> An HTML attachment was scrubbed... URL: http://mailman.srv.cs.cmu.edu/pipermail/teamtalk-developers/attachments/20061109/6ae1667d/attachment-0001.html -------------- next part -------------- Modified: TeamTalk/Agents/PrimitiveComm/robot_packet.cpp =================================================================== --- TeamTalk/Agents/PrimitiveComm/robot_packet.cpp 2006-11-08 20:05:26 UTC (rev 543) +++ TeamTalk/Agents/PrimitiveComm/robot_packet.cpp 2006-11-09 19:17:31 UTC (rev 544) @@ -59,6 +59,7 @@ } } else if (w1 == "pause") retval = new MsgCmdPausePP(); else if (w1 == "resume") retval = new MsgCmdResumePP(); + else if (w1 == "setpos") retval = new MsgCmdSetPos(playaction); return retval; } @@ -88,8 +89,6 @@ case CMD_PAUSE: retval = new MsgCmdPausePP(*(const MsgCmdPause*)c); break; case CMD_RESUME: retval = new MsgCmdResumePP(*(const MsgCmdResume*)c); break; case CMD_FOLLOW: retval = new MsgCmdFollowPP(*(const MsgCmdFollow*)c); break; - //case CMD_LOAD: retval = new MsgCmdLoadPP(*(const MsgCmdLoad*)c); break; - //case CMD_UNLOAD: retval = new MsgCmdUnloadPP(*(const MsgCmdUnload*)c); break; case REQ_LOCATION: retval = new MsgReqLocationPP(*(const MsgReqLocation*)c); break; case ROB_ACK: retval = new MsgRobAckPP(*(const MsgRobAck*)c); break; case ROB_DONE: retval = new MsgRobDonePP(*(const MsgRobDone*)c); break; @@ -132,10 +131,6 @@ if(resume != NULL) return resume->clone(); const MsgCmdFollowPP *follow = dynamic_cast(this); if(follow != NULL) return follow->clone(); - //const MsgCmdLoadPP *load = dynamic_cast(this); - //if(load != NULL) return load->clone(); - //const MsgCmdUnloadPP *unload = dynamic_cast(this); - //if(unload != NULL) return unload->clone(); const MsgReqLocationPP *rloc = dynamic_cast(this); if(rloc != NULL) return rloc->clone(); const MsgRobAckPP *ack = dynamic_cast(this); @@ -163,8 +158,6 @@ if(dynamic_cast(this) != NULL) return CMD_RESUME; if(dynamic_cast(this) != NULL) return CMD_FOLLOW; if(dynamic_cast(this) != NULL) return CMD_COVER; - //if(dynamic_cast(this) != NULL) return CMD_LOAD; - //if(dynamic_cast(this) != NULL) return CMD_UNLOAD; if(dynamic_cast(this) != NULL) return REQ_LOCATION; if(dynamic_cast(this) != NULL) return ROB_ACK; if(dynamic_cast(this) != NULL) return ROB_DONE; @@ -179,22 +172,6 @@ return sender; } -/* -void Msg::stamp(const string& hostname, const string& recipient) { - MsgHeader *h = (MsgHeader*)this; - //hostname.copy(h->sender, SADDR_LENGTH); - //recipient.copy(h->recipient, SADDR_LENGTH); -#ifdef WIN32 -#error fixme -#else - struct timeval tv; - struct timezone tz; - gettimeofday(&tv, &tz); - h->tstamp = tv.tv_sec + (float)tv.tv_usec/1e6; -#endif -}; -*/ - MsgCmdActionPP::MsgCmdActionPP() {} MsgCmdActionPP::MsgCmdActionPP(const MsgCmdAction& c) : content_(c) {} MsgHeader* MsgCmdActionPP::header() {return (MsgHeader*)&content_;}; @@ -205,11 +182,6 @@ return &content_; } -/* -MsgCmdHaltPP::MsgCmdHaltPP() - : MsgCmdActionPP(construct_MsgCmdAction("halt", iTaskCounter++)) {}; -*/ - MsgCmdHaltPP::MsgCmdHaltPP() { content_.type = CMD_HALT; content_.len = sizeof(content_); @@ -387,34 +359,6 @@ return out.str(); }; -/* -MsgCmdLoadPP::MsgCmdLoadPP() { - content_.type = CMD_LOAD; - content_.len = sizeof(content_); - content_.taskid = iTaskCounter++; - content_.priority = 1; -}; -MsgCmdLoadPP::MsgCmdLoadPP(const MsgCmdLoad& x) : content_(x) {}; -MsgCmdLoadPP* MsgCmdLoadPP::clone() const {return new MsgCmdLoadPP(*this);}; -MsgHeader* MsgCmdLoadPP::header() {return (MsgHeader*)&content_;}; -const MsgCmdLoad* MsgCmdLoadPP::content() const {return &content_;} -string MsgCmdLoadPP::action_string() const {return "load";} -string MsgCmdLoadPP::render() const {return "Load";}; - -MsgCmdUnloadPP::MsgCmdUnloadPP() { - content_.type = CMD_UNLOAD; - content_.len = sizeof(content_); - content_.taskid = iTaskCounter++; - content_.priority = 1; -}; -MsgCmdUnloadPP::MsgCmdUnloadPP(const MsgCmdUnload& x) : content_(x) {}; -MsgCmdUnloadPP* MsgCmdUnloadPP::clone() const {return new MsgCmdUnloadPP(*this);}; -MsgHeader* MsgCmdUnloadPP::header() {return (MsgHeader*)&content_;}; -const MsgCmdUnload* MsgCmdUnloadPP::content() const {return &content_;} -string MsgCmdUnloadPP::action_string() const {return "unload";} -string MsgCmdUnloadPP::render() const {return "Unload";}; -*/ - MsgReqLocationPP::MsgReqLocationPP() { content_.type = REQ_LOCATION; content_.len = sizeof(content_); @@ -609,6 +553,8 @@ return retval; } +// **************** SetPos **************************************************** + const char *const MsgCmdSetPos::scan_template = "setpos (%d %d) %d"; bool MsgCmdSetPos::parse() { Modified: TeamTalk/Agents/TeamTalkBackend/backendstub/robot.cpp =================================================================== --- TeamTalk/Agents/TeamTalkBackend/backendstub/robot.cpp 2006-11-08 20:05:26 UTC (rev 543) +++ TeamTalk/Agents/TeamTalkBackend/backendstub/robot.cpp 2006-11-09 19:17:31 UTC (rev 544) @@ -19,16 +19,16 @@ static unsigned char* image = NULL; static int image_size; void readImage(const char* file) { - ifstream i(file, ios::in|ios::binary|ios::ate); - if(!i.is_open()) { - cerr << "file: " << file << " not found" << endl; - return; - } - image_size = i.tellg(); - char *memblock = new char[image_size]; - i.seekg(0, ios::beg); - i.read(memblock, image_size); - image = (unsigned char*) memblock; + ifstream i(file, ios::in|ios::binary|ios::ate); + if(!i.is_open()) { + cerr << "file: " << file << " not found" << endl; + return; + } + image_size = i.tellg(); + char *memblock = new char[image_size]; + i.seekg(0, ios::beg); + i.read(memblock, image_size); + image = (unsigned char*) memblock; } float mod(const float& a, const float& b) { @@ -43,10 +43,10 @@ unsigned int Hash (string const& s) { - unsigned int result = 0; - for (unsigned int i = 0; s [i] != 0; ++i) - result = (result & mask) ^ (result << shift) ^ s [i]; - return result; + unsigned int result = 0; + for (unsigned int i = 0; s [i] != 0; ++i) + result = (result & mask) ^ (result << shift) ^ s [i]; + return result; } const float Robot::velocity=1.0F; //velocity in meters per second @@ -64,17 +64,14 @@ void Robot::simulate(void *thisp) { Robot* me = (Robot*) thisp; - //const string hashstuff(me->server_->getHandle()); - //srand((unsigned int)time(NULL)*Hash(hashstuff)); EnterCriticalSection(&me->CriticalSection); for(;;) { LeaveCriticalSection(&me->CriticalSection); do { const Boeing::MsgCmd *bmsg; - //if(me->server_->isConnected()) cerr << '.'; if(me->server_->isConnected() && (bmsg = me->server_->getNextMessage())) { Msg* msg = Msg::interpret(bmsg->buff); - //cerr << "got message: " << msg->render() << endl; + cerr << "got message: " << msg->render() << endl; me->callback(msg, NULL); } else Sleep((int) (updatePeriod*1000)); } while(!TryEnterCriticalSection(&me->CriticalSection)); @@ -155,18 +152,18 @@ } Robot::Robot(const map *robs, string name) - : x(0), goal_x(0), y(0), goal_y(0), r(0), goal_r(0), action(WAITING), robots(robs) { +: x(0), goal_x(0), y(0), goal_y(0), r(0), goal_r(0), action(WAITING), robots(robs) { InitializeCriticalSection(&CriticalSection); - if(!image) readImage("pic.jpg"); - server_ = new Boeing::RobotServer(); + if(!image) readImage("pic.jpg"); + server_ = new Boeing::RobotServer(); server_->open(); simulationThread_ = (HANDLE)_beginthread(simulate, 0, (void *) this); } Robot::Robot(const map *robs, string name, unsigned int port) - : x(0), goal_x(0), y(0), goal_y(0), r(0), goal_r(0), action(WAITING), robots(robs) { +: x(0), goal_x(0), y(0), goal_y(0), r(0), goal_r(0), action(WAITING), robots(robs) { InitializeCriticalSection(&CriticalSection); - if(!image) readImage("pic.jpg"); + if(!image) readImage("pic.jpg"); server_ = new Boeing::RobotServer(); server_->open(port); simulationThread_ = (HANDLE)_beginthread(simulate, 0, (void *) this); @@ -188,55 +185,58 @@ } else { temp_message = msgp->clone(); } - if(const MsgMapReqPP* req_image = dynamic_cast(temp_message)) { - server_->sendJPEGImage(image, image_size, 320, 240, req_image->getInvoice()); - delete temp_message; - return; - } + if(const MsgMapReqPP* req_image = dynamic_cast(temp_message)) { + server_->sendJPEGImage(image, image_size, 320, 240, req_image->getInvoice()); + delete temp_message; + return; + } if(const MsgReqLocationPP* rloc = dynamic_cast(temp_message)) { server_->sendLocation(x, y, r, true); - delete temp_message; - return; - } + delete temp_message; + return; + } EnterCriticalSection(&CriticalSection); if(const MsgCmdGoToRelativePP* goto_relative = dynamic_cast(temp_message)) { - cout << "got: " << *goto_relative << endl; + cerr << "got: " << *goto_relative << endl; float m_x = goto_relative->content()->x; float m_y = goto_relative->content()->y; float dir = r+atan2(m_y, m_x); float len = sqrt(m_x*m_x+m_y*m_y); setGoal(x+cos(dir)*len, y+sin(dir)*len); //will report done when complete } else if(const MsgCmdHaltPP* halt = dynamic_cast(temp_message)) { - cout << "got: " << *halt << endl; + cerr << "got: " << *halt << endl; action = WAITING; cerr << "done with halt" << endl; } else if(const MsgCmdGoToGlobalPP* goto_global = dynamic_cast(temp_message)) { - cout << "got: " << *goto_global << endl; + cerr << "got: " << *goto_global << endl; setGoal(goto_global->content()->x, goto_global->content()->y); } else if(const MsgCmdTurnRelativePP* turn = dynamic_cast(temp_message)) { - cout << "got: " << *turn << endl; + cerr << "got: " << *turn << endl; goal_r = canonical_angle(r+turn->content()->angle); action = GO_TO_ANGLE; //will report done when complete } else if(const MsgCmdHomePP* home = dynamic_cast(temp_message)) { - cout << "got: " << *home << endl; + cerr << "got: " << *home << endl; setGoal(0, 0); } else if(const MsgCmdPausePP* pause = dynamic_cast(temp_message)) { - cout << "got: " << *pause << endl; + cerr << "got: " << *pause << endl; if(action != PAUSED) { paused_action = action; action = PAUSED; } cerr << "done with pause" << endl; } else if(const MsgCmdResumePP* resume = dynamic_cast(temp_message)) { - cout << "got: " << *resume << endl; + cerr << "got: " << *resume << endl; if(action == PAUSED) { action = paused_action; cerr << "done with resume" << endl; //resume only succeeds if already paused } } else if(const MsgCmdFollowPP* follow = dynamic_cast(temp_message)) { - cout << "got: " << *follow << endl; + cerr << "got: " << *follow << endl; //setFollow(follow->content()->leader); - } + } else if(const MsgCmdSetPos* setpos = dynamic_cast(temp_message)) { + cerr << "got: " << *setpos << endl; + x = setpos->getX(); y = setpos->getY(); r = setpos->getAngle(); + } LeaveCriticalSection(&CriticalSection); delete temp_message; } Modified: TeamTalk/Agents/TeamTalkBackend/gal_be.cpp =================================================================== --- TeamTalk/Agents/TeamTalkBackend/gal_be.cpp 2006-11-08 20:05:26 UTC (rev 543) +++ TeamTalk/Agents/TeamTalkBackend/gal_be.cpp 2006-11-09 19:17:31 UTC (rev 544) @@ -74,27 +74,30 @@ vector comms; GalIO_CommStruct* skeleton_comm = NULL; -void writeFrameAllHubs(Gal_Frame f) { - GalUtil_Debug1("writing to all hubs\n"); +void writeFrameAllHubs(Gal_Frame f) +{ + GalUtil_Debug1("writing to all hubs\n"); for(vector::iterator i=comms.begin(); i!=comms.end(); i++) { - GalUtil_Debug1("writing to hub\n"); + GalUtil_Debug1("writing to hub\n"); GalIO_CommWriteFrame(*i, f, GAL_FALSE); } }; -void writeFrameFirstHub(Gal_Frame f) { - for(int i=0; i<30; i++) { - if(skeleton_comm) { - GalIO_CommWriteFrame(skeleton_comm, f, GAL_FALSE); - return; - } - GalUtil_Debug1("skeleton unavailable\n"); - Sleep(1000); - } +void writeFrameFirstHub(Gal_Frame f) +{ + for(int i=0; i<30; i++) { + if(skeleton_comm) { + GalIO_CommWriteFrame(skeleton_comm, f, GAL_FALSE); + return; + } + GalUtil_Debug1("skeleton unavailable\n"); + Sleep(1000); + } }; // [2006-07-14] (tk): this restarts sphinx for a newly created dict and lm -void restartDecoder() { +void restartDecoder() +{ cerr << "sending restart_decoder" << endl; Gal_Frame gfInput = Gal_MakeFrame("restart_decoder", GAL_CLAUSE); writeFrameAllHubs(gfInput); @@ -104,7 +107,8 @@ // 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) { +void SendMessageToDM(string sMsgType, string sMessage) +{ // variables holding the nested galaxy parse frame Gal_Frame gfInput, gfParse, gfSlot, gfNet; Gal_Object *pgoParses, *pgoSlots, *pgoNets; @@ -169,7 +173,8 @@ //------------------------------------------------------------------- // [2006-07-22] (tk): send a robot_config message to galaxy hubs //------------------------------------------------------------------- -static void SendRobotConfigMessage(const string& sName, const string& sVoice) { +static void SendRobotConfigMessage(const string& sName, const string& sVoice) +{ // variables holding the nested galaxy parse frame Gal_Frame f = Gal_MakeFrame("robot_config", GAL_CLAUSE); @@ -178,7 +183,8 @@ writeFrameAllHubs(f); } -static void stubMessage(const Msg* msgp) { +static void stubMessage(const Msg* msgp) +{ const MsgRobLocationPP *rloc; if((rloc = dynamic_cast(msgp)) != NULL) { map::iterator i = locations.find(rloc->getSender()); @@ -194,7 +200,8 @@ } } -template string string_space(const Iter begin, const Iter end) { +template string string_space(const Iter begin, const Iter end) +{ ostringstream out; if(begin == end) return out.str(); for(Iter i = begin;;) { @@ -206,7 +213,8 @@ return out.str(); } -template string string_space(const String_Array_Elem** begin) { +template string string_space(const String_Array_Elem** begin) +{ ostringstream out; if(*begin == NULL) return out.str(); for(const String_Array_Elem** i = begin;;) { @@ -218,7 +226,8 @@ return out.str(); } -BOOL WINAPI ConsoleHandler(DWORD CEvent) { +BOOL WINAPI ConsoleHandler(DWORD CEvent) +{ //kill all of the spawned children while(!children.empty()) { HANDLE child = children.top(); @@ -229,7 +238,8 @@ return TRUE; } -static PROCESS_INFORMATION spawnProg(const string& title, const string& dir, const string& exe, const string& args) { +static PROCESS_INFORMATION spawnProg(const string& title, const string& dir, const string& exe, const string& args) +{ //TK: CreateProcess wants a writable char* for some stupid reason ostringstream cmdline; cmdline << exe << ' ' << args; @@ -268,22 +278,25 @@ return pi; } -void substitute(string& temp, const string& var, const string& val) { +void substitute(string& temp, const string& var, const string& val) +{ for(string::size_type j = temp.find(var); j != string::npos; j = temp.find(var)) { temp.replace(j, var.size(), val); } } -void substitute(string& temp, const map& subs) { +void substitute(string& temp, const map& subs) +{ for(map::const_iterator i = subs.begin(); i != subs.end(); i++) { substitute(temp, i->first, i->second); } } static string writeSpecializedConfig(const string temp, - const string ext, - const map& subs, - const string name = string()) { + const string ext, + const map& subs, + const string name = string()) +{ ostringstream cfilename; cfilename << temp; if(!name.empty()) cfilename << '-' << name; @@ -309,13 +322,15 @@ return cfilename.str(); } -template string stringOf(const C& x) { +template string stringOf(const C& x) +{ ostringstream oss; oss << x; return oss.str(); } -static void spawnHub(const string& uppername) { +static void spawnHub(const string& uppername) +{ map subs; subs["%%DialogManager%%"] = uppername; subs["%%DMPort%%"] = stringOf(iDMPort); @@ -328,7 +343,8 @@ spawnProg(cfilename, ".", HUB, args.str()); } -static void spawnHelios(const string& uppername) { +static void spawnHelios(const string& uppername) +{ map subs; subs["%%NAME%%"] = uppername; @@ -339,7 +355,8 @@ spawnProg(cfilename, ".", HELIOS, args.str()); } -static void spawnDM(const string& uppername, const string& safeness) { +static void spawnDM(const string& uppername, const string& safeness) +{ map subs; subs["%%ServerName%%"] = uppername; subs["%%ServerPort%%"] = stringOf(iDMPort); @@ -364,7 +381,8 @@ spawnProg(cfilename, ".", DM, args.str()); } -static void spawnMinorGalaxy(const string& name, const string& safeness) { +static void spawnMinorGalaxy(const string& name, const string& safeness) +{ string uppername(name); string uppersafeness(safeness); toupper(uppername); toupper(uppersafeness); @@ -376,7 +394,8 @@ iDMPort++; iHeliosPort++; } -static void addRobotNamesToGrammar(const vector& names) { +static void addRobotNamesToGrammar(const vector& names) +{ map subs; ostringstream gname; for(vector::const_iterator i = names.begin(); i != names.end(); i++) { @@ -389,7 +408,8 @@ WaitForSingleObject(lm_build_proc.hProcess, INFINITE); } -static void addRobotVoices() { +static void addRobotVoices() +{ vector names = p_client->getClientList(); for(vector::const_iterator i = names.begin(); i != names.end(); i++) { string name(toupper(*i)); @@ -443,39 +463,41 @@ * assured that that was not nor would be the * case */ -static int complete_frame(char c) { +static int complete_frame(char c) +{ switch (c) { - case '\n': - /* Test if the unclosed paren count is zero and - we have seen one or more open parens (to account - for any leading newlines) */ + case '\n': + /* Test if the unclosed paren count is zero and + we have seen one or more open parens (to account + for any leading newlines) */ - if ((unclosed == 0) && opened) - return TRUE; - else - return FALSE; + if ((unclosed == 0) && opened) + return TRUE; + else + return FALSE; - case '{': - unclosed++; - opened = TRUE; + case '{': + unclosed++; + opened = TRUE; - return FALSE; + return FALSE; - case '}': - unclosed--; + case '}': + unclosed--; - if (unclosed < 0) { - GalUtil_Fatal("Unmatched close parens seen in frame\n"); - } + if (unclosed < 0) { + GalUtil_Fatal("Unmatched close parens seen in frame\n"); + } - return FALSE; + return FALSE; - default: - return FALSE; + default: + return FALSE; } } -void fCallback(const string& x, const string& y) { +void fCallback(const string& x, const string& y) +{ char *s = "{c FromDialogue :output_frame {c greeting } :is_greeting 1 }"; Gal_Frame greeting = Gal_ReadFrameFromString(s); @@ -483,8 +505,9 @@ Gal_FreeFrame(greeting); } -void trackbots(void *nul) { - cerr << "starting trackbots thread" << endl; +void trackbots(void *nul) +{ + cerr << "starting trackbots thread" << endl; for(int t=0; true; t++) { Sleep(1000); vector bots = p_client->getClientList(); @@ -494,157 +517,161 @@ cerr << "can't find robot: " << *i << endl; continue; } - cerr << "sending location request" << endl; + cerr << "sending location request" << endl; r->sendReqLocation(); //p_client->sendPacket(*i, MsgReqLocationPP()); } - if(!(t%3)) { //send map keepalive every 3 seconds - m_client->sendKeepAlive(0); - } - if(!(t%40)) { //send image request every 40 seconds - if(!bots.empty()) { - Boeing::RobotClient* r = p_client->find("FESTO"); - if(r == NULL) { - cerr << "can't find robot: " << bots.front() << endl; - } else { - r->sendReqImage(); - } - } - } + if(!(t%3)) { //send map keepalive every 3 seconds + m_client->sendKeepAlive(0); + } + if(!(t%40)) { //send image request every 40 seconds + if(!bots.empty()) { + Boeing::RobotClient* r = p_client->find("FESTO"); + if(r == NULL) { + cerr << "can't find robot: " << bots.front() << endl; + } else { + r->sendReqImage(); + } + } + } } } -static void traderlistener(void *nul) { - for(;;) { - GalUtil_Warn("waiting for next trader message\n"); - const Boeing::MsgTraderClient* msg = t_client->getNextMessage(); - if(!msg) { - GalUtil_Warn("msgtraderclient is null\n"); - Sleep(500); - continue; - } - Gal_Frame f = Gal_MakeFrame("trader_message", GAL_CLAUSE); - switch(msg->hdr.type) { - case Boeing::INFO: - Gal_SetProp(f, ":type", Gal_StringObject("info")); - break; - default: - GalUtil_Warn("unknown message type '%d' in traderlistener", msg->hdr.type); - Gal_FreeFrame(f); - continue; - } - GalUtil_Warn("got info message: %s\n", msg->info.task); - istringstream input(msg->info.task); - string token; - string ip; - string object; - float x, y; - input >> token; - GalUtil_Debug1("got info token %s\n", token.c_str()); - if(token != "object") { - ip = token; - input >> token; - if(token != "object") { - GalUtil_Debug1("was expecting 'object'\n"); - continue; - } - } - input >> object; - GalUtil_Debug1("got info object %s\n", object.c_str()); - input >> token; - GalUtil_Debug1("got info token %s\n", token.c_str()); - if(token != "at") { - GalUtil_Debug1("was expecting 'at'\n"); - continue; - } - input >> token; - GalUtil_Debug1("got info token %s\n", token.c_str()); - if(token.empty() || token.at(0) != '(') { - GalUtil_Debug1("was expecting (...\n"); - continue; - } - if(token == "(") { - input >> token; - GalUtil_Debug1("got info token %s\n", token.c_str()); - x = (float)atof(token.c_str()); - } else { - x = (float)atof(token.c_str()+1); - } - GalUtil_Debug1("got info x: %f\n", x); - input >> token; - GalUtil_Debug1("got info token %s\n", token.c_str()); - if(token.empty()) { - GalUtil_Debug1("was expecting ...)\n"); - continue; - } else if(token.at(token.length()-1) != ')') { - token.resize(token.length()-1); - } - y = (float)atof(token.c_str()); - GalUtil_Debug1("got info y: %f\n", y); - Gal_SetProp(f, ":ip", Gal_StringObject(ip.c_str())); - Gal_SetProp(f, ":object", Gal_StringObject(object.c_str())); - Gal_SetProp(f, ":x", Gal_FloatObject(x)); - Gal_SetProp(f, ":y", Gal_FloatObject(y)); - writeFrameFirstHub(f); - Gal_FreeFrame(f); - } +static void traderlistener(void *nul) +{ + for(;;) { + GalUtil_Warn("waiting for next trader message\n"); + const Boeing::MsgTraderClient* msg = t_client->getNextMessage(); + if(!msg) { + GalUtil_Warn("msgtraderclient is null\n"); + Sleep(500); + continue; + } + Gal_Frame f = Gal_MakeFrame("trader_message", GAL_CLAUSE); + switch(msg->hdr.type) { + case Boeing::INFO: + Gal_SetProp(f, ":type", Gal_StringObject("info")); + break; + default: + GalUtil_Warn("unknown message type '%d' in traderlistener", msg->hdr.type); + Gal_FreeFrame(f); + continue; + } + GalUtil_Warn("got info message: %s\n", msg->info.task); + istringstream input(msg->info.task); + string token; + string ip; + string object; + float x, y; + input >> token; + GalUtil_Debug1("got info token %s\n", token.c_str()); + if(token != "object") { + ip = token; + input >> token; + if(token != "object") { + GalUtil_Debug1("was expecting 'object'\n"); + continue; + } + } + input >> object; + GalUtil_Debug1("got info object %s\n", object.c_str()); + input >> token; + GalUtil_Debug1("got info token %s\n", token.c_str()); + if(token != "at") { + GalUtil_Debug1("was expecting 'at'\n"); + continue; + } + input >> token; + GalUtil_Debug1("got info token %s\n", token.c_str()); + if(token.empty() || token.at(0) != '(') { + GalUtil_Debug1("was expecting (...\n"); + continue; + } + if(token == "(") { + input >> token; + GalUtil_Debug1("got info token %s\n", token.c_str()); + x = (float)atof(token.c_str()); + } else { + x = (float)atof(token.c_str()+1); + } + GalUtil_Debug1("got info x: %f\n", x); + input >> token; + GalUtil_Debug1("got info token %s\n", token.c_str()); + if(token.empty()) { + GalUtil_Debug1("was expecting ...)\n"); + continue; + } else if(token.at(token.length()-1) != ')') { + token.resize(token.length()-1); + } + y = (float)atof(token.c_str()); + GalUtil_Debug1("got info y: %f\n", y); + Gal_SetProp(f, ":ip", Gal_StringObject(ip.c_str())); + Gal_SetProp(f, ":object", Gal_StringObject(object.c_str())); + Gal_SetProp(f, ":x", Gal_FloatObject(x)); + Gal_SetProp(f, ":y", Gal_FloatObject(y)); + writeFrameFirstHub(f); + Gal_FreeFrame(f); + } } -static void maplistener(void *nul) { - for(;;) { - GalUtil_Debug1("waiting for next map message\n"); - const Boeing::MsgMapClient* msg = m_client->getNextMessage(); - if(!msg) { - GalUtil_Debug1("msgmapclient is null\n"); - Sleep(1000); - continue; - } - Gal_Frame f = Gal_MakeFrame("map_message", GAL_CLAUSE); - switch(msg->hdr.type) { - case Boeing::MAP_FULL: - Gal_SetProp(f, ":type", Gal_StringObject("full")); - break; - case Boeing::MAP_DIFF: - Gal_SetProp(f, ":type", Gal_StringObject("diff")); - break; - default: - GalUtil_Fatal("unknown message type '%d' in maplistener", msg->hdr.type); - Gal_FreeFrame(f); - continue; - } - Gal_SetProp(f, ":x_size", Gal_IntObject(msg->map.x)); - Gal_SetProp(f, ":y_size", Gal_IntObject(msg->map.y)); - Gal_SetProp(f, ":resolution", Gal_IntObject(msg->map.resolution)); - int *temp = new int[msg->map.array_length]; - for(int i=0; imap.array_length; i++) temp[i] = msg->map.map[i]; - cerr << "got raw: " << temp[0] - << " rl: " << ((temp[0]&0xFFFFFF00)>>8) - << " rv: " << (temp[0]&0x000000FF) << endl; - Gal_SetProp(f, ":encoded_map", - Gal_CreateInt32Object((void *) temp, msg->map.array_length, 1)); - GalUtil_Debug1("sending map to hub\n"); - writeFrameFirstHub(f); - Gal_FreeFrame(f); - } +static void maplistener(void *nul) +{ + for(;;) { + GalUtil_Debug1("waiting for next map message\n"); + const Boeing::MsgMapClient* msg = m_client->getNextMessage(); + if(!msg) { + GalUtil_Debug1("msgmapclient is null\n"); + Sleep(1000); + continue; + } + Gal_Frame f = Gal_MakeFrame("map_message", GAL_CLAUSE); + switch(msg->hdr.type) { + case Boeing::MAP_FULL: + Gal_SetProp(f, ":type", Gal_StringObject("full")); + break; + case Boeing::MAP_DIFF: + Gal_SetProp(f, ":type", Gal_StringObject("diff")); + break; + default: + GalUtil_Fatal("unknown message type '%d' in maplistener", msg->hdr.type); + Gal_FreeFrame(f); + continue; + } + Gal_SetProp(f, ":x_size", Gal_IntObject(msg->map.x)); + Gal_SetProp(f, ":y_size", Gal_IntObject(msg->map.y)); + Gal_SetProp(f, ":resolution", Gal_IntObject(msg->map.resolution)); + int *temp = new int[msg->map.array_length]; + for(int i=0; imap.array_length; i++) temp[i] = msg->map.map[i]; + cerr << "got raw: " << temp[0] + << " rl: " << ((temp[0]&0xFFFFFF00)>>8) + << " rv: " << (temp[0]&0x000000FF) << endl; + Gal_SetProp(f, ":encoded_map", + Gal_CreateInt32Object((void *) temp, msg->map.array_length, 1)); + GalUtil_Debug1("sending map to hub\n"); + writeFrameFirstHub(f); + Gal_FreeFrame(f); + } } static bool lastConfig = false; -static bool testLastConfig(const string& source, const string& target) { - //return true if target is newer than source - struct _stat source_stat, target_stat; - if(_stat(source.c_str(), &source_stat)) { - cerr << "problem stating source: " << source << endl; - return false; - } - if(_stat(target.c_str(), &target_stat)) { - cerr << "problem stating target: " << target << endl; - return false; - } - return target_stat.st_mtime > source_stat.st_mtime; +static bool testLastConfig(const string& source, const string& target) +{ + //return true if target is newer than source + struct _stat source_stat, target_stat; + if(_stat(source.c_str(), &source_stat)) { + cerr << "problem stating source: " << source << endl; + return false; + } + if(_stat(target.c_str(), &target_stat)) { + cerr << "problem stating target: " << target << endl; + return false; + } + return target_stat.st_mtime > source_stat.st_mtime; } -void *init_server(Gal_Server *s, int argc, char **argv) { +void *init_server(Gal_Server *s, int argc, char **argv) +{ if (SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleHandler,TRUE)==FALSE) { cerr << "Unable to install handler!" << endl; return (void *) s; @@ -671,26 +698,26 @@ try { p_client = new TeamTalk::RobotClient("tester", &stubMessage, &spawnMinorGalaxy); t_client = new Boeing::TraderClient(); - m_client = new Boeing::MapClient(); + m_client = new Boeing::MapClient(); p_client->addRobotsFile("peerfile.txt", t_client, m_client); - if(!(lastConfig = testLastConfig("peerfile.txt", "..\\..\\Resources\\DecoderConfig\\LanguageModel\\zap2LM.arpa"))) + if(!(lastConfig = testLastConfig("peerfile.txt", "..\\..\\Resources\\DecoderConfig\\LanguageModel\\zap2LM.arpa"))) addRobotNamesToGrammar(p_client->getClientList()); - if(!t_client->isConnected()) { - GalUtil_Fatal("optraderserver not found"); - } else { - GalUtil_Debug1("connected to trader\n"); - } - _beginthread(traderlistener, 0, (void*) NULL); + if(!t_client->isConnected()) { + GalUtil_Fatal("optraderserver not found"); + } else { + GalUtil_Debug1("connected to trader\n"); + } + _beginthread(traderlistener, 0, (void*) NULL); - if(!m_client->isConnected()) { - GalUtil_Fatal("mapserver not found"); - } else { - if(!m_client->sendSubscribe(0)) - GalUtil_Fatal("couldn't send subscribe message to map server"); - } - _beginthread(maplistener, 0, (void*) NULL); + if(!m_client->isConnected()) { + GalUtil_Fatal("mapserver not found"); + } else { + if(!m_client->sendSubscribe(0)) + GalUtil_Fatal("couldn't send subscribe message to map server"); + } + _beginthread(maplistener, 0, (void*) NULL); //start robot tracking thread _beginthread(trackbots, 0, (void*) NULL); @@ -704,9 +731,9 @@ Gal_Frame reinitialize(Gal_Frame f, void *server_data) { comms.push_back(GalSS_EnvComm((GalSS_Environment *)server_data)); - const char *user_id = Gal_GetString(f, ":user_id"); - if(!user_id) GalUtil_Debug1("no user_id\n"); - else if(!strcmp(user_id, "TeamTalk")) skeleton_comm = comms.back(); + const char *user_id = Gal_GetString(f, ":user_id"); + if(!user_id) GalUtil_Debug1("no user_id\n"); + else if(!strcmp(user_id, "TeamTalk")) skeleton_comm = comms.back(); restartDecoder(); @@ -715,7 +742,8 @@ return f; } -int tkGetNumber999(const string& x) { +int tkGetNumber999(const string& x) +{ istringstream issX(x); int retval = 0; for(string token; issX >> token;) { @@ -782,426 +810,467 @@ return retval; } -template bool sendAction(Boeing::RobotClient *r, const A *action) { +template bool sendAction(Boeing::RobotClient *r, const A *action) +{ return r->sendAction(action->content()->priority, action->content()->taskid, action->action_string().c_str()); } -Gal_Frame launch_query(Gal_Frame f, void *server_data) { - Gal_Object aStr; - aStr = Gal_GetObject(f, ":inframe"); - if (aStr) { +const char *const compass_points[] = { + "east", "east north east", "north east", "north north east", + "north", "north north west", "north west", "west north west", + "west", "west south west", "south west", "south south west", + "south", "south south east", "south east", "east south east"}; - //inframe = Gal_StringValue(aStr); - GalUtil_Error("about to print a frame"); - Gal_PrFrame(f); - char* s_inframe = Gal_StringValue(aStr); - if(s_inframe) { - //frame fixup -> ravenclaw doesn't make proper frames - ostringstream fixed; - string notfixed(s_inframe + 1); - istringstream inotfixed(notfixed); - fixed << "{c zap "; - string token; - do { - inotfixed >> token; - if(token == "}") break; - fixed << ':' << token << ' '; - char cpVal[255]; - inotfixed.ignore(); - inotfixed.getline(cpVal, 254); - fixed << '"' << cpVal << "\" "; - } while(inotfixed); - GalUtil_Error("working with fixed version: %s", fixed.str().c_str()); - Gal_Frame inframe = Gal_ReadFrameFromString(fixed.str().c_str()); - if(inframe) { - Gal_PrFrame(inframe); - char* query = Gal_GetString(inframe, ":query"); - char* robot = Gal_GetString(inframe, ":robot_name"); - if(query) { - GalUtil_Error("query is %s", query); - if(robot) { - GalUtil_Error("robot is %s", robot); - if(!strcmp(query, "location_query")) { - static const float precision = 1.1F; //110 cm precision - ostringstream ossMessage; - map::iterator i = locations.find(robot); - if(i == locations.end()) { //no location info yet? - ossMessage << "I don't know." << endl; - } else { - const Vector p(i->second.x, i->second.y); - double distanceFromHome = p.length(); - if(distanceFromHome < precision) { - ossMessage << "I am home"; - } else { - ossMessage << setiosflags(ios_base::fixed) << setprecision(1); - ossMessage << "I am " - // << "at location " << p.x << ' ' << p.y << ". " - << p.length() << " meters from home; bearing is "; - int a = ((int)(p.angle()*180/PI+PI/16)/16)%16; - switch(a) { - case 0: ossMessage << "east."; break; - case 1: ossMessage << "east north east."; break; - case 2: ossMessage << "north east."; break; - case 3: ossMessage << "north north east."; break; - case 4: ossMessage << "north."; break; - case 5: ossMessage << "north north west."; break; - case 6: ossMessage << "north west."; break; - case 7: ossMessage << "west north west."; break; - case 8: ossMessage << "west."; break; - case 9: ossMessage << "west south west."; break; - case 10: ossMessage << "south west"; break; - case 11: ossMessage << "south south west."; break; - case 12: ossMessage << "south."; break; - case 13: ossMessage << "south south east."; break; - case 14: ossMessage << "south east."; break; - case 15: ossMessage << "east south east."; break; - default: ossMessage << "unknown."; - } - //<< p.angle()*180/PI << " degrees to the left."; - } - } +static void location_query(const char* robot) +{ + static const float precision = 1.1F; //110 cm precision + ostringstream ossMessage; + map::iterator i = locations.find(robot); + if(i == locations.end()) { //no location info yet? + ossMessage << "I don't know." << endl; + } else { + const Vector p(i->second.x, i->second.y); + double distanceFromHome = p.length(); + if(distanceFromHome < precision) { + ossMessage << "I am home"; + } else { + ossMessage << setiosflags(ios_base::fixed) << setprecision(1); + ossMessage << "I am " + << p.length() << " meters from home; bearing is "; + int a = ((int)(p.angle()*180/PI+PI/16)/16)%16; + ossMessage << compass_points[a] << '.'; +/* + switch(a) + { + case 0: ossMessage << "east."; break; } + case 1: ossMessage << "east north east."; break; + case 2: ossMessage << "north east."; break; + case 3: ossMessage << "north north east."; break; + case 4: ossMessage << "north."; break; + case 5: ossMessage << "north north west."; break; + case 6: ossMessage << "north west."; break; + case 7: ossMessage << "west north west."; break; + case 8: ossMessage << "west."; break; + case 9: ossMessage << "west south west."; break; + case 10: ossMessage << "south west"; break; + case 11: ossMessage << "south south west."; break; + case 12: ossMessage << "south."; break; + case 13: ossMessage << "south south east."; break; + case 14: ossMessage << "south east."; break; + case 15: ossMessage << "east south east."; break; + default: ossMessage << "unknown."; break; + } + */ + } + } - // [2005-09-18] (dbohus): send the message through the hub towards - // helios and the DM - SendMessageToDM("Location", ossMessage.str()); - } - else if(!strcmp(query, "move_cardinal_command")) { - GalUtil_Error("sending move query to backend"); - string s_distance(Gal_GetString(inframe, ":distance")); - string s_units(Gal_GetString(inframe, ":units")); - string s_direction(Gal_GetString(inframe, ":direction")); - if(!(s_distance.empty() && s_direction.empty())) { - GalUtil_Error("distance or direction missing"); - } else { - Point vec(static_cast(tkGetNumber999(s_distance)), 0); - if(!s_distance.empty()) { - if(!s_units.empty()) { - if(s_units == "FOOT" || s_units == "FEET") { - vec.x *= 0.3048F; - } else if(s_units == "YARD" || s_units == "YARDS") { - vec.x *= 0.9144F; - } - } - MsgCmdGoToRelativePP *go = NULL; - if(s_direction == "NORTH") - go = new MsgCmdGoToRelativePP(vec.rotate(PI/2)); - else if(s_direction == "NORTHEAST") - go = new MsgCmdGoToRelativePP(vec.rotate(PI/4)); - else if(s_direction == "NORTHWEST") - go = new MsgCmdGoToRelativePP(vec.rotate(3*PI/4)); - else if(s_direction == "EAST") - go = new MsgCmdGoToRelativePP(vec); - else if(s_direction == "SOUTH") - go = new MsgCmdGoToRelativePP(vec.rotate(-PI/2)); - else if(s_direction == "SOUTHEAST") - go = new MsgCmdGoToRelativePP(vec.rotate(-PI/4)); - else if(s_direction == "SOUTHWEST") - go = new MsgCmdGoToRelativePP(vec.rotate(-3*PI/4)); - else if(s_direction == "WEST") - go = new MsgCmdGoToRelativePP(vec.rotate(PI)); - if(go != NULL) { - Boeing::RobotClient *r = p_client->find(robot); - if(r) + // [2005-09-18] (dbohus): send the message through the hub towards + // helios and the DM + SendMessageToDM("Location", ossMessage.str()); +} + +static void move_cardinal_command(const char* robot, const Gal_Frame& inframe) +{ + GalUtil_Error("sending move query to backend"); + string s_distance(Gal_GetString(inframe, ":distance")); + string s_units(Gal_GetString(inframe, ":units")); + string s_direction(Gal_GetString(inframe, ":direction")); + if(!(s_distance.empty() && s_direction.empty())) { + GalUtil_Error("distance or direction missing"); + } else { + Point vec(static_cast(tkGetNumber999(s_distance)), 0); + if(!s_distance.empty()) { + if(!s_units.empty()) { + if(s_units == "FOOT" || s_units == "FEET") { + vec.x *= 0.3048F; + } else if(s_units == "YARD" || s_units == "YARDS") { + vec.x *= 0.9144F; + } + } + MsgCmdGoToRelativePP *go = NULL; + if(s_direction == "NORTH") + go = new MsgCmdGoToRelativePP(vec.rotate(PI/2)); + else if(s_direction == "NORTHEAST") + go = new MsgCmdGoToRelativePP(vec.rotate(PI/4)); + else if(s_direction == "NORTHWEST") + go = new MsgCmdGoToRelativePP(vec.rotate(3*PI/4)); + else if(s_direction == "EAST") + go = new MsgCmdGoToRelativePP(vec); + else if(s_direction == "SOUTH") + go = new MsgCmdGoToRelativePP(vec.rotate(-PI/2)); + else if(s_direction == "SOUTHEAST") + go = new MsgCmdGoToRelativePP(vec.rotate(-PI/4)); + else if(s_direction == "SOUTHWEST") + go = new MsgCmdGoToRelativePP(vec.rotate(-3*PI/4)); + else if(s_direction == "WEST") + go = new MsgCmdGoToRelativePP(vec.rotate(PI)); + if(go != NULL) { + Boeing::RobotClient *r = p_client->find(robot); + if(r) #ifdef USE_TXT_COMMANDS - sendAction(r, go); + sendAction(r, go); #else - r->sendGoToCmd(1, go->content()->taskid, - go->content()->x, go->content()->y, go->content()->angle, - go->content()->useAngle(), go->content()->useRelative()); + r->sendGoToCmd(1, go->content()->taskid, + go->content()->x, go->content()->y, go->content()->angle, + go->content()->useAngle(), go->content()->useRelative()); #endif - delete go; - } else - GalUtil_Error("unknown direction %s", s_direction.c_str()); - } - } - } - else if(!strcmp(query, "move_relative_command")) { - GalUtil_Error("sending move relative query to backend"); - string s_distance; - if (Gal_GetString(inframe, ":distance")) - s_distance = Gal_GetString(inframe, ":distance"); - string s_direction; - if (Gal_GetString(inframe, ":direction")) - s_direction = Gal_GetString(inframe, ":direction"); - string s_units; - if (Gal_GetString(inframe, ":units")) - s_units = Gal_GetString(inframe, ":units"); - if(s_distance.empty() || s_direction.empty()) { - GalUtil_Error("distance or direction missing"); - } else { - if(!s_distance.empty()) { - Point vec(static_cast(tkGetNumber999(s_distance)), 0); - if(!s_units.empty()) { - if(s_units == "FOOT" || s_units == "FEET") { - vec.x *= 0.3048F; - } else if(s_units == "YARD" || s_units == "YARDS") { - vec.x *= 0.9144F; - } - } - MsgCmdGoToRelativePP *go = NULL; - if(s_direction == "STRAIGHT" || - s_direction == "FORWARD" || - s_direction == "FORWARDS" || - s_direction == "AROUND") - go = new MsgCmdGoToRelativePP(vec); - else if(s_direction.substr(0, 5) == "RIGHT") - go = new MsgCmdGoToRelativePP(vec.rotate(-PI/2)); - else if(s_direction.substr(0, 4) == "LEFT") - go = new MsgCmdGoToRelativePP(vec.rotate(PI/2)); - else if(s_direction == "BACK" || - s_direction == "BACKWARD" || - s_direction == "BACKWARDS") - go = new MsgCmdGoToRelativePP(vec.rotate(PI)); - if(go != NULL) { - Boeing::RobotClient *r = p_client->find(robot); - if(r) + delete go; + } else + GalUtil_Error("unknown direction %s", s_direction.c_str()); + } + } +} + +static void move_relative_command(const char* robot, const Gal_Frame& inframe) +{ + GalUtil_Error("sending move relative query to backend"); + string s_distance; + if (Gal_GetString(inframe, ":distance")) + s_distance = Gal_GetString(inframe, ":distance"); + string s_direction; + if (Gal_GetString(inframe, ":direction")) + s_direction = Gal_GetString(inframe, ":direction"); + string s_units; + if (Gal_GetString(inframe, ":units")) + s_units = Gal_GetString(inframe, ":units"); + if(s_distance.empty() || s_direction.empty()) { + GalUtil_Error("distance or direction missing"); + } else { + if(!s_distance.empty()) { + Point vec(static_cast(tkGetNumber999(s_distance)), 0); + if(!s_units.empty()) { + if(s_units == "FOOT" || s_units == "FEET") { + vec.x *= 0.3048F; + } else if(s_units == "YARD" || s_units == "YARDS") { + vec.x *= 0.9144F; + } + } + MsgCmdGoToRelativePP *go = NULL; + if(s_direction == "STRAIGHT" || + s_direction == "FORWARD" || + s_direction == "FORWARDS" || + s_direction == "AROUND") + go = new MsgCmdGoToRelativePP(vec); + else if(s_direction.substr(0, 5) == "RIGHT") + go = new MsgCmdGoToRelativePP(vec.rotate(-PI/2)); + else if(s_direction.substr(0, 4) == "LEFT") + go = new MsgCmdGoToRelativePP(vec.rotate(PI/2)); + else if(s_direction == "BACK" || + s_direction == "BACKWARD" || + s_direction == "BACKWARDS") + go = new MsgCmdGoToRelativePP(vec.rotate(PI)); + if(go != NULL) { + Boeing::RobotClient *r = p_client->find(robot); + if(r) #ifdef USE_TXT_COMMANDS - sendAction(r, go); + sendAction(r, go); #else - r->sendGoToCmd(go->content()->priority, go->content()->taskid, - go->content()->x, go->content()->y, go->content()->angle, - go->content()->useAngle(), go->content()->useRelative()); + r->sendGoToCmd(go->content()->priority, go->content()->taskid, + go->content()->x, go->content()->y, go->content()->angle, + go->content()->useAngle(), go->content()->useRelative()); #endif - delete go; - } else - GalUtil_Error("unknown direction %s", s_direction.c_str()); - } - } - } - else if(!strcmp(query, "halt_command")) { - GalUtil_Error("sending halt query to backend"); - vector bots = p_client->getClientList(); - for(vector::const_iterator i = bots.begin(); i != bots.end(); i++) { - Boeing::RobotClient *r = p_client->find(*i); - MsgCmdHaltPP halt; - if (r) + delete go; + } else + GalUtil_Error("unknown direction %s", s_direction.c_str()); + } + } +} + +static void halt_command(const char* robot, const Gal_Frame& inframe) +{ + GalUtil_Error("sending halt query to backend"); + vector bots = p_client->getClientList(); + for(vector::const_iterator i = bots.begin(); i != bots.end(); i++) { + Boeing::RobotClient *r = p_client->find(*i); + MsgCmdHaltPP halt; + if (r) #ifdef USE_TXT_COMMANDS - sendAction(r, &halt); + sendAction(r, &halt); #else - r->sendHalt(halt.content()->priority, halt.content()->taskid); + r->sendHalt(halt.content()->priority, halt.content()->taskid); #endif - } - } - else if(!strcmp(query, "follow_command")) { - GalUtil_Error("sending follow command to backend"); - string followee = Gal_GetString(inframe, ":followee"); - if(followee.empty()) { - cerr << "no followee" << endl; - } else { - MsgCmdFollowPP follow(followee); - Boeing::RobotClient *r = p_client->find(robot); - if(r) + } +} + +static void follow_command(const char* robot, const Gal_Frame& inframe) +{ + GalUtil_Error("sending follow command to backend"); + string followee = Gal_GetString(inframe, ":followee"); + if(followee.empty()) { + cerr << "no followee" << endl; + } else { + MsgCmdFollowPP follow(followee); + Boeing::RobotClient *r = p_client->find(robot); + if(r) #ifdef USE_TXT_COMMANDS - sendAction(r, &follow); + sendAction(r, &follow); #else - r->sendFollow(follow.content()->priority, follow.content()->taskid); + r->sendFollow(follow.content()->priority, follow.content()->taskid); #endif - } - } - else if(!strcmp(query, "search_command") || !strcmp(query, "explore_command")) { - if(!strcmp(query, "search_command")) { - GalUtil_Debug1("sending search command to backend\n"); - } else { - GalUtil_Debug1("sending explore command to backend\n"); - } - geometry::Polygon polygon; - ostringstream search; - if(!strcmp(query, "search_command")) { - search << "search"; - } else { - search << "explore"; - } - for(int i=1;;i++) { - ostringstream xparam; - xparam << ":x" << i; - GalUtil_Debug1("xparam is %s\n", xparam.str().c_str()); - char* sx = Gal_GetString(inframe, xparam.str().c_str()); - ostringstream yparam; - yparam << ":y" << i; - char* sy = Gal_GetString(inframe, yparam.str().c_str()); - if(sx == NULL || !strcmp(sx, "") || sy == NULL || !strcmp(sy, "")) break; - //polygon.push_back(Point(atof(sx), atof(sy))); - //GalUtil_Debug1("x = %f, y = %f\n", polygon.back().x, polygon.back().y); - search << " (" << sx << ' ' << sy << ')'; - } - //MsgCmdCoverPP mcc(polygon); - //MsgCmdActionPP mcc = Msg::construct_MsgCmdAction(search.str()); - //p_client->sendPacketToOptrader(mcc); - t_client->sendTask(iTraderTaskId++, search.str().c_str()); - } - else if(!strcmp(query, "move_to_goal_command")) { - GalUtil_Error("sending goal movement to backend"); - string ordinal(Gal_GetString(inframe, ":ordinal")); - if(ordinal == "home") { - string sRelDist(Gal_GetString(inframe, ":relDist")); - if(sRelDist == "1") { - MsgCmdHomePP home; - Boeing::RobotClient *r = p_client->find(robot); - if(r) r->sendHome(home.content()->priority, home.content()->taskid); - //p_client->sendPacket(robot, MsgCmdHomePP()); - } else if(sRelDist == "2") { - ostringstream err; - err << "relative to goal '" << sRelDist << '\'' << " not understood"; - GalUtil_Error(err.str().c_str()); - return f; - } else if(sRelDist == "3") { - ostringstream err; - err << "relative to goal '" << sRelDist << '\'' << " not understood"; - GalUtil_Error(err.str().c_str()); - return f; - } else if(sRelDist == "4") { - ostringstream err; - err << "relative to goal '" << sRelDist << '\'' << " not understood"; - GalUtil_Error(err.str().c_str()); - return f; - } else if(sRelDist == "5") { - ostringstream err; - err << "relative to goal '" << sRelDist << '\'' << " not understood"; - GalUtil_Error(err.str().c_str()); - return f; - } else if(sRelDist == "6") { - ostringstream err; - err << "relative to goal '" << sRelDist << '\'' << " not understood"; - GalUtil_Error(err.str().c_str()); - return f; - } else { - ostringstream err; - err << "relative to goal '" << sRelDist << '\'' << " not understood"; - GalUtil_Error(err.str().c_str()); - return f; - } - } - else { - //absolute ordinal - istringstream issOrdinal(ordinal); - string token; - issOrdinal >> token; - float f_xcoord, f_ycoord; - if(token == "NEGATIVE") { - GalUtil_Error("got negative x"); - issOrdinal >> token; - ostringstream dispval; - dispval << '"' << token << '"'; - GalUtil_Error(dispval.str().c_str()); - f_xcoord = static_cast(-tkGetNumber999(token)); - } else { - ostringstream dispval; - dispval << '"' << token << '"'; - GalUtil_Error(dispval.str().c_str()); - f_xcoord = static_cast(tkGetNumber999(token)); - } - GalUtil_Error("got x"); - issOrdinal >> token; - if(token == "NEGATIVE") { - GalUtil_Error("got negative y"); - issOrdinal >> token; - ostringstream dispval; - dispval << '"' << token << '"'; - GalUtil_Error(dispval.str().c_str()); - f_ycoord = static_cast(-tkGetNumber999(token)); - } else { - ostringstream dispval; - dispval << '"' << token << '"'; - GalUtil_Error(dispval.str().c_str()); - f_ycoord = static_cast(tkGetNumber999(token)); - } - GalUtil_Error("got y"); - MsgCmdGoToGlobalPP go(Point(f_xcoord, f_ycoord)); - Boeing::RobotClient *r = p_client->find(robot); - if(r) + } +} + +static void search_or_explore(const char* query, const char* robot, const Gal_Frame& inframe) +{ + if(!strcmp(query, "search_command")) { + GalUtil_Debug1("sending search command to backend\n"); + } else { + GalUtil_Debug1("sending explore command to backend\n"); + } + geometry::Polygon polygon; + ostringstream search; + if(!strcmp(query, "search_command")) { + search << "search"; + } else { + search << "explore"; + } + for(int i=1;;i++) { + ostringstream xparam; + xparam << ":x" << i; + GalUtil_Debug1("xparam is %s\n", xparam.str().c_str()); + char* sx = Gal_GetString(inframe, xparam.str().c_str()); + ostringstream yparam; + yparam << ":y" << i; + char* sy = Gal_GetString(inframe, yparam.str().c_str()); + if(sx == NULL || !strcmp(sx, "") || sy == NULL || !strcmp(sy, "")) break; + //polygon.push_back(Point(atof(sx), atof(sy))); + //GalUtil_Debug1("x = %f, y = %f\n", polygon.back().x, polygon.back().y); + search << " (" << sx << ' ' << sy << ')'; + } + //MsgCmdCoverPP mcc(polygon); + //MsgCmdActionPP mcc = Msg::construct_MsgCmdAction(search.str()); + //p_client->sendPacketToOptrader(mcc); + t_client->sendTask(iTraderTaskId++, search.str().c_str()); +} + +static void move_to_goal_command(const char* robot, const Gal_Frame& inframe) +{ + GalUtil_Error("sending goal movement to backend"); + string ordinal(Gal_GetString(inframe, ":ordinal")); + if(ordinal == "home") { + string sRelDist(Gal_GetString(inframe, ":relDist")); + if(sRelDist == "1") { + MsgCmdHomePP home; + Boeing::RobotClient *r = p_client->find(robot); + if(r) r->sendHome(home.content()->priority, home.content()->taskid); + //p_client->sendPacket(robot, MsgCmdHomePP()); + } else if(sRelDist == "2") { + ostringstream err; + err << "relative to goal '" << sRelDist << '\'' << " not understood"; + GalUtil_Error(err.str().c_str()); + return; + } else if(sRelDist == "3") { + ostringstream err; + err << "relative to goal '" << sRelDist << '\'' << " not understood"; + GalUtil_Error(err.str().c_str()); + return; + } else if(sRelDist == "4") { + ostringstream err; + err << "relative to goal '" << sRelDist << '\'' << " not understood"; + GalUtil_Error(err.str().c_str()); + return; + } else if(sRelDist == "5") { + ostringstream err; + err << "relative to goal '" << sRelDist << '\'' << " not understood"; + GalUtil_Error(err.str().c_str()); + return; + } else if(sRelDist == "6") { + ostringstream err; + err << "relative to goal '" << sRelDist << '\'' << " not understood"; + GalUtil_Error(err.str().c_str()); + return; + } else { + ostringstream err; + err << "relative to goal '" << sRelDist << '\'' << " not understood"; + GalUtil_Error(err.str().c_str()); + return; + } + } else { + //absolute ordinal + istringstream issOrdinal(ordinal); + string token; + issOrdinal >> token; + float f_xcoord, f_ycoord; + if(token == "NEGATIVE") { + GalUtil_Error("got negative x"); + issOrdinal >> token; + ostringstream dispval; + dispval << '"' << token << '"'; + GalUtil_Error(dispval.str().c_str()); + f_xcoord = static_cast(-tkGetNumber999(token)); + } else { + ostringstream dispval; + dispval << '"' << token << '"'; + GalUtil_Error(dispval.str().c_str()); + f_xcoord = static_cast(tkGetNumber999(token)); + } + GalUtil_Error("got x"); + issOrdinal >> token; + if(token == "NEGATIVE") { + GalUtil_Error("got negative y"); + issOrdinal >> token; + ostringstream dispval; + dispval << '"' << token << '"'; + GalUtil_Error(dispval.str().c_str()); + f_ycoord = static_cast(-tkGetNumber999(token)); + } else { + ostringstream dispval; + dispval << '"' << token << '"'; + GalUtil_Error(dispval.str().c_str()); + f_ycoord = static_cast(tkGetNumber999(token)); + } + GalUtil_Error("got y"); + MsgCmdGoToGlobalPP go(Point(f_xcoord, f_ycoord)); + Boeing::RobotClient *r = p_client->find(robot); + if(r) #ifdef USE_TXT_COMMANDS - sendAction(r, &go); + sendAction(r, &go); #else - r->sendGoToCmd(go.content()->priority, go.content()->taskid, - go.content()->x, go.content()->y, go.content()->angle, - go.content()->useAngle(), go.content()->useRelative()); + r->sendGoToCmd(go.content()->priority, go.content()->taskid, + go.content()->x, go.content()->y, go.content()->angle, + go.content()->useAngle(), go.content()->useRelative()); #endif - } - } - else if(!strcmp(query, "turn_command")) { - GalUtil_Error("got turn command"); - string sDirection(Gal_GetString(inframe, ":direction")); - bool bRel(false); - double fRad; - if(sDirection == "NORTH") fRad = PI/2; - else if(sDirection == "NORTHEAST") fRad = PI/4; - else if(sDirection == "NORTHWEST") fRad = 3*PI/4; - else if(sDirection == "EAST") fRad = 0; - else if(sDirection == "WEST") fRad = PI; - else if(sDirection == "SOUTH") fRad = 3*PI/2; - else if(sDirection == "SOUTHEAST") fRad = 7*PI/4; - else if(sDirection == "SOUTHWEST") fRad = 5*PI/4; - else if(sDirection == "STRAIGHT" || - sDirection == "FORWARD" || - sDirection == "FORWARDS") { - bRel = true; - fRad = 0; - } else if(sDirection.substr(0, 5) == "RIGHT") { - string sQual; - if(Gal_GetString(inframe, ":increment")) - sQual = (Gal_GetString(inframe, ":increment")); - bRel = true; - if(sQual.empty() || sQual == "") { - fRad = -PI/2; - } else { - fRad = -tkGetNumber999(sQual)*PI/180; - } - } else if(sDirection.substr(0, 4) == "LEFT") { - string sQual; - if(Gal_GetString(inframe, ":increment")) - sQual = (Gal_GetString(inframe, ":increment")); - bRel = true; - if(sQual.empty() || sQual == "") { - fRad = PI/2; - } else { - fRad = tkGetNumber999(sQual)*PI/180; - } - } else if(sDirection == "AROUND" || - sDirection == "BACK" || - sDirection == "BACKWARD" || - sDirection == "BACKWARDS") { - bRel = true; - fRad = PI; - } else { - GalUtil_Error("unknown direction %s", sDirection.c_str()); - return f; - } - MsgCmdTurnRelativePP turn(fRad); - Boeing::RobotClient *r = p_client->find(robot); - if(r) + } +} + + + +static void turn_command(const char* robot, const Gal_Frame& inframe) +{ + GalUtil_Error("got turn command"); + string sDirection(Gal_GetString(inframe, ":direction")); + bool bRel(false); + double fRad; + if(sDirection == "NORTH") fRad = PI/2; + else if(sDirection == "NORTHEAST") fRad = PI/4; + else if(sDirection == "NORTHWEST") fRad = 3*PI/4; + else if(sDirection == "EAST") fRad = 0; + else if(sDirection == "WEST") fRad = PI; + else if(sDirection == "SOUTH") fRad = 3*PI/2; + else if(sDirection == "SOUTHEAST") fRad = 7*PI/4; + else if(sDirection == "SOUTHWEST") fRad = 5*PI/4; + else if(sDirection == "STRAIGHT" || + sDirection == "FORWARD" || + sDirection == "FORWARDS") { + bRel = true; + fRad = 0; + } else if(sDirection.substr(0, 5) == "RIGHT") { + string sQual; + if(Gal_GetString(inframe, ":increment")) + sQual = (Gal_GetString(inframe, ":increment")); + bRel = true; + if(sQual.empty() || sQual == "") { + fRad = -PI/2; + } else { + fRad = -tkGetNumber999(sQual)*PI/180; + } + } else if(sDirection.substr(0, 4) == "LEFT") { + string sQual; + if(Gal_GetString(inframe, ":increment")) + sQual = (Gal_GetString(inframe, ":increment")); + bRel = true; + if(sQual.empty() || sQual == "") { + fRad = PI/2; + } else { + fRad = tkGetNumber999(sQual)*PI/180; + } + } else if(sDirection == "AROUND" || + sDirection == "BACK" || + sDirection == "BACKWARD" || + sDirection == "BACKWARDS") { + bRel = true; + fRad = PI; + } else { + GalUtil_Error("unknown direction %s", sDirection.c_str()); + return; + } + MsgCmdTurnRelativePP turn(fRad); + Boeing::RobotClient *r = p_client->find(robot); + if(r) #ifdef USE_TXT_COMMANDS - sendAction(r, &turn); + sendAction(r, &turn); #else - r->sendGoToCmd(turn.content()->priority, turn.content()->taskid, - turn.content()->x, turn.content()->y, turn.content()->angle, - turn.content()->useAngle(), turn.content()->useRelative()); + r->sendGoToCmd(turn.content()->priority, turn.content()->taskid, + turn.content()->x, turn.content()->y, turn.content()->angle, + turn.content()->useAngle(), turn.content()->useRelative()); #endif - } - else { - GalUtil_Error("unhandled query: %s", query); - } - } else { - GalUtil_Error("there is no robot"); - } - } else { - GalUtil_Error("there is no query"); - } - } else { - GalUtil_Error("couldn't find :inframe"); - } - } else { @@ Diff output truncated at 60000 characters. @@ From tk at edam.speech.cs.cmu.edu Thu Nov 9 15:10:39 2006 From: tk at edam.speech.cs.cmu.edu (tk@edam.speech.cs.cmu.edu) Date: Thu, 9 Nov 2006 15:10:39 -0500 Subject: [TeamTalk 8]: [545] TeamTalk/Agents: Added code for PenDecoder and Backend handling of setpos. Message-ID: <200611092010.kA9KAdTF025998@edam.speech.cs.cmu.edu> An HTML attachment was scrubbed... URL: http://mailman.srv.cs.cmu.edu/pipermail/teamtalk-developers/attachments/20061109/7a29be6f/attachment.html -------------- next part -------------- Modified: TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/DrawingCanvas.java =================================================================== --- TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/DrawingCanvas.java 2006-11-09 19:17:31 UTC (rev 544) +++ TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/DrawingCanvas.java 2006-11-09 20:10:38 UTC (rev 545) @@ -92,6 +92,25 @@ } } + /** + * this informs the bot that it should be at the screen position and orientation + * indicated by the point + */ + public void placeSelectedBot(Point p, float theta) { + screen_to_map.transform(p, p); + if(shapes != null) { + Iterator i = shapes.iterator(); + while(i.hasNext()) { + Shape shape = i.next(); + if(shape.isSelected()) { + BotShape selectedBot = (BotShape) shape; + drawingPad.placeBot(shape.getName(), p, theta); + return; + } + } + } + } + public void search(RectangleShape shape) { //find translator bot and do translation here BotShape bot = BotOf(opTraderFrameHolder); //[2005-10-02] (tk): hack Modified: TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/DrawingPad.java =================================================================== --- TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/DrawingPad.java 2006-11-09 19:17:31 UTC (rev 544) +++ TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/DrawingPad.java 2006-11-09 20:10:38 UTC (rev 545) @@ -152,6 +152,13 @@ } } + public void placeBot(String name, Point p, float theta) { + ListIterator i = servers.listIterator(); + while(i.hasNext()) { + i.next().placeBot(name, p.x, p.y, theta); + } + } + public void selectBot(String name) { drawingCanvas.selectBot(name); } Modified: TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/PenDecoderServer.java =================================================================== --- TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/PenDecoderServer.java 2006-11-09 19:17:31 UTC (rev 544) +++ TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/PenDecoderServer.java 2006-11-09 20:10:38 UTC (rev 545) @@ -194,6 +194,15 @@ sayToBot("Commands", "[HumanReportCommand]", rname); } + public void placeBot(String name, float x, float y, float theta) { + System.err.println("placing bot " + name + ": (" + x + " " + y + ") " + theta); + Map pose = new HashMap(); + pose.put("[x]", Double.toString(x)); + pose.put("[y]", Double.toString(y)); + pose.put("[angle]", Double.toString(theta)); + sayToBot("Commands", "[SetPoseCommand]", pose); + } + public void search(RectangleShape shape) { System.err.println("Searching..."); Map loc = new HashMap(); Modified: TeamTalk/Agents/PrimitiveComm/robot_packet.cpp =================================================================== --- TeamTalk/Agents/PrimitiveComm/robot_packet.cpp 2006-11-09 19:17:31 UTC (rev 544) +++ TeamTalk/Agents/PrimitiveComm/robot_packet.cpp 2006-11-09 20:10:38 UTC (rev 545) @@ -580,4 +580,10 @@ double MsgCmdSetPos::getX() const {return x_;} double MsgCmdSetPos::getY() const {return y_;} -double MsgCmdSetPos::getAngle() const {return angle_;} \ No newline at end of file +double MsgCmdSetPos::getAngle() const {return angle_;} + +string MsgCmdSetPos::action_string() const { + ostringstream out; + out << "setpos (" << x_ << ' ' << y_ << ") " << angle_; + return out.str(); +} Modified: TeamTalk/Agents/PrimitiveComm/robot_packet.hpp =================================================================== --- TeamTalk/Agents/PrimitiveComm/robot_packet.hpp 2006-11-09 19:17:31 UTC (rev 544) +++ TeamTalk/Agents/PrimitiveComm/robot_packet.hpp 2006-11-09 20:10:38 UTC (rev 545) @@ -95,6 +95,7 @@ double getX() const; double getY() const; double getAngle() const; + string action_string() const; }; class MsgCmdHaltPP : public Msg { Modified: TeamTalk/Agents/TeamTalkBackend/gal_be.cpp =================================================================== --- TeamTalk/Agents/TeamTalkBackend/gal_be.cpp 2006-11-09 19:17:31 UTC (rev 544) +++ TeamTalk/Agents/TeamTalkBackend/gal_be.cpp 2006-11-09 20:10:38 UTC (rev 545) @@ -1197,6 +1197,17 @@ #endif } +static void set_pose_command(const char* robot, const Gal_Frame& inframe) +{ + GalUtil_Error("got turn command"); + const char* x = Gal_GetString(inframe, ":x"); + const char* y = Gal_GetString(inframe, ":y"); + const char* a = Gal_GetString(inframe, ":angle"); + MsgCmdSetPos set_pos(atof(x), atof(y), atof(a)); + Boeing::RobotClient *r = p_client->find(robot); + if(r) sendAction(r, &set_pos); +} + Gal_Frame launch_query(Gal_Frame f, void *server_data) { Gal_Object aStr; @@ -1261,6 +1272,7 @@ search_or_explore(query, robot, inframe); else if(!strcmp(query, "move_to_goal_command")) move_to_goal_command(robot, inframe); else if(!strcmp(query, "turn_command")) turn_command(robot, inframe); + else if(!strcmp(query, "set_pose_command")) set_pose_command(robot, inframe); else GalUtil_Error("unhandled query: %s", query); Gal_SetProp(f, ":outframe", aStr);