Index: AiboPup/INSTALL
diff -c /dev/null AiboPup/INSTALL:1.1
*** /dev/null	Fri Oct 10 14:37:42 2003
--- AiboPup/INSTALL	Sat Aug 23 19:25:37 2003
***************
*** 0 ****
--- 1,16 ----
+   For full information on installation, visit:
+   http://www.tekkotsu.org/TekkotsuInstall.html
+ 
+   In short, you should put the Tekkotsu directory someplace like
+   /usr/local (the default location scripts will look), and then copy
+   the template 'project' directory to your personal workspace (like
+   your home directory).
+ 
+   The Tekkotsu directory (the current directory) will be shared by all
+   projects.  You should be able to get pretty far without having to
+   modify the shared Tekkotsu framework files, although if you do, feel
+   free to let us know and send us a patch if you think your changes
+   would be useful to others.
+ 
+   Your code should go in your own copy of the 'project' directory.  To
+   build an executable, type 'make' in your local copy of 'project'.
Index: AiboPup/Makefile
diff -c AiboPup/Makefile:1.15 AiboPup/Makefile:1.26
*** AiboPup/Makefile:1.15	Mon Jul  7 14:08:12 2003
--- AiboPup/Makefile	Thu Oct  2 00:54:17 2003
***************
*** 1,106 ****
  all:
  
! PROCESSES=MMCombo TinyFTPD SoundPlay
! MMCombo_COMP=MMCombo Behaviors Events Motion Shared SoundPlay/SoundManager.o SoundPlay/WAV.o Vision Wireless WorldModel2
! TinyFTPD_COMP=TinyFTPD
! SoundPlay_COMP=SoundPlay Shared/Config.o Shared/ProcessID.o Events/EventRouter.o Events/EventTranslator.o Events/EventBase.o Shared/LoadSave.o Shared/get_time.o
! TARGETS=all clean
! OPENRSDK_ROOT?=/usr/local/OPEN_R_SDK
! LD=$(OPENRSDK_ROOT)/bin/mipsel-linux-ld
  
! # list of components for all processes
! # NOT SORTED, process directories need to be made first (generated stub header files)
! COMPONENTS:=$(foreach proc,$(PROCESSES),$($(proc)_COMP))
  
! # for all components of all processes:
! # converts directory component name to expected library name: MMCombo -> MMCombo/MMComboLib.o
! # sorted to remove duplicates
! LIB_COMPONENTS:=$(foreach comp,$(COMPONENTS), $(if $(suffix $(comp)),$(comp),$(comp)/$(comp)Lib.o))
! 
! # for all processes:
! # creates 'target' names: MMCombo -> build/MMCombo.o
! BUILDS:=$(foreach proc,$(PROCESSES),build/$(proc).o)
! 
! #the automatic way of doing this part is too messy, just add a rule for each processes by hand: (skip lines!)
! $(word 1,$(BUILDS)): $($(word 1,$(PROCESSES))_COMP)
! 
! $(word 2,$(BUILDS)): $($(word 2,$(PROCESSES))_COMP)
! 
! $(word 3,$(BUILDS)): $($(word 3,$(PROCESSES))_COMP)
! 
! .PHONY: $(TARGETS) reportTarget docs doc cleandoc tools updateComponents testbuild update clean
! 
! all: reportTarget updateComponents $(BUILDS)
! 
! reportTarget:
! 	@echo " ** Targeting $(TEKKOTSU_TARGET_MODEL) for build ** ";
! 
! tools:
! 	cd tools && $(MAKE) $@; \
! 
! %.o:
! 	@if [ "$(dir $@)" != "./" -a -d "$(dir $@)" ] ; then \
! 		echo "cd $(dir $@) && $(MAKE) $(notdir $@)"; \
! 		cd $(dir $@) && $(MAKE) $(notdir $@); \
! 	else \
! 		echo "Unknown target"; \
! 		exit 1; \
! 	fi;
! 
! $(BUILDS):
! 	@if [ ! -d build ] ; then mkdir build; fi;
! 	@echo "Linking component object files..."
! 	@echo "$@ <- $(foreach comp,$($(basename $(notdir $@))_COMP),$(if $(suffix $(comp)),$(comp),$(comp)/$(comp)Lib.o))"
! 	@$(LD)	-i $(foreach comp,$($(basename $(notdir $@))_COMP),$(if $(suffix $(comp)),$(comp),$(comp)/$(comp)Lib.o)) -o $@ ; \
! 		if [ $$? -ne 0 ] ; then exit 1; fi;
! 	@echo "Copying .ocf files..."
! 	@cp $(basename $(notdir $@))/$(notdir $@)cf $(dir $@)
! 
! updateComponents:
! 	@for comp in tools/ $(LIB_COMPONENTS); do \
! 		dir=`echo "$$comp" | sed 's/\/[^/]*$$//'`; \
! 		name=`echo "$$comp" | sed 's/.*\///'`; \
! 		echo "** BUILDING: $$dir/$$name"; \
! 		(cd $$dir && $(MAKE) $$name); \
! 		if [ $$? -ne 0 ] ; then \
! 			exit 1; \
! 		fi; \
! 	done
! 
! clean:
! 	@for comp in tools $(LIB_COMPONENTS); do \
! 		dir=`echo "$$comp" | sed 's/\/[^/]*$$//'`; \
! 		name=`echo "$$comp" | sed 's/.*\///'`; \
! 		echo "** CLEANING: $$dir" ;\
! 		(cd $$dir && $(MAKE) $@); \
! 		if [ $$? -ne 0 ] ; then \
! 			exit 1; \
! 		fi; \
! 	done
! 	rm -f docs/doxygenbuildcfg;
! 	rm -rf build;
! 
! #memstick: install
! #	tools/cpymem;
! #	@echo "Copy completed; memory stick unmounted"
! #	tools/mntmem;
! #	cp -r ms/* /mnt/memstick
! #	tools/umntmem;
! 
! #ftp: install
! #	tools/mstreeput 192.168.0.5 ms;
! 
! docs doc:
! 	docs/builddocs --update
! 
! cleandoc:
! 	docs/builddocs --clean
! 
! #fullcopy:
! #	tools/mntmem;
! #	cp -r ms/* /mnt/memstick
! #	tools/umntmem;
! 
! update:
! 	$(MAKE) all;
! 	(cd project && $(MAKE) update);
--- 1,12 ----
  all:
+ 	@echo INSTALLATION INSTRUCTIONS:
+ 	@cat INSTALL
  
! update install clean allclean:
! 	@echo You should be running \'$(MAKE)\' from your project directory...
! 	@echo Nothing to be done here.
  
! dox docs doc:
! 	docs/builddocs --update --tree --search
  
! .PHONY: all update install dox docs doc
\ No newline at end of file
Index: AiboPup/README
diff -c AiboPup/README:1.4 AiboPup/README:1.5
*** AiboPup/README:1.4	Tue Apr  8 23:37:10 2003
--- AiboPup/README	Sat Aug 23 19:25:37 2003
***************
*** 19,28 ****
  Directory Descriptions:
  ----------------------
  
    * Non-Source Framework Files *
      --------------------------
      docs - scripts, configuration, and other files for the doxygen documentation
-     project - project template directory, copy to another location for local development
      tools - build scripts, utilities, and PC-side tools.
  
    * Source Files *
--- 19,31 ----
  Directory Descriptions:
  ----------------------
  
+   * User Code Template *
+     ------------------
+     project - project template directory, copy to another location for local development
+ 
    * Non-Source Framework Files *
      --------------------------
      docs - scripts, configuration, and other files for the doxygen documentation
      tools - build scripts, utilities, and PC-side tools.
  
    * Source Files *
Index: AiboPup/entry.h
diff -c /dev/null AiboPup/entry.h:1.1
*** /dev/null	Fri Oct 10 14:37:42 2003
--- AiboPup/entry.h	Fri Jul 25 16:18:00 2003
***************
*** 0 ****
--- 1,4 ----
+ // This file is merely to workaround a bug in:
+ // OPEN_R_SDK/OPEN_R/include/OPENR/core_macro.h:10
+ // which says  #include "entry.h" (a stub-generated file, specific to each process)
+ 
Index: AiboPup/Behaviors/BehaviorBase.h
diff -c AiboPup/Behaviors/BehaviorBase.h:1.5 AiboPup/Behaviors/BehaviorBase.h:1.9
*** AiboPup/Behaviors/BehaviorBase.h:1.5	Mon Jun  9 04:05:08 2003
--- AiboPup/Behaviors/BehaviorBase.h	Fri Oct 10 11:54:04 2003
***************
*** 12,28 ****
  class BehaviorBase : public ReferenceCounter, public EventListener {
   public:
  	//! constructor
! 	BehaviorBase() : ReferenceCounter(), started(false) {}
  	//! destructor - if is active when deleted, will call DoStop() first
! 	virtual ~BehaviorBase() { SetAutoDelete(false); if(started) DoStop();  } //{ if(started) { references++; DoStop(); references--; } }
  	//! By default, merely adds to the reference counter (through AddReference()) @note you should still call this from your overriding methods
! 	virtual void DoStart() { if(!started) { started=true; AddReference(); } }
  	//! By default, subtracts from the reference counter, and deletes if zero @note you should still call this when you override this @warning call this at the end of your DoStop(), not beginning (it might @c delete @c this )
! 	virtual void DoStop() { if(started) { started=false; RemoveReference(); } }
! 	//! Allows you to get away with not supplying a processEvent() function for the EventListener interface.  By default, does nothing.
  	virtual void processEvent(const EventBase& /*event*/) {};
  
- 	
  	//! Identifies the behavior in menus and such
  	virtual std::string getName() const =0;
  
--- 12,52 ----
  class BehaviorBase : public ReferenceCounter, public EventListener {
   public:
  	//! constructor
! 	BehaviorBase() : ReferenceCounter(), EventListener(), started(false) {}
! 	//! copy constructor; assumes subclass handles copying approriately - i.e. if @a b is active, the copy will be as well, even though DoStart was never called..
! 	BehaviorBase(const BehaviorBase& b) : ReferenceCounter(b), EventListener(b), started(b.started) {}
! 	//! assignment operator; assumes subclass handles assignment appropriately - i.e. if @a b is active, the copy will be as well, even though DoStart was never called..
! 	BehaviorBase& operator=(const BehaviorBase& b) { ReferenceCounter::operator=(b); EventListener::operator=(b); started=b.started; return *this; }
! 
  	//! destructor - if is active when deleted, will call DoStop() first
! 	virtual ~BehaviorBase() {
! 		SetAutoDelete(false);
! 		if(started)
! 			DoStop();
! 		//{ if(started) { references++; DoStop(); references--; } }
! 	}
! 	
  	//! By default, merely adds to the reference counter (through AddReference()) @note you should still call this from your overriding methods
! 	virtual void DoStart() {
! 		//std::cout << getName() << " started " << this << std::endl;
! 		if(!started) {
! 			started=true;
! 			AddReference();
! 		}
! 	}
! 
  	//! By default, subtracts from the reference counter, and deletes if zero @note you should still call this when you override this @warning call this at the end of your DoStop(), not beginning (it might @c delete @c this )
! 	virtual void DoStop() {
! 		//std::cout << getName() << " stopped " << this << std::endl;
! 		if(started) {
! 			started=false;
! 			RemoveReference();
! 		}
! 	}
! 	
! 	//! By defining here, allows you to get away with not supplying a processEvent() function for the EventListener interface.  By default, does nothing.
  	virtual void processEvent(const EventBase& /*event*/) {};
  
  	//! Identifies the behavior in menus and such
  	virtual std::string getName() const =0;
  
***************
*** 44,53 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 68,77 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controller.cc
diff -c AiboPup/Behaviors/Controller.cc:1.20 AiboPup/Behaviors/Controller.cc:1.28
*** AiboPup/Behaviors/Controller.cc:1.20	Sun Jul  6 21:00:07 2003
--- AiboPup/Behaviors/Controller.cc	Thu Oct  9 20:44:50 2003
***************
*** 9,14 ****
--- 9,16 ----
  #include "Events/TextMsgEvent.h"
  #include "Shared/ERS210Info.h"
  #include "Shared/ERS220Info.h"
+ #include "Shared/DynamicConfig.h"
+ #include "Shared/string_util.h"
  #include <sstream>
  
  Controller * Controller::theOneController=NULL;
***************
*** 21,26 ****
--- 23,30 ----
  EventBase Controller::selectItem;
  EventBase Controller::cancel;
  
+ using namespace string_util;
+ 
  
  void Controller::DoStart() {
  	BehaviorBase::DoStart();
***************
*** 115,120 ****
--- 119,125 ----
  		cmdstack.top()->deactivate();
  		cmdstack.pop();
  	}
+ 	refresh();
  }
  
  void Controller::refresh() {
***************
*** 128,139 ****
--- 133,146 ----
  		return;
  	cmdstack.top()->pause();
  	cmdstack.push(c);
+ 	theOneController->gui_comm->printf("push\n");
  	setNext(cmdstack.top()->activate(display,gui_comm));
  }
  
  void Controller::pop() {
  	cmdstack.top()->deactivate();
  	cmdstack.pop();
+ 	theOneController->gui_comm->printf("pop\n");
  	refresh();
  }
  
***************
*** 173,178 ****
--- 180,188 ----
  }
  
  void Controller::closeGUI(const std::string& name) {
+ 	ASSERTRET(theOneController!=NULL,"null controller");
+ 	ASSERTRET(theOneController->gui_comm!=NULL,"null gui_comm");
+ 
  	theOneController->gui_comm->printf("close\n%s\n",name.c_str());
  }
  
***************
*** 229,234 ****
--- 239,245 ----
  }
  
  void Controller::init() {
+   wireless->setDaemon(gui_comm);
  	if(state->robotDesign & WorldState::ERS210Mask) {
  		nextItem=EventBase(EventBase::buttonEGID,ERS210Info::HeadFrButOffset,EventBase::deactivateETID,0);
  		prevItem=EventBase(EventBase::buttonEGID,ERS210Info::HeadBkButOffset,EventBase::deactivateETID,0);
***************
*** 253,304 ****
  
  void Controller::takeLine(const std::string& s) {
  	//	cout << "RECEIVED: " << s << endl;
! 	if(s.size()==0) {
  		return;
! 	} else if(s[0]!='!') {
  		setNext(cmdstack.top()->takeInput(s));
  	} else {
! 		//find the first non-whitespace character after the '!'
! 		std::string msg;
! 		{ unsigned int i=1;	while(isspace(s[i]) && i<s.size()) i++;	msg=s.substr(i); }
! 		if(msg.find("refresh")==0) {
  			refresh();
! 		} else if(msg.find("reset")==0) {
  			reset();
! 		} else if(msg.find("cancel")==0) {
  			setNext(cmdstack.top()->doCancel());
! 		} else if(msg.find("select")==0) {
  			setNext(cmdstack.top()->doSelect());
! 		} else if(msg.find("next")==0) {
  			setNext(cmdstack.top()->doNextItem());
! 		} else if(msg.find("prev")==0) {
  			setNext(cmdstack.top()->doPrevItem());
! 		} else if(msg.find("msg ")==0) {
! 			erouter->postEvent(new TextMsgEvent(msg.substr(strlen("msg "))));
! 		} else if(msg.find("hilight")==0) {
  			std::vector<unsigned int> hilights;
! 			unsigned int i=strlen("hilight");
! 			while(i<msg.size()) {
! 				while(i<msg.size() && isspace(msg[i])) i++;
! 				if(i<msg.size())
! 					 hilights.push_back(atoi(&msg.c_str()[i]));
! 				while(i<msg.size() && !isspace(msg[i])) i++;
! 			}
  			cmdstack.top()->setHilights(hilights);
! 		} else if(msg.find("input ")==0) {
  			const std::vector<unsigned int>& hilights=cmdstack.top()->getHilights();
  			const std::vector<ControlBase*>& slots=cmdstack.top()->getSlots();
! 			std::string in=msg.substr(strlen("input "));
! 			for(unsigned int i=0; i<hilights.size(); i++) {
! 				if(hilights[i]<slots.size() && slots[hilights[i]]!=NULL)
! 					slots[hilights[i]]->takeInput(in);
! 				/* if(ret!=NULL) {
! 					 push(ret);
! 					 break;
! 					 }*/
! 			}
  			refresh();
! 		} else
  			setNext(cmdstack.top()->takeInput(s));
  	}
  }
--- 264,338 ----
  
  void Controller::takeLine(const std::string& s) {
  	//	cout << "RECEIVED: " << s << endl;
! 	if(s.size()==0)
! 		return;
! 	// break s into a vector of arguments
! 	std::vector<std::string> args;
! 	std::vector<unsigned int> offsets;
! 	if(!string_util::parseArgs(s,args,offsets)) {
! 		serr->printf("Controller::takeLine(\"%s\") was malformed.\n",s.c_str());
! 		return;
! 	}
! 	// now look through for a ';' (separates multiple commands)
! 	unsigned int last=offsets[0];
! 	for(unsigned int i=0; i<args.size(); i++) {
! 		if(args[i]==";") { // if we found a ';', recurse with substring
! 			takeLine(s.substr(last,offsets[i]-last));
! 			if(i+1==args.size()) // last arg is a ';'
! 				return;
! 			last=offsets[i+1];
! 		}
! 		if(args[i]=="\\;") // if we found a '\;', replace it with base ';'
! 			args[i]=";";
! 	}
! 	if(!chkCmdStack())
  		return;
! 	if(args[0][0]!='!') {
  		setNext(cmdstack.top()->takeInput(s));
  	} else {
! 		if(last!=offsets[0]) { // only changes if we found a ';' - in that case, need to do last segment
! 			takeLine(s.substr(last));
! 		} else if(args[0]=="!refresh") {
  			refresh();
! 		} else if(args[0]=="!reset") {
  			reset();
! 		} else if(args[0]=="!cancel") {
  			setNext(cmdstack.top()->doCancel());
! 		} else if(args[0]=="!select") {
  			setNext(cmdstack.top()->doSelect());
! 		} else if(args[0]=="!next") {
  			setNext(cmdstack.top()->doNextItem());
! 		} else if(args[0]=="!prev") {
  			setNext(cmdstack.top()->doPrevItem());
! 		} else if(args[0]=="!msg") {
! 			erouter->postEvent(new TextMsgEvent(s.substr(offsets[1])));
! 		} else if(args[0]=="!hello") {
! 			static unsigned int count=0;
! 			count++;
! 			theOneController->gui_comm->printf("hello\n%d\n",count);
! 		} else if(args[0]=="!root") {
! 			ControlBase * ret=root->takeInput(s.substr(offsets[1]));
! 			if(ret!=NULL)
! 				setNext(ret);
! 		} else if(args[0]=="!hilight") {
  			std::vector<unsigned int> hilights;
! 			for(unsigned int i=1; i<args.size(); i++)
! 				hilights.push_back(atoi(args[i].c_str()));
  			cmdstack.top()->setHilights(hilights);
! 		} else if(args[0]=="!input") {
  			const std::vector<unsigned int>& hilights=cmdstack.top()->getHilights();
  			const std::vector<ControlBase*>& slots=cmdstack.top()->getSlots();
! 			std::string in=s.substr(offsets[1]);
! 			for(unsigned int i=0; i<hilights.size(); i++)
! 				if(hilights[i]<slots.size() && slots[hilights[i]]!=NULL) {
! 					ControlBase * ret=slots[hilights[i]]->takeInput(in);
! 					if(ret!=NULL)
! 						setNext(ret);
! 				}
  			refresh();
! 		} else if(args[0]=="!set") {
!       DynamicConfig::assignVarFromController(s.substr(offsets[1]).c_str());
!     } else
  			setNext(cmdstack.top()->takeInput(s));
  	}
  }
***************
*** 347,375 ****
  	return true;
  }
  
- std::string Controller::makeLower(const std::string& s) {
- 	std::string ans;
- 	ans.reserve(s.size());
- 	unsigned int i=s.size();
- 	while(i--!=0)
- 		ans+= ::tolower(s[i]);
- return ans;
- }
- 
- std::string Controller::removePrefix(const std::string& str, const std::string& pre) {
- 	if(str.compare(0,pre.size(),pre)==0)
- 		return str.substr(pre.size());
- 	return std::string();
- }
- 
  
  /*! @file
   * @brief Implements Controller class, a behavior that should be started whenever the emergency stop goes on to provide menus for robot control
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
--- 381,394 ----
  	return true;
  }
  
  
  /*! @file
   * @brief Implements Controller class, a behavior that should be started whenever the emergency stop goes on to provide menus for robot control
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
Index: AiboPup/Behaviors/Controller.h
diff -c AiboPup/Behaviors/Controller.h:1.16 AiboPup/Behaviors/Controller.h:1.21
*** AiboPup/Behaviors/Controller.h:1.16	Tue Jul  8 14:01:21 2003
--- AiboPup/Behaviors/Controller.h	Tue Sep  9 17:10:01 2003
***************
*** 24,34 ****
--- 24,38 ----
   *	- '<tt>!select</tt>' - calls ControlBase::doSelect() of the current control
   *	- '<tt>!cancel</tt>' - calls ControlBase::doCancel() of the current control
   *	- '<tt>!msg </tt><i>text</i>' - broadcasts <i>text</i> as a TextMsgEvent
+  *  - '<tt>!root </tt><i>text</i>' - calls ControlBase::takeInput(<i>text</i>) on the root control
+  *  - '<tt>!hello</tt>' - responds with '<tt>hello\n</tt><i>count</i>' where <i>count</i> is the number of times '<tt>!hello</tt>' has been sent.  Good for detecting first connection after boot vs. a reconnect.
   *	- '<tt>!hilight</tt> [<i>n1</i> [<i>n2</i> [...]]]' - hilights zero, one, or more items in the menu
   *	- '<tt>!input </tt><i>text</i>' - calls ControlBase::takeInput(<i>text</i>) on the currently hilighted control(s)
   *	- any text not beginning with '!' - sent to ControlBase::takeInput() of the current control
   *
   *  In return, to send the menus to the GUI, the following messages are sent: (newlines are required where shown)
+  *  - '<tt>push</tt>' - signals a submenu has been activated
+  *  - '<tt>pop</tt>' - signals a submenu has been closed
   *  - '<tt>refresh</tt>\n
   *    <i>text:title</i>\n
   *    <i>int:numitems</i>\n
***************
*** 81,90 ****
  class Controller : public BehaviorBase, public EventTrapper {
   public:
  	Controller() : display(MotionManager::invalid_MC_ID), estop_id(MotionManager::invalid_MC_ID), root(NULL), cmdstack(), last_time(0), cur_time(0), nextEv_val(0), nextEv_dur(0), prevEv_val(0), prevEv_dur(0), alreadyGotBoth(false), gui_comm(wireless->socket(SocketNS::SOCK_STREAM, 2048, 2048))  {init();}	//!< Constructor
! 	Controller(ControlBase* r) : display(MotionManager::invalid_MC_ID), estop_id(MotionManager::invalid_MC_ID), root(r), cmdstack(), last_time(0), cur_time(0), nextEv_val(0), nextEv_dur(0), prevEv_val(0), prevEv_dur(0), alreadyGotBoth(false), gui_comm(wireless->socket(SocketNS::SOCK_STREAM, 2048, 2048)) {init();} //!< Constructor, sets a default root control
  	virtual ~Controller() {
  		cout << "~Controller()..." << endl;
  		delete root;
  		cout << "~Controller()-DONE" << endl;
  	} //!< Destructor
  
--- 85,95 ----
  class Controller : public BehaviorBase, public EventTrapper {
   public:
  	Controller() : display(MotionManager::invalid_MC_ID), estop_id(MotionManager::invalid_MC_ID), root(NULL), cmdstack(), last_time(0), cur_time(0), nextEv_val(0), nextEv_dur(0), prevEv_val(0), prevEv_dur(0), alreadyGotBoth(false), gui_comm(wireless->socket(SocketNS::SOCK_STREAM, 2048, 2048))  {init();}	//!< Constructor
! 	Controller(ControlBase* r) : display(MotionManager::invalid_MC_ID), estop_id(MotionManager::invalid_MC_ID), root(r), cmdstack(), last_time(0), cur_time(0), nextEv_val(0), nextEv_dur(0), prevEv_val(0), prevEv_dur(0), alreadyGotBoth(false), gui_comm(wireless->socket(SocketNS::SOCK_STREAM, 2048, 2048)) { init(); } //!< Constructor, sets a default root control
  	virtual ~Controller() {
  		cout << "~Controller()..." << endl;
  		delete root;
+ 		theOneController=NULL;
  		cout << "~Controller()-DONE" << endl;
  	} //!< Destructor
  
***************
*** 171,180 ****
  		return (lastclock!=nextclock);
  	}
  
- 	static std::string makeLower(const std::string& s); //!< returns lower case version of @a s
- 	static std::string removePrefix(const std::string& str, const std::string& pre); //!< returns @a str with @a pre removed - if @a pre is not fully matched, @a str is returned unchanged
- 
- 
  
  	unsigned int last_time; //!< the time of the last event
  	unsigned int cur_time; //!< the time of the current event (do*() can check this instead of calling get_time() )
--- 176,181 ----
***************
*** 197,206 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 198,207 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Makefile
diff -c AiboPup/Behaviors/Makefile:1.8 AiboPup/Behaviors/Makefile:removed
*** AiboPup/Behaviors/Makefile:1.8	Tue Jun 10 21:18:52 2003
--- AiboPup/Behaviors/Makefile	Fri Oct 10 14:37:43 2003
***************
*** 1,52 ****
- TEKKOTSU_TARGET_MODEL?=TGT_ERS2xx
- 
- SRCS:=$(shell find . -name "*.cc")
- 
- OBJS:=${SRCS:.cc=.o}
- DEPENDS:=${SRCS:.cc=.d}
- 
- OPENRSDK_ROOT?=/usr/local/OPEN_R_SDK
- CXX=$(OPENRSDK_ROOT)/bin/mipsel-linux-g++
- LD=$(OPENRSDK_ROOT)/bin/mipsel-linux-ld
- FILTERSYSWARN=../tools/filtersyswarn/filtersyswarn
- LIBS=-lObjectComm -lOPENR -lInternet -lantMCOOP
- CURDIR:=$(shell pwd | sed 's/.*\///')
- CXXFLAGS= \
- 	-g -O2 \
- 	-Wall -W -Wshadow -Wlarger-than-8192 -Wpointer-arith -Wcast-qual \
- 	-Woverloaded-virtual -Weffc++ -Winline -Wdeprecated \
- 	-I. -I.. -I../MMCombo -isystem $(OPENRSDK_ROOT)/OPEN_R/include/MCOOP \
- 	-isystem $(OPENRSDK_ROOT)/OPEN_R/include/R4000 -isystem $(OPENRSDK_ROOT)/OPEN_R/include \
- 	-DPLATFORM_APERIOS -DDEBUG -DOPENR_DEBUG \
- 	-D$(TEKKOTSU_TARGET_MODEL) $(GLOBAL_MAP) \
- 
- .PHONY: all clean
- 
- all: $(CURDIR)Lib.o
- 
- $(CURDIR)Lib.o : $(OBJS)
- 	@echo Linking object files...
- 	@echo "$@ <- $(OBJS)"
- 	@$(LD) -i $(OBJS) -o $@
- 
- %.o: %.cc %.d $(FILTERSYSWARN)
- 	@echo Compiling $< into $@...
- 	@$(CXX) $(CXXFLAGS) -o $@ -c $< > $*.log 2>&1; \
- 	retval=$$?; \
- 	cat $*.log | $(FILTERSYSWARN); \
- 	test $$retval -eq 0;
- 
- %.d : %.cc
- 	@echo Building $@ for $<
- 	@$(CXX) $(CXXFLAGS) -MP -MG -MT $@ -MT $*.o -MM $< > $@
- 
- $(FILTERSYSWARN):
- 	(cd ../tools && $(MAKE));
- 
- ifneq ($(MAKECMDGOALS),clean)
- -include $(DEPENDS)
- endif
- 
- 
- clean:
- 	rm -f $(CURDIR)Lib.o $(OBJS) $(DEPENDS) ${SRCS:.cc=.log} *~ 
--- 0 ----
Index: AiboPup/Behaviors/StateNode.cc
diff -c AiboPup/Behaviors/StateNode.cc:1.2 AiboPup/Behaviors/StateNode.cc:1.10
*** AiboPup/Behaviors/StateNode.cc:1.2	Thu Jun  5 13:03:09 2003
--- AiboPup/Behaviors/StateNode.cc	Fri Oct 10 12:00:54 2003
***************
*** 1,46 ****
  #include "StateNode.h"
  #include "Events/EventRouter.h"
  
  StateNode::~StateNode() {
! 	if(isActive())
! 		DoStop();
  	for(std::vector<Transition*>::iterator it=transitions.begin(); it!=transitions.end(); it++)
- 		delete *it;
- 	for(std::vector<StateNode*>::iterator it=nodes.begin(); it!=nodes.end(); it++)
  		(*it)->RemoveReference();
  }
  
  void StateNode::addTransition(Transition* trans) {
  	transitions.push_back(trans);
! 	if(isActive())
! 		trans->enable();
  }
  
  void StateNode::DoStart() {
  	BehaviorBase::DoStart();
  	if(!issetup) {
  		setup();
  		issetup=true;
  	}
  	for(std::vector<Transition*>::iterator it=transitions.begin(); it!=transitions.end(); it++)
! 		(*it)->enable();
  	erouter->postEvent(EventBase::stateMachineEGID,reinterpret_cast<unsigned int>(this),EventBase::activateETID,0,getName(),1);
  	if(parent!=NULL)
  		parent->transitionTo(this);
  }
  
  void StateNode::DoStop() {
! 	for(std::vector<Transition*>::iterator it=transitions.begin(); it!=transitions.end(); it++)
! 		(*it)->disable();
  	for(std::vector<StateNode*>::iterator it=nodes.begin(); it!=nodes.end(); it++)
! 		(*it)->DoStop();
  	if(!retain) {
  		for(std::vector<StateNode*>::iterator it=nodes.begin(); it!=nodes.end(); it++)
  			(*it)->RemoveReference();
  		issetup=false;
  	}
  	erouter->postEvent(EventBase::stateMachineEGID,reinterpret_cast<unsigned int>(this),EventBase::deactivateETID,0,getName(),0);
  	BehaviorBase::DoStop();
  }
  
  void StateNode::setName(const std::string& n) {
--- 1,73 ----
  #include "StateNode.h"
  #include "Events/EventRouter.h"
+ #include "Wireless/Wireless.h"
  
  StateNode::~StateNode() {
! 	//std::cout << getName() << " DESTRUCTOR!!!!!!!" << this << std::endl;
! 	ASSERT(!isActive(), "Destructing while active?")
  	for(std::vector<Transition*>::iterator it=transitions.begin(); it!=transitions.end(); it++)
  		(*it)->RemoveReference();
+ 	if(issetup) {
+ 		for(std::vector<StateNode*>::iterator it=nodes.begin(); it!=nodes.end(); it++)
+ 			(*it)->RemoveReference();
+ 	}
  }
  
  void StateNode::addTransition(Transition* trans) {
  	transitions.push_back(trans);
! 	trans->AddReference();
  }
  
  void StateNode::DoStart() {
  	BehaviorBase::DoStart();
  	if(!issetup) {
+ 		//std::cout << getName() << " setting up... " << this << std::endl;
  		setup();
  		issetup=true;
  	}
  	for(std::vector<Transition*>::iterator it=transitions.begin(); it!=transitions.end(); it++)
! 		(*it)->DoStart();
  	erouter->postEvent(EventBase::stateMachineEGID,reinterpret_cast<unsigned int>(this),EventBase::activateETID,0,getName(),1);
  	if(parent!=NULL)
  		parent->transitionTo(this);
  }
  
  void StateNode::DoStop() {
! 	//	for(int i=0; i<500; i++)
! 	//cout << "BLAH " << getName() << " 0" << endl;
! 	//serr->printf("BLAH %s %d\n",getName().c_str(),0);
! 	for(std::vector<Transition*>::iterator it=transitions.begin(); it!=transitions.end(); it++) {
! 		ASSERT((*it)->isActive(),"Inactive transition");
! 		if((*it)->isActive())
! 			(*it)->DoStop();
! 	}
! 	//	for(int i=0; i<500; i++)
! 	//cout << "BLAH " << getName() << " 1" << endl;
! 	//serr->printf("BLAH %s %d\n",getName().c_str(),1);
  	for(std::vector<StateNode*>::iterator it=nodes.begin(); it!=nodes.end(); it++)
! 		if((*it)->isActive())
! 			(*it)->DoStop();
! 	//for(int i=0; i<1000; i++)
! 	//cout << "BLAH 2" << endl;
! 	//serr->printf("BLAH %s %d\n",getName().c_str(),2);
  	if(!retain) {
+ 		std::cout << getName() << " unretaining... " << this << std::endl;
  		for(std::vector<StateNode*>::iterator it=nodes.begin(); it!=nodes.end(); it++)
  			(*it)->RemoveReference();
+ 		teardown();
  		issetup=false;
  	}
+ 	///for(int i=0; i<1000; i++)
+ 	//cout << "BLAH 3" << endl;
+ 	//serr->printf("BLAH %s %d\n",getName().c_str(),3);
  	erouter->postEvent(EventBase::stateMachineEGID,reinterpret_cast<unsigned int>(this),EventBase::deactivateETID,0,getName(),0);
+ 	//for(int i=0; i<1000; i++)
+ 	//cout << "BLAH 4" << endl;
+ 	//serr->printf("BLAH %s %d\n",getName().c_str(),4);
  	BehaviorBase::DoStop();
+ 	//for(int i=0; i<1000; i++)
+ 	//cout << "BLAH 5" << endl;
+ 	//serr->printf("BLAH %s %d\n",getName().c_str(),5);
  }
  
  void StateNode::setName(const std::string& n) {
***************
*** 60,68 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 87,95 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Behaviors/StateNode.h
diff -c AiboPup/Behaviors/StateNode.h:1.2 AiboPup/Behaviors/StateNode.h:1.7
*** AiboPup/Behaviors/StateNode.h:1.2	Thu Jun  5 13:03:09 2003
--- AiboPup/Behaviors/StateNode.h	Thu Sep 25 11:23:56 2003
***************
*** 12,25 ****
  class StateNode  : public BehaviorBase {
  public:
  	//!constructor
! 	StateNode() : BehaviorBase(), parent(NULL), transitions(), issetup(false), retain(true), nodes(), name("?") {}
  
  	//!constructor, pass a name to use, calls setName(n) 
! 	StateNode(const char* n, StateNode* p=NULL) : BehaviorBase(), parent(p), transitions(), issetup(false), retain(true), nodes(), name(NULL) {
  		setName(n);
  	}
  
! 	//!destructor, frees memory used by its outgoing transitions (be careful of incoming ones - they're still around!), and calls RemoveReference() on subnodes
  	virtual ~StateNode();
  
  	//!Adds the specified StateTransition to the transition table
--- 12,25 ----
  class StateNode  : public BehaviorBase {
  public:
  	//!constructor
! 	StateNode() : BehaviorBase(), parent(NULL), transitions(), issetup(false), retain(true), nodes(), name("?") {	std::cout << "!" << std::endl;}
  
  	//!constructor, pass a name to use, calls setName(n) 
! 	StateNode(const char* n, StateNode* p=NULL) : BehaviorBase(), parent(p), transitions(), issetup(false), retain(true), nodes(), name("") {
  		setName(n);
  	}
  
! 	//!destructor, removes references to its outgoing transitions (be careful of incoming ones - they're still around!), and calls RemoveReference() on subnodes
  	virtual ~StateNode();
  
  	//!Adds the specified StateTransition to the transition table
***************
*** 28,34 ****
  	//!Returns the std::vector of transitions so you can modify them yourself if need be
  	std::vector<Transition*>& getTransitions() { return transitions; }
  
! 	//!Adds a StateNode to #nodes so it can be automatically deleted later, returns what it's passed (for convenience), calls AddReference() on @a node
  	virtual StateNode* addNode(StateNode* node) { nodes.push_back(node); node->AddReference(); return node; }
  
  	//!Returns the std::vector of nodes so you can modify them yourself if need be
--- 28,34 ----
  	//!Returns the std::vector of transitions so you can modify them yourself if need be
  	std::vector<Transition*>& getTransitions() { return transitions; }
  
! 	//!Adds a StateNode to #nodes so it can be automatically dereferenced later, returns what it's passed (for convenience), calls AddReference() on @a node
  	virtual StateNode* addNode(StateNode* node) { nodes.push_back(node); node->AddReference(); return node; }
  
  	//!Returns the std::vector of nodes so you can modify them yourself if need be
***************
*** 38,51 ****
  	void setRetain(bool f) { retain=f; }
  
  	//!Transitions should call this when you are entering the state, so it can enable its transitions
! 	void DoStart();
  
! 	//!This is called by DoStart() when you should setup the network
  	virtual void setup() {issetup=true;}
  
  	//!Transitions should call this when you are leaving the state, so it can disable its transitions
! 	void DoStop();
  	
  	//!set name to @a n.  Makes a copy of @a n, so you can throw it away later.
  	void setName(const std::string& n);
  
--- 38,54 ----
  	void setRetain(bool f) { retain=f; }
  
  	//!Transitions should call this when you are entering the state, so it can enable its transitions
! 	virtual void DoStart();
  
! 	//!This is called by DoStart() when you should setup the network of subnodes
  	virtual void setup() {issetup=true;}
  
  	//!Transitions should call this when you are leaving the state, so it can disable its transitions
! 	virtual void DoStop();
  	
+ 	//!This is called by DoStop() when you should destruct subnodes
+ 	virtual void teardown() { std::cout << "Teardown!!!!!!!!" << std::endl;issetup=false;}
+ 
  	//!set name to @a n.  Makes a copy of @a n, so you can throw it away later.
  	void setName(const std::string& n);
  
***************
*** 55,70 ****
  	//!returns name again (you should override this for top-level nodes to give users better descriptions)
  	virtual std::string getDescription() const { return name; }
  
! 	//!Doesn't do anything, supplied here so you don't have to (since events will probably be going to Transition's, not here)
! 	virtual void processEvent(const EventBase&) {}
! 
  	//!called by a subnode when it is being DoStart()'ed
! 	void transitionTo(StateNode* n);
  
  	//!called by a subnode when it is being DoStop()'ed
! 	void transitionFrom(StateNode* n);
  
- protected:
  	//Node Stuff:
  	//! pointer to the machine that contains this node
  	StateNode* parent;
--- 58,70 ----
  	//!returns name again (you should override this for top-level nodes to give users better descriptions)
  	virtual std::string getDescription() const { return name; }
  
! protected:
  	//!called by a subnode when it is being DoStart()'ed
! 	virtual void transitionTo(StateNode* n);
  
  	//!called by a subnode when it is being DoStop()'ed
! 	virtual void transitionFrom(StateNode* n);
  
  	//Node Stuff:
  	//! pointer to the machine that contains this node
  	StateNode* parent;
***************
*** 74,82 ****
  	//Machine Stuff:
  	//! this is set to true if the network has been setup but not destroyed (i.e. don't need to call setupSubNodes again)
  	bool issetup;
! 	//! this is set to true if the network should be retained between activations.  Otherwise it's deleted upon DoStop(). (or at least RemoveReference() is called on subnodes)
  	bool retain;
! 	//! vector of StateNodes, just so they can be deleted again on DoStop() (unless retained) or ~StateNode()
  	std::vector<StateNode*> nodes;
  
  	//Behavior Stuff:
--- 74,82 ----
  	//Machine Stuff:
  	//! this is set to true if the network has been setup but not destroyed (i.e. don't need to call setupSubNodes again)
  	bool issetup;
! 	//! this is set to true if the network should be retained between activations.  Otherwise it's dereferenced upon DoStop(). (or at least RemoveReference() is called on subnodes)
  	bool retain;
! 	//! vector of StateNodes, just so they can be dereferenced again on DoStop() (unless retained) or ~StateNode()
  	std::vector<StateNode*> nodes;
  
  	//Behavior Stuff:
***************
*** 93,102 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 93,102 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Transition.cc
diff -c AiboPup/Behaviors/Transition.cc:1.1 AiboPup/Behaviors/Transition.cc:1.3
*** AiboPup/Behaviors/Transition.cc:1.1	Sat Mar  1 15:53:26 2003
--- AiboPup/Behaviors/Transition.cc	Thu Sep 25 13:22:49 2003
***************
*** 1,9 ****
--- 1,14 ----
  #include "Transition.h"
  #include "StateNode.h"
+ #include "Wireless/Wireless.h"
  
  void Transition::activate() {
+ 	serr->printf("%s activate() - enter %d\n",getName().c_str(),get_time());
+ 	AddReference();
  	src->DoStop();
  	dst->DoStart();
+ 	serr->printf("%s activate() - leave %d\n",getName().c_str(),get_time());
+ 	RemoveReference();
  }
  
  /*! @file
***************
*** 11,19 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 16,24 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Behaviors/Transition.h
diff -c AiboPup/Behaviors/Transition.h:1.1 AiboPup/Behaviors/Transition.h:1.2
*** AiboPup/Behaviors/Transition.h:1.1	Sat Mar  1 15:53:26 2003
--- AiboPup/Behaviors/Transition.h	Thu Aug 21 18:32:41 2003
***************
*** 2,31 ****
  #ifndef INCLUDED_Transition_h_
  #define INCLUDED_Transition_h_
  
  class StateNode;
  
  //! Represents a transition between StateNodes.
  /*! This is an abstract class - you'll want to subclass it to put
!  *  conditions on the transitions */
! class Transition {
  public:
  	//!constructor, specifies source and destination StateNode's
! 	Transition(StateNode* source, StateNode* destination) : src(source), dst(destination) {}
  	//!copy constructor, just in case you need it
! 	Transition(const Transition& t) : src(t.src), dst(t.dst) {}
  	//!destructor
  	virtual ~Transition() {}
  
! 	//!called by StateNode when it becomes active - use this to request events (or whatever you need to do)
! 	virtual void enable()=0;
! 	//!called by StateNode when it becomes inactive - undo whatever you did in Enable()
! 	virtual void disable()=0;
! 
! 	//!call this when the transition should be made, base class version simply calls StateNode::Leave() on #src and StateNode::Enter() on #dst, but you can override.
  	virtual void activate();
  
  	//!assignment operator (only does shallow copy)
! 	Transition& operator=(const Transition& t) { src=t.src; dst=t.dst; return *this; }
  protected:
  	StateNode* src; //!< the node being transitioned from
  	StateNode* dst; //!< the node being transitioned to
--- 2,34 ----
  #ifndef INCLUDED_Transition_h_
  #define INCLUDED_Transition_h_
  
+ #include "BehaviorBase.h"
+ 
  class StateNode;
  
  //! Represents a transition between StateNodes.
  /*! This is an abstract class - you'll want to subclass it to put
!  *  conditions on the transitions
!  *
!  *  DoStart() will be called when this transition is 'active' - it should
!  *  listen/monitor for the transition it represents until DoStop() is called.
!  *  
!  *  If the conditions are satisified for a transition, you should call activate()
!  *  to do the appropriate notifications. */
! class Transition : public BehaviorBase {
  public:
  	//!constructor, specifies source and destination StateNode's
! 	Transition(StateNode* source, StateNode* destination) : BehaviorBase(), src(source), dst(destination) {}
  	//!copy constructor, just in case you need it
! 	Transition(const Transition& t) : BehaviorBase(t), src(t.src), dst(t.dst) {}
  	//!destructor
  	virtual ~Transition() {}
  
! 	//!call this when the transition should be made, base class version simply calls StateNode::DoStop() on #src and StateNode::DoStart() on #dst, but you can override.
  	virtual void activate();
  
  	//!assignment operator (only does shallow copy)
! 	Transition& operator=(const Transition& t) { BehaviorBase::operator=(t); src=t.src; dst=t.dst; return *this; }
  protected:
  	StateNode* src; //!< the node being transitioned from
  	StateNode* dst; //!< the node being transitioned to
***************
*** 36,45 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 39,48 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/BatteryCheckControl.h
diff -c AiboPup/Behaviors/Controls/BatteryCheckControl.h:1.4 AiboPup/Behaviors/Controls/BatteryCheckControl.h:1.7
*** AiboPup/Behaviors/Controls/BatteryCheckControl.h:1.4	Mon Jun  9 04:05:12 2003
--- AiboPup/Behaviors/Controls/BatteryCheckControl.h	Fri Jul 25 21:48:03 2003
***************
*** 7,12 ****
--- 7,13 ----
  #include "Motion/MMAccessor.h"
  #include "Motion/LedMC.h"
  #include "NullControl.h"
+ #include "Events/EventRouter.h"
  
  //! when activated, this will print a battery report to stdout and light up LEDs to specify power level
  /*! The LEDs use the LedEngine::displayPercent() function, with minor/major style.  This means
***************
*** 33,39 ****
  	//!Prints a report to stdio and lights up the face to show battery level
  	/*! keeps running until deactivated - will listen for power events and continue to update display */
  	virtual ControlBase * activate(MotionManager::MC_ID display, Socket * gui) {
! 		cout << "Press the \"back\" button to leave battery display" << endl;
  		erouter->addListener(this,EventBase::powerEGID);
  		return ControlBase::activate(display,gui);
  	}
--- 34,40 ----
  	//!Prints a report to stdio and lights up the face to show battery level
  	/*! keeps running until deactivated - will listen for power events and continue to update display */
  	virtual ControlBase * activate(MotionManager::MC_ID display, Socket * gui) {
! 		sout->printf("Press the \"back\" button to leave battery display\n");
  		erouter->addListener(this,EventBase::powerEGID);
  		return ControlBase::activate(display,gui);
  	}
***************
*** 72,101 ****
  	virtual ControlBase * doSelect() {
  		return this;
  	}
! 	//! redisplay text to cout and refresh LED values
  	void report() {
! 		cout << "BATTERY REPORT:" << endl;
! 		cout << "\tPower Remain:\t" << (int)(state->sensors[PowerRemainOffset]*100) << "%" << endl;
! 		cout << "\tCapacity:\t" << state->sensors[PowerCapacityOffset] << endl;
! 		cout << "\tVoltage:\t" << state->sensors[PowerVoltageOffset] << endl;
! 		cout << "\tCurrent:\t" << state->sensors[PowerCurrentOffset] << endl;
! 		cout << "\tTemp:\t" << state->sensors[PowerThermoOffset] << endl;
! 		cout << "\tFlags:\t";
  		if(state->powerFlags[PowerSourceID::BatteryConnectSID])
! 			cout << "BatteryConnect ";
  		if(state->powerFlags[PowerSourceID::DischargingSID])
! 			cout << "Discharging ";
  		if(state->powerFlags[PowerSourceID::ChargingSID])
! 			cout << "Charging ";
  		if(state->powerFlags[PowerSourceID::ExternalPowerSID])
! 			cout << "ExternalPower ";
  		if(state->powerFlags[PowerSourceID::PowerGoodSID])
! 			cout << "PowerGood ";
  		if(state->powerFlags[PowerSourceID::LowPowerWarnSID])
! 			cout << "LowPowerWarn ";
  		if(state->powerFlags[PowerSourceID::BatteryEmptySID])
! 			cout << "BatteryEmpty ";
! 		cout << endl;
  		if(display_id!=MotionManager::invalid_MC_ID) {
  			MMAccessor<LedMC> disp(display_id);
  			disp->displayPercent(state->sensors[PowerRemainOffset],LedEngine::major,LedEngine::major);
--- 73,102 ----
  	virtual ControlBase * doSelect() {
  		return this;
  	}
! 	//! redisplay text to sout and refresh LED values
  	void report() {
! 		sout->printf("BATTERY REPORT:\n");
! 		sout->printf("\tPower Remain:\t%d%%\n",(int)(state->sensors[PowerRemainOffset]*100));
! 		sout->printf("\tCapacity:\t%d\n",state->sensors[PowerCapacityOffset]);
! 		sout->printf("\tVoltage:\t%g\n",state->sensors[PowerVoltageOffset]);
! 		sout->printf("\tCurrent:\t%d\n",state->sensors[PowerCurrentOffset]);
! 		sout->printf("\tTemperature:\t%g\n",state->sensors[PowerThermoOffset]);
! 		sout->printf("\tFlags:\t");
  		if(state->powerFlags[PowerSourceID::BatteryConnectSID])
! 			sout->printf("BatteryConnect ");
  		if(state->powerFlags[PowerSourceID::DischargingSID])
! 			sout->printf("Discharging ");
  		if(state->powerFlags[PowerSourceID::ChargingSID])
! 			sout->printf("Charging ");
  		if(state->powerFlags[PowerSourceID::ExternalPowerSID])
! 			sout->printf("ExternalPower ");
  		if(state->powerFlags[PowerSourceID::PowerGoodSID])
! 			sout->printf("PowerGood ");
  		if(state->powerFlags[PowerSourceID::LowPowerWarnSID])
! 			sout->printf("LowPowerWarn ");
  		if(state->powerFlags[PowerSourceID::BatteryEmptySID])
! 			sout->printf("BatteryEmpty ");
! 		sout->printf("\n");
  		if(display_id!=MotionManager::invalid_MC_ID) {
  			MMAccessor<LedMC> disp(display_id);
  			disp->displayPercent(state->sensors[PowerRemainOffset],LedEngine::major,LedEngine::major);
***************
*** 109,118 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 110,119 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/BehaviorActivatorControl.h
diff -c AiboPup/Behaviors/Controls/BehaviorActivatorControl.h:1.7 AiboPup/Behaviors/Controls/BehaviorActivatorControl.h:1.8
*** AiboPup/Behaviors/Controls/BehaviorActivatorControl.h:1.7	Thu Jun 12 14:06:10 2003
--- AiboPup/Behaviors/Controls/BehaviorActivatorControl.h	Thu Sep 25 11:26:10 2003
***************
*** 62,71 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 62,71 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/BehaviorSwitchActivatorControl.h
diff -c AiboPup/Behaviors/Controls/BehaviorSwitchActivatorControl.h:1.2 AiboPup/Behaviors/Controls/BehaviorSwitchActivatorControl.h:1.3
*** AiboPup/Behaviors/Controls/BehaviorSwitchActivatorControl.h:1.2	Thu Jun 12 14:06:10 2003
--- AiboPup/Behaviors/Controls/BehaviorSwitchActivatorControl.h	Thu Sep 25 11:26:10 2003
***************
*** 54,63 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 54,63 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/BehaviorSwitchControl.h
diff -c AiboPup/Behaviors/Controls/BehaviorSwitchControl.h:1.7 AiboPup/Behaviors/Controls/BehaviorSwitchControl.h:1.9
*** AiboPup/Behaviors/Controls/BehaviorSwitchControl.h:1.7	Mon Jun  9 20:53:47 2003
--- AiboPup/Behaviors/Controls/BehaviorSwitchControl.h	Thu Sep 25 23:08:54 2003
***************
*** 149,155 ****
--- 149,160 ----
  			if(behgrp!=NULL)
  				behgrp->curBehavior=mybeh;
  		}
+ 		mybeh->AddReference(); //temporary in case mybeh stops itself right away
  		mybeh->DoStart();
+ 		bool stopped=(!mybeh->isActive() && !retained);
+ 		mybeh->RemoveReference();
+ 		if(stopped)
+ 			mybeh=NULL;
  	}
  
  	//! Returns true if the associated behavior is running
***************
*** 182,191 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 187,196 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/ControlBase.cc
diff -c AiboPup/Behaviors/Controls/ControlBase.cc:1.6 AiboPup/Behaviors/Controls/ControlBase.cc:1.8
*** AiboPup/Behaviors/Controls/ControlBase.cc:1.6	Thu Jun 12 14:06:10 2003
--- AiboPup/Behaviors/Controls/ControlBase.cc	Wed Aug  6 18:50:41 2003
***************
*** 1,6 ****
--- 1,7 ----
  #include "ControlBase.h"
  #include "Motion/MMAccessor.h"
  #include "Motion/LedMC.h"
+ #include "Shared/string_util.h"
  #include "Wireless/Wireless.h"
  #include <iomanip>
  #include <sstream>
***************
*** 22,33 ****
  void ControlBase::refresh() {
  	//Level 1: LEDs
  	if(display_id!=MotionManager::invalid_MC_ID) {
! 		MMAccessor<LedMC> display(display_id);
! 		unsigned int cur=hilights.front();
! 		if(options.size()<=10)
! 			display.mc()->displayNumber(cur,LedEngine::onedigit);
! 		else
! 			display.mc()->displayNumber(cur,LedEngine::twodigit);
  	}
  
  	//Just do one of the other two levels to avoid over-redundancy
--- 23,36 ----
  void ControlBase::refresh() {
  	//Level 1: LEDs
  	if(display_id!=MotionManager::invalid_MC_ID) {
! 		if(hilights.size()>0) {
! 			MMAccessor<LedMC> display(display_id);
! 			unsigned int cur=hilights.front();
! 			if(options.size()<=10)
! 				display.mc()->displayNumber(cur,LedEngine::onedigit);
! 			else
! 				display.mc()->displayNumber(cur,LedEngine::twodigit);
! 		}
  	}
  
  	//Just do one of the other two levels to avoid over-redundancy
***************
*** 59,86 ****
  		doRewrite=true;
  	} else {
  		//Level 3: GUI
! 		if(gui_comm!=NULL && wireless->isConnected(gui_comm->sock)) {
! 			//		cout << "REFRESHING " << getName() << endl;
! 			//try to get it all in one packet for better performance
! 			std::stringstream ss;
! 			ss << "refresh\n"
! 				 << getName() << '\n'
! 				 << options.size() << '\n';
! 			for(unsigned int i=0; i<options.size(); i++)
! 				if(options[i]==NULL)
! 					ss << "0\n0\n----------\n\n";
! 				else 
! 					ss << options[i]->options.size() << '\n'
! 						 << (binary_search(hilights.begin(),hilights.end(),i)?1:0) << '\n'
! 						 << options[i]->getName() << '\n'
! 						 << options[i]->getDescription().c_str() << '\n';
! 			//		do {
! 			//cout << "Writing " << ss.str().size() << "...";
! 			gui_comm->write((const byte*)ss.str().c_str(),ss.str().size());
! 			//		int cnt=gui_comm->printf("%s",(const byte*)ss.str().c_str());
! 			//cout << "wrote " << cnt << endl;
! 			//} while(cnt==-1);
! 		}
  	}
  }
  
--- 62,88 ----
  		doRewrite=true;
  	} else {
  		//Level 3: GUI
! 
! 		//		cout << "REFRESHING " << getName() << endl;
! 		//try to get it all in one packet for better performance
! 		std::stringstream ss;
! 		ss << "refresh\n"
! 			 << getName() << '\n'
! 			 << options.size() << '\n';
! 		for(unsigned int i=0; i<options.size(); i++)
! 			if(options[i]==NULL)
! 				ss << "0\n0\n----------\n\n";
! 			else 
! 				ss << options[i]->options.size() << '\n'
! 					 << (binary_search(hilights.begin(),hilights.end(),i)?1:0) << '\n'
! 					 << options[i]->getName() << '\n'
! 					 << options[i]->getDescription().c_str() << '\n';
! 		//		do {
! 		//cout << "Writing " << ss.str().size() << "...";
! 		gui_comm->write((const byte*)ss.str().c_str(),ss.str().size());
! 		//		int cnt=gui_comm->printf("%s",(const byte*)ss.str().c_str());
! 		//cout << "wrote " << cnt << endl;
! 		//} while(cnt==-1);
  	}
  }
  
***************
*** 211,217 ****
  }
  
  ControlBase* ControlBase::takeInput(const std::string& str) {
! 	std::string msg;
  	{unsigned int i=0; while(i<str.size() && isspace(str[i])) i++; msg=str.substr(i);}
  	if(isdigit(msg[0])) {
  		char* endp=NULL;
--- 213,298 ----
  }
  
  ControlBase* ControlBase::takeInput(const std::string& str) {
! 	std::vector<std::string> args;
! 	std::vector<unsigned int> offsets;
! 	if(!string_util::parseArgs(str,args,offsets)) {
! 		serr->printf("ControlBase::takeInput(\"%s\") was not understood.\n",str.c_str());
! 		refresh();
! 		return this;
! 	} else {
! 		//are there valid arguments?
! 		if(args.size()==0) {
! 			refresh();
! 			return this;
! 		}
! 		//let's see if the first arg matches an option name (case sensitive)
! 		unsigned int choice=-1U;
! 		bool ambiguous=false;
! 		for(unsigned int i=0; i<options.size(); i++) {
! 			if(options[i]!=NULL && options[i]->name.compare(0,args[0].size(),args[0])==0) {
! 				if(choice==-1U)
! 					choice=i;
! 				else
! 					ambiguous=true;
! 			}
! 		}
! 		//let's see if the first arg matches an option name (case insensitive)
! 		if(!ambiguous && choice==-1U) {
! 			std::string argname=string_util::makeLower(args[0]);
! 			for(unsigned int i=0; i<options.size(); i++) {
! 				if(options[i]!=NULL) {
! 					std::string optname=string_util::makeLower(options[i]->name);
! 					if(optname.compare(0,argname.size(),argname)==0) {
! 						if(choice==-1U)
! 							choice=i;
! 						else
! 							ambiguous=true;
! 					}
! 				}
! 			}
! 		}
! 		//if we didn't find one already, try treating the arg as an index number
! 		if(ambiguous || choice==-1U) {
! 			char* endp=NULL;
! 			choice=strtol(args[0].c_str(),&endp,10);
! 			if(endp==NULL || endp==args[0].c_str()) {
! 				if(config->main.use_VT100) {
! 					sout->printf("\r\33[1A");
! 					clearMenu();
! 					doRewrite=false;
! 				}
! 				if(ambiguous)
! 					serr->printf("ControlBase(\"%s\")::takeInput(\"%s\") was ambiguous\n",name.c_str(),args[0].c_str());
! 				else
! 					serr->printf("ControlBase(\"%s\")::takeInput(\"%s\") was not a valid index or option name.\n",name.c_str(),args[0].c_str());
! 				refresh();
! 				return this;
! 			} else if(choice<options.size() && options[choice]!=NULL) {
! 				ambiguous=false;
! 			} else {
! 				if(config->main.use_VT100) {
! 					sout->printf("\r\33[1A");
! 					clearMenu();
! 					doRewrite=false;
! 				}
! 				if(ambiguous)
! 					serr->printf("ControlBase(\"%s\")::takeInput(\"%s\") was ambiguous\n",name.c_str(),args[0].c_str());
! 				else
! 					serr->printf("ControlBase(\"%s\")::takeInput(\"%d\") is not a valid selection\n",name.c_str(),choice);
! 				refresh();
! 				return this;
! 			}	
! 		}
! 		//see what we got...
! 		if(args.size()>1)
! 			return options[choice]->takeInput(str.substr(offsets[1]));
! 		else {
! 			hilights.clear();
! 			hilights.push_back(choice);
! 			return doSelect();
! 		}
! 	}
! 	/*	std::string msg;
  	{unsigned int i=0; while(i<str.size() && isspace(str[i])) i++; msg=str.substr(i);}
  	if(isdigit(msg[0])) {
  		char* endp=NULL;
***************
*** 248,254 ****
  		serr->printf("ControlBase::takeInput(\"%s\") was not understood.\nPlease enter the number of the index - string entry is not supported yet\n",str.c_str());
  		refresh();
  		return this;		
! 	}
  }
  
  bool ControlBase::validInput(const std::string& str) {
--- 329,335 ----
  		serr->printf("ControlBase::takeInput(\"%s\") was not understood.\nPlease enter the number of the index - string entry is not supported yet\n",str.c_str());
  		refresh();
  		return this;		
! 		}*/
  }
  
  bool ControlBase::validInput(const std::string& str) {
***************
*** 329,337 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 410,418 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Behaviors/Controls/ControlBase.h
diff -c AiboPup/Behaviors/Controls/ControlBase.h:1.15 AiboPup/Behaviors/Controls/ControlBase.h:1.16
*** AiboPup/Behaviors/Controls/ControlBase.h:1.15	Thu Jun 12 19:41:35 2003
--- AiboPup/Behaviors/Controls/ControlBase.h	Wed Aug  6 18:50:41 2003
***************
*** 109,114 ****
--- 109,115 ----
  	virtual ControlBase& setDisplay(MotionManager::MC_ID d) { display_id=d; return *this; } //!< sets display to use
  
  protected:
+ 		
  	//! clears the display (if use_VT100 is on)
  	virtual void clearMenu();
  
***************
*** 136,144 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  #endif
--- 137,145 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  #endif
Index: AiboPup/Behaviors/Controls/DumpFileControl.h
diff -c AiboPup/Behaviors/Controls/DumpFileControl.h:1.1 AiboPup/Behaviors/Controls/DumpFileControl.h:1.2
*** AiboPup/Behaviors/Controls/DumpFileControl.h:1.1	Tue Jun 10 21:22:47 2003
--- AiboPup/Behaviors/Controls/DumpFileControl.h	Thu Sep 25 11:26:10 2003
***************
*** 40,49 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 40,49 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/EventLogger.cc
diff -c AiboPup/Behaviors/Controls/EventLogger.cc:1.7 AiboPup/Behaviors/Controls/EventLogger.cc:1.8
*** AiboPup/Behaviors/Controls/EventLogger.cc:1.7	Mon Jun  9 20:53:48 2003
--- AiboPup/Behaviors/Controls/EventLogger.cc	Thu Sep 25 11:26:10 2003
***************
*** 118,125 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
--- 118,125 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
Index: AiboPup/Behaviors/Controls/EventLogger.h
diff -c AiboPup/Behaviors/Controls/EventLogger.h:1.4 AiboPup/Behaviors/Controls/EventLogger.h:1.5
*** AiboPup/Behaviors/Controls/EventLogger.h:1.4	Mon Jun  9 04:05:12 2003
--- AiboPup/Behaviors/Controls/EventLogger.h	Thu Sep 25 11:26:10 2003
***************
*** 42,51 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 42,51 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/FileBrowserControl.cc
diff -c AiboPup/Behaviors/Controls/FileBrowserControl.cc:1.7 AiboPup/Behaviors/Controls/FileBrowserControl.cc:1.8
*** AiboPup/Behaviors/Controls/FileBrowserControl.cc:1.7	Thu Jun 12 19:41:36 2003
--- AiboPup/Behaviors/Controls/FileBrowserControl.cc	Thu Sep 25 11:26:10 2003
***************
*** 152,160 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 152,160 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Behaviors/Controls/FileBrowserControl.h
diff -c AiboPup/Behaviors/Controls/FileBrowserControl.h:1.7 AiboPup/Behaviors/Controls/FileBrowserControl.h:1.8
*** AiboPup/Behaviors/Controls/FileBrowserControl.h:1.7	Mon Jun  9 20:53:48 2003
--- AiboPup/Behaviors/Controls/FileBrowserControl.h	Thu Sep 25 11:26:10 2003
***************
*** 71,80 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 71,80 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/FreeMemReportControl.cc
diff -c AiboPup/Behaviors/Controls/FreeMemReportControl.cc:1.2 AiboPup/Behaviors/Controls/FreeMemReportControl.cc:1.4
*** AiboPup/Behaviors/Controls/FreeMemReportControl.cc:1.2	Thu Jun 12 19:41:36 2003
--- AiboPup/Behaviors/Controls/FreeMemReportControl.cc	Thu Sep 25 11:26:11 2003
***************
*** 23,28 ****
--- 23,37 ----
  		ASSERT(false,"Unexpected timer event");
  }
  	
+ void FreeMemReportControl::refresh() {
+ 	char tmp[256];
+ 	sprintf(tmp,"Free Mem: %d",freeMem());
+ 	options[1]->setName(tmp);
+ 	ControlBase::refresh();
+ 	report();
+ }
+ 
+ 
  //! reports size of free memory - if this is below low_mem, also generates a warning
  void FreeMemReportControl::report() {
  	size_t freemem=freeMem();
***************
*** 42,51 ****
  }
  
  void FreeMemReportControl::resetTimerFreq() {
! 	if(report_freq==-1U)
  		erouter->removeTimer(this,0);
  	else
! 		erouter->addTimer(this,0,report_freq*1000,true);
  	erouter->addTimer(this,1,monitor_freq,true);
  }
  
--- 51,60 ----
  }
  
  void FreeMemReportControl::resetTimerFreq() {
! 	if(report_freq<0)
  		erouter->removeTimer(this,0);
  	else
! 		erouter->addTimer(this,0,report_freq,true);
  	erouter->addTimer(this,1,monitor_freq,true);
  }
  
***************
*** 54,62 ****
   * @author ejt (object), alokl (core function)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 63,71 ----
   * @author ejt (object), alokl (core function)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Behaviors/Controls/FreeMemReportControl.h
diff -c AiboPup/Behaviors/Controls/FreeMemReportControl.h:1.3 AiboPup/Behaviors/Controls/FreeMemReportControl.h:1.6
*** AiboPup/Behaviors/Controls/FreeMemReportControl.h:1.3	Thu Jun 12 19:41:36 2003
--- AiboPup/Behaviors/Controls/FreeMemReportControl.h	Thu Sep 25 23:28:38 2003
***************
*** 16,22 ****
  	FreeMemReportControl() : BehaviorBase(), ControlBase("Free Memory Report","Reports size of free memory, and monitors for low memory warning"), report_freq(-1U), low_mem(256), monitor_freq(1000), isWarning(false) {init();}
  	FreeMemReportControl(const std::string& n) : BehaviorBase(), ControlBase(n,"Reports size of free memory, and monitors for low memory warning"), report_freq(-1U), low_mem(256), monitor_freq(1000),isWarning(false) {init();}
  	FreeMemReportControl(const std::string& n, const std::string& d) : BehaviorBase(), ControlBase(n,d), report_freq(-1U), low_mem(256), monitor_freq(1000),isWarning(false) {init();}
! 	virtual ~FreeMemReportControl() { SetAutoDelete(false); clearSlots(); } //!< destructor
  	//@}
  
  	virtual void DoStart() {
--- 16,22 ----
  	FreeMemReportControl() : BehaviorBase(), ControlBase("Free Memory Report","Reports size of free memory, and monitors for low memory warning"), report_freq(-1U), low_mem(256), monitor_freq(1000), isWarning(false) {init();}
  	FreeMemReportControl(const std::string& n) : BehaviorBase(), ControlBase(n,"Reports size of free memory, and monitors for low memory warning"), report_freq(-1U), low_mem(256), monitor_freq(1000),isWarning(false) {init();}
  	FreeMemReportControl(const std::string& n, const std::string& d) : BehaviorBase(), ControlBase(n,d), report_freq(-1U), low_mem(256), monitor_freq(1000),isWarning(false) {init();}
! 	virtual ~FreeMemReportControl() { SetAutoDelete(false); DoStop(); clearSlots(); } //!< destructor
  	//@}
  
  	virtual void DoStart() {
***************
*** 34,41 ****
  
  	virtual std::string getName() const { return (isActive()?"#":"-")+ControlBase::getName(); }
  
! 	virtual void refresh() { ControlBase::refresh(); report(); }
! 
  	//! reports size of free memory - if this is below low_mem, also generates a warning
  	void report();
  
--- 34,41 ----
  
  	virtual std::string getName() const { return (isActive()?"#":"-")+ControlBase::getName(); }
  
! 	virtual void refresh();
! 	
  	//! reports size of free memory - if this is below low_mem, also generates a warning
  	void report();
  
***************
*** 49,60 ****
  	//! builds the submenus
  	void init() {
  		pushSlot(new BehaviorActivatorControl(this));
! 		pushSlot(new ValueEditControl<unsigned int>("Report Frequency","Controls how often to generate free memory reports (in seconds)","Please enter seconds to wait between reports (-1 to stop)",&report_freq));
  		pushSlot(new ValueEditControl<unsigned int>("Low Memory Threshold","Controls when to start warning about low memory (in KB)","Please enter the new low memory warning threshold (in KB)",&low_mem));
  		pushSlot(new ValueEditControl<unsigned int>("Monitor Frequency","Controls how often to check for low memory (in milliseconds)","Please enter milliseconds to wait between low memory checks (-1 to stop)",&monitor_freq));
  	}
  
! 	unsigned int report_freq;  //!< how often to report memory size (in seconds - -1U turns off, 0 is as often as possible)
  	unsigned int low_mem;      //!< threshold to trigger low memory warning (in kilobytes)
  	unsigned int monitor_freq; //!< how often to check for low memory (in milliseconds - -1U turns off, 0 is as often as possible)
  	bool isWarning;            //!< true we already know we're below threshold
--- 49,61 ----
  	//! builds the submenus
  	void init() {
  		pushSlot(new BehaviorActivatorControl(this));
! 		pushSlot(new NullControl("Free Mem: unknown"));
! 		pushSlot(new ValueEditControl<int>("Report Frequency","Controls how often to generate free memory reports (in milliseconds)","Please enter milliseconds to wait between reports (-1 to stop)",&report_freq));
  		pushSlot(new ValueEditControl<unsigned int>("Low Memory Threshold","Controls when to start warning about low memory (in KB)","Please enter the new low memory warning threshold (in KB)",&low_mem));
  		pushSlot(new ValueEditControl<unsigned int>("Monitor Frequency","Controls how often to check for low memory (in milliseconds)","Please enter milliseconds to wait between low memory checks (-1 to stop)",&monitor_freq));
  	}
  
! 	int report_freq;  //!< how often to report memory size (in milliseconds - negative turns off, 0 is as often as possible)
  	unsigned int low_mem;      //!< threshold to trigger low memory warning (in kilobytes)
  	unsigned int monitor_freq; //!< how often to check for low memory (in milliseconds - -1U turns off, 0 is as often as possible)
  	bool isWarning;            //!< true we already know we're below threshold
***************
*** 65,74 ****
   * @author ejt (object), alokl (core function)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 66,75 ----
   * @author ejt (object), alokl (core function)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/HelpControl.cc
diff -c AiboPup/Behaviors/Controls/HelpControl.cc:1.3 AiboPup/Behaviors/Controls/HelpControl.cc:1.4
*** AiboPup/Behaviors/Controls/HelpControl.cc:1.3	Tue Jul  8 20:10:57 2003
--- AiboPup/Behaviors/Controls/HelpControl.cc	Thu Sep 25 11:26:11 2003
***************
*** 79,87 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 79,87 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Behaviors/Controls/HelpControl.h
diff -c AiboPup/Behaviors/Controls/HelpControl.h:1.3 AiboPup/Behaviors/Controls/HelpControl.h:1.4
*** AiboPup/Behaviors/Controls/HelpControl.h:1.3	Thu Jun 12 19:41:36 2003
--- AiboPup/Behaviors/Controls/HelpControl.h	Thu Sep 25 11:26:11 2003
***************
*** 34,43 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 34,43 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/LoadPostureControl.h
diff -c AiboPup/Behaviors/Controls/LoadPostureControl.h:1.9 AiboPup/Behaviors/Controls/LoadPostureControl.h:1.10
*** AiboPup/Behaviors/Controls/LoadPostureControl.h:1.9	Mon Jun  9 20:53:48 2003
--- AiboPup/Behaviors/Controls/LoadPostureControl.h	Fri Jul 25 21:48:03 2003
***************
*** 6,11 ****
--- 6,12 ----
  #include "Motion/PostureMC.h"
  #include "Motion/MMAccessor.h"
  #include "Motion/EmergencyStopMC.h"
+ #include "Events/EventRouter.h"
  #include <string>
  
  //! Upon activation, loads a position from a file name read from cin (stored in ms/data/motion...)
***************
*** 59,68 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 60,69 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/LoadWalkControl.h
diff -c AiboPup/Behaviors/Controls/LoadWalkControl.h:1.4 AiboPup/Behaviors/Controls/LoadWalkControl.h:1.7
*** AiboPup/Behaviors/Controls/LoadWalkControl.h:1.4	Mon Jun  9 20:53:48 2003
--- AiboPup/Behaviors/Controls/LoadWalkControl.h	Tue Sep  2 16:58:48 2003
***************
*** 1,3 ****
--- 1,4 ----
+ //-*-c++-*-
  #ifndef INCLUDED_LoadWalkControl_h
  #define INCLUDED_LoadWalkControl_h
  
***************
*** 11,33 ****
  public:
  	//! constructor, pass the MC_ID of the WalkMC which you want to save
  	LoadWalkControl(const std::string& n, MotionManager::MC_ID w)
! 		: FileBrowserControl(n,"Loads a set of walk parameters from a file specified by user",config->motion.root), walk_id(w)
  	{
  		setFilter("*.prm");
  	}
  	//! destructor
  	virtual ~LoadWalkControl() {}
  
  protected:
  	//!does the actual loading of the MotionSequence
  	virtual ControlBase* selectedFile(const std::string& f) {
! 		WalkMC* walk = (WalkMC*)motman->checkoutMotion(walk_id);
! 		walk->load(f.c_str());
! 		motman->checkinMotion(walk_id);
  		return NULL;
  	}
  
  	MotionManager::MC_ID walk_id; //!< the MC_ID of the walk to load into
  };
  
  /*! @file
--- 12,54 ----
  public:
  	//! constructor, pass the MC_ID of the WalkMC which you want to save
  	LoadWalkControl(const std::string& n, MotionManager::MC_ID w)
! 		: FileBrowserControl(n,"Loads a set of walk parameters from a file specified by user",config->motion.root), walk_id(w), thewalk(NULL)
  	{
  		setFilter("*.prm");
  	}
+ 
+ 	//! constructor, pass a pointer to the WalkMC which you want to save
+ 	LoadWalkControl(const std::string& n, WalkMC * awalk)
+ 		: FileBrowserControl(n,"Loads a set of walk parameters from a file specified by user",config->motion.root), walk_id(MotionManager::invalid_MC_ID), thewalk(awalk)
+ 	{
+ 		setFilter("*.prm");
+ 	}
+ 
  	//! destructor
  	virtual ~LoadWalkControl() {}
  
  protected:
  	//!does the actual loading of the MotionSequence
  	virtual ControlBase* selectedFile(const std::string& f) {
! 		MotionManager::MC_ID id = thewalk==NULL?walk_id:thewalk->getID();
! 		WalkMC* walk=thewalk;
! 		if(id!=MotionManager::invalid_MC_ID)
! 			walk = (WalkMC*)motman->checkoutMotion(id);
! 		if(walk==NULL)
! 			serr->printf("Invalid walk for loading\n");
! 		else {
! 			walk->load(f.c_str());
! 			motman->checkinMotion(id);
! 		}
  		return NULL;
  	}
  
  	MotionManager::MC_ID walk_id; //!< the MC_ID of the walk to load into
+ 	WalkMC * thewalk; //!< the walk to load into (if NULL, check walk_id)
+ 
+ private:
+ 	LoadWalkControl(const LoadWalkControl&); //!< don't call
+ 	LoadWalkControl operator=(const LoadWalkControl&); //!< don't call
  };
  
  /*! @file
***************
*** 35,44 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 56,65 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/MCValueEditControl.h
diff -c AiboPup/Behaviors/Controls/MCValueEditControl.h:1.2 AiboPup/Behaviors/Controls/MCValueEditControl.h:1.3
*** AiboPup/Behaviors/Controls/MCValueEditControl.h:1.2	Sun Mar  2 20:18:11 2003
--- AiboPup/Behaviors/Controls/MCValueEditControl.h	Thu Sep 25 11:26:11 2003
***************
*** 29,38 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 29,38 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/NullControl.h
diff -c AiboPup/Behaviors/Controls/NullControl.h:1.1 AiboPup/Behaviors/Controls/NullControl.h:1.2
*** AiboPup/Behaviors/Controls/NullControl.h:1.1	Mon Jun  9 04:05:12 2003
--- AiboPup/Behaviors/Controls/NullControl.h	Thu Sep 25 11:26:11 2003
***************
*** 32,41 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 32,41 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/PlaySoundControl.h
diff -c AiboPup/Behaviors/Controls/PlaySoundControl.h:1.5 AiboPup/Behaviors/Controls/PlaySoundControl.h:1.6
*** AiboPup/Behaviors/Controls/PlaySoundControl.h:1.5	Mon Jun  9 20:53:48 2003
--- AiboPup/Behaviors/Controls/PlaySoundControl.h	Thu Sep 25 11:26:11 2003
***************
*** 32,41 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 32,41 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/ProfilerCheckControl.h
diff -c AiboPup/Behaviors/Controls/ProfilerCheckControl.h:1.3 AiboPup/Behaviors/Controls/ProfilerCheckControl.h:1.5
*** AiboPup/Behaviors/Controls/ProfilerCheckControl.h:1.3	Mon Jun  9 20:53:48 2003
--- AiboPup/Behaviors/Controls/ProfilerCheckControl.h	Fri Jul 25 16:18:04 2003
***************
*** 5,11 ****
  #include "ControlBase.h"
  #include "Shared/WorldState.h"
  
! //! causes the WorldState::mainProfile and WorldState::motionProfile to display reports to cout
  class ProfilerCheckControl : public ControlBase {
  public:
  	//! Constructor
--- 5,11 ----
  #include "ControlBase.h"
  #include "Shared/WorldState.h"
  
! //! causes the WorldState::mainProfile and WorldState::motionProfile to display reports to #sout
  class ProfilerCheckControl : public ControlBase {
  public:
  	//! Constructor
***************
*** 14,39 ****
  	//! Destructor
  	~ProfilerCheckControl() {}
  	
! 	//! Prints a report to cout
! 	virtual ControlBase * activate(MotionManager::MC_ID display, Socket *) {
! 		if(display!=MotionManager::invalid_MC_ID) {
! 			//!@todo make the leds flash
! 		}
! 		printf("~~~ Main: ~~~\n%s",state->mainProfile.report().c_str());
! 		printf("~~~ Motion: ~~~\n%s",state->motionProfile.report().c_str());
  		return NULL;
  	}
  };
  
  /*! @file
!  * @brief Defines ProfilerCheckControl, which causes the WorldState::mainProfile and WorldState::motionProfile to display reports to cout
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 14,36 ----
  	//! Destructor
  	~ProfilerCheckControl() {}
  	
! 	//! Prints a report to sout
! 	virtual ControlBase * activate(MotionManager::MC_ID, Socket *) {
! 		sout->printf("~~~ Main: ~~~\n%s",state->mainProfile.report().c_str());
! 		sout->printf("~~~ Motion: ~~~\n%s",state->motionProfile.report().c_str());
  		return NULL;
  	}
  };
  
  /*! @file
!  * @brief Defines ProfilerCheckControl, which causes the WorldState::mainProfile and WorldState::motionProfile to display reports to #sout
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/RebootControl.cc
diff -c AiboPup/Behaviors/Controls/RebootControl.cc:1.2 AiboPup/Behaviors/Controls/RebootControl.cc:1.3
*** AiboPup/Behaviors/Controls/RebootControl.cc:1.2	Thu Jun 12 19:41:36 2003
--- AiboPup/Behaviors/Controls/RebootControl.cc	Thu Sep 25 11:26:11 2003
***************
*** 12,20 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 12,20 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Behaviors/Controls/RebootControl.h
diff -c AiboPup/Behaviors/Controls/RebootControl.h:1.1 AiboPup/Behaviors/Controls/RebootControl.h:1.2
*** AiboPup/Behaviors/Controls/RebootControl.h:1.1	Mon Jun  9 04:05:13 2003
--- AiboPup/Behaviors/Controls/RebootControl.h	Thu Sep 25 11:26:11 2003
***************
*** 23,32 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 23,32 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/RunSequenceControl.h
diff -c AiboPup/Behaviors/Controls/RunSequenceControl.h:1.9 AiboPup/Behaviors/Controls/RunSequenceControl.h:1.10
*** AiboPup/Behaviors/Controls/RunSequenceControl.h:1.9	Thu Jun 12 14:06:10 2003
--- AiboPup/Behaviors/Controls/RunSequenceControl.h	Mon Jul 14 02:55:14 2003
***************
*** 34,42 ****
  protected:
  	//!does the actual loading of the MotionSequence
  	virtual ControlBase* selectedFile(const std::string& f) {
! 		TimeET timer;
  		SharedObject< MotionSequenceMC<SequenceSize> > s(f.c_str());
! 		cout << "Load Time: " << timer.Age() << endl;
  		MMAccessor<EmergencyStopMC>(estopid)->setActive(false);
  		MotionManager::MC_ID id=motman->addMotion(s,MotionManager::kEmergencyPriority+1,true);
  		erouter->addListener(this,EventBase::motmanEGID,id,EventBase::deactivateETID);
--- 34,42 ----
  protected:
  	//!does the actual loading of the MotionSequence
  	virtual ControlBase* selectedFile(const std::string& f) {
! 		//TimeET timer;
  		SharedObject< MotionSequenceMC<SequenceSize> > s(f.c_str());
! 		//cout << "Load Time: " << timer.Age() << endl;
  		MMAccessor<EmergencyStopMC>(estopid)->setActive(false);
  		MotionManager::MC_ID id=motman->addMotion(s,MotionManager::kEmergencyPriority+1,true);
  		erouter->addListener(this,EventBase::motmanEGID,id,EventBase::deactivateETID);
***************
*** 51,60 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 51,60 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/SavePostureControl.h
diff -c AiboPup/Behaviors/Controls/SavePostureControl.h:1.6 AiboPup/Behaviors/Controls/SavePostureControl.h:1.7
*** AiboPup/Behaviors/Controls/SavePostureControl.h:1.6	Thu Jun 12 14:06:10 2003
--- AiboPup/Behaviors/Controls/SavePostureControl.h	Mon Jul 28 01:54:32 2003
***************
*** 14,27 ****
  	SavePostureControl(const std::string& n) : StringInputControl(n,"Saves current posture to filename read from user","Please enter name for posture file (in /ms/data/motion)...") {}
  
  	virtual ControlBase * takeInput(const std::string& msg) {
! 		std::string filename;
! 		if(msg[0]=='/')
! 			filename=msg;
! 		else
! 			filename="/ms/data/motion/"+msg;
! 		PostureEngine post;
! 		post.takeSnapshot();
! 		post.SaveFile(filename.c_str());
  		return StringInputControl::takeInput(msg);
  	}
  };
--- 14,29 ----
  	SavePostureControl(const std::string& n) : StringInputControl(n,"Saves current posture to filename read from user","Please enter name for posture file (in /ms/data/motion)...") {}
  
  	virtual ControlBase * takeInput(const std::string& msg) {
! 		if(msg.size()>0) {
! 			std::string filename;
! 			if(msg[0]=='/')
! 				filename=msg;
! 			else
! 				filename="/ms/data/motion/"+msg;
! 			PostureEngine post;
! 			post.takeSnapshot();
! 			post.SaveFile(filename.c_str());
! 		}
  		return StringInputControl::takeInput(msg);
  	}
  };
***************
*** 31,40 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 33,42 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/SaveWalkControl.h
diff -c AiboPup/Behaviors/Controls/SaveWalkControl.h:1.4 AiboPup/Behaviors/Controls/SaveWalkControl.h:1.6
*** AiboPup/Behaviors/Controls/SaveWalkControl.h:1.4	Sat Jun  7 18:03:53 2003
--- AiboPup/Behaviors/Controls/SaveWalkControl.h	Mon Jul 28 14:39:11 2003
***************
*** 1,42 ****
  #ifndef INCLUDED_SaveWalkControl_h
  #define INCLUDED_SaveWalkControl_h
  
! #include "ControlBase.h"
  #include "Motion/MotionManager.h"
  #include "Motion/WalkMC.h"
  #include <string>
  
  //! When activated, saves walk parameters to a file specified from cin
! class SaveWalkControl : public ControlBase {
   public:
  	//! constructor, pass the MC_ID of the walk you want to save
! 	SaveWalkControl(const std::string& n, MotionManager::MC_ID w) : ControlBase(n), walk_id(w) {}
  	//! destructor
  	virtual ~SaveWalkControl() {}
  
! 	//! when called, prompts on cin for file to save into -- will overwrite this file
! 	virtual ControlBase * activate(MotionManager::MC_ID disp_id, Socket*) {
!     if(disp_id!=MotionManager::invalid_MC_ID) {
!       MMAccessor<LedMC> display(disp_id);
!       display.mc()->cset(FaceLEDMask,.5);
!     }
! 
! 		char cur[33];
! 		std::cout << "#> " << std::flush;
! 		std::cin >> cur;
! 		std::cout << std::endl;
! 		if(strlen(cur)>0) {
! 			WalkMC* walk = (WalkMC*)motman->checkoutMotion(walk_id);
! 			walk->save(cur);
! 			motman->checkinMotion(walk_id);
  		}
! 		return NULL;
  	}
- 	//! does nothing
- 	virtual void deactivate() {}
  
   protected:
  	MotionManager::MC_ID walk_id; //!< MC_ID of walk to save from
  };
  
  /*! @file
--- 1,49 ----
  #ifndef INCLUDED_SaveWalkControl_h
  #define INCLUDED_SaveWalkControl_h
  
! #include "StringInputControl.h"
  #include "Motion/MotionManager.h"
  #include "Motion/WalkMC.h"
  #include <string>
  
  //! When activated, saves walk parameters to a file specified from cin
! class SaveWalkControl : public StringInputControl {
   public:
  	//! constructor, pass the MC_ID of the walk you want to save
! 	SaveWalkControl(const std::string& n, MotionManager::MC_ID w) : StringInputControl(n,"Saves Walk parameters to filename read from user","Please enter name for posture file (in /ms/data/motion)..."), walk_id(w), thewalk(NULL) {}
! 	//! constructor, pass a pointer to the walk you want to save
! 	SaveWalkControl(const std::string& n, WalkMC * awalk) : StringInputControl(n,"Saves Walk parameters to filename read from user","Please enter name for posture file (in /ms/data/motion)..."), walk_id(MotionManager::invalid_MC_ID), thewalk(awalk) {}
  	//! destructor
  	virtual ~SaveWalkControl() {}
  
! 	virtual ControlBase * takeInput(const std::string& msg) {
! 		if(msg.size()>0) {
! 			std::string filename;
! 			if(msg[0]=='/')
! 				filename=msg;
! 			else
! 				filename="/ms/data/motion/"+msg;
! 			MotionManager::MC_ID id = thewalk==NULL?walk_id:thewalk->getID();
! 			WalkMC* walk=thewalk;
! 			if(id!=MotionManager::invalid_MC_ID)
! 				walk = (WalkMC*)motman->checkoutMotion(id);
! 			if(walk==NULL)
! 				serr->printf("Invalid walk for saving\n");
! 			else {
! 				walk->save(filename.c_str());
! 				motman->checkinMotion(id);
! 			}
  		}
! 		return StringInputControl::takeInput(msg);
  	}
  
   protected:
  	MotionManager::MC_ID walk_id; //!< MC_ID of walk to save from
+ 	WalkMC * thewalk; //!< walk to save from
+ 
+ private:
+ 	SaveWalkControl(const SaveWalkControl&); //!< don't call
+ 	SaveWalkControl operator=(const SaveWalkControl&); //!< don't call
  };
  
  /*! @file
***************
*** 44,52 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  #endif
--- 51,59 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  #endif
Index: AiboPup/Behaviors/Controls/ShutdownControl.cc
diff -c AiboPup/Behaviors/Controls/ShutdownControl.cc:1.2 AiboPup/Behaviors/Controls/ShutdownControl.cc:1.3
*** AiboPup/Behaviors/Controls/ShutdownControl.cc:1.2	Thu Jun 12 19:41:36 2003
--- AiboPup/Behaviors/Controls/ShutdownControl.cc	Thu Sep 25 11:26:11 2003
***************
*** 12,20 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 12,20 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Behaviors/Controls/ShutdownControl.h
diff -c AiboPup/Behaviors/Controls/ShutdownControl.h:1.2 AiboPup/Behaviors/Controls/ShutdownControl.h:1.3
*** AiboPup/Behaviors/Controls/ShutdownControl.h:1.2	Thu Jun 12 19:41:36 2003
--- AiboPup/Behaviors/Controls/ShutdownControl.h	Thu Sep 25 11:26:11 2003
***************
*** 23,32 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 23,32 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/StringInputControl.cc
diff -c AiboPup/Behaviors/Controls/StringInputControl.cc:1.3 AiboPup/Behaviors/Controls/StringInputControl.cc:1.5
*** AiboPup/Behaviors/Controls/StringInputControl.cc:1.3	Thu Jun 12 19:41:36 2003
--- AiboPup/Behaviors/Controls/StringInputControl.cc	Mon Jul 28 01:54:32 2003
***************
*** 3,20 ****
  #include "Motion/MMAccessor.h"
  #include "Motion/LedMC.h"
  #include "Motion/MotionManager.h"
  
! ControlBase* StringInputControl::activate(MotionManager::MC_ID disp_id, Socket* gui) {
  	display_id=disp_id;
  	gui_comm=gui;
  	return doReadStdIn(userPrompt);
! }
  
  void StringInputControl::refresh() {
! 	ControlBase::doReadStdIn(userPrompt);
  }
  
  ControlBase* StringInputControl::doReadStdIn(const std::string& prompt/*=std::string()*/) {
  	if(prompt.size()==0)
  		return ControlBase::doReadStdIn(userPrompt);
  	else
--- 3,36 ----
  #include "Motion/MMAccessor.h"
  #include "Motion/LedMC.h"
  #include "Motion/MotionManager.h"
+ #include <sstream>
  
! /*ControlBase* StringInputControl::activate(MotionManager::MC_ID disp_id, Socket* gui) {
  	display_id=disp_id;
  	gui_comm=gui;
  	return doReadStdIn(userPrompt);
! 	}*/
  
  void StringInputControl::refresh() {
! 	ControlBase::refresh();
! 	doReadStdIn(userPrompt);
  }
  
  ControlBase* StringInputControl::doReadStdIn(const std::string& prompt/*=std::string()*/) {
+ 	if(gui_comm!=NULL && wireless->isConnected(gui_comm->sock)) {
+ 		//		cout << "REFRESHING " << getName() << endl;
+ 		//try to get it all in one packet for better performance
+ 		std::stringstream ss;
+ 		ss << "refresh\n"
+ 			 << getName() << '\n'
+ 			 << "1\n"
+ 			 << "0\n"
+ 			 << "0\n"
+ 			 << "Waiting for input...\n"
+ 			 << userPrompt << "\n";
+ 		gui_comm->write((const byte*)ss.str().c_str(),ss.str().size());
+ 	}
+ 	
  	if(prompt.size()==0)
  		return ControlBase::doReadStdIn(userPrompt);
  	else
***************
*** 26,34 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 42,50 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Behaviors/Controls/StringInputControl.h
diff -c AiboPup/Behaviors/Controls/StringInputControl.h:1.2 AiboPup/Behaviors/Controls/StringInputControl.h:1.4
*** AiboPup/Behaviors/Controls/StringInputControl.h:1.2	Thu Jun 12 14:06:10 2003
--- AiboPup/Behaviors/Controls/StringInputControl.h	Thu Sep 25 11:26:11 2003
***************
*** 14,20 ****
  	//! Constructor
  	StringInputControl(const std::string& n, const std::string& desc, const std::string& prompt) : ControlBase(n,desc), lastInput(), userPrompt(prompt) {}
  
! 	virtual ControlBase* activate(MotionManager::MC_ID disp_id, Socket* gui);
  	
  	virtual void refresh();
  	
--- 14,20 ----
  	//! Constructor
  	StringInputControl(const std::string& n, const std::string& desc, const std::string& prompt) : ControlBase(n,desc), lastInput(), userPrompt(prompt) {}
  
! 	//	virtual ControlBase* activate(MotionManager::MC_ID disp_id, Socket* gui);
  	
  	virtual void refresh();
  	
***************
*** 41,50 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 41,50 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/ValueEditControl.h
diff -c AiboPup/Behaviors/Controls/ValueEditControl.h:1.8 AiboPup/Behaviors/Controls/ValueEditControl.h:1.9
*** AiboPup/Behaviors/Controls/ValueEditControl.h:1.8	Mon Jun  9 16:10:17 2003
--- AiboPup/Behaviors/Controls/ValueEditControl.h	Mon Jul 14 01:50:25 2003
***************
*** 41,58 ****
  		case ButtonSourceID::HeadBkButSID: doNextItem(); doSelect(); break;
  			//		case ButtonSourceID::ChinButSID: doSelect(); break;
  		default:
! 			cout << "*** WARNING ValueEditControl got an unasked for event" << endl;
  			break;
  		}
  	}
  	//! displays current value
! 	/*	virtual void refresh() {
! 			cout << getName();
  			if(cur!=*target)
! 			cout << ": " << cur;
! 			cout << endl;
! 			StringInputControl::refresh();
! 			}*/
  	//! request to continue receiving events so we can modify the value while running
  	virtual void pause() {
  		erouter->addListener(this,EventBase(EventBase::buttonEGID,ButtonSourceID::HeadFrButSID,EventBase::deactivateETID,0));
--- 41,64 ----
  		case ButtonSourceID::HeadBkButSID: doNextItem(); doSelect(); break;
  			//		case ButtonSourceID::ChinButSID: doSelect(); break;
  		default:
! 			serr->printf("*** WARNING ValueEditControl got an unasked for event\n");
  			break;
  		}
  	}
  	//! displays current value
! 	virtual void refresh() {
! 		//Do console only if GUI is connected
! 		if(gui_comm!=NULL && wireless->isConnected(gui_comm->sock)) {
! 			std::stringstream ss;
! 			ss << getName();
  			if(cur!=*target)
! 				ss << ": " << cur;
! 			sout->printf("%s\n",ss.str().c_str());
! 		}
! 
! 		StringInputControl::refresh();
! 	}
! 
  	//! request to continue receiving events so we can modify the value while running
  	virtual void pause() {
  		erouter->addListener(this,EventBase(EventBase::buttonEGID,ButtonSourceID::HeadFrButSID,EventBase::deactivateETID,0));
***************
*** 71,77 ****
  			//				display->flash(FaceLEDMask,100);
  			//				display->clear();
  			//			}
! 			cout << getName() << " set to " << *target << endl;
  		}
  		return NULL;
  	}
--- 77,85 ----
  			//				display->flash(FaceLEDMask,100);
  			//				display->clear();
  			//			}
! 			std::stringstream ss;
! 			ss << getName() << " set to " << *target;
! 			sout->printf("%s\n",ss.str().c_str());
  		}
  		return NULL;
  	}
***************
*** 123,132 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 131,140 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Controls/ValueSetControl.h
diff -c AiboPup/Behaviors/Controls/ValueSetControl.h:1.1 AiboPup/Behaviors/Controls/ValueSetControl.h:1.2
*** AiboPup/Behaviors/Controls/ValueSetControl.h:1.1	Sat Mar  1 15:53:29 2003
--- AiboPup/Behaviors/Controls/ValueSetControl.h	Thu Sep 25 11:26:11 2003
***************
*** 50,59 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 50,59 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Demos/Aibo3DControllerBehavior.h
diff -c AiboPup/Behaviors/Demos/Aibo3DControllerBehavior.h:1.5 AiboPup/Behaviors/Demos/Aibo3DControllerBehavior.h:removed
*** AiboPup/Behaviors/Demos/Aibo3DControllerBehavior.h:1.5	Sun Jul  6 21:00:07 2003
--- AiboPup/Behaviors/Demos/Aibo3DControllerBehavior.h	Fri Oct 10 14:37:43 2003
***************
*** 1,125 ****
- //-*-c++-*-
- #ifndef INCLUDED_Aibo3DControllerBehavior_h_
- #define INCLUDED_Aibo3DControllerBehavior_h_
- 
- #include <iostream>
- #include "Wireless/Wireless.h"
- #include "Behaviors/BehaviorBase.h"
- #include "Motion/MotionManager.h"
- #include "Motion/RemoteControllerMC.h"
- #include "Events/EventRouter.h"
- #include "Events/EventBase.h"
- #include "Shared/RobotInfo.h"
- 
- //! gets input from the GUI
- int aibo3dcontrollercmd_callback(char *buf, int bytes);
- class Aibo3DControllerBehavior;
- 
- //! so aibo3dcontrollercmd_callback knows where to send the input from the GUI
- Aibo3DControllerBehavior *aibo3dControllerBehavior = NULL;
- 
-   
- //! Listens to aibo3d control commands coming in from the command port.
- class Aibo3DControllerBehavior : public BehaviorBase {
-  protected:
- 	MotionManager::MC_ID rcontrol_id; //!< remote controller motion command's id
-  
- 	//! The input command stream socket
- 	Socket *cmdsock;
- 
-   float val[NumPIDJoints]; //!< the value to use for each of the PID joints
-   char *fbuf;  //!< alias to val
-   unsigned int pos; //!< a counter to know when we've gotten 4 frames
- 
-  private:
- 	Aibo3DControllerBehavior(const Aibo3DControllerBehavior&); //!< don't call
- 	Aibo3DControllerBehavior operator=(const Aibo3DControllerBehavior&); //!< don't call
- 
-  public:
- 	//! constructor
- 	Aibo3DControllerBehavior() :
- 	  BehaviorBase(),
- 	  rcontrol_id(MotionManager::invalid_MC_ID),
- 	  cmdsock(wireless->socket(SocketNS::SOCK_STREAM, 2048, 2048)),
-     fbuf((char*)val), pos(0)
- 	{ aibo3dControllerBehavior = this; }
- 	//! destructor
- 	virtual ~Aibo3DControllerBehavior() { aibo3dControllerBehavior = NULL; }
- 
- 	//! processes input from the GUI
-   int registerData(char *buf, int bytes) {
-     int read=0;
-     while (read<bytes) {
-       if (pos==NumPIDJoints*4) {
-         RemoteControllerMC *rcontrol =
-           (RemoteControllerMC*)motman->checkoutMotion(rcontrol_id);
-         for (unsigned int i=0; i<NumPIDJoints; i++)
-           rcontrol->cmds[i]=val[i];
-         rcontrol->setDirty();
-         motman->checkinMotion(rcontrol_id);
-         pos=0;
-       }
-       fbuf[pos]=buf[read];
-       pos++;
-       read++;
-     }
-     return read;
-   }
- 
- 	virtual void DoStart() {
- 		// Behavior startup
- 		BehaviorBase::DoStart();
- 		// Enable remote control stream
- 		rcontrol_id = motman->addMotion(SharedObject<RemoteControllerMC>());
- 		// Turn on wireless
- 		wireless->setReceiver(cmdsock->sock, aibo3dcontrollercmd_callback);
- 		wireless->listen(cmdsock->sock, config->main.aibo3d_port);
- 		// open gui
- 		std::vector<std::string> tmp;
- 		tmp.push_back("Aibo3D Load Instructions");
- 		tmp.push_back("To load Aibo3D, you will need to install java3d\nand then run Tekkotsu/tools/aibo3d/");
- 		tmp.back()+=getGUIType();
- 		Controller::loadGUI("ControllerMsg","LoadAibo3d",getPort(),tmp);
- 		//Controller::loadGUI(getGUIType(),getGUIType(),getPort());
- 	}
- 
- 	virtual void DoStop() {
- 		Controller::closeGUI(getGUIType());
- 		// Close socket; turn wireless off
- 		wireless->close(cmdsock);
- 		// Disable remote control
- 		motman->removeMotion(rcontrol_id);
- 		// Total behavior stop
- 		BehaviorBase::DoStop();
- 	}
- 
- 	virtual std::string getGUIType() const { return "Aibo3DPick"; }
- 	virtual unsigned int getPort() const { return config->main.aibo3d_port; }
- 
- 	virtual std::string getName() const { return "Aibo3D Controller"; } //!< returns name of behavior
- 	static std::string getClassDescription() { 
- 		char tmp[20];
- 		sprintf(tmp,"%d",config->main.aibo3d_port);
- 		return std::string("Listens to aibo3d control commands coming in from port ")+tmp;
- 	}
- };
- 
- 
- int aibo3dcontrollercmd_callback(char *buf, int bytes) {
-   if (aibo3dControllerBehavior!=NULL)
-     return aibo3dControllerBehavior->registerData(buf, bytes);
-   return 0;
- }
- 
- /*! @file
-  * @brief Defines Aibo3DControllerBehavior, which listens to commands from the Aibo3D gui and shows current state
-  * @author alokl (Creator)
-  *
-  * $Author: ejt $
-  * $Name: HEAD $
-  * $Revision: 1.2 $
-  * $State: Exp $
-  * $Date: 2003/10/10 20:25:03 $
-  */
- 
- #endif 
--- 0 ----
Index: AiboPup/Behaviors/Demos/Aibo3DMonitorBehavior.h
diff -c AiboPup/Behaviors/Demos/Aibo3DMonitorBehavior.h:1.2 AiboPup/Behaviors/Demos/Aibo3DMonitorBehavior.h:removed
*** AiboPup/Behaviors/Demos/Aibo3DMonitorBehavior.h:1.2	Sun Jul  6 21:00:07 2003
--- AiboPup/Behaviors/Demos/Aibo3DMonitorBehavior.h	Fri Oct 10 14:37:43 2003
***************
*** 1,32 ****
- //-*-c++-*-
- #ifndef INCLUDED_Aibo3DMonitorBehavior_h_
- #define INCLUDED_Aibo3DMonitorBehavior_h_
- 
- //! Sends current pose to Aibo3D GUI, ignores incoming commands
- class Aibo3DMonitorBehavior : public Aibo3DControllerBehavior {
- public:
- 	Aibo3DMonitorBehavior() : Aibo3DControllerBehavior() {}
- 
- 	virtual std::string getGUIType() const { return "Aibo3D"; }
- 	virtual unsigned int getPort() const { return config->main.aibo3d_port; }
- 
- 	virtual std::string getName() const { return "Aibo3D Monitor"; } //!< returns name of behavior
- 	static std::string getClassDescription() {
- 		char tmp[20];
- 		sprintf(tmp,"%d",config->main.aibo3d_port);
- 		return std::string("Sends current pose on port ")+tmp;
- 	}	
- };
- 
- /*! @file
-  * @brief Defines Aibo3DMonitorBehavior, which sends current pose to Aibo3D GUI, ignores incoming commands
-  * @author ejt (Creator)
-  *
-  * $Author: ejt $
-  * $Name: HEAD $
-  * $Revision: 1.2 $
-  * $State: Exp $
-  * $Date: 2003/10/10 20:25:03 $
-  */
- 
- #endif
--- 0 ----
Index: AiboPup/Behaviors/Demos/AlanBehavior.h
diff -c /dev/null AiboPup/Behaviors/Demos/AlanBehavior.h:1.4
*** /dev/null	Fri Oct 10 14:37:43 2003
--- AiboPup/Behaviors/Demos/AlanBehavior.h	Thu Sep 25 23:09:04 2003
***************
*** 0 ****
--- 1,103 ----
+ //-*-c++-*-
+ #ifndef INCLUDED_AlanBehavior_h_
+ #define INCLUDED_AlanBehavior_h_
+ 
+ #include "Behaviors/BehaviorBase.h"
+ #include "Motion/MotionManager.h"
+ #include "Motion/MMAccessor.h"
+ #include "Shared/SharedObject.h"
+ #include "Shared/WorldState.h"
+ #include "Events/EventRouter.h"
+ #include "Motion/PostureMC.h"
+ 
+ //! just a little demo behavior which lifts a leg higher as more pressure is put on a head button
+ /*! Based on an idea from Alan Chun-ho Ho for a basic demo program */
+ class AlanBehavior : public BehaviorBase {
+ public:
+ 	AlanBehavior()
+ 		: BehaviorBase(), pose_id(MotionManager::invalid_MC_ID)
+ 	{}
+ 	
+ 	virtual void DoStart() {
+ 		//call superclass first for housekeeping:
+ 		BehaviorBase::DoStart();
+ 
+ 		//now do your code:
+ 		
+ 		// creates a PostureMC class to move the joint(s) and adds it to global MotionManager
+ 		pose_id=motman->addMotion(SharedObject<PostureMC>());
+ 		// subscribe to sensor updated events through the global EventRouter
+ 		erouter->addListener(this,EventBase::sensorEGID,SensorSourceID::UpdatedSID);
+ 	}
+ 	
+ 	virtual void DoStop() {
+ 		//do your code first:
+ 		motman->removeMotion(pose_id);  // removes your posture controller
+ 		erouter->forgetListener(this); // stops getting events (and timers, if we had any)
+ 
+ 		//but don't forget to call superclass at the end:
+ 		BehaviorBase::DoStop();
+ 	}
+ 	
+ 	virtual void processEvent(const EventBase& event) {
+ 		// to be more general, let's check that it's the right event:
+ 		if(event.getGeneratorID()==EventBase::sensorEGID) {
+ 
+ 			// "checks out" the posture motion command from MotionManager
+ 			// (this is the PostureMC we created in DoStart())
+ 			MMAccessor<PostureMC> pose_mc(pose_id);
+ 			
+ 			//Joint offsets are defined in ERS210Info.h, ERS220Info.h and ERS2xxInfo.h
+ 			unsigned int joint=LFrLegOffset+RotatorOffset;
+ 			
+ 			//state is a global instantiation of WorldState, kept up to date by framework;
+ 			//pressure is in range 0 to 1 - we use the pressure on the front head button here
+ 			float pressure=state->buttons[HeadFrButOffset];
+ 			std::cout << "HeadFrBut Pressure: " << pressure << std::endl;
+ 			
+ 			//outputRanges is a constant table, also defined in ERS210Info.h or ERS220Info.h
+ 			float angle=outputRanges[joint][MaxRange]*pressure;
+ 
+ 			// now send the joint angle to the posture motion command
+ 			pose_mc->setOutputCmd(joint,angle);
+ 
+ 			//let's do the whole thing again with the other head button for the other leg:
+ 			// (cutting out a some of the intermediary steps this time)
+ 			joint=RFrLegOffset+RotatorOffset;
+ 			pose_mc->setOutputCmd(joint,outputRanges[joint][MaxRange]*state->buttons[HeadBkButOffset]);
+ 
+ 			// notice that there's no "check in" for pose_mc
+ 			// MMAccessor's destructor does this automatically
+ 
+ 		} else {
+ 			//should never happen
+ 			cout << "Unhandled Event:" << event.getName() << endl;
+ 		}
+ 	}
+ 	
+ 	virtual std::string getName() const {
+ 		// Name is used for menus, or debugging.
+ 		return "AlanBehavior";
+ 	}
+ 	
+ 	static std::string getClassDescription() {
+ 		// This string will be shown by the HelpControl or by the tooltips of the Controller GUI
+ 		return "Lifts the left/right front legs higher as more pressure is applied to the front/back head buttons";
+ 	}
+ 	
+ protected:
+ 	MotionManager::MC_ID pose_id; //!< ID of PostureMC, set up in DoStart() and used in processEvent()
+ };
+ 
+ /*! @file
+  * @brief Defines AlanBehavior, a little demo behavior which lifts a leg higher as more pressure is put on the back head button
+  * @author ejt (Creator)
+  *
+  * $Author: ejt $
+  * $Name: HEAD $
+  * $Revision: 1.2 $
+  * $State: Exp $
+  * $Date: 2003/10/10 20:25:03 $
+  */
+ 
+ #endif
Index: AiboPup/Behaviors/Demos/AutoGetupBehavior.h
diff -c AiboPup/Behaviors/Demos/AutoGetupBehavior.h:1.8 AiboPup/Behaviors/Demos/AutoGetupBehavior.h:1.9
*** AiboPup/Behaviors/Demos/AutoGetupBehavior.h:1.8	Mon Jun  9 20:53:48 2003
--- AiboPup/Behaviors/Demos/AutoGetupBehavior.h	Thu Sep 25 11:26:22 2003
***************
*** 74,83 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 74,83 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Demos/BanditMachine.h
diff -c AiboPup/Behaviors/Demos/BanditMachine.h:1.9 AiboPup/Behaviors/Demos/BanditMachine.h:1.10
*** AiboPup/Behaviors/Demos/BanditMachine.h:1.9	Thu Jun 12 19:41:39 2003
--- AiboPup/Behaviors/Demos/BanditMachine.h	Thu Sep 25 11:26:22 2003
***************
*** 213,222 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 213,222 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Demos/BatteryMonitorBehavior.h
diff -c AiboPup/Behaviors/Demos/BatteryMonitorBehavior.h:1.10 AiboPup/Behaviors/Demos/BatteryMonitorBehavior.h:1.12
*** AiboPup/Behaviors/Demos/BatteryMonitorBehavior.h:1.10	Thu Jun 12 14:06:10 2003
--- AiboPup/Behaviors/Demos/BatteryMonitorBehavior.h	Fri Jul 25 21:48:09 2003
***************
*** 12,17 ****
--- 12,18 ----
  #include "Motion/LedMC.h"
  #include "Shared/ERS210Info.h"
  #include "Shared/ERS220Info.h"
+ #include "Motion/MMAccessor.h"
  
  //! A background behavior which will monitor the power level and flip the ears when appropriate on a 210, or blink the headlight if a 220
  /*! Think of this as a simple example class.  For exercise, try using a MotionSequenceMC instead
***************
*** 101,107 ****
  protected:
  	//! adds a pose and a timer to get the ears flipping
  	void startWarning() {
! 		cout << "LOW BATTERY" << endl;
  		pose_id=motman->addMotion(SharedObject<PostureMC>(),MotionManager::kEmergencyPriority+1);
  		pose=(PostureMC*)motman->peekMotion(pose_id);
  		SharedObject<LedMC> led;
--- 102,108 ----
  protected:
  	//! adds a pose and a timer to get the ears flipping
  	void startWarning() {
! 		serr->printf("LOW BATTERY\n");
  		pose_id=motman->addMotion(SharedObject<PostureMC>(),MotionManager::kEmergencyPriority+1);
  		pose=(PostureMC*)motman->peekMotion(pose_id);
  		SharedObject<LedMC> led;
***************
*** 112,118 ****
  	}
  	//! removes pose, in case battery magically charges
  	void stopWarning() {
! 		cout << "BATTERY GOOD" << endl;
  		motman->removeMotion(pose_id);
  		motman->removeMotion(led_id);
  		led_id=pose_id=MotionManager::invalid_MC_ID;
--- 113,119 ----
  	}
  	//! removes pose, in case battery magically charges
  	void stopWarning() {
! 		serr->printf("BATTERY GOOD\n");
  		motman->removeMotion(pose_id);
  		motman->removeMotion(led_id);
  		led_id=pose_id=MotionManager::invalid_MC_ID;
***************
*** 151,160 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 152,161 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Demos/CameraBehavior.h
diff -c AiboPup/Behaviors/Demos/CameraBehavior.h:1.4 AiboPup/Behaviors/Demos/CameraBehavior.h:1.5
*** AiboPup/Behaviors/Demos/CameraBehavior.h:1.4	Thu Jun 12 19:41:39 2003
--- AiboPup/Behaviors/Demos/CameraBehavior.h	Thu Sep 25 11:26:22 2003
***************
*** 124,133 ****
   * @author alokl (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 124,133 ----
   * @author alokl (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Demos/ChaseBallBehavior.cc
diff -c AiboPup/Behaviors/Demos/ChaseBallBehavior.cc:1.2 AiboPup/Behaviors/Demos/ChaseBallBehavior.cc:1.5
*** AiboPup/Behaviors/Demos/ChaseBallBehavior.cc:1.2	Sat Mar  8 21:45:21 2003
--- AiboPup/Behaviors/Demos/ChaseBallBehavior.cc	Fri Sep 12 17:37:47 2003
***************
*** 5,10 ****
--- 5,11 ----
  #include "Motion/HeadPointerMC.h"
  #include "Motion/WalkMC.h"
  #include "Vision/Vision.h"
+ #include "Shared/WMclass.h"
  
  //! Converts degrees to radians
  inline double DtoR(double deg) { return (deg/180.0*M_PI); }
***************
*** 14,26 ****
  	headpointer_id = motman->addMotion(SharedObject<HeadPointerMC>());
  	walker_id = motman->addMotion(SharedObject<WalkMC>());
  	erouter->addListener(this,EventBase::visionEGID);
-   vision->enableEvents(VisionEventNS::RedBallSID);
-   vision->enableEvents(VisionEventNS::PinkBallSID);
  }
  
  void ChaseBallBehavior::DoStop() {
-   vision->disableEvents(VisionEventNS::RedBallSID);
-   vision->disableEvents(VisionEventNS::PinkBallSID);
  	erouter->forgetListener(this);
  	motman->removeMotion(headpointer_id);
  	motman->removeMotion(walker_id);
--- 15,23 ----
***************
*** 29,35 ****
  
  //this could be cleaned up event-wise (only use a timer when out of view)
  void ChaseBallBehavior::processEvent(const EventBase& event) {
! 	static float horiz=0,vert=0;
  	if(event.getGeneratorID()==EventBase::visionEGID && event.getTypeID()==EventBase::statusETID) {
  		horiz=static_cast<const VisionEvent*>(&event)->getCenterX();
  		vert=static_cast<const VisionEvent*>(&event)->getCenterY();
--- 26,35 ----
  
  //this could be cleaned up event-wise (only use a timer when out of view)
  void ChaseBallBehavior::processEvent(const EventBase& event) {
!   WMreg(chase_ball_behavior);
!   WMvari_(float, horiz, 0, chase_ball_behavior);
!   WMvari_(float, vert, 0, chase_ball_behavior);
! 
  	if(event.getGeneratorID()==EventBase::visionEGID && event.getTypeID()==EventBase::statusETID) {
  		horiz=static_cast<const VisionEvent*>(&event)->getCenterX();
  		vert=static_cast<const VisionEvent*>(&event)->getCenterY();
***************
*** 37,43 ****
  
  	WalkMC * walker = (WalkMC*)motman->checkoutMotion(walker_id);
  	if(state->outputs[HeadOffset+PanOffset]<-.05 || state->outputs[HeadOffset+PanOffset]>.05)
! 		walker->setTargetVelocity(100,0,state->outputs[HeadOffset+PanOffset]*2);
  	else
  		walker->setTargetVelocity(160,0,0);
  	motman->checkinMotion(walker_id);
--- 37,43 ----
  
  	WalkMC * walker = (WalkMC*)motman->checkoutMotion(walker_id);
  	if(state->outputs[HeadOffset+PanOffset]<-.05 || state->outputs[HeadOffset+PanOffset]>.05)
! 		walker->setTargetVelocity(100,0,state->outputs[HeadOffset+PanOffset]);
  	else
  		walker->setTargetVelocity(160,0,0);
  	motman->checkinMotion(walker_id);
***************
*** 64,73 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  
--- 64,73 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  
Index: AiboPup/Behaviors/Demos/ChaseBallBehavior.h
diff -c AiboPup/Behaviors/Demos/ChaseBallBehavior.h:1.3 AiboPup/Behaviors/Demos/ChaseBallBehavior.h:1.4
*** AiboPup/Behaviors/Demos/ChaseBallBehavior.h:1.3	Thu Jun  5 13:03:15 2003
--- AiboPup/Behaviors/Demos/ChaseBallBehavior.h	Thu Sep 25 11:26:22 2003
***************
*** 37,46 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 37,46 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Demos/CrashTestBehavior.h
diff -c /dev/null AiboPup/Behaviors/Demos/CrashTestBehavior.h:1.1
*** /dev/null	Fri Oct 10 14:37:43 2003
--- AiboPup/Behaviors/Demos/CrashTestBehavior.h	Thu Oct  2 23:40:17 2003
***************
*** 0 ****
--- 1,49 ----
+ //-*-c++-*-
+ #ifndef INCLUDED_CrashTestBehavior_h_
+ #define INCLUDED_CrashTestBehavior_h_
+ 
+ #include "Behaviors/BehaviorBase.h"
+ #include "Wireless/Wireless.h"
+ 
+ //! Demonstrates (lack of) blocking using serr to (not) pinpoint a crash
+ class CrashTestBehavior : public BehaviorBase {
+ public:
+ 	CrashTestBehavior() : BehaviorBase()	{}
+ 	
+ 	virtual void DoStart() {
+ 		//call superclass first for housekeeping:
+ 		BehaviorBase::DoStart();
+ 
+ 		//now do your code:
+ 		for(unsigned int i=0; i<100; i++) {
+ 			serr->printf("Hello serr!  This is %d\n",i);
+ 			if(i==33)
+ 				*(int*)0xDEADDEAD=0x600DB4E;
+ 		}
+ 		//Hate to break it to you, but we're never going to get here...
+ 	}
+ 	
+ 	virtual std::string getName() const {
+ 		// Name is used for menus, or debugging.
+ 		return "CrashTestBehavior";
+ 	}
+ 	
+ 	static std::string getClassDescription() {
+ 		// This string will be shown by the HelpControl or by the tooltips of the Controller GUI
+ 		return "A little demo of blocking output before a crash (yes, this crashes the AIBO)";
+ 	}
+ 	
+ };
+ 
+ /*! @file
+  * @brief Defines CrashTestBehavior, demonstrates (lack of) blocking using serr to (not) pinpoint a crash
+  * @author ejt (Creator)
+  *
+  * $Author: ejt $
+  * $Name: HEAD $
+  * $Revision: 1.2 $
+  * $State: Exp $
+  * $Date: 2003/10/10 20:25:03 $
+  */
+ 
+ #endif
Index: AiboPup/Behaviors/Demos/DriveMeBehavior.cc
diff -c AiboPup/Behaviors/Demos/DriveMeBehavior.cc:1.3 AiboPup/Behaviors/Demos/DriveMeBehavior.cc:1.4
*** AiboPup/Behaviors/Demos/DriveMeBehavior.cc:1.3	Thu Jun 12 19:41:39 2003
--- AiboPup/Behaviors/Demos/DriveMeBehavior.cc	Fri Jul 25 16:18:04 2003
***************
*** 1,4 ****
- #include "BehaviorBase.h"
  #include "Motion/MotionManager.h"
  #include "Motion/WalkMC.h"
  #include "Motion/MotionSequenceMC.h"
--- 1,3 ----
***************
*** 110,118 ****
   * @author tss (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 109,117 ----
   * @author tss (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Behaviors/Demos/DriveMeBehavior.h
diff -c AiboPup/Behaviors/Demos/DriveMeBehavior.h:1.4 AiboPup/Behaviors/Demos/DriveMeBehavior.h:1.5
*** AiboPup/Behaviors/Demos/DriveMeBehavior.h:1.4	Thu Jun 12 19:41:39 2003
--- AiboPup/Behaviors/Demos/DriveMeBehavior.h	Fri Jul 25 16:18:05 2003
***************
*** 2,8 ****
  #ifndef INCLUDED_DriveMeBehavior_h_
  #define INCLUDED_DriveMeBehavior_h_
  
! #include "BehaviorBase.h"
  #include "Motion/MotionManager.h"
  #include "Motion/MotionSequenceMC.h"
  #include "Shared/SharedObject.h"
--- 2,8 ----
  #ifndef INCLUDED_DriveMeBehavior_h_
  #define INCLUDED_DriveMeBehavior_h_
  
! #include "Behaviors/BehaviorBase.h"
  #include "Motion/MotionManager.h"
  #include "Motion/MotionSequenceMC.h"
  #include "Shared/SharedObject.h"
***************
*** 39,48 ****
   * @author tss (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 39,48 ----
   * @author tss (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Demos/DumbWM2Behavior.h
diff -c AiboPup/Behaviors/Demos/DumbWM2Behavior.h:1.7 AiboPup/Behaviors/Demos/DumbWM2Behavior.h:1.8
*** AiboPup/Behaviors/Demos/DumbWM2Behavior.h:1.7	Thu Jun 12 19:41:39 2003
--- AiboPup/Behaviors/Demos/DumbWM2Behavior.h	Thu Sep 25 11:26:22 2003
***************
*** 40,49 ****
   * @author tss (Creator)
   * 
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif 
--- 40,49 ----
   * @author tss (Creator)
   * 
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif 
Index: AiboPup/Behaviors/Demos/EStopControllerBehavior.cc
diff -c AiboPup/Behaviors/Demos/EStopControllerBehavior.cc:1.2 AiboPup/Behaviors/Demos/EStopControllerBehavior.cc:removed
*** AiboPup/Behaviors/Demos/EStopControllerBehavior.cc:1.2	Tue Jul  8 20:10:57 2003
--- AiboPup/Behaviors/Demos/EStopControllerBehavior.cc	Fri Oct 10 14:37:43 2003
***************
*** 1,75 ****
- #include "EStopControllerBehavior.h"
- #include "Motion/EmergencyStopMC.h"
- #include "Motion/MMAccessor.h"
- 
- EStopControllerBehavior* EStopControllerBehavior::theOne = NULL;
- 
- void EStopControllerBehavior::DoStart() {
- 	// Behavior startup
- 	BehaviorBase::DoStart();
- 	// We listen to the estop
- 	erouter->addListener(this, EventBase::estopEGID);
- 	// Turn on wireless
- 	wireless->setReceiver(cmdsock->sock, callback);
- 	wireless->listen(cmdsock->sock, config->main.estopControl_port);
- }
- 
- void EStopControllerBehavior::DoStop() {
- 	// Turn off timers
- 	erouter->forgetListener(this);
- 	// Close socket; turn wireless off
- 	wireless->close(cmdsock);
- 	// Total behavior stop
- 	BehaviorBase::DoStop();
- }
- 
- void EStopControllerBehavior::runCommand(std::string s) {
- 	if(s==std::string("start")) {
- 		MMAccessor<EmergencyStopMC> estop(estop_id);
- 		estop->setStopped(false);
- 	} else if(s==std::string("stop")) {
- 		MMAccessor<EmergencyStopMC> estop(estop_id);
- 		estop->setStopped(true);
- 	} else if(s==std::string("refresh")) {
- 		MMAccessor<EmergencyStopMC> estop(estop_id);
- 		if(estop.checkin(estop->getStopped()))
- 			cmdsock->printf("on\n");
- 		else
- 			cmdsock->printf("off\n");
- 	} else {
- 		serr->printf("EStopControllerBehavior::runCommand() - bad message: '%s'",s.c_str());
- 	}
- }
- 
- void EStopControllerBehavior::processEvent(const EventBase & e) {
- 	if(e.getTypeID()==EventBase::activateETID) {
- 		cmdsock->printf("on\n");
- 	} else if(e.getTypeID()==EventBase::deactivateETID) {
- 		cmdsock->printf("off\n");
- 	}
- }
- 
- // The command packet reassembly mechanism
- int EStopControllerBehavior::callback(char *buf, int bytes) {
- 	static std::string cmd;
- 	for(int i=0; i<bytes; i++) {
- 		if(buf[i]=='\n') {
- 			EStopControllerBehavior::theOne->runCommand(cmd);
- 			cmd.clear();
- 		} else
- 			cmd+=buf[i];
- 	}
-   return 0;
- }
- 
- /*! @file
-  * @brief Implements EStopControllerBehavior, listens to commands coming in from the command port for remotely controlling toggling the estop
-  * @author tss (Creator)
-  * 
-  * $Author: ejt $
-  * $Name: HEAD $
-  * $Revision: 1.2 $
-  * $State: Exp $
-  * $Date: 2003/10/10 20:25:03 $
-  */
- 
--- 0 ----
Index: AiboPup/Behaviors/Demos/EStopControllerBehavior.h
diff -c AiboPup/Behaviors/Demos/EStopControllerBehavior.h:1.1 AiboPup/Behaviors/Demos/EStopControllerBehavior.h:removed
*** AiboPup/Behaviors/Demos/EStopControllerBehavior.h:1.1	Mon Jul  7 03:08:27 2003
--- AiboPup/Behaviors/Demos/EStopControllerBehavior.h	Fri Oct 10 14:37:43 2003
***************
*** 1,74 ****
- //-*-c++-*-
- #ifndef INCLUDED_EStopControllerBehavior_h_
- #define INCLUDED_EStopControllerBehavior_h_
- 
- #include <iostream>
- #include "Wireless/Wireless.h"
- #include "Behaviors/BehaviorBase.h"
- #include "Motion/MotionManager.h"
- #include "Events/EventRouter.h"
- #include "Events/EventBase.h"
- #include "Shared/Config.h"
- 
- //! Listens to control commands coming in from the command port for remotely controlling the head
- class EStopControllerBehavior : public BehaviorBase {
- 
- public:	
- 	//! Points to the one EStopControllerBehavior object that the input
- 	//! command stream is talking to. A kludge. Dunno how you're gonna
- 	//! make sure you're not using this uninitialized.
- 	static EStopControllerBehavior * theOne;
- 	static int callback(char *buf, int bytes); //!< called by wireless when there's new data
- 
- public:
- 	//! constructor
- 	EStopControllerBehavior(MotionManager::MC_ID estop)
- 		: BehaviorBase(),
- 			cmdsock(wireless->socket(SocketNS::SOCK_STREAM, 256, 256)),
- 			estop_id(estop)
- 	{
- 		theOne=this;
- 	}
- 	//! destructor
- 	virtual ~EStopControllerBehavior() { }
- 
- 	virtual void DoStart();
- 
- 	virtual void DoStop();
- 
- 	virtual void processEvent(const EventBase &);
- 
- 	virtual std::string getName() const { return "EStop Remote Control"; }
- 	static std::string getClassDescription() {
- 		char tmp[20];
- 		sprintf(tmp,"%d",config->main.estopControl_port);
- 		return std::string("Listens to estop commands coming in from port ")+tmp;
- 	}
- 
- 	virtual void runCommand(std::string s);
- 
- protected:
- 	//! The input command stream socket
- 	Socket *cmdsock;
- 
- 	//! The estop to control
- 	MotionManager::MC_ID estop_id;
- 
- private:
- 	EStopControllerBehavior(const EStopControllerBehavior&); //!< don't call
- 	EStopControllerBehavior operator=(const EStopControllerBehavior&); //!< don't call
- 
- };
- 
- /*! @file
-  * @brief Describes EStopControllerBehavior, listens to control commands coming in from the command port for remotely toggling the estop
-  * @author tss (Creator)
-  * 
-  * $Author: ejt $
-  * $Name: HEAD $
-  * $Revision: 1.2 $
-  * $State: Exp $
-  * $Date: 2003/10/10 20:25:03 $
-  */
- 
- #endif 
--- 0 ----
Index: AiboPup/Behaviors/Demos/EvtRptBehavior.cc
diff -c AiboPup/Behaviors/Demos/EvtRptBehavior.cc:1.1 AiboPup/Behaviors/Demos/EvtRptBehavior.cc:1.2
*** AiboPup/Behaviors/Demos/EvtRptBehavior.cc:1.1	Sat Mar  1 15:53:30 2003
--- AiboPup/Behaviors/Demos/EvtRptBehavior.cc	Thu Jul 31 23:01:31 2003
***************
*** 7,25 ****
  void EvtRptBehavior::DoStart() {
  	BehaviorBase::DoStart();
  	erouter->addListener(this,EventBase::locomotionEGID);
! 	erouter->addListener(this,EventBase::visionEGID,
! 				  VisionEventNS::MarkersSID);
! 
! 	vision->enableEvents(VisionEventNS::MarkersSID);
! 	//vision->enableEvents(VisionEventNS::RedBallSID);
! 	//vision->enableEvents(VisionEventNS::PinkBallSID);
  }
  
  void EvtRptBehavior::DoStop() {
- 	vision->disableEvents(VisionEventNS::MarkersSID);
- 	//vision->disableEvents(VisionEventNS::RedBallSID);
- 	//vision->disableEvents(VisionEventNS::PinkBallSID);
- 
  	erouter->forgetListener(this);
  	BehaviorBase::DoStop();
  }
--- 7,16 ----
  void EvtRptBehavior::DoStart() {
  	BehaviorBase::DoStart();
  	erouter->addListener(this,EventBase::locomotionEGID);
! 	erouter->addListener(this,EventBase::visionEGID,VisionEventNS::MarkersSID);
  }
  
  void EvtRptBehavior::DoStop() {
  	erouter->forgetListener(this);
  	BehaviorBase::DoStop();
  }
Index: AiboPup/Behaviors/Demos/ExploreMachine.h
diff -c /dev/null AiboPup/Behaviors/Demos/ExploreMachine.h:1.11
*** /dev/null	Fri Oct 10 14:37:43 2003
--- AiboPup/Behaviors/Demos/ExploreMachine.h	Fri Oct 10 13:46:01 2003
***************
*** 0 ****
--- 1,83 ----
+ //-*-c++-*-
+ #ifndef INCLUDED_ExploreMachine_h_
+ #define INCLUDED_ExploreMachine_h_
+ 
+ #include "Behaviors/StateNode.h"
+ #include "Behaviors/Nodes/WalkNode.h"
+ #include "Behaviors/Transitions/SmoothCompareTrans.h"
+ #include <stdlib.h>
+ 
+ //! A state machine for exploring an environment (or searching for an object)
+ class ExploreMachine : public StateNode {
+ public:
+ 	//!constructor
+ 	ExploreMachine(StateNode* p=NULL)
+ 		: StateNode("ExploreMachine",p), start(NULL), turn(NULL), walkid(MotionManager::invalid_MC_ID)
+ 	{
+ 		//setRetain(false);
+ 	}
+ 
+ 	virtual void setup() {
+ 		SharedObject<WalkMC> walk;
+ 		walkid=motman->addMotion(walk);
+ 		WalkNode * move=NULL;
+ 		start=addNode(turn=new WalkNode(0,0,0.5f,this));
+ 		turn->setName(getName()+"::turn");
+ 		addNode(move=new WalkNode(150,0,0,this));
+ 		move->setName(getName()+"::move");
+ 		turn->addTransition(new TimeOutTrans(turn,move,2000));
+ 		move->addTransition(new SmoothCompareTrans<float>(move,turn,&state->sensors[IRDistOffset],CompareTrans<float>::LT,350,EventBase(EventBase::sensorEGID,SensorSourceID::UpdatedSID,EventBase::statusETID),.7));
+ 		turn->setWalkID(walkid);
+ 		move->setWalkID(walkid);
+ 		StateNode::setup();
+ 	}
+ 
+ 	virtual void DoStart() {
+ 		StateNode::DoStart();
+ 		start->DoStart();
+ 		//erouter->addListener(this,EventBase::sensorEGID,SensorSourceID::UpdatedSID);
+ 		erouter->addListener(this,EventBase::stateMachineEGID,(unsigned int)turn);
+ 	}
+ 
+ 	virtual void DoStop() {
+ 		erouter->forgetListener(this);
+ 		StateNode::DoStop();
+ 	}
+ 
+ 	virtual void teardown() {
+ 		motman->removeMotion(walkid);
+ 		StateNode::teardown();
+ 	}
+ 
+ 	virtual void processEvent(const EventBase& /*e*/) {
+ 		sout->printf("IR: %g\n",state->sensors[IRDistOffset]);
+ 		float vel=rand()/(float)RAND_MAX*2.0f-1;
+ 		if(vel<0)
+ 			vel-=.25;
+ 		if(vel>0)
+ 			vel+=.25;
+ 		turn->setAVelocity(vel);
+ 	}
+ 
+ protected:
+ 	StateNode * start; //!< the node to begin within on DoStart() (turn)
+ 	WalkNode * turn; //!< walk node to use when turning
+ 	MotionManager::MC_ID walkid; //!< we want to share a walk between turning and walking nodes
+ 
+ private:
+ 	ExploreMachine(const ExploreMachine&); //!< don't use
+ 	ExploreMachine operator=(const ExploreMachine&); //!< don't use
+ };
+ 
+ /*! @file
+  * @brief Describes ExploreMachine, a state machine for exploring an environment (or searching for an object)
+  * @author ejt (Creator)
+  *
+  * $Author: ejt $
+  * $Name: HEAD $
+  * $Revision: 1.2 $
+  * $State: Exp $
+  * $Date: 2003/10/10 20:25:03 $
+  */
+ 
+ #endif
Index: AiboPup/Behaviors/Demos/FollowHeadBehavior.cc
diff -c AiboPup/Behaviors/Demos/FollowHeadBehavior.cc:1.3 AiboPup/Behaviors/Demos/FollowHeadBehavior.cc:1.4
*** AiboPup/Behaviors/Demos/FollowHeadBehavior.cc:1.3	Sat Mar  8 21:45:21 2003
--- AiboPup/Behaviors/Demos/FollowHeadBehavior.cc	Thu Sep 25 11:26:23 2003
***************
*** 74,81 ****
   *
   * $Author: ejt $
   * $Name $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 74,81 ----
   *
   * $Author: ejt $
   * $Name $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Behaviors/Demos/FollowHeadBehavior.h
diff -c AiboPup/Behaviors/Demos/FollowHeadBehavior.h:1.3 AiboPup/Behaviors/Demos/FollowHeadBehavior.h:1.4
*** AiboPup/Behaviors/Demos/FollowHeadBehavior.h:1.3	Thu Jun  5 13:03:15 2003
--- AiboPup/Behaviors/Demos/FollowHeadBehavior.h	Thu Sep 25 11:26:23 2003
***************
*** 54,63 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 54,63 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Demos/HeadLevelBehavior.h
diff -c AiboPup/Behaviors/Demos/HeadLevelBehavior.h:1.3 AiboPup/Behaviors/Demos/HeadLevelBehavior.h:1.4
*** AiboPup/Behaviors/Demos/HeadLevelBehavior.h:1.3	Thu Jun  5 13:03:15 2003
--- AiboPup/Behaviors/Demos/HeadLevelBehavior.h	Thu Sep 25 11:26:23 2003
***************
*** 68,77 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif 
--- 68,77 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif 
Index: AiboPup/Behaviors/Demos/HeadPointControllerBehavior.cc
diff -c AiboPup/Behaviors/Demos/HeadPointControllerBehavior.cc:1.1 AiboPup/Behaviors/Demos/HeadPointControllerBehavior.cc:removed
*** AiboPup/Behaviors/Demos/HeadPointControllerBehavior.cc:1.1	Sun Jul  6 21:00:08 2003
--- AiboPup/Behaviors/Demos/HeadPointControllerBehavior.cc	Fri Oct 10 14:37:43 2003
***************
*** 1,125 ****
- #include "HeadPointControllerBehavior.h"
- #include "Behaviors/Controller.h"
- #include "Motion/MMAccessor.h"
- 
- HeadPointControllerBehavior* HeadPointControllerBehavior::theOne = NULL;
- 
- void HeadPointControllerBehavior::runCommand(unsigned char *command) {
- 	// First, turn off the stop-if-no-heartbeat timer
- 	erouter->removeTimer(this);
- 
- 	// Extract the command parameter
- 	float param;
- 	unsigned char *paramp = (unsigned char *) &param;
- 
- 	paramp[0] = command[1];
- 	paramp[1] = command[2];
- 	paramp[2] = command[3];
- 	paramp[3] = command[4];
- 
- 	// Find out what type of command this is
- 	switch(command[0]) {
- 	case CMD_tilt:
- 		t = param*outputRanges[HeadOffset+TiltOffset][MaxRange];
- 		break;
- 	case CMD_pan:
- 		p = param*outputRanges[HeadOffset+PanOffset][MaxRange];
- 		break;
- 	case CMD_roll:
- 		r = param*outputRanges[HeadOffset+RollOffset][MaxRange];
- 		break;
- 	default:
- 		cout << "MECHA: unknown command " << command[0] << endl;
- 	}
- 
- 	// If the command was a new motion command, apply the
- 	// new motion parameters:
- 	switch(command[0]) {
- 	case CMD_tilt:
- 	case CMD_pan:
- 	case CMD_roll:
- 		{
- 			MMAccessor<HeadPointerMC> head(head_id);
- 			head->setJoints(t,p,r);
- 		}
- 	}
- 
- 	// Reset the stop-if-no-heartbeat timer -- if we don't
- 	// hear from the mothership in three seconds, stop immediately.
- 	erouter->addTimer(this, 0, 3000, false);
- }
- 
- void HeadPointControllerBehavior::DoStart() {
- 	// Behavior startup
- 	BehaviorBase::DoStart();
- 	// We listen to timers
- 	erouter->addListener(this, EventBase::timerEGID);
- 	// Enable head control
- 	head_id = motman->addMotion(SharedObject<HeadPointerMC>());
- 	// Turn on wireless
- 	wireless->setReceiver(cmdsock->sock, mechacmd_callback);
- 	wireless->listen(cmdsock->sock, config->main.headControl_port);
- 	// Open the WalkGUI on the desktop
- 	Controller::loadGUI("HeadPointGUI","HeadPointGUI",config->main.headControl_port);
- }
- 
- void HeadPointControllerBehavior::DoStop() {
- 	// Close the GUI
- 	Controller::closeGUI("HeadPointGUI");
- 	// Turn off timers
- 	erouter->forgetListener(this);
- 	// Close socket; turn wireless off
- 	wireless->close(cmdsock);
- 	// Disable head pointer
- 	motman->removeMotion(head_id);
- 	// Total behavior stop
- 	BehaviorBase::DoStop();
- }
- 
- // The command packet reassembly mechanism
- int HeadPointControllerBehavior::mechacmd_callback(char *buf, int bytes) {
-   static char cb_buf[5];
-   static int cb_buf_filled;
- 
-   // If there's an incomplete command in the command buffer, fill
-   // up as much of the command buffer as we can and then execute it
-   // if possible
-   if(cb_buf_filled) {
-     while((cb_buf_filled < 5) && bytes) {
-       cb_buf[cb_buf_filled++] = *buf++;	// copy incoming buffer byte
-       --bytes;				// decrement remaining byte ct.
-     }
-     // did we fill it? if so, execute! and mark buffer empty.
-     if(cb_buf_filled == 5) {
-       if(HeadPointControllerBehavior::theOne) HeadPointControllerBehavior::theOne->runCommand((unsigned char*) cb_buf);
-       cb_buf_filled = 0;
-     }
-   }
- 
-   // now execute all complete bytes in the incoming buffer
-   while(bytes >= 5) {
-     if(HeadPointControllerBehavior::theOne) HeadPointControllerBehavior::theOne->runCommand((unsigned char *) buf);
-     bytes -= 5;
-     buf += 5;
-   }
- 
-   // finally, store all remaining bytes in the command buffer
-   while(bytes) {
-     cb_buf[cb_buf_filled++] = *buf++;
-     --bytes;
-   }
- 
-   return 0;
- }
- 
- /*! @file
-  * @brief Implements HeadPointControllerBehavior, listens to control commands coming in from the command port for remotely controlling the head
-  * @author tss (Creator)
-  * 
-  * $Author: ejt $
-  * $Name: HEAD $
-  * $Revision: 1.2 $
-  * $State: Exp $
-  * $Date: 2003/10/10 20:25:03 $
-  */
- 
--- 0 ----
Index: AiboPup/Behaviors/Demos/HeadPointControllerBehavior.h
diff -c AiboPup/Behaviors/Demos/HeadPointControllerBehavior.h:1.1 AiboPup/Behaviors/Demos/HeadPointControllerBehavior.h:removed
*** AiboPup/Behaviors/Demos/HeadPointControllerBehavior.h:1.1	Sun Jul  6 21:00:08 2003
--- AiboPup/Behaviors/Demos/HeadPointControllerBehavior.h	Fri Oct 10 14:37:43 2003
***************
*** 1,92 ****
- //-*-c++-*-
- #ifndef INCLUDED_HeadPointControllerBehavior_h_
- #define INCLUDED_HeadPointControllerBehavior_h_
- 
- #include <iostream>
- #include "Wireless/Wireless.h"
- #include "Behaviors/BehaviorBase.h"
- #include "Motion/MotionManager.h"
- #include "Motion/HeadPointerMC.h"
- #include "Events/EventRouter.h"
- #include "Events/EventBase.h"
- #include "Shared/Config.h"
- 
- //! Listens to control commands coming in from the command port for remotely controlling the head
- class HeadPointControllerBehavior : public BehaviorBase {
- 
-  public:	
- 	//! Points to the one HeadPointControllerBehavior object that the input
- 	//! command stream is talking to. A kludge. Dunno how you're gonna
- 	//! make sure you're not using this uninitialized.
- 	static HeadPointControllerBehavior * theOne;
- 	static int mechacmd_callback(char *buf, int bytes); //!< called by wireless when there's new data
- 
-  protected:
- 	MotionManager::MC_ID head_id;   //!< the HeadPointerMC to use
-  
-  private:
- 	//!@name Command Bytes
- 	static const char CMD_tilt  = 't'; //!< handy symbol for matching incoming communication
- 	static const char CMD_pan   = 'p';
- 	static const char CMD_roll  = 'r';
- 	//@}
- 
- 	float t; //!< head parameter
- 	float p; //!< head parameter
- 	float r; //!< head parameter
- 
- 	//! The last HPCB object that was theOne, so we can restore it
- 	//! to prominence when we die. This is a nice gesture, but it doesn't
- 	//! really make sense since we're all using the same port. But just
- 	//! in case something changes and we don't do that, this mechanism
- 	//! is in place.
- 	HeadPointControllerBehavior *theLastOne;
- 
- 	//! The input command stream socket
- 	Socket *cmdsock;
- 
- 	//! Executes a command. Called by mechacmd_callback.
- 	void runCommand(unsigned char *command);
- 
- 	HeadPointControllerBehavior(const HeadPointControllerBehavior&); //!< don't call
- 	HeadPointControllerBehavior operator=(const HeadPointControllerBehavior&); //!< don't call
- 
-  public:
- 	//! constructor
- 	HeadPointControllerBehavior() :
- 	  BehaviorBase(),
- 	  head_id(MotionManager::invalid_MC_ID),
- 	  t(0), p(0), r(0),
- 	  theLastOne(theOne),
- 	  cmdsock(wireless->socket(SocketNS::SOCK_STREAM, 2048, 2048))
- 	{ theOne = this; }
- 	//! destructor
- 	virtual ~HeadPointControllerBehavior() { theOne = theLastOne; }
- 
- 	virtual void DoStart();
- 
- 	virtual void DoStop();
- 
- 	//! The only event we could possibly receive is the stop-if-no-heartbeat timer.
- 	virtual void processEvent(const EventBase &) {}
- 
- 	virtual std::string getName() const { return "Head Remote Control"; }
- 	static std::string getClassDescription() {
- 		char tmp[20];
- 		sprintf(tmp,"%d",config->main.headControl_port);
- 		return std::string("Listens to head control commands coming in from port ")+tmp;
- 	}
- };
- 
- /*! @file
-  * @brief Describes HeadPointControllerBehavior, listens to control commands coming in from the command port for remotely controlling the head
-  * @author tss (Creator)
-  * 
-  * $Author: ejt $
-  * $Name: HEAD $
-  * $Revision: 1.2 $
-  * $State: Exp $
-  * $Date: 2003/10/10 20:25:03 $
-  */
- 
- #endif 
--- 0 ----
Index: AiboPup/Behaviors/Demos/HelloWorldBehavior.h
diff -c /dev/null AiboPup/Behaviors/Demos/HelloWorldBehavior.h:1.4
*** /dev/null	Fri Oct 10 14:37:43 2003
--- AiboPup/Behaviors/Demos/HelloWorldBehavior.h	Mon Oct  6 20:59:33 2003
***************
*** 0 ****
--- 1,54 ----
+ //-*-c++-*-
+ #ifndef INCLUDED_HelloWorldBehavior_h_
+ #define INCLUDED_HelloWorldBehavior_h_
+ 
+ #include "Behaviors/BehaviorBase.h"
+ #include "Wireless/Wireless.h"
+ 
+ //! Demonstrates serr, sout, and cout
+ class HelloWorldBehavior : public BehaviorBase {
+ public:
+ 	HelloWorldBehavior() : BehaviorBase()	{}
+ 	
+ 	virtual void DoStart() {
+ 		//call superclass first for housekeeping:
+ 		BehaviorBase::DoStart();
+ 
+ 		//now do your code:
+ 		for(unsigned int i=0; i<100; i++)
+ 			serr->printf("Hello serr!  This is %d\n",i);
+ 		for(unsigned int i=0; i<10; i++)
+ 			sout->printf("Hello sout!  This is %d\n",i);
+ 		for(unsigned int i=0; i<10; i++)
+ 			cout << "Hello cout!  This is " << i << endl;
+ 		for(unsigned int i=0; i<10; i++)
+ 			printf("Hello printf!  This is %d\n",i);
+ 
+ 		//we'll just stop right away since this Behavior has no 'active' state.
+ 		DoStop();
+ 	}
+ 	
+ 	virtual std::string getName() const {
+ 		// Name is used for menus, or debugging.
+ 		return "HelloWorldBehavior";
+ 	}
+ 	
+ 	static std::string getClassDescription() {
+ 		// This string will be shown by the HelpControl or by the tooltips of the Controller GUI
+ 		return "A little demo of text output";
+ 	}
+ 	
+ };
+ 
+ /*! @file
+  * @brief Defines HelloWorldBehavior, a little demo of text output (serr, sout, and cout)
+  * @author ejt (Creator)
+  *
+  * $Author: ejt $
+  * $Name: HEAD $
+  * $Revision: 1.2 $
+  * $State: Exp $
+  * $Date: 2003/10/10 20:25:03 $
+  */
+ 
+ #endif
Index: AiboPup/Behaviors/Demos/SimpleChaseBallBehavior.h
diff -c AiboPup/Behaviors/Demos/SimpleChaseBallBehavior.h:1.3 AiboPup/Behaviors/Demos/SimpleChaseBallBehavior.h:1.4
*** AiboPup/Behaviors/Demos/SimpleChaseBallBehavior.h:1.3	Thu Jun 12 14:06:11 2003
--- AiboPup/Behaviors/Demos/SimpleChaseBallBehavior.h	Mon Jul 28 14:39:18 2003
***************
*** 30,39 ****
  		BehaviorBase::DoStart();
  		walker_id = motman->addMotion(SharedObject<WalkMC>());
  		erouter->addListener(this,EventBase::visionEGID);
- 		// in the near future, these two will be unnecessary.
- 		// (vision will use erouter to check if it has listeners)
- 		vision->enableEvents(VisionEventNS::RedBallSID);
- 		vision->enableEvents(VisionEventNS::PinkBallSID);
  	}
  
  	//! removes motion commands and stops listening
--- 30,35 ----
***************
*** 65,74 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 61,70 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Demos/SoundTestBehavior.h
diff -c AiboPup/Behaviors/Demos/SoundTestBehavior.h:1.8 AiboPup/Behaviors/Demos/SoundTestBehavior.h:1.9
*** AiboPup/Behaviors/Demos/SoundTestBehavior.h:1.8	Thu Jun  5 13:03:15 2003
--- AiboPup/Behaviors/Demos/SoundTestBehavior.h	Thu Sep 25 11:26:23 2003
***************
*** 109,118 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 109,118 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Demos/StareAtBallBehavior.cc
diff -c AiboPup/Behaviors/Demos/StareAtBallBehavior.cc:1.2 AiboPup/Behaviors/Demos/StareAtBallBehavior.cc:1.3
*** AiboPup/Behaviors/Demos/StareAtBallBehavior.cc:1.2	Sat Mar  8 21:45:21 2003
--- AiboPup/Behaviors/Demos/StareAtBallBehavior.cc	Thu Jul 31 23:01:31 2003
***************
*** 12,24 ****
  	BehaviorBase::DoStart();
  	headpointer_id = motman->addMotion(SharedObject<HeadPointerMC>());
  	erouter->addListener(this,EventBase::visionEGID);
-   vision->enableEvents(VisionEventNS::RedBallSID);
-   vision->enableEvents(VisionEventNS::PinkBallSID);
  }
  
  void StareAtBallBehavior::DoStop() {
-   vision->disableEvents(VisionEventNS::RedBallSID);
-   vision->disableEvents(VisionEventNS::PinkBallSID);
  	erouter->forgetListener(this);
  	motman->removeMotion(headpointer_id);
  	BehaviorBase::DoStop();
--- 12,20 ----
Index: AiboPup/Behaviors/Demos/StareAtBallBehavior.h
diff -c AiboPup/Behaviors/Demos/StareAtBallBehavior.h:1.3 AiboPup/Behaviors/Demos/StareAtBallBehavior.h:1.4
*** AiboPup/Behaviors/Demos/StareAtBallBehavior.h:1.3	Thu Jun  5 13:03:15 2003
--- AiboPup/Behaviors/Demos/StareAtBallBehavior.h	Thu Sep 25 11:26:23 2003
***************
*** 36,45 ****
   * @author tss (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 36,45 ----
   * @author tss (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Demos/ToggleHeadLightBehavior.h
diff -c AiboPup/Behaviors/Demos/ToggleHeadLightBehavior.h:1.1 AiboPup/Behaviors/Demos/ToggleHeadLightBehavior.h:1.2
*** AiboPup/Behaviors/Demos/ToggleHeadLightBehavior.h:1.1	Sat Jun 28 14:03:57 2003
--- AiboPup/Behaviors/Demos/ToggleHeadLightBehavior.h	Tue Sep  2 16:58:49 2003
***************
*** 32,38 ****
  	std::string getName() const { return "ToggleHeadLightBehavior"; }
  
  protected:
! 	MotionManager::MC_ID light_id;
  };
  
  /*! @file
--- 32,38 ----
  	std::string getName() const { return "ToggleHeadLightBehavior"; }
  
  protected:
! 	MotionManager::MC_ID light_id; //!< id value of the PostureMC used to control the light
  };
  
  /*! @file
***************
*** 40,49 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 40,49 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Demos/WalkControllerBehavior.cc
diff -c AiboPup/Behaviors/Demos/WalkControllerBehavior.cc:1.1 AiboPup/Behaviors/Demos/WalkControllerBehavior.cc:removed
*** AiboPup/Behaviors/Demos/WalkControllerBehavior.cc:1.1	Sun Jul  6 21:00:08 2003
--- AiboPup/Behaviors/Demos/WalkControllerBehavior.cc	Fri Oct 10 14:37:43 2003
***************
*** 1,154 ****
- #include "WalkControllerBehavior.h"
- #include "Behaviors/Controller.h"
- 
- WalkControllerBehavior* WalkControllerBehavior::theOne = NULL;
- 
- void WalkControllerBehavior::runCommand(unsigned char *command) {
- 	// First, turn off the stop-if-no-heartbeat timer
- 	erouter->removeTimer(this);
- 
- 	// Extract the command parameter
- 	float param;
- 	unsigned char *paramp = (unsigned char *) &param;
- 
- 	paramp[0] = command[1];
- 	paramp[1] = command[2];
- 	paramp[2] = command[3];
- 	paramp[3] = command[4];
- 
- 	// Find out what type of command this is
- 	switch(command[0]) {
- 	case CMD_fwd:
- 		dx = param;
- 		break;
- 	case CMD_roto:
- 		da = param;
- 		break;
- 	case CMD_side:
- 		dy = param;
- 		break;
- 	case CMD_opt0:
- 		{
- 			/*			HeadPointerMC *head =
- 				(HeadPointerMC*)motman->checkoutMotion(head_id);
- 			head->setJoints(0,0,0);
- 			motman->checkinMotion(head_id);*/
- 			break;
- 		}
- 	case CMD_opt1:
- 	case CMD_opt2:
- 	case CMD_opt3:
- 	case CMD_opt4:
- 		cout << "MECHA: hey, reprogram this button!" << endl;
- 		break;
- 	case CMD_opt5:
- 		sndman->PlayFile("howl.wav");
- 		break;
- 	case CMD_opt6:
- 		sndman->PlayFile("yap.wav");
- 		break;
- 	case CMD_opt7:
- 		sndman->PlayFile("whimper.wav");
- 		break;
- 	case CMD_opt8:
- 		sndman->PlayFile("growl.wav");
- 		break;
- 	case CMD_opt9:
- 		sndman->PlayFile("barkmed.wav");
- 		break;
- 		// The options button commands.
- 	default:
- 		cout << "MECHA: unknown command " << command[0] << endl;
- 	}
- 
- 	// If the command was a new motion command, apply the
- 	// new motion parameters:
- 	switch(command[0]) {
- 	case CMD_fwd:
- 	case CMD_roto:
- 	case CMD_side:
- 		{
- 			MMAccessor<WalkMC> walker(walker_id);
- 			walker->setTargetVelocity(dx,dy,da);
- 		}
- 	}
- 
- 	// Reset the stop-if-no-heartbeat timer -- if we don't
- 	// hear from the mothership in three seconds, stop immediately.
- 	erouter->addTimer(this, 0, 3000, false);
- }
- 
- void WalkControllerBehavior::DoStart() {
- 	// Behavior startup
- 	BehaviorBase::DoStart();
- 	// We listen to timers
- 	erouter->addListener(this, EventBase::timerEGID);
- 	// Enable walker
- 	walker_id = motman->addMotion(SharedObject<WalkMC>());
- 	// Turn on wireless
- 	wireless->setReceiver(cmdsock->sock, mechacmd_callback);
- 	wireless->listen(cmdsock->sock, config->main.walkControl_port);
- 	// Open the WalkGUI on the desktop
- 	Controller::loadGUI("WalkGUI","WalkGUI",config->main.walkControl_port);
- }
- 
- void WalkControllerBehavior::DoStop() {
- 	// Close the GUI
- 	Controller::closeGUI("WalkGUI");
- 	// Turn off timers
- 	erouter->forgetListener(this);
- 	// Close socket; turn wireless off
- 	wireless->close(cmdsock);
- 	// Disable walker
- 	motman->removeMotion(walker_id);
- 	// Total behavior stop
- 	BehaviorBase::DoStop();
- }
- 
- // The command packet reassembly mechanism
- int WalkControllerBehavior::mechacmd_callback(char *buf, int bytes) {
-   static char cb_buf[5];
-   static int cb_buf_filled;
- 
-   // If there's an incomplete command in the command buffer, fill
-   // up as much of the command buffer as we can and then execute it
-   // if possible
-   if(cb_buf_filled) {
-     while((cb_buf_filled < 5) && bytes) {
-       cb_buf[cb_buf_filled++] = *buf++;	// copy incoming buffer byte
-       --bytes;				// decrement remaining byte ct.
-     }
-     // did we fill it? if so, execute! and mark buffer empty.
-     if(cb_buf_filled == 5) {
-       if(WalkControllerBehavior::theOne) WalkControllerBehavior::theOne->runCommand((unsigned char*) cb_buf);
-       cb_buf_filled = 0;
-     }
-   }
- 
-   // now execute all complete bytes in the incoming buffer
-   while(bytes >= 5) {
-     if(WalkControllerBehavior::theOne) WalkControllerBehavior::theOne->runCommand((unsigned char *) buf);
-     bytes -= 5;
-     buf += 5;
-   }
- 
-   // finally, store all remaining bytes in the command buffer
-   while(bytes) {
-     cb_buf[cb_buf_filled++] = *buf++;
-     --bytes;
-   }
- 
-   return 0;
- }
- 
- /*! @file
-  * @brief Implements WalkControllerBehavior, listens to mecha control commands coming in from the command port for remotely controlling the walk
-  * @author tss (Creator)
-  * 
-  * $Author: ejt $
-  * $Name: HEAD $
-  * $Revision: 1.2 $
-  * $State: Exp $
-  * $Date: 2003/10/10 20:25:03 $
-  */
- 
--- 0 ----
Index: AiboPup/Behaviors/Demos/WalkControllerBehavior.h
diff -c AiboPup/Behaviors/Demos/WalkControllerBehavior.h:1.1 AiboPup/Behaviors/Demos/WalkControllerBehavior.h:removed
*** AiboPup/Behaviors/Demos/WalkControllerBehavior.h:1.1	Sun Jul  6 21:00:08 2003
--- AiboPup/Behaviors/Demos/WalkControllerBehavior.h	Fri Oct 10 14:37:43 2003
***************
*** 1,107 ****
- //-*-c++-*-
- #ifndef INCLUDED_WalkControllerBehavior_h_
- #define INCLUDED_WalkControllerBehavior_h_
- 
- #include <iostream>
- #include "Wireless/Wireless.h"
- #include "Behaviors/BehaviorBase.h"
- #include "Motion/MotionManager.h"
- #include "Motion/WalkMC.h"
- #include "Motion/MMAccessor.h"
- #include "Events/EventRouter.h"
- #include "Events/EventBase.h"
- #include "SoundPlay/SoundManager.h"
- #include "Shared/Config.h"
- 
- //! Listens to control commands coming in from the command port for remotely controlling the walk
- class WalkControllerBehavior : public BehaviorBase {
- 
-  public:	
- 	//! Points to the one WalkControllerBehavior object that the input
- 	//! command stream is talking to. A kludge. Dunno how you're gonna
- 	//! make sure you're not using this uninitialized.
- 	static WalkControllerBehavior * theOne;
- 	static int mechacmd_callback(char *buf, int bytes); //!< called by wireless when there's new data
- 
-  protected:
- 	MotionManager::MC_ID walker_id; //!< the WalkMC to use
-  
-  private:
- 	//!@name Command Bytes
- 	static const char CMD_fwd  = 'f'; //!< handy symbol for matching incoming communication
- 	static const char CMD_roto = 'r';
- 	static const char CMD_side = 's';
- 	static const char CMD_opt0 = '0';
- 	static const char CMD_opt1 = '1';
- 	static const char CMD_opt2 = '2';
- 	static const char CMD_opt3 = '3';
- 	static const char CMD_opt4 = '4';
- 	static const char CMD_opt5 = '5';
- 	static const char CMD_opt6 = '6';
- 	static const char CMD_opt7 = '7';
- 	static const char CMD_opt8 = '8';
- 	static const char CMD_opt9 = '9';
- 	//@}
- 
- 	float dx; //!< Motion parameter
- 	float dy; //!< Motion parameter
- 	float da; //!< Motion parameter
- 
- 	//! The last WCB object that was theOne, so we can restore it
- 	//! to prominence when we die. This is a nice gesture, but it doesn't
- 	//! really make sense since we're all using the same port. But just
- 	//! in case something changes and we don't do that, this mechanism
- 	//! is in place.
- 	WalkControllerBehavior *theLastOne;
- 
- 	//! The input command stream socket
- 	Socket *cmdsock;
- 
- 	//! Executes a command. Called by mechacmd_callback.
- 	void runCommand(unsigned char *command);
- 
- 	WalkControllerBehavior(const WalkControllerBehavior&); //!< don't call
- 	WalkControllerBehavior operator=(const WalkControllerBehavior&); //!< don't call
- 
-  public:
- 	//! constructor
- 	WalkControllerBehavior() :
- 	  BehaviorBase(),
- 	  walker_id(MotionManager::invalid_MC_ID),
- 	  dx(0), dy(0), da(0),
- 	  theLastOne(theOne),
- 	  cmdsock(wireless->socket(SocketNS::SOCK_STREAM, 2048, 2048))
- 	{ theOne = this; }
- 	//! destructor
- 	virtual ~WalkControllerBehavior() { theOne = theLastOne; }
- 
- 	virtual void DoStart();
- 
- 	virtual void DoStop();
- 
- 	//! The only event we could possibly receive is the stop-if-no-heartbeat timer.
- 	virtual void processEvent(const EventBase &) {
- 		MMAccessor<WalkMC> walker(walker_id);
- 		walker->setTargetVelocity(0,0,0);
- 	}
- 
- 	virtual std::string getName() const { return "Walk Remote Control"; }
- 	static std::string getClassDescription() {
- 		char tmp[20];
- 		sprintf(tmp,"%d",config->main.walkControl_port);
- 		return std::string("Listens to walk control commands coming in from port ")+tmp;
- 	}
- };
- 
- /*! @file
-  * @brief Describes WalkControllerBehavior, listens to control commands coming in from the command port for remotely controlling the walk
-  * @author tss (Creator)
-  * 
-  * $Author: ejt $
-  * $Name: HEAD $
-  * $Revision: 1.2 $
-  * $State: Exp $
-  * $Date: 2003/10/10 20:25:03 $
-  */
- 
- #endif 
--- 0 ----
Index: AiboPup/Behaviors/Demos/WalkToTargetMachine.cc
diff -c AiboPup/Behaviors/Demos/WalkToTargetMachine.cc:1.2 AiboPup/Behaviors/Demos/WalkToTargetMachine.cc:1.6
*** AiboPup/Behaviors/Demos/WalkToTargetMachine.cc:1.2	Sat Mar  8 21:45:21 2003
--- AiboPup/Behaviors/Demos/WalkToTargetMachine.cc	Thu Sep 25 11:26:23 2003
***************
*** 8,13 ****
--- 8,14 ----
  inline double DtoR(double deg) { return (deg/180.0*M_PI); }
  
  void WalkToTargetMachine::setup() {
+ 	StateNode::setup();
  	if(close!=NULL)
  		addTransition(new VisualTargetCloseTrans(this,close,tracking));
  	if(lost!=NULL)
***************
*** 20,30 ****
  	headpointer_id = motman->addMotion(SharedObject<HeadPointerMC>());
  	walker_id = motman->addMotion(SharedObject<WalkMC>());
  	erouter->addListener(this,EventBase::visionEGID,tracking);
-   vision->enableEvents(tracking);
  }
  
  void WalkToTargetMachine::DoStop() {
-   vision->disableEvents(tracking);
  	erouter->forgetListener(this);
  	motman->removeMotion(headpointer_id);
  	motman->removeMotion(walker_id);
--- 21,29 ----
***************
*** 43,60 ****
  	} else
  		return;
  
! 	//		cout << inview << ' ' << horiz << ' ' << vert << endl;
  
  	double tilt=state->outputs[HeadOffset+TiltOffset]-vert*M_PI/6;
  	double pan=state->outputs[HeadOffset+PanOffset]-horiz*M_PI/7.5;
! 	if(tilt<DtoR(-20))
! 		tilt=DtoR(-20);
! 	if(tilt>DtoR(70))
! 		tilt=DtoR(70);
! 	if(pan>DtoR(80))
! 		pan=DtoR(80);
! 	if(pan<DtoR(-80))
! 		pan=DtoR(-80);
  	HeadPointerMC * headpointer= (HeadPointerMC*)motman->checkoutMotion(headpointer_id);
  	headpointer->setJoints(tilt,pan,0);
  	motman->checkinMotion(headpointer_id);
--- 42,59 ----
  	} else
  		return;
  
! 	//cout << "Pos: " << horiz << ' ' << vert << endl;
  
  	double tilt=state->outputs[HeadOffset+TiltOffset]-vert*M_PI/6;
  	double pan=state->outputs[HeadOffset+PanOffset]-horiz*M_PI/7.5;
! 	if(tilt>outputRanges[HeadOffset+TiltOffset][MaxRange])
! 		tilt=outputRanges[HeadOffset+TiltOffset][MaxRange];
! 	if(tilt<outputRanges[HeadOffset+TiltOffset][MinRange]*3/4)
! 		tilt=outputRanges[HeadOffset+TiltOffset][MinRange]*3/4;
! 	if(pan>outputRanges[HeadOffset+PanOffset][MaxRange]*2/3)
! 		pan=outputRanges[HeadOffset+PanOffset][MaxRange]*2/3;
! 	if(pan<outputRanges[HeadOffset+PanOffset][MinRange]*2/3)
! 		pan=outputRanges[HeadOffset+PanOffset][MinRange]*2/3;
  	HeadPointerMC * headpointer= (HeadPointerMC*)motman->checkoutMotion(headpointer_id);
  	headpointer->setJoints(tilt,pan,0);
  	motman->checkinMotion(headpointer_id);
***************
*** 72,80 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 71,79 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Behaviors/Demos/WalkToTargetMachine.h
diff -c AiboPup/Behaviors/Demos/WalkToTargetMachine.h:1.3 AiboPup/Behaviors/Demos/WalkToTargetMachine.h:1.6
*** AiboPup/Behaviors/Demos/WalkToTargetMachine.h:1.3	Thu Jun  5 13:03:15 2003
--- AiboPup/Behaviors/Demos/WalkToTargetMachine.h	Fri Sep 12 17:37:48 2003
***************
*** 10,16 ****
  //! a state machine for walking towards a visual target
  class WalkToTargetMachine : public StateNode {
  public:
! 	//!constructor, pass parent, success and failure nodes, and VisionSourceID_t
  	WalkToTargetMachine(VisionEventNS::VisionSourceID_t obj,StateNode* c=NULL, StateNode* l=NULL,StateNode* p=NULL)
  		: StateNode("WalkToTarget",p),tracking(obj),timeout(NULL),close(c),lost(l),
  			walker_id(MotionManager::invalid_MC_ID), headpointer_id(MotionManager::invalid_MC_ID) 
--- 10,16 ----
  //! a state machine for walking towards a visual target
  class WalkToTargetMachine : public StateNode {
  public:
! 	//!constructor, pass success (close), failure (lost), and parent nodes, and VisionSourceID_t
  	WalkToTargetMachine(VisionEventNS::VisionSourceID_t obj,StateNode* c=NULL, StateNode* l=NULL,StateNode* p=NULL)
  		: StateNode("WalkToTarget",p),tracking(obj),timeout(NULL),close(c),lost(l),
  			walker_id(MotionManager::invalid_MC_ID), headpointer_id(MotionManager::invalid_MC_ID) 
***************
*** 21,30 ****
  	virtual void DoStart();
  	virtual void DoStop();
  
! 	static std::string getClassDescription() { return "INCOMPLETE: walks towards a visual target until it gets \"close\""; }
  
  	//uses head to watch ball, walks towards it
! 	virtual void processEvent(const EventBase&);
  	
  
  protected:
--- 21,30 ----
  	virtual void DoStart();
  	virtual void DoStop();
  
! 	static std::string getClassDescription() { return "walks towards a visual target until it gets \"close\""; }
  
  	//uses head to watch ball, walks towards it
! 	virtual void processEvent(const EventBase& event);
  	
  
  protected:
***************
*** 45,54 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 45,54 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Demos/WorldModel2Behavior.cc
diff -c AiboPup/Behaviors/Demos/WorldModel2Behavior.cc:1.7 AiboPup/Behaviors/Demos/WorldModel2Behavior.cc:1.8
*** AiboPup/Behaviors/Demos/WorldModel2Behavior.cc:1.7	Mon Jun  9 20:53:48 2003
--- AiboPup/Behaviors/Demos/WorldModel2Behavior.cc	Fri Jul 25 16:18:05 2003
***************
*** 6,13 ****
  
  #include "WorldModel2Behavior.h"
  
! #include "StateNode.h"
! #include "Transitions/TimeOutTrans.h"
  #include "Motion/MotionManager.h"
  #include "Motion/WalkMC.h"
  #include "Motion/HeadPointerMC.h"
--- 6,13 ----
  
  #include "WorldModel2Behavior.h"
  
! #include "Behaviors/StateNode.h"
! #include "Behaviors/Transitions/TimeOutTrans.h"
  #include "Motion/MotionManager.h"
  #include "Motion/WalkMC.h"
  #include "Motion/HeadPointerMC.h"
Index: AiboPup/Behaviors/Demos/karmedbandit.h
diff -c AiboPup/Behaviors/Demos/karmedbandit.h:1.2 AiboPup/Behaviors/Demos/karmedbandit.h:1.3
*** AiboPup/Behaviors/Demos/karmedbandit.h:1.2	Sun Mar  2 20:18:12 2003
--- AiboPup/Behaviors/Demos/karmedbandit.h	Thu Sep 18 18:40:27 2003
***************
*** 5,10 ****
--- 5,11 ----
  #include <vector>
  #include <iostream>
  #include <stdlib.h>
+ #include <math.h>
  
  //!Makes decisions regarding an adversarial k-armed bandit
  /*! Uses algorithms described in:
***************
*** 112,119 ****
  	void restart() {
  		std::cout << "Exp3 restart, g=" << std::flush;
  		unsigned int k=exp3.getK();
! 		gr=(k*log(k))/(M_E-1)*pow(4,r);
! 		double gammap=sqrt(k*log(k)/(M_E-1)/gr);
  		//		exp3.reset(); //not sure if we're supposed to do this
  		exp3.setGamma(gammap<1?gammap:1);
  		std::cout << (gammap<1?gammap:1) << std::endl;
--- 113,120 ----
  	void restart() {
  		std::cout << "Exp3 restart, g=" << std::flush;
  		unsigned int k=exp3.getK();
! 		gr=(k*log((double)k))/(M_E-1)*pow(4.0,(double)r);
! 		double gammap=sqrt(k*log((double)k)/(M_E-1)/gr);
  		//		exp3.reset(); //not sure if we're supposed to do this
  		exp3.setGamma(gammap<1?gammap:1);
  		std::cout << (gammap<1?gammap:1) << std::endl;
***************
*** 130,140 ****
   * @brief Defines karmedbandit - implements an algorithm which makes decisions regarding an adversarial k-armed bandit
   * @author ejt (Creator)
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 131,141 ----
   * @brief Defines karmedbandit - implements an algorithm which makes decisions regarding an adversarial k-armed bandit
   * @author ejt (Creator)
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Mon/Aibo3DControllerBehavior.h
diff -c /dev/null AiboPup/Behaviors/Mon/Aibo3DControllerBehavior.h:1.1
*** /dev/null	Fri Oct 10 14:37:43 2003
--- AiboPup/Behaviors/Mon/Aibo3DControllerBehavior.h	Thu Oct  9 20:45:01 2003
***************
*** 0 ****
--- 1,136 ----
+ //-*-c++-*-
+ #ifndef INCLUDED_Aibo3DControllerBehavior_h_
+ #define INCLUDED_Aibo3DControllerBehavior_h_
+ 
+ #include <iostream>
+ #include "Wireless/Wireless.h"
+ #include "Behaviors/BehaviorBase.h"
+ #include "Motion/MotionManager.h"
+ #include "Motion/RemoteControllerMC.h"
+ #include "Events/EventRouter.h"
+ #include "Events/EventBase.h"
+ #include "Shared/RobotInfo.h"
+ #include "Behaviors/Controller.h"
+ #include "Shared/WorldState.h"
+ 
+ //! gets input from the GUI
+ int aibo3dcontrollercmd_callback(char *buf, int bytes);
+ class Aibo3DControllerBehavior;
+ 
+ //! so aibo3dcontrollercmd_callback knows where to send the input from the GUI
+ Aibo3DControllerBehavior *aibo3dControllerBehavior = NULL;
+ 
+   
+ //! Listens to aibo3d control commands coming in from the command port.
+ class Aibo3DControllerBehavior : public BehaviorBase {
+  protected:
+ 	MotionManager::MC_ID rcontrol_id; //!< remote controller motion command's id
+  
+ 	//! The input command stream socket
+ 	Socket *cmdsock;
+ 
+   float val[NumPIDJoints]; //!< the value to use for each of the PID joints
+   char *fbuf;  //!< alias to val
+   unsigned int pos; //!< a counter to know when we've gotten 4 frames
+ 
+  private:
+ 	Aibo3DControllerBehavior(const Aibo3DControllerBehavior&); //!< don't call
+ 	Aibo3DControllerBehavior operator=(const Aibo3DControllerBehavior&); //!< don't call
+ 
+  public:
+ 	//! constructor
+ 	Aibo3DControllerBehavior() :
+ 	  BehaviorBase(),
+ 	  rcontrol_id(MotionManager::invalid_MC_ID),
+ 	  cmdsock(wireless->socket(SocketNS::SOCK_STREAM, 2048, 2048)),
+     fbuf((char*)val), pos(0)
+ 	{ wireless->setDaemon(cmdsock);
+     aibo3dControllerBehavior = this; }
+ 	//! destructor
+ 	virtual ~Aibo3DControllerBehavior() { aibo3dControllerBehavior = NULL; }
+ 
+ 	//! processes input from the GUI
+   int registerData(char *buf, int bytes) {
+     int read=0;
+     while (read<bytes) {
+       fbuf[pos]=buf[read];
+ 			pos++;
+ 			read++;
+       if (pos==NumPIDJoints*sizeof(float)) {
+ 				updateRC();
+ 				pos=0;
+ 			}
+     }
+     return read;
+   }
+ 
+ 	void updateRC() {
+ 		RemoteControllerMC *rcontrol = (RemoteControllerMC*)motman->checkoutMotion(rcontrol_id);
+ 		for (unsigned int i=0; i<NumPIDJoints; i++)
+ 			rcontrol->cmds[i]=val[i];
+ 		rcontrol->setDirty();
+ 		motman->checkinMotion(rcontrol_id);
+ 	}
+ 	
+ 	virtual void DoStart() {
+ 		// Behavior startup
+ 		BehaviorBase::DoStart();
+ 		for(unsigned int i=0; i<NumPIDJoints; i++)
+ 			val[i]=state->outputs[i];
+ 		// Enable remote control stream
+ 		rcontrol_id = motman->addMotion(SharedObject<RemoteControllerMC>());
+ 		updateRC();
+ 		// Turn on wireless
+ 		wireless->setReceiver(cmdsock->sock, aibo3dcontrollercmd_callback);
+ 		wireless->listen(cmdsock->sock, config->main.aibo3d_port);
+ 		// open gui
+ 		/*		std::vector<std::string> tmp;
+ 					tmp.push_back("Aibo3D Load Instructions");
+ 					tmp.push_back("To load Aibo3D, you will need to install java3d\nand then run Tekkotsu/tools/aibo3d/");
+ 					tmp.back()+=getGUIType();
+ 					Controller::loadGUI("ControllerMsg","LoadAibo3d",getPort(),tmp);*/
+ 		Controller::loadGUI(getGUIType(),getGUIType(),getPort());
+ 	}
+ 
+ 	virtual void DoStop() {
+ 		Controller::closeGUI(getGUIType());
+ 		// Close socket; turn wireless off
+ 		wireless->close(cmdsock);
+ 		// Disable remote control
+ 		motman->removeMotion(rcontrol_id);
+ 		// Total behavior stop
+ 		BehaviorBase::DoStop();
+ 	}
+ 
+ 	//! returns string corresponding to the Java GUI which should be launched
+ 	virtual std::string getGUIType() const { return "org.tekkotsu.aibo3d.Aibo3DPick"; }
+ 	//! returns port number the Java GUI should connect to
+ 	virtual unsigned int getPort() const { return config->main.aibo3d_port; }
+ 
+ 	virtual std::string getName() const { return "Aibo 3D"; } //!< returns name of behavior
+ 	static std::string getClassDescription() { 
+ 		char tmp[20];
+ 		sprintf(tmp,"%d",config->main.aibo3d_port);
+ 		return std::string("Listens to aibo3d control commands coming in from port ")+tmp;
+ 	}
+ };
+ 
+ 
+ int aibo3dcontrollercmd_callback(char *buf, int bytes) {
+   if (aibo3dControllerBehavior!=NULL)
+     return aibo3dControllerBehavior->registerData(buf, bytes);
+   return 0;
+ }
+ 
+ /*! @file
+  * @brief Defines Aibo3DControllerBehavior, which listens to commands from the Aibo3D gui and shows current state
+  * @author alokl (Creator)
+  *
+  * $Author: ejt $
+  * $Name: HEAD $
+  * $Revision: 1.2 $
+  * $State: Exp $
+  * $Date: 2003/10/10 20:25:03 $
+  */
+ 
+ #endif 
Index: AiboPup/Behaviors/Mon/EStopControllerBehavior.cc
diff -c /dev/null AiboPup/Behaviors/Mon/EStopControllerBehavior.cc:1.1
*** /dev/null	Fri Oct 10 14:37:43 2003
--- AiboPup/Behaviors/Mon/EStopControllerBehavior.cc	Thu Oct  9 20:45:01 2003
***************
*** 0 ****
--- 1,75 ----
+ #include "EStopControllerBehavior.h"
+ #include "Motion/EmergencyStopMC.h"
+ #include "Motion/MMAccessor.h"
+ 
+ EStopControllerBehavior* EStopControllerBehavior::theOne = NULL;
+ 
+ void EStopControllerBehavior::DoStart() {
+ 	// Behavior startup
+ 	BehaviorBase::DoStart();
+ 	// We listen to the estop
+ 	erouter->addListener(this, EventBase::estopEGID);
+ 	// Turn on wireless
+ 	wireless->setReceiver(cmdsock->sock, callback);
+ 	wireless->listen(cmdsock->sock, config->main.estopControl_port);
+ }
+ 
+ void EStopControllerBehavior::DoStop() {
+ 	// Turn off timers
+ 	erouter->forgetListener(this);
+ 	// Close socket; turn wireless off
+ 	wireless->close(cmdsock);
+ 	// Total behavior stop
+ 	BehaviorBase::DoStop();
+ }
+ 
+ void EStopControllerBehavior::runCommand(std::string s) {
+ 	if(s==std::string("start")) {
+ 		MMAccessor<EmergencyStopMC> estop(estop_id);
+ 		estop->setStopped(false);
+ 	} else if(s==std::string("stop")) {
+ 		MMAccessor<EmergencyStopMC> estop(estop_id);
+ 		estop->setStopped(true);
+ 	} else if(s==std::string("refresh")) {
+ 		MMAccessor<EmergencyStopMC> estop(estop_id);
+ 		if(estop.checkin(estop->getStopped()))
+ 			cmdsock->printf("on\n");
+ 		else
+ 			cmdsock->printf("off\n");
+ 	} else {
+ 		serr->printf("EStopControllerBehavior::runCommand() - bad message: '%s'",s.c_str());
+ 	}
+ }
+ 
+ void EStopControllerBehavior::processEvent(const EventBase & e) {
+ 	if(e.getTypeID()==EventBase::activateETID) {
+ 		cmdsock->printf("on\n");
+ 	} else if(e.getTypeID()==EventBase::deactivateETID) {
+ 		cmdsock->printf("off\n");
+ 	}
+ }
+ 
+ // The command packet reassembly mechanism
+ int EStopControllerBehavior::callback(char *buf, int bytes) {
+ 	static std::string cmd;
+ 	for(int i=0; i<bytes; i++) {
+ 		if(buf[i]=='\n') {
+ 			EStopControllerBehavior::theOne->runCommand(cmd);
+ 			cmd.clear();
+ 		} else
+ 			cmd+=buf[i];
+ 	}
+   return 0;
+ }
+ 
+ /*! @file
+  * @brief Implements EStopControllerBehavior, listens to commands coming in from the command port for remotely controlling toggling the estop
+  * @author tss (Creator)
+  * 
+  * $Author: ejt $
+  * $Name: HEAD $
+  * $Revision: 1.2 $
+  * $State: Exp $
+  * $Date: 2003/10/10 20:25:03 $
+  */
+ 
Index: AiboPup/Behaviors/Mon/EStopControllerBehavior.h
diff -c /dev/null AiboPup/Behaviors/Mon/EStopControllerBehavior.h:1.1
*** /dev/null	Fri Oct 10 14:37:43 2003
--- AiboPup/Behaviors/Mon/EStopControllerBehavior.h	Thu Oct  9 20:45:01 2003
***************
*** 0 ****
--- 1,75 ----
+ //-*-c++-*-
+ #ifndef INCLUDED_EStopControllerBehavior_h_
+ #define INCLUDED_EStopControllerBehavior_h_
+ 
+ #include <iostream>
+ #include "Wireless/Wireless.h"
+ #include "Behaviors/BehaviorBase.h"
+ #include "Motion/MotionManager.h"
+ #include "Events/EventRouter.h"
+ #include "Events/EventBase.h"
+ #include "Shared/Config.h"
+ 
+ //! Listens to control commands coming in from the command port for remotely controlling the head
+ class EStopControllerBehavior : public BehaviorBase {
+ 
+ public:	
+ 	//! Points to the one EStopControllerBehavior object that the input
+ 	//! command stream is talking to. A kludge. Dunno how you're gonna
+ 	//! make sure you're not using this uninitialized.
+ 	static EStopControllerBehavior * theOne;
+ 	static int callback(char *buf, int bytes); //!< called by wireless when there's new data
+ 
+ public:
+ 	//! constructor
+ 	EStopControllerBehavior(MotionManager::MC_ID estop)
+ 		: BehaviorBase(),
+ 			cmdsock(wireless->socket(SocketNS::SOCK_STREAM, 256, 256)),
+ 			estop_id(estop)
+ 	{
+     wireless->setDaemon(cmdsock);
+ 		theOne=this;
+ 	}
+ 	//! destructor
+ 	virtual ~EStopControllerBehavior() { }
+ 
+ 	virtual void DoStart();
+ 
+ 	virtual void DoStop();
+ 
+ 	virtual void processEvent(const EventBase &);
+ 
+ 	virtual std::string getName() const { return "EStop Remote Control"; }
+ 	static std::string getClassDescription() {
+ 		char tmp[20];
+ 		sprintf(tmp,"%d",config->main.estopControl_port);
+ 		return std::string("Listens to estop commands coming in from port ")+tmp;
+ 	}
+ 
+ 	virtual void runCommand(std::string s); //!< processes a string received from wireless
+ 
+ protected:
+ 	//! The input command stream socket
+ 	Socket *cmdsock;
+ 
+ 	//! The estop to control
+ 	MotionManager::MC_ID estop_id;
+ 
+ private:
+ 	EStopControllerBehavior(const EStopControllerBehavior&); //!< don't call
+ 	EStopControllerBehavior operator=(const EStopControllerBehavior&); //!< don't call
+ 
+ };
+ 
+ /*! @file
+  * @brief Describes EStopControllerBehavior, listens to control commands coming in from the command port for remotely toggling the estop
+  * @author tss (Creator)
+  * 
+  * $Author: ejt $
+  * $Name: HEAD $
+  * $Revision: 1.2 $
+  * $State: Exp $
+  * $Date: 2003/10/10 20:25:03 $
+  */
+ 
+ #endif 
Index: AiboPup/Behaviors/Mon/HeadPointControllerBehavior.cc
diff -c /dev/null AiboPup/Behaviors/Mon/HeadPointControllerBehavior.cc:1.1
*** /dev/null	Fri Oct 10 14:37:43 2003
--- AiboPup/Behaviors/Mon/HeadPointControllerBehavior.cc	Thu Oct  9 20:45:01 2003
***************
*** 0 ****
--- 1,128 ----
+ #include "HeadPointControllerBehavior.h"
+ #include "Behaviors/Controller.h"
+ #include "Motion/MMAccessor.h"
+ 
+ HeadPointControllerBehavior* HeadPointControllerBehavior::theOne = NULL;
+ 
+ void HeadPointControllerBehavior::runCommand(unsigned char *command) {
+ 	// First, turn off the stop-if-no-heartbeat timer
+ 	erouter->removeTimer(this);
+ 
+ 	// Extract the command parameter
+ 	float param;
+ 	unsigned char *paramp = (unsigned char *) &param;
+ 
+ 	paramp[0] = command[1];
+ 	paramp[1] = command[2];
+ 	paramp[2] = command[3];
+ 	paramp[3] = command[4];
+ 
+ 	// Find out what type of command this is
+ 	switch(command[0]) {
+ 	case CMD_tilt:
+ 		t = param*outputRanges[HeadOffset+TiltOffset][MaxRange];
+ 		break;
+ 	case CMD_pan:
+ 		p = param*outputRanges[HeadOffset+PanOffset][MaxRange];
+ 		break;
+ 	case CMD_roll:
+ 		r = param*outputRanges[HeadOffset+RollOffset][MaxRange];
+ 		break;
+ 	default:
+ 		cout << "MECHA: unknown command " << command[0] << endl;
+ 	}
+ 
+ 	// If the command was a new motion command, apply the
+ 	// new motion parameters:
+ 	switch(command[0]) {
+ 	case CMD_tilt:
+ 	case CMD_pan:
+ 	case CMD_roll:
+ 		{
+ 			MMAccessor<HeadPointerMC> head(head_id);
+ 			head->setJoints(t,p,r);
+ 		}
+ 	}
+ 
+ 	// Reset the stop-if-no-heartbeat timer -- if we don't
+ 	// hear from the mothership in three seconds, stop immediately.
+ 	erouter->addTimer(this, 0, 3000, false);
+ }
+ 
+ void HeadPointControllerBehavior::DoStart() {
+ 	// Behavior startup
+ 	BehaviorBase::DoStart();
+ 	// We listen to timers
+ 	erouter->addListener(this, EventBase::timerEGID);
+ 	// Enable head control
+ 	head_id = motman->addMotion(SharedObject<HeadPointerMC>());
+ 	// Turn on wireless
+ 	theLastOne=theOne;
+ 	theOne=this;
+ 	wireless->setReceiver(cmdsock->sock, mechacmd_callback);
+ 	wireless->listen(cmdsock->sock, config->main.headControl_port);
+ 	// Open the WalkGUI on the desktop
+ 	Controller::loadGUI("org.tekkotsu.mon.HeadPointGUI","HeadPointGUI",config->main.headControl_port);
+ }
+ 
+ void HeadPointControllerBehavior::DoStop() {
+ 	// Close the GUI
+ 	Controller::closeGUI("HeadPointGUI");
+ 	// Turn off timers
+ 	erouter->forgetListener(this);
+ 	// Close socket; turn wireless off
+ 	wireless->close(cmdsock);
+ 	theOne=theLastOne;
+ 	// Disable head pointer
+ 	motman->removeMotion(head_id);
+ 	// Total behavior stop
+ 	BehaviorBase::DoStop();
+ }
+ 
+ // The command packet reassembly mechanism
+ int HeadPointControllerBehavior::mechacmd_callback(char *buf, int bytes) {
+   static char cb_buf[5];
+   static int cb_buf_filled;
+ 
+   // If there's an incomplete command in the command buffer, fill
+   // up as much of the command buffer as we can and then execute it
+   // if possible
+   if(cb_buf_filled) {
+     while((cb_buf_filled < 5) && bytes) {
+       cb_buf[cb_buf_filled++] = *buf++;	// copy incoming buffer byte
+       --bytes;				// decrement remaining byte ct.
+     }
+     // did we fill it? if so, execute! and mark buffer empty.
+     if(cb_buf_filled == 5) {
+       if(HeadPointControllerBehavior::theOne) HeadPointControllerBehavior::theOne->runCommand((unsigned char*) cb_buf);
+       cb_buf_filled = 0;
+     }
+   }
+ 
+   // now execute all complete bytes in the incoming buffer
+   while(bytes >= 5) {
+     if(HeadPointControllerBehavior::theOne) HeadPointControllerBehavior::theOne->runCommand((unsigned char *) buf);
+     bytes -= 5;
+     buf += 5;
+   }
+ 
+   // finally, store all remaining bytes in the command buffer
+   while(bytes) {
+     cb_buf[cb_buf_filled++] = *buf++;
+     --bytes;
+   }
+ 
+   return 0;
+ }
+ 
+ /*! @file
+  * @brief Implements HeadPointControllerBehavior, listens to control commands coming in from the command port for remotely controlling the head
+  * @author tss (Creator)
+  * 
+  * $Author: ejt $
+  * $Name: HEAD $
+  * $Revision: 1.2 $
+  * $State: Exp $
+  * $Date: 2003/10/10 20:25:03 $
+  */
+ 
Index: AiboPup/Behaviors/Mon/HeadPointControllerBehavior.h
diff -c /dev/null AiboPup/Behaviors/Mon/HeadPointControllerBehavior.h:1.1
*** /dev/null	Fri Oct 10 14:37:43 2003
--- AiboPup/Behaviors/Mon/HeadPointControllerBehavior.h	Thu Oct  9 20:45:01 2003
***************
*** 0 ****
--- 1,92 ----
+ //-*-c++-*-
+ #ifndef INCLUDED_HeadPointControllerBehavior_h_
+ #define INCLUDED_HeadPointControllerBehavior_h_
+ 
+ #include <iostream>
+ #include "Wireless/Wireless.h"
+ #include "Behaviors/BehaviorBase.h"
+ #include "Motion/MotionManager.h"
+ #include "Motion/HeadPointerMC.h"
+ #include "Events/EventRouter.h"
+ #include "Events/EventBase.h"
+ #include "Shared/Config.h"
+ 
+ //! Listens to control commands coming in from the command port for remotely controlling the head
+ class HeadPointControllerBehavior : public BehaviorBase {
+ 
+  public:	
+ 	//! Points to the one HeadPointControllerBehavior object that the input
+ 	//! command stream is talking to. A kludge. Dunno how you're gonna
+ 	//! make sure you're not using this uninitialized.
+ 	static HeadPointControllerBehavior * theOne;
+ 	static int mechacmd_callback(char *buf, int bytes); //!< called by wireless when there's new data
+ 
+  protected:
+ 	MotionManager::MC_ID head_id;   //!< the HeadPointerMC to use
+  
+  private:
+ 	//!@name Command Bytes
+ 	static const char CMD_tilt  = 't'; //!< handy symbol for matching incoming communication
+ 	static const char CMD_pan   = 'p';
+ 	static const char CMD_roll  = 'r';
+ 	//@}
+ 
+ 	float t; //!< head parameter
+ 	float p; //!< head parameter
+ 	float r; //!< head parameter
+ 
+ 	//! The last HPCB object that was theOne, so we can restore it
+ 	//! to prominence when we die. This is a nice gesture, but it doesn't
+ 	//! really make sense since we're all using the same port. But just
+ 	//! in case something changes and we don't do that, this mechanism
+ 	//! is in place.
+ 	HeadPointControllerBehavior *theLastOne;
+ 
+ 	//! The input command stream socket
+ 	Socket *cmdsock;
+ 
+ 	//! Executes a command. Called by mechacmd_callback.
+ 	void runCommand(unsigned char *command);
+ 
+ 	HeadPointControllerBehavior(const HeadPointControllerBehavior&); //!< don't call
+ 	HeadPointControllerBehavior operator=(const HeadPointControllerBehavior&); //!< don't call
+ 
+  public:
+ 	//! constructor
+ 	HeadPointControllerBehavior() :
+ 	  BehaviorBase(),
+ 	  head_id(MotionManager::invalid_MC_ID),
+ 	  t(0), p(0), r(0),
+ 	  theLastOne(theOne),
+ 	  cmdsock(wireless->socket(SocketNS::SOCK_STREAM, 2048, 2048))
+ 	{ wireless->setDaemon(cmdsock); }
+ 	//! destructor
+ 	virtual ~HeadPointControllerBehavior() { theOne = theLastOne; }
+ 
+ 	virtual void DoStart();
+ 
+ 	virtual void DoStop();
+ 
+ 	//! The only event we could possibly receive is the stop-if-no-heartbeat timer.
+ 	virtual void processEvent(const EventBase &) {}
+ 
+ 	virtual std::string getName() const { return "Head Remote Control"; }
+ 	static std::string getClassDescription() {
+ 		char tmp[20];
+ 		sprintf(tmp,"%d",config->main.headControl_port);
+ 		return std::string("Listens to head control commands coming in from port ")+tmp;
+ 	}
+ };
+ 
+ /*! @file
+  * @brief Describes HeadPointControllerBehavior, listens to control commands coming in from the command port for remotely controlling the head
+  * @author tss (Creator)
+  * 
+  * $Author: ejt $
+  * $Name: HEAD $
+  * $Revision: 1.2 $
+  * $State: Exp $
+  * $Date: 2003/10/10 20:25:03 $
+  */
+ 
+ #endif 
Index: AiboPup/Behaviors/Mon/ViewWMVarsBehavior.h
diff -c /dev/null AiboPup/Behaviors/Mon/ViewWMVarsBehavior.h:1.1
*** /dev/null	Fri Oct 10 14:37:43 2003
--- AiboPup/Behaviors/Mon/ViewWMVarsBehavior.h	Thu Oct  9 20:47:52 2003
***************
*** 0 ****
--- 1,47 ----
+ //-*-c++-*-
+ #ifndef INCLUDED_ViewWMVarsBehavior_h_
+ #define INCLUDED_ViewWMVarsBehavior_h_
+ 
+ #include "Behaviors/BehaviorBase.h"
+ #include "Behaviors/Controller.h"
+ #include "Shared/Config.h"
+ #include <stdio.h>
+ 
+ //! simply launches the Watchable Memory GUI
+ class ViewWMVarsBehavior : public BehaviorBase {
+ public:
+ 	//! constructor
+ 	ViewWMVarsBehavior() : BehaviorBase() {}
+ 
+ 	virtual void DoStart() {
+ 		BehaviorBase::DoStart();
+ 		// Open the WalkGUI on the desktop
+ 		Controller::loadGUI("org.tekkotsu.mon.WatchableMemory","WatchableMemory",config->main.wmmonitor_port);
+ 	}
+ 
+ 	virtual void DoStop() {
+ 		// Close the GUI
+ 		Controller::closeGUI("WatchableMemory");
+ 		BehaviorBase::DoStop();
+ 	}
+ 
+ 	virtual std::string getName() const { return "View WMVars"; }
+ 	static std::string getClassDescription() {
+ 		char tmp[20];
+ 		sprintf(tmp,"%d",config->main.wmmonitor_port);
+ 		return std::string("Brings up the WatchableMemory GUI on port ")+tmp;
+ 	}
+ };
+ 
+ /*! @file
+  * @brief Describes ViewWMVarsBehavior, simply launches the Watchable Memory GUI
+  * @author ejt (Creator)
+  * 
+  * $Author: ejt $
+  * $Name: HEAD $
+  * $Revision: 1.2 $
+  * $State: Exp $
+  * $Date: 2003/10/10 20:25:03 $
+  */
+ 
+ #endif 
Index: AiboPup/Behaviors/Mon/WMMonitorBehavior.cc
diff -c /dev/null AiboPup/Behaviors/Mon/WMMonitorBehavior.cc:1.1
*** /dev/null	Fri Oct 10 14:37:43 2003
--- AiboPup/Behaviors/Mon/WMMonitorBehavior.cc	Thu Oct  9 20:45:01 2003
***************
*** 0 ****
--- 1,147 ----
+ #include "WMMonitorBehavior.h"
+ #include "Shared/WMclass.h"
+ 
+ //! so wmmonitorcmd_callback knows where to send the input from the GUI
+ WMMonitorBehavior *wmMonitorBehavior = NULL;
+ 
+ void
+ WMMonitorBehavior::registerData(const std::string& s) {
+   if (s.size()==0) return;
+   unsigned int pos;
+ 
+   pos=s.find(' ');
+   std::string cmd=s.substr(0,pos);
+   std::string var=s.substr(pos+1, s.length());
+ 
+   if (cmd[0]=='w') {           // enable watch on WMitem
+     WMitem_base* wmitem=find (var);
+     if (wmitem!=NULL) wmitem->watch();
+   } else if (cmd[0]=='s') {    // disable watch on WMitem
+     WMitem_base* wmitem=find (var);
+     if (wmitem!=NULL) wmitem->unwatch();
+   } else if (cmd[0]=='x') {    // examing a WMitem
+     WMitem_base* wmitem=find (var);
+     if (wmitem!=NULL)
+       report(wmitem->entry->type_name, wmitem->entry->item_name,
+           wmitem->toString());
+   } else if (cmd[0]=='r') {
+     WMregistry* wmreg=NULL;
+     if (var.length()==0) wmreg=&GlobalWM;
+     else {
+       WMitem<WMregistry>* wmitem=static_cast<WMitem<WMregistry> *> (find (var));
+       if (wmitem!=NULL)
+         wmreg=&wmitem->get_value();
+     }
+     if (wmreg!=NULL)
+       for (std::vector<WMentry*>::const_iterator it = wmreg->entries.begin();
+           it != wmreg->entries.end(); it++) {
+         WMentry* entry=*it;
+         std::string sn(entry->item_name);
+         WMregistry *temp=entry->registry;
+         while (temp!=&GlobalWM && temp!=NULL) {
+           sn=temp->name + "." + sn;
+           temp=temp->parent;
+         }
+         report(entry->type_name, sn, entry->item->toString());
+       }
+   } else if (cmd[0]=='d') {    // set debug mode (blocking/nonblocking)
+     // implement within this class
+   }
+ }
+ 
+ 
+ WMitem_base*
+ WMMonitorBehavior::find (std::string& s) {
+   WMregistry* wmreg=&GlobalWM;
+   unsigned int pos=s.find('.');
+   while (pos!=std::string::npos) {
+     bool changed=false;
+     std::string subreg=s.substr(0, pos);
+     s=s.substr(pos+1);
+     for (std::vector<WMentry*>::const_iterator it = wmreg->entries.begin(); it != wmreg->entries.end(); it++)
+       if ( (*it)->item_name == subreg) {
+         WMitem<WMregistry> const* wmitem=static_cast<WMitem<WMregistry> const*>((*it)->item);
+         wmreg=&(wmitem->get_value());
+         changed=true;
+ 				break;
+       }
+     if (!changed) return NULL;
+ 
+     pos=s.find('.');
+   }
+ 
+   for (std::vector<WMentry*>::const_iterator it = wmreg->entries.begin(); it != wmreg->entries.end(); it++)
+     if ( (*it)->item_name == s)
+       return (*it)->item;
+   return NULL;
+ }
+ 
+ void
+ WMMonitorBehavior::report (const std::string& var_type,
+                            const std::string& var_name,
+                            const std::string& value) {
+   report (var_type.c_str(), var_type.length(),
+           var_name.c_str(), var_name.length(),
+           value.c_str(), value.length());
+ }
+ 
+ void
+ WMMonitorBehavior::report (const std::string& var_type,
+                            const std::string& var_name,
+                            const char* value, int value_length) {
+   report (var_type.c_str(), var_type.length(),
+           var_name.c_str(), var_name.length(),
+           value, value_length);
+ }
+ 
+ void
+ WMMonitorBehavior::report (const char* var_type, int var_type_length,
+                            const char* var_name, int var_name_length,
+                            const char* value, int value_length) {
+   char *buf=(char*)cmdsock->getWriteBuffer(5+ var_type_length+
+                                               var_name_length+
+                                               value_length);
+   if (buf) {
+     Serializer::encodeHeader(&buf, SerializerNS::packet_wmclass);
+     Serializer::encode(&buf, var_type_length);
+     Serializer::encode(&buf, var_type, var_type_length);
+     Serializer::encode(&buf, var_name_length);
+     Serializer::encode(&buf, var_name, var_name_length);
+     Serializer::encode(&buf, value_length);
+     Serializer::encode(&buf, value, value_length);
+     cmdsock->write(5*sizeof(int)+var_type_length+var_name_length+value_length);
+   }
+ }
+ 
+ int wmmonitorcmd_callback(char *buf, int bytes) {
+   std::string s(buf, bytes);
+   if (wmMonitorBehavior==NULL) return 0;
+   static std::string incomplete;
+                                                                                 
+   //pass a line at a time to the controller
+   while(s.size()>0) {
+     unsigned int endline=s.find('\n');
+     if(endline==std::string::npos) {
+       incomplete+=s;
+       return 0;
+     }
+     incomplete+=s.substr(0,endline);
+     //is now complete:
+     wmMonitorBehavior->registerData(incomplete);
+     incomplete.erase();
+     s=s.substr(endline+1);
+   }
+                                                                                 
+   return 0;
+ }
+ 
+ /*! @file
+  * @brief Defines WMMonitorBehavior, which listens to commands from the Aibo3D gui and shows current state
+  * @author alokl (Creator)
+  *
+  * $Author: ejt $
+  * $Name: HEAD $
+  * $Revision: 1.2 $
+  * $State: Exp $
+  * $Date: 2003/10/10 20:25:03 $
+  */
Index: AiboPup/Behaviors/Mon/WMMonitorBehavior.h
diff -c /dev/null AiboPup/Behaviors/Mon/WMMonitorBehavior.h:1.3
*** /dev/null	Fri Oct 10 14:37:43 2003
--- AiboPup/Behaviors/Mon/WMMonitorBehavior.h	Fri Oct 10 13:50:10 2003
***************
*** 0 ****
--- 1,122 ----
+ //-*-c++-*-
+ #ifndef INCLUDED_WMMonitorBehavior_h_
+ #define INCLUDED_WMMonitorBehavior_h_
+ 
+ #include <iostream>
+ #include "Wireless/Wireless.h"
+ #include "Behaviors/BehaviorBase.h"
+ #include "Motion/MotionManager.h"
+ #include "Events/EventRouter.h"
+ #include "Events/EventBase.h"
+ #include "Shared/RobotInfo.h"
+ #include "Shared/Serializer.h"
+ #include "Behaviors/Controller.h"
+ #include "Shared/WMclass.h"
+ 
+ //! gets input from the GUI
+ int wmmonitorcmd_callback(char *buf, int bytes);
+ class WMMonitorBehavior;
+ 
+ //! so wmmonitorcmd_callback knows where to send the input from the GUI
+ extern WMMonitorBehavior *wmMonitorBehavior;
+ 
+ class WMitem_base;
+ 
+ //! Listens to wmmonitor control commands coming in from the command port.
+ class WMMonitorBehavior : public BehaviorBase {
+  protected:
+ 	//! The input command stream socket
+ 	Socket *cmdsock;
+ 
+  private:
+ 	WMMonitorBehavior(const WMMonitorBehavior&); //!< don't call
+ 	WMMonitorBehavior operator=(const WMMonitorBehavior&); //!< don't call
+ 
+  public:
+ 	//! constructor
+ 	WMMonitorBehavior() :
+ 	  BehaviorBase(),
+ 	  cmdsock(wireless->socket(SocketNS::SOCK_STREAM, 2048, 8192))
+ 	{ wmMonitorBehavior = this;
+     wireless->setDaemon(cmdsock); }
+ 	//! destructor
+ 	virtual ~WMMonitorBehavior() { wmMonitorBehavior = NULL; }
+ 
+ 	//! processes input from the GUI
+   void registerData(const std::string& s);
+ 
+ 	//! Finds the item with the corresponding name
+   WMitem_base* find (std::string& s);
+ 
+ 	//! Writes out the passed information to #cmdsock
+   void report (const std::string& var_type,
+                const std::string& var_name,
+                const std::string& value);
+ 
+ 	//! Writes out the passed information to #cmdsock
+   void report (const std::string& var_type,
+                const std::string& var_name,
+                const char* value, int value_length);
+ 
+ 	//! Writes out the passed information to #cmdsock
+   void report(const char* var_type, int var_type_length,
+               const char* var_name, int var_name_length,
+               const char* value, int value_length);
+ 
+ 	virtual void DoStart() {
+ 		// Behavior startup
+ 		BehaviorBase::DoStart();
+ 		// Turn on wireless
+ 		wireless->setReceiver(cmdsock->sock, wmmonitorcmd_callback);
+ 		wireless->listen(cmdsock->sock, config->main.wmmonitor_port);
+ 		// open gui
+ 		// GUI is opened by separate behavior ViewWMVarsBehavior
+ 		// until bug with clearing wmvars when restarting this is fixed
+ 		erouter->addListener(this,EventBase::wmVarEGID);
+ 	}
+ 
+ 	virtual void DoStop() {
+ //		Controller::closeGUI(getGUIType());
+ 		erouter->forgetListener(this);
+ 		// Close socket; turn wireless off
+ 		wireless->close(cmdsock);
+ 		// Total behavior stop
+ 		BehaviorBase::DoStop();
+ 	}
+ 
+ 	virtual void processEvent(const EventBase& e) {
+ 		WMentry * entry = reinterpret_cast<WMentry*>(e.getSourceID());
+ 		std::string s(entry->item_name);
+ 		WMregistry *temp=entry->registry;
+ 		while (temp!=&GlobalWM && temp!=NULL) {
+ 			s=temp->name + "." + s;
+ 			temp=temp->parent;
+ 		}
+ 		report(entry->type_name, s, entry->item->toString());
+ 	}
+ 
+ 	virtual unsigned int getPort() const { return config->main.wmmonitor_port; }
+ 
+ 	virtual std::string getName() const { return "Watchable Memory Monitor"; } //!< returns name of behavior
+ 	static std::string getClassDescription() { 
+ 		char tmp[20];
+ 		sprintf(tmp,"%d",config->main.wmmonitor_port);
+ 		return std::string("Bidirectional control communication with WMMonitor on port ")+tmp;
+ 	}
+ };
+ 
+ //! interfaces with wireless to pass information from the gui to the monitor
+ int wmmonitorcmd_callback(char *buf, int bytes);
+ 
+ /*! @file
+  * @brief Defines WMMonitorBehavior, which listens to commands from the Aibo3D gui and shows current state
+  * @author alokl (Creator)
+  *
+  * $Author: ejt $
+  * $Name: HEAD $
+  * $Revision: 1.2 $
+  * $State: Exp $
+  * $Date: 2003/10/10 20:25:03 $
+  */
+ 
+ #endif 
Index: AiboPup/Behaviors/Mon/WalkControllerBehavior.cc
diff -c /dev/null AiboPup/Behaviors/Mon/WalkControllerBehavior.cc:1.1
*** /dev/null	Fri Oct 10 14:37:43 2003
--- AiboPup/Behaviors/Mon/WalkControllerBehavior.cc	Thu Oct  9 20:45:01 2003
***************
*** 0 ****
--- 1,159 ----
+ #include "WalkControllerBehavior.h"
+ #include "Behaviors/Controller.h"
+ 
+ WalkControllerBehavior* WalkControllerBehavior::theOne = NULL;
+ 
+ void WalkControllerBehavior::runCommand(unsigned char *command) {
+ 	// First, turn off the stop-if-no-heartbeat timer
+ 	erouter->removeTimer(this);
+ 
+ 	// Extract the command parameter
+ 	float param;
+ 	unsigned char *paramp = (unsigned char *) &param;
+ 
+ 	paramp[0] = command[1];
+ 	paramp[1] = command[2];
+ 	paramp[2] = command[3];
+ 	paramp[3] = command[4];
+ 
+ 	// Find out what type of command this is
+ 	switch(command[0]) {
+ 	case CMD_fwd:
+ 		dx = param;
+ 		break;
+ 	case CMD_roto:
+ 		da = param;
+ 		break;
+ 	case CMD_side:
+ 		dy = param;
+ 		break;
+ 	case CMD_opt0:
+ 		{
+ 			/*			HeadPointerMC *head =
+ 				(HeadPointerMC*)motman->checkoutMotion(head_id);
+ 			head->setJoints(0,0,0);
+ 			motman->checkinMotion(head_id);*/
+ 			break;
+ 		}
+ 	case CMD_opt1:
+ 	case CMD_opt2:
+ 	case CMD_opt3:
+ 	case CMD_opt4:
+ 		cout << "MECHA: hey, reprogram this button!" << endl;
+ 		break;
+ 	case CMD_opt5:
+ 		sndman->PlayFile("howl.wav");
+ 		break;
+ 	case CMD_opt6:
+ 		sndman->PlayFile("yap.wav");
+ 		break;
+ 	case CMD_opt7:
+ 		sndman->PlayFile("whimper.wav");
+ 		break;
+ 	case CMD_opt8:
+ 		sndman->PlayFile("growl.wav");
+ 		break;
+ 	case CMD_opt9:
+ 		sndman->PlayFile("barkmed.wav");
+ 		break;
+ 		// The options button commands.
+ 	default:
+ 		cout << "MECHA: unknown command " << command[0] << endl;
+ 	}
+ 
+ 	// If the command was a new motion command, apply the
+ 	// new motion parameters:
+ 	switch(command[0]) {
+ 	case CMD_fwd:
+ 	case CMD_roto:
+ 	case CMD_side:
+ 		{
+ 			MMAccessor<WalkMC> walker(getWalkID());
+ 			walker->setTargetVelocity(dx,dy,da);
+ 		}
+ 	}
+ 
+ 	// Reset the stop-if-no-heartbeat timer -- if we don't
+ 	// hear from the mothership in three seconds, stop immediately.
+ 	erouter->addTimer(this, 0, 3000, false);
+ }
+ 
+ void WalkControllerBehavior::DoStart() {
+ 	// Behavior startup
+ 	BehaviorBase::DoStart();
+ 	// We listen to timers
+ 	erouter->addListener(this, EventBase::timerEGID);
+ 	// Enable walker (the MC_ID can be accessed through the shared_walker later)
+ 	motman->addMotion(shared_walker);
+ 	// Turn on wireless
+ 	theLastOne=theOne;
+ 	theOne=this;
+ 	wireless->setReceiver(cmdsock->sock, mechacmd_callback);
+ 	wireless->listen(cmdsock->sock, config->main.walkControl_port);
+ 	// Open the WalkGUI on the desktop
+ 	Controller::loadGUI("org.tekkotsu.mon.WalkGUI","WalkGUI",config->main.walkControl_port);
+ }
+ 
+ void WalkControllerBehavior::DoStop() {
+ 	// Close the GUI
+ 	Controller::closeGUI("WalkGUI");
+ 	// Turn off timers
+ 	erouter->forgetListener(this);
+ 	// Close socket; turn wireless off
+ 	wireless->close(cmdsock);
+ 	theOne=theLastOne;
+ 	// Disable walker
+ 	motman->removeMotion(getWalkID());
+ 	// Total behavior stop
+ 	BehaviorBase::DoStop();
+ }
+ 
+ // The command packet reassembly mechanism
+ int WalkControllerBehavior::mechacmd_callback(char *buf, int bytes) {
+   static char cb_buf[5];
+   static int cb_buf_filled;
+ 
+   // If there's an incomplete command in the command buffer, fill
+   // up as much of the command buffer as we can and then execute it
+   // if possible
+   if(cb_buf_filled) {
+     while((cb_buf_filled < 5) && bytes) {
+       cb_buf[cb_buf_filled++] = *buf++;	// copy incoming buffer byte
+       --bytes;				// decrement remaining byte ct.
+     }
+     // did we fill it? if so, execute! and mark buffer empty.
+     if(cb_buf_filled == 5) {
+       if(WalkControllerBehavior::theOne) WalkControllerBehavior::theOne->runCommand((unsigned char*) cb_buf);
+       cb_buf_filled = 0;
+     }
+   }
+ 
+   // now execute all complete bytes in the incoming buffer
+   while(bytes >= 5) {
+     if(WalkControllerBehavior::theOne) WalkControllerBehavior::theOne->runCommand((unsigned char *) buf);
+     bytes -= 5;
+     buf += 5;
+   }
+ 
+   // finally, store all remaining bytes in the command buffer
+   while(bytes) {
+     cb_buf[cb_buf_filled++] = *buf++;
+     --bytes;
+   }
+ 
+   return 0;
+ }
+ 
+ /*! @file
+  * @brief Implements WalkControllerBehavior, listens to mecha control commands coming in from the command port for remotely controlling the walk
+  * @author tss (Creator)
+  * @author ejt (modifications)
+  * @author PA Gov. School for the Sciences 2003 Team Project - Haoqian Chen, Yantian Martin, Jon Stahlman (modifications)
+  * 
+  * $Author: ejt $
+  * $Name: HEAD $
+  * $Revision: 1.2 $
+  * $State: Exp $
+  * $Date: 2003/10/10 20:25:03 $
+  */
+ 
Index: AiboPup/Behaviors/Mon/WalkControllerBehavior.h
diff -c /dev/null AiboPup/Behaviors/Mon/WalkControllerBehavior.h:1.1
*** /dev/null	Fri Oct 10 14:37:43 2003
--- AiboPup/Behaviors/Mon/WalkControllerBehavior.h	Thu Oct  9 20:45:01 2003
***************
*** 0 ****
--- 1,113 ----
+ //-*-c++-*-
+ #ifndef INCLUDED_WalkControllerBehavior_h_
+ #define INCLUDED_WalkControllerBehavior_h_
+ 
+ #include <iostream>
+ #include "Wireless/Wireless.h"
+ #include "Behaviors/BehaviorBase.h"
+ #include "Motion/MotionManager.h"
+ #include "Motion/WalkMC.h"
+ #include "Motion/MMAccessor.h"
+ #include "Events/EventRouter.h"
+ #include "Events/EventBase.h"
+ #include "SoundPlay/SoundManager.h"
+ #include "Shared/Config.h"
+ 
+ //! Listens to control commands coming in from the command port for remotely controlling the walk
+ class WalkControllerBehavior : public BehaviorBase {
+ 
+  public:	
+ 	//! Points to the one WalkControllerBehavior object that the input
+ 	//! command stream is talking to. A kludge. Dunno how you're gonna
+ 	//! make sure you're not using this uninitialized.
+ 	static WalkControllerBehavior * theOne;
+ 	static int mechacmd_callback(char *buf, int bytes); //!< called by wireless when there's new data
+ 
+  protected:
+ 	SharedObject<WalkMC> shared_walker; //!< the WalkMC to use
+  
+  private:
+ 	//!@name Command Bytes
+ 	static const char CMD_fwd  = 'f'; //!< handy symbol for matching incoming communication
+ 	static const char CMD_roto = 'r';
+ 	static const char CMD_side = 's';
+ 	static const char CMD_opt0 = '0';
+ 	static const char CMD_opt1 = '1';
+ 	static const char CMD_opt2 = '2';
+ 	static const char CMD_opt3 = '3';
+ 	static const char CMD_opt4 = '4';
+ 	static const char CMD_opt5 = '5';
+ 	static const char CMD_opt6 = '6';
+ 	static const char CMD_opt7 = '7';
+ 	static const char CMD_opt8 = '8';
+ 	static const char CMD_opt9 = '9';
+ 	//@}
+ 
+ 	float dx; //!< Motion parameter
+ 	float dy; //!< Motion parameter
+ 	float da; //!< Motion parameter
+ 
+ 	//! The last WCB object that was theOne, so we can restore it
+ 	//! to prominence when we die. This is a nice gesture, but it doesn't
+ 	//! really make sense since we're all using the same port. But just
+ 	//! in case something changes and we don't do that, this mechanism
+ 	//! is in place.
+ 	WalkControllerBehavior *theLastOne;
+ 
+ 	//! The input command stream socket
+ 	Socket *cmdsock;
+ 
+ 	//! Executes a command. Called by mechacmd_callback.
+ 	void runCommand(unsigned char *command);
+ 
+ 	WalkControllerBehavior(const WalkControllerBehavior&); //!< don't call
+ 	WalkControllerBehavior operator=(const WalkControllerBehavior&); //!< don't call
+ 
+  public:
+ 	//! constructor
+ 	WalkControllerBehavior() :
+ 	  BehaviorBase(),
+ 		shared_walker(),
+ 	  dx(0), dy(0), da(0),
+ 	  theLastOne(theOne),
+ 	  cmdsock(wireless->socket(SocketNS::SOCK_STREAM, 2048, 2048))
+ 	{ wireless->setDaemon(cmdsock); }
+ 	//! destructor
+ 	virtual ~WalkControllerBehavior() { theOne = theLastOne; }
+ 
+ 	virtual void DoStart();
+ 
+ 	virtual void DoStop();
+ 
+ 	virtual WalkMC * getWalkMC() { return &(*shared_walker); }  //!< returns the WalkMC which [will be|is being] used
+ 
+ 	virtual MotionManager::MC_ID getWalkID() { return shared_walker->getID(); } //!< returns the current Walk's MotionCommand ID
+ 
+ 	//! The only event we could possibly receive is the stop-if-no-heartbeat timer.
+ 	virtual void processEvent(const EventBase &) {
+ 		MMAccessor<WalkMC> walker(getWalkID());
+ 		walker->setTargetVelocity(0,0,0);
+ 	}
+ 
+ 	virtual std::string getName() const { return "Walk Remote Control"; }
+ 	static std::string getClassDescription() {
+ 		char tmp[20];
+ 		sprintf(tmp,"%d",config->main.walkControl_port);
+ 		return std::string("Listens to walk control commands coming in from port ")+tmp;
+ 	}
+ };
+ 
+ /*! @file
+  * @brief Describes WalkControllerBehavior, listens to control commands coming in from the command port for remotely controlling the walk
+  * @author tss (Creator)
+  * @author ejt (modifications)
+  * @author PA Gov. School for the Sciences 2003 Team Project - Haoqian Chen, Yantian Martin, Jon Stahlman (modifications)
+  * 
+  * $Author: ejt $
+  * $Name: HEAD $
+  * $Revision: 1.2 $
+  * $State: Exp $
+  * $Date: 2003/10/10 20:25:03 $
+  */
+ 
+ #endif 
Index: AiboPup/Behaviors/Nodes/OutputNode.h
diff -c AiboPup/Behaviors/Nodes/OutputNode.h:1.2 AiboPup/Behaviors/Nodes/OutputNode.h:1.4
*** AiboPup/Behaviors/Nodes/OutputNode.h:1.2	Sat Mar  8 21:45:22 2003
--- AiboPup/Behaviors/Nodes/OutputNode.h	Thu Sep 25 23:09:10 2003
***************
*** 10,34 ****
  class OutputNode : public StateNode {
  public:
  	//!constructor, uses cout for output
! 	OutputNode() : StateNode(), next(NULL), out(cout) {}
  	//!constructor, sets name and ostream to use for output
! 	OutputNode(const char* nm, StateNode* par, ostream& output) : StateNode(nm,par), next(NULL), out(output) {}
  	//!constructor, sets name and another state which will immediately be transitioned to upon activation
! 	OutputNode(const char* nm, StateNode* par, ostream& output, StateNode * nextstate) : StateNode(nm,par), next(nextstate), out(output) {}
  
  	//!outputs this state's name, will transition to #next if non-NULL
  	/*!if #next is NULL, the state will simply stay active until some other transition causes it to leave*/
  	virtual void DoStart() {
  		StateNode::DoStart();
! 		out << name << endl;
! 		DoStop();
! 		if(next!=NULL)
  			next->DoStart();
  	}
  	
  protected:
  	StateNode* next; //!< the state to transition to upon entering, can be NULL
  	ostream& out;    //!< the stream to use for output - if not specified (default constructor) cout will be used
  
  private:
  	OutputNode(const OutputNode& node); //!< don't call this
--- 10,38 ----
  class OutputNode : public StateNode {
  public:
  	//!constructor, uses cout for output
! 	OutputNode() : StateNode(), next(NULL), out(cout), msg() {}
  	//!constructor, sets name and ostream to use for output
! 	OutputNode(const char* nm, StateNode* par, ostream& output) : StateNode(nm,par), next(NULL), out(output), msg(nm) {}
  	//!constructor, sets name and another state which will immediately be transitioned to upon activation
! 	OutputNode(const char* nm, StateNode* par, ostream& output, StateNode * nextstate) : StateNode(nm,par), next(nextstate), out(output), msg(nm) {}
! 	//!constructor, sets name, message, and another state which will immediately be transitioned to upon activation
! 	OutputNode(const char* nm, const std::string& mg, StateNode* par, ostream& output, StateNode * nextstate) : StateNode(nm,par), next(nextstate), out(output), msg(mg) {}
  
  	//!outputs this state's name, will transition to #next if non-NULL
  	/*!if #next is NULL, the state will simply stay active until some other transition causes it to leave*/
  	virtual void DoStart() {
  		StateNode::DoStart();
! 		out << msg << endl;
! 		if(next!=NULL) {
! 			DoStop();
  			next->DoStart();
+ 		}
  	}
  	
  protected:
  	StateNode* next; //!< the state to transition to upon entering, can be NULL
  	ostream& out;    //!< the stream to use for output - if not specified (default constructor) cout will be used
+ 	std::string msg;      //!< message to show on activation
  
  private:
  	OutputNode(const OutputNode& node); //!< don't call this
***************
*** 40,49 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 44,53 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Nodes/WalkNode.h
diff -c /dev/null AiboPup/Behaviors/Nodes/WalkNode.h:1.2
*** /dev/null	Fri Oct 10 14:37:43 2003
--- AiboPup/Behaviors/Nodes/WalkNode.h	Fri Oct 10 13:46:04 2003
***************
*** 0 ****
--- 1,121 ----
+ //-*-c++-*-
+ #ifndef INCLUDED_WalkNode_h_
+ #define INCLUDED_WalkNode_h_
+ 
+ #include "Behaviors/StateNode.h"
+ #include "Motion/MotionManager.h"
+ #include "Motion/WalkMC.h"
+ #include "Motion/MMAccessor.h"
+ 
+ //! A StateNode for walking in a direction
+ class WalkNode : public StateNode {
+ public:
+ 	//!constructor
+ 	WalkNode(StateNode * p=NULL)
+ 		: StateNode("WalkNode",p), walkid(MotionManager::invalid_MC_ID), walkidIsMine(true), x(0), y(0), a(0)
+ 	{
+ 		setRetain(false);
+ 	}
+ 
+ 	//!constructor, positive is counter-clockwise from above (to match coordinate system)
+ 	WalkNode(float xvel, float yvel, float avel, StateNode * p=NULL)
+ 		: StateNode("WalkNode",p), walkid(MotionManager::invalid_MC_ID), walkidIsMine(true), x(xvel), y(yvel), a(avel)
+ 	{
+ 		setRetain(false);
+ 	}
+ 
+ 	//! sets the velocity of the walk
+ 	void setVelocity(float xvel, float yvel, float avel) {
+ 		x=xvel;
+ 		y=yvel;
+ 		a=avel;
+ 		updateWalk(x,y,a);
+ 	}
+ 	
+ 	//! sets the velocity in x direction (positive is forward)
+ 	void setXVelocity(float xvel) { x=xvel; updateWalk(x,y,a); }
+ 
+ 	//! returns the velocity in x direction (positive is forward)
+ 	float getXVelocity() { return x; }
+ 
+ 	//! sets the velocity in y direction (positive is forward)
+ 	void setYVelocity(float yvel) { y=yvel; updateWalk(x,y,a); }
+ 
+ 	//! returns the velocity in y direction (positive is forward)
+ 	float getYVelocity() { return y; }
+ 
+ 	//! sets the velocity of the turn, positive is counter-clockwise from above (to match coordinate system)
+ 	void setAVelocity(float avel) { a=avel; updateWalk(x,y,a); }
+ 
+ 	//! returns the velocity of the turn, positive is counter-clockwise from above (to match coordinate system)
+ 	float getAVelocity() { return a; }
+ 
+ 	virtual void DoStart() {
+ 		StateNode::DoStart();
+ 		std::cout << "WalkNode::DoStart(); " << x << ' ' << y << ' ' << a << std::endl;
+ 		updateWalk(x,y,a);
+ 	}
+ 
+ 	virtual void DoStop() {
+ 		std::cout << "WalkNode::DoStop(); " << x << ' ' << y << ' ' << a << std::endl;
+ 		updateWalk(0,0,0);
+ 		StateNode::DoStop();
+ 	}
+ 
+ 	//! removes #walkid if #walkidIsMine
+ 	virtual void teardown() {
+ 		if(walkidIsMine) {
+ 			motman->removeMotion(walkid);
+ 			walkid=MotionManager::invalid_MC_ID;
+ 		}
+ 	}
+ 
+ 	//! use this to force the WalkNode to use a shared WalkMC - set to MotionManager::invalid_MC_ID to reset to internally generated walk
+ 	virtual void setWalkID(MotionManager::MC_ID id) {
+ 		if(walkidIsMine) {
+ 			motman->removeMotion(walkid);
+ 			walkid=MotionManager::invalid_MC_ID;
+ 		}
+ 		walkid=id;
+ 		walkidIsMine=(id==MotionManager::invalid_MC_ID);
+ 	}
+ 
+ 	//! use this to access the WalkMC that the WalkNode is using
+ 	virtual MotionManager::MC_ID getWalkID() { return walkid; }
+ 
+ 	//! returns true if #walkid was created (and will be destroyed) by this WalkNode - false if assigned by setWalkID()
+ 	virtual bool ownsWalkID() { return walkidIsMine; }
+ 
+ protected:
+ 	//!if the walk is invalid, create; then set xya
+ 	void updateWalk(float xvel, float yvel, float avel) {
+ 		if(walkid==MotionManager::invalid_MC_ID) {
+ 			SharedObject<WalkMC> walk;
+ 			walk->setTargetVelocity(xvel,yvel,avel);
+ 			walkid=motman->addMotion(walk);
+ 			walkidIsMine=true;
+ 		} else {
+ 			MMAccessor<WalkMC> walk(walkid);
+ 			walk->setTargetVelocity(xvel,yvel,avel);
+ 		}
+ 	}
+ 
+ 	MotionManager::MC_ID walkid; //!< the current WalkMC
+ 	bool walkidIsMine; //!< true if the walk was created in updateWalk (instead of assigned externally)
+ 	float x; //!< velocity in x direction (positive is forward)
+ 	float y; //!< velocity in y direction (positive is dog's left)
+ 	float a; //!< velocity of the turn, positive is counter-clockwise from above (to match coordinate system)
+ };
+ 
+ /*! @file
+  * @brief Describes WalkNode, a  StateNode for walking in a direction
+  * @author ejt (Creator)
+  *
+  * $Author: ejt $
+  * $Name: HEAD $
+  * $Revision: 1.2 $
+  * $State: Exp $
+  * $Date: 2003/10/10 20:25:03 $
+  */
+ 
+ #endif
Index: AiboPup/Behaviors/Transitions/CompareTrans.h
diff -c AiboPup/Behaviors/Transitions/CompareTrans.h:1.2 AiboPup/Behaviors/Transitions/CompareTrans.h:1.4
*** AiboPup/Behaviors/Transitions/CompareTrans.h:1.2	Sat Mar  8 21:45:22 2003
--- AiboPup/Behaviors/Transitions/CompareTrans.h	Thu Sep 25 11:26:57 2003
***************
*** 22,28 ****
   *  Passing NULL as the value to monitor will cause a transition on the first event received
   */
  template<class T>
! class CompareTrans : public Transition, public EventListener {
  public:
  	//! use these values to sepecify what kind of comparison should be made to test for activation
  	enum Test_t {
--- 22,28 ----
   *  Passing NULL as the value to monitor will cause a transition on the first event received
   */
  template<class T>
! class CompareTrans : public Transition {
  public:
  	//! use these values to sepecify what kind of comparison should be made to test for activation
  	enum Test_t {
***************
*** 36,49 ****
  	
  	//! constructor, see class notes for information
    CompareTrans(StateNode* source, StateNode* destination, const T* monitor, Test_t test, const T& value, const EventBase& poll)
! 		: Transition(source,destination), EventListener(), mon(monitor), tst(test), val(value), poller(poll)
  	{ }
  	
  	//!starts listening
! 	virtual void enable() { erouter->addListener(this,poller); }
  
  	//!stops listening
! 	virtual void disable() { erouter->forgetListener(this); }
  
  	//!don't care about the event, just a pulse to check the values
  	virtual void processEvent(const EventBase&) {
--- 36,49 ----
  	
  	//! constructor, see class notes for information
    CompareTrans(StateNode* source, StateNode* destination, const T* monitor, Test_t test, const T& value, const EventBase& poll)
! 		: Transition(source,destination), mon(monitor), tst(test), val(value), poller(poll)
  	{ }
  	
  	//!starts listening
! 	virtual void DoStart() { Transition::DoStart(); erouter->addListener(this,poller); }
  
  	//!stops listening
! 	virtual void DoStop() { erouter->forgetListener(this); Transition::DoStop(); }
  
  	//!don't care about the event, just a pulse to check the values
  	virtual void processEvent(const EventBase&) {
***************
*** 69,74 ****
--- 69,76 ----
  		}
  	}
  
+ 	virtual std::string getName() const { return "CompareTrans"; }
+ 
  protected:
  	const T* mon; //!< address of value to monitor
  	Test_t tst; //!< test to make
***************
*** 85,94 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 87,96 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Transitions/SmoothCompareTrans.h
diff -c AiboPup/Behaviors/Transitions/SmoothCompareTrans.h:1.4 AiboPup/Behaviors/Transitions/SmoothCompareTrans.h:1.7
*** AiboPup/Behaviors/Transitions/SmoothCompareTrans.h:1.4	Sat Mar  8 21:45:22 2003
--- AiboPup/Behaviors/Transitions/SmoothCompareTrans.h	Fri Oct 10 13:46:04 2003
***************
*** 16,36 ****
  public:
  	//! constructor, see class notes for information
    SmoothCompareTrans(StateNode* source, StateNode* destination, const T* monitor, typename SmoothCompareTrans<T>::Test_t test, const T& value, const EventBase& poll, float gammap=0)
! 		: CompareTrans<T>(source,destination,&avg,test,value,poll), avg(*monitor), realmon(monitor), g(gammap)
  	{ }
  
  	//!don't care about the event, just a pulse to check the values
  	virtual void processEvent(const EventBase& e) {
  		avg*=g;
  		T x(*realmon);
  		x*=(1-g);
  		avg+=x;
! 		CompareTrans<T>::processEvent(e);
  	}
  protected:
  	T avg; //!< the current running average
  	const T* realmon; //!< pointer to the value being monitored
  
  	//! the gamma value controlling the exponential average, see the class documentation at the top
  	float g; 
  
--- 16,61 ----
  public:
  	//! constructor, see class notes for information
    SmoothCompareTrans(StateNode* source, StateNode* destination, const T* monitor, typename SmoothCompareTrans<T>::Test_t test, const T& value, const EventBase& poll, float gammap=0)
! 		: CompareTrans<T>(source,destination,&avg,test,value,poll), avg(*monitor), realmon(monitor),
! 		burnin((unsigned int)(1/(1-gammap))), tests(0), g(gammap)
  	{ }
  
+ 	virtual void DoStart() {
+ 		CompareTrans<T>::DoStart();
+ 		avg=*realmon;
+ 		tests=0;
+ 	}
+ 
+ 	//! sets number of tests to perform before allowing a transition; default 1/(1-g)
+ 	void setBurnIn(unsigned int i) {
+ 		burnin=i;
+ 	}
+ 
+ 	//! returns number of tests to perform before allowing a transition; default 1/(1-g)
+ 	unsigned int getBurnIn() {
+ 		return burnin;
+ 	}
+ 
  	//!don't care about the event, just a pulse to check the values
  	virtual void processEvent(const EventBase& e) {
  		avg*=g;
  		T x(*realmon);
  		x*=(1-g);
  		avg+=x;
! 		tests++;
! 		if(tests>burnin)
! 			CompareTrans<T>::processEvent(e);
  	}
+ 
+ 	virtual std::string getName() const { return "SmoothCompareTrans"; }
+ 
  protected:
  	T avg; //!< the current running average
  	const T* realmon; //!< pointer to the value being monitored
  
+ 	unsigned int burnin; //!< number of tests to perform before allowing a transition; default 1/(1-g)
+ 	unsigned int tests; //!< counter of tests made since last DoStart()
+ 
  	//! the gamma value controlling the exponential average, see the class documentation at the top
  	float g; 
  
***************
*** 44,53 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 69,78 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Transitions/TimeOutTrans.h
diff -c AiboPup/Behaviors/Transitions/TimeOutTrans.h:1.2 AiboPup/Behaviors/Transitions/TimeOutTrans.h:1.7
*** AiboPup/Behaviors/Transitions/TimeOutTrans.h:1.2	Sat Mar  8 21:45:22 2003
--- AiboPup/Behaviors/Transitions/TimeOutTrans.h	Thu Oct  2 23:40:23 2003
***************
*** 6,29 ****
  #include "Events/EventRouter.h"
  
  //! causes a transition after a specified amount of time has passed
! class TimeOutTrans : public Transition, public EventListener {
  public:
  	//! constructor, specify delay in milliseconds
! 	TimeOutTrans(StateNode* source, StateNode* destination, unsigned int delay) : Transition(source,destination), EventListener(), d(delay) {}
  	
  	//!starts timer
! 	virtual void enable() { resetTimer(); }
  
  	//!stops timer
! 	virtual void disable() { erouter->forgetListener(this); }
  
  	//!resets timer
! 	void resetTimer() { erouter->addTimer(this,0,d,false); }
  
  	//!if we receive the timer event, activate()
! 	virtual void processEvent(const EventBase&) {
  		activate();
  	}
  protected:
  	//!amount to delay (in milliseconds) before transition
  	unsigned int d;
--- 6,39 ----
  #include "Events/EventRouter.h"
  
  //! causes a transition after a specified amount of time has passed
! class TimeOutTrans : public Transition {
  public:
  	//! constructor, specify delay in milliseconds
! 	TimeOutTrans(StateNode* source, StateNode* destination, unsigned int delay) : Transition(source,destination), d(delay) {}
  	
  	//!starts timer
! 	virtual void DoStart() {
! 		Transition::DoStart();
! 		resetTimer(); 
! 	}
  
  	//!stops timer
! 	virtual void DoStop() { erouter->forgetListener(this); Transition::DoStop(); }
  
  	//!resets timer
! 	void resetTimer() {
! 		std::cout << "Reset @ " << get_time() << " stop @ " << get_time()+d << ' ' << this << std::endl;
! 		erouter->addTimer(this,0,d,false);
! 	}
  
  	//!if we receive the timer event, activate()
! 	virtual void processEvent(const EventBase& e) {
! 		std::cout << "Timeout @ " << get_time() << " from " << e.getName() << ' ' << this << std::endl;
  		activate();
  	}
+ 
+ 	virtual std::string getName() const { return "TimeOutTrans"; }
+ 
  protected:
  	//!amount to delay (in milliseconds) before transition
  	unsigned int d;
***************
*** 34,43 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 44,53 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Transitions/VisualTargetCloseTrans.h
diff -c AiboPup/Behaviors/Transitions/VisualTargetCloseTrans.h:1.1 AiboPup/Behaviors/Transitions/VisualTargetCloseTrans.h:1.5
*** AiboPup/Behaviors/Transitions/VisualTargetCloseTrans.h:1.1	Sat Mar  1 15:53:32 2003
--- AiboPup/Behaviors/Transitions/VisualTargetCloseTrans.h	Thu Sep 25 11:26:57 2003
***************
*** 5,29 ****
  #include "Events/EventRouter.h"
  #include "Events/VisionEvent.h"
  #include "Shared/debuget.h"
  
  //! causes a transition when a visual object is "close"
! class VisualTargetCloseTrans : public Transition, public EventListener {
  public:
  	//!constructor
! 	explicit VisualTargetCloseTrans(StateNode* source, StateNode* destination, VisionEventNS::VisionSourceID_t source_id) : Transition(source,destination), EventListener(), sid(source_id) {}
  
  	//!starts listening for the object specified by the source id in the constructor
! 	virtual void enable() { erouter->addListener(this,EventBase::visionEGID,sid); }
  
  	//!called by StateNode when it becomes inactive - undo whatever you did in Enable()
! 	virtual void disable() { erouter->forgetListener(this); }
  
  	//!if the object is "close", calls activate()
  	virtual void processEvent(const EventBase& e) {
  		const VisionEvent* ve=dynamic_cast<const VisionEvent*>(&e);
  		ASSERTRET(ve!=NULL,"Casting error");
! 		//!@todo need to activate if it's "close"
  	}
  protected:
  	//!Source ID of object to track
  	VisionEventNS::VisionSourceID_t sid;
--- 5,36 ----
  #include "Events/EventRouter.h"
  #include "Events/VisionEvent.h"
  #include "Shared/debuget.h"
+ #include "Shared/WorldState.h"
  
  //! causes a transition when a visual object is "close"
! class VisualTargetCloseTrans : public Transition {
  public:
  	//!constructor
! 	VisualTargetCloseTrans(StateNode* source, StateNode* destination, VisionEventNS::VisionSourceID_t source_id) : Transition(source,destination), sid(source_id) {}
  
  	//!starts listening for the object specified by the source id in the constructor
! 	virtual void DoStart() { Transition::DoStart(); erouter->addListener(this,EventBase::visionEGID,sid); }
  
  	//!called by StateNode when it becomes inactive - undo whatever you did in Enable()
! 	virtual void DoStop() { erouter->forgetListener(this); Transition::DoStop(); }
  
  	//!if the object is "close", calls activate()
  	virtual void processEvent(const EventBase& e) {
  		const VisionEvent* ve=dynamic_cast<const VisionEvent*>(&e);
  		ASSERTRET(ve!=NULL,"Casting error");
! 		float x=ve->getCenterX();
! 		float y=ve->getCenterY();
! 		if(x*x+y*y<0.02f && state->sensors[IRDistOffset]<300)
! 			activate();
  	}
+ 
+ 	virtual std::string getName() const { return "VisualTargetCloseTrans"; }
+ 
  protected:
  	//!Source ID of object to track
  	VisionEventNS::VisionSourceID_t sid;
***************
*** 34,43 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 41,50 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Behaviors/Transitions/VisualTargetTrans.h
diff -c /dev/null AiboPup/Behaviors/Transitions/VisualTargetTrans.h:1.5
*** /dev/null	Fri Oct 10 14:37:43 2003
--- AiboPup/Behaviors/Transitions/VisualTargetTrans.h	Thu Oct  2 23:40:23 2003
***************
*** 0 ****
--- 1,68 ----
+ //-*-c++-*-
+ #ifndef INCLUDED_VisualTargetTrans_h_
+ #define INCLUDED_VisualTargetTrans_h_
+ 
+ #include "Events/EventRouter.h"
+ #include "Events/VisionEvent.h"
+ #include "Shared/debuget.h"
+ #include "Shared/WorldState.h"
+ 
+ //! causes a transition when a visual object is "close"
+ class VisualTargetTrans : public Transition {
+ public:
+ 	//!constructor
+ 	VisualTargetTrans(StateNode* source, StateNode* destination, VisionEventNS::VisionSourceID_t source_id)
+ 		: Transition(source,destination), sid(source_id), count(0) {}
+ 
+ 	//!starts listening for the object specified by the source id in the constructor
+ 	virtual void DoStart() {
+ 		serr->printf("VisualTargetTrans::DoStart() - enter\n");
+ 		Transition::DoStart();
+ 		count=0;
+ 		erouter->addListener(this,EventBase::visionEGID,sid);
+ 		serr->printf("VisualTargetTrans::DoStart() - leave\n");
+ 	}
+ 
+ 	//!called by StateNode when it becomes inactive - undo whatever you did in Enable()
+ 	virtual void DoStop() {
+ 		serr->printf("VisualTargetTrans::DoStop() - enter\n");
+ 		erouter->forgetListener(this);
+ 		count=0;
+ 		Transition::DoStop();
+ 		serr->printf("VisualTargetTrans::DoStop() - leave\n");
+ 	}
+ 
+ 	//!if the object is "close", calls activate()
+ 	virtual void processEvent(const EventBase& e) {
+ 		serr->printf("VisualTargetTrans::processEvent() - enter %d\n",get_time());
+ 
+ 		if(e.getTypeID()==EventBase::deactivateETID)
+ 			count=0;
+ 		else
+ 			count++;
+ 		if(count>5)
+ 			activate();
+ 
+ 		serr->printf("VisualTargetTrans::processEvent() - leave %d\n",get_time());
+ 	}
+ 
+ 	virtual std::string getName() const { return "VisualTargetTrans"; }
+ 
+ protected:
+ 	//!Source ID of object to track
+ 	VisionEventNS::VisionSourceID_t sid;
+ 	unsigned int count;
+ };
+ 
+ /*! @file
+  * @brief Defines VisualTargetTrans, which causes a transition when a visual object is seen for a few frames
+  * @author ejt (Creator)
+  *
+  * $Author: ejt $
+  * $Name: HEAD $
+  * $Revision: 1.2 $
+  * $State: Exp $
+  * $Date: 2003/10/10 20:25:03 $
+  */
+ 
+ #endif
Index: AiboPup/Events/EventBase.cc
diff -c AiboPup/Events/EventBase.cc:1.10 AiboPup/Events/EventBase.cc:1.12
*** AiboPup/Events/EventBase.cc:1.10	Fri Apr 25 14:22:39 2003
--- AiboPup/Events/EventBase.cc	Mon Oct  6 21:00:28 2003
***************
*** 15,21 ****
  	"Locomotion",
  	"TextMsg",
  	"EStop",
! 	"MotionManager"
  };
  
  
--- 15,22 ----
  	"Locomotion",
  	"TextMsg",
  	"EStop",
! 	"MotionManager",
! 	"WMVariable"
  };
  
  
***************
*** 169,177 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 170,178 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Events/EventBase.h
diff -c AiboPup/Events/EventBase.h:1.12 AiboPup/Events/EventBase.h:1.14
*** AiboPup/Events/EventBase.h:1.12	Wed Apr  9 00:48:15 2003
--- AiboPup/Events/EventBase.h	Mon Oct  6 21:00:28 2003
***************
*** 49,54 ****
--- 49,55 ----
      textmsgEGID,      //!< Sends events when a text msg is received on console
  		estopEGID,        //!< Sends an event when the estop is turned on or off
  		motmanEGID,       //!< Sends events when a MotionCommand is added or removed
+ 		wmVarEGID,        //!< Sends an event when a watched memory is changed; source id is pointer to WMEntry
  		numEGIDs          //!< the number of generators available
  	};
  
***************
*** 140,149 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 141,150 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Events/EventListener.h
diff -c AiboPup/Events/EventListener.h:1.1.1.1 AiboPup/Events/EventListener.h:1.2
*** AiboPup/Events/EventListener.h:1.1.1.1	Mon Sep 30 14:19:47 2002
--- AiboPup/Events/EventListener.h	Thu Sep 25 11:27:10 2003
***************
*** 19,29 ****
   * @brief Defines EventListener class, an interface for anything that wants to receive events
   * @author ejt (Creator)
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 19,29 ----
   * @brief Defines EventListener class, an interface for anything that wants to receive events
   * @author ejt (Creator)
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Events/EventRouter.cc
diff -c AiboPup/Events/EventRouter.cc:1.8 AiboPup/Events/EventRouter.cc:1.10
*** AiboPup/Events/EventRouter.cc:1.8	Mon Jun  9 04:05:13 2003
--- AiboPup/Events/EventRouter.cc	Thu Oct  2 23:41:01 2003
***************
*** 150,161 ****
  	std::vector<EventTrapper*> t;
  	trappers.getMapping(e,t);
  	for(std::vector<EventTrapper*>::iterator it=t.begin(); it!=t.end(); it++)
! 		if((*it)->trapEvent(e))
! 			return;
  	std::vector<EventListener*> l;
  	listeners.getMapping(e,l);
  	for(std::vector<EventListener*>::iterator it=l.begin(); it!=l.end(); it++)
! 		(*it)->processEvent(e);
  	//	cout << "done." << flush;
  }
  
--- 150,163 ----
  	std::vector<EventTrapper*> t;
  	trappers.getMapping(e,t);
  	for(std::vector<EventTrapper*>::iterator it=t.begin(); it!=t.end(); it++)
! 		if(trappers.verifyMapping(*it,e))
! 			if((*it)->trapEvent(e))
! 				return;
  	std::vector<EventListener*> l;
  	listeners.getMapping(e,l);
  	for(std::vector<EventListener*>::iterator it=l.begin(); it!=l.end(); it++)
! 		if(listeners.verifyMapping(*it,e))
! 			(*it)->processEvent(e);
  	//	cout << "done." << flush;
  }
  
***************
*** 317,331 ****
  		ls.push_back(static_cast<T*>(*elit));
  }
  
  /*! @file
   * @brief Implements EventRouter class, for distribution and trapping of events to listeners
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  
--- 319,357 ----
  		ls.push_back(static_cast<T*>(*elit));
  }
  
+ bool EventRouter::EventMapper::verifyMapping(void * listener, EventBase::EventGeneratorID_t egid, unsigned int sid, EventBase::EventTypeID_t etid) {
+ 	// first get all the filtered subscribers (tricky!)
+ 	std::vector<void*>* elv=NULL;
+ 	SIDtoListenerVectorMap_t* sidtovm=filteredevents[egid][etid];
+ 	if(sidtovm!=NULL) { // if there's a map (at least one EL is filtering on this EGID and ETID)
+ 		SIDtoListenerVectorMap_t::iterator mapit=sidtovm->find(sid); // find listening for this source id
+ 		if(mapit!=sidtovm->end()) { // if there's at least one is filtering on this sourceID as well
+ 			elv=&(*mapit).second; // now go through them all
+ 			for(std::vector<void*>::iterator elit=elv->begin(); elit!=elv->end(); elit++)
+ 				if(*elit==listener)
+ 					return true;
+ 		}
+ 	}
+ 	// now get the 'all events' subscribers
+ 	elv=&allevents[egid];
+ 	for(std::vector<void*>::iterator elit=elv->begin(); elit!=elv->end(); elit++)
+ 		if(*elit==listener)
+ 			return true;
+ 
+ 	// if we haven't found it, doesn't exist:
+ 	return false;
+ }
+ 
+ 
  /*! @file
   * @brief Implements EventRouter class, for distribution and trapping of events to listeners
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  
Index: AiboPup/Events/EventRouter.h
diff -c AiboPup/Events/EventRouter.h:1.10 AiboPup/Events/EventRouter.h:1.12
*** AiboPup/Events/EventRouter.h:1.10	Fri Apr 25 14:22:39 2003
--- AiboPup/Events/EventRouter.h	Thu Oct  2 23:41:01 2003
***************
*** 111,118 ****
  	//@}
  
   protected:
! 	void doSendBuffer(); //!< does the work of clearing the buffer
! 	void doSendEvent(const EventBase& e); //!< does the work of sending an event
  
  	//! Contains all the information needed to maintain a timer by the EventRouter
  	struct TimerEntry {
--- 111,124 ----
  	//@}
  
   protected:
! 	void doSendBuffer(); //!< does the work of clearing the buffer (calls doSendEvent() )
! 	
! 	//! does the work of sending an event
! 	/*! Be aware this is an O(n^2) where n is the number of listeners for a particular event.
! 	 *  This is because after each call to processEvent, the list of listeners could have changed
! 	 *  so each listener much be verified before it is sent an event.  New listeners won't get the
! 	 *  current event, but neither should listeners which have just be removed */
! 	void doSendEvent(const EventBase& e); 
  
  	//! Contains all the information needed to maintain a timer by the EventRouter
  	struct TimerEntry {
***************
*** 200,208 ****
  
  		//@{
  		//! so stuff can tell if it even needs to bother generating an event...
! 		/* ... if a tree falls in a forest, and there's no one around to see it, does it make a sound?
! 			 ... if Vision sees a ball in an image, and there's no listeners, does it make an event? ;) */
! 		/*! @return true if it has any listeners, false otherwise */
  		bool hasMapping(EventBase::EventGeneratorID_t egid);
  		bool hasMapping(EventBase::EventGeneratorID_t egid, unsigned int sid);
  		bool hasMapping(EventBase::EventGeneratorID_t egid, unsigned int sid, EventBase::EventTypeID_t etid);
--- 206,214 ----
  
  		//@{
  		//! so stuff can tell if it even needs to bother generating an event...
! 		/*! ... if a tree falls in a forest, and there's no one around to see it, does it make a sound?\n
! 			  ... if Vision sees a ball in an image, and there's no listeners, does it make an event? ;) \n
! 			  @return true if it has any listeners, false otherwise */
  		bool hasMapping(EventBase::EventGeneratorID_t egid);
  		bool hasMapping(EventBase::EventGeneratorID_t egid, unsigned int sid);
  		bool hasMapping(EventBase::EventGeneratorID_t egid, unsigned int sid, EventBase::EventTypeID_t etid);
***************
*** 216,221 ****
--- 222,235 ----
  		template<class T>
  		void getMapping(const EventBase& e, std::vector<T*>& listeners);
  
+ 		//! Used to make sure that the specified listener exists for the given event
+ 		/*! This is needed because after we call processEvent on a lister, we can't assume
+ 		 *  that no other listeners have been modified - one listener could cause another
+ 		 *  to turn off.  If that has happened, we shouldn't send the event, even if it
+ 		 *  was in the queue originally. */
+ 		bool verifyMapping(void * listener, const EventBase& e) { return verifyMapping(listener,e.getGeneratorID(),e.getSourceID(),e.getTypeID()); }
+ 		bool verifyMapping(void * listener, EventBase::EventGeneratorID_t egid, unsigned int sid, EventBase::EventTypeID_t etid);
+ 
  	protected:
  		//! a mapping from source IDs (unsigned ints), each to a vector of pointers to listeners
  		/*! main use in filteredevents @see filteredevents */
***************
*** 244,253 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 258,267 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Events/EventTranslator.cc
diff -c AiboPup/Events/EventTranslator.cc:1.4 AiboPup/Events/EventTranslator.cc:1.5
*** AiboPup/Events/EventTranslator.cc:1.4	Thu Jun 12 19:41:40 2003
--- AiboPup/Events/EventTranslator.cc	Thu Sep 25 11:27:10 2003
***************
*** 86,94 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 86,94 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Events/EventTranslator.h
diff -c AiboPup/Events/EventTranslator.h:1.2 AiboPup/Events/EventTranslator.h:1.3
*** AiboPup/Events/EventTranslator.h:1.2	Thu Jun 12 19:41:40 2003
--- AiboPup/Events/EventTranslator.h	Thu Sep 25 11:27:10 2003
***************
*** 59,68 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 59,68 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Events/EventTrapper.h
diff -c AiboPup/Events/EventTrapper.h:1.1.1.1 AiboPup/Events/EventTrapper.h:1.2
*** AiboPup/Events/EventTrapper.h:1.1.1.1	Mon Sep 30 14:19:47 2002
--- AiboPup/Events/EventTrapper.h	Thu Sep 25 11:27:10 2003
***************
*** 25,35 ****
   * @brief Defines EventTrapper class, an interface for anything that wants to trap events
   * @author ejt (Creator)
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 25,35 ----
   * @brief Defines EventTrapper class, an interface for anything that wants to trap events
   * @author ejt (Creator)
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Events/LocomotionEvent.h
diff -c AiboPup/Events/LocomotionEvent.h:1.4 AiboPup/Events/LocomotionEvent.h:1.5
*** AiboPup/Events/LocomotionEvent.h:1.4	Sun Apr  6 16:57:44 2003
--- AiboPup/Events/LocomotionEvent.h	Thu Sep 25 11:27:10 2003
***************
*** 80,89 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 80,89 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Events/Makefile
diff -c AiboPup/Events/Makefile:1.8 AiboPup/Events/Makefile:removed
*** AiboPup/Events/Makefile:1.8	Tue Jun 10 21:18:55 2003
--- AiboPup/Events/Makefile	Fri Oct 10 14:37:44 2003
***************
*** 1,52 ****
- TEKKOTSU_TARGET_MODEL?=TGT_ERS2xx
- 
- SRCS:=$(shell find . -name "*.cc")
- 
- OBJS:=${SRCS:.cc=.o}
- DEPENDS:=${SRCS:.cc=.d}
- 
- OPENRSDK_ROOT?=/usr/local/OPEN_R_SDK
- CXX=$(OPENRSDK_ROOT)/bin/mipsel-linux-g++
- LD=$(OPENRSDK_ROOT)/bin/mipsel-linux-ld
- FILTERSYSWARN=../tools/filtersyswarn/filtersyswarn
- LIBS=-lObjectComm -lOPENR -lInternet -lantMCOOP
- CURDIR:=$(shell pwd | sed 's/.*\///')
- CXXFLAGS= \
- 	-g -O2 \
- 	-Wall -W -Wshadow -Wlarger-than-8192 -Wpointer-arith -Wcast-qual \
- 	-Woverloaded-virtual -Weffc++ -Winline -Wdeprecated \
- 	-I. -I.. -I../MMCombo -isystem $(OPENRSDK_ROOT)/OPEN_R/include/MCOOP \
- 	-isystem $(OPENRSDK_ROOT)/OPEN_R/include/R4000 -isystem $(OPENRSDK_ROOT)/OPEN_R/include \
- 	-DPLATFORM_APERIOS -DDEBUG -DOPENR_DEBUG \
- 	-D$(TEKKOTSU_TARGET_MODEL) $(GLOBAL_MAP) \
- 
- .PHONY: all clean
- 
- all: $(CURDIR)Lib.o
- 
- $(CURDIR)Lib.o : $(OBJS)
- 	@echo Linking object files...
- 	@echo "$@ <- $(OBJS)"
- 	@$(LD) -i $(OBJS) -o $@
- 
- %.o: %.cc %.d $(FILTERSYSWARN)
- 	@echo Compiling $< into $@...
- 	@$(CXX) $(CXXFLAGS) -o $@ -c $< > $*.log 2>&1; \
- 	retval=$$?; \
- 	cat $*.log | $(FILTERSYSWARN); \
- 	test $$retval -eq 0;
- 
- %.d : %.cc
- 	@echo Building $@ for $<
- 	@$(CXX) $(CXXFLAGS) -MP -MG -MT $@ -MT $*.o -MM $< > $@
- 
- $(FILTERSYSWARN):
- 	(cd ../tools && $(MAKE));
- 
- ifneq ($(MAKECMDGOALS),clean)
- -include $(DEPENDS)
- endif
- 
- 
- clean:
- 	rm -f $(CURDIR)Lib.o $(OBJS) $(DEPENDS) ${SRCS:.cc=.log} *~ 
--- 0 ----
Index: AiboPup/Events/TextMsgEvent.h
diff -c AiboPup/Events/TextMsgEvent.h:1.7 AiboPup/Events/TextMsgEvent.h:1.8
*** AiboPup/Events/TextMsgEvent.h:1.7	Thu Jun 12 19:41:40 2003
--- AiboPup/Events/TextMsgEvent.h	Thu Sep 25 11:27:10 2003
***************
*** 65,74 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 65,74 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Events/VisionEvent.h
diff -c AiboPup/Events/VisionEvent.h:1.7 AiboPup/Events/VisionEvent.h:1.9
*** AiboPup/Events/VisionEvent.h:1.7	Thu Jun 12 19:41:40 2003
--- AiboPup/Events/VisionEvent.h	Fri Sep 12 17:38:20 2003
***************
*** 8,20 ****
  namespace VisionEventNS {
  	//! contains source IDs for the objects we can recognize
    enum VisionSourceID_t {
      RedBallSID=0, //!< a red bean bag ball
-     PinkBallSID,  //!< the plastic pink ball Aibos ship with
      HandSID,      //!< Optimized for Ethan's hand, a pasty white thing.
      ThumbsupSID,  //!< Recognizes when Ethan is giving a thumbs up.
      ThingSID,     //!< Other stuff
!     MarkersSID    //!< never actually generated: data directly
!                   //!  reported to WorldModel
    };
  }
  
--- 8,19 ----
  namespace VisionEventNS {
  	//! contains source IDs for the objects we can recognize
    enum VisionSourceID_t {
+     PinkBallSID=0,//!< the plastic pink ball Aibos ship with
      RedBallSID=0, //!< a red bean bag ball
      HandSID,      //!< Optimized for Ethan's hand, a pasty white thing.
      ThumbsupSID,  //!< Recognizes when Ethan is giving a thumbs up.
      ThingSID,     //!< Other stuff
!     MarkersSID    //!< never actually generated: data directly reported to WorldModel
    };
  }
  
***************
*** 98,107 ****
   * @author alokl (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 97,106 ----
   * @author alokl (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/MMCombo/MMCombo.cc
diff -c AiboPup/MMCombo/MMCombo.cc:1.36 AiboPup/MMCombo/MMCombo.cc:1.40
*** AiboPup/MMCombo/MMCombo.cc:1.36	Thu Jun 12 14:06:11 2003
--- AiboPup/MMCombo/MMCombo.cc	Fri Oct 10 01:38:21 2003
***************
*** 11,16 ****
--- 11,17 ----
  #include "SoundPlay/SoundManager.h"
  #include "Vision/Vision.h"
  #include "Events/TextMsgEvent.h"
+ #include "Shared/WMclass.h"
  
  #include "Shared/ERS210Info.h"
  #include "Shared/ERS220Info.h"
***************
*** 79,84 ****
--- 80,87 ----
      wireless = new Wireless();
      sout=wireless->socket(SocketNS::SOCK_STREAM,Wireless::WIRELESS_DEF_RECV_SIZE,Wireless::WIRELESS_DEF_SEND_SIZE*6);
      serr=wireless->socket(SocketNS::SOCK_STREAM,Wireless::WIRELESS_DEF_RECV_SIZE,Wireless::WIRELESS_DEF_SEND_SIZE*2);
+     wireless->setDaemon(sout);
+     wireless->setDaemon(serr);
  		serr->setFlushType(SocketNS::FLUSH_BLOCKING);
      sout->setTextForward();
      serr->setForward(sout);
***************
*** 95,101 ****
  
      //Setup vision
      vision=new Vision();
! 
  	}
  	if(strcmp(objectName,"MotoObj")==0) {
  		ProcessID::setID(ProcessID::MotionProcess);
--- 98,108 ----
  
      //Setup vision
      vision=new Vision();
! 		// someday these will go away:
! 		vision->enableEvents(VisionEventNS::PinkBallSID);
! 		vision->enableEvents(VisionEventNS::RedBallSID);
! 		vision->enableEvents(VisionEventNS::MarkersSID);
! 	
  	}
  	if(strcmp(objectName,"MotoObj")==0) {
  		ProcessID::setID(ProcessID::MotionProcess);
***************
*** 416,437 ****
  	PROFSECTION("GotImage()",state->mainProfile);
  	etrans.translateEvents();
  
!   const OFbkImageVectorData *fbkImageVectorData=reinterpret_cast<const OFbkImageVectorData*>(event.Data(0));
!   OFbkImageInfo* info = const_cast<OFbkImageVectorData*>(fbkImageVectorData)->GetInfo(0);
!   const byte* dat = const_cast<OFbkImageVectorData*>(fbkImageVectorData)->GetData(0);
!   const OFbkImage yimage(info, const_cast<byte*>(dat), ofbkimageBAND_Y);
!   const OFbkImage uimage(info, const_cast<byte*>(dat), ofbkimageBAND_Cr);
!   const OFbkImage vimage(info, const_cast<byte*>(dat), ofbkimageBAND_Cb);
!             
!   const byte* bytes_y = yimage.Pointer();
!   const byte* bytes_u = uimage.Pointer();
!   const byte* bytes_v = vimage.Pointer();
! 
!   int width  = yimage.Width();
!   int height = yimage.Height();
! 
!   vision->processFrame(bytes_y, bytes_u, bytes_v, width, height);
!  
    erouter->processTimers();
    
    observer[obsImage]->AssertReady();
--- 423,447 ----
  	PROFSECTION("GotImage()",state->mainProfile);
  	etrans.translateEvents();
  
!   if (vision!=NULL) {
!     const OFbkImageVectorData *fbkImageVectorData=reinterpret_cast<const OFbkImageVectorData*>(event.Data(0));
!     OFbkImageInfo* info = const_cast<OFbkImageVectorData*>(fbkImageVectorData)->GetInfo(vision->imageLayer);
!     const byte* dat = const_cast<OFbkImageVectorData*>(fbkImageVectorData)->GetData(vision->imageLayer);
!     const OFbkImage yimage(info, const_cast<byte*>(dat), ofbkimageBAND_Y);
!     const OFbkImage uimage(info, const_cast<byte*>(dat), ofbkimageBAND_Cr);
!     const OFbkImage vimage(info, const_cast<byte*>(dat), ofbkimageBAND_Cb);
! 
!     const byte* bytes_y = yimage.Pointer();
!     const byte* bytes_u = uimage.Pointer();
!     const byte* bytes_v = vimage.Pointer();
! 
!     int width  = yimage.Width();
!     int height = yimage.Height();
! 
!     WMvari(int, frame_counter, 0);
!     ++frame_counter;
!     vision->processFrame(bytes_y, bytes_u, bytes_v, width, height, yimage.Skip());
!   }
    erouter->processTimers();
    
    observer[obsImage]->AssertReady();
***************
*** 628,637 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  
--- 638,647 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  
Index: AiboPup/MMCombo/MMCombo.h
diff -c AiboPup/MMCombo/MMCombo.h:1.20 AiboPup/MMCombo/MMCombo.h:1.22
*** AiboPup/MMCombo/MMCombo.h:1.20	Tue Jun 10 21:18:55 2003
--- AiboPup/MMCombo/MMCombo.h	Mon Jul 28 02:39:51 2003
***************
*** 7,12 ****
--- 7,13 ----
  #include "Wireless/Wireless.h"
  #include "Events/EventTranslator.h"
  
+ #include "MMCombo/entry.h"
  #include <OPENR/OObject.h>
  #include <OPENR/OSubject.h>
  #include <OPENR/OObserver.h>
***************
*** 68,74 ****
    
    void RPOPENR_ready(const OReadyEvent& /*event*/) { RPOPENR_isready=true; } //!< main only, called when //ALTODO
    void RPOPENR_notify(const ONotifyEvent& event);                            //!< main only, called when //ALTODO
!   
  protected:
  	void OpenPrimitives();                               //!< both, called from SetupOutputs() (mostly for motion, but main does ears), uses #open to tell which to open
  	void SetupOutputs(const bool to_open[NumOutputs]);   //!< both, called from DoInit() (mostly for motion, but main does ears)
--- 69,75 ----
    
    void RPOPENR_ready(const OReadyEvent& /*event*/) { RPOPENR_isready=true; } //!< main only, called when //ALTODO
    void RPOPENR_notify(const ONotifyEvent& event);                            //!< main only, called when //ALTODO
!  
  protected:
  	void OpenPrimitives();                               //!< both, called from SetupOutputs() (mostly for motion, but main does ears), uses #open to tell which to open
  	void SetupOutputs(const bool to_open[NumOutputs]);   //!< both, called from DoInit() (mostly for motion, but main does ears)
***************
*** 126,136 ****
   * @brief Describes MMCombo, the OObject which "forks" (sort of) into Main and Motion processes
   * @author ejt (Creator)
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 127,137 ----
   * @brief Describes MMCombo, the OObject which "forks" (sort of) into Main and Motion processes
   * @author ejt (Creator)
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/MMCombo/Makefile
diff -c AiboPup/MMCombo/Makefile:1.30 AiboPup/MMCombo/Makefile:removed
*** AiboPup/MMCombo/Makefile:1.30	Tue Jun 10 21:18:55 2003
--- AiboPup/MMCombo/Makefile	Fri Oct 10 14:37:44 2003
***************
*** 1,56 ****
- TEKKOTSU_TARGET_MODEL?=TGT_ERS2xx
- 
- SRCS=$(sort $(shell find . -name "*.cc") ./MMComboStub.cc)
- 
- OBJS=${SRCS:.cc=.o}
- DEPENDS=${SRCS:.cc=.d}
- 
- OPENRSDK_ROOT?=/usr/local/OPEN_R_SDK
- CXX=$(OPENRSDK_ROOT)/bin/mipsel-linux-g++
- LD=$(OPENRSDK_ROOT)/bin/mipsel-linux-ld
- STUBGEN=$(OPENRSDK_ROOT)/OPEN_R/bin/stubgen2
- FILTERSYSWARN=../tools/filtersyswarn/filtersyswarn
- CURDIR:=$(shell pwd | sed 's/.*\///')
- CXXFLAGS= \
- 	-g \
- 	-Wall -W -Wshadow -Wlarger-than-8192 -Wpointer-arith -Wcast-qual \
- 	-Woverloaded-virtual -Weffc++ -Winline -Wdeprecated \
- 	-I. -I.. -isystem $(OPENRSDK_ROOT)/OPEN_R/include/MCOOP \
- 	-isystem $(OPENRSDK_ROOT)/OPEN_R/include/R4000 -isystem $(OPENRSDK_ROOT)/OPEN_R/include \
- 	-DPLATFORM_APERIOS -DDEBUG -DOPENR_DEBUG \
- 	-D$(TEKKOTSU_TARGET_MODEL) $(GLOBAL_MAP) \
- 
- .PHONY: all
- 
- all: $(CURDIR)Lib.o
- 
- $(CURDIR)Lib.o : $(OBJS)
- 	@echo Linking object files...
- 	@echo "$@ <- $(OBJS)"
- 	@$(LD) -i $(OBJS) -o $@
- 
- %.o: %.cc %.d $(FILTERSYSWARN)
- 	@echo Compiling $< into $@...
- 	@$(CXX) $(CXXFLAGS) -o $@ -c $< > $*.log 2>&1; \
- 	retval=$$?; \
- 	cat $*.log | $(FILTERSYSWARN); \
- 	test $$retval -eq 0;
- 
- MMComboStub.cc: stub.cfg
- 	$(STUBGEN) stub.cfg	
- 
- %.d : %.cc
- 	@echo Building $@ for $<
- 	@$(CXX) $(CXXFLAGS) -MP -MG -MT $@ -MT $*.o -MM $< > $@
- 
- $(FILTERSYSWARN):
- 	(cd ../tools && $(MAKE));
- 
- ifneq ($(MAKECMDGOALS),clean)
- -include $(DEPENDS)
- endif
- 
- 
- clean:
- 	rm -f $(CURDIR)Lib.o $(OBJS) $(DEPENDS) ${SRCS:.cc=.log} *~
- 	rm -f *.o MMComboStub.* def.h entry.h
--- 0 ----
Index: AiboPup/Motion/DynamicMotionSequence.h
diff -c AiboPup/Motion/DynamicMotionSequence.h:1.3 AiboPup/Motion/DynamicMotionSequence.h:1.4
*** AiboPup/Motion/DynamicMotionSequence.h:1.3	Fri Apr 25 14:22:39 2003
--- AiboPup/Motion/DynamicMotionSequence.h	Thu Sep 25 11:27:22 2003
***************
*** 112,121 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 112,121 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Motion/EmergencyStopMC.cc
diff -c AiboPup/Motion/EmergencyStopMC.cc:1.13 AiboPup/Motion/EmergencyStopMC.cc:1.14
*** AiboPup/Motion/EmergencyStopMC.cc:1.13	Tue Jun 10 14:30:00 2003
--- AiboPup/Motion/EmergencyStopMC.cc	Thu Sep 25 11:27:22 2003
***************
*** 137,145 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 137,145 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Motion/EmergencyStopMC.h
diff -c AiboPup/Motion/EmergencyStopMC.h:1.7 AiboPup/Motion/EmergencyStopMC.h:1.8
*** AiboPup/Motion/EmergencyStopMC.h:1.7	Tue May 13 17:40:10 2003
--- AiboPup/Motion/EmergencyStopMC.h	Sun Sep  7 18:14:01 2003
***************
*** 15,21 ****
   *  to whatever their current state is.  LEDs are left blank, except the tail,
   *  which is used to indicate that the emergency stop is on.
   *
!  *  A second double-tap will cause it to set all joints to MotionCommand::unusedJoint
   *
   *  The tail LEDs only ever go up to .5, so that if you really care whether the tail
   *  light was set by an underlying behavior/motion, you should be able to tell by
--- 15,21 ----
   *  to whatever their current state is.  LEDs are left blank, except the tail,
   *  which is used to indicate that the emergency stop is on.
   *
!  *  A second double-tap will cause it to set all joints to 0 weight
   *
   *  The tail LEDs only ever go up to .5, so that if you really care whether the tail
   *  light was set by an underlying behavior/motion, you should be able to tell by
***************
*** 60,69 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 60,69 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Motion/Geometry.h
diff -c AiboPup/Motion/Geometry.h:1.2 AiboPup/Motion/Geometry.h:1.3
*** AiboPup/Motion/Geometry.h:1.2	Fri Jan 17 18:15:51 2003
--- AiboPup/Motion/Geometry.h	Thu Sep 25 11:27:22 2003
***************
*** 51,60 ****
   * @verbinclude CMPack_license.txt
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 51,60 ----
   * @verbinclude CMPack_license.txt
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Motion/HeadPointerMC.cc
diff -c AiboPup/Motion/HeadPointerMC.cc:1.6 AiboPup/Motion/HeadPointerMC.cc:1.8
*** AiboPup/Motion/HeadPointerMC.cc:1.6	Thu Jun 12 19:41:40 2003
--- AiboPup/Motion/HeadPointerMC.cc	Sun Sep  7 18:14:01 2003
***************
*** 3,17 ****
  #include "Shared/WorldState.h"
  #include "MotionManager.h"
  #include <math.h>
! 
! const OutputCmd HeadPointerMC::unused;
  
  HeadPointerMC::HeadPointerMC() :
  	MotionCommand(), dirty(true), active(true) {
  	setWeight(1);
  	for(unsigned int i=0; i<NumHeadJoints; i++) {
  		headModes[i]=BodyRelative;
  		headValues[i]=0;
  	}
  }
  
--- 3,18 ----
  #include "Shared/WorldState.h"
  #include "MotionManager.h"
  #include <math.h>
! #include "Shared/Config.h"
  
  HeadPointerMC::HeadPointerMC() :
  	MotionCommand(), dirty(true), active(true) {
  	setWeight(1);
+ 	defaultMaxSpeed();
  	for(unsigned int i=0; i<NumHeadJoints; i++) {
  		headModes[i]=BodyRelative;
  		headValues[i]=0;
+ 		headJoints[i].value=state->outputs[HeadOffset+i];
  	}
  }
  
***************
*** 28,33 ****
--- 29,40 ----
  	dirty=true;
  }
  
+ void HeadPointerMC::defaultMaxSpeed() {
+ 	maxSpeed[TiltOffset]=config->motion.max_head_tilt_speed*FrameTime/1000;
+ 	maxSpeed[PanOffset]=config->motion.max_head_pan_speed*FrameTime/1000;
+ 	maxSpeed[RollOffset]=config->motion.max_head_roll_speed*FrameTime/1000;
+ }
+ 
  void HeadPointerMC::setMode(CoordFrame_t m, bool conv) {
  	for(unsigned int x=0; x<NumHeadJoints; x++)
  		setJointMode((RobotInfo::TPROffset_t)x,m,conv);
***************
*** 45,57 ****
  	if(tmp) {
  		dirty=false;
  		for(unsigned int i=0; i<NumHeadJoints; i++) {
  			if(headModes[i]!=BodyRelative) {
! 				headJoints[i].value=convToBodyRelative((RobotInfo::TPROffset_t)i,headValues[i],headModes[i]);
  				dirty=true;
  			} else
! 				headJoints[i].value=headValues[i];
! 			for(unsigned int f=0; f<NumFrames; f++)
  				motman->setOutput(this,i+HeadOffset,headJoints[i]);
  		}
  	}
  	return tmp;
--- 52,86 ----
  	if(tmp) {
  		dirty=false;
  		for(unsigned int i=0; i<NumHeadJoints; i++) {
+ 			float value;
  			if(headModes[i]!=BodyRelative) {
! 				value=convToBodyRelative((RobotInfo::TPROffset_t)i,headValues[i],headModes[i]);
  				dirty=true;
  			} else
! 				value=headValues[i];
! 			if(maxSpeed[i]<=0)
! 				headJoints[i].value=value;
! 			if(value==headJoints[i].value) {
  				motman->setOutput(this,i+HeadOffset,headJoints[i]);
+ 			} else { // we're trying to exceeded maxSpeed
+ 				unsigned int f=0;
+ 				while(value>headJoints[i].value+maxSpeed[i] && f<NumFrames) {
+ 					headJoints[i].value+=maxSpeed[i];
+ 					motman->setOutput(this,i+HeadOffset,headJoints[i],f);
+ 					f++;
+ 				}
+ 				while(value<headJoints[i].value-maxSpeed[i] && f<NumFrames) {
+ 					headJoints[i].value-=maxSpeed[i];
+ 					motman->setOutput(this,i+HeadOffset,headJoints[i],f);
+ 					f++;
+ 				}
+ 				if(f<NumFrames) { //we reached target value, fill in rest of frames
+ 					headJoints[i].value=value;
+ 					for(;f<NumFrames;f++)
+ 						motman->setOutput(this,i+HeadOffset,headJoints[i],f);
+ 				} else // we didn't reach target value, still dirty
+ 					dirty=true;
+ 			}
  		}
  	}
  	return tmp;
***************
*** 62,72 ****
  	if(i<NumHeadJoints && getActive())
  		return headJoints[i];
  	else
! 		return unused;
  }
  
  /*! @todo this is perhaps a bit amateurish - could be more accurate */
! double HeadPointerMC::convToBodyRelative(RobotInfo::TPROffset_t i, double v, CoordFrame_t mode) const {
  	switch(mode) {
  	default:
  		ASSERT(false,"Passed bad mode "<<mode);
--- 91,101 ----
  	if(i<NumHeadJoints && getActive())
  		return headJoints[i];
  	else
! 		return OutputCmd::unused;
  }
  
  /*! @todo this is perhaps a bit amateurish - could be more accurate */
! double HeadPointerMC::convToBodyRelative(TPROffset_t i, double v, CoordFrame_t mode) const {
  	switch(mode) {
  	default:
  		ASSERT(false,"Passed bad mode "<<mode);
***************
*** 92,98 ****
  }
  
  /*! @todo this is perhaps a bit amateurish - could be more accurate */
! double HeadPointerMC::convFromBodyRelative(RobotInfo::TPROffset_t i, double v, CoordFrame_t mode) const {
  	switch(mode) {
  	default:
  		ASSERT(false,"Passed bad mode "<<mode);
--- 121,127 ----
  }
  
  /*! @todo this is perhaps a bit amateurish - could be more accurate */
! double HeadPointerMC::convFromBodyRelative(TPROffset_t i, double v, CoordFrame_t mode) const {
  	switch(mode) {
  	default:
  		ASSERT(false,"Passed bad mode "<<mode);
***************
*** 123,132 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  
--- 152,161 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  
Index: AiboPup/Motion/HeadPointerMC.h
diff -c AiboPup/Motion/HeadPointerMC.h:1.5 AiboPup/Motion/HeadPointerMC.h:1.7
*** AiboPup/Motion/HeadPointerMC.h:1.5	Sun Jul  6 21:00:08 2003
--- AiboPup/Motion/HeadPointerMC.h	Sun Sep  7 18:14:01 2003
***************
*** 25,30 ****
--- 25,35 ----
  	inline void   setActive(bool a)                                  { active=a; } //!< sets #active flag, see isDirty()
  	inline bool   getActive() const                                  { return active; } //!< returns #active flag, see isDirty()
  
+ 	       void   noMaxSpeed()                                       { for(unsigned int i=0; i<NumHeadJoints; i++) maxSpeed[i]=0; } //!< sets #maxSpeed to 0 (no maximum)
+ 	       void   defaultMaxSpeed();                                 //!< restores #maxSpeed to default settings from Config::Motion_Config
+ 	       void   setMaxSpeed(TPROffset_t i, float x)                { maxSpeed[i]=x*FrameTime/1000; } //!< sets #maxSpeed, pass it rad/sec
+ 	       float  getMaxSpeed(TPROffset_t i)                         { return maxSpeed[i]*1000/FrameTime; } //!< returns #maxSpeed in rad/sec
+ 
  	//! converts a value @a v in @a srcmode to a value in @a tgtmode that would leave the joint angle for joint @a i constant (you probably won't need to call this directly)
  	inline double convert(RobotInfo::TPROffset_t i, double v, CoordFrame_t srcmode, CoordFrame_t tgtmode) const {
  		return (srcmode==tgtmode)?v:convFromBodyRelative(i,convToBodyRelative(i, v, srcmode),tgtmode);
***************
*** 50,64 ****
  	//@}
  
   protected:
! 	double convToBodyRelative(RobotInfo::TPROffset_t i, double v, CoordFrame_t mode) const;   //!< converts to a body relative measurement for joint @a i
! 	double convFromBodyRelative(RobotInfo::TPROffset_t i, double v, CoordFrame_t mode) const; //!< converts from a body relative measurement for joint @a i
  
  	bool dirty;                         //!< true if a change has been made since last call to updateJointCmds()
  	bool active;                        //!< set by accessor functions, defaults to true
! 	OutputCmd headJoints[NumHeadJoints]; //!< stores the current target head angles
! 	double headValues[NumHeadJoints];   //!< stores the target value of each joint, relative to #headModes
  	CoordFrame_t headModes[NumHeadJoints];    //!< stores the current mode of each joint, for instance so tilt can be GravityRelative while pan is static
! 	static const OutputCmd unused;      //!< handy when we need a reference to an unused joint
  };
  
  /*! @file
--- 55,70 ----
  	//@}
  
   protected:
! 	double convToBodyRelative(TPROffset_t i, double v, CoordFrame_t mode) const;   //!< converts to a body relative measurement for joint @a i
! 	double convFromBodyRelative(TPROffset_t i, double v, CoordFrame_t mode) const; //!< converts from a body relative measurement for joint @a i
  
  	bool dirty;                         //!< true if a change has been made since last call to updateJointCmds()
  	bool active;                        //!< set by accessor functions, defaults to true
! 	OutputCmd headJoints[NumHeadJoints]; //!< stores the last values we sent from updateOutputs
! 	float headValues[NumHeadJoints];   //!< stores the target value of each joint, relative to #headModes
  	CoordFrame_t headModes[NumHeadJoints];    //!< stores the current mode of each joint, for instance so tilt can be GravityRelative while pan is static
! 	
! 	float maxSpeed[NumHeadJoints];   //!< initialized from Config::motion_config, but can be overridden by setMaxSpeed(); rad per frame
  };
  
  /*! @file
***************
*** 66,75 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 72,81 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Motion/Kinematics.cc
diff -c AiboPup/Motion/Kinematics.cc:1.3 AiboPup/Motion/Kinematics.cc:1.4
*** AiboPup/Motion/Kinematics.cc:1.3	Fri Jan 17 18:15:51 2003
--- AiboPup/Motion/Kinematics.cc	Thu Sep 25 11:27:22 2003
***************
*** 448,456 ****
   * @verbinclude CMPack_license.txt
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 448,456 ----
   * @verbinclude CMPack_license.txt
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Motion/Kinematics.h
diff -c AiboPup/Motion/Kinematics.h:1.6 AiboPup/Motion/Kinematics.h:1.7
*** AiboPup/Motion/Kinematics.h:1.6	Sun Mar  2 20:18:13 2003
--- AiboPup/Motion/Kinematics.h	Thu Sep 25 11:27:22 2003
***************
*** 109,118 ****
   * @verbinclude CMPack_license.txt
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 109,118 ----
   * @verbinclude CMPack_license.txt
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Motion/LedEngine.cc
diff -c AiboPup/Motion/LedEngine.cc:1.8 AiboPup/Motion/LedEngine.cc:1.9
*** AiboPup/Motion/LedEngine.cc:1.8	Tue Jun 10 14:30:00 2003
--- AiboPup/Motion/LedEngine.cc	Thu Sep 25 11:27:23 2003
***************
*** 287,294 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
--- 287,294 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
Index: AiboPup/Motion/LedEngine.h
diff -c AiboPup/Motion/LedEngine.h:1.9 AiboPup/Motion/LedEngine.h:1.10
*** AiboPup/Motion/LedEngine.h:1.9	Thu Jun 12 14:06:11 2003
--- AiboPup/Motion/LedEngine.h	Thu Sep 25 11:27:23 2003
***************
*** 160,169 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 160,169 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Motion/LedMC.h
diff -c AiboPup/Motion/LedMC.h:1.5 AiboPup/Motion/LedMC.h:1.6
*** AiboPup/Motion/LedMC.h:1.5	Tue Mar  4 02:00:15 2003
--- AiboPup/Motion/LedMC.h	Thu Sep 25 11:27:23 2003
***************
*** 46,55 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 46,55 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Motion/MMAccessor.h
diff -c AiboPup/Motion/MMAccessor.h:1.7 AiboPup/Motion/MMAccessor.h:1.8
*** AiboPup/Motion/MMAccessor.h:1.7	Sat Mar  8 21:45:23 2003
--- AiboPup/Motion/MMAccessor.h	Fri Sep 12 17:38:46 2003
***************
*** 59,83 ****
  			mcptr=(MC_t*)motman->peekMotion(id);
  	}
  
! 	//! copy constructor - will reference the same mc_id - checkin/checkouts are NOT independent between this and @a a - they will be linked
! 	MMAccessor(const MMAccessor& a) : mc_id(a.mc_id), mcptr(a.mcptr) {}
  
  	//! destructor, checks in if needed
  	~MMAccessor() {
! 		while(motman->checkoutLevel(mc_id)>0)
! 			checkin();
  	}
  
  	//! allows assignment of MMAccessor's, similar to the copy constructor - the two MMAccessor's will control the same MotionCommand
  	MMAccessor<MC_t> operator=(const MMAccessor<MC_t>& a) {
  		mc_id=a.mc_id;
  		mcptr=a.mcptr;
  		return *this;
  	}
  	
  	//! So you can check out if not done by default (or you checked in already)
  	inline MC_t* checkout() {
! 		return mcptr=dynamic_cast<MC_t*>(motman->checkoutMotion(mc_id)); //!< @test can this be a dynamic_cast?
  	}
  
  	//! Returns the motion command's address so you can call functions
--- 59,92 ----
  			mcptr=(MC_t*)motman->peekMotion(id);
  	}
  
! 	//! constructor, allows objects to provide uniform access to MotionCommands, regardless of whether they are currently in the MotionManager
! 	MMAccessor(MotionCommand * ptr) : mc_id(invalid_MC_ID), mcptr(ptr) {}
! 
! 	//! copy constructor - will reference the same mc_id - checkin/checkouts are independent between this and @a a - motman does counting of checkin/checkouts
! 	MMAccessor(const MMAccessor& a) : mc_id(a.mc_id), mcptr(a.mcptr) {
! 		if(motman->isOwner(mc_id))
! 			checkout();
! 	}
  
  	//! destructor, checks in if needed
  	~MMAccessor() {
! 		checkin();
  	}
  
  	//! allows assignment of MMAccessor's, similar to the copy constructor - the two MMAccessor's will control the same MotionCommand
  	MMAccessor<MC_t> operator=(const MMAccessor<MC_t>& a) {
  		mc_id=a.mc_id;
  		mcptr=a.mcptr;
+ 		if(motman->isOwner(mc_id))
+ 			checkout();
  		return *this;
  	}
  	
  	//! So you can check out if not done by default (or you checked in already)
  	inline MC_t* checkout() {
! 		if(mc_id!=MotionManager::invalid_MC_ID)
! 			mcptr=dynamic_cast<MC_t*>(motman->checkoutMotion(mc_id)); 
! 		return mcptr;
  	}
  
  	//! Returns the motion command's address so you can call functions
***************
*** 86,92 ****
  	//! Checks in the motion
  	/*! Don't forget, you can also just limit the scope using extra { }'s */
  	inline void checkin() {
! 		motman->checkinMotion(mc_id);
  	}
  
  	//! Checks in the motion, passing through the value it is passed.
--- 95,104 ----
  	//! Checks in the motion
  	/*! Don't forget, you can also just limit the scope using extra { }'s */
  	inline void checkin() {
! 		if(motman->isOwner(mc_id)) {
! 			motman->checkinMotion(mc_id);
! 			mcptr=NULL; // fail fast if we use it after checkin
! 		}
  	}
  
  	//! Checks in the motion, passing through the value it is passed.
***************
*** 116,122 ****
  	 *  @endcode*/
  	template<class Ret_t> Ret_t checkin(Ret_t ret) {
  		checkin();
- 		mcptr=NULL;
  		return ret;
  	}
  
--- 128,133 ----
***************
*** 137,146 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 148,157 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Motion/Makefile
diff -c AiboPup/Motion/Makefile:1.8 AiboPup/Motion/Makefile:removed
*** AiboPup/Motion/Makefile:1.8	Tue Jun 10 21:18:55 2003
--- AiboPup/Motion/Makefile	Fri Oct 10 14:37:44 2003
***************
*** 1,52 ****
- TEKKOTSU_TARGET_MODEL?=TGT_ERS2xx
- 
- SRCS:=$(shell find . -name "*.cc")
- 
- OBJS:=${SRCS:.cc=.o}
- DEPENDS:=${SRCS:.cc=.d}
- 
- OPENRSDK_ROOT?=/usr/local/OPEN_R_SDK
- CXX=$(OPENRSDK_ROOT)/bin/mipsel-linux-g++
- LD=$(OPENRSDK_ROOT)/bin/mipsel-linux-ld
- FILTERSYSWARN=../tools/filtersyswarn/filtersyswarn
- LIBS=-lObjectComm -lOPENR -lInternet -lantMCOOP
- CURDIR:=$(shell pwd | sed 's/.*\///')
- CXXFLAGS= \
- 	-g -O2 \
- 	-Wall -W -Wshadow -Wlarger-than-8192 -Wpointer-arith -Wcast-qual \
- 	-Woverloaded-virtual -Weffc++ -Winline -Wdeprecated \
- 	-I. -I.. -I../MMCombo -isystem $(OPENRSDK_ROOT)/OPEN_R/include/MCOOP \
- 	-isystem $(OPENRSDK_ROOT)/OPEN_R/include/R4000 -isystem $(OPENRSDK_ROOT)/OPEN_R/include \
- 	-DPLATFORM_APERIOS -DDEBUG -DOPENR_DEBUG \
- 	-D$(TEKKOTSU_TARGET_MODEL) $(GLOBAL_MAP) \
- 
- .PHONY: all clean
- 
- all: $(CURDIR)Lib.o
- 
- $(CURDIR)Lib.o : $(OBJS)
- 	@echo Linking object files...
- 	@echo "$@ <- $(OBJS)"
- 	@$(LD) -i $(OBJS) -o $@
- 
- %.o: %.cc %.d $(FILTERSYSWARN)
- 	@echo Compiling $< into $@...
- 	@$(CXX) $(CXXFLAGS) -o $@ -c $< > $*.log 2>&1; \
- 	retval=$$?; \
- 	cat $*.log | $(FILTERSYSWARN); \
- 	test $$retval -eq 0;
- 
- %.d : %.cc
- 	@echo Building $@ for $<
- 	@$(CXX) $(CXXFLAGS) -MP -MG -MT $@ -MT $*.o -MM $< > $@
- 
- $(FILTERSYSWARN):
- 	(cd ../tools && $(MAKE));
- 
- ifneq ($(MAKECMDGOALS),clean)
- -include $(DEPENDS)
- endif
- 
- 
- clean:
- 	rm -f $(CURDIR)Lib.o $(OBJS) $(DEPENDS) ${SRCS:.cc=.log} *~ 
--- 0 ----
Index: AiboPup/Motion/MotionCommand.cc
diff -c AiboPup/Motion/MotionCommand.cc:1.2 AiboPup/Motion/MotionCommand.cc:1.3
*** AiboPup/Motion/MotionCommand.cc:1.2	Thu Jun 12 19:41:40 2003
--- AiboPup/Motion/MotionCommand.cc	Thu Sep 25 11:27:23 2003
***************
*** 7,15 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 7,15 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Motion/MotionCommand.h
diff -c AiboPup/Motion/MotionCommand.h:1.15 AiboPup/Motion/MotionCommand.h:1.16
*** AiboPup/Motion/MotionCommand.h:1.15	Tue Apr  8 23:33:56 2003
--- AiboPup/Motion/MotionCommand.h	Mon Jul 28 01:55:16 2003
***************
*** 101,107 ****
  	virtual void DoStart() { started=true; }
  
  	//! called after this is removed from MotionManager
! 	virtual void DoStop() { started=false; }
  
  	//! returns true if the MotionCommand is currently running (although it may be overridden by a higher priority MotionCommand)
  	virtual bool isActive() const { return started; }
--- 101,107 ----
  	virtual void DoStart() { started=true; }
  
  	//! called after this is removed from MotionManager
! 	virtual void DoStop() { started=false; clearID(); }
  
  	//! returns true if the MotionCommand is currently running (although it may be overridden by a higher priority MotionCommand)
  	virtual bool isActive() const { return started; }
***************
*** 166,175 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 166,175 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Motion/MotionManager.cc
diff -c AiboPup/Motion/MotionManager.cc:1.22 AiboPup/Motion/MotionManager.cc:1.25
*** AiboPup/Motion/MotionManager.cc:1.22	Thu Jun 12 00:16:43 2003
--- AiboPup/Motion/MotionManager.cc	Mon Oct  6 21:00:40 2003
***************
*** 9,15 ****
  #include <list>
  
  MotionManager * motman=NULL;
! unsigned int MotionManager::_MMaccID=-1U;
  
  const float MotionManager::kIgnoredPriority    =-1;
  const float MotionManager::kBackgroundPriority = 0;
--- 9,15 ----
  #include <list>
  
  MotionManager * motman=NULL;
! int MotionManager::_MMaccID=-1U;
  
  const float MotionManager::kIgnoredPriority    =-1;
  const float MotionManager::kBackgroundPriority = 0;
***************
*** 423,433 ****
--- 423,437 ----
  	}
  	cmdlist[mc_id].baseaddrs[_MMaccID]=mc;
  	cmdlist[mc_id].rcr[_MMaccID]=sm.getRegion();
+ 	//cout << "addMotion(): sm.getRegion()->NumberOfReference()==" << sm.getRegion()->NumberOfReference() << endl;
+ 	cmdlist[mc_id].rcr[_MMaccID]->AddReference();
+ 	//cout << "addMotion()NOW: sm.getRegion()->NumberOfReference()==" << sm.getRegion()->NumberOfReference() << endl;
  	cmdlist[mc_id].lastAccessor=_MMaccID;
  	cmdlist[mc_id].priority=kStdPriority;
  	mc->setAdd(mc_id);
  	OStatus err;
  	ASSERT((err=subjs[_MMaccID]->SetData(sm.getRegion()))==oSUCCESS,"*** ERROR MotionManager: SetData returned " << err);
+ 	//cout << "addMotion()afterSetData: sm.getRegion()->NumberOfReference()==" << sm.getRegion()->NumberOfReference() << endl;
  	ASSERT((err=subjs[_MMaccID]->NotifyObservers())==oSUCCESS,"*** ERROR MotionManager: NotifyObservers returned " << err);
  	//	cout << "addMotion-done" << endl;
  	return func_end(mc_id);
***************
*** 476,482 ****
--- 480,488 ----
  		MC_ID mc_id=mminfo->mc_id;
  		switch(mminfo->type) {
  		case MotionManagerMsg::addMotion: {
+ 			//cout << "receiveMotion(): rcr->NumberOfReference()==" << rcr->NumberOfReference() << endl;
  			rcr->AddReference();
+ 			//cout << "receiveMotion()NOW: rcr->NumberOfReference()==" << rcr->NumberOfReference() << endl;
  			cmdlist[mc_id].rcr[_MMaccID]=rcr;
  			//should be able to do a nice dynamic cast instead of a static one
  			// but it gives NULL for some reason - i blame having to do the fork trick
***************
*** 485,491 ****
--- 491,499 ----
  			cmdlist[mc_id].baseaddrs[_MMaccID]->DoStart();
  		} break;
  		case MotionManagerMsg::deleteMotion: {
+ 			//cout << "deleteMotion(): cmdlist[mc_id].rcr[_MMaccID]->NumberOfReference()==" << cmdlist[mc_id].rcr[_MMaccID]->NumberOfReference() << endl;
  			cmdlist[mc_id].rcr[_MMaccID]->RemoveReference();
+ 			//cout << "deleteMotion()NOW: cmdlist[mc_id].rcr[_MMaccID]->NumberOfReference()==" << cmdlist[mc_id].rcr[_MMaccID]->NumberOfReference() << endl;
  		} break;
  		default:
  			printf("*** WARNING *** unknown MotionManager msg type received\n");
***************
*** 530,539 ****
  
  void
  MotionManager::checkinMotion(MC_ID mcid) {
! 	cmdlist[mcid].lock.release();
  }
  
- //! @test do i do this right, or does it leak memory?
  void
  MotionManager::removeMotion(MC_ID mcid) {
  	if(mcid==invalid_MC_ID)
--- 538,547 ----
  
  void
  MotionManager::checkinMotion(MC_ID mcid) {
! 	if(mcid!=invalid_MC_ID)
! 		cmdlist[mcid].lock.release();
  }
  
  void
  MotionManager::removeMotion(MC_ID mcid) {
  	if(mcid==invalid_MC_ID)
***************
*** 547,553 ****
--- 555,563 ----
  	dmsg.setDelete(mcid);
  	subjs[_MMaccID]->SetData(&dmsg,sizeof(dmsg));
  	subjs[_MMaccID]->NotifyObservers();
+ 	//cout << "removeMotion(): cmdlist[mcid].rcr[_MMaccID]->NumberOfReference()==" << cmdlist[mcid].rcr[_MMaccID]->NumberOfReference() << endl;
  	cmdlist[mcid].rcr[_MMaccID]->RemoveReference();
+ 	//cout << "removeMotion()NOW: cmdlist[mcid].rcr[_MMaccID]->NumberOfReference()==" << cmdlist[mcid].rcr[_MMaccID]->NumberOfReference() << endl;
  #endif //PLATFORM_APERIOS
  	push_free(mcid);
  	checkinMotion(mcid);
***************
*** 647,656 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  
--- 657,666 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  
Index: AiboPup/Motion/MotionManager.h
diff -c AiboPup/Motion/MotionManager.h:1.13 AiboPup/Motion/MotionManager.h:1.15
*** AiboPup/Motion/MotionManager.h:1.13	Fri Apr 25 14:22:40 2003
--- AiboPup/Motion/MotionManager.h	Fri Sep 12 17:38:47 2003
***************
*** 63,69 ****
  	static const unsigned int MAX_MOTIONS=64;   //!< This is the maximum number of Motions which can be managed, can probably be increased reasonably without trouble
  
  	typedef MotionManagerMsg::MC_ID MC_ID;      //!< use this type when referring to the ID numbers that MotionManager hands out
! 	static const MC_ID invalid_MC_ID=(MC_ID)-1; //!< for errors and undefined stuff
  
  	MotionManager();                            //!< Constructor, sets all the outputs to 0
  
--- 63,69 ----
  	static const unsigned int MAX_MOTIONS=64;   //!< This is the maximum number of Motions which can be managed, can probably be increased reasonably without trouble
  
  	typedef MotionManagerMsg::MC_ID MC_ID;      //!< use this type when referring to the ID numbers that MotionManager hands out
! 	static const MC_ID invalid_MC_ID=MotionManagerMsg::invalid_MC_ID; //!< for errors and undefined stuff
  
  	MotionManager();                            //!< Constructor, sets all the outputs to 0
  
***************
*** 95,102 ****
  	//!@name MotionCommand "Risky"
  	MotionCommand * checkoutMotion(MC_ID mcid,bool block=true); //!< locks the command and possibly performs RTTI conversion; supports recursive calls
  	void checkinMotion(MC_ID mcid); //!< marks a MotionCommand as unused
! 	MotionCommand * peekMotion(MC_ID mcid) { return cmdlist[mcid].baseaddrs[_MMaccID]; } //!< allows access to a MotionCommand without checking it out @warning @b never call a function based on this, only access member fields through it
! 	unsigned int checkoutLevel(MC_ID mcid) { return cmdlist[mcid].lock.get_lock_level(); } //!< returns the number of times @a mcid has been checked out minus the times it's been checked in
  	//@}
  
  	//!@name MotionCommand Unsafe
--- 95,103 ----
  	//!@name MotionCommand "Risky"
  	MotionCommand * checkoutMotion(MC_ID mcid,bool block=true); //!< locks the command and possibly performs RTTI conversion; supports recursive calls
  	void checkinMotion(MC_ID mcid); //!< marks a MotionCommand as unused
! 	MotionCommand * peekMotion(MC_ID mcid) { return mcid==invalid_MC_ID?NULL:cmdlist[mcid].baseaddrs[_MMaccID]; } //!< allows access to a MotionCommand without checking it out @warning @b never call a function based on this, only access member fields through it
! 	unsigned int checkoutLevel(MC_ID mcid) { return mcid==invalid_MC_ID?0:cmdlist[mcid].lock.get_lock_level(); } //!< returns the number of times @a mcid has been checked out minus the times it's been checked in
! 	bool isOwner(MC_ID mcid) { return mcid==invalid_MC_ID?false:(cmdlist[mcid].lock.owner()==_MMaccID); }
  	//@}
  
  	//!@name MotionCommand Unsafe
***************
*** 217,223 ****
  	OSubject* subjs[MAX_ACCESS];           //!<The OSubject for each process (accessor) on which it should be broadcast when a command is added
  #endif
  
! 	static unsigned int _MMaccID;          //!<Stores the accessor for the current process
  
  private:
  	MotionManager(const MotionManager&); //!< this shouldn't be called...
--- 218,224 ----
  	OSubject* subjs[MAX_ACCESS];           //!<The OSubject for each process (accessor) on which it should be broadcast when a command is added
  #endif
  
! 	static int _MMaccID;          //!<Stores the accessor for the current process
  
  private:
  	MotionManager(const MotionManager&); //!< this shouldn't be called...
***************
*** 232,241 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 233,242 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Motion/MotionManagerMsg.h
diff -c AiboPup/Motion/MotionManagerMsg.h:1.2 AiboPup/Motion/MotionManagerMsg.h:1.4
*** AiboPup/Motion/MotionManagerMsg.h:1.2	Sat Mar  8 21:45:23 2003
--- AiboPup/Motion/MotionManagerMsg.h	Tue Sep  2 16:58:49 2003
***************
*** 7,14 ****
  	//! the type to use when referring to MotionCommand ID's
  	typedef unsigned short MC_ID;
  
  	//! constructor
! 	MotionManagerMsg() : type(unknown), mc_id(static_cast<MC_ID>(-1)) {}
  
  	//! virtual destructor
  	/*! doesn't do anything, but don't remove it, otherwise this would no longer be a virtual base class */
--- 7,17 ----
  	//! the type to use when referring to MotionCommand ID's
  	typedef unsigned short MC_ID;
  
+ 	//! for errors and undefined stuff
+ 	static const MC_ID invalid_MC_ID=static_cast<MC_ID>(-1); 
+ 
  	//! constructor
! 	MotionManagerMsg() : type(unknown), mc_id(invalid_MC_ID) {}
  
  	//! virtual destructor
  	/*! doesn't do anything, but don't remove it, otherwise this would no longer be a virtual base class */
***************
*** 17,22 ****
--- 20,29 ----
  	//! Accessor for the id number, set by MotionManager::addMotion()
  	MC_ID getID() const { return mc_id; }
  
+ protected:
+ 	//! resets the #mc_id to #invalid_MC_ID
+ 	void clearID() { mc_id=invalid_MC_ID; }
+ 
  private:
  	friend class MotionManager;
  
***************
*** 45,54 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif // INCLUDED_MotionManagerMsg_h
--- 52,61 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif // INCLUDED_MotionManagerMsg_h
Index: AiboPup/Motion/MotionSequenceMC.cc
diff -c AiboPup/Motion/MotionSequenceMC.cc:1.8 AiboPup/Motion/MotionSequenceMC.cc:1.9
*** AiboPup/Motion/MotionSequenceMC.cc:1.8	Thu Jun 12 00:16:43 2003
--- AiboPup/Motion/MotionSequenceMC.cc	Thu Sep 25 11:27:23 2003
***************
*** 420,428 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 420,428 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Motion/MotionSequenceMC.h
diff -c AiboPup/Motion/MotionSequenceMC.h:1.9 AiboPup/Motion/MotionSequenceMC.h:1.10
*** AiboPup/Motion/MotionSequenceMC.h:1.9	Tue Jun 10 00:41:41 2003
--- AiboPup/Motion/MotionSequenceMC.h	Thu Sep 25 11:27:23 2003
***************
*** 289,298 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 289,298 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Motion/OutputCmd.cc
diff -c /dev/null AiboPup/Motion/OutputCmd.cc:1.1
*** /dev/null	Fri Oct 10 14:37:44 2003
--- AiboPup/Motion/OutputCmd.cc	Fri Sep 12 11:29:03 2003
***************
*** 0 ****
--- 1,3 ----
+ #include "OutputCmd.h"
+ 
+ OutputCmd OutputCmd::unused;
Index: AiboPup/Motion/OutputCmd.h
diff -c AiboPup/Motion/OutputCmd.h:1.2 AiboPup/Motion/OutputCmd.h:1.3
*** AiboPup/Motion/OutputCmd.h:1.2	Wed Apr  9 03:01:30 2003
--- AiboPup/Motion/OutputCmd.h	Sun Sep  7 18:14:01 2003
***************
*** 13,24 ****
  
  	inline void set(float v, float w=1) { value=v; weight=w; } //!< sets the value to @a v and weight to @a w
  	inline void set(const OutputCmd& a, const OutputCmd& b, float w) { value=a.value*w+b.value*(1-w); weight=a.weight*w+b.weight*(1-w); } //!< sets the value to a weighted average of @a a and @a b (higher @a w, more @a a)
! 	inline void unset() { value=weight=0; } //!< sets value and weight to 0 (same as assigning ::unusedJoint)
  	bool operator==(const OutputCmd& c) const { return value==c.value && weight==c.weight; } //!< tests for equality of weight and value
  	bool operator!=(const OutputCmd& c) const { return value!=c.value || weight!=c.weight; } //!< tests for inequality of weight and value
  
  	float value; //!< value of the output
  	float weight; //!< weight to be used in averaging, 0 to "fall through"
  };
  
  /*! @file
--- 13,25 ----
  
  	inline void set(float v, float w=1) { value=v; weight=w; } //!< sets the value to @a v and weight to @a w
  	inline void set(const OutputCmd& a, const OutputCmd& b, float w) { value=a.value*w+b.value*(1-w); weight=a.weight*w+b.weight*(1-w); } //!< sets the value to a weighted average of @a a and @a b (higher @a w, more @a a)
! 	inline void unset() { value=weight=0; } //!< sets value and weight to 0
  	bool operator==(const OutputCmd& c) const { return value==c.value && weight==c.weight; } //!< tests for equality of weight and value
  	bool operator!=(const OutputCmd& c) const { return value!=c.value || weight!=c.weight; } //!< tests for inequality of weight and value
  
  	float value; //!< value of the output
  	float weight; //!< weight to be used in averaging, 0 to "fall through"
+ 	static OutputCmd unused; //!< handy sometimes for returning a reference to a 0,0 cmd
  };
  
  /*! @file
***************
*** 26,35 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 27,36 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Motion/OutputPID.h
diff -c AiboPup/Motion/OutputPID.h:1.3 AiboPup/Motion/OutputPID.h:1.4
*** AiboPup/Motion/OutputPID.h:1.3	Wed Apr  9 03:01:30 2003
--- AiboPup/Motion/OutputPID.h	Sun Sep  7 18:14:01 2003
***************
*** 19,25 ****
  		pid[2]=a.pid[2]*w+b.pid[2]*(1-w);
  		weight=a.weight*w+b.weight*(1-w); 
  	} 
! 	inline void unset() { weight=0; } //!< sets value and weight to 0 (same as assigning ::unusedJoint)
  
  	float pid[3]; //!< pid value of the output
  	float weight; //!< weight to be used in averaging, 0 to "fall through"
--- 19,25 ----
  		pid[2]=a.pid[2]*w+b.pid[2]*(1-w);
  		weight=a.weight*w+b.weight*(1-w); 
  	} 
! 	inline void unset() { weight=0; } //!< sets value and weight to 0
  
  	float pid[3]; //!< pid value of the output
  	float weight; //!< weight to be used in averaging, 0 to "fall through"
***************
*** 37,46 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 37,46 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Motion/PIDMC.h
diff -c AiboPup/Motion/PIDMC.h:1.9 AiboPup/Motion/PIDMC.h:1.10
*** AiboPup/Motion/PIDMC.h:1.9	Thu Jun 12 19:41:40 2003
--- AiboPup/Motion/PIDMC.h	Thu Sep 25 11:27:23 2003
***************
*** 108,117 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 108,117 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Motion/Path.h
diff -c AiboPup/Motion/Path.h:1.4 AiboPup/Motion/Path.h:1.5
*** AiboPup/Motion/Path.h:1.4	Thu Jan 23 13:14:04 2003
--- AiboPup/Motion/Path.h	Thu Sep 25 11:27:23 2003
***************
*** 107,116 ****
   * @endverbatim
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 107,116 ----
   * @endverbatim
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Motion/PostureEngine.cc
diff -c AiboPup/Motion/PostureEngine.cc:1.8 AiboPup/Motion/PostureEngine.cc:1.9
*** AiboPup/Motion/PostureEngine.cc:1.8	Thu Jun 12 00:16:43 2003
--- AiboPup/Motion/PostureEngine.cc	Sun Sep  7 18:14:01 2003
***************
*** 34,40 ****
  	PostureEngine tmp(*this);
  	return tmp.setUnderlay(pe);
  }
! /*! joints being averaged with ::unusedJoint have their weights averaged, but not their values (so an output can crossfade properly)\n
   *  @param pe the other PostureEngine
   *  @param w amount to weight towards @a pe
   *  - if @a w < .001, nothing is done
--- 34,40 ----
  	PostureEngine tmp(*this);
  	return tmp.setUnderlay(pe);
  }
! /*! joints being averaged with unused joints have their weights averaged, but not their values (so an output can crossfade properly)\n
   *  @param pe the other PostureEngine
   *  @param w amount to weight towards @a pe
   *  - if @a w < .001, nothing is done
***************
*** 229,237 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 229,237 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Motion/PostureEngine.h
diff -c AiboPup/Motion/PostureEngine.h:1.2 AiboPup/Motion/PostureEngine.h:1.3
*** AiboPup/Motion/PostureEngine.h:1.2	Tue Mar  4 00:46:07 2003
--- AiboPup/Motion/PostureEngine.h	Thu Sep 25 11:27:23 2003
***************
*** 87,96 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 87,96 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Motion/PostureMC.h
diff -c AiboPup/Motion/PostureMC.h:1.3 AiboPup/Motion/PostureMC.h:1.4
*** AiboPup/Motion/PostureMC.h:1.3	Tue Mar  4 00:46:07 2003
--- AiboPup/Motion/PostureMC.h	Thu Sep 25 11:27:23 2003
***************
*** 82,91 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 82,91 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Motion/RemoteControllerMC.h
diff -c AiboPup/Motion/RemoteControllerMC.h:1.2 AiboPup/Motion/RemoteControllerMC.h:1.3
*** AiboPup/Motion/RemoteControllerMC.h:1.2	Thu Jun 12 14:06:11 2003
--- AiboPup/Motion/RemoteControllerMC.h	Fri Sep 12 17:38:47 2003
***************
*** 39,52 ****
  };
  
  /*! @file
!  * @brief Describes RemoteControllerMC, a class for various ways to control where the head is looking
!  * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 39,52 ----
  };
  
  /*! @file
!  * @brief Describes RemoteControllerMC, a class used for setting all PIDJoints to a certain set of values (not the gains, just the joint positions)
!  * @author alokl (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Motion/Spline.h
diff -c AiboPup/Motion/Spline.h:1.4 AiboPup/Motion/Spline.h:1.5
*** AiboPup/Motion/Spline.h:1.4	Thu Jan 23 13:14:04 2003
--- AiboPup/Motion/Spline.h	Thu Sep 25 11:27:23 2003
***************
*** 375,384 ****
   * @endverbatim
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 375,384 ----
   * @endverbatim
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Motion/TailWagMC.h
diff -c AiboPup/Motion/TailWagMC.h:1.4 AiboPup/Motion/TailWagMC.h:1.5
*** AiboPup/Motion/TailWagMC.h:1.4	Tue Jul  8 20:10:57 2003
--- AiboPup/Motion/TailWagMC.h	Thu Sep 25 11:27:23 2003
***************
*** 51,60 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 51,60 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Motion/WalkMC.cc
diff -c AiboPup/Motion/WalkMC.cc:1.13 AiboPup/Motion/WalkMC.cc:1.16
*** AiboPup/Motion/WalkMC.cc:1.13	Thu May  1 13:19:29 2003
--- AiboPup/Motion/WalkMC.cc	Thu Sep 11 22:01:44 2003
***************
*** 42,47 ****
--- 42,48 ----
  #include <fcntl.h>
  #include <unistd.h>
  #include <fstream>
+ #include <cmath>
  
  //REGIMP(WalkMC);
  
***************
*** 50,55 ****
--- 51,58 ----
  const float WalkMC::MAX_DX   = 180;//225; // mm/sec
  const float WalkMC::MAX_DY   = 140;//170; // mm/sec
  const float WalkMC::MAX_DA   = 1.8;//2.1; // rad/sec
+ // tss "SmoothWalk" modification follows
+ // const vector3d WalkMC::max_accel_xya(MAX_DX*2,MAX_DY*2,MAX_DA*2);
  const vector3d WalkMC::max_accel_xya(MAX_DX*2,MAX_DY*2,MAX_DA*2);
  
  unsigned int checksum(const char *data,int num); //!< computes a file checksum
***************
*** 57,66 ****
  template <class data> int save_file(data *arr,int num,const char *filename); //!< saves the current walk parameters to a file
  
  WalkMC::WalkMC(const char* pfile/*=NULL*/)
  	: MotionCommand(), isPaused(false), wp(), body_loc(), body_angle(),
  		pos_delta(0,0,0), angle_delta(0), travelTime(get_time()),
! 		time(get_time()), TimeStep(FrameTime), vel_xya(0,0,0),
! 		target_vel_xya(0,0,0)
  {
  	init(pfile);
  }
--- 60,75 ----
  template <class data> int save_file(data *arr,int num,const char *filename); //!< saves the current walk parameters to a file
  
  WalkMC::WalkMC(const char* pfile/*=NULL*/)
+ // tss "SmoothWalk" modification follows
+ //	: MotionCommand(), isPaused(false), wp(), body_loc(), body_angle(),
+ //		pos_delta(0,0,0), angle_delta(0), travelTime(get_time()),
+ //		time(get_time()), TimeStep(FrameTime), vel_xya(0,0,0),
+ //		target_vel_xya(0,0,0)
  	: MotionCommand(), isPaused(false), wp(), body_loc(), body_angle(),
  		pos_delta(0,0,0), angle_delta(0), travelTime(get_time()),
! 		time(get_time()), TimeStep(FrameTime), slowmo(1.0f),
! 		CycleOffset(0), TimeOffset(0), NewCycleOffset(false),
! 		vel_xya(0,0,0), target_vel_xya(0,0,0)
  {
  	init(pfile);
  }
***************
*** 106,111 ****
--- 115,133 ----
  	//	cmds[HeadOffset+TiltOffset].set(.3333,1);
  }
  
+ // tss "SmoothWalk" addition follows
+ int WalkMC::isDirty()
+ {
+   if(isPaused) return false;
+   if((target_vel_xya.x == 0) && (target_vel_xya.y == 0) && (target_vel_xya.z == 0)) {
+ 	if((vel_xya.x != 0) || (vel_xya.y != 0) || (vel_xya.z != 0)) return true
+ ;
+ 	else return false;
+   }
+   return true;
+ }
+ // tss "SmoothWalk" addition ends
+ 
  void WalkMC::load(const char* pfile)
  {
    mzero(wp);
***************
*** 150,156 ****
  	if(!isDirty())
  		return 0;
  	
!   double t = TimeStep / 1000.0;
  
    vel_xya.x = bound(target_vel_xya.x, vel_xya.x-max_accel_xya.x*t, vel_xya.x+max_accel_xya.x*t);
    vel_xya.y = bound(target_vel_xya.y, vel_xya.y-max_accel_xya.y*t, vel_xya.y+max_accel_xya.y*t);
--- 172,178 ----
  	if(!isDirty())
  		return 0;
  	
!   double t = TimeStep * slowmo / 1000;
  
    vel_xya.x = bound(target_vel_xya.x, vel_xya.x-max_accel_xya.x*t, vel_xya.x+max_accel_xya.x*t);
    vel_xya.y = bound(target_vel_xya.y, vel_xya.y-max_accel_xya.y*t, vel_xya.y+max_accel_xya.y*t);
***************
*** 160,166 ****
    delta.loc.set(vel_xya.x*t,vel_xya.y*t,0);
    delta.angle.set(0,0,vel_xya.z*t);
  
! 	time=get_time();
  
  	for(unsigned int frame=0; frame<NumFrames; frame++) {
  		target_vel_xya.rotate_z(-delta.angle.z);
--- 182,205 ----
    delta.loc.set(vel_xya.x*t,vel_xya.y*t,0);
    delta.angle.set(0,0,vel_xya.z*t);
  
! 	time=(int)(get_time()*slowmo);
! 
! // tss "SmoothWalk" addition follows
! 	// If necessary, we compute a new TimeOffset here.
! 	if(NewCycleOffset) {
! 		TimeOffset = CycleOffset - time % wp.period;
! 		NewCycleOffset = false;
! 	}
! 
! 	// Adjusted time--time adjusted for cycle matching
! 	int AdjustedTime = time + TimeOffset;
! 
! 	// If walking speeds have dwindled down to zero, save our time offset from the beginning of the current walk cycle. Once we start walking again, we start up at the same offset to prevent jerky starts.
! 	if((vel_xya.x == 0) && (vel_xya.y == 0) && (vel_xya.z == 0)) {
! 		CycleOffset = AdjustedTime % wp.period;
! 		NewCycleOffset = true;
! 	}
! // tss "SmoothWalk" addition ends
  
  	for(unsigned int frame=0; frame<NumFrames; frame++) {
  		target_vel_xya.rotate_z(-delta.angle.z);
***************
*** 171,177 ****
  
  		//		cout << "setup,,," << flush;
  
! 		double cycle = (double)(time % wp.period) / wp.period;
  		double sway   = wp.sway*cos(2*M_PI*cycle);
  		double hop    = wp.hop*sin(4*M_PI*cycle);
  		double height = wp.body_height;
--- 210,218 ----
  
  		//		cout << "setup,,," << flush;
  
! // tss "SmoothWalk" modification follows
! 		// double cycle = (double)(time % wp.period) / wp.period;
! 		double cycle = (double)(AdjustedTime % wp.period) / wp.period;
  		double sway   = wp.sway*cos(2*M_PI*cycle);
  		double hop    = wp.hop*sin(4*M_PI*cycle);
  		double height = wp.body_height;
***************
*** 206,211 ****
--- 247,281 ----
  			if(air){
  				t = (cycle - wp.leg[i].lift_time) / air_f;
  				legpos[i] = legw[i].airpath.eval(t);
+ 
+ // Core tss "SmoothWalk" addition follows
+ 				// KLUDGY MOD. Goal: reduce the height of the
+ 				// AIBO's steps as its velocity nears zero.
+ 				// Since I don't know how most of this code 
+ 				// works, I'll directly alter legpos[i].z in
+ 				// the following code to change the z height
+ 				// with velocity.
+ 				double velfraction_x = fabs(vel_xya.x / MAX_DX);
+ 				double velfraction_y = fabs(vel_xya.y / MAX_DY);
+ 				double velfraction_a = fabs(vel_xya.z / MAX_DA);
+ 
+ 				// Choose the biggest velfraction
+ 				double velfraction =
+ 				  (velfraction_x > velfraction_y) ?
+ 				    velfraction_x : velfraction_y;
+ 				if(velfraction_a > velfraction)
+ 				  velfraction = velfraction_a;
+ 
+ 				// Modify legpos[i].z with velfraction to
+ 				// shrink it down
+ 				//velfraction = atan(velfraction * M_PI);
+ 
+ 				velfraction-=1;
+ 				velfraction*=velfraction;
+ 				velfraction*=velfraction;
+ 
+ 				legpos[i].z *= 1-velfraction;
+ // Core tss "SmoothWalk" addition ends
  			}else{
  				legpos[i] = (legpos[i] - delta.loc).rotate_z(-delta.angle.z);
  			}
***************
*** 215,223 ****
  				cmds[LegOffset+i*JointsPerLeg+j][frame].set(nextlegangles[j]);
  		}
  
! 		time += TimeStep;
  	}
! 
  	for(unsigned int joint=LegOffset; joint<LegOffset+NumLegJoints; joint++)
  		motman->setOutput(this,joint,cmds[joint]);
  
--- 285,294 ----
  				cmds[LegOffset+i*JointsPerLeg+j][frame].set(nextlegangles[j]);
  		}
  
! 		// tss "SmoothWalk" modification follows
! 		AdjustedTime = time+TimeOffset+(int)(frame*TimeStep*slowmo);
  	}
! 	
  	for(unsigned int joint=LegOffset; joint<LegOffset+NumLegJoints; joint++)
  		motman->setOutput(this,joint,cmds[joint]);
  
***************
*** 303,311 ****
   * @verbinclude CMPack_license.txt
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 374,389 ----
   * @verbinclude CMPack_license.txt
   *
   * $Author: ejt $
! <<<<<<< WalkMC.cc
!  * $Name: HEAD $
!  * $Revision: 1.2 $
!  * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
! =======
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
! >>>>>>> 1.15
   */
  
Index: AiboPup/Motion/WalkMC.h
diff -c AiboPup/Motion/WalkMC.h:1.8 AiboPup/Motion/WalkMC.h:1.14
*** AiboPup/Motion/WalkMC.h:1.8	Tue Apr  8 23:33:57 2003
--- AiboPup/Motion/WalkMC.h	Mon Oct  6 21:00:40 2003
***************
*** 45,50 ****
--- 45,52 ----
   *
   *  This portion of the code falls under CMPack's license:
   *  @verbinclude CMPack_license.txt
+  *
+  *  @bug the legs try (briefly) to straighten out when first starting to move
   */
  class WalkMC : public MotionCommand {
  public:
***************
*** 87,94 ****
  	virtual void DoStop();  //!< sends a deactivate LocomotionEvent
  
  	virtual int updateOutputs(); //!< calculates current positions of the paws
! 	virtual int isDirty() { return !isPaused && (target_vel_xya.x!=0 || target_vel_xya.y!=0 || target_vel_xya.z!=0); } //!< returns true if we are walking
! 	virtual int isAlive() { return true; } //!< always true - never autoprunes
  
  	//! loads parameters from a file (@todo use LoadSave)
  	void load(const char* pfile);
--- 89,100 ----
  	virtual void DoStop();  //!< sends a deactivate LocomotionEvent
  
  	virtual int updateOutputs(); //!< calculates current positions of the paws
! 	
! 	//! Returns true if we are walking. This modified isDirty allows the AIBO to slow down to a stop rather than stopping immediately.
! 	virtual int isDirty();
! 	
! 	//! always true - never autoprunes
! 	virtual int isAlive() { return true; }
  
  	//! loads parameters from a file (@todo use LoadSave)
  	void load(const char* pfile);
***************
*** 115,128 ****
  	double getSway() { return wp.sway; } //!< gets WalkParam::sway of #wp
  	void setPeriod(long p) { wp.period=p; } //!< sets WalkParam::period of #wp
  	long getPeriod() { return wp.period; } //!< gets WalkParam::period of #wp
  
  	//! takes current leg positions from WorldState and tries to match the point in the cycle most like it
  	void resetLegPos();
  
  	static const float MAX_DX; //!< ==180 mm/sec
  	static const float MAX_DY; //!< ==140 mm/sec
  	static const float MAX_DA; //!< ==1.8 rad/sec
! 	static const vector3d max_accel_xya; //!< vector version of MAX_DX,MAX_DY,MAX_DA
  
   protected:
  	//! holds current joint commands
--- 121,140 ----
  	double getSway() { return wp.sway; } //!< gets WalkParam::sway of #wp
  	void setPeriod(long p) { wp.period=p; } //!< sets WalkParam::period of #wp
  	long getPeriod() { return wp.period; } //!< gets WalkParam::period of #wp
+ 	void setSlowMo(float p) { slowmo=p; } //!< sets slowmo
+ 	float* getSlowMo() { return &slowmo; } //!< gets slowmo
  
+ 	WalkParam & getWP() { return wp; }; //!< returns the current walk parameter structure
+ 	
  	//! takes current leg positions from WorldState and tries to match the point in the cycle most like it
  	void resetLegPos();
  
  	static const float MAX_DX; //!< ==180 mm/sec
  	static const float MAX_DY; //!< ==140 mm/sec
  	static const float MAX_DA; //!< ==1.8 rad/sec
! // tss "SmoothWalk" modification follows (actually only comment is changed)
! 	// static const vector3d max_accel_xya; //!< vector version of MAX_DX,MAX_DY,MAX_DA
! 	static const vector3d max_accel_xya; //!< maximum acceleration of x, y, and a velocity
  
   protected:
  	//! holds current joint commands
***************
*** 144,152 ****
  	double angle_delta; //!< how much we've turned
  	
  	unsigned int travelTime; //!< the time since the last call to setTargetVelocity - handy to check the time we've been traveling current vector
! 	int time; //!< time of last call to updateJointCmds()
! 	int TimeStep; //!< time to pretend passes between each call to updateJointCmds() - usually RobotInfo::FrameTime, unless you want to make it walk in slow motion (handy sometimes for debugging)
! 	
  	vector3d vel_xya; //!< the current velocity we're moving
  	vector3d target_vel_xya; //!< the velocity that was requested
  };
--- 156,185 ----
  	double angle_delta; //!< how much we've turned
  	
  	unsigned int travelTime; //!< the time since the last call to setTargetVelocity - handy to check the time we've been traveling current vector
! 	int time; //!< time of last call to updateJointCmds() (scaled by slowmo)
! 	int TimeStep; //!< time to pretend passes between each call to updateJointCmds() - usually RobotInfo::FrameTime
! 	float slowmo; //!< scales time values to make the walk move in slow motion for analysis (or fast forward)
! 
! 	// tss "SmoothWalk" addition follows
! 	/*! The CycleOffset variable is used to ensure that each time the AIBO
! 	 *  starts walking, it starts at the same point in the walk cycle as
! 	 *  where it stopped. This measure is intended to decrease the amount
! 	 *  of jerking (and hence deviation) that occurs when the AIBO starts
! 	 *  walking forward and then suddenly stops. */
! 	int CycleOffset;
! 	/*! Each CycleOffset corresponds to a different TimeOffset once the
! 	 *  robot starts walking again. Consider this example: the robot
! 	 *  stops 2/3 of the way through the cycle, then starts again 1/3
! 	 *  of the way through the cycle on the absolute clock. The time
! 	 *  offset to advance the clock to the right part of the cycle is
! 	 *  1/3 of a cycle, so we set TimeOffset to 1/3 cycle and add that to
! 	 *  every clock value used in the walk code. */
! 	int TimeOffset;
! 	/*! Every time we stop, we know we'll have a new CycleOffset, and we'll
! 	 *  need to compute a new TimeOffset. This boolean says as much. */
! 	bool NewCycleOffset;
! // tss "SmoothWalk" addition ends
! 
  	vector3d vel_xya; //!< the current velocity we're moving
  	vector3d target_vel_xya; //!< the velocity that was requested
  };
***************
*** 174,187 ****
   * @brief Describes WalkMC, a MotionCommand for walking around
   * @author CMU RoboSoccer 2001-2002 (Creator)
   * @author ejt (ported)
   * 
   * @verbinclude CMPack_license.txt
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 207,221 ----
   * @brief Describes WalkMC, a MotionCommand for walking around
   * @author CMU RoboSoccer 2001-2002 (Creator)
   * @author ejt (ported)
+  * @author PA Gov. School for the Sciences 2003 Team Project - Haoqian Chen, Yantian Martin, Jon Stahlman (modifications)
   * 
   * @verbinclude CMPack_license.txt
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Motion/gvector.h
diff -c AiboPup/Motion/gvector.h:1.4 AiboPup/Motion/gvector.h:1.5
*** AiboPup/Motion/gvector.h:1.4	Thu Jan 23 13:14:04 2003
--- AiboPup/Motion/gvector.h	Thu Sep 25 11:27:23 2003
***************
*** 677,686 ****
   * @endverbatim
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 677,686 ----
   * @endverbatim
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/RemoteProcess/Makefile
diff -c AiboPup/RemoteProcess/Makefile:1.3 AiboPup/RemoteProcess/Makefile:removed
*** AiboPup/RemoteProcess/Makefile:1.3	Fri Jun  6 18:39:47 2003
--- AiboPup/RemoteProcess/Makefile	Fri Oct 10 14:37:44 2003
***************
*** 1,40 ****
- OPENRSDK_ROOT?=/usr/local/OPEN_R_SDK
- CP=cp
- INSTALLDIR=MS
- STRIP=strip
- MKBIN=g++
- STUBGEN=$(OPENRSDK_ROOT)/RP_OPEN_R/bin/rp-openr-stubgen2
- MKBINFLAGS=
- OPENRCONFIG=$(OPENRSDK_ROOT)/RP_OPEN_R/bin/rp-openr-config
- LIBS=`$(OPENRCONFIG) --libs`
- CXXFLAGS= \
- 	-O2 \
- 	-g \
- 	-I. \
- 	-I.. \
- 	-DPLATFORM_APERIOS -DDEBUG -DOPENR_DEBUG \
- 	-D$(TEKKOTSU_TARGET_MODEL) $(GLOBAL_MAP) \
- 	`$(OPENRCONFIG) --cflags`
- OCF=
- 
- .PHONY: all install clean
- 
- all: remoteProcess.bin
- 
- %.o: %.cc
- 	$(CXX) $(CXXFLAGS) -o $@ -c $^
- 
- RemoteProcessStub.cc: stub.cfg
- 	$(STUBGEN) $^
- 
- remoteProcess.bin: RemoteProcessStub.o RemoteProcess.o $(OCF)
- 	$(MKBIN) $(MKBINFLAGS) -o $@ $^ $(LIBS)
- 	$(STRIP) $@
- 
- install: remoteProcess.bin
- 	$(CP) $^ $(INSTALLDIR)/OPEN-R/MW/OBJS/RPROCESS.BIN
- 
- clean:
- 	rm -f *.o *.bin *.elf *.snap.cc
- 	rm -f RemoteProcessStub.h RemoteProcessStub.cc def.h entry.h
- 	rm -f $(INSTALLDIR)/OPEN-R/MW/OBJS/RPROCESS.BIN
--- 0 ----
Index: AiboPup/RemoteProcess/RemoteProcess.cc
diff -c AiboPup/RemoteProcess/RemoteProcess.cc:1.3 AiboPup/RemoteProcess/RemoteProcess.cc:1.4
*** AiboPup/RemoteProcess/RemoteProcess.cc:1.3	Thu Jun 12 19:41:40 2003
--- AiboPup/RemoteProcess/RemoteProcess.cc	Thu Sep 25 11:27:50 2003
***************
*** 89,97 ****
   * @author alokl (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 89,97 ----
   * @author alokl (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/RemoteProcess/RemoteProcess.h
diff -c AiboPup/RemoteProcess/RemoteProcess.h:1.6 AiboPup/RemoteProcess/RemoteProcess.h:1.7
*** AiboPup/RemoteProcess/RemoteProcess.h:1.6	Thu Jun 12 19:41:40 2003
--- AiboPup/RemoteProcess/RemoteProcess.h	Thu Sep 25 11:27:50 2003
***************
*** 54,63 ****
   * @author alokl (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 54,63 ----
   * @author alokl (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Shared/Config.cc
diff -c AiboPup/Shared/Config.cc:1.14 AiboPup/Shared/Config.cc:1.17
*** AiboPup/Shared/Config.cc:1.14	Mon Jul  7 00:32:47 2003
--- AiboPup/Shared/Config.cc	Sun Sep  7 18:14:19 2003
***************
*** 1,163 ****
  #include <Shared/Config.h>
  #include <stdio.h>
  #include <string>
  #include <ctype.h>
  
  Config* config=NULL;
  
  void Config::readConfig(const char* filename) {
    FILE* fp = fopen(filename, "r");
    char buf[80], key[30], value[50];
    section_t section=sec_invalid;
!   if (fp==NULL) return; // ALTODO
    
    while (fscanf(fp,"%79[^\n]\n", buf)!=EOF) {
      if (sscanf(buf,"[%29[^]]",key)>0) {
!       if (strncasecmp(key,"wireless",29)==0) {
!         section=sec_wireless;
!       } else if (strncasecmp(key,"vision",29)==0) {
!         section=sec_vision;
!       } else if (strncasecmp(key,"main",29)==0) {
!         section=sec_main;
!       } else if (strncasecmp(key,"behaviors",29)==0) {
!         section=sec_behaviors;
!       } else if (strncasecmp(key,"controller",29)==0) {
!         section=sec_controller;
!       } else if (strncasecmp(key,"motion",29)==0) {
!         section=sec_motion;
!       } else if (strncasecmp(key,"worldmodel2",29)==0) {
!         section=sec_worldmodel2;
!       } else if (strncasecmp(key,"sound",29)==0) {
!         section=sec_sound;
!       } else {
!         section=sec_invalid;
!       }
      } else if (sscanf(buf,"%29[^=]=%49s",key,value)>1) {
!       switch (section) {
! 			case sec_wireless:
! 				if (strncasecmp(key,"id",29)==0) {
! 					wireless.id=atoi(value);
! 				}
! 				break;
! 			case sec_vision:
! 				if (strncasecmp(key,"white_balance",29)==0) {
! 					if (strncasecmp(value,"indoor",49)==0) {
! 						vision.white_balance=1;
! 					} else if (strncasecmp(value,"flourescent",49)==0) {
! 						vision.white_balance=3;
! 					} else if (strncasecmp(value,"outdoor",49)==0) {
! 						vision.white_balance=2;
! 					}
! 				} else if (strncasecmp(key,"gain",29)==0) {
! 					if (strncasecmp(value,"low",49)==0) {
! 						vision.gain=1;
! 					} else if (strncasecmp(value,"mid",49)==0) {
! 						vision.gain=2;
! 					} else if (strncasecmp(value,"high",49)==0) {
! 						vision.gain=3;
! 					}
! 				} else if (strncasecmp(key,"shutter_speed",29)==0) {
! 					if (strncasecmp(value,"slow",49)==0) {
! 						vision.shutter_speed=1;
! 					} else if (strncasecmp(value,"mid",49)==0) {
! 						vision.shutter_speed=2;
! 					} else if (strncasecmp(value,"fast",49)==0) {
! 						vision.shutter_speed=3;
! 					}
! 				} else if (strncasecmp(key,"resolution",29)==0) {
! 					if (strncasecmp(value,"full",49)==0) {
! 						vision.resolution=1;
! 					} else if (strncasecmp(value,"half",49)==0) {
! 						vision.resolution=2;
! 					} else if (strncasecmp(value,"quarter",49)==0) {
! 						vision.resolution=3;
! 					}
! 				} else if (strncasecmp(key,"thresh",29)==0) {
! 					strncpy(vision.thresh,value,49);
! 				} else if (strncasecmp(key,"colors",29)==0) {
! 					strncpy(vision.colors,value,49);
! 				} else if (strncasecmp(key,"raw_port",29)==0) {
! 					vision.raw_port=atoi(value);
! 				} else if (strncasecmp(key,"rle_port",29)==0) {
! 					vision.rle_port=atoi(value);
! 				} else if (strncasecmp(key,"obj_port",29)==0) {
! 					vision.obj_port=atoi(value);
! 				}
! 				break;
! 			case sec_main:
! 				if (strncasecmp(key,"console_port",29)==0) {
! 					main.console_port=atoi(value);
! 				} else if (strncasecmp(key,"stderr_port",29)==0) {
! 					main.stderr_port=atoi(value);
! 				} else if (strncasecmp(key,"error_level",29)==0) {
! 					main.error_level=atoi(value);
! 				} else if (strncasecmp(key,"debug_level",29)==0) {
! 					main.debug_level=atoi(value);
! 				} else if (strncasecmp(key,"verbose_level",29)==0) {
! 					main.verbose_level=atoi(value);
! 				} else if (strncasecmp(key,"wsjoints_port",29)==0) {
! 					main.wsjoints_port=atoi(value);
! 				} else if (strncasecmp(key,"wspids_port",29)==0) {
! 					main.wspids_port=atoi(value);
! 				} else if (strncasecmp(key,"headControl_port",29)==0) {
! 					main.headControl_port=atoi(value);
! 				} else if (strncasecmp(key,"walkControl_port",29)==0) {
! 					main.walkControl_port=atoi(value);
! 				} else if (strncasecmp(key,"estopControl_port",29)==0) {
! 					main.estopControl_port=atoi(value);
! 				} else if (strncasecmp(key,"aibo3d_port",29)==0) {
! 					main.aibo3d_port=atoi(value);
! 				} else if (strncasecmp(key,"use_VT100",29)==0) {
! 					main.use_VT100=extractBool(value);
! 				}
! 				break;
! 			case sec_behaviors:
! 				break;
! 			case sec_controller:
! 				if (strncasecmp(key,"gui_port",29)==0)
! 					controller.gui_port = atoi(value);
! 				else if (strncasecmp(key,"select_snd",29)==0)
! 					strncpy(controller.select_snd,value,49);
! 				else if (strncasecmp(key,"next_snd",29)==0)
! 					strncpy(controller.next_snd,value,49);
! 				else if (strncasecmp(key,"prev_snd",29)==0)
! 					strncpy(controller.prev_snd,value,49);
! 				else if (strncasecmp(key,"read_snd",29)==0)
! 					strncpy(controller.read_snd,value,49);
! 				else if (strncasecmp(key,"cancel_snd",29)==0)
! 					strncpy(controller.cancel_snd,value,49);
! 				break;
! 			case sec_motion:
! 				if (strncasecmp(key,"root",29)==0)
! 					motion.root=value;
! 				else if (strncasecmp(key,"estop_on_snd",29)==0)
! 					strncpy(motion.estop_on_snd,value,49);
! 				else if (strncasecmp(key,"estop_off_snd",29)==0)
! 					strncpy(motion.estop_off_snd,value,49);
! 				break;
! 			case sec_worldmodel2:
! 				if (strncasecmp(key,"dm_port",29)==0)
! 					worldmodel2.dm_port = atoi(value);
! 				else if (strncasecmp(key,"hm_port",29)==0)
! 					worldmodel2.hm_port = atoi(value);
! 				else if (strncasecmp(key,"gm_port",29)==0)
! 					worldmodel2.gm_port = atoi(value);
! 				else if (strncasecmp(key,"fs_port",29)==0)
! 					worldmodel2.fs_port = atoi(value);
! 				break;
! 			case sec_sound:
! 				if (strncasecmp(key,"root",29)==0)
! 					sound.root=value;
! 				else if (strncasecmp(key,"sample_rate",29)==0)
! 					sound.sample_rate = atoi(value);
! 				else if (strncasecmp(key,"sample_bits",29)==0)
! 					sound.sample_bits = atoi(value);
! 				else if (strncasecmp(key,"preload",29)==0)
! 					sound.preload.push_back(value);
! 				break;
! 			default:
! 				break;
!       }
      }
    }
    fclose(fp);
--- 1,236 ----
  #include <Shared/Config.h>
+ #include <Shared/Serializer.h>
  #include <stdio.h>
  #include <string>
  #include <ctype.h>
  
  Config* config=NULL;
+ using namespace SerializerNS;
+ 
+ void* Config::setValue(section_t section, const char *key, const char *value,
+ 											 bool /*updated*/) {
+   switch (section) {
+     case sec_wireless:
+       if (strncasecmp(key,"id",29)==0) {
+         wireless.id=atoi(value);
+         return &wireless.id;
+       }
+       break;
+     case sec_vision:
+       if (strncasecmp(key,"white_balance",29)==0) {
+         if (strncasecmp(value,"indoor",49)==0) {
+           vision.white_balance=1;
+         } else if (strncasecmp(value,"flourescent",49)==0) {
+           vision.white_balance=3;
+         } else if (strncasecmp(value,"outdoor",49)==0) {
+           vision.white_balance=2;
+         }
+         return &vision.white_balance;
+       } else if (strncasecmp(key,"gain",29)==0) {
+         if (strncasecmp(value,"low",49)==0) {
+           vision.gain=1;
+         } else if (strncasecmp(value,"mid",49)==0) {
+           vision.gain=2;
+         } else if (strncasecmp(value,"high",49)==0) {
+           vision.gain=3;
+         }
+         return &vision.gain;
+       } else if (strncasecmp(key,"shutter_speed",29)==0) {
+         if (strncasecmp(value,"slow",49)==0) {
+           vision.shutter_speed=1;
+         } else if (strncasecmp(value,"mid",49)==0) {
+           vision.shutter_speed=2;
+         } else if (strncasecmp(value,"fast",49)==0) {
+           vision.shutter_speed=3;
+         }
+         return &vision.shutter_speed;
+       } else if (strncasecmp(key,"resolution",29)==0) {
+         if (strncasecmp(value,"full",49)==0) {
+           vision.resolution=1;
+         } else if (strncasecmp(value,"half",49)==0) {
+           vision.resolution=2;
+         } else if (strncasecmp(value,"quarter",49)==0) {
+           vision.resolution=3;
+         }
+         return &vision.resolution;
+       } else if (strncasecmp(key,"thresh",29)==0) {
+         strncpy(vision.thresh,value,49);
+         return &vision.thresh;
+       } else if (strncasecmp(key,"colors",29)==0) {
+         strncpy(vision.colors,value,49);
+         return &vision.colors;
+       } else if (strncasecmp(key,"raw_port",29)==0) {
+         vision.raw_port=atoi(value);
+         return &vision.raw_port;
+       } else if (strncasecmp(key,"rle_port",29)==0) {
+         vision.rle_port=atoi(value);
+         return &vision.rle_port;
+       } else if (strncasecmp(key,"obj_port",29)==0) {
+         vision.obj_port=atoi(value);
+         return &vision.obj_port;
+       } else if (strncasecmp(key,"raw_encoding",29)==0) {
+         if (strncasecmp(value,"half",49)==0) {
+           vision.raw_encoding=packet_visionraw_half;
+         } else if (strncasecmp(value,"full",49)==0) {
+           vision.raw_encoding=packet_visionraw_full;
+         } else if (strncasecmp(value,"yfull_uvhalf",49)==0) {
+           vision.raw_encoding=packet_visionraw_yfull_uvhalf;
+         }
+         return &vision.raw_encoding;
+       }
+       break;
+     case sec_main:
+       if (strncasecmp(key,"console_port",29)==0) {
+         main.console_port=atoi(value);
+         return &main.console_port;
+       } else if (strncasecmp(key,"stderr_port",29)==0) {
+         main.stderr_port=atoi(value);
+         return &main.stderr_port;
+       } else if (strncasecmp(key,"error_level",29)==0) {
+         main.error_level=atoi(value);
+         return &main.error_level;
+       } else if (strncasecmp(key,"debug_level",29)==0) {
+         main.debug_level=atoi(value);
+         return &main.debug_level;
+       } else if (strncasecmp(key,"verbose_level",29)==0) {
+         main.verbose_level=atoi(value);
+         return &main.verbose_level;
+       } else if (strncasecmp(key,"wsjoints_port",29)==0) {
+         main.wsjoints_port=atoi(value);
+         return &main.wsjoints_port;
+       } else if (strncasecmp(key,"wspids_port",29)==0) {
+         main.wspids_port=atoi(value);
+         return &main.wspids_port;
+       } else if (strncasecmp(key,"headControl_port",29)==0) {
+         main.headControl_port=atoi(value);
+         return &main.headControl_port;
+       } else if (strncasecmp(key,"walkControl_port",29)==0) {
+         main.walkControl_port=atoi(value);
+         return &main.walkControl_port;
+       } else if (strncasecmp(key,"estopControl_port",29)==0) {
+         main.estopControl_port=atoi(value);
+         return &main.estopControl_port;
+       } else if (strncasecmp(key,"aibo3d_port",29)==0) {
+         main.aibo3d_port=atoi(value);
+         return &main.aibo3d_port;
+       } else if (strncasecmp(key,"wmmonitor_port",29)==0) {
+         main.wmmonitor_port=atoi(value);
+         return &main.wmmonitor_port;
+       } else if (strncasecmp(key,"use_VT100",29)==0) {
+         main.use_VT100=extractBool(value);
+         return &main.use_VT100;
+       }
+       break;
+     case sec_behaviors:
+       break;
+     case sec_controller:
+       if (strncasecmp(key,"gui_port",29)==0) {
+         controller.gui_port = atoi(value);
+         return &controller.gui_port ;
+       } else if (strncasecmp(key,"select_snd",29)==0) {
+         strncpy(controller.select_snd,value,49);
+         return &controller.select_snd;
+       } else if (strncasecmp(key,"next_snd",29)==0) {
+         strncpy(controller.next_snd,value,49);
+         return &controller.next_snd;
+       } else if (strncasecmp(key,"prev_snd",29)==0) {
+         strncpy(controller.prev_snd,value,49);
+         return &controller.prev_snd;
+       } else if (strncasecmp(key,"read_snd",29)==0) {
+         strncpy(controller.read_snd,value,49);
+         return &controller.read_snd;
+       } else if (strncasecmp(key,"cancel_snd",29)==0) {
+         strncpy(controller.cancel_snd,value,49);
+         return &controller.cancel_snd;
+       }
+       break;
+     case sec_motion:
+       if (strncasecmp(key,"root",29)==0) {
+         motion.root=value;
+         return &motion.root;
+       } else if (strncasecmp(key,"estop_on_snd",29)==0) {
+         strncpy(motion.estop_on_snd,value,49);
+         return &motion.estop_on_snd;
+       } else if (strncasecmp(key,"estop_off_snd",29)==0) {
+         strncpy(motion.estop_off_snd,value,49);
+         return &motion.estop_off_snd;
+       } else if (strncasecmp(key,"max_head_tilt_speed",29)==0) {
+ 					motion.max_head_tilt_speed=atof(value);
+       } else if (strncasecmp(key,"max_head_pan_speed",29)==0) {
+ 					motion.max_head_pan_speed=atof(value);
+       } else if (strncasecmp(key,"max_head_roll_speed",29)==0) {
+ 					motion.max_head_roll_speed=atof(value);
+       }
+       break;
+     case sec_worldmodel2:
+       if (strncasecmp(key,"dm_port",29)==0) {
+         worldmodel2.dm_port = atoi(value);
+         return &worldmodel2.dm_port ;
+       } else if (strncasecmp(key,"hm_port",29)==0) {
+         worldmodel2.hm_port = atoi(value);
+         return &worldmodel2.hm_port ;
+       } else if (strncasecmp(key,"gm_port",29)==0) {
+         worldmodel2.gm_port = atoi(value);
+         return &worldmodel2.gm_port ;
+       } else if (strncasecmp(key,"fs_port",29)==0) {
+         worldmodel2.fs_port = atoi(value);
+         return &worldmodel2.fs_port ;
+       }
+       break;
+     case sec_sound:
+       if (strncasecmp(key,"root",29)==0) {
+         sound.root=value;
+         return &sound.root;
+       } else if (strncasecmp(key,"sample_rate",29)==0) {
+         sound.sample_rate = atoi(value);
+         return &sound.sample_rate ;
+       } else if (strncasecmp(key,"sample_bits",29)==0) {
+         sound.sample_bits = atoi(value);
+         return &sound.sample_bits ;
+       } else if (strncasecmp(key,"preload",29)==0) {
+         sound.preload.push_back(value);
+         return &sound.preload ;
+       }
+       break;
+     default:
+       break;
+   }
+   return NULL;
+ }
+ 
+ Config::section_t Config::parseSection(const char* key) {
+   if (strncasecmp(key,"wireless",29)==0) {
+     return sec_wireless;
+   } else if (strncasecmp(key,"vision",29)==0) {
+     return sec_vision;
+   } else if (strncasecmp(key,"main",29)==0) {
+     return sec_main;
+   } else if (strncasecmp(key,"behaviors",29)==0) {
+     return sec_behaviors;
+   } else if (strncasecmp(key,"controller",29)==0) {
+     return sec_controller;
+   } else if (strncasecmp(key,"motion",29)==0) {
+     return sec_motion;
+   } else if (strncasecmp(key,"worldmodel2",29)==0) {
+     return sec_worldmodel2;
+   } else if (strncasecmp(key,"sound",29)==0) {
+     return sec_sound;
+   } else {
+     return sec_invalid;
+   }
+ }
  
  void Config::readConfig(const char* filename) {
    FILE* fp = fopen(filename, "r");
    char buf[80], key[30], value[50];
    section_t section=sec_invalid;
!   if (fp==NULL) return;
    
    while (fscanf(fp,"%79[^\n]\n", buf)!=EOF) {
      if (sscanf(buf,"[%29[^]]",key)>0) {
!       section=parseSection(key);
      } else if (sscanf(buf,"%29[^=]=%49s",key,value)>1) {
!       setValue(section, key, value);    
      }
    }
    fclose(fp);
***************
*** 191,199 ****
   * @author alokl (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 264,272 ----
   * @author alokl (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Shared/Config.h
diff -c AiboPup/Shared/Config.h:1.16 AiboPup/Shared/Config.h:1.19
*** AiboPup/Shared/Config.h:1.16	Mon Jul  7 00:32:47 2003
--- AiboPup/Shared/Config.h	Sun Sep  7 18:14:19 2003
***************
*** 4,9 ****
--- 4,10 ----
  
  #include <vector>
  #include <string>
+ #include "RobotInfo.h"
  
  //!provides global access to system configuration information
  class Config {
***************
*** 42,55 ****
  		int gain;             //!< gain
  		int shutter_speed;    //!< shutter speed
  		int resolution;       //!< resolution
! 		char thresh[30];      //!< thresholds
! 		char colors[30];      //!< colors
  		int raw_port;         //!< port to send raw frames on
  		int rle_port;         //!< port to send RLE frames on
  		int obj_port;         //!< port to send object info on
        
  		//!constructor
! 		vision_config() : white_balance(3), gain(2), shutter_speed(2), resolution(2), thresh(), colors(), raw_port(0), rle_port(0), obj_port(0) {}
  	} vision;
  	
  	//!core functionality information
--- 43,57 ----
  		int gain;             //!< gain
  		int shutter_speed;    //!< shutter speed
  		int resolution;       //!< resolution
! 		char thresh[50];      //!< thresholds
! 		char colors[50];      //!< colors
  		int raw_port;         //!< port to send raw frames on
  		int rle_port;         //!< port to send RLE frames on
  		int obj_port;         //!< port to send object info on
+     int raw_encoding;     //!< resolution and other details for raw output
        
  		//!constructor
! 		vision_config() : white_balance(3), gain(2), shutter_speed(2), resolution(2), thresh(), colors(), raw_port(0), rle_port(0), obj_port(0), raw_encoding(0) {}
  	} vision;
  	
  	//!core functionality information
***************
*** 65,77 ****
  		int walkControl_port;	   //!< port for receiving walk commands
  		int estopControl_port;	   //!< port for receiving walk commands
      int aibo3d_port;   //!< port for send/receive of joint positions from Aibo 3D GUI
  		bool use_VT100;    //!< if true, enables VT100 console codes (currently only in Controller menus - 1.3)
  
  		//!constructor
  		main_config()
  			: console_port(0), stderr_port(0), error_level(0), debug_level(0),
  				verbose_level(0),wsjoints_port(0),wspids_port(0),headControl_port(0),
! 				walkControl_port(0),estopControl_port(0),aibo3d_port(0), use_VT100(true)
  		{ }
  	} main;
  
--- 67,81 ----
  		int walkControl_port;	   //!< port for receiving walk commands
  		int estopControl_port;	   //!< port for receiving walk commands
      int aibo3d_port;   //!< port for send/receive of joint positions from Aibo 3D GUI
+     int wmmonitor_port; //!< port for monitoring Watchable Memory
  		bool use_VT100;    //!< if true, enables VT100 console codes (currently only in Controller menus - 1.3)
  
  		//!constructor
  		main_config()
  			: console_port(0), stderr_port(0), error_level(0), debug_level(0),
  				verbose_level(0),wsjoints_port(0),wspids_port(0),headControl_port(0),
! 				walkControl_port(0),estopControl_port(0),aibo3d_port(0),
!         wmmonitor_port(0), use_VT100(true)
  		{ }
  	} main;
  
***************
*** 99,104 ****
--- 103,111 ----
  		std::string root;       //!< path on memory stick to "motion" files - for instance, position (.pos) and motion sequence (.mot)
  		char estop_on_snd[50];  //!< sound file to use when e-stop turned on
  		char estop_off_snd[50]; //!< sound file to use when e-stop turned off
+ 		float max_head_tilt_speed; //!< max speed for the head joints, used by HeadPointerMC; rad/s
+ 		float max_head_pan_speed; //!< max speed for the head joints, used by HeadPointerMC; rad/s
+ 		float max_head_roll_speed; //!< max speed for the head joints, used by HeadPointerMC; rad/s
  
  		//!returns an absolute path if @a is relative (to root), otherwise just @a name
  		std::string makePath(std::string name) { 
***************
*** 106,113 ****
  		}
  
  		//!constructor
! 		motion_config() : root() {
  			estop_on_snd[0]=estop_off_snd[0]='\0';
  		}
  	} motion;
  
--- 113,123 ----
  		}
  
  		//!constructor
! 		motion_config() : root(), max_head_tilt_speed(0), max_head_pan_speed(0), max_head_roll_speed(0) {
  			estop_on_snd[0]=estop_off_snd[0]='\0';
+ 			max_head_tilt_speed=0;
+ 			max_head_pan_speed=0;
+ 			max_head_roll_speed=0;
  		}
  	} motion;
  
***************
*** 139,144 ****
--- 149,159 ----
  
  	//! call this function when it's time to read the configuration file
  	void readConfig(const char* filename);
+ 	//! returns the section structure corresponding to the section name given
+   section_t parseSection(const char* key);
+ 	//! pass the section, item name string, item value string - sets the value and returns pointer to the item changed
+   void* setValue(section_t section, const char *key, const char *value, bool updated=false);
+ 
  
  protected:
  
***************
*** 154,163 ****
   * @author alokl (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 169,178 ----
   * @author alokl (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Shared/DynamicConfig.h
diff -c /dev/null AiboPup/Shared/DynamicConfig.h:1.1
*** /dev/null	Fri Oct 10 14:37:45 2003
--- AiboPup/Shared/DynamicConfig.h	Mon Jul 28 03:01:47 2003
***************
*** 0 ****
--- 1,32 ----
+ #include <Shared/Config.h>
+ #include <Vision/Vision.h>
+ 
+ namespace DynamicConfig {
+   int assignVarFromController(const char *str) {
+     char buf[80];
+     strncpy(buf, str, 79);
+     char *value=index(buf, '=');
+     char *key=index(buf, '.');
+     if (key==NULL || value==NULL) return -1;
+     if (key>=value) return -1;
+     *key=0;
+     key++;
+     *value=0;
+     value++;
+     Config::section_t section=config->parseSection(buf);
+     if (section==Config::sec_invalid) return -2;
+     void *val_set=config->setValue(section, key, value, true);
+ 
+     if (val_set == &config->vision.white_balance ||
+         val_set == &config->vision.gain ||
+         val_set == &config->vision.shutter_speed)
+       vision->setCameraParams();
+     else if (val_set == &config->vision.resolution)
+       vision->setResolution();
+     else if (val_set == &config->vision.thresh ||
+              val_set == &config->vision.colors)
+       vision->setColors();
+     
+     return 0;
+   }
+ }
Index: AiboPup/Shared/ERS210Info.h
diff -c AiboPup/Shared/ERS210Info.h:1.6 AiboPup/Shared/ERS210Info.h:1.7
*** AiboPup/Shared/ERS210Info.h:1.6	Thu Jun 12 19:41:40 2003
--- AiboPup/Shared/ERS210Info.h	Thu Sep 25 11:31:52 2003
***************
*** 464,473 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 464,473 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Shared/ERS220Info.h
diff -c AiboPup/Shared/ERS220Info.h:1.6 AiboPup/Shared/ERS220Info.h:1.7
*** AiboPup/Shared/ERS220Info.h:1.6	Thu Jun 12 00:16:44 2003
--- AiboPup/Shared/ERS220Info.h	Thu Sep 25 11:31:52 2003
***************
*** 568,577 ****
   * @author Daishi MORI (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 568,577 ----
   * @author Daishi MORI (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Shared/ERS2xxInfo.h
diff -c AiboPup/Shared/ERS2xxInfo.h:1.2 AiboPup/Shared/ERS2xxInfo.h:1.3
*** AiboPup/Shared/ERS2xxInfo.h:1.2	Thu Jun 12 19:41:40 2003
--- AiboPup/Shared/ERS2xxInfo.h	Thu Sep 25 11:31:52 2003
***************
*** 610,619 ****
   * @author Daishi MORI (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 610,619 ----
   * @author Daishi MORI (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Shared/Factory.h
diff -c AiboPup/Shared/Factory.h:1.3 AiboPup/Shared/Factory.h:1.4
*** AiboPup/Shared/Factory.h:1.3	Wed Jan  8 21:02:59 2003
--- AiboPup/Shared/Factory.h	Thu Sep 25 11:31:53 2003
***************
*** 26,35 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 26,35 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Shared/ListMemBuf.h
diff -c AiboPup/Shared/ListMemBuf.h:1.7 AiboPup/Shared/ListMemBuf.h:1.8
*** AiboPup/Shared/ListMemBuf.h:1.7	Tue Mar  4 00:46:07 2003
--- AiboPup/Shared/ListMemBuf.h	Thu Sep 25 11:31:53 2003
***************
*** 334,343 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
   
   #endif
--- 334,343 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
   
   #endif
Index: AiboPup/Shared/LoadSave.cc
diff -c AiboPup/Shared/LoadSave.cc:1.2 AiboPup/Shared/LoadSave.cc:1.3
*** AiboPup/Shared/LoadSave.cc:1.2	Wed Jan  8 21:02:59 2003
--- AiboPup/Shared/LoadSave.cc	Thu Sep 25 11:31:53 2003
***************
*** 137,145 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 137,145 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Shared/LoadSave.h
diff -c AiboPup/Shared/LoadSave.h:1.3 AiboPup/Shared/LoadSave.h:1.4
*** AiboPup/Shared/LoadSave.h:1.3	Fri Jan 10 02:45:21 2003
--- AiboPup/Shared/LoadSave.h	Thu Sep 25 11:31:53 2003
***************
*** 229,238 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 229,238 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Shared/LockScope.h
diff -c AiboPup/Shared/LockScope.h:1.2 AiboPup/Shared/LockScope.h:1.3
*** AiboPup/Shared/LockScope.h:1.2	Sun Apr  6 16:57:45 2003
--- AiboPup/Shared/LockScope.h	Thu Sep 25 11:31:53 2003
***************
*** 22,31 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 22,31 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Shared/Makefile
diff -c AiboPup/Shared/Makefile:1.8 AiboPup/Shared/Makefile:removed
*** AiboPup/Shared/Makefile:1.8	Tue Jun 10 21:18:55 2003
--- AiboPup/Shared/Makefile	Fri Oct 10 14:37:45 2003
***************
*** 1,52 ****
- TEKKOTSU_TARGET_MODEL?=TGT_ERS2xx
- 
- SRCS:=$(shell find . -name "*.cc")
- 
- OBJS:=${SRCS:.cc=.o}
- DEPENDS:=${SRCS:.cc=.d}
- 
- OPENRSDK_ROOT?=/usr/local/OPEN_R_SDK
- CXX=$(OPENRSDK_ROOT)/bin/mipsel-linux-g++
- LD=$(OPENRSDK_ROOT)/bin/mipsel-linux-ld
- FILTERSYSWARN=../tools/filtersyswarn/filtersyswarn
- LIBS=-lObjectComm -lOPENR -lInternet -lantMCOOP
- CURDIR:=$(shell pwd | sed 's/.*\///')
- CXXFLAGS= \
- 	-g -O2 \
- 	-Wall -W -Wshadow -Wlarger-than-8192 -Wpointer-arith -Wcast-qual \
- 	-Woverloaded-virtual -Weffc++ -Winline -Wdeprecated \
- 	-I. -I.. -I../MMCombo -isystem $(OPENRSDK_ROOT)/OPEN_R/include/MCOOP \
- 	-isystem $(OPENRSDK_ROOT)/OPEN_R/include/R4000 -isystem $(OPENRSDK_ROOT)/OPEN_R/include \
- 	-DPLATFORM_APERIOS -DDEBUG -DOPENR_DEBUG \
- 	-D$(TEKKOTSU_TARGET_MODEL) $(GLOBAL_MAP) \
- 
- .PHONY: all clean
- 
- all: $(CURDIR)Lib.o
- 
- $(CURDIR)Lib.o : $(OBJS)
- 	@echo Linking object files...
- 	@echo "$@ <- $(OBJS)"
- 	@$(LD) -i $(OBJS) -o $@
- 
- %.o: %.cc %.d $(FILTERSYSWARN)
- 	@echo Compiling $< into $@...
- 	@$(CXX) $(CXXFLAGS) -o $@ -c $< > $*.log 2>&1; \
- 	retval=$$?; \
- 	cat $*.log | $(FILTERSYSWARN); \
- 	test $$retval -eq 0;
- 
- %.d : %.cc
- 	@echo Building $@ for $<
- 	@$(CXX) $(CXXFLAGS) -MP -MG -MT $@ -MT $*.o -MM $< > $@
- 
- $(FILTERSYSWARN):
- 	(cd ../tools && $(MAKE));
- 
- ifneq ($(MAKECMDGOALS),clean)
- -include $(DEPENDS)
- endif
- 
- 
- clean:
- 	rm -f $(CURDIR)Lib.o $(OBJS) $(DEPENDS) ${SRCS:.cc=.log} *~ 
--- 0 ----
Index: AiboPup/Shared/MutexLock.h
diff -c AiboPup/Shared/MutexLock.h:1.7 AiboPup/Shared/MutexLock.h:1.8
*** AiboPup/Shared/MutexLock.h:1.7	Thu Jun 12 19:41:40 2003
--- AiboPup/Shared/MutexLock.h	Thu Sep 25 11:31:53 2003
***************
*** 256,265 ****
   * @author ejt (Creator), Edward A. Lycklama, Vassos Hadzilacos (paper from which this was based)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 256,265 ----
   * @author ejt (Creator), Edward A. Lycklama, Vassos Hadzilacos (paper from which this was based)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Shared/ProcessID.cc
diff -c AiboPup/Shared/ProcessID.cc:1.2 AiboPup/Shared/ProcessID.cc:1.3
*** AiboPup/Shared/ProcessID.cc:1.2	Thu Jun 12 19:41:41 2003
--- AiboPup/Shared/ProcessID.cc	Thu Sep 25 11:31:53 2003
***************
*** 7,15 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 7,15 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Shared/ProcessID.h
diff -c AiboPup/Shared/ProcessID.h:1.2 AiboPup/Shared/ProcessID.h:1.3
*** AiboPup/Shared/ProcessID.h:1.2	Sun Apr  6 16:57:45 2003
--- AiboPup/Shared/ProcessID.h	Thu Sep 25 11:31:53 2003
***************
*** 27,36 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 27,36 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Shared/Profiler.cc
diff -c AiboPup/Shared/Profiler.cc:1.9 AiboPup/Shared/Profiler.cc:1.10
*** AiboPup/Shared/Profiler.cc:1.9	Tue Apr  8 21:12:24 2003
--- AiboPup/Shared/Profiler.cc	Thu Sep 25 11:31:53 2003
***************
*** 162,169 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
--- 162,169 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
Index: AiboPup/Shared/Profiler.h
diff -c AiboPup/Shared/Profiler.h:1.8 AiboPup/Shared/Profiler.h:1.9
*** AiboPup/Shared/Profiler.h:1.8	Wed Apr  9 03:01:30 2003
--- AiboPup/Shared/Profiler.h	Mon Jul 14 02:55:18 2003
***************
*** 79,86 ****
   */
  class Profiler {
  public:
! 	//! maximum length of names of timers, 32 chosen to make nice memory alignment
! 	static const unsigned int MaxSectionNameLen=32;
  	//! number of slots in the histograms
  	static const unsigned int HistSize=32;
  	//! the upper bound (exclusive) of the histograms, in milliseconds.
--- 79,86 ----
   */
  class Profiler {
  public:
! 	//! maximum length of names of timers
! 	static const unsigned int MaxSectionNameLen=64;
  	//! number of slots in the histograms
  	static const unsigned int HistSize=32;
  	//! the upper bound (exclusive) of the histograms, in milliseconds.
***************
*** 197,206 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 197,206 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Shared/ReferenceCounter.h
diff -c AiboPup/Shared/ReferenceCounter.h:1.3 AiboPup/Shared/ReferenceCounter.h:1.5
*** AiboPup/Shared/ReferenceCounter.h:1.3	Thu Jun 12 14:06:11 2003
--- AiboPup/Shared/ReferenceCounter.h	Thu Aug 21 18:33:00 2003
***************
*** 12,17 ****
--- 12,21 ----
   public:
  	//! constructor
  	ReferenceCounter() : references(0),RC_autodelete(true) {}
+ 	//! copy constructor - uses autodelete setting of @a rc, but references will still start at 0
+ 	ReferenceCounter(const ReferenceCounter& rc) : references(0),RC_autodelete(rc.RC_autodelete) {}
+ 	//! assignment operator - does nothing
+ 	ReferenceCounter& operator=(const ReferenceCounter& rc) {return *this;}
  
  	//! destructor - will std::cout a warning if still has references
  	virtual ~ReferenceCounter() {
***************
*** 69,78 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 73,82 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Shared/RobotInfo.h
diff -c AiboPup/Shared/RobotInfo.h:1.12 AiboPup/Shared/RobotInfo.h:1.13
*** AiboPup/Shared/RobotInfo.h:1.12	Tue Jun 10 21:18:56 2003
--- AiboPup/Shared/RobotInfo.h	Fri Jul 11 15:54:42 2003
***************
*** 14,19 ****
--- 14,24 ----
  #endif //model selection
  
  //! Contains information about the robot, such as number of joints, PID defaults, timing information, etc.
+ /*! This is just a wrapper for whichever namespace corresponds to the current
+  *  robot target setting (one of TGT_ERS210, TGT_ERS220, or the default, TGT_ERS2xx)
+  *
+  *  You probably should look at ERS210Info, ERS220Info, or ERS2xxInfo for the actual
+  *  constants used for each model. */
  namespace RobotInfo {
  
  #if TGT_ERS220
***************
*** 33,42 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 38,47 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Shared/Serializer.h
diff -c AiboPup/Shared/Serializer.h:1.4 AiboPup/Shared/Serializer.h:1.5
*** AiboPup/Shared/Serializer.h:1.4	Thu Jun 12 14:06:11 2003
--- AiboPup/Shared/Serializer.h	Mon Jul 28 02:43:52 2003
***************
*** 1,11 ****
  #ifndef INCLUDED_Serializer_h
  #define INCLUDED_Serializer_h
  
  //!provides a default serializer base class for simple objects
  class Serializer {
  public:
-   
- protected:
  	//! writes @a value to @a dst and advances @a dst
    template<class T>
    inline static void encode(char **dst, T value) {
--- 1,29 ----
  #ifndef INCLUDED_Serializer_h
  #define INCLUDED_Serializer_h
  
+ #include "Shared/get_time.h"
+ #include <iostream>
+ 
+ namespace SerializerNS {
+   // SYNC with Listener.java in TekkotsuMon
+   enum PacketFormat_t {
+     packet_text=0,
+     packet_visionraw_half,
+     packet_visionraw_full,
+     packet_visionraw_yfull_uvhalf,
+     packet_visionrle_full,
+     packet_worldstatejoints,
+     packet_worldstatepids,
+     packet_worldstatebuttons,
+     packet_wmclass
+   };
+ };
+ 
+ using namespace SerializerNS;
+ 
  //!provides a default serializer base class for simple objects
  class Serializer {
  public:
  	//! writes @a value to @a dst and advances @a dst
    template<class T>
    inline static void encode(char **dst, T value) {
***************
*** 17,35 ****
    }
  
  	//! converts to network byte order (big endian - aibo is little endian)
!   inline static void hostToNetwork(char *dst, char *src, int length) {
      for (int i=0; i<length; i++)
        dst[length-1-i]=src[i];
    }
  
  	//! writes @a length bytes from @a src to @a dst
!   inline static void encode(char **dst, char *src, int length) {
      memcpy(*dst, src, length);
      (*dst) +=length;
    }
  
  	//! a simple form of compression - calls encode(@a dst,float(@a src[i])) for i=0..@a length
!   inline static void encodeDoublesAsFloats(char **dst, double *src, int length) {
      for (int i=0; i<length; i++)
        encode(dst, float(src[i]));
    }
--- 35,60 ----
    }
  
  	//! converts to network byte order (big endian - aibo is little endian)
!   inline static void hostToNetwork(char *dst, const char *src, int length) {
      for (int i=0; i<length; i++)
        dst[length-1-i]=src[i];
    }
  
  	//! writes @a length bytes from @a src to @a dst
!   inline static void encode(char **dst, const char *src, int length) {
      memcpy(*dst, src, length);
      (*dst) +=length;
    }
  
+   //! writes packet type and timestamp
+   inline static void encodeHeader(char **dst, PacketFormat_t pformat) {
+     int time=get_time();
+     encode(dst, pformat);
+     encode(dst, time);
+   }
+ 
  	//! a simple form of compression - calls encode(@a dst,float(@a src[i])) for i=0..@a length
!   inline static void encodeDoublesAsFloats(char **dst, const double *src, int length) {
      for (int i=0; i<length; i++)
        encode(dst, float(src[i]));
    }
***************
*** 39,49 ****
   * @brief Defines the Serializer base class, which provides a default serializer for simple objects
   * @author alokl (Creator)
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 64,74 ----
   * @brief Defines the Serializer base class, which provides a default serializer for simple objects
   * @author alokl (Creator)
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Shared/SharedObject.h
diff -c AiboPup/Shared/SharedObject.h:1.1 AiboPup/Shared/SharedObject.h:1.3
*** AiboPup/Shared/SharedObject.h:1.1	Sun Mar  9 02:06:11 2003
--- AiboPup/Shared/SharedObject.h	Fri Sep 12 19:42:12 2003
***************
*** 13,18 ****
--- 13,28 ----
  
  protected:
  	SharedObjectBase() : rcr(NULL) {} //!< constructor, protected because you shouldn't need to create this directly, just a common interface to all templates of SharedObject
+ 
+ 	//< destructor, automatically dereferences #rcr
+ 	virtual ~SharedObjectBase() {
+ 		//std::cout << "~SharedObjectBase(): rcr->NumberOfReference()==" << rcr->NumberOfReference() << std::endl;
+ 		if(rcr && rcr->NumberOfReference()>0)
+ 			rcr->RemoveReference();
+ 		else
+ 			std::cout << "WARNING: SharedObjectBase destructed without reference" << std::endl;
+ 		//std::cout << "~SharedObjectBase()NOW: rcr->NumberOfReference()==" << rcr->NumberOfReference() << std::endl;
+ 	} 
  	RCRegion * rcr; //!< the pointer to the shared memory region this is in charge of
  	
  private:
***************
*** 30,61 ****
  
  	//! Creates the class with the default constructor
  	SharedObject() : SharedObjectBase() {
! 		rcr = new RCRegion(calcsize());
  		new (rcr->Base()) MC;
  	}
  	//! Creates the class, passing its constructor t1
  	template<class T1> SharedObject(T1 t1) : SharedObjectBase() {
! 		rcr = new RCRegion(calcsize());
  		new (rcr->Base()) MC(t1);
  	}
  	//! Creates the class, passing its constructor t1 and t2
  	template<class T1, class T2> SharedObject(T1 t1, T2 t2) : SharedObjectBase(){
! 		rcr = new RCRegion(calcsize());
  		new (rcr->Base()) MC(t1,t2);
  	}
  	//! Creates the class, passing its constructor t1, t2, and t3
  	template<class T1, class T2, class T3> SharedObject(T1 t1, T2 t2, T3 t3) : SharedObjectBase(){
! 		rcr = new RCRegion(calcsize());
  		new (rcr->Base()) MC(t1,t2,t3);
  	}
  	//! Creates the class, passing its constructor t1, t2, t3 and t4
  	template<class T1, class T2, class T3, class T4> SharedObject(T1 t1, T2 t2, T3 t3, T4 t4) : SharedObjectBase(){
! 		rcr = new RCRegion(calcsize());
  		new (rcr->Base()) MC(t1,t2,t3,t4);
  	}
  	//! Creates the class, passing its constructor t1, t2, t3, t4 and t5 - if you need more arguments, just add them
  	template<class T1, class T2, class T3, class T4, class T5> SharedObject(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) : SharedObjectBase(){
! 		rcr = new RCRegion(calcsize());
  		new (rcr->Base()) MC(t1,t2,t3,t4,t5);
  	}
  	//@}
--- 40,71 ----
  
  	//! Creates the class with the default constructor
  	SharedObject() : SharedObjectBase() {
! 		rcr=createRCRegion();
  		new (rcr->Base()) MC;
  	}
  	//! Creates the class, passing its constructor t1
  	template<class T1> SharedObject(T1 t1) : SharedObjectBase() {
! 		rcr=createRCRegion();
  		new (rcr->Base()) MC(t1);
  	}
  	//! Creates the class, passing its constructor t1 and t2
  	template<class T1, class T2> SharedObject(T1 t1, T2 t2) : SharedObjectBase(){
! 		rcr=createRCRegion();
  		new (rcr->Base()) MC(t1,t2);
  	}
  	//! Creates the class, passing its constructor t1, t2, and t3
  	template<class T1, class T2, class T3> SharedObject(T1 t1, T2 t2, T3 t3) : SharedObjectBase(){
! 		rcr=createRCRegion();
  		new (rcr->Base()) MC(t1,t2,t3);
  	}
  	//! Creates the class, passing its constructor t1, t2, t3 and t4
  	template<class T1, class T2, class T3, class T4> SharedObject(T1 t1, T2 t2, T3 t3, T4 t4) : SharedObjectBase(){
! 		rcr=createRCRegion();
  		new (rcr->Base()) MC(t1,t2,t3,t4);
  	}
  	//! Creates the class, passing its constructor t1, t2, t3, t4 and t5 - if you need more arguments, just add them
  	template<class T1, class T2, class T3, class T4, class T5> SharedObject(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) : SharedObjectBase(){
! 		rcr=createRCRegion();
  		new (rcr->Base()) MC(t1,t2,t3,t4,t5);
  	}
  	//@}
***************
*** 64,76 ****
  	MC& operator*() const { return *dataCasted(); } //!< smart pointer to the underlying class
  	MC& operator[](int i) const { return dataCasted()[i]; } //!< smart pointer to the underlying class
  protected:
  	MC* dataCasted() const { return static_cast<MC*>(data()); } //!< returns a correctly typed pointer to the object's memory
  
  	//!Calculates the size of the memory region to be used, rounding up to the nearest page size
  	/*! Not sure this is completely necessary, but may be nice.  Of course, this also means even
  	 *  small regions are going to be at least 4K (current page size)  If memory gets tight or we
  	 *  get a lot of little regions floating around, this might be worth checking into */
! 	unsigned int calcsize() {
  		size_t size = sizeof(MC);
  		sError error;
  		size_t page_size;
--- 74,94 ----
  	MC& operator*() const { return *dataCasted(); } //!< smart pointer to the underlying class
  	MC& operator[](int i) const { return dataCasted()[i]; } //!< smart pointer to the underlying class
  protected:
+ 	//! creates and returns RCRegion of correct size for current class.  Adds a reference (which is removed in the destructor)
+ 	static RCRegion * createRCRegion() {
+ 		RCRegion * r = new RCRegion(calcsize());
+ 		//std::cout << "createRCRegion(): rcr->NumberOfReference()==" << r->NumberOfReference() << std::endl;
+ 		r->AddReference();
+ 		//std::cout << "createRCRegion()NOW: rcr->NumberOfReference()==" << r->NumberOfReference() << std::endl;
+ 		return r;
+ 	}
  	MC* dataCasted() const { return static_cast<MC*>(data()); } //!< returns a correctly typed pointer to the object's memory
  
  	//!Calculates the size of the memory region to be used, rounding up to the nearest page size
  	/*! Not sure this is completely necessary, but may be nice.  Of course, this also means even
  	 *  small regions are going to be at least 4K (current page size)  If memory gets tight or we
  	 *  get a lot of little regions floating around, this might be worth checking into */
! 	static unsigned int calcsize() {
  		size_t size = sizeof(MC);
  		sError error;
  		size_t page_size;
***************
*** 98,107 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif //INCLUDED_SharedObject_h
--- 116,125 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif //INCLUDED_SharedObject_h
Index: AiboPup/Shared/SharedQueue.h
diff -c AiboPup/Shared/SharedQueue.h:1.3 AiboPup/Shared/SharedQueue.h:1.4
*** AiboPup/Shared/SharedQueue.h:1.3	Thu Jun 12 19:41:41 2003
--- AiboPup/Shared/SharedQueue.h	Thu Sep 25 11:31:53 2003
***************
*** 134,143 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 134,143 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Shared/SystemUtility.h
diff -c AiboPup/Shared/SystemUtility.h:1.2 AiboPup/Shared/SystemUtility.h:1.4
*** AiboPup/Shared/SystemUtility.h:1.2	Thu Jan 23 19:37:39 2003
--- AiboPup/Shared/SystemUtility.h	Fri Oct 10 13:46:04 2003
***************
*** 32,37 ****
--- 32,41 ----
  #include <MCOOP.h>
  
  #ifdef PLATFORM_APERIOS
+ //! Gets memory from Aperios/OPEN-R using system's NewRegion command
+ /*! This seems to be the thing to do when getting large regions?  We've
+  *  had some issues with large regions returned from @c new which overlap.
+  *  This issue may no longer exist, was never well known. */
  template <class T>
  T *NewLarge(T **dst, int count) {
    sError result;
***************
*** 42,47 ****
--- 46,52 ----
    return *dst;
  }
  
+ //! Frees memory from Aperios/OPEN-R using system's DeleteRegion command (use only on regions obtained from NewLarge)
  template <class T>
  void DeleteLarge(T *dst) {
    DeleteRegion(dst);
***************
*** 55,64 ****
   * @verbinclude CMPack_license.txt
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 60,69 ----
   * @verbinclude CMPack_license.txt
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Shared/TimeET.cc
diff -c AiboPup/Shared/TimeET.cc:1.2 AiboPup/Shared/TimeET.cc:1.3
*** AiboPup/Shared/TimeET.cc:1.2	Wed Jan  8 21:02:59 2003
--- AiboPup/Shared/TimeET.cc	Thu Sep 25 11:31:53 2003
***************
*** 7,15 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 7,15 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Shared/TimeET.h
diff -c AiboPup/Shared/TimeET.h:1.2 AiboPup/Shared/TimeET.h:1.3
*** AiboPup/Shared/TimeET.h:1.2	Fri Apr 18 01:15:11 2003
--- AiboPup/Shared/TimeET.h	Thu Sep 25 11:31:53 2003
***************
*** 148,157 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 148,157 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Shared/Util.h
diff -c AiboPup/Shared/Util.h:1.4 AiboPup/Shared/Util.h:1.5
*** AiboPup/Shared/Util.h:1.4	Thu Jan 23 13:14:11 2003
--- AiboPup/Shared/Util.h	Thu Sep 25 11:31:53 2003
***************
*** 300,309 ****
   * @endverbatim
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 300,309 ----
   * @endverbatim
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Shared/WMclass.cc
diff -c /dev/null AiboPup/Shared/WMclass.cc:1.2
*** /dev/null	Fri Oct 10 14:37:45 2003
--- AiboPup/Shared/WMclass.cc	Mon Oct  6 21:01:09 2003
***************
*** 0 ****
--- 1,98 ----
+ // Watchable Memory (WM)
+ //
+ // David S. Touretzky
+ // (Insert standard Tekkotsu copyright stuff here.)
+ 
+ #include "WMclass.h"
+ 
+ //================================================================
+ //
+ // toString() methods for various classes
+ //
+ 
+ template<>
+ std::string WMitem<int>::toString(void) const {
+   char print_buffer[30];
+   sprintf(print_buffer,"%d",get_value());
+   return std::string(print_buffer);
+ }
+ 
+ template<>
+ std::string WMitem<float>::toString(void) const {
+   char print_buffer[30];
+   sprintf(print_buffer,"%g",get_value());
+   return std::string(print_buffer);
+ }
+ 
+ template<>
+ std::string WMitem<double>::toString(void) const {
+   char print_buffer[30];
+   sprintf(print_buffer,"%g",get_value());
+   return std::string(print_buffer);
+ }
+ 
+ template<>
+ std::string WMitem<bool>::toString(void) const {
+   char print_buffer[30];
+   sprintf(print_buffer,"%d",get_value());
+   return std::string(print_buffer);
+ }
+ 
+ template<>
+ std::string WMitem<char>::toString(void) const {
+   char print_buffer[30];
+   sprintf(print_buffer,"'%c'",get_value());
+   return std::string(print_buffer);
+ }
+ 
+ template<>
+ std::string WMitem<char*>::toString(void) const {
+   char buff[1+WM_max_stringlen] = "";
+   strncpy(buff,get_value(),WM_max_stringlen);
+   char *p = get_value();
+   char *q = p + WM_max_stringlen + 1;
+   for (; p != q ; p++)
+     if ( *p == 0 ) break;
+   std::string result = std::string("\"") + buff + ((p==q) ? "..." : "") + "\"";
+   return result;
+ }
+ 
+ template<>
+ std::string WMitem<std::string>::toString(void) const {
+   return std::string("\"") + 
+     ((get_value().length() <= WM_max_stringlen) ?
+      get_value() : get_value().substr(0,WM_max_stringlen) + "...") + "\"";
+ }
+ 
+ template<>
+ std::string WMitem<WMregistry>::toString(void) const {
+   char print_buffer[300];
+   sprintf(print_buffer,"<%s, %d entries>",
+ 	  get_value().name.data(),get_value().entries.size());
+   return std::string(print_buffer);
+ }
+ 
+ WMregistry GlobalWM("GlobalWM");
+ 
+ WMitem<WMregistry> lookup_reg(std::string const &name, WMregistry &registry) {
+   for (std::vector<WMentry*>::const_iterator it = registry.entries.begin(); 
+        it != registry.entries.end(); it++) {
+     if ( (*it)->item_name == name )
+       return *static_cast<WMitem<WMregistry> const*>((*it)->item);
+   };
+   return create_WMentry(name, "WMregistry", new WMregistry(name, &registry),
+                         registry);
+ }
+ 
+ void WMregistry::dump(void) const {
+   std::cout << std::endl << "Registry " << name << ":" << std::endl;
+   for (std::vector<WMentry*>::const_iterator it = entries.begin();
+        it != entries.end();
+        it++)
+     std::cout << "  " << (*it)->type_name << " " << (*it)->item_name
+ 	 << " = " << (*it)->item->toString() << std::endl;
+ }
+ 
+ void dump(WMitem<WMregistry> const &wmreg) {
+   wmreg.get_value().dump();
+ }
Index: AiboPup/Shared/WMclass.h
diff -c /dev/null AiboPup/Shared/WMclass.h:1.3
*** /dev/null	Fri Oct 10 14:37:45 2003
--- AiboPup/Shared/WMclass.h	Fri Oct 10 13:46:04 2003
***************
*** 0 ****
--- 1,395 ----
+ //-*-c++-*-
+ // David S. Touretzky
+ #ifndef INCLUDED_WMclass_h_
+ #define INCLUDED_WMclass_h_
+ 
+ #include <string>
+ #include <vector>
+ #include <iostream>
+ #include "Events/EventRouter.h"
+ 
+ /*! @file
+  *	@brief  Watchable memory.  Variables are monitored and changes are announced.
+  *  @author dst (Creator)
+  *  @author alokl (Ported)
+  *  
+  *  $Author: ejt $
+  *  $Name: HEAD $
+  *  $Revision: 1.2 $
+  *  $State: Exp $
+  *  $Date: 2003/10/10 20:25:03 $
+  *
+  * \par These macros allow you to quickly create a WM variable, but only if
+  * it's staticly defined - you can't use these with a dynamic number
+  * of variables.  You'll have to manually create a WMitem<T> or
+  * another subclass of WMitem_base if you want define these on the
+  * fly... it's not hard to do, just look at the macro definitions.
+  *
+  * \par WMvar(type,name) declares the variable in the registry
+  * GlobalWM.
+  *
+  * \par WMvari(type,name,initval) declares the variable in GlobalWM
+  * and initializes it if it doesn't already exist.
+  *
+  * \par WMvar_(type,name,registry) declares the variable in the
+  * specified registry.
+  *
+  * \par WMvari_(type,name,initval,registry) declares the variable in
+  * the specified registry and initializes it if it doesn't already
+  * exist.
+  *
+  * \par WMreg(name) declares a new WMregistry as a variable in
+  * GlobalWM.
+  *
+  * \par WMreg(name,registry) declares a new WMregistry as a variable
+  * in the specified registry,
+  *
+  * Examples:  
+  * - WMvar(int, foo);  
+  * - WMvari(double, head_angle, 37.5);  
+  * - WMreg(myreg);<br>
+  * - WMvar_(bool, winflag, myreg);
+  */
+ 
+ #define WM_max_stringlen 60		//!< Maximum displayed length of a char* or std::string variable.
+ 
+ class WMentry;
+ class WMitem_base;
+ 
+ //================================================================
+ 
+ //! A WMregistry is a namespace; it holds a collection of WMEntry instances describing the variables that live in this registry.
+ class WMregistry {
+ public:
+   std::string	name; //!< Name of the registry.
+   std::vector<WMentry*> entries; //!< Entries that make up the registry.
+   bool watched; //!< True if changes to this registry are being monitored.
+   WMregistry* parent; //!< pointer to parent registry (allows recursive structure)
+ 
+ public:
+ 	//! Constructor
+   WMregistry(const std::string &n = "anonymous", WMregistry* p=NULL) : name(n), entries(), watched(0), parent(p) {};
+ 	WMregistry(const WMregistry& in) : name(in.name), entries(in.entries), watched(in.watched), parent(in.parent) {} //!< shallow copy
+ 
+ 	//! shallow assignment
+ 	WMregistry& operator=(const WMregistry& in) {
+ 		name=in.name;
+ 		entries=in.entries;
+ 		watched=in.watched;
+ 		parent=in.parent;
+ 		return *this;
+ 	}
+ 
+   //! Turn on monitoring of changes to variables.
+   void watch(void) { watched = 1; };
+ 
+   //! Turn off monitoring of changes to variables.
+   void unwatch(void) { watched = 0; };
+ 
+   //! Dump the registry to the console, for debugging.
+   void dump(void) const;
+ 
+ };
+ 
+ //================================================================
+ 
+ //! A WMentry is an entry in a WMregistry.
+ /*! The item it describes is a unique variable, which may be accessed
+  *  via many WMitem instances, all of which point back to the same
+  *  WMentry. */
+ class WMentry {
+ public:
+   std::string const item_name; //!< Name of the variable described by this entry.
+   std::string const type_name; //!< Type of the variable, e.g., "int".
+   WMitem_base* const item; //!< Pointer to a WMitem instance for the variable.
+   WMregistry* registry; //!< The registry in which this entry resides.
+   bool watched;//!< True if changes to this variable should be reported.
+ 
+ public:
+ 	//! constructor
+   WMentry(const std::string &iname, const std::string &tname, WMitem_base* ival, WMregistry* reg = 0) : 
+     item_name(iname), type_name(tname), item(ival), registry(reg), watched(0) {};
+ 	WMentry(const WMentry& in) : item_name(in.item_name), type_name(in.type_name), item(in.item), registry(in.registry), watched(in.watched) {} //!< shallow copy
+ 
+ private:
+ 	WMentry operator=(const WMentry&); //!< don't assign
+ };
+ 
+ 
+ //================================================================
+ 
+ //! WMitem_base is the base class from which all WMitem<T> subclasses are derived.
+ class WMitem_base {
+ public:
+   void* const         value;    //!< Pointer to the actual variable referenced by this WMitem.
+   WMentry*            entry;    //!< Pointer to the WMentry describing this variable.
+   virtual std::string toString(void) const = 0; //!< override this to return appropriate string representation
+ 
+ 	//!Constructor
+   WMitem_base(void* const val) : value(val), entry(NULL) {};
+ 	WMitem_base(const WMitem_base &in ) : value(in.value), entry(in.entry) {} //!< *can* copy
+ 
+   //! Turn on monitoring of changes to the variable described by this entry.
+   void watch(void) const {
+ 		entry->watched = 1; 
+ 		erouter->postEvent(new EventBase(EventBase::wmVarEGID,reinterpret_cast<unsigned int>(entry),EventBase::activateETID));
+ 	};
+ 
+   //! Turn off monitoring of changes to the variable described by this entry.
+   void unwatch(void) const {
+ 		entry->watched = 0;
+ 		erouter->postEvent(new EventBase(EventBase::wmVarEGID,reinterpret_cast<unsigned int>(entry),EventBase::deactivateETID));
+ 	};
+ 
+ private:
+ 	WMitem_base& operator=(const WMitem_base & ); //!< don't assign
+ };
+ 
+ 
+ 
+ //! WMitem<T> is a reference to the variable of type T described by the associated WMentry
+ /*! If the variable is declared in multiple functions, each
+  *	declaration will have an associated WMitem<T> instance, but all
+  *	the instances will reference the same variable. */
+ template<class T>
+ class WMitem : public WMitem_base {
+ public:
+   WMitem(T* const initval) : WMitem_base(initval)  {} //!< constructor
+ 	WMitem(const WMitem& in) : WMitem_base(in) {} //!< shallow copy
+ 
+   virtual WMitem<T>& operator= (const T &new_value); //!< Assignment operator.
+   WMitem<T>& operator++ ();                  //!< Generic operator prefix (++x)
+   WMitem<T>  operator++ (int);               //!< Generic operator postfix (x++)
+   WMitem<T>& operator-- ();                  //!< Generic operator prefix (--x)
+   WMitem<T>  operator-- (int);               //!< Generic operator postfix (x--)
+   WMitem<T>& operator+= (const T &val);      //!< Generic operator+=
+   WMitem<T>& operator-= (const T &val);      //!< Generic operator-=
+   WMitem<T>& operator*= (const T &val);      //!< Generic operator*=
+   WMitem<T>& operator/= (const T &val);      //!< Generic operator/=
+ 	
+ 	//! Annonces changes, throws an event from wmVarEGID
+   void announce (const T &val);
+ 	
+ 	//! Explicit retrieval of variable value, used by toString()
+   virtual T& get_value(void) const { return *static_cast<T*>(value); };
+ 	
+ 	//! Coerce a WMitem<T> to type T by retrieving the value.
+   virtual operator T&() const { return  *static_cast<T*>(value); };
+ 	
+ 	//! std::String representation of the value.
+   virtual std::string toString(void) const;    
+ };
+ 
+ 
+ //================================================================
+ 
+ //!Allows you to create a static WMvar
+ #define WMvar(T,name) \
+   static WMitem<T> name(lookup_WMentry<T>(#name,#T,GlobalWM));
+ 
+ //!Allows you to create a static WMvar with a default initialization value
+ #define WMvari(T,name,initval) \
+   static WMitem<T> name(lookup_WMentry<T>(#name,#T,initval,GlobalWM));
+ 
+ //!Allows you to create a static WMvar in a registry with a default initialization value
+ #define WMvar_(T,name,registry) \
+   static WMitem<T> name(lookup_WMentry<T>(#name,#T,registry));
+ 
+ //!Allows you to create a static WMvar in a registry with a default initialization value
+ #define WMvari_(T,name,initval,registry) \
+   static WMitem<T> name(lookup_WMentry<T>(#name,#T,initval,registry));
+ 
+ //!Allows you to create a new static registry
+ #define WMreg(name) \
+   static WMitem<WMregistry> name(lookup_reg(#name,GlobalWM));
+ 
+ //!Allows you to create a new static registry with a parent registry
+ #define WMreg_(name,parent) \
+   static WMitem<WMregistry> name(lookup_reg(#name,parent));
+ 
+ //================================================================
+ 
+ 
+ 
+ //! Three versions of lookup_WMentry with different argument types, and one version of create_WMentry, which they share.  
+ //!@name Global Lookup functions
+ 
+ //! The lookup_reg function is defined in WMclass.cc since it's not templated.
+ template<typename T>
+ WMitem<T> lookup_WMentry(const std::string &iname,
+ 												 const std::string &tname,
+ 												 const std::string &regname);
+ 
+ template<typename T>
+ WMitem<T> lookup_WMentry(const std::string &iname,
+ 												 const std::string &tname, 
+ 												 const WMregistry &reg);
+ 
+ template<typename T>
+ WMitem<T> lookup_WMentry(const std::string &iname,
+ 												 const std::string &tname,
+ 												 const T &initval, WMregistry &reg);
+ 
+ template<typename T>
+ WMitem<T> create_WMentry(const std::string &iname, 
+ 												 const std::string &tname, 
+ 												 const T* const value, WMregistry &reg);
+ 
+ //! the global registry for all others to put their stuff in
+ extern WMregistry GlobalWM;
+ 
+ WMitem<WMregistry> lookup_reg(const std::string &name, WMregistry &registry);
+ 
+ void dump(const WMitem<WMregistry> &wmreg);
+ 
+ //@}
+ 
+ /*! Generic toString() method that just displays the variable's type and
+  *  address.  Will be overridden for common types like int or double. */
+ template<class T>
+ std::string WMitem<T>::toString(void) const {
+   char print_buffer[30];
+   sprintf(print_buffer,"%x",reinterpret_cast<unsigned int>(value));
+   return "<" + entry->type_name + " at 0x" + print_buffer + ">";
+ }
+ 
+ /*! The assignment operator for WMitem<T> changes the value of the
+  *  variable referenced by the WMitem, and reports the change if the
+  *  variable is "watched". */
+ template<class T>
+ WMitem<T>& WMitem<T>::operator= (const T &new_value) {
+ 	get_value() = new_value;
+ 	//	*static_cast<T*>(value)=new_value;
+ 	announce (new_value);
+   return *this;
+ }
+ 
+ template<class T>
+ void WMitem<T>::announce (const T&) {
+   if (entry->watched) {
+ 		erouter->postEvent(new EventBase(EventBase::wmVarEGID,reinterpret_cast<unsigned int>(entry),EventBase::statusETID));
+ 	}
+ 	/*    if (wmMonitorBehavior!=NULL) {
+ 				std::string s(entry->item_name);
+ 				WMregistry *temp=entry->registry;
+ 				while (temp!=&GlobalWM && temp!=NULL) {
+         s=temp->name + "." + s;
+         temp=temp->parent;
+ 				}
+ 				wmMonitorBehavior->report(entry->type_name, s, toString());
+ 				}
+ 	*/
+ 	/*
+ 		if (entry->registry->watched)
+     if (wmMonitorBehavior!=NULL)
+ 		wmMonitorBehavior->report(entry->registry->name, "registry_change",
+ 		"change to var");
+ 	*/
+ }
+ 
+ template<class T>
+ WMitem<T>& WMitem<T>::operator++ (void) {
+   announce(++get_value());
+   return *this;
+ }
+ 
+ template<class T>
+ WMitem<T> WMitem<T>::operator++ (int) {
+   WMitem<T> temp(*this);
+   announce(++get_value());
+   return temp;
+ }
+ 
+ template<class T>
+ WMitem<T>& WMitem<T>::operator-- (void) {
+   announce(--get_value());
+   return *this;
+ }
+ 
+ template<class T>
+ WMitem<T> WMitem<T>::operator-- (int) {
+   WMitem<T> temp(*this);
+   announce(--get_value());
+   return temp;
+ }
+ 
+ template<class T>
+ WMitem<T>& WMitem<T>::operator+= (const T &val) {
+   return operator=(get_value()+val);
+ }
+ 
+ template<class T>
+ WMitem<T>& WMitem<T>::operator-= (const T &val) {
+   return operator=(get_value()-val);
+ }
+ 
+ template<class T>
+ WMitem<T>& WMitem<T>::operator*= (const T &val) {
+   return operator=(get_value()*val);
+ }
+ 
+ template<class T>
+ WMitem<T>& WMitem<T>::operator/= (const T &val) {
+   return operator=(get_value()/val);
+ }
+ 
+ //================================================================
+ //
+ // Three versions of lookup_WMentry with different argument types,
+ // and one version of create_WMentry, which they share.  
+ //
+ // The lookup_reg function is defined in WMclass.c since it's not
+ // templated.
+ 
+ template<typename T>
+ WMitem<T> lookup_WMentry(const std::string &iname,
+ 												 const std::string &tname,
+ 												 const std::string &regname) {
+   WMregistry* reg = 0;
+   for (std::vector<WMentry*>::const_iterator it = GlobalWM.entries.begin(); it != GlobalWM.entries.end(); it++) {
+     if ( (*it)->item_name == regname ) {
+       reg = static_cast<WMregistry*>((*it)->item->value);
+       break;
+     };
+   };
+   if ( reg == 0 ) {
+     reg = new WMregistry(regname, &GlobalWM);
+     create_WMentry(regname, "WMregistry", reg, GlobalWM);
+   };
+   return lookup_WMentry<T>(iname, tname, *reg);
+ }
+ 
+ template<typename T>
+ WMitem<T> lookup_WMentry(const std::string &iname,
+ 												 const std::string &tname, 
+ 												 WMregistry &reg) {
+   for (std::vector<WMentry*>::const_iterator it = reg.entries.begin(); it != reg.entries.end(); it++) {
+     if ( (*it)->item_name == iname )
+       return *static_cast<WMitem<T> const*>((*it)->item);
+   };
+   return create_WMentry(iname, tname, new T, reg);
+ }
+ 
+ template<typename T>
+ WMitem<T> lookup_WMentry(const std::string &iname,
+ 												 const std::string &tname,
+ 												 T const &initval, WMregistry &reg) {
+   for (std::vector<WMentry*>::const_iterator it = reg.entries.begin(); it != reg.entries.end(); it++) {
+     if ( (*it)->item_name == iname )
+       return *static_cast<WMitem<T> const*>((*it)->item);
+   };
+   return create_WMentry(iname, tname, new T(initval), reg);
+ }
+  
+ template<typename T>
+ WMitem<T> create_WMentry(const std::string &iname, 
+ 												 const std::string &tname, 
+ 												 T* const value, WMregistry &reg) {
+   WMentry* new_entry = new WMentry(iname, tname, new WMitem<T>(value), &reg);
+   new_entry->item->entry = new_entry;
+   reg.entries.push_back(new_entry);
+   return *static_cast<WMitem<T> const*>(new_entry->item);
+ }
+ 
+ #endif
+ 
Index: AiboPup/Shared/WorldState.cc
diff -c AiboPup/Shared/WorldState.cc:1.15 AiboPup/Shared/WorldState.cc:1.16
*** AiboPup/Shared/WorldState.cc:1.15	Thu Jun 12 00:16:44 2003
--- AiboPup/Shared/WorldState.cc	Thu Sep 25 11:31:53 2003
***************
*** 310,317 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
--- 310,317 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
Index: AiboPup/Shared/WorldState.h
diff -c AiboPup/Shared/WorldState.h:1.18 AiboPup/Shared/WorldState.h:1.19
*** AiboPup/Shared/WorldState.h:1.18	Thu Jun 12 19:41:41 2003
--- AiboPup/Shared/WorldState.h	Sun Jul 27 15:11:27 2003
***************
*** 110,116 ****
  	};
  }
  	
! //! The state of the robot and its environment\n
  /* Contains sensor readings, current joint positions, etc.\n
   * This is a shared memory region between MainObj, MotoObj, and possibly others in the future\n
   * Be very careful about including structures that use pointers in this class... they will only be valid
--- 110,116 ----
  	};
  }
  	
! //! The state of the robot and its environment
  /* Contains sensor readings, current joint positions, etc.\n
   * This is a shared memory region between MainObj, MotoObj, and possibly others in the future\n
   * Be very careful about including structures that use pointers in this class... they will only be valid
***************
*** 214,223 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 214,223 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Shared/WorldStateSerializer.cc
diff -c AiboPup/Shared/WorldStateSerializer.cc:1.5 AiboPup/Shared/WorldStateSerializer.cc:1.6
*** AiboPup/Shared/WorldStateSerializer.cc:1.5	Thu May 29 15:55:27 2003
--- AiboPup/Shared/WorldStateSerializer.cc	Mon Jul 28 02:43:52 2003
***************
*** 7,14 ****
--- 7,16 ----
  
  WorldStateSerializer::WorldStateSerializer() : wsJoints(NULL), wsPIDs(NULL) {
    wsJoints=wireless->socket(SocketNS::SOCK_STREAM, 1024, 2048);
+   wireless->setDaemon(wsJoints);
    wireless->listen(wsJoints, config->main.wsjoints_port);
    wsPIDs=wireless->socket(SocketNS::SOCK_STREAM, 1024, 2048);
+   wireless->setDaemon(wsPIDs);
    wireless->listen(wsPIDs, config->main.wspids_port);
  }
  
Index: AiboPup/Shared/debuget.h
diff -c AiboPup/Shared/debuget.h:1.1.1.1 AiboPup/Shared/debuget.h:1.2
*** AiboPup/Shared/debuget.h:1.1.1.1	Mon Sep 30 14:19:48 2002
--- AiboPup/Shared/debuget.h	Thu Sep 25 11:31:53 2003
***************
*** 72,82 ****
   * @brief Defines several debugging functions and macros, including ::ASSERT (and variations)
   * @author ejt (Creator)
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  // static void hexout(unsigned int in) {
--- 72,82 ----
   * @brief Defines several debugging functions and macros, including ::ASSERT (and variations)
   * @author ejt (Creator)
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  // static void hexout(unsigned int in) {
Index: AiboPup/Shared/get_time.cc
diff -c AiboPup/Shared/get_time.cc:1.2 AiboPup/Shared/get_time.cc:1.3
*** AiboPup/Shared/get_time.cc:1.2	Wed Jan  8 21:03:00 2003
--- AiboPup/Shared/get_time.cc	Fri Jul 25 16:18:07 2003
***************
*** 19,26 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
--- 19,26 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
Index: AiboPup/Shared/get_time.h
diff -c AiboPup/Shared/get_time.h:1.1.1.1 AiboPup/Shared/get_time.h:1.2
*** AiboPup/Shared/get_time.h:1.1.1.1	Mon Sep 30 14:19:48 2002
--- AiboPup/Shared/get_time.h	Fri Jul 25 16:18:08 2003
***************
*** 8,18 ****
   * @brief prototype for get_time(), a simple way to get the current time since boot in milliseconds
   * @author ejt (Creator)
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 8,18 ----
   * @brief prototype for get_time(), a simple way to get the current time since boot in milliseconds
   * @author ejt (Creator)
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Shared/string_util.cc
diff -c /dev/null AiboPup/Shared/string_util.cc:1.2
*** /dev/null	Fri Oct 10 14:37:45 2003
--- AiboPup/Shared/string_util.cc	Tue Sep  2 16:58:49 2003
***************
*** 0 ****
--- 1,88 ----
+ #include "string_util.h"
+ #include <ctype.h>
+ 
+ namespace string_util {
+ 
+ 	std::string makeLower(const std::string& s) {
+ 		std::string ans(s.size(),'#');
+ 		unsigned int i=s.size();
+ 		while(i--!=0)
+ 			ans[i]=::tolower(s[i]);
+ 		return ans;
+ 	}
+ 
+ 	std::string removePrefix(const std::string& str, const std::string& pre) {
+ 		if(str.compare(0,pre.size(),pre)==0)
+ 			return str.substr(pre.size());
+ 		return std::string();
+ 	}
+ 
+ 	bool parseArgs(const std::string& input, std::vector<std::string>& args, std::vector<unsigned int>& offsets) {
+ 		std::string cur;
+ 		bool isDoubleQuote=false;
+ 		bool isSingleQuote=false;
+ 		args.clear();
+ 		offsets.clear();
+ 		unsigned int begin=-1U;
+ 		for(unsigned int i=0; i<input.size(); i++) {
+ 			char c=input[i];
+ 			if(begin==-1U && !isspace(c))
+ 				begin=i;
+ 			switch(c) {
+ 			case ' ':
+ 			case '\n':
+ 			case '\r':
+ 			case '\t':
+ 			case '\v':
+ 			case '\f':
+ 				if(isSingleQuote || isDoubleQuote)
+ 					cur+=c;
+ 				else if(cur.size()!=0) {
+ 					args.push_back(cur);
+ 					offsets.push_back(begin);
+ 					cur.clear();
+ 					begin=-1U;
+ 				}
+ 				break;
+ 			case '\\':
+ 				if(i==input.size()-1) { //escaped line break
+ 					return false;
+ 				} else
+ 					cur.push_back(input[++i]);
+ 				break;
+ 			case '"':
+ 				if(isSingleQuote)
+ 					cur.push_back(c);
+ 				else
+ 					isDoubleQuote=!isDoubleQuote;
+ 				break;
+ 			case '\'':
+ 				if(isDoubleQuote)
+ 					cur+=c;
+ 				else
+ 					isSingleQuote=!isSingleQuote;
+ 				break;
+ 			default:
+ 				cur+=c;
+ 				break;
+ 			}
+ 		}
+ 		if(cur.size()>0) {
+ 			args.push_back(cur);
+ 			offsets.push_back(begin);
+ 		}
+ 		return !isDoubleQuote && !isSingleQuote;
+ 	}
+ 
+ }
+ 
+ /*! @file
+  * @brief Implements some useful functions for string manipulation in the string_util namespace
+  * @author ejt (Creator)
+  *
+  * $Author: ejt $
+  * $Name: HEAD $
+  * $Revision: 1.2 $
+  * $State: Exp $
+  * $Date: 2003/10/10 20:25:03 $
+  */
Index: AiboPup/Shared/string_util.h
diff -c /dev/null AiboPup/Shared/string_util.h:1.1
*** /dev/null	Fri Oct 10 14:37:45 2003
--- AiboPup/Shared/string_util.h	Wed Aug  6 18:50:49 2003
***************
*** 0 ****
--- 1,30 ----
+ //-*-c++-*-
+ #ifndef INCLUDED_string_util_h
+ #define INCLUDED_string_util_h
+ 
+ #include <string>
+ #include <vector>
+ 
+ namespace string_util {
+ 	//! returns lower case version of @a s
+ 	std::string makeLower(const std::string& s);
+ 
+ 	//! returns @a str with @a pre removed - if @a pre is not fully matched, @a str is returned unchanged
+ 	std::string removePrefix(const std::string& str, const std::string& pre);
+ 	
+ 	//! parses the input string into an arg list, with corresponding offsets of each arg in the original input
+ 	bool parseArgs(const std::string& input, std::vector<std::string>& args, std::vector<unsigned int>& offsets); 
+ };
+ 
+ /*! @file
+  * @brief Describes some useful functions for string manipulation in the string_util namespace
+  * @author ejt (Creator)
+  *
+  * $Author: ejt $
+  * $Name: HEAD $
+  * $Revision: 1.2 $
+  * $State: Exp $
+  * $Date: 2003/10/10 20:25:03 $
+  */
+ 
+ #endif
Index: AiboPup/SoundPlay/Makefile
diff -c AiboPup/SoundPlay/Makefile:1.6 AiboPup/SoundPlay/Makefile:removed
*** AiboPup/SoundPlay/Makefile:1.6	Tue Jun 10 21:18:56 2003
--- AiboPup/SoundPlay/Makefile	Fri Oct 10 14:37:45 2003
***************
*** 1,56 ****
- TEKKOTSU_TARGET_MODEL?=TGT_ERS2xx
- 
- SRCS=$(sort $(shell find . -name "*.cc") ./SoundPlayStub.cc)
- 
- OBJS=${SRCS:.cc=.o}
- DEPENDS=${SRCS:.cc=.d}
- 
- OPENRSDK_ROOT?=/usr/local/OPEN_R_SDK
- CXX=$(OPENRSDK_ROOT)/bin/mipsel-linux-g++
- LD=$(OPENRSDK_ROOT)/bin/mipsel-linux-ld
- STUBGEN=$(OPENRSDK_ROOT)/OPEN_R/bin/stubgen2
- FILTERSYSWARN=../tools/filtersyswarn/filtersyswarn
- CURDIR:=$(shell pwd | sed 's/.*\///')
- CXXFLAGS= \
- 	-O2 \
- 	-g \
- 	-I. -I.. \
- 	-I$(OPENRSDK_ROOT)/OPEN_R/include/R4000 \
- 	-I$(OPENRSDK_ROOT)/OPEN_R/include \
- 	-DPLATFORM_APERIOS -DDEBUG -DOPENR_DEBUG \
- 	-D$(TEKKOTSU_TARGET_MODEL) $(GLOBAL_MAP) 
- 
- .PHONY: all clean
- 
- all: $(CURDIR)Lib.o
- 
- $(CURDIR)Lib.o : $(OBJS)
- 	@echo Linking object files...
- 	@echo "$@ <- $(OBJS)"
- 	@$(LD) -i $(OBJS) -o $@
- 
- %.o: %.cc %.d $(FILTERSYSWARN)
- 	@echo Compiling $< into $@...
- 	@$(CXX) $(CXXFLAGS) -o $@ -c $< > $*.log 2>&1; \
- 	retval=$$?; \
- 	cat $*.log | $(FILTERSYSWARN); \
- 	test $$retval -eq 0;
- 
- SoundPlayStub.cc: stub.cfg
- 	$(STUBGEN) stub.cfg	
- 
- %.d : %.cc
- 	@echo Building $@ for $<
- 	@$(CXX) $(CXXFLAGS) -MP -MG -MT $@ -MT $*.o -MM $< > $@
- 
- $(FILTERSYSWARN):
- 	(cd ../tools && $(MAKE));
- 
- ifneq ($(MAKECMDGOALS),clean)
- -include $(DEPENDS)
- endif
- 
- 
- clean:
- 	rm -f $(CURDIR)Lib.o $(OBJS) $(DEPENDS) ${SRCS:.cc=.log} *~
- 	rm -f *.o SoundPlayStub.* def.h entry.h
--- 0 ----
Index: AiboPup/SoundPlay/SoundManager.cc
diff -c AiboPup/SoundPlay/SoundManager.cc:1.13 AiboPup/SoundPlay/SoundManager.cc:1.14
*** AiboPup/SoundPlay/SoundManager.cc:1.13	Mon Jun  9 20:53:48 2003
--- AiboPup/SoundPlay/SoundManager.cc	Fri Jul 25 16:18:08 2003
***************
*** 193,200 ****
  		
  		if(sndlist[id].rcr!=NULL)
  			erouter->postEvent(EventBase::audioEGID,playid,EventBase::activateETID,0);
- 		return playid;
  	}
  }
  	
  SoundManager::Play_ID
--- 193,200 ----
  		
  		if(sndlist[id].rcr!=NULL)
  			erouter->postEvent(EventBase::audioEGID,playid,EventBase::activateETID,0);
  	}
+ 	return playid;
  }
  	
  SoundManager::Play_ID
***************
*** 370,376 ****
  				char size=srcs.size();
  				//just the first one, set dest
  				for(unsigned int c=0; c<1; c++) {
! 					if(ends[c]-srcs[c]>avail) {
  						for(dest=begin;dest<end;dest++) {
  							*dest=(*(char*)srcs[c])/size;
  							srcs[c]++;
--- 370,376 ----
  				char size=srcs.size();
  				//just the first one, set dest
  				for(unsigned int c=0; c<1; c++) {
! 					if((size_t)(ends[c]-srcs[c])>avail) {
  						for(dest=begin;dest<end;dest++) {
  							*dest=(*(char*)srcs[c])/size;
  							srcs[c]++;
***************
*** 388,394 ****
  				}
  				//the rest, add to dest
  				for(unsigned int c=1; c<srcs.size(); c++) {
! 					if(ends[c]-srcs[c]>avail) {
  						for(dest=begin;dest<end;dest++) {
  							*dest+=(*(char*)srcs[c])/size;
  							srcs[c]++;
--- 388,394 ----
  				}
  				//the rest, add to dest
  				for(unsigned int c=1; c<srcs.size(); c++) {
! 					if((size_t)(ends[c]-srcs[c])>avail) {
  						for(dest=begin;dest<end;dest++) {
  							*dest+=(*(char*)srcs[c])/size;
  							srcs[c]++;
***************
*** 407,413 ****
  				short size=srcs.size();
  				//just the first one, set dest
  				for(unsigned int c=0; c<1; c++) {
! 					if(ends[c]-srcs[c]>avail) {
  						for(dest=begin;dest<end;dest+=2) {
  							*(short*)dest=(*(short*)srcs[c])/size;
  							srcs[c]+=2;
--- 407,413 ----
  				short size=srcs.size();
  				//just the first one, set dest
  				for(unsigned int c=0; c<1; c++) {
! 					if((size_t)(ends[c]-srcs[c])>avail) {
  						for(dest=begin;dest<end;dest+=2) {
  							*(short*)dest=(*(short*)srcs[c])/size;
  							srcs[c]+=2;
***************
*** 425,431 ****
  				}
  				//the rest, add to dest
  				for(unsigned int c=1; c<srcs.size(); c++) {
! 					if(ends[c]-srcs[c]>avail) {
  						for(dest=begin;dest<end;dest+=2) {
  							*(short*)dest+=(*(short*)srcs[c])/size;
  							srcs[c]+=2;
--- 425,431 ----
  				}
  				//the rest, add to dest
  				for(unsigned int c=1; c<srcs.size(); c++) {
! 					if((size_t)(ends[c]-srcs[c])>avail) {
  						for(dest=begin;dest<end;dest+=2) {
  							*(short*)dest+=(*(short*)srcs[c])/size;
  							srcs[c]+=2;
***************
*** 688,697 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  
--- 688,697 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  
Index: AiboPup/SoundPlay/SoundManager.h
diff -c AiboPup/SoundPlay/SoundManager.h:1.8 AiboPup/SoundPlay/SoundManager.h:1.9
*** AiboPup/SoundPlay/SoundManager.h:1.8	Tue Apr  8 23:33:57 2003
--- AiboPup/SoundPlay/SoundManager.h	Thu Sep 25 11:32:08 2003
***************
*** 232,241 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 232,241 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/SoundPlay/SoundManagerMsg.h
diff -c AiboPup/SoundPlay/SoundManagerMsg.h:1.3 AiboPup/SoundPlay/SoundManagerMsg.h:1.4
*** AiboPup/SoundPlay/SoundManagerMsg.h:1.3	Wed Apr  9 00:48:19 2003
--- AiboPup/SoundPlay/SoundManagerMsg.h	Thu Sep 25 11:32:08 2003
***************
*** 59,68 ****
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif // INCLUDED_SoundManagerMsg_h
--- 59,68 ----
   * @author ejt (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif // INCLUDED_SoundManagerMsg_h
Index: AiboPup/SoundPlay/SoundPlay.cc
diff -c AiboPup/SoundPlay/SoundPlay.cc:1.7 AiboPup/SoundPlay/SoundPlay.cc:1.9
*** AiboPup/SoundPlay/SoundPlay.cc:1.7	Thu Jun 12 19:41:41 2003
--- AiboPup/SoundPlay/SoundPlay.cc	Wed Oct  1 19:03:03 2003
***************
*** 11,16 ****
--- 11,17 ----
  
  // Additional modifications for Tekkotsu framework
  
+ #include "SoundPlay/entry.h"
  #include <OPENR/OPENRAPI.h>
  #include <OPENR/OSyslog.h>
  #include <OPENR/core_macro.h>
***************
*** 24,37 ****
  #include "Events/EventRouter.h"
  
  SoundPlay::SoundPlay()
! 	: active(0), eventTranslatorQueueMemRgn(NULL), etrans(), speakerID(oprimitiveID_UNDEF)
  {
! 	for (int i = 0; i < SOUND_NUM_BUFFER; i++)
  		region[i] = 0;
  }
  
  OStatus
! SoundPlay::DoInit(const OSystemEvent& event)
  {
  	//OSYSDEBUG(("SoundPlay::DoInit()\n"));
  
--- 25,38 ----
  #include "Events/EventRouter.h"
  
  SoundPlay::SoundPlay()
! 	: active(0), soundManagerMemRgn(NULL), eventTranslatorQueueMemRgn(NULL), etrans(), speakerID(oprimitiveID_UNDEF)
  {
! 	for (unsigned int i = 0; i < SOUND_NUM_BUFFER; i++)
  		region[i] = 0;
  }
  
  OStatus
! SoundPlay::DoInit(const OSystemEvent&)
  {
  	//OSYSDEBUG(("SoundPlay::DoInit()\n"));
  
***************
*** 65,71 ****
  }
  
  OStatus
! SoundPlay::DoStart(const OSystemEvent& event)
  {
  	//OSYSDEBUG(("SoundPlay::DoStart()\n"));
  
--- 66,72 ----
  }
  
  OStatus
! SoundPlay::DoStart(const OSystemEvent&)
  {
  	//OSYSDEBUG(("SoundPlay::DoStart()\n"));
  
***************
*** 76,85 ****
  }
  
  OStatus
! SoundPlay::DoStop(const OSystemEvent& event)
  {
  	//OSYSDEBUG(("SoundPlay::DoStop()\n"));
  
  	DISABLE_ALL_SUBJECT;
  	DEASSERT_READY_TO_ALL_OBSERVER;
  
--- 77,88 ----
  }
  
  OStatus
! SoundPlay::DoStop(const OSystemEvent&)
  {
  	//OSYSDEBUG(("SoundPlay::DoStop()\n"));
  
+ 	sndman->StopPlay();
+ 
  	DISABLE_ALL_SUBJECT;
  	DEASSERT_READY_TO_ALL_OBSERVER;
  
***************
*** 87,93 ****
  }
  
  OStatus
! SoundPlay::DoDestroy(const OSystemEvent& event)
  {
  	for(unsigned int i=0; i<config->sound.preload.size(); i++)
  		sndman->ReleaseFile(config->sound.preload[i].c_str());
--- 90,96 ----
  }
  
  OStatus
! SoundPlay::DoDestroy(const OSystemEvent&)
  {
  	for(unsigned int i=0; i<config->sound.preload.size(); i++)
  		sndman->ReleaseFile(config->sound.preload[i].c_str());
***************
*** 188,194 ****
  	 */
  	size_t soundUnitSize = config->sound.sample_rate*config->sound.sample_bits/8*SoundBufferTime/1000;
  
! 	for (int i = 0; i < SOUND_NUM_BUFFER; i++) {
  		result = OPENR::NewSoundVectorData(1, soundUnitSize,&soundVecDataID, &soundVecData);
  		if (result != oSUCCESS) {
  			OSYSLOG1((osyslogERROR, "%s : %s %d","SoundPlay::NewSoundVectorData()","OPENR::NewSoundVectorData() FAILED", result));
--- 191,197 ----
  	 */
  	size_t soundUnitSize = config->sound.sample_rate*config->sound.sample_bits/8*SoundBufferTime/1000;
  
! 	for (unsigned int i = 0; i < SOUND_NUM_BUFFER; i++) {
  		result = OPENR::NewSoundVectorData(1, soundUnitSize,&soundVecDataID, &soundVecData);
  		if (result != oSUCCESS) {
  			OSYSLOG1((osyslogERROR, "%s : %s %d","SoundPlay::NewSoundVectorData()","OPENR::NewSoundVectorData() FAILED", result));
***************
*** 243,249 ****
  RCRegion*
  SoundPlay::FindFreeRegion()
  {
! 	for (int i = 0; i < SOUND_NUM_BUFFER; i++)
  		if (region[i]->NumberOfReference() == 1)
  			return region[i];
  	return 0;
--- 246,252 ----
  RCRegion*
  SoundPlay::FindFreeRegion()
  {
! 	for (unsigned int i = 0; i < SOUND_NUM_BUFFER; i++)
  		if (region[i]->NumberOfReference() == 1)
  			return region[i];
  	return 0;
***************
*** 266,274 ****
   * implied warranties of fitness for a particular purpose.
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 269,277 ----
   * implied warranties of fitness for a particular purpose.
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/SoundPlay/SoundPlay.h
diff -c AiboPup/SoundPlay/SoundPlay.h:1.3 AiboPup/SoundPlay/SoundPlay.h:1.4
*** AiboPup/SoundPlay/SoundPlay.h:1.3	Tue Apr  8 23:33:57 2003
--- AiboPup/SoundPlay/SoundPlay.h	Fri Jul 25 16:18:08 2003
***************
*** 63,68 ****
--- 63,71 ----
  
  	OPrimitiveID   speakerID;  //!< ID returned to system after opening SPEAKER_LOCATOR
  	RCRegion*      region[SOUND_NUM_BUFFER]; //!< holds references to shared regions holding sound clips
+ 
+ 	SoundPlay(const SoundPlay&); //!< don't call
+ 	SoundPlay& operator=(const SoundPlay&); //!< don't call
  };
  
  /*! @file
***************
*** 82,91 ****
   * implied warranties of fitness for a particular purpose.
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif // SoundPlay_h_DEFINED
--- 85,94 ----
   * implied warranties of fitness for a particular purpose.
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif // SoundPlay_h_DEFINED
Index: AiboPup/SoundPlay/WAV.cc
diff -c AiboPup/SoundPlay/WAV.cc:1.3 AiboPup/SoundPlay/WAV.cc:1.4
*** AiboPup/SoundPlay/WAV.cc:1.3	Thu Jun 12 19:41:41 2003
--- AiboPup/SoundPlay/WAV.cc	Fri Jul 25 16:18:08 2003
***************
*** 15,24 ****
   * implied warranties of fitness for a particular purpose.
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #include <OPENR/OPENR.h>
--- 15,24 ----
   * implied warranties of fitness for a particular purpose.
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #include <OPENR/OPENR.h>
***************
*** 187,193 ****
      byte* end;
      int num = (int)(dataEnd - dataCurrent);
  
!     if (soundUnitSize <= num) {
      
          end = dest + soundUnitSize;
          if (soundUnitSize == MONO8K8B_UNIT_SIZE) {
--- 187,193 ----
      byte* end;
      int num = (int)(dataEnd - dataCurrent);
  
!     if (soundUnitSize <= (unsigned int)num) {
      
          end = dest + soundUnitSize;
          if (soundUnitSize == MONO8K8B_UNIT_SIZE) {
Index: AiboPup/SoundPlay/WAV.h
diff -c AiboPup/SoundPlay/WAV.h:1.2 AiboPup/SoundPlay/WAV.h:1.3
*** AiboPup/SoundPlay/WAV.h:1.2	Thu Jun 12 19:41:41 2003
--- AiboPup/SoundPlay/WAV.h	Fri Jul 25 16:18:08 2003
***************
*** 15,24 ****
   * implied warranties of fitness for a particular purpose.
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #ifndef WAV_h_DEFINED
--- 15,24 ----
   * implied warranties of fitness for a particular purpose.
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #ifndef WAV_h_DEFINED
***************
*** 72,77 ****
--- 72,80 ----
      byte*      dataStart;
      byte*      dataEnd;
      byte*      dataCurrent;
+ 
+ 		WAV(const WAV&); //!< don't call
+ 		WAV& operator=(const WAV&); //!< don't call
  };
  
  #endif // WAV_h_DEFINED
Index: AiboPup/TinyFTPD/FtpDTP.cc
diff -c AiboPup/TinyFTPD/FtpDTP.cc:1.1.1.1 AiboPup/TinyFTPD/FtpDTP.cc:1.2
*** AiboPup/TinyFTPD/FtpDTP.cc:1.1.1.1	Mon Sep 30 14:19:49 2002
--- AiboPup/TinyFTPD/FtpDTP.cc	Fri Jul 25 16:18:08 2003
***************
*** 129,135 ****
  
      connection.state = CONNECTION_CONNECTED;
  
!     switch (method) {
      case FTP_METHOD_RETR:
          RetrieveSend();
          break;
--- 129,136 ----
  
      connection.state = CONNECTION_CONNECTED;
  
! 		//CHANGE_ET - cast to int to avoid warning
!     switch ((int)method) {
      case FTP_METHOD_RETR:
          RetrieveSend();
          break;
***************
*** 282,288 ****
  }
  
  void
! FtpDTP::CloseCont(TCPEndpointCloseMsg* closeMsg)
  {
      OSYSDEBUG(("FtpDTP::CloseCont()\n"));
      
--- 283,289 ----
  }
  
  void
! FtpDTP::CloseCont(TCPEndpointCloseMsg* /*closeMsg*/)
  {
      OSYSDEBUG(("FtpDTP::CloseCont()\n"));
      
Index: AiboPup/TinyFTPD/FtpDTP.h
diff -c AiboPup/TinyFTPD/FtpDTP.h:1.1.1.1 AiboPup/TinyFTPD/FtpDTP.h:1.2
*** AiboPup/TinyFTPD/FtpDTP.h:1.1.1.1	Mon Sep 30 14:19:49 2002
--- AiboPup/TinyFTPD/FtpDTP.h	Fri Jul 25 16:18:08 2003
***************
*** 88,92 ****
--- 88,95 ----
      
      void* continuation;
      TCPConnection connection;
+ 
+ 		FtpDTP(const FtpDTP&); //!< don't call
+ 		FtpDTP& operator=(const FtpDTP&); //!< don't call
  };
  #endif /* _FtpDTP_h_DEFINED */
Index: AiboPup/TinyFTPD/FtpMethod.cc
diff -c AiboPup/TinyFTPD/FtpMethod.cc:1.1.1.1 AiboPup/TinyFTPD/FtpMethod.cc:1.2
*** AiboPup/TinyFTPD/FtpMethod.cc:1.1.1.1	Mon Sep 30 14:19:49 2002
--- AiboPup/TinyFTPD/FtpMethod.cc	Fri Jul 25 16:18:08 2003
***************
*** 189,198 ****
      DirNorm(tmp);
  
      if (!strncmp(tmp, ftpHome, strlen(ftpHome))) {
!         FILE *fp = fopen(tmp, "r");
!         if (fp != NULL) {
              strncpy(ftpFile, tmp, MAX_STRING_LENGTH);
!             fclose(fp);
              return true;
          }
      }
--- 189,199 ----
      DirNorm(tmp);
  
      if (!strncmp(tmp, ftpHome, strlen(ftpHome))) {
!         //CHANGE_ET renamed fp to tfp to avoid shadow
!         FILE *tfp = fopen(tmp, "r");
!         if (tfp != NULL) {
              strncpy(ftpFile, tmp, MAX_STRING_LENGTH);
!             fclose(tfp);
              return true;
          }
      }
***************
*** 245,251 ****
      DirNorm(tmp);
  
      if (!strncmp(tmp, ftpHome, strlen(ftpHome))) {
!         if (dirp = opendir(tmp)) {
              method = FTP_METHOD_LIST;
              strcpy(ftpFile, tmp);
              Connect();
--- 246,252 ----
      DirNorm(tmp);
  
      if (!strncmp(tmp, ftpHome, strlen(ftpHome))) {
!         if ((dirp = opendir(tmp))) {
              method = FTP_METHOD_LIST;
              strcpy(ftpFile, tmp);
              Connect();
***************
*** 267,276 ****
          sprintf(tmp, "%s/%s", ftpFile, entry->d_name);
          DirNorm(tmp);
          
!         int ret = stat(tmp, &statbuf);
          if (listLong) {
              sprintf((char *)connection.sendData,
!                     "%c%c%c%c%c%c%c%c%c%c %x %s %s %-d %s %d %d %s\r\n",
                      (statbuf.st_mode & S_IFMT) == S_IFDIR ? 'd' : '-',
                      (statbuf.st_mode & S_IRUSR) ? 'r' : '-',
                      (statbuf.st_mode & S_IWUSR) ? 'w' : '-',
--- 268,277 ----
          sprintf(tmp, "%s/%s", ftpFile, entry->d_name);
          DirNorm(tmp);
          
!         stat(tmp, &statbuf);
          if (listLong) {
              sprintf((char *)connection.sendData,
!                     "%c%c%c%c%c%c%c%c%c%c %x %s %s %-u %s %d %d %s\r\n",
                      (statbuf.st_mode & S_IFMT) == S_IFDIR ? 'd' : '-',
                      (statbuf.st_mode & S_IRUSR) ? 'r' : '-',
                      (statbuf.st_mode & S_IWUSR) ? 'w' : '-',
***************
*** 284,290 ****
                      0,
                      "AIBO",
                      "AIBO",
!                     statbuf.st_size,
                      "May",
                      11,
                      1999,
--- 285,291 ----
                      0,
                      "AIBO",
                      "AIBO",
!                     (unsigned int)statbuf.st_size,
                      "May",
                      11,
                      1999,
***************
*** 327,333 ****
  
      if (!strncmp(tmp, ftpHome, strlen(ftpHome))) {
          DIR* tmpdirp;
!         if (tmpdirp = opendir(tmp)) {
              closedir(tmpdirp);
              strcpy(ftpDir, tmp);
              return true;
--- 328,334 ----
  
      if (!strncmp(tmp, ftpHome, strlen(ftpHome))) {
          DIR* tmpdirp;
!         if ((tmpdirp = opendir(tmp))) {
              closedir(tmpdirp);
              strcpy(ftpDir, tmp);
              return true;
Index: AiboPup/TinyFTPD/FtpPI.cc
diff -c AiboPup/TinyFTPD/FtpPI.cc:1.1.1.1 AiboPup/TinyFTPD/FtpPI.cc:1.2
*** AiboPup/TinyFTPD/FtpPI.cc:1.1.1.1	Mon Sep 30 14:19:49 2002
--- AiboPup/TinyFTPD/FtpPI.cc	Fri Jul 25 16:18:09 2003
***************
*** 248,254 ****
  }
  
  void
! FtpPI::CloseCont(TCPEndpointCloseMsg* closeMsg)
  {
      OSYSDEBUG(("FtpPI::CloseCont()\n"));
      
--- 248,254 ----
  }
  
  void
! FtpPI::CloseCont(TCPEndpointCloseMsg* /*closeMsg*/)
  {
      OSYSDEBUG(("FtpPI::CloseCont()\n"));
      
Index: AiboPup/TinyFTPD/FtpPI.h
diff -c AiboPup/TinyFTPD/FtpPI.h:1.1.1.1 AiboPup/TinyFTPD/FtpPI.h:1.2
*** AiboPup/TinyFTPD/FtpPI.h:1.1.1.1	Mon Sep 30 14:19:49 2002
--- AiboPup/TinyFTPD/FtpPI.h	Fri Jul 25 16:18:09 2003
***************
*** 56,61 ****
--- 56,64 ----
      FtpDTP ftpDTP;
  
      OList<Passwd, MAX_LOGIN> *passwd;
+ 
+ 		FtpPI(const FtpPI&); //!< don't call
+ 		FtpPI& operator=(const FtpPI&); //!< don't call
  };
  #endif /* _FtpPI_h_DEFINED */
  
Index: AiboPup/TinyFTPD/Makefile
diff -c AiboPup/TinyFTPD/Makefile:1.3 AiboPup/TinyFTPD/Makefile:removed
*** AiboPup/TinyFTPD/Makefile:1.3	Mon Jul  7 14:08:12 2003
--- AiboPup/TinyFTPD/Makefile	Fri Oct 10 14:37:47 2003
***************
*** 1,62 ****
- #
- # Copyright 2002 Sony Corporation 
- #
- # Permission to use, copy, modify, and redistribute this software for
- # non-commercial use is hereby granted.
- #
- # This software is provided "as is" without warranty of any kind,
- # either expressed or implied, including but not limited to the
- # implied warranties of fitness for a particular purpose.
- #
- 
- OPENRSDK_ROOT?=/usr/local/OPEN_R_SDK
- INSTALLDIR=../ms
- CXX=$(OPENRSDK_ROOT)/bin/mipsel-linux-g++
- LD=$(OPENRSDK_ROOT)/bin/mipsel-linux-ld
- STRIP=$(OPENRSDK_ROOT)/bin/mipsel-linux-strip
- MKBIN=$(OPENRSDK_ROOT)/OPEN_R/bin/mkbin
- STUBGEN=$(OPENRSDK_ROOT)/OPEN_R/bin/stubgen2
- MKBINFLAGS=-p $(OPENRSDK_ROOT)
- LIBS=-L$(OPENRSDK_ROOT)/OPEN_R/lib -lObjectComm -lOPENR -lInternet -lantMCOOP
- CXXFLAGS= \
- 	-O2 \
- 	-g \
- 	-I. \
- 	-I$(OPENRSDK_ROOT)/OPEN_R/include/R4000 \
- 	-I$(OPENRSDK_ROOT)/OPEN_R/include/MCOOP \
- 	-I$(OPENRSDK_ROOT)/OPEN_R/include
- 
- #
- # When OPENR_DEBUG is defined, OSYSDEBUG() is available.
- #
- #CXXFLAGS+= -DOPENR_DEBUG
- 
- .PHONY: all install clean
- 
- all: TinyFTPDLib.o
- 
- %.o: %.cc
- 	$(CXX) $(CXXFLAGS) -o $@ -c $^
- 
- TinyFTPDStub.cc: stub.cfg
- 	$(STUBGEN) stub.cfg	
- 
- TinyFTPDLib.o: TinyFTPDStub.o TinyFTPD.o FtpPI.o FtpRequest.o FtpDTP.o FtpMethod.o
- 	@echo Linking object files...
- 	@echo "$@ <- $^"
- 	$(LD) -i $^ -o $@
- 
- TinyFTPD.bin: TinyFTPDStub.o TinyFTPD.o FtpPI.o FtpRequest.o FtpDTP.o FtpMethod.o TinyFTPD.ocf
- 	$(MKBIN) $(MKBINFLAGS) -o $@ $^ $(LIBS)
- 	$(STRIP) $@
- 
- $(INSTALLDIR)/open-r/mw/objs/tinyftpd.bin: TinyFTPD.bin
- 	gzip -c $< > $@
- 
- install: $(INSTALLDIR)/open-r/mw/objs/tinyftpd.bin
- 
- clean:
- 	rm -f *.o *.bin *.elf *.snap.cc
- 	rm -f TinyFTPDStub.h TinyFTPDStub.cc def.h entry.h
- 	rm -f $(INSTALLDIR)/open-r/mw/objs/tinyftpd.bin
- 
--- 0 ----
Index: AiboPup/TinyFTPD/TinyFTPD.cc
diff -c AiboPup/TinyFTPD/TinyFTPD.cc:1.2 AiboPup/TinyFTPD/TinyFTPD.cc:1.3
*** AiboPup/TinyFTPD/TinyFTPD.cc:1.2	Mon Oct 28 13:51:25 2002
--- AiboPup/TinyFTPD/TinyFTPD.cc	Fri Jul 25 16:18:09 2003
***************
*** 9,34 ****
  // implied warranties of fitness for a particular purpose.
  //
  
  #include <sys/stat.h>
  #include <OPENR/OSyslog.h>
  #include <EndpointTypes.h>
  #include <TCPEndpointMsg.h>
  #include "TinyFTPD.h"
- #include "entry.h"
  
  TinyFTPD::TinyFTPD() : passwd()
  {
  }
  
  OStatus
! TinyFTPD::DoInit(const OSystemEvent& event)
  {
      OSYSDEBUG(("TinyFTPD::DoInit()\n"));
      return oSUCCESS;
  }
  
  OStatus
! TinyFTPD::DoStart(const OSystemEvent& event)
  {
      OSYSDEBUG(("TinyFTPD::DoStart()\n"));
  
--- 9,34 ----
  // implied warranties of fitness for a particular purpose.
  //
  
+ #include "TinyFTPD/entry.h"
  #include <sys/stat.h>
  #include <OPENR/OSyslog.h>
  #include <EndpointTypes.h>
  #include <TCPEndpointMsg.h>
  #include "TinyFTPD.h"
  
  TinyFTPD::TinyFTPD() : passwd()
  {
  }
  
  OStatus
! TinyFTPD::DoInit(const OSystemEvent&)
  {
      OSYSDEBUG(("TinyFTPD::DoInit()\n"));
      return oSUCCESS;
  }
  
  OStatus
! TinyFTPD::DoStart(const OSystemEvent&)
  {
      OSYSDEBUG(("TinyFTPD::DoStart()\n"));
  
***************
*** 64,70 ****
  }
  
  OStatus
! TinyFTPD::DoStop(const OSystemEvent& event)
  {
      OSYSDEBUG(("TinyFTPD::DoStop()\n"));
      for(int index = 0; index < FTP_CONNECTION_MAX; index++) {
--- 64,70 ----
  }
  
  OStatus
! TinyFTPD::DoStop(const OSystemEvent&)
  {
      OSYSDEBUG(("TinyFTPD::DoStop()\n"));
      for(int index = 0; index < FTP_CONNECTION_MAX; index++) {
***************
*** 74,80 ****
  }
  
  OStatus
! TinyFTPD::DoDestroy(const OSystemEvent& event)
  {
      OSYSDEBUG(("TinyFTPD::DoDestroy()\n"));
      return oSUCCESS;
--- 74,80 ----
  }
  
  OStatus
! TinyFTPD::DoDestroy(const OSystemEvent&)
  {
      OSYSDEBUG(("TinyFTPD::DoDestroy()\n"));
      return oSUCCESS;
***************
*** 203,209 ****
  OStatus
  TinyFTPD::Load(char* path, byte** data, size_t* size)
  {
-     sError error;
      struct stat statbuf;
      FILE* fp;
      byte* readBuf = 0;
--- 203,208 ----
Index: AiboPup/TinyFTPD/TinyFTPD.h
diff -c AiboPup/TinyFTPD/TinyFTPD.h:1.1.1.1 AiboPup/TinyFTPD/TinyFTPD.h:1.2
*** AiboPup/TinyFTPD/TinyFTPD.h:1.1.1.1	Mon Sep 30 14:19:49 2002
--- AiboPup/TinyFTPD/TinyFTPD.h	Fri Jul 25 16:18:09 2003
***************
*** 53,58 ****
--- 53,60 ----
  
      OList<Passwd, MAX_LOGIN> passwd;
  
+ 		TinyFTPD(const TinyFTPD&); //!< don't call
+ 		TinyFTPD& operator=(const TinyFTPD&); //!< don't call
  };
  #endif /* _TinyFTPD_h_DEFINED */
  
Index: AiboPup/Vision/Makefile
diff -c AiboPup/Vision/Makefile:1.8 AiboPup/Vision/Makefile:removed
*** AiboPup/Vision/Makefile:1.8	Tue Jun 10 21:18:56 2003
--- AiboPup/Vision/Makefile	Fri Oct 10 14:37:47 2003
***************
*** 1,52 ****
- TEKKOTSU_TARGET_MODEL?=TGT_ERS2xx
- 
- SRCS:=$(shell find . -name "*.cc")
- 
- OBJS:=${SRCS:.cc=.o}
- DEPENDS:=${SRCS:.cc=.d}
- 
- OPENRSDK_ROOT?=/usr/local/OPEN_R_SDK
- CXX=$(OPENRSDK_ROOT)/bin/mipsel-linux-g++
- LD=$(OPENRSDK_ROOT)/bin/mipsel-linux-ld
- FILTERSYSWARN=../tools/filtersyswarn/filtersyswarn
- LIBS=-lObjectComm -lOPENR -lInternet -lantMCOOP
- CURDIR:=$(shell pwd | sed 's/.*\///')
- CXXFLAGS= \
- 	-g -O3 \
- 	-Wall -W -Wshadow -Wlarger-than-8192 -Wpointer-arith -Wcast-qual \
- 	-Woverloaded-virtual -Weffc++ -Winline -Wdeprecated \
- 	-I. -I.. -I../MMCombo -isystem $(OPENRSDK_ROOT)/OPEN_R/include/MCOOP \
- 	-isystem $(OPENRSDK_ROOT)/OPEN_R/include/R4000 -isystem $(OPENRSDK_ROOT)/OPEN_R/include \
- 	-DPLATFORM_APERIOS -DDEBUG -DOPENR_DEBUG \
- 	-D$(TEKKOTSU_TARGET_MODEL) $(GLOBAL_MAP) \
- 
- .PHONY: all clean
- 
- all: $(CURDIR)Lib.o
- 
- $(CURDIR)Lib.o : $(OBJS)
- 	@echo Linking object files...
- 	@echo "$@ <- $(OBJS)"
- 	@$(LD) -i $(OBJS) -o $@
- 
- %.o: %.cc %.d $(FILTERSYSWARN)
- 	@echo Compiling $< into $@...
- 	@$(CXX) $(CXXFLAGS) -o $@ -c $< > $*.log 2>&1; \
- 	retval=$$?; \
- 	cat $*.log | $(FILTERSYSWARN); \
- 	test $$retval -eq 0;
- 
- %.d : %.cc
- 	@echo Building $@ for $<
- 	@$(CXX) $(CXXFLAGS) -MP -MG -MT $@ -MT $*.o -MM $< > $@
- 
- $(FILTERSYSWARN):
- 	(cd ../tools && $(MAKE));
- 
- ifneq ($(MAKECMDGOALS),clean)
- -include $(DEPENDS)
- endif
- 
- 
- clean:
- 	rm -f $(CURDIR)Lib.o $(OBJS) $(DEPENDS) ${SRCS:.cc=.log} *~ 
--- 0 ----
Index: AiboPup/Vision/Vision.cc
diff -c AiboPup/Vision/Vision.cc:1.11 AiboPup/Vision/Vision.cc:1.15
*** AiboPup/Vision/Vision.cc:1.11	Thu Jun 12 19:41:41 2003
--- AiboPup/Vision/Vision.cc	Fri Oct 10 01:38:25 2003
***************
*** 20,33 ****
  using namespace mathutils;
  using namespace VisionEventNS;
  
! Vision::Vision()
  {
    initialize();
-   setCameraParam();
    vser=new VisionSerializer();
  }
  
! void Vision::setCameraParam()
  {
    static OPrimitiveID fbkID = 0;
        
--- 20,37 ----
  using namespace mathutils;
  using namespace VisionEventNS;
  
! Vision::Vision() : frameTimestamp(0UL), frame_count(0), cmap(NULL), tmap(NULL),
!                    rmap(NULL), rmap2(NULL), reg(NULL), width(0), height(0),
!                    max_width(0), max_height(0), max_runs(0), max_regions(0),
!                    num_colors(0), num_runs(0), num_regions(0), body_angle(0.0),
!                    body_height(100.0), vis_markers(0), obj_info(NULL),
!                    imageLayer(ofbkimageLAYER_H), vser(NULL)
  {
    initialize();
    vser=new VisionSerializer();
  }
  
! void Vision::setCameraParams()
  {
    static OPrimitiveID fbkID = 0;
        
***************
*** 60,195 ****
    }
  }
  
! void Vision::initialize()
  {
-   int num_y,num_u,num_v;
-   int size;
-   num_tmaps=1;
-   int result;
- 
-   obj_info=new ObjectInfo;
- 
    switch(config->vision.resolution) {
!     case 1:
!       width=344;
!       height=288;
        break;
      case 3:
!       width=86;
!       height=72;
        break;
      default:
!       width=172;
        height=144;
        break;
    }
  
    max_width  = width;
    max_height = height;
  
!   // Load color information
!   num_colors =
!   CMVision::LoadColorInformation(color,MAX_COLORS,config->vision.colors);
!   if(num_colors > 0){
!     printf("  Loaded %d colors.\n",num_colors);
!   }else{
!     printf("  ERROR: Could not load color information.\n");
!   }
! 
!   // Set up threshold
!   size = 1 << (bits_y + bits_u + bits_v);
!   num_y = 1 << bits_y;
!   num_u = 1 << bits_u;
!   num_v = 1 << bits_v;
! 
!   cur_tmap = 0;
!   memset(tmap,0,sizeof(tmap));
!   for(int i=0; i<num_tmaps; i++) {
! #ifdef PLATFORM_APERIOS
!   result = NewRegion(size, reinterpret_cast<void**>(&tmap[i]));
!   if (result != sSUCCESS)
!     printf("Unable to allocate tmap buffer %d of size %d\n",i,size);
! #else
!   tmap[i] = new cmap_t[size];
! #endif
!   memset(tmap[i],0,size*sizeof(cmap_t));
!   }
! 
!   for(int i=0; i<num_tmaps; i++) {
!     char tmapfile[256];
!     if(i==0)
!       sprintf(tmapfile,"%s",config->vision.thresh);
!     else
!       sprintf(tmapfile,"%s%d",config->vision.thresh,i);
!     if(!CMVision::LoadThresholdFile(tmap[i],num_y,num_u,num_v,tmapfile)) {
!       printf("  ERROR: Could not load threshold file '%s'.\n",tmapfile);
!     }
!     int remapped=CMVision::CheckTMapColors(tmap[i],num_y,num_u,num_v,num_colors,0);
!     printf("remapped %d colors in threshold file '%s'\n",remapped,tmapfile);
!   }
! 
!   // Allocate map structures
!   max_width  = width;
!   max_height = height;
!   size = width * height;
    max_runs = size / MIN_EXP_RUN_LENGTH;
    max_regions = size / MIN_EXP_REGION_SIZE;
    size = max_width * max_height;
    NewLarge(&cmap,size+1); // +1 to store EncodeRuns terminator value
    if(!cmap) {
      cout << "Couldn't allocate cmap\n\xFF" << endl;
      *((long *)0xDEADCC44)=1;
    }
    NewLarge(&rmap,max_runs);
    if(!rmap) {
      cout << "Couldn't allocate rmap\n\xFF" << endl;
      *((long *)0xDEAD7744)=1;
    }
    NewLarge(&rmap2,max_runs);
    if(!rmap2) {
      cout << "Couldn't allocate rmap2\n\xFF" << endl;
      *((long *)0xDEAD7745)=1;
    }
    NewLarge(&reg,max_regions);
    if(!reg) {
      cout << "Couldn't allocate reg\n" << endl;
      *((long *)0xDEAD7E66)=1;
    }
  
-   body_angle=0.0;
-   body_height=100.0;
-   head_angles[0]=head_angles[1]=head_angles[2]=0.0;
- /*
-   // initialize output stuff
-   encodeBuf = NULL;
-   encoder = NULL;
-   // Always init
-   //if(config.spoutConfig.dumpVisionRLE!=0) {
-   //if(config.spoutConfig.dumpVisionRLE) {
-   // body position (5 floats) + image size*3 chars(value, x, length) + stop chars
-   // body position (5 floats) + image size*3 chars(y, u, v) + stop chars
  #ifdef PLATFORM_APERIOS
!   NewRegion(5*4+176*144*3+2,(void **)&encodeBuf);
!   if(encodeBuf==NULL)
!     printf("Null vision rle encode buf\n");
!   else
!     encoder=new SPOutVisionEncoder;
!   //}
  #endif
  
!   visionColorAreaStream = NULL;
!   visionRawStream       = NULL;
!   visionRLEStream       = NULL;
!   visionObjStream       = NULL;
! 
!   outCountRaw = 0;
!   outCountRLE = 0;
! 
!   //printf("Done initializing vision.\n");
! */
!   frameTimestamp = 0UL;
!   frame_count=0;
    initializeEventSpecs();
  }
  
  void Vision::initializeEventSpecs() {
--- 64,184 ----
    }
  }
  
! void Vision::setResolution()
  {
    switch(config->vision.resolution) {
!     case 2:
!       width=88;
!       height=72;
!       imageLayer=ofbkimageLAYER_M;
        break;
      case 3:
!       width=44;
!       height=36;
!       imageLayer=ofbkimageLAYER_L;
        break;
      default:
!       width=176;
        height=144;
+       imageLayer=ofbkimageLAYER_H;
        break;
    }
  
    max_width  = width;
    max_height = height;
  
!   int size = width * height;
    max_runs = size / MIN_EXP_RUN_LENGTH;
    max_regions = size / MIN_EXP_REGION_SIZE;
    size = max_width * max_height;
+ 
+   if (cmap!=NULL) { DeleteLarge(cmap); cmap=NULL; }
    NewLarge(&cmap,size+1); // +1 to store EncodeRuns terminator value
    if(!cmap) {
      cout << "Couldn't allocate cmap\n\xFF" << endl;
      *((long *)0xDEADCC44)=1;
    }
+   if (rmap!=NULL) { DeleteLarge(rmap); rmap=NULL; }
    NewLarge(&rmap,max_runs);
    if(!rmap) {
      cout << "Couldn't allocate rmap\n\xFF" << endl;
      *((long *)0xDEAD7744)=1;
    }
+   if (rmap2!=NULL) { DeleteLarge(rmap2); rmap2=NULL; }
    NewLarge(&rmap2,max_runs);
    if(!rmap2) {
      cout << "Couldn't allocate rmap2\n\xFF" << endl;
      *((long *)0xDEAD7745)=1;
    }
+   if (reg!=NULL) { DeleteLarge(reg); reg=NULL; }
    NewLarge(&reg,max_regions);
    if(!reg) {
      cout << "Couldn't allocate reg\n" << endl;
      *((long *)0xDEAD7E66)=1;
    }
+ }
+ 
+ void Vision::setColors()
+ {
+   color_names.clear();
+   num_colors =
+     CMVision::LoadColorInformation(color,MAX_COLORS,config->vision.colors,
+                                    color_names);
+   if(num_colors > 0){
+     printf("  Loaded %d colors.\n",num_colors);
+   }else{
+     printf("  ERROR: Could not load colors file:%s\n", config->vision.colors);
+   }
+ 
+   int num_y,num_u,num_v;
+   int size = 1 << (bits_y + bits_u + bits_v);
+   num_y = 1 << bits_y;
+   num_u = 1 << bits_u;
+   num_v = 1 << bits_v;
+ 
+   memset(tmap,0,size*sizeof(cmap_t));
+ 
+   if(!CMVision::LoadThresholdFile(tmap,num_y,num_u,num_v,
+                                   config->vision.thresh)) {
+     printf("  ERROR: Could not load threshold file '%s'.\n",
+            config->vision.thresh);
+   }
+   int remapped=CMVision::CheckTMapColors(tmap,num_y,num_u,num_v,num_colors,0);
+   printf("remapped %d colors in threshold file '%s'\n",
+          remapped, config->vision.thresh);
+ }
+ 
+ int Vision::getColor(const char* color) {
+   hash_map<const char*, int, hash<const char*>, hashcmp_eqstr>::iterator i;
+   i=color_names.find(color);
+   if (i==color_names.end()) return -1;
+   return i->second;
+ }
+ 
+ void Vision::initialize()
+ {
+   int result;
+   int size = 1 << (bits_y + bits_u + bits_v);
+ 
+   obj_info=new ObjectInfo;
+ 
+   setResolution();
+ 
+   // Set up threshold
  
  #ifdef PLATFORM_APERIOS
!   result = NewRegion(size, reinterpret_cast<void**>(&tmap));
!   if (result != sSUCCESS)
!     printf("Unable to allocate tmap buffer of size %d\n",size);
! #else
!   tmap = new cmap_t[size];
  #endif
  
!   setColors();
! 
! 
    initializeEventSpecs();
+   setCameraParams();
  }
  
  void Vision::initializeEventSpecs() {
***************
*** 266,292 ****
  
  bool Vision::close()
  {
!   for(int i=0; i<num_tmaps; i++) {
!     delete[] tmap[i];
!   }
!   delete(cmap);
!   delete(rmap);
!   delete(reg);
  
!   memset(tmap,0,sizeof(tmap));
    cmap = NULL;
    rmap = NULL;
    reg  = NULL;
  
    max_width  = 0;
    max_height = 0;
- /*
- #ifdef PLATFORM_APERIOS
-   DeleteRegion(encodeBuf); // don't care about error
- #else
-   delete[] encodeBuf;
- #endif
-   delete encoder;*/
  
    return(true);
  }
--- 255,274 ----
  
  bool Vision::close()
  {
!   DeleteLarge(tmap);
!   DeleteLarge(cmap);
!   DeleteLarge(rmap);
!   DeleteLarge(rmap2);
!   DeleteLarge(reg);
  
!   tmap = NULL;
    cmap = NULL;
    rmap = NULL;
+   rmap2 = NULL;
    reg  = NULL;
  
    max_width  = 0;
    max_height = 0;
  
    return(true);
  }
***************
*** 349,355 ****
    int n;
    double conf;
  
!   skin=&color[COLOR_SKIN];
  
    region *or_reg; // hand region(s)
  
--- 331,337 ----
    int n;
    double conf;
  
!   skin=&color[getColor("skin")];
  
    region *or_reg; // hand region(s)
  
***************
*** 378,385 ****
  }
  
  bool Vision::findBall(int ball_color, VObject *ball,VisionObjectInfo *ball_info) {
!   if ((ball_color==COLOR_RED && vevent_spec[RedBallSID].listeners==0)
!       ||(ball_color==COLOR_PINK && vevent_spec[PinkBallSID].listeners==0)) return false;
  
    static const bool debug_ball = false;
    static const bool debug_conf = false;
--- 360,367 ----
  }
  
  bool Vision::findBall(int ball_color, VObject *ball,VisionObjectInfo *ball_info) {
!   if ((ball_color==getColor("red") && vevent_spec[RedBallSID].listeners==0)
!       ||(ball_color==getColor("pink") && vevent_spec[PinkBallSID].listeners==0)) return false;
  
    static const bool debug_ball = false;
    static const bool debug_conf = false;
***************
*** 445,465 ****
                conf0,conf_square_bbox,conf_area,conf_area_bonus,conf);
      }
      
! 
      if(conf > ball->confidence) {
        if(debug_ball &&
         (frame_cnt == 0 ||
          frame_cnt == 1)) {
! /*        printf("%s ball n%d cen (%f,%f) area %d bbox (%d,%d)-(%d,%d) conf %f\n", (ball_color==COLOR_PINK)?"Pink":"Orange",
                  n,or_reg->cen_x,or_reg->cen_y,or_reg->area,
                  or_reg->x1,or_reg->y1,or_reg->x2,or_reg->y2,
!                 conf);*/
        }
  
        int sx[2],sy[2]; // scan bounding coordinates;
        bool edge_x[2],edge_y[2]; // true if scan coordinate went off edge
        static const int scan_distance = 3;
!       static int color_cnts[MAX_COLORS];
        int scan_pixels;
        int good_value;
      
--- 427,447 ----
                conf0,conf_square_bbox,conf_area,conf_area_bonus,conf);
      }
      
! /*
      if(conf > ball->confidence) {
        if(debug_ball &&
         (frame_cnt == 0 ||
          frame_cnt == 1)) {
!         printf("%s ball n%d cen (%f,%f) area %d bbox (%d,%d)-(%d,%d) conf %f\n", (ball_color==COLOR_PINK)?"Pink":"Orange",
                  n,or_reg->cen_x,or_reg->cen_y,or_reg->area,
                  or_reg->x1,or_reg->y1,or_reg->x2,or_reg->y2,
!                 conf);
        }
  
        int sx[2],sy[2]; // scan bounding coordinates;
        bool edge_x[2],edge_y[2]; // true if scan coordinate went off edge
        static const int scan_distance = 3;
!       static int color_cnts[num_colors];
        int scan_pixels;
        int good_value;
      
***************
*** 495,515 ****
        }
  
        int non_robot_fringe=0;
!       non_robot_fringe += 5*color_cnts[COLOR_BLUE ];
! /*      non_robot_fringe += 3*color_cnts[COLOR_GRAY ];
!       non_robot_fringe -= 2*color_cnts[COLOR_YELLOW];
!       non_robot_fringe += 3*color_cnts[COLOR_BLUE  ];*/
!       non_robot_fringe -=   color_cnts[COLOR_GREEN   ];
  
        conf_red_v_area = 1 + non_robot_fringe / or_reg->area;
        conf_red_v_area = bound(conf_red_v_area,0.0,1.0);
        
        good_value = 0;
!       good_value += 2*color_cnts[COLOR_BLUE ];
!       good_value += 3*color_cnts[COLOR_GREEN]/2;
! /*      good_value += 2*color_cnts[COLOR_GRAY ];
!       good_value -=   color_cnts[COLOR_YELLOW]/2;
!       good_value += 2*color_cnts[COLOR_BLUE  ];*/
  
        green_f = std::max(good_value+1,1) / (scan_pixels + 1.0);
        green_f = bound(green_f,0.0,1.0);
--- 477,491 ----
        }
  
        int non_robot_fringe=0;
!       non_robot_fringe += 5*color_cnts[getColor("blue")];
!       non_robot_fringe -=   color_cnts[getColor("green")];
  
        conf_red_v_area = 1 + non_robot_fringe / or_reg->area;
        conf_red_v_area = bound(conf_red_v_area,0.0,1.0);
        
        good_value = 0;
!       good_value += 2*color_cnts[getColor("blue")];
!       good_value += 3*color_cnts[getColor("green")]/2;
  
        green_f = std::max(good_value+1,1) / (scan_pixels + 1.0);
        green_f = bound(green_f,0.0,1.0);
***************
*** 519,539 ****
          conf0 *
          conf_square_bbox *
          conf_area *
!         conf_red_v_area *
!         conf_green +
!         conf_area_bonus;
      
        if(conf > 1.0) conf = 1.0;
! /*
!       if(debug_ball &&
!          frame_cnt == 0) {
!         printf(" conf red_v_area %f conf' %f good_value %d g %d w %d r %d b %d y %d scan_pixels %d green_f %f\n",
!                 conf_red_v_area,conf,good_value,
!                 color_cnts[COLOR_GREEN],color_cnts[COLOR_WHITE],color_cnts[COLOR_RED],color_cnts[COLOR_BLUE],color_cnts[COLOR_YELLOW],
!                 scan_pixels,green_f);
!       }
! */
!     }
      
      if(conf > ball->confidence) {
        /*
--- 495,504 ----
          conf0 *
          conf_square_bbox *
          conf_area *
!         + conf_area_bonus;
      
        if(conf > 1.0) conf = 1.0;
!     }*/
      
      if(conf > ball->confidence) {
        /*
***************
*** 593,600 ****
      or_reg = or_reg->next;
      n++;
    }
!   
!   return (ball_color==COLOR_RED)?generateEvent (RedBallSID, ball->confidence, ball_info->reg->cen_x, ball_info->reg->cen_y):generateEvent(PinkBallSID,ball->confidence,ball_info->reg->cen_x,ball_info->reg->cen_y);
  }
  
  bool Vision::findThing(VObject *thing, VisionObjectInfo *thing_info) {
--- 558,564 ----
      or_reg = or_reg->next;
      n++;
    }
!   return (ball_color==getColor("red"))?generateEvent (RedBallSID, ball->confidence, ball_info->reg->cen_x, ball_info->reg->cen_y):generateEvent(PinkBallSID,ball->confidence,ball_info->reg->cen_x,ball_info->reg->cen_y);
  }
  
  bool Vision::findThing(VObject *thing, VisionObjectInfo *thing_info) {
***************
*** 670,678 ****
  
    region *or_reg, *gr_reg, *pu_reg;
  
!   or_reg = color[COLOR_ORANGE].list;
!   gr_reg = color[COLOR_BGREEN].list;
!   pu_reg = color[COLOR_PURPLE].list;
  
    region* marker_regs[9];
    int num_regs=0;
--- 634,642 ----
  
    region *or_reg, *gr_reg, *pu_reg;
  
!   or_reg = color[getColor("orange")].list;
!   gr_reg = color[getColor("bgreen")].list;
!   pu_reg = color[getColor("purple")].list;
  
    region* marker_regs[9];
    int num_regs=0;
***************
*** 794,800 ****
          if (rmap[i].parent==parent
              && rmap[i].width>5
              && rmap[i].x > xl+10) {
- //          rmap[i].color=COLOR_RED;
            thumbsup++;
            thumbx+=xl+(rmap[i].x-xl)/2;
          } else {
--- 758,763 ----
***************
*** 804,810 ****
          if (rmap[i].parent==parent
              && rmap[i].width>5) {
            r=i;
- //          rmap[i].color=COLOR_ORANGE;
            xl=rmap[i].x+rmap[i].width;
          }
        }
--- 767,772 ----
***************
*** 830,844 ****
      vobj_info[obj_idx].reg = NULL;
    }
  
!   findMarkers();
!   bool rball_exist=findBall(COLOR_RED,&obj_info->rball,&vobj_info[RBALL]);
!   bool pball_exist=findBall(COLOR_PINK,&obj_info->pball,&vobj_info[PBALL]);
    bool hand_exist=findHand(&obj_info->hand,&vobj_info[HAND]);
    if (hand_exist
        && !(rball_exist && isIn(vobj_info[RBALL].reg,vobj_info[HAND].reg))
        && !(pball_exist && isIn(vobj_info[PBALL].reg,vobj_info[HAND].reg)))
        // hand exists and hand is not holding ball
!     findGesture(&vobj_info[HAND]);
    return true;
  }
  
--- 792,809 ----
      vobj_info[obj_idx].reg = NULL;
    }
  
! 
! //  findMarkers();
! //  bool rball_exist=findBall(getColor("red"),&obj_info->rball,&vobj_info[RBALL]);
!   if (getColor("red")>=0)
!     bool pball_exist=findBall(getColor("red"),&obj_info->pball,&vobj_info[PBALL]);
!   /*
    bool hand_exist=findHand(&obj_info->hand,&vobj_info[HAND]);
    if (hand_exist
        && !(rball_exist && isIn(vobj_info[RBALL].reg,vobj_info[HAND].reg))
        && !(pball_exist && isIn(vobj_info[PBALL].reg,vobj_info[HAND].reg)))
        // hand exists and hand is not holding ball
!     findGesture(&vobj_info[HAND]);*/
    return true;
  }
  
***************
*** 858,864 ****
  }
  
  bool Vision::thresholdImage(CMVision::image_yuv<const uchar> &img) {
!   CMVision::ThresholdImageYUVPlanar<cmap_t,CMVision::image_yuv<const uchar>,const uchar,bits_y,bits_u,bits_v>(cmap,img,tmap[cur_tmap]);
  
    return true;
  }
--- 823,829 ----
  }
  
  bool Vision::thresholdImage(CMVision::image_yuv<const uchar> &img) {
!   CMVision::ThresholdImageYUVPlanar<cmap_t,CMVision::image_yuv<const uchar>,const uchar,bits_y,bits_u,bits_v>(cmap,img,tmap);
  
    return true;
  }
***************
*** 945,985 ****
  #endif
  
  //   CMVision::CreateRunIndex(yindex,rmap,num_runs);
- /*
- #ifdef PLATFORM_APERIOS
-   // output color area if desired
-   if(config.spoutConfig.dumpVisionColorArea!=0) {
-     outCountColorArea = (outCountColorArea + 1) % config.spoutConfig.dumpVisionColorArea;
-     if(outCountColorArea==0) {
-       sendColorArea();
-     }
-   }
- #endif
- 
- #ifdef PLATFORM_APERIOS
-   // output raw frames if desired
-   if(config.spoutConfig.dumpVisionRaw!=0) {
-     outCountRaw = (outCountRaw + 1) % config.spoutConfig.dumpVisionRaw;
-     if(outCountRaw==0) {
-       sendRawImage();
-     }
-   }
- #endif
- 
- #ifdef PLATFORM_APERIOS
-   // output RLE if desired
-   if(config.spoutConfig.dumpVisionRLE!=0) {
-     outCountRLE = (outCountRLE + 1) % config.spoutConfig.dumpVisionRLE;
-     if(outCountRLE==0) {
-       sendRLEImage();
-     }
-   }
- #endif
- */
    return(true);
  }
  
! bool Vision::processFrame(const uchar *data_y, const uchar *data_u, const uchar *data_v, int width, int height) {
    frameTimestamp = get_time();
    frame_count++;
  
--- 910,919 ----
  #endif
  
  //   CMVision::CreateRunIndex(yindex,rmap,num_runs);
    return(true);
  }
  
! bool Vision::processFrame(const uchar *data_y, const uchar *data_u, const uchar *data_v, int width, int height, int skip) {
    frameTimestamp = get_time();
    frame_count++;
  
***************
*** 989,995 ****
  
    img.width=width;
    img.height=height;
!   img.row_stride=3*width;
  
    bool ok=true;
  
--- 923,930 ----
  
    img.width=width;
    img.height=height;
!   //img.row_stride=3*width;
!   img.row_stride=skip+width;
  
    bool ok=true;
  
***************
*** 1016,1032 ****
    return(wrote);
  }
  
- int Vision::setThreshold(int threshold_id) {
-   if(threshold_id < 0 || threshold_id >= num_tmaps) {
-     return -1;
-   } else {
-     int old_threshold;
-     old_threshold = cur_tmap;
-     cur_tmap = threshold_id;
-     return old_threshold;
-   }
- }
- 
  bool Vision::saveThresholdImage(char *filename)
  {
    rgb *buf;
--- 951,956 ----
***************
*** 1041,1139 ****
  
    return(wrote > 0);
  }
- /*
- void Vision::sendRawImage() {
- #ifdef PLATFORM_APERIOS
-   if(encodeBuf!=NULL && 
-      encoder  !=NULL && 
-      visionRawStream!=NULL) {
-     int out_size=0;
-     out_size=encoder->encodeVisionRaw(encodeBuf,
-                                       body_angle,body_height,
-                                       head_angles[0],head_angles[1],head_angles[2],
-                                       img);
-     if(!visionRawStream->writeBinary(encodeBuf,out_size,frameTimestamp))
-       printf("problem writing raw image\n");
-   } else {
-     if(encoder==NULL)
-       printf("NVEnc\n");
-     else if(encodeBuf==NULL)
-       printf("NVEncBuf\n");
-     else
-       printf("NVRawStream\n");
-   }
- #endif
- 
-   outCountRaw = 0;
- }
- 
- void Vision::sendRLEImage() {
- #ifdef PLATFORM_APERIOS
-   if(encodeBuf!=NULL && 
-      encoder  !=NULL && 
-      visionRLEStream!=NULL) {
-     int out_size=0;
- #ifdef ENABLE_JOIN_NEARBY
-     out_size=encoder->encodeVisionRLE(encodeBuf,
-                                       body_angle,body_height,
-                                       head_angles[0],head_angles[1],head_angles[2],
-                                       num_runs-2,rmap+1);
- #else
-     out_size=encoder->encodeVisionRLE(encodeBuf,
-                                       body_angle,body_height,
-                                       head_angles[0],head_angles[1],head_angles[2],
-                                       num_runs,rmap);
- #endif
-     visionRLEStream->writeBinary(encodeBuf,out_size,frameTimestamp);
-   } else {
-     if(encoder==NULL)
-       printf("NVEnc\n");
-     else if(encodeBuf==NULL)
-       printf("NVEncBuf\n");
-     else
-       printf("NVRLEStream\n");
-   }
- #endif
- 
-   outCountRLE = 0;
- }
  
! void Vision::sendColorArea() {
!   if(encodeBuf!=NULL && 
!      visionColorAreaStream!=NULL) {
!     int out_size=0;
!     uchar *buf;
!     buf = encodeBuf;
!     SPOutEncoder::encodeAs<uchar>(&buf,(uchar)num_colors);
!     for(int color_idx=0; color_idx<num_colors; color_idx++) {
!       SPOutEncoder::encodeAs<ulong>(&buf,(ulong)color[color_idx].total_area);
!     }
!     out_size = buf - encodeBuf;
!     visionColorAreaStream->writeBinary(encodeBuf,out_size,frameTimestamp);
!   } else {
!     if(encodeBuf==NULL)
!       printf("NVEncBuf\n");
!     else
!       printf("NVColorAreaStream\n");
!   }
! }*/
! 
! namespace VisionInterface {
! /*  void SendRawImage(Vision *vision) {
!     vision->sendRawImage();
!   }
! 
!   void SendRLEImage(Vision *vision) {
!     vision->sendRLEImage();
!   }*/
! 
!   void WriteThresholdImage(Vision *vision, char *filename) {
!     vision->saveThresholdImage(filename);
!   }
! 
!   int SetThreshold(Vision *vision,int threshold_id) {
!     return vision->setThreshold(threshold_id);
!   }
  }
  
  /*! @file
--- 965,985 ----
  
    return(wrote > 0);
  }
  
! vector3d Vision::getPixelDirection(double x, double y) {
! /*  vector3d img_pixel_dir; // direction vector of pixel in image coordinates
!                                                                                 
!   img_pixel_dir.set((x+.5-width/2.0),(height/2.0-(y+.5))*YPixelSize,FocalDist);
!                                                                                 
!   vector3d robot_pixel_dir; // direction vector of pixel in robot coordinates
!   robot_pixel_dir =
!     camera_dir  *img_pixel_dir.z +
!     camera_up   *img_pixel_dir.y +
!     camera_right*img_pixel_dir.x;
!                                                                                 
!   robot_pixel_dir = robot_pixel_dir.norm();
!                                                                                 
!   return robot_pixel_dir;*/
  }
  
  /*! @file
***************
*** 1144,1151 ****
   * @verbinclude CMPack_license.txt
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
--- 990,997 ----
   * @verbinclude CMPack_license.txt
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
Index: AiboPup/Vision/Vision.h
diff -c AiboPup/Vision/Vision.h:1.7 AiboPup/Vision/Vision.h:1.10
*** AiboPup/Vision/Vision.h:1.7	Wed Mar 26 23:25:04 2003
--- AiboPup/Vision/Vision.h	Fri Oct 10 01:38:25 2003
***************
*** 30,49 ****
  #define INCLUDED_Vision_h
  
  #include <math.h>
  
  #include "cmvision.h"
  #include "VisionInterface.h"
  
  using namespace VisionInterface;
  
- #include "Shared/Config.h"
  #include "Visiondefines.h"
  #include "Wireless/Wireless.h"
  #include "Events/VisionEvent.h"
  
- #define MAX_TMAPS 16
- 
- 
  typedef uchar pixel;
  typedef uchar cmap_t;
  typedef CMVision::image<uchar> image;
--- 30,46 ----
  #define INCLUDED_Vision_h
  
  #include <math.h>
+ #include <ext/hash_map>
  
  #include "cmvision.h"
  #include "VisionInterface.h"
  
  using namespace VisionInterface;
  
  #include "Visiondefines.h"
  #include "Wireless/Wireless.h"
  #include "Events/VisionEvent.h"
  
  typedef uchar pixel;
  typedef uchar cmap_t;
  typedef CMVision::image<uchar> image;
***************
*** 94,99 ****
--- 91,98 ----
  
  class VisionSerializer;
  
+ using namespace __gnu_cxx;
+ 
  class Vision{
    friend class VisionSerializer;
  public:
***************
*** 103,111 ****
    unsigned long frameTimestamp;
    int frame_count;
  
!   int num_tmaps;
!   int cur_tmap;
!   cmap_t *cmap,*tmap[MAX_TMAPS];
    run *rmap,*rmap2;
    region *reg;
    int yindex[144];
--- 102,108 ----
    unsigned long frameTimestamp;
    int frame_count;
  
!   cmap_t *cmap,*tmap;
    run *rmap,*rmap2;
    region *reg;
    int yindex[144];
***************
*** 123,144 ****
    double body_angle, body_height;
    double head_angles[3];
  
-   vector3d camera_loc,camera_dir,camera_up,camera_right;
- 
-   // distortion calibration stuff
-   double sq_distort_coeff,lin_distort_coeff;
- 
-   int setThreshold(int threshold_id);
- 
-   const vector3d &get_camera_loc() {return camera_loc;}
-   const vector3d &get_camera_dir() {return camera_dir;}
-   int getColor(int x,int y)
-     {return((x>=0 && y>=0 && x<width && y<height)?
-             cmap[y*width+x] : COLOR_BACKGROUND);}
    int getWidth() {return width;}
    int getHeight() {return height;}
    void initialize();
!   void setCameraParam();
    void initializeEventSpecs();
  
    void enableEvents(int vevent);
--- 120,132 ----
    double body_angle, body_height;
    double head_angles[3];
  
    int getWidth() {return width;}
    int getHeight() {return height;}
    void initialize();
!   void setCameraParams();
!   void setResolution();
!   void setColors();
!   int getColor(const char* color);
    void initializeEventSpecs();
  
    void enableEvents(int vevent);
***************
*** 149,178 ****
    
    bool close();
  
!   bool processFrame(const uchar *data_y, const uchar *data_u, const uchar *data_v, int width, int height);
    bool saveThresholdImage(char *filename);
  
-   void sendRawImage ();
-   void sendRLEImage ();
-   void sendColorArea();
- 
-   bool calcTotalArea;
- 
    Marker markers[3];
    int vis_markers;
    ObjectInfo *obj_info;
  
  private:
  
-   int outCountAvgColor;  // number of frames since avg img color was output
-   int outCountColorArea; // number of frames since color area was output
-   int outCountRaw;       // number of frames since raw image was output
-   int outCountRLE;       // number of frames since RLE image was output
- 
    VisionSerializer* vser;
  
    // other stuff
    CMVision::image_yuv<const uchar> img;
  
    bool thresholdImage(CMVision::image_idx<rgb> &img);
    bool thresholdImage(CMVision::image_yuv<const uchar> &img);
--- 137,157 ----
    
    bool close();
  
!   bool processFrame(const uchar *data_y, const uchar *data_u, const uchar *data_v, int width, int height, int skip);
    bool saveThresholdImage(char *filename);
  
    Marker markers[3];
    int vis_markers;
    ObjectInfo *obj_info;
+   OFbkImageLayer imageLayer;
  
  private:
  
    VisionSerializer* vser;
  
    // other stuff
    CMVision::image_yuv<const uchar> img;
+   hash_map<const char*, int, hash<const char*>, hashcmp_eqstr> color_names;
  
    bool thresholdImage(CMVision::image_idx<rgb> &img);
    bool thresholdImage(CMVision::image_yuv<const uchar> &img);
***************
*** 225,234 ****
   * 
   * @verbinclude CMPack_license.txt
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  #endif
--- 204,213 ----
   * 
   * @verbinclude CMPack_license.txt
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  #endif
Index: AiboPup/Vision/VisionInterface.h
diff -c AiboPup/Vision/VisionInterface.h:1.4 AiboPup/Vision/VisionInterface.h:1.5
*** AiboPup/Vision/VisionInterface.h:1.4	Thu Feb 13 15:11:07 2003
--- AiboPup/Vision/VisionInterface.h	Mon Jul 28 02:53:09 2003
***************
*** 88,100 ****
    VObject thing;
  };
  
- // returns the id of the old threshold or -1 on error
- int SetThreshold(Vision *vision,int threshold_id);
- 
- void SendRawImage(Vision *vision); // Forces the output of the current raw image to the log/spout/wl
- void SendRLEImage(Vision *vision); // Forces the output of the current RLE image to the log/spout/wl
- void WriteThresholdImage(Vision *vision, char *filename);
- 
  } // namespace vision
  
  /*! @file
--- 88,93 ----
***************
*** 104,114 ****
   * 
   * @verbinclude CMPack_license.txt
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  #endif
  // __VISION_INTERFACE_H__
--- 97,107 ----
   * 
   * @verbinclude CMPack_license.txt
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  #endif
  // __VISION_INTERFACE_H__
Index: AiboPup/Vision/VisionSerializer.cc
diff -c AiboPup/Vision/VisionSerializer.cc:1.5 AiboPup/Vision/VisionSerializer.cc:1.6
*** AiboPup/Vision/VisionSerializer.cc:1.5	Thu Jun 12 19:41:41 2003
--- AiboPup/Vision/VisionSerializer.cc	Mon Jul 28 02:53:09 2003
***************
*** 31,68 ****
  #include "Wireless/Wireless.h"
  #include "Shared/Config.h"
  #include "Shared/get_time.h"
  
  VisionSerializer::VisionSerializer() : visRaw(NULL), visRLE(NULL) {
!   visRaw=wireless->socket(SocketNS::SOCK_STREAM, 1024, 88*72*3);
!   visRLE=wireless->socket(SocketNS::SOCK_STREAM, 1024, 22*144*3*2);
    wireless->listen(visRaw, config->vision.raw_port);
    wireless->listen(visRLE, config->vision.rle_port);
  }
  
  void
  VisionSerializer::serialize() {
! //  static int time=get_time();
! //  static int frame=0;
!   char *buf=(char*)visRaw->getWriteBuffer(22*144*3);
!   if (buf) {
!     encodeVisionRaw((char *)buf,vision->img,2); 
!     //visRaw->write(174*144*3);
!     visRaw->write(88*72*3);
! /*    if (get_time()-time>1000) {
!       time=get_time();
!       cout << frame << "hz " << time << endl;
!       frame=0;
!     } else {
!       frame++;
!     }*/
!   }
  
-   buf=(char*)visRLE->getWriteBuffer(22*144*3*2);
    if (buf) {
      encodeVisionRLE((char *)buf, vision->num_runs, vision->rmap);
      visRLE->write(4+vision->num_runs*3);
    }
-   
  }
  
  char *
--- 31,79 ----
  #include "Wireless/Wireless.h"
  #include "Shared/Config.h"
  #include "Shared/get_time.h"
+ #include <iostream>
  
  VisionSerializer::VisionSerializer() : visRaw(NULL), visRLE(NULL) {
!   visRaw=wireless->socket(SocketNS::SOCK_STREAM, 1024, 80000);
!   // 80000 bytes for use upto 176x144 only
!   visRLE=wireless->socket(SocketNS::SOCK_STREAM, 1024, 40000);
!   // 40000 bytes is an approximation intended for 176x144
!   // increase or decrease depending on missing lines
!   wireless->setDaemon(visRaw);
!   wireless->setDaemon(visRLE);
    wireless->listen(visRaw, config->vision.raw_port);
    wireless->listen(visRLE, config->vision.rle_port);
  }
  
  void
  VisionSerializer::serialize() {
!   char *buf=(char*)visRaw->getWriteBuffer(79999);
!   if (buf)
!     switch (config->vision.raw_encoding) {
!       case packet_visionraw_yfull_uvhalf:
!         encodeHeader(&buf, packet_visionraw_yfull_uvhalf);
!         encodeVisionRaw_YhalfUVquarter(buf,vision->img); 
!         visRaw->write(8+(176*144*3)/2);
!         break;
!       case packet_visionraw_full:
!         encodeHeader(&buf, packet_visionraw_full);
!         encodeVisionRaw(buf,vision->img,1); 
!         visRaw->write(8+176*144*3);
!         break;
!       case packet_visionraw_half:
!       default:
!         encodeHeader(&buf, packet_visionraw_half);
!         encodeVisionRaw(buf,vision->img,2); 
!         visRaw->write(8+88*72*3);
!         break;
!     }
! 
!   buf=(char*)visRLE->getWriteBuffer(39999);
  
    if (buf) {
      encodeVisionRLE((char *)buf, vision->num_runs, vision->rmap);
      visRLE->write(4+vision->num_runs*3);
    }
  }
  
  char *
***************
*** 96,101 ****
--- 107,137 ----
  }
  
  void
+ VisionSerializer::encodeVisionRaw_YhalfUVquarter(char *buf,
+                                   CMVision::image_yuv<const uchar> &img) {
+   const uchar *row_y,*row_u,*row_v;
+   int height, width;
+   height = img.height;
+   width  = img.width;
+                                                                                 
+   for(int y=0; y<height; y++) {
+     row_y = img.buf_y + y*img.row_stride;
+     row_u = img.buf_u + y*img.row_stride;
+     row_v = img.buf_v + y*img.row_stride;
+     for(int x=0; x<width; x++) {
+       *(buf  )=row_y[x];
+       if (!(y&1) && !(x&1)) {
+         *(buf+1)=row_u[x];
+         *(buf+2)=row_v[x];
+         buf+=3;
+       } else {
+         buf++;
+       }
+     }
+   }
+ }
+ 
+ void
  VisionSerializer::encodeVisionRLE(char *buf,int num_runs,run *runs) {
    encode(&buf,num_runs);
    for (; num_runs>0; num_runs--, runs++) {
***************
*** 110,118 ****
   * 
   * @verbinclude CMPack_license.txt
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
--- 146,154 ----
   * 
   * @verbinclude CMPack_license.txt
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
Index: AiboPup/Vision/VisionSerializer.h
diff -c AiboPup/Vision/VisionSerializer.h:1.2 AiboPup/Vision/VisionSerializer.h:1.3
*** AiboPup/Vision/VisionSerializer.h:1.2	Thu Jun 12 19:41:41 2003
--- AiboPup/Vision/VisionSerializer.h	Mon Jul 28 02:53:10 2003
***************
*** 15,20 ****
--- 15,23 ----
  	//! encodes the original camera image
    void encodeVisionRaw(char *buf,CMVision::image_yuv<const uchar> &img,
                         int scale);
+   //! special encoding of the original camera image
+   void encodeVisionRaw_YhalfUVquarter(char *buf,
+       CMVision::image_yuv<const uchar> &img);
  	//! encodes the RLE processed image
    void encodeVisionRLE(char *buf,int num_runs,run *runs);
  	//! helper function for encodeVisionRLE, encodes one run length
***************
*** 34,44 ****
   * 
   * @verbinclude CMPack_license.txt
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 37,47 ----
   * 
   * @verbinclude CMPack_license.txt
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Vision/Visiondefines.h
diff -c AiboPup/Vision/Visiondefines.h:1.1.1.1 AiboPup/Vision/Visiondefines.h:1.2
*** AiboPup/Vision/Visiondefines.h:1.1.1.1	Mon Sep 30 14:19:51 2002
--- AiboPup/Vision/Visiondefines.h	Mon Jul 28 02:53:10 2003
***************
*** 1,7 ****
  #ifndef INCLUDED_Visiondefines_h
  #define INCLUDED_Visiondefines_h
  
! #define MAX_COLORS 11
  
  #define COLOR_BACKGROUND 0
  #define COLOR_BLACK 0
--- 1,7 ----
  #ifndef INCLUDED_Visiondefines_h
  #define INCLUDED_Visiondefines_h
  
! #define MAX_COLORS 20
  
  #define COLOR_BACKGROUND 0
  #define COLOR_BLACK 0
Index: AiboPup/Vision/cmv_region.h
diff -c AiboPup/Vision/cmv_region.h:1.5 AiboPup/Vision/cmv_region.h:1.6
*** AiboPup/Vision/cmv_region.h:1.5	Sun Mar  2 20:18:14 2003
--- AiboPup/Vision/cmv_region.h	Mon Jul 28 02:53:10 2003
***************
*** 20,25 ****
--- 20,29 ----
  #include "Visiondefines.h"
  
  #include "cmv_types.h"
+ #include <ext/hash_map>
+ 
+ struct hashcmp_eqstr { bool operator()(const char* s1, const char* s2) const
+                      { return strcasecmp(s1, s2) == 0; } };
  
  namespace CMVision{
  
***************
*** 78,88 ****
  
  //==== Main Library Functions ======================================//
  
! // this code is currently broken, it seems to cause rare crashes !!!
! //#define ENABLE_JOIN_NEARBY
! //#define ALOK_JOIN
  
- #ifndef ALOK_JOIN
  template <class rle_t,class tmap_t>
  int EncodeRuns(rle_t *rle,tmap_t *map,int width,int height,int max_runs)
  // Changes the flat array version of the thresholded image into a run
--- 82,89 ----
  
  //==== Main Library Functions ======================================//
  
! #define REMOVE_NOISE
  
  template <class rle_t,class tmap_t>
  int EncodeRuns(rle_t *rle,tmap_t *map,int width,int height,int max_runs)
  // Changes the flat array version of the thresholded image into a run
***************
*** 92,97 ****
--- 93,105 ----
    tmap_t m,save;
    tmap_t *row;
    int x,y,j,l;
+  
+ #ifdef REMOVE_NOISE
+   int lastcolor;
+   int noise;
+   int noise_back;
+ #endif
+   
    rle_t r;
  
    r.next = 0;
***************
*** 100,114 ****
    save = map[0];
  
    j = 0;
! #ifdef ENABLE_JOIN_NEARBY
!   // store black row before image
!   r.color = 0;
!   r.width = width;
!   r.x = 0;
!   r.y = -1;
!   r.parent = j;
!   rle[j++] = r;
! #endif
    for(y=0; y<height; y++){
      row = &map[y * width];
  
--- 108,114 ----
    save = map[0];
  
    j = 0;
! 
    for(y=0; y<height; y++){
      row = &map[y * width];
  
***************
*** 120,229 ****
      r.y = y;
  
      x = 0;
-     while(x < width){
-       m = row[x];
-       r.x = x;
- 
-       l = x;
-       while(row[x] == m) x++;
  
!       if(m!=0 || x>=width){
! 	r.color = m; 
! 	r.width = x - l;
! 	r.parent = j;
! 	rle[j++] = r;
! 
!         // printf("run (%d,%d):%d %d\n",r.x,r.y,r.width,r.color);
! 
! 	if(j >= max_runs) {
!           row[width] = save;
!           return(j);
!         }
!       }
!     }
!   }
! 
! #ifdef ENABLE_JOIN_NEARBY
!   // store black row after image
!   r.color = 0;
!   r.width = width;
!   r.x = 0;
!   r.y = height;
!   r.parent = j;
!   rle[j++] = r;
! #endif
! 
!   return(j);
! }
  #endif
- 
- #ifdef ALOK_JOIN
- template <class rle_t,class tmap_t>
- int EncodeRuns(rle_t *rle,tmap_t *map,int width,int height,int max_runs)
- {
-   tmap_t m,save;
-   tmap_t *row;
-   int x,y,j,l,l1;
-   rle_t r;
-   bool entry=false;
- 
-   r.next = 0;
- 
-   // initialize terminator restore
-   save = map[0];
- 
-   j = 0;
-   for(y=0; y<height; y++){
-     row = &map[y * width];
- 
-     // restore previous terminator and store next
-     // one in the first pixel on the next row
-     row[0] = save;
-     save = row[width];
-     row[width] = MAX_COLORS;
-     r.y = y;
- 
-     x = 0;
      while(x < width){
        m = row[x];
        r.x = x;
  
        l = x;
  
!       if (x==0) {
!         l1=l;
!         while (row[x]==m) x++;
!         while (((x-l1<4)||(m==0 && x-l1<9 )) && x<width) {
!           l1=x;
!           m=row[x];
!           while (row[x]==m) x++;
          }
!         if (m!=0) entry=true;
        } else {
!         while (row[x]==m) x++;
        }
  
!       if (x<width && ((m<MAX_COLORS && x-l<4) || (m==0 && x-l<9))) {
!         if (entry) rle[j-1].width=rle[j-1].width+x-l;
!       } else if(m!=0 || x>=width){
!       	r.color = m; 
!        	r.width = x - l;
!        	r.parent = j;
!        	rle[j++] = r;
! 
!         // printf("run (%d,%d):%d %d\n",r.x,r.y,r.width,r.color);
  
!        	if(j >= max_runs) {
            row[width] = save;
            return(j);
          }
        }
      }
    }
  
    return(j);
  }
- #endif
  
  template <class rle_t,class tmap_t,class edge_t>
  int EncodeRunsUseEdges(rle_t *rle,tmap_t *map,edge_t *edge_map,int width,int height,int max_runs)
--- 120,175 ----
      r.y = y;
  
      x = 0;
  
! #ifdef REMOVE_NOISE
!     lastcolor=0;
!     noise=0;
!     noise_back=0;
  #endif
      while(x < width){
        m = row[x];
        r.x = x;
  
        l = x;
+       while(row[x] == m) x++;
  
! #ifdef REMOVE_NOISE
!       if (x - l > 4) {
!         if (noise>=4) {
!           j=j-noise_back;
!           lastcolor=0;
          }
!         noise=0; 
!         noise_back=0;
        } else {
!         noise++;
!         if (m) noise_back++;
        }
+ #endif
  
!       if(m!=0 || x>=width){
!         r.color = m; 
!         r.width = x - l;
!         r.parent = j;
!         rle[j++] = r;
  
!         if(j >= max_runs) {
            row[width] = save;
            return(j);
          }
        }
+ #ifdef REMOVE_NOISE
+       else if (!m && lastcolor && x-l<5) {
+         rle[j-1].width+=x-l;
+       }
+       
+       lastcolor=m;
+ #endif
      }
    }
  
    return(j);
  }
  
  template <class rle_t,class tmap_t,class edge_t>
  int EncodeRunsUseEdges(rle_t *rle,tmap_t *map,edge_t *edge_map,int width,int height,int max_runs)
***************
*** 1112,1119 ****
    return(end);
  }
  
  template <class color_class_state_t>
! int LoadColorInformation(color_class_state_t *color,int max,const char *filename)
  {
    char buf[512];
    FILE *in;
--- 1058,1067 ----
    return(end);
  }
  
+ using namespace __gnu_cxx;
+ 
  template <class color_class_state_t>
! int LoadColorInformation(color_class_state_t *color,int max,const char *filename, hash_map<const char*, int, hash<const char*>, hashcmp_eqstr> &color_names)
  {
    char buf[512];
    FILE *in;
***************
*** 1156,1161 ****
--- 1104,1110 ----
  	  color[idx].color.green = g;
  	  color[idx].color.blue  = b;
  	  color[idx].name = strdup(name);
+     color_names[color[idx].name]=idx;
  	  if(idx >= num) num = idx+1;
  	} else {
   	  printf("Options error: %2d (%3d %3d %3d) '%s' %d\n",
Index: AiboPup/Wireless/DummySocket.h
diff -c /dev/null AiboPup/Wireless/DummySocket.h:1.2
*** /dev/null	Fri Oct 10 14:37:47 2003
--- AiboPup/Wireless/DummySocket.h	Thu Sep 25 11:32:14 2003
***************
*** 0 ****
--- 1,50 ----
+ #ifndef DummySocket_h_DEFINED
+ #define DummySocket_h_DEFINED
+ 
+ #include <stdarg.h>
+ 
+ class Wireless;
+ 
+ //! Tekkotsu wireless DummySocket class
+ /*! 
+  * This class provides a DummySocket that doesn't really do anything
+  * It exists to maintain code readability; while supporting dogs without
+  * wireless
+  * Of course, since it does nothing, it doesn't need documentation
+  */
+ 
+ class DummySocket : public Socket {
+   friend class Wireless;
+ 
+ public:
+   DummySocket (int sockn) : Socket (sockn) { }
+   virtual ~DummySocket () { }
+   byte* getWriteBuffer(int bytesreq) { return NULL; }
+   void write(int size) { }
+   int read() { return -1; }
+   byte* getReadBuffer() { return NULL; };
+   void init() { }
+   int setFlushType(FlushType_t fType) { return 0; }
+   void setTextForward() { }
+   void setForward(DummySocket * forsock) { }
+   void setVerbosity(int verbose) { }
+   int write(const byte *buf, int size) { return -1; }
+   int read(byte *buf, int size) { return -1; }
+   int printf(const char *fmt, ...) { return 0; }
+   int vprintf(const char *fmt, va_list al) { return 0; }
+   int pprintf(int vlevel, const char *fmt, ...) { return 0; }
+   void flush() { }
+ };
+ 
+ /*! @file
+  * @brief Defines Tekkotsu wireless DummySocket class
+  * @author alokl (Creator)
+  * 
+  * $Author: ejt $
+  * $Name: HEAD $
+  * $Revision: 1.2 $
+  * $State: Exp $
+  * $Date: 2003/10/10 20:25:03 $
+  */
+ 
+ #endif
Index: AiboPup/Wireless/Makefile
diff -c AiboPup/Wireless/Makefile:1.8 AiboPup/Wireless/Makefile:removed
*** AiboPup/Wireless/Makefile:1.8	Tue Jun 10 21:18:56 2003
--- AiboPup/Wireless/Makefile	Fri Oct 10 14:37:47 2003
***************
*** 1,52 ****
- TEKKOTSU_TARGET_MODEL?=TGT_ERS2xx
- 
- SRCS:=$(shell find . -name "*.cc")
- 
- OBJS:=${SRCS:.cc=.o}
- DEPENDS:=${SRCS:.cc=.d}
- 
- OPENRSDK_ROOT?=/usr/local/OPEN_R_SDK
- CXX=$(OPENRSDK_ROOT)/bin/mipsel-linux-g++
- LD=$(OPENRSDK_ROOT)/bin/mipsel-linux-ld
- FILTERSYSWARN=../tools/filtersyswarn/filtersyswarn
- LIBS=-lObjectComm -lOPENR -lInternet -lantMCOOP
- CURDIR:=$(shell pwd | sed 's/.*\///')
- CXXFLAGS= \
- 	-g -O2 \
- 	-Wall -W -Wshadow -Wlarger-than-8192 -Wpointer-arith -Wcast-qual \
- 	-Woverloaded-virtual -Weffc++ -Winline -Wdeprecated \
- 	-I. -I.. -I../MMCombo -isystem $(OPENRSDK_ROOT)/OPEN_R/include/MCOOP \
- 	-isystem $(OPENRSDK_ROOT)/OPEN_R/include/R4000 -isystem $(OPENRSDK_ROOT)/OPEN_R/include \
- 	-DPLATFORM_APERIOS -DDEBUG -DOPENR_DEBUG \
- 	-D$(TEKKOTSU_TARGET_MODEL) $(GLOBAL_MAP) \
- 
- .PHONY: all clean
- 
- all: $(CURDIR)Lib.o
- 
- $(CURDIR)Lib.o : $(OBJS)
- 	@echo Linking object files...
- 	@echo "$@ <- $(OBJS)"
- 	@$(LD) -i $(OBJS) -o $@
- 
- %.o: %.cc %.d $(FILTERSYSWARN)
- 	@echo Compiling $< into $@...
- 	@$(CXX) $(CXXFLAGS) -o $@ -c $< > $*.log 2>&1; \
- 	retval=$$?; \
- 	cat $*.log | $(FILTERSYSWARN); \
- 	test $$retval -eq 0;
- 
- %.d : %.cc
- 	@echo Building $@ for $<
- 	@$(CXX) $(CXXFLAGS) -MP -MG -MT $@ -MT $*.o -MM $< > $@
- 
- $(FILTERSYSWARN):
- 	(cd ../tools && $(MAKE));
- 
- ifneq ($(MAKECMDGOALS),clean)
- -include $(DEPENDS)
- endif
- 
- 
- clean:
- 	rm -f $(CURDIR)Lib.o $(OBJS) $(DEPENDS) ${SRCS:.cc=.log} *~ 
--- 0 ----
Index: AiboPup/Wireless/Socket.cc
diff -c AiboPup/Wireless/Socket.cc:1.13 AiboPup/Wireless/Socket.cc:1.15
*** AiboPup/Wireless/Socket.cc:1.13	Thu Jun 12 19:41:41 2003
--- AiboPup/Wireless/Socket.cc	Wed Oct  1 19:03:43 2003
***************
*** 83,88 ****
--- 83,89 ----
  			sendData=writeData;
  			sendSize=writeSize;
  			wireless->blockingSend(sock);
+ 			writeSize=0;
  		}
  	}
  }
***************
*** 165,173 ****
   * @author alokl (Creator)
   * 
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 166,174 ----
   * @author alokl (Creator)
   * 
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Wireless/Socket.h
diff -c AiboPup/Wireless/Socket.h:1.12 AiboPup/Wireless/Socket.h:1.15
*** AiboPup/Wireless/Socket.h:1.12	Thu Jun 12 23:23:05 2003
--- AiboPup/Wireless/Socket.h	Thu Sep 25 11:32:14 2003
***************
*** 58,66 ****
  			sendSize(0), recvSize(0), writeSize(0), readSize(0),
  			tx(false), rx(false), sendBuffer(), recvBuffer(), sendData(NULL),
  			recvData(NULL), readData(NULL), writeData(NULL), server_port(0),
! 		rcvcbckfn(NULL), textForward(false), textForwardBuf(NULL), forwardSock(NULL)
  	{ }
!   ~Socket() {} //!< destructor
  
    //! use getWriteBuffer to get a memory address to write bytes to, for
    //! subsequent writing to a connection.
--- 58,67 ----
  			sendSize(0), recvSize(0), writeSize(0), readSize(0),
  			tx(false), rx(false), sendBuffer(), recvBuffer(), sendData(NULL),
  			recvData(NULL), readData(NULL), writeData(NULL), server_port(0),
!       rcvcbckfn(NULL), textForward(false), textForwardBuf(NULL),
!       forwardSock(NULL), daemon(false)
  	{ }
!   virtual ~Socket() {} //!< destructor
  
    //! use getWriteBuffer to get a memory address to write bytes to, for
    //! subsequent writing to a connection.
***************
*** 170,176 ****
     */
    void flush();
  
! private:
  	//@{
  	//!private ALOKL_TODO
    TransportType_t trType;
--- 171,177 ----
     */
    void flush();
  
! protected:
  	//@{
  	//!private ALOKL_TODO
    TransportType_t trType;
***************
*** 193,201 ****
    bool textForward;
  	char* textForwardBuf;
  	Socket * forwardSock;
  	//@}
   
! private:
    Socket(const Socket&); //!< copy constructor, don't call
    Socket& operator= (const Socket&); //!< assignment operator, don't call
  };
--- 194,204 ----
    bool textForward;
  	char* textForwardBuf;
  	Socket * forwardSock;
+ 
+   bool daemon;
  	//@}
   
! protected:
    Socket(const Socket&); //!< copy constructor, don't call
    Socket& operator= (const Socket&); //!< assignment operator, don't call
  };
***************
*** 208,217 ****
   * @author alokl (Creator)
   * 
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
--- 211,220 ----
   * @author alokl (Creator)
   * 
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif
Index: AiboPup/Wireless/Wireless.cc
diff -c AiboPup/Wireless/Wireless.cc:1.7 AiboPup/Wireless/Wireless.cc:1.14
*** AiboPup/Wireless/Wireless.cc:1.7	Thu Jun 12 19:41:41 2003
--- AiboPup/Wireless/Wireless.cc	Mon Oct  6 21:01:22 2003
***************
*** 15,27 ****
  Wireless *wireless=NULL;
  
  Wireless::Wireless ()
!   : ipstackRef(), myOID(), sock_num(0)
  {
    ipstackRef = antStackRef("IPStack");
    WhoAmI(&myOID);
  
!   for (int sock = 0; sock < WIRELESS_MAX_SOCKETS; sock++) {
      sockets[sock]=NULL;
    }
  }    
  
--- 15,29 ----
  Wireless *wireless=NULL;
  
  Wireless::Wireless ()
!   : ipstackRef(), myOID(), freeSockets()
  {
    ipstackRef = antStackRef("IPStack");
    WhoAmI(&myOID);
  
!   sockets[0]=new DummySocket(0);
!   for (int sock = 1; sock < WIRELESS_MAX_SOCKETS; sock++) {
      sockets[sock]=NULL;
+     freeSockets.push_back(sock);
    }
  }    
  
***************
*** 37,44 ****
  
  Socket* Wireless::socket(TransportType_t ttype, int recvsize, int sendsize)
  {
!   if (sock_num >= WIRELESS_MAX_SOCKETS
!       || (recvsize + sendsize) <= 256) return NULL;
  
    sockets[sock_num]=new Socket(sock_num);
    sockets[sock_num]->trType=ttype;
--- 39,48 ----
  
  Socket* Wireless::socket(TransportType_t ttype, int recvsize, int sendsize)
  {
!   if (freeSockets.empty()
!       || (recvsize + sendsize) <= 256) return sockets[0];
!   int sock_num=freeSockets.front();
!   freeSockets.pop_front();
  
    sockets[sock_num]=new Socket(sock_num);
    sockets[sock_num]->trType=ttype;
***************
*** 48,54 ****
    // setup send buffer
    antEnvCreateSharedBufferMsg sendBufferMsg(sendsize*2);
    sendBufferMsg.Call(ipstackRef, sizeof(sendBufferMsg));
!   if (sendBufferMsg.error != ANT_SUCCESS) return NULL;
    
    sockets[sock_num]->sendBuffer = sendBufferMsg.buffer;
    sockets[sock_num]->sendBuffer.Map();
--- 52,58 ----
    // setup send buffer
    antEnvCreateSharedBufferMsg sendBufferMsg(sendsize*2);
    sendBufferMsg.Call(ipstackRef, sizeof(sendBufferMsg));
!   if (sendBufferMsg.error != ANT_SUCCESS) return sockets[0];
    
    sockets[sock_num]->sendBuffer = sendBufferMsg.buffer;
    sockets[sock_num]->sendBuffer.Map();
***************
*** 58,64 ****
    // setup receive buffer
    antEnvCreateSharedBufferMsg recvBufferMsg(recvsize*2);
    recvBufferMsg.Call(ipstackRef, sizeof(recvBufferMsg));
!   if (recvBufferMsg.error != ANT_SUCCESS) return NULL;
    
    sockets[sock_num]->recvBuffer = recvBufferMsg.buffer;
    sockets[sock_num]->recvBuffer.Map();
--- 62,68 ----
    // setup receive buffer
    antEnvCreateSharedBufferMsg recvBufferMsg(recvsize*2);
    recvBufferMsg.Call(ipstackRef, sizeof(recvBufferMsg));
!   if (recvBufferMsg.error != ANT_SUCCESS) return sockets[0];
    
    sockets[sock_num]->recvBuffer = recvBufferMsg.buffer;
    sockets[sock_num]->recvBuffer.Map();
***************
*** 68,80 ****
    sockets[sock_num]->readData=sockets[sock_num]->recvData+recvsize;
    sockets[sock_num]->writeData=sockets[sock_num]->sendData+sendsize;
  
!   return sockets[sock_num++]; 
  }
  
  int Wireless::listen(int sock, int port)
  {
    if (port<=0 || port>=65535
!       || sock<0 || sock>=sock_num
        || sockets[sock]->state != CONNECTION_CLOSED) return -1;
    
    sockets[sock]->server_port=port;
--- 72,84 ----
    sockets[sock_num]->readData=sockets[sock_num]->recvData+recvsize;
    sockets[sock_num]->writeData=sockets[sock_num]->sendData+sendsize;
  
!   return sockets[sock_num]; 
  }
  
  int Wireless::listen(int sock, int port)
  {
    if (port<=0 || port>=65535
!       || sock<=0 || sock>=WIRELESS_MAX_SOCKETS || sockets[sock]==NULL
        || sockets[sock]->state != CONNECTION_CLOSED) return -1;
    
    sockets[sock]->server_port=port;
***************
*** 126,132 ****
  int Wireless::connect(int sock, const char* ipaddr, int port)
  {
    if (port<=0 || port>=65535
!       || sock<0 || sock>=sock_num
        || sockets[sock]->state != CONNECTION_CLOSED) return -1;
    
    sockets[sock]->init();
--- 130,136 ----
  int Wireless::connect(int sock, const char* ipaddr, int port)
  {
    if (port<=0 || port>=65535
!       || sock<=0 || sock>=WIRELESS_MAX_SOCKETS || sockets[sock]==NULL
        || sockets[sock]->state != CONNECTION_CLOSED) return -1;
    
    sockets[sock]->init();
***************
*** 185,190 ****
--- 189,195 ----
    }
    
    sockets[sock]->state = CONNECTION_CONNECTED;
+   if (sockets[sock]->rcvcbckfn) { receive(sock); }  //Thanks to Andrew Cristina <acristin@cs.uno.edu>, et. al. for bug fix
  }
  
  void
***************
*** 204,210 ****
  void
  Wireless::send(int sock)
  {
!   if (sock<0 || sock>=sock_num
        || sockets[sock]->state != CONNECTION_CONNECTED
        || sockets[sock]->sendSize <= 0) return;
  
--- 209,215 ----
  void
  Wireless::send(int sock)
  {
!   if (sock<=0 || sock>=WIRELESS_MAX_SOCKETS || sockets[sock]==NULL
        || sockets[sock]->state != CONNECTION_CONNECTED
        || sockets[sock]->sendSize <= 0) return;
  
***************
*** 235,244 ****
      sockets[sock]->flush();
  }
  
  void
  Wireless::blockingSend(int sock)
  {
!   if (sock<0 || sock>=sock_num
        || sockets[sock]->state != CONNECTION_CONNECTED
        || sockets[sock]->sendSize <= 0) return;
  
--- 240,254 ----
      sockets[sock]->flush();
  }
  
+ /*! @bug This doesn't actually seem to block until the message is
+  *	fully sent... a crash immediately after this will still cause a
+  *	line or two to be dropped.  This is still less dropped than
+  *	regular send, but doesn't do much good for debugging until we fix
+  *	this. (if we can...) */
  void
  Wireless::blockingSend(int sock)
  {
!   if (sock<=0 || sock>=WIRELESS_MAX_SOCKETS || sockets[sock]==NULL
        || sockets[sock]->state != CONNECTION_CONNECTED
        || sockets[sock]->sendSize <= 0) return;
  
***************
*** 257,263 ****
  void
  Wireless::setReceiver(int sock, int (*rcvcbckfn) (char*, int) )
  {
!   if (sock<0 || sock>=sock_num) return;
  
    sockets[sock]->rcvcbckfn=rcvcbckfn;
  }
--- 267,273 ----
  void
  Wireless::setReceiver(int sock, int (*rcvcbckfn) (char*, int) )
  {
!   if (sock<=0 || sock>=WIRELESS_MAX_SOCKETS || sockets[sock]==NULL) return;
  
    sockets[sock]->rcvcbckfn=rcvcbckfn;
  }
***************
*** 265,271 ****
  void
  Wireless::receive(int sock)
  {
!   if (sock<0 || sock>=sock_num
        || sockets[sock]->state != CONNECTION_CONNECTED) return;
    
    TCPEndpointReceiveMsg receiveMsg(sockets[sock]->endpoint,
--- 275,281 ----
  void
  Wireless::receive(int sock)
  {
!   if (sock<=0 || sock>=WIRELESS_MAX_SOCKETS || sockets[sock]==NULL
        || sockets[sock]->state != CONNECTION_CONNECTED) return;
    
    TCPEndpointReceiveMsg receiveMsg(sockets[sock]->endpoint,
***************
*** 282,288 ****
  void
  Wireless::receive(int sock, int (*rcvcbckfn) (char*, int) )
  {
!   if (sock<0 || sock>=sock_num
        || sockets[sock]->state != CONNECTION_CONNECTED) return;
  
    sockets[sock]->rcvcbckfn=rcvcbckfn;
--- 292,298 ----
  void
  Wireless::receive(int sock, int (*rcvcbckfn) (char*, int) )
  {
!   if (sock<=0 || sock>=WIRELESS_MAX_SOCKETS || sockets[sock]==NULL
        || sockets[sock]->state != CONNECTION_CONNECTED) return;
  
    sockets[sock]->rcvcbckfn=rcvcbckfn;
***************
*** 321,326 ****
--- 331,345 ----
    if (sockets[sock]->state == CONNECTION_CLOSED ||
        sockets[sock]->state == CONNECTION_CLOSING) return;
  
+   if (!(sockets[sock]->server_port>0 && sockets[sock]->daemon)) {
+     sockets[sock]->recvBuffer.UnMap();
+     antEnvDestroySharedBufferMsg receiveBufferMsg(sockets[sock]->recvBuffer);
+     receiveBufferMsg.Call(ipstackRef, sizeof(antEnvDestroySharedBufferMsg));
+     sockets[sock]->sendBuffer.UnMap();
+     antEnvDestroySharedBufferMsg sendBufferMsg(sockets[sock]->sendBuffer);
+     sendBufferMsg.Call(ipstackRef, sizeof(antEnvDestroySharedBufferMsg));
+   }
+ 
    TCPEndpointCloseMsg closeMsg(sockets[sock]->endpoint);
    closeMsg.continuation = (void*)sock;
  
***************
*** 337,346 ****
    int sock = (int)(closeMsg->continuation);
  
    sockets[sock]->state = CONNECTION_CLOSED;
!   if (sockets[sock]->server_port>0) {
      // recycle if server
!     if (sockets[sock]->server_port>0)
!       listen(sock, sockets[sock]->server_port);
    }
  }
  
--- 356,369 ----
    int sock = (int)(closeMsg->continuation);
  
    sockets[sock]->state = CONNECTION_CLOSED;
!   if (sockets[sock]->server_port>0
!       && sockets[sock]->daemon) {
      // recycle if server
!     listen(sock, sockets[sock]->server_port);
!   } else {
!     delete(sockets[sock]);
!     sockets[sock]=NULL;
!     freeSockets.push_back(sock);
    }
  }
  
***************
*** 351,359 ****
   * @verbinclude CMPack_license.txt
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 374,382 ----
   * @verbinclude CMPack_license.txt
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/Wireless/Wireless.h
diff -c AiboPup/Wireless/Wireless.h:1.12 AiboPup/Wireless/Wireless.h:1.14
*** AiboPup/Wireless/Wireless.h:1.12	Thu Jun 12 19:41:41 2003
--- AiboPup/Wireless/Wireless.h	Sun Sep 21 15:43:41 2003
***************
*** 8,15 ****
--- 8,18 ----
  #include <ant.h>
  //#include "MMCombo/def.h"
  #include "Socket.h"
+ #include "DummySocket.h"
+ #include <list>
  
  using namespace SocketNS;
+ using namespace __gnu_cxx;
  
  //! Tekkotsu wireless class
  /*!
***************
*** 62,68 ****
    int connect(int sock, const char* ipaddr, int port);
  	//! sets receiver callback for a socket
    void setReceiver(int sock, int (*rcvcbckfn) (char*, int) );
! 	//! closes a socket
    void close(int sock);
  
    //@{
--- 65,73 ----
    int connect(int sock, const char* ipaddr, int port);
  	//! sets receiver callback for a socket
    void setReceiver(int sock, int (*rcvcbckfn) (char*, int) );
!   //! sets the socket to be a daemon (recycles on close)
!   void setDaemon(int sock, bool val=true) { sockets[sock]->daemon=val; }
! 	//! closes and destroys non server, daemon sockets
    void close(int sock);
  
    //@{
***************
*** 82,87 ****
--- 87,94 ----
      { setReceiver(sobj.sock, rcvcbckfn); }
    void setReceiver(Socket *sobj, int (*rcvcbckfn) (char*, int) )
      { setReceiver(sobj->sock, rcvcbckfn); }
+   void setDaemon(Socket &sobj, bool val=true) { setDaemon(sobj.sock, val); }
+   void setDaemon(Socket *sobj, bool val=true) { setDaemon(sobj->sock, val); }
    int listen(Socket &sobj, int port) { return listen(sobj.sock, port); } 
    int listen(Socket *sobj, int port) { return listen(sobj->sock, port); } 
    int connect(Socket &sobj, const char* ipaddr, int port)
***************
*** 123,129 ****
    antStackRef ipstackRef;
    OID myOID;
    Socket* sockets[WIRELESS_MAX_SOCKETS];
!   int sock_num;
  	//@}
  
  private:
--- 130,136 ----
    antStackRef ipstackRef;
    OID myOID;
    Socket* sockets[WIRELESS_MAX_SOCKETS];
!   list<int> freeSockets;
  	//@}
  
  private:
***************
*** 140,150 ****
   * 
   * @verbinclude CMPack_license.txt
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif // Wireless_h_DEFINED
--- 147,157 ----
   * 
   * @verbinclude CMPack_license.txt
   *
!  * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
  #endif // Wireless_h_DEFINED
Index: AiboPup/WorldModel2/Makefile
diff -c AiboPup/WorldModel2/Makefile:1.8 AiboPup/WorldModel2/Makefile:removed
*** AiboPup/WorldModel2/Makefile:1.8	Tue Jun 10 21:18:56 2003
--- AiboPup/WorldModel2/Makefile	Fri Oct 10 14:37:47 2003
***************
*** 1,52 ****
- TEKKOTSU_TARGET_MODEL?=TGT_ERS2xx
- 
- SRCS:=$(shell find . -name "*.cc")
- 
- OBJS:=${SRCS:.cc=.o}
- DEPENDS:=${SRCS:.cc=.d}
- 
- OPENRSDK_ROOT?=/usr/local/OPEN_R_SDK
- CXX=$(OPENRSDK_ROOT)/bin/mipsel-linux-g++
- LD=$(OPENRSDK_ROOT)/bin/mipsel-linux-ld
- FILTERSYSWARN=../tools/filtersyswarn/filtersyswarn
- LIBS=-lObjectComm -lOPENR -lInternet -lantMCOOP
- CURDIR:=$(shell pwd | sed 's/.*\///')
- CXXFLAGS= \
- 	-g -O2 \
- 	-Wall -W -Wshadow -Wlarger-than-8192 -Wpointer-arith -Wcast-qual \
- 	-Woverloaded-virtual -Weffc++ -Winline -Wdeprecated \
- 	-I. -I.. -I../MMCombo -isystem $(OPENRSDK_ROOT)/OPEN_R/include/MCOOP \
- 	-isystem $(OPENRSDK_ROOT)/OPEN_R/include/R4000 -isystem $(OPENRSDK_ROOT)/OPEN_R/include \
- 	-DPLATFORM_APERIOS -DDEBUG -DOPENR_DEBUG \
- 	-D$(TEKKOTSU_TARGET_MODEL) $(GLOBAL_MAP) \
- 
- .PHONY: all clean
- 
- all: $(CURDIR)Lib.o
- 
- $(CURDIR)Lib.o : $(OBJS)
- 	@echo Linking object files...
- 	@echo "$@ <- $(OBJS)"
- 	@$(LD) -i $(OBJS) -o $@
- 
- %.o: %.cc %.d $(FILTERSYSWARN)
- 	@echo Compiling $< into $@...
- 	@$(CXX) $(CXXFLAGS) -o $@ -c $< > $*.log 2>&1; \
- 	retval=$$?; \
- 	cat $*.log | $(FILTERSYSWARN); \
- 	test $$retval -eq 0;
- 
- %.d : %.cc
- 	@echo Building $@ for $<
- 	@$(CXX) $(CXXFLAGS) -MP -MG -MT $@ -MT $*.o -MM $< > $@
- 
- $(FILTERSYSWARN):
- 	(cd ../tools && $(MAKE));
- 
- ifneq ($(MAKECMDGOALS),clean)
- -include $(DEPENDS)
- endif
- 
- 
- clean:
- 	rm -f $(CURDIR)Lib.o $(OBJS) $(DEPENDS) ${SRCS:.cc=.log} *~ 
--- 0 ----
Index: AiboPup/WorldModel2/WorldModel2.cc
diff -c AiboPup/WorldModel2/WorldModel2.cc:1.13 AiboPup/WorldModel2/WorldModel2.cc:1.15
*** AiboPup/WorldModel2/WorldModel2.cc:1.13	Wed May 28 10:44:44 2003
--- AiboPup/WorldModel2/WorldModel2.cc	Thu Jul 31 23:01:46 2003
***************
*** 25,30 ****
--- 25,31 ----
  #include "Shared/WorldState.h"
  #include "Vision/Vision.h"
  #include "Wireless/Wireless.h"
+ #include "Shared/Config.h"
  
  // include WorldModel2 particulars
  #include "FastSLAM/afsMain.h"
***************
*** 203,212 ****
    // Marker events--for FastSLAM
  void WorldModel2::enableMarkers()
  {
!     // We enable marker vision events
!   vision->enableEvents(VisionEventNS::MarkersSID);
!     // We even listen to them if we're not moving
!     // note: also checks for indicator value of 0 of movingSince
    if(movingSince && !moving)
      erouter->addListener(this,EventBase::visionEGID, VisionEventNS::MarkersSID);
    enabledMarkers = true;
--- 204,211 ----
    // Marker events--for FastSLAM
  void WorldModel2::enableMarkers()
  {
! 	// We even listen to them if we're not moving
! 	// note: also checks for indicator value of 0 of movingSince
    if(movingSince && !moving)
      erouter->addListener(this,EventBase::visionEGID, VisionEventNS::MarkersSID);
    enabledMarkers = true;
Index: AiboPup/contrib/ENSTA_OPENR_Tutorial.url
diff -c /dev/null AiboPup/contrib/ENSTA_OPENR_Tutorial.url:1.1
*** /dev/null	Fri Oct 10 14:37:48 2003
--- AiboPup/contrib/ENSTA_OPENR_Tutorial.url	Fri Aug 29 22:17:39 2003
***************
*** 0 ****
--- 1 ----
+ http://www.ensta.fr/~baillie/openr_tutorial.html
Index: AiboPup/contrib/pgss_project_2003/Presentation.pdf.url
diff -c /dev/null AiboPup/contrib/pgss_project_2003/Presentation.pdf.url:1.1
*** /dev/null	Fri Oct 10 14:37:48 2003
--- AiboPup/contrib/pgss_project_2003/Presentation.pdf.url	Sat Aug 23 19:59:09 2003
***************
*** 0 ****
--- 1 ----
+ http://www.tekkotsu.org/media/pgss_2003_presentation.pdf
Index: AiboPup/contrib/pgss_project_2003/Presentation.ppt.url
diff -c /dev/null AiboPup/contrib/pgss_project_2003/Presentation.ppt.url:1.1
*** /dev/null	Fri Oct 10 14:37:48 2003
--- AiboPup/contrib/pgss_project_2003/Presentation.ppt.url	Sat Aug 23 19:59:12 2003
***************
*** 0 ****
--- 1 ----
+ http://www.tekkotsu.org/media/pgss_2003_presentation.ppt
Index: AiboPup/contrib/pgss_project_2003/Writeup.doc.url
diff -c /dev/null AiboPup/contrib/pgss_project_2003/Writeup.doc.url:1.1
*** /dev/null	Fri Oct 10 14:37:48 2003
--- AiboPup/contrib/pgss_project_2003/Writeup.doc.url	Sat Aug 23 19:59:14 2003
***************
*** 0 ****
--- 1 ----
+ http://www.tekkotsu.org/media/pgss_2003_paper.doc
Index: AiboPup/contrib/pgss_project_2003/Writeup.pdf.url
diff -c /dev/null AiboPup/contrib/pgss_project_2003/Writeup.pdf.url:1.1
*** /dev/null	Fri Oct 10 14:37:48 2003
--- AiboPup/contrib/pgss_project_2003/Writeup.pdf.url	Sat Aug 23 19:59:16 2003
***************
*** 0 ****
--- 1 ----
+ http://www.tekkotsu.org/media/pgss_2003_paper.pdf
Index: AiboPup/docs/builddocs
diff -c AiboPup/docs/builddocs:1.6 AiboPup/docs/builddocs:1.9
*** AiboPup/docs/builddocs:1.6	Wed Feb  5 00:05:59 2003
--- AiboPup/docs/builddocs	Mon Oct  6 23:28:14 2003
***************
*** 8,27 ****
  update=0;
  search=0;
  clean=0;
  extract_all="EXTRACT_ALL = NO";
  always_detailed_sec="ALWAYS_DETAILED_SEC = NO";
  generate_treeview="GENERATE_TREEVIEW = NO";
  searchengine="SEARCHENGINE = NO";
  enabled_sections="ENABLED_SECTIONS += INTERNAL";
  input="$src";
! exclude="$input/docs/header.h $input/docs/implementation.cc $input/TinyFTPD $input/ms $input/tools";
  
  while [ $# -gt 0 ] ; do
  	case $1 in
  		-a | --all) extract_all="EXTRACT_ALL = YES"; shift;;
  		-u | --update) update=1; shift;;
  		-d | --detailed) always_detailed_sec="ALWAYS_DETAILED_SEC = YES"; shift;;
! 		-t | --tree) generate_treeview="GENERATE_TREEVIEW = YES"; shift;;
  		-s | --search) search=1; searchengine="SEARCHENGINE = YES"; shift;;
  		-r | --release) enabled_sections=""; shift;;
  		-c | --clean) clean=1; shift;;
--- 8,28 ----
  update=0;
  search=0;
  clean=0;
+ tree=0;
  extract_all="EXTRACT_ALL = NO";
  always_detailed_sec="ALWAYS_DETAILED_SEC = NO";
  generate_treeview="GENERATE_TREEVIEW = NO";
  searchengine="SEARCHENGINE = NO";
  enabled_sections="ENABLED_SECTIONS += INTERNAL";
  input="$src";
! exclude="$input/docs/header.h $input/docs/implementation.cc $input/TinyFTPD $input/ms $input/tools $input/contrib";
  
  while [ $# -gt 0 ] ; do
  	case $1 in
  		-a | --all) extract_all="EXTRACT_ALL = YES"; shift;;
  		-u | --update) update=1; shift;;
  		-d | --detailed) always_detailed_sec="ALWAYS_DETAILED_SEC = YES"; shift;;
! 		-t | --tree) tree=1; generate_treeview="GENERATE_TREEVIEW = YES"; shift;;
  		-s | --search) search=1; searchengine="SEARCHENGINE = YES"; shift;;
  		-r | --release) enabled_sections=""; shift;;
  		-c | --clean) clean=1; shift;;
***************
*** 52,58 ****
  
  if [ $update -eq 0 -o $clean -ne 0 ] ; then
  	printf "Cleaning previous build of \`\`$target''...";
! 	rm -rf "$target"/*;
  	printf "done\n";
  	if [ $update -ne 0 ] ; then
  		update=0;
--- 53,61 ----
  
  if [ $update -eq 0 -o $clean -ne 0 ] ; then
  	printf "Cleaning previous build of \`\`$target''...";
! 	rm -rf ${target}/*.html;
! 	rm -rf ${target}/*.png;
! 	rm -rf ${target}/*;
  	printf "done\n";
  	if [ $update -ne 0 ] ; then
  		update=0;
***************
*** 69,89 ****
  
  if [ $update -eq 0 ] ; then
  	printf "Copying additional documentation..."
! 	cp -rf "$src"/docs/html/* $target ;
  	cp -f "$src"/docs/html/.htaccess $target ;
! 	rm -rf $target/CVS ;
! #	echo "Allow from `host syna.no-ip.org | cut -d \  -f 4`" >> $target/.htaccess;
  	printf "done\n"
  else
! 	printf "Replacing generated index.html with docs/html/index.html..."
! 	cp "$src"/docs/html/index.html $target ;
! 	printf "done\n"
! fi;
! 
! if [ $search -gt 0 ] ; then
! 	printf "Building search index..."
! 	cd "$target" ;
! 	doxytag -s search.idx ;
  	printf "done\n"
  fi;
  
--- 72,103 ----
  
  if [ $update -eq 0 ] ; then
  	printf "Copying additional documentation..."
! 	for x in ${src}/docs/html/* ; do
! 		printf "${x}, "
! 		if echo "$x" | grep -q /index.html\$ ; then
! 			if [ $tree -eq 0 ] ; then
! 				cp -f $x $target ;
! 			else
! 				cp -f $x ${target}/main.html ;
! 			fi;
! 		else
! 			if echo "$x" | grep -v -q /CVS\$ ; then
! 				cp -rf $x $target ;
! 			fi;
! 		fi;
! 	done;
!   printf "${src}/docs/html/.htaccess..."
  	cp -f "$src"/docs/html/.htaccess $target ;
! #	rm -rf $target/CVS ;
  	printf "done\n"
  else
! 	if [ $tree -eq 0 ] ; then
! 		printf "Replacing generated index.html with docs/html/index.html..."
! 		cp -f "$src"/docs/html/index.html $target ;
! 	else
! 		printf "Replacing generated main.html with docs/html/index.html..."
! 		cp -f "$src"/docs/html/index.html $target/main.html ;
! 	fi;
  	printf "done\n"
  fi;
  
Index: AiboPup/docs/doxygencfg
diff -c AiboPup/docs/doxygencfg:1.13 AiboPup/docs/doxygencfg:1.24
*** AiboPup/docs/doxygencfg:1.13	Tue Jul  8 17:33:12 2003
--- AiboPup/docs/doxygencfg	Wed Oct  1 22:46:04 2003
***************
*** 1,4 ****
! # Doxyfile 1.2.17
  
  # This file describes the settings to be used by the documentation system
  # doxygen (www.doxygen.org) for a project
--- 1,4 ----
! # Doxyfile 1.3.4
  
  # This file describes the settings to be used by the documentation system
  # doxygen (www.doxygen.org) for a project
***************
*** 11,17 ****
  # Values that contain spaces should be placed between quotes (" ")
  
  #---------------------------------------------------------------------------
! # General configuration options
  #---------------------------------------------------------------------------
  
  # The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
--- 11,17 ----
  # Values that contain spaces should be placed between quotes (" ")
  
  #---------------------------------------------------------------------------
! # Project related configuration options
  #---------------------------------------------------------------------------
  
  # The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
***************
*** 23,29 ****
  # This could be handy for archiving the generated documentation or 
  # if some version control system is used.
  
! PROJECT_NUMBER         = 1.4
  
  # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
  # base path where the generated documentation will be put. 
--- 23,29 ----
  # This could be handy for archiving the generated documentation or 
  # if some version control system is used.
  
! PROJECT_NUMBER         = 1.5
  
  # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
  # base path where the generated documentation will be put. 
***************
*** 31,87 ****
  # where doxygen was started. If left blank the current directory will be used.
  
  #builddocs will set this in doxygenbuildcfg
! #OUTPUT_DIRECTORY       = /usr0/apache/htdocs/
  
  # The OUTPUT_LANGUAGE tag is used to specify the language in which all 
  # documentation generated by doxygen is written. Doxygen will use this 
  # information to generate all constant output in the proper language. 
  # The default language is English, other supported languages are: 
! # Brazilian, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, 
  # Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en 
! # (Japanese with english messages), Korean, Norwegian, Polish, Portuguese, 
! # Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish and Ukrainian.
  
  OUTPUT_LANGUAGE        = English
  
! # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
! # documentation are documented, even if no documentation was available. 
! # Private class members and static file members will be hidden unless 
! # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
! 
! #builddocs will set this in doxygenbuildcfg
! #EXTRACT_ALL            = NO
! 
! # If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
! # will be included in the documentation.
! 
! EXTRACT_PRIVATE        = YES
! 
! # If the EXTRACT_STATIC tag is set to YES all static members of a file 
! # will be included in the documentation.
! 
! EXTRACT_STATIC         = YES
! 
! # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
! # defined locally in source files will be included in the documentation. 
! # If set to NO only classes defined in header files are included.
! 
! EXTRACT_LOCAL_CLASSES  = YES
! 
! # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
! # undocumented members of documented classes, files or namespaces. 
! # If set to NO (the default) these members will be included in the 
! # various overviews, but no documentation section is generated. 
! # This option has no effect if EXTRACT_ALL is enabled.
! 
! HIDE_UNDOC_MEMBERS     = NO
! 
! # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
! # undocumented classes that are normally visible in the class hierarchy. 
! # If set to NO (the default) these class will be included in the various 
! # overviews. This option has no effect if EXTRACT_ALL is enabled.
  
! HIDE_UNDOC_CLASSES     = NO
  
  # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
  # include brief member descriptions after the members that are listed in 
--- 31,58 ----
  # where doxygen was started. If left blank the current directory will be used.
  
  #builddocs will set this in doxygenbuildcfg
! #OUTPUT_DIRECTORY       = /Users/ejt/todo/Tekkotsu/docs/generated
  
  # The OUTPUT_LANGUAGE tag is used to specify the language in which all 
  # documentation generated by doxygen is written. Doxygen will use this 
  # information to generate all constant output in the proper language. 
  # The default language is English, other supported languages are: 
! # Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, 
  # Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en 
! # (Japanese with English messages), Korean, Norwegian, Polish, Portuguese, 
! # Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian.
  
  OUTPUT_LANGUAGE        = English
  
! # This tag can be used to specify the encoding used in the generated output. 
! # The encoding is not always determined by the language that is chosen, 
! # but also whether or not the output is meant for Windows or non-Windows users. 
! # In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES 
! # forces the Windows encoding (this is the default for the Windows binary), 
! # whereas setting the tag to NO uses a Unix-style encoding (the default for 
! # all platforms other than Windows).
  
! USE_WINDOWS_ENCODING   = NO
  
  # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
  # include brief member descriptions after the members that are listed in 
***************
*** 118,178 ****
  FULL_PATH_NAMES        = NO
  
  # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
! # can be used to strip a user defined part of the path. Stripping is 
  # only done if one of the specified strings matches the left-hand part of 
  # the path. It is allowed to use relative paths in the argument list.
  
  STRIP_FROM_PATH        = 
  
- # The INTERNAL_DOCS tag determines if documentation 
- # that is typed after a \internal command is included. If the tag is set 
- # to NO (the default) then the documentation will be excluded. 
- # Set it to YES to include the internal documentation.
- 
- INTERNAL_DOCS          = NO
- 
- # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
- # doxygen to hide any special comment blocks from generated source code 
- # fragments. Normal C and C++ comments will always remain visible.
- 
- STRIP_CODE_COMMENTS    = NO
- 
- # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
- # file names in lower case letters. If set to YES upper case letters are also 
- # allowed. This is useful if you have classes or files whose names only differ 
- # in case and if your file system supports case sensitive file names. Windows 
- # users are adviced to set this option to NO.
- 
- CASE_SENSE_NAMES       = YES
- 
  # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
  # (but less readable) file names. This can be useful is your file systems 
  # doesn't support long names like on DOS, Mac, or CD-ROM.
  
  SHORT_NAMES            = NO
  
- # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
- # will show members with their full class and namespace scopes in the 
- # documentation. If set to YES the scope will be hidden.
- 
- HIDE_SCOPE_NAMES       = NO
- 
- # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
- # will generate a verbatim copy of the header file for each class for 
- # which an include is specified. Set to NO to disable this.
- 
- VERBATIM_HEADERS       = YES
- 
- # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
- # will put list of the files that are included by a file in the documentation 
- # of that file.
- 
- SHOW_INCLUDE_FILES     = YES
- 
  # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
  # will interpret the first line (until the first dot) of a JavaDoc-style 
  # comment as the brief description. If set to NO, the JavaDoc 
! # comments  will behave just like the Qt-style comments (thus requiring an 
  # explict @brief command for a brief description.
  
  JAVADOC_AUTOBRIEF      = NO
--- 89,110 ----
  FULL_PATH_NAMES        = NO
  
  # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
! # can be used to strip a user-defined part of the path. Stripping is 
  # only done if one of the specified strings matches the left-hand part of 
  # the path. It is allowed to use relative paths in the argument list.
  
  STRIP_FROM_PATH        = 
  
  # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
  # (but less readable) file names. This can be useful is your file systems 
  # doesn't support long names like on DOS, Mac, or CD-ROM.
  
  SHORT_NAMES            = NO
  
  # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
  # will interpret the first line (until the first dot) of a JavaDoc-style 
  # comment as the brief description. If set to NO, the JavaDoc 
! # comments will behave just like the Qt-style comments (thus requiring an 
  # explict @brief command for a brief description.
  
  JAVADOC_AUTOBRIEF      = NO
***************
*** 198,215 ****
  
  INHERIT_DOCS           = YES
  
- # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
- # is inserted in the documentation for inline members.
- 
- INLINE_INFO            = YES
- 
- # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
- # will sort the (detailed) documentation of file and class members 
- # alphabetically by member name. If set to NO the members will appear in 
- # declaration order.
- 
- SORT_MEMBER_DOCS       = YES
- 
  # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
  # tag is set to YES, then doxygen will reuse the documentation of the first 
  # member in the group (if any) for the other members of the group. By default 
--- 130,135 ----
***************
*** 222,227 ****
--- 142,274 ----
  
  TAB_SIZE               = 2
  
+ # This tag can be used to specify a number of aliases that acts 
+ # as commands in the documentation. An alias has the form "name=value". 
+ # For example adding "sideeffect=\par Side Effects:\n" will allow you to 
+ # put the command \sideeffect (or @sideeffect) in the documentation, which 
+ # will result in a user-defined paragraph with heading "Side Effects:". 
+ # You can put \n's in the value part of an alias to insert newlines.
+ 
+ ALIASES                = 
+ 
+ # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources 
+ # only. Doxygen will then generate output that is more tailored for C. 
+ # For instance, some of the names that are used will be different. The list 
+ # of all members will be omitted, etc.
+ 
+ OPTIMIZE_OUTPUT_FOR_C  = NO
+ 
+ # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources 
+ # only. Doxygen will then generate output that is more tailored for Java. 
+ # For instance, namespaces will be presented as packages, qualified scopes 
+ # will look different, etc.
+ 
+ OPTIMIZE_OUTPUT_JAVA   = NO
+ 
+ # Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
+ # the same type (for instance a group of public functions) to be put as a 
+ # subgroup of that type (e.g. under the Public Functions section). Set it to 
+ # NO to prevent subgrouping. Alternatively, this can be done per class using 
+ # the \nosubgrouping command.
+ 
+ SUBGROUPING            = YES
+ 
+ #---------------------------------------------------------------------------
+ # Build related configuration options
+ #---------------------------------------------------------------------------
+ 
+ # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
+ # documentation are documented, even if no documentation was available. 
+ # Private class members and static file members will be hidden unless 
+ # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+ 
+ #builddocs will set this in doxygenbuildcfg
+ #EXTRACT_ALL            = NO
+ 
+ # If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
+ # will be included in the documentation.
+ 
+ EXTRACT_PRIVATE        = YES
+ 
+ # If the EXTRACT_STATIC tag is set to YES all static members of a file 
+ # will be included in the documentation.
+ 
+ EXTRACT_STATIC         = YES
+ 
+ # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
+ # defined locally in source files will be included in the documentation. 
+ # If set to NO only classes defined in header files are included.
+ 
+ EXTRACT_LOCAL_CLASSES  = YES
+ 
+ # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
+ # undocumented members of documented classes, files or namespaces. 
+ # If set to NO (the default) these members will be included in the 
+ # various overviews, but no documentation section is generated. 
+ # This option has no effect if EXTRACT_ALL is enabled.
+ 
+ HIDE_UNDOC_MEMBERS     = NO
+ 
+ # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
+ # undocumented classes that are normally visible in the class hierarchy. 
+ # If set to NO (the default) these classes will be included in the various 
+ # overviews. This option has no effect if EXTRACT_ALL is enabled.
+ 
+ HIDE_UNDOC_CLASSES     = NO
+ 
+ # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
+ # friend (class|struct|union) declarations. 
+ # If set to NO (the default) these declarations will be included in the 
+ # documentation.
+ 
+ HIDE_FRIEND_COMPOUNDS  = NO
+ 
+ # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
+ # documentation blocks found inside the body of a function. 
+ # If set to NO (the default) these blocks will be appended to the 
+ # function's detailed documentation block.
+ 
+ HIDE_IN_BODY_DOCS      = NO
+ 
+ # The INTERNAL_DOCS tag determines if documentation 
+ # that is typed after a \internal command is included. If the tag is set 
+ # to NO (the default) then the documentation will be excluded. 
+ # Set it to YES to include the internal documentation.
+ 
+ INTERNAL_DOCS          = NO
+ 
+ # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
+ # file names in lower-case letters. If set to YES upper-case letters are also 
+ # allowed. This is useful if you have classes or files whose names only differ 
+ # in case and if your file system supports case sensitive file names. Windows 
+ # users are advised to set this option to NO.
+ 
+ CASE_SENSE_NAMES       = YES
+ 
+ # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
+ # will show members with their full class and namespace scopes in the 
+ # documentation. If set to YES the scope will be hidden.
+ 
+ HIDE_SCOPE_NAMES       = NO
+ 
+ # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
+ # will put a list of the files that are included by a file in the documentation 
+ # of that file.
+ 
+ SHOW_INCLUDE_FILES     = YES
+ 
+ # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
+ # is inserted in the documentation for inline members.
+ 
+ INLINE_INFO            = YES
+ 
+ # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
+ # will sort the (detailed) documentation of file and class members 
+ # alphabetically by member name. If set to NO the members will appear in 
+ # declaration order.
+ 
+ SORT_MEMBER_DOCS       = YES
+ 
  # The GENERATE_TODOLIST tag can be used to enable (YES) or 
  # disable (NO) the todo list. This list is created by putting \todo 
  # commands in the documentation.
***************
*** 240,261 ****
  
  GENERATE_BUGLIST       = YES
  
! # This tag can be used to specify a number of aliases that acts 
! # as commands in the documentation. An alias has the form "name=value". 
! # For example adding "sideeffect=\par Side Effects:\n" will allow you to 
! # put the command \sideeffect (or @sideeffect) in the documentation, which 
! # will result in a user defined paragraph with heading "Side Effects:". 
! # You can put \n's in the value part of an alias to insert newlines.
  
! ALIASES                = 
  
  # The ENABLED_SECTIONS tag can be used to enable conditional 
  # documentation sections, marked by \if sectionname ... \endif.
  
! ENABLED_SECTIONS       = 
  
  # The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
! # the initial value of a variable or define consist of for it to appear in 
  # the documentation. If the initializer consists of more lines than specified 
  # here it will be hidden. Use a value of 0 to hide initializers completely. 
  # The appearance of the initializer of individual variables and defines in the 
--- 287,305 ----
  
  GENERATE_BUGLIST       = YES
  
! # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
! # disable (NO) the deprecated list. This list is created by putting 
! # \deprecated commands in the documentation.
  
! GENERATE_DEPRECATEDLIST= YES
  
  # The ENABLED_SECTIONS tag can be used to enable conditional 
  # documentation sections, marked by \if sectionname ... \endif.
  
! ENABLED_SECTIONS       =
  
  # The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
! # the initial value of a variable or define consists of for it to appear in 
  # the documentation. If the initializer consists of more lines than specified 
  # here it will be hidden. Use a value of 0 to hide initializers completely. 
  # The appearance of the initializer of individual variables and defines in the 
***************
*** 264,283 ****
  
  MAX_INITIALIZER_LINES  = 30
  
- # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources 
- # only. Doxygen will then generate output that is more tailored for C. 
- # For instance some of the names that are used will be different. The list 
- # of all members will be omitted, etc.
- 
- OPTIMIZE_OUTPUT_FOR_C  = NO
- 
- # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources 
- # only. Doxygen will then generate output that is more tailored for Java. 
- # For instance namespaces will be presented as packages, qualified scopes 
- # will look different, etc.
- 
- OPTIMIZE_OUTPUT_JAVA   = NO
- 
  # Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
  # at the bottom of the documentation of classes and structs. If set to YES the 
  # list will mention the files that were used to generate the documentation.
--- 308,313 ----
***************
*** 305,310 ****
--- 335,347 ----
  
  WARN_IF_UNDOCUMENTED   = YES
  
+ # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
+ # potential errors in the documentation, such as not documenting some 
+ # parameters in a documented function, or documenting parameters that 
+ # don't exist or using markup commands wrongly.
+ 
+ WARN_IF_DOC_ERROR      = YES
+ 
  # The WARN_FORMAT tag determines the format of the warning messages that 
  # doxygen can produce. The string should contain the $file, $line, and $text 
  # tags, which will be replaced by the file and line number from which the 
***************
*** 335,341 ****
  # and *.h) to filter out the source-files in the directories. If left 
  # blank the following patterns are tested: 
  # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp 
! # *.h++ *.idl *.odl
  
  FILE_PATTERNS          = 
  
--- 372,378 ----
  # and *.h) to filter out the source-files in the directories. If left 
  # blank the following patterns are tested: 
  # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp 
! # *.h++ *.idl *.odl *.cs *.php *.php3 *.inc
  
  FILE_PATTERNS          = 
  
***************
*** 350,356 ****
  # subdirectory from a directory tree whose root is specified with the INPUT tag.
  
  #builddocs will set this in doxygenbuildcfg
! #EXCLUDE                = header.h implementation.cc
  
  # The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories 
  # that are symbolic links (a Unix filesystem feature) are excluded from the input.
--- 387,393 ----
  # subdirectory from a directory tree whose root is specified with the INPUT tag.
  
  #builddocs will set this in doxygenbuildcfg
! #EXCLUDE                = 
  
  # The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories 
  # that are symbolic links (a Unix filesystem feature) are excluded from the input.
***************
*** 361,367 ****
  # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
  # certain files from those directories.
  
! EXCLUDE_PATTERNS       = */Vision/cmv*.h */Vision/colors.h
  
  # The EXAMPLE_PATH tag can be used to specify one or more files or 
  # directories that contain example code fragments that are included (see 
--- 398,405 ----
  # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
  # certain files from those directories.
  
! EXCLUDE_PATTERNS       = */Vision/cmv*.h \
!                          */Vision/colors.h
  
  # The EXAMPLE_PATH tag can be used to specify one or more files or 
  # directories that contain example code fragments that are included (see 
***************
*** 400,406 ****
  
  # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
  # INPUT_FILTER) will be used to filter the input files when producing source 
! # files to browse.
  
  FILTER_SOURCE_FILES    = NO
  
--- 438,444 ----
  
  # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
  # INPUT_FILTER) will be used to filter the input files when producing source 
! # files to browse (i.e. when SOURCE_BROWSER is set to YES).
  
  FILTER_SOURCE_FILES    = NO
  
***************
*** 418,423 ****
--- 456,467 ----
  
  INLINE_SOURCES         = NO
  
+ # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
+ # doxygen to hide any special comment blocks from generated source code 
+ # fragments. Normal C and C++ comments will always remain visible.
+ 
+ STRIP_CODE_COMMENTS    = NO
+ 
  # If the REFERENCED_BY_RELATION tag is set to YES (the default) 
  # then for each documented function all documented 
  # functions referencing it will be listed.
***************
*** 430,435 ****
--- 474,485 ----
  
  REFERENCES_RELATION    = YES
  
+ # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
+ # will generate a verbatim copy of the header file for each class for 
+ # which an include is specified. Set to NO to disable this.
+ 
+ VERBATIM_HEADERS       = YES
+ 
  #---------------------------------------------------------------------------
  # configuration options related to the alphabetical class index
  #---------------------------------------------------------------------------
***************
*** 467,473 ****
  # put in front of it. If left blank `html' will be used as the default path.
  
  #builddocs will set this in doxygenbuildcfg
! #HTML_OUTPUT            = Tekkotsu
  
  # The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
  # each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
--- 517,523 ----
  # put in front of it. If left blank `html' will be used as the default path.
  
  #builddocs will set this in doxygenbuildcfg
! #HTML_OUTPUT            = html
  
  # The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
  # each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
***************
*** 487,493 ****
  
  HTML_FOOTER            = doxygenfoot.html
  
! # The HTML_STYLESHEET tag can be used to specify a user defined cascading 
  # style sheet that is used by each HTML page. It can be used to 
  # fine-tune the look of the HTML output. If the tag is left blank doxygen 
  # will generate a default style sheet
--- 537,543 ----
  
  HTML_FOOTER            = doxygenfoot.html
  
! # The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
  # style sheet that is used by each HTML page. It can be used to 
  # fine-tune the look of the HTML output. If the tag is left blank doxygen 
  # will generate a default style sheet
***************
*** 516,523 ****
  
  # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
  # be used to specify the location (absolute path including file name) of 
! # the HTML help compiler (hhc.exe). If non empty doxygen will try to run 
! # the html help compiler on the generated index.hhp.
  
  HHC_LOCATION           = 
  
--- 566,573 ----
  
  # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
  # be used to specify the location (absolute path including file name) of 
! # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
! # the HTML help compiler on the generated index.hhp.
  
  HHC_LOCATION           = 
  
***************
*** 534,540 ****
  BINARY_TOC             = NO
  
  # The TOC_EXPAND flag can be set to YES to add extra items for group members 
! # to the contents of the Html help documentation and to the tree view.
  
  TOC_EXPAND             = NO
  
--- 584,590 ----
  BINARY_TOC             = NO
  
  # The TOC_EXPAND flag can be set to YES to add extra items for group members 
! # to the contents of the HTML help documentation and to the tree view.
  
  TOC_EXPAND             = NO
  
***************
*** 552,564 ****
  # If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
  # generated containing a tree-like index structure (just like the one that 
  # is generated for HTML Help). For this to work a browser that supports 
! # JavaScript and frames is required (for instance Mozilla, Netscape 4.0+, 
! # or Internet explorer 4.0+). Note that for large projects the tree generation 
! # can take a very long time. In such cases it is better to disable this feature. 
! # Windows users are probably better off using the HTML help feature.
  
  #builddocs will set this in doxygenbuildcfg
! #GENERATE_TREEVIEW      = NO
  
  # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
  # used to set the initial width (in pixels) of the frame in which the tree 
--- 602,613 ----
  # If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
  # generated containing a tree-like index structure (just like the one that 
  # is generated for HTML Help). For this to work a browser that supports 
! # JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, 
! # Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are 
! # probably better off using the HTML help feature.
  
  #builddocs will set this in doxygenbuildcfg
! #GENERATE_TREEVIEW      = YES
  
  # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
  # used to set the initial width (in pixels) of the frame in which the tree 
***************
*** 573,579 ****
  # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
  # generate Latex output.
  
! GENERATE_LATEX         = NO
  
  # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
  # If a relative path is entered the value of OUTPUT_DIRECTORY will be 
--- 622,628 ----
  # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
  # generate Latex output.
  
! GENERATE_LATEX         = YES
  
  # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
  # If a relative path is entered the value of OUTPUT_DIRECTORY will be 
***************
*** 581,587 ****
  
  LATEX_OUTPUT           = latex
  
! # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be invoked. If left blank `latex' will be used as the default command name.
  
  LATEX_CMD_NAME         = latex
  
--- 630,637 ----
  
  LATEX_OUTPUT           = latex
  
! # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
! # invoked. If left blank `latex' will be used as the default command name.
  
  LATEX_CMD_NAME         = latex
  
***************
*** 635,640 ****
--- 685,696 ----
  
  LATEX_BATCHMODE        = NO
  
+ # If LATEX_HIDE_INDICES is set to YES then doxygen will not 
+ # include the index chapters (such as File Index, Compound Index, etc.) 
+ # in the output.
+ 
+ LATEX_HIDE_INDICES     = NO
+ 
  #---------------------------------------------------------------------------
  # configuration options related to the RTF output
  #---------------------------------------------------------------------------
***************
*** 717,722 ****
--- 773,796 ----
  
  GENERATE_XML           = NO
  
+ # The XML_OUTPUT tag is used to specify where the XML pages will be put. 
+ # If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+ # put in front of it. If left blank `xml' will be used as the default path.
+ 
+ XML_OUTPUT             = xml
+ 
+ # The XML_SCHEMA tag can be used to specify an XML schema, 
+ # which can be used by a validating XML parser to check the 
+ # syntax of the XML files.
+ 
+ XML_SCHEMA             = 
+ 
+ # The XML_DTD tag can be used to specify an XML DTD, 
+ # which can be used by a validating XML parser to check the 
+ # syntax of the XML files.
+ 
+ XML_DTD                = 
+ 
  #---------------------------------------------------------------------------
  # configuration options for the AutoGen Definitions output
  #---------------------------------------------------------------------------
***************
*** 730,735 ****
--- 804,842 ----
  GENERATE_AUTOGEN_DEF   = NO
  
  #---------------------------------------------------------------------------
+ # configuration options related to the Perl module output
+ #---------------------------------------------------------------------------
+ 
+ # If the GENERATE_PERLMOD tag is set to YES Doxygen will 
+ # generate a Perl module file that captures the structure of 
+ # the code including all documentation. Note that this 
+ # feature is still experimental and incomplete at the 
+ # moment.
+ 
+ GENERATE_PERLMOD       = NO
+ 
+ # If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
+ # the necessary Makefile rules, Perl scripts and LaTeX code to be able 
+ # to generate PDF and DVI output from the Perl module output.
+ 
+ PERLMOD_LATEX          = NO
+ 
+ # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
+ # nicely formatted so it can be parsed by a human reader.  This is useful 
+ # if you want to understand what is going on.  On the other hand, if this 
+ # tag is set to NO the size of the Perl module output will be much smaller 
+ # and Perl will parse it just the same.
+ 
+ PERLMOD_PRETTY         = YES
+ 
+ # The names of the make variables in the generated doxyrules.make file 
+ # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
+ # This is useful so different doxyrules.make files included by the same 
+ # Makefile don't overwrite each other's variables.
+ 
+ PERLMOD_MAKEVAR_PREFIX = 
+ 
+ #---------------------------------------------------------------------------
  # Configuration options related to the preprocessor   
  #---------------------------------------------------------------------------
  
***************
*** 776,789 ****
  # or name=definition (no spaces). If the definition and the = are 
  # omitted =1 is assumed.
  
! PREDEFINED             = DEBUG PLATFORM_APERIOS
  
! # If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then 
  # this tag can be used to specify a list of macro names that should be expanded. 
  # The macro definition that is found in the sources will be used. 
  # Use the PREDEFINED tag if you want to use a different macro definition.
  
! EXPAND_AS_DEFINED      = REGDEFNOMEM REGDEF REGIMP
  
  # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
  # doxygen's preprocessor will remove all function-like macros that are alone 
--- 883,899 ----
  # or name=definition (no spaces). If the definition and the = are 
  # omitted =1 is assumed.
  
! PREDEFINED             = DEBUG \
!                          PLATFORM_APERIOS
  
! # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
  # this tag can be used to specify a list of macro names that should be expanded. 
  # The macro definition that is found in the sources will be used. 
  # Use the PREDEFINED tag if you want to use a different macro definition.
  
! EXPAND_AS_DEFINED      = REGDEFNOMEM \
!                          REGDEF \
!                          REGIMP
  
  # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
  # doxygen's preprocessor will remove all function-like macros that are alone 
***************
*** 797,803 ****
  # Configuration::addtions related to external references   
  #---------------------------------------------------------------------------
  
! # The TAGFILES tag can be used to specify one or more tagfiles.
  
  TAGFILES               = 
  
--- 907,926 ----
  # Configuration::addtions related to external references   
  #---------------------------------------------------------------------------
  
! # The TAGFILES option can be used to specify one or more tagfiles. 
! # Optionally an initial location of the external documentation 
! # can be added for each tagfile. The format of a tag file without 
! # this location is as follows: 
! #   TAGFILES = file1 file2 ... 
! # Adding location for the tag files is done as follows: 
! #   TAGFILES = file1=loc1 "file2 = loc2" ... 
! # where "loc1" and "loc2" can be relative or absolute paths or 
! # URLs. If a location is present for each tag, the installdox tool 
! # does not have to be run to correct the links.
! # Note that each tag file must have a unique name
! # (where the name does NOT include the path)
! # If a tag file is not located in the directory in which doxygen 
! # is run, you must also specify the path to the tagfile here.
  
  TAGFILES               = 
  
***************
*** 828,837 ****
  #---------------------------------------------------------------------------
  
  # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
! # generate a inheritance diagram (in Html, RTF and LaTeX) for classes with base or 
  # super classes. Setting the tag to NO turns the diagrams off. Note that this 
  # option is superceded by the HAVE_DOT option below. This is only a fallback. It is 
! # recommended to install and use dot, since it yield more powerful graphs.
  
  CLASS_DIAGRAMS         = YES
  
--- 951,960 ----
  #---------------------------------------------------------------------------
  
  # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
! # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or 
  # super classes. Setting the tag to NO turns the diagrams off. Note that this 
  # option is superceded by the HAVE_DOT option below. This is only a fallback. It is 
! # recommended to install and use dot, since it yields more powerful graphs.
  
  CLASS_DIAGRAMS         = YES
  
***************
*** 862,867 ****
--- 985,996 ----
  
  COLLABORATION_GRAPH    = NO
  
+ # If the UML_LOOK tag is set to YES doxygen will generate inheritance and 
+ # collaboration diagrams in a style similiar to the OMG's Unified Modeling 
+ # Language.
+ 
+ UML_LOOK               = NO
+ 
  # If set to YES, the inheritance and collaboration graphs will show the 
  # relations between templates and their instances.
  
***************
*** 881,886 ****
--- 1010,1023 ----
  
  INCLUDED_BY_GRAPH      = YES
  
+ # If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will 
+ # generate a call dependency graph for every global function or class method. 
+ # Note that enabling this option will significantly increase the time of a run. 
+ # So in most cases it will be better to enable call graphs for selected 
+ # functions only using the \callgraph command.
+ 
+ CALL_GRAPH             = YES
+ 
  # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
  # will graphical hierarchy of all classes instead of a textual one.
  
***************
*** 919,924 ****
--- 1056,1072 ----
  
  MAX_DOT_GRAPH_HEIGHT   = 512
  
+ # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 
+ # graphs generated by dot. A depth value of 3 means that only nodes reachable 
+ # from the root by following a path via at most 3 edges will be shown. Nodes that 
+ # lay further from the root node will be omitted. Note that setting this option to 
+ # 1 or 2 may greatly reduce the computation time needed for large code bases. Also 
+ # note that a graph may be further truncated if the graph's image dimensions are 
+ # not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT). 
+ # If 0 is used for the depth value (the default), the graph is not depth-constrained.
+ 
+ MAX_DOT_GRAPH_DEPTH    = 0
+ 
  # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
  # generate a legend page explaining the meaning of the various boxes and 
  # arrows in the dot generated graphs.
***************
*** 926,932 ****
  GENERATE_LEGEND        = YES
  
  # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
! # remove the intermedate dot files that are used to generate 
  # the various graphs.
  
  DOT_CLEANUP            = YES
--- 1074,1080 ----
  GENERATE_LEGEND        = YES
  
  # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
! # remove the intermediate dot files that are used to generate 
  # the various graphs.
  
  DOT_CLEANUP            = YES
***************
*** 941,979 ****
  #builddocs will set this in doxygenbuildcfg
  #SEARCHENGINE           = YES
  
! # The CGI_NAME tag should be the name of the CGI script that 
! # starts the search engine (doxysearch) with the correct parameters. 
! # A script with this name will be generated by doxygen.
! 
! CGI_NAME               = apsearch.cgi
! 
! # The CGI_URL tag should be the absolute URL to the directory where the 
! # cgi binaries are located. See the documentation of your http daemon for 
! # details.
! 
! CGI_URL                = http://Tekkotsu.no-ip.org/cgi-bin/
! 
! # The DOC_URL tag should be the absolute URL to the directory where the 
! # documentation is located. If left blank the absolute path to the 
! # documentation, with file:// prepended to it, will be used.
! 
! DOC_URL                = http://Tekkotsu.no-ip.org/Tekkotsu/
! 
! # The DOC_ABSPATH tag should be the absolute path to the directory where the 
! # documentation is located. If left blank the directory on the local machine 
! # will be used.
! 
! DOC_ABSPATH            = 
! 
! # The BIN_ABSPATH tag must point to the directory where the doxysearch binary 
! # is installed.
! 
! BIN_ABSPATH            = /usr0/doxygen/bin
! 
! # The EXT_DOC_PATHS tag can be used to specify one or more paths to 
! # documentation generated for other projects. This allows doxysearch to search 
! # the documentation for these projects as well.
! 
! EXT_DOC_PATHS          = 
  
  @INCLUDE = doxygenbuildcfg
--- 1089,1097 ----
  #builddocs will set this in doxygenbuildcfg
  #SEARCHENGINE           = YES
  
! #---------------------------------------------------------------------------
! # Custom inclusions - doxygenbuildcfg is created by the builddocs script
! #---------------------------------------------------------------------------
  
  @INCLUDE = doxygenbuildcfg
+ 
Index: AiboPup/docs/doxygenhead.html
diff -c AiboPup/docs/doxygenhead.html:1.4 AiboPup/docs/doxygenhead.html:1.5
*** AiboPup/docs/doxygenhead.html:1.4	Mon Apr  7 01:54:17 2003
--- AiboPup/docs/doxygenhead.html	Fri Jul 18 23:48:41 2003
***************
*** 4,49 ****
  		<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
  		<title>$title</title>
  		<link href="doxygen.css" rel="stylesheet" type="text/css">
! 		<link rel="home" href="../index.html">
  		<link rel="up" href="index.html">
  		<link rel="SHORTCUT ICON" href="favicon.ico">
  	</head>
  	<body>
! 		<img src="aibosmall.jpg" width=92 height=75 align=right>
  		<table cellpadding="1" cellspacing="6" border="0"
  					 style="text-align: left; margin-left: auto; margin-right: auto;">
  			<tbody>
  				<tr>
! <!-- #Homepage# --> <td style="vertical-align: top;"><a href="../index.html">Homepage</a></td>
! <!-- #Bar# --> <td
!  style="vertical-align: top; background-color: rgb(0, 0, 0);"><br>
!       </td>
! <!-- #Demos# --> <td style="vertical-align: top;"><a href="../Samples.html">Demos</a></td>
! <!-- #Bar# --> <td
!  style="vertical-align: top; background-color: rgb(0, 0, 0);"><br>
!       </td>
! <!-- #Overview# --> <td style="vertical-align: top;"><a
!  href="../Overview.html">Overview</a></td>
! <!-- #Bar# --> <td
!  style="vertical-align: top; background-color: rgb(0, 0, 0);"><br>
!       </td>
! <!-- #Downloads# --> <td style="vertical-align: top;"><a
!  href="../VersionHistory.html">Downloads</a></td>
! <!-- #Bar# --> <td
!  style="vertical-align: top; background-color: rgb(0, 0, 0);"><br>
!       </td>
! <!-- #Tutorials# --> <td style="vertical-align: top;"><a
!  href="../Tutorials.html">Tutorials</a></td>
! <!-- #Bar# --> <td
!  style="vertical-align: top; background-color: rgb(0, 0, 0);"><br>
!       </td>
! <!-- #Current# -->
! <!-- #Reference# --> <td style="vertical-align: top;"><i>Reference</i></td>
! <!-- #Bar# --> <td
!  style="vertical-align: top; background-color: rgb(0, 0, 0);"><br>
!       </td>
! <!-- #Credits# --> <td style="vertical-align: top;"><a
!  href="../Credits.html">Credits</a> </td>
  				</tr>
  			</tbody>
  		</table>
--- 4,32 ----
  		<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
  		<title>$title</title>
  		<link href="doxygen.css" rel="stylesheet" type="text/css">
! 		<link rel="home" href="http://www.tekkotsu.org/index.html">
  		<link rel="up" href="index.html">
  		<link rel="SHORTCUT ICON" href="favicon.ico">
  	</head>
  	<body>
! 		<img src="http://www.tekkotsu.org/dox/aibosmall.jpg" width=92 height=75 align=right>
  		<table cellpadding="1" cellspacing="6" border="0"
  					 style="text-align: left; margin-left: auto; margin-right: auto;">
  			<tbody>
  				<tr>
! 					<!-- #Homepage# --> <td style="vertical-align: top;"><a target="_top" href="http://www.tekkotsu.org/index.html">Homepage</a></td>
! 					<!-- #Bar# --> <td style="vertical-align: top; background-color: rgb(0, 0, 0);"></td>
! 					<!-- #Demos# --> <td style="vertical-align: top;"><a target="_top" href="http://www.tekkotsu.org/Samples.html">Demos</a></td>
! 					<!-- #Bar# --> <td style="vertical-align: top; background-color: rgb(0, 0, 0);"></td>
! 					<!-- #Overview# --> <td style="vertical-align: top;"><a target="_top" href="http://www.tekkotsu.org/Overview.html">Overview</a></td>
! 					<!-- #Bar# --> <td style="vertical-align: top; background-color: rgb(0, 0, 0);"></td>
! 					<!-- #Downloads# --> <td style="vertical-align: top;"><a target="_top" href="http://www.tekkotsu.org/VersionHistory.html">Downloads</a></td>
! 					<!-- #Bar# --> <td style="vertical-align: top; background-color: rgb(0, 0, 0);"></td>
! 					<!-- #Tutorials# --> <td style="vertical-align: top;"><a target="_top" href="http://www.tekkotsu.org/Tutorials.html">Tutorials</a></td>
! 					<!-- #Bar# --> <td style="vertical-align: top; background-color: rgb(0, 0, 0);"></td>
! 					<!-- #Current# --><!-- #Reference# --> <td style="vertical-align: top;"><i>Reference</i></td>
! 					<!-- #Bar# --> <td style="vertical-align: top; background-color: rgb(0, 0, 0);"><br></td>
! 					<!-- #Credits# --> <td style="vertical-align: top;"><a target="_top" href="http://www.tekkotsu.org/Credits.html">Credits</a> </td>
  				</tr>
  			</tbody>
  		</table>
Index: AiboPup/docs/implementation.cc
diff -c AiboPup/docs/implementation.cc:1.1 AiboPup/docs/implementation.cc:1.2
*** AiboPup/docs/implementation.cc:1.1	Mon Feb 24 05:35:06 2003
--- AiboPup/docs/implementation.cc	Thu Sep 25 11:32:14 2003
***************
*** 5,13 ****
   * @author YOURNAMEHERE (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
--- 5,13 ----
   * @author YOURNAMEHERE (Creator)
   *
   * $Author: ejt $
!  * $Name: HEAD $
!  * $Revision: 1.2 $
   * $State: Exp $
!  * $Date: 2003/10/10 20:25:03 $
   */
  
Index: AiboPup/docs/profilerun_1.5.txt
diff -c /dev/null AiboPup/docs/profilerun_1.5.txt:1.1
*** /dev/null	Fri Oct 10 14:37:49 2003
--- AiboPup/docs/profilerun_1.5.txt	Fri Oct 10 11:54:20 2003
***************
*** 0 ****
--- 1,65 ----
+ Setup:
+   Default build for ERS-2xx
+   Pink ball in view (8.5in from snout)
+   Press power button, start timer
+   Telnet to system console (port 59000)
+ 	Connect ControllerGUI
+   STARTUP script:
+     Launch StareAtBallBehavior (leave E-Stop ON)
+     Navigate to Status Reports -> Profiler
+   Wait until 5 minutes from initial press of power button.
+   Recorded profiler run shown below
+ 
+ ~~~ Main: ~~~
+ Profiling information since: 21.308397 to 301.154604
+ ReadySendJoints():
+         2166 calls
+         0.464783 ms avg
+         0.466646 ms exp.avg
+         0.001892 ms avg child time (0.400000%)
+         0.128692 ms avg inter (7.770471 fps)
+         0.128015 ms exp.avg (7.811559 fps)
+         Exec: 0 0 2132 28 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
+         Inter: 0 1 0 1 0 0 0 0 0 1 1743 418 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 
+ GotSensorFrame():
+         8651 calls
+         1.261532 ms avg
+         1.127146 ms exp.avg
+         0.000000 ms avg child time (0.000000%)
+         0.032192 ms avg inter (31.063535 fps)
+         0.031483 ms exp.avg (31.762732 fps)
+         Exec: 0 0 4685 1137 2821 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
+         Inter: 0 0 0 0 1 34 1699 3422 3492 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 
+ PowerEvent():
+         40 calls
+         48.219025 ms avg
+         3.852258 ms exp.avg
+         0.000000 ms avg child time (0.000000%)
+         6.841377 ms avg inter (0.146169 fps)
+         8.272842 ms exp.avg (0.120877 fps)
+         Exec: 0 0 35 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 
+         Inter: 0 0 0 0 0 0 0 0 0 0 0 2 0 1 0 0 0 0 0 0 3 18 0 0 0 2 0 2 0 1 0 10 
+ GotImage():
+         6906 calls
+         17.643117 ms avg
+         18.216816 ms exp.avg
+         0.000000 ms avg child time (0.000000%)
+         0.040067 ms avg inter (24.958427 fps)
+         0.040390 ms exp.avg (24.758671 fps)
+         Exec: 0 0 0 0 0 0 6840 63 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
+         Inter: 0 0 0 0 0 0 0 10 6894 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
+ Bucket distribution (in ms):
+         0<0.00802, <0.133, <0.686, <2.2, <5.43, <11.4, <21.2, <36.4, <58.7, <90, <132, <188, <260, <352, <465, <604, <772, <973, <1.21e+03, <1.49e+03, <1.82e+03, <2.19e+03, <2.63e+03, <3.12e+03, <3.68e+03, <4.31e+03, <5.03e+03, <5.82e+03, <6.71e+03, <7.7e+03, <8.79e+03, <1e+04, 
+ ~~~ Motion: ~~~
+ Profiling information since: 21.309742 to 301.171805
+ ReadySendJoints():
+         8680 calls
+         2.581590 ms avg
+         2.339066 ms exp.avg
+         0.000000 ms avg child time (0.000000%)
+         0.032098 ms avg inter (31.154166 fps)
+         0.032084 ms exp.avg (31.168249 fps)
+         Exec: 0 0 0 3662 4956 41 3 0 0 4 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
+         Inter: 0 0 0 0 0 0 0 8661 0 4 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
+ Bucket distribution (in ms):
+         0<0.00802, <0.133, <0.686, <2.2, <5.43, <11.4, <21.2, <36.4, <58.7, <90, <132, <188, <260, <352, <465, <604, <772, <973, <1.21e+03, <1.49e+03, <1.82e+03, <2.19e+03, <2.63e+03, <3.12e+03, <3.68e+03, <4.31e+03, <5.03e+03, <5.82e+03, <6.71e+03, <7.7e+03, <8.79e+03, <1e+04, 
Index: AiboPup/docs/profilerun_supercore_1.5.txt
diff -c /dev/null AiboPup/docs/profilerun_supercore_1.5.txt:1.1
*** /dev/null	Fri Oct 10 14:37:49 2003
--- AiboPup/docs/profilerun_supercore_1.5.txt	Fri Oct 10 11:54:21 2003
***************
*** 0 ****
--- 1,65 ----
+ Setup:
+   Default build for ERS-2xx
+   Pink ball in view (8.5in from snout)
+   Press power button, start timer
+   Telnet to system console (port 59000)
+ 	Connect ControllerGUI
+   STARTUP script:
+     Launch StareAtBallBehavior (leave E-Stop ON)
+     Navigate to Status Reports -> Profiler
+   Wait until 5 minutes from initial press of power button.
+   Recorded profiler run shown below
+ 
+ ~~~ Main: ~~~
+ Profiling information since: 19.001622 to 299.518935
+ ReadySendJoints():
+         2181 calls
+         0.218475 ms avg
+         0.213048 ms exp.avg
+         0.000962 ms avg child time (0.400000%)
+         0.128268 ms avg inter (7.796156 fps)
+         0.127905 ms exp.avg (7.818315 fps)
+         Exec: 0 0 2176 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
+         Inter: 0 1 0 1 0 0 0 0 0 0 2177 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 
+ GotSensorFrame():
+         8713 calls
+         0.372159 ms avg
+         0.336552 ms exp.avg
+         0.000000 ms avg child time (0.000000%)
+         0.032097 ms avg inter (31.155296 fps)
+         0.031662 ms exp.avg (31.583469 fps)
+         Exec: 0 0 8616 95 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
+         Inter: 0 0 0 0 0 0 13 6965 1733 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 
+ GotImage():
+         6948 calls
+         8.654783 ms avg
+         9.004468 ms exp.avg
+         0.000000 ms avg child time (0.000000%)
+         0.040246 ms avg inter (24.847421 fps)
+         0.039988 ms exp.avg (25.007385 fps)
+         Exec: 0 0 0 0 0 6932 15 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
+         Inter: 0 0 0 0 0 0 1 1 6944 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 
+ PowerEvent():
+         36 calls
+         30.859333 ms avg
+         4.040380 ms exp.avg
+         0.000000 ms avg child time (0.000000%)
+         7.602424 ms avg inter (0.131537 fps)
+         5.762940 ms exp.avg (0.173523 fps)
+         Exec: 0 0 32 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 
+         Inter: 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 3 11 0 0 1 3 0 0 0 1 1 9 
+ Bucket distribution (in ms):
+         0<0.00802, <0.133, <0.686, <2.2, <5.43, <11.4, <21.2, <36.4, <58.7, <90, <132, <188, <260, <352, <465, <604, <772, <973, <1.21e+03, <1.49e+03, <1.82e+03, <2.19e+03, <2.63e+03, <3.12e+03, <3.68e+03, <4.31e+03, <5.03e+03, <5.82e+03, <6.71e+03, <7.7e+03, <8.79e+03, <1e+04, 
+ ~~~ Motion: ~~~
+ Profiling information since: 19.001708 to 299.525091
+ ReadySendJoints():
+         8726 calls
+         1.368196 ms avg
+         1.194053 ms exp.avg
+         0.000000 ms avg child time (0.000000%)
+         0.032054 ms avg inter (31.196870 fps)
+         0.031926 ms exp.avg (31.322392 fps)
+         Exec: 0 0 1 8693 13 0 0 0 0 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
+         Inter: 0 0 0 0 0 0 0 8706 0 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
+ Bucket distribution (in ms):
+         0<0.00802, <0.133, <0.686, <2.2, <5.43, <11.4, <21.2, <36.4, <58.7, <90, <132, <188, <260, <352, <465, <604, <772, <973, <1.21e+03, <1.49e+03, <1.82e+03, <2.19e+03, <2.63e+03, <3.12e+03, <3.68e+03, <4.31e+03, <5.03e+03, <5.82e+03, <6.71e+03, <7.7e+03, <8.79e+03, <1e+04, 
Index: AiboPup/docs/html/favicon.ico
Index: AiboPup/docs/html/index.html
diff -c AiboPup/docs/html/index.html:1.13 AiboPup/docs/html/index.html:1.19
*** AiboPup/docs/html/index.html:1.13	Mon Apr 14 22:33:56 2003
--- AiboPup/docs/html/index.html	Mon Oct  6 23:28:30 2003
***************
*** 1,42 ****
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  <html>
  <head>
!   <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
    <title>Tekkotsu Framework</title>
!   <link href="doxygen.css" rel="stylesheet" type="text/css">
!   <link rel="home" href="../index.html">
!   <link rel="up" href="../index.html">
!   <link rel="first" href="../index.html">
!   <link rel="last" href="../Credits.html">
!   <link rel="previous" href="../Tutorials.html">
!   <link rel="next" href="../Credits.html">
! 	<link rel="SHORTCUT ICON" href="favicon.ico">
  </head>
  <body>
! <table style="text-align: left; margin-left: auto; margin-right: auto;"
!  border="0" cellspacing="6" cellpadding="1">
    <tbody>
      <tr>
! <!-- #Homepage# --> <td style="vertical-align: top;"><a href="../index.html">Homepage</a></td>
  <!-- #Bar# --> <td
   style="vertical-align: top; background-color: rgb(0, 0, 0);"><br>
        </td>
! <!-- #Demos# --> <td style="vertical-align: top;"><a href="../Samples.html">Demos</a></td>
  <!-- #Bar# --> <td
   style="vertical-align: top; background-color: rgb(0, 0, 0);"><br>
        </td>
  <!-- #Overview# --> <td style="vertical-align: top;"><a
!  href="../Overview.html">Overview</a></td>
  <!-- #Bar# --> <td
   style="vertical-align: top; background-color: rgb(0, 0, 0);"><br>
        </td>
  <!-- #Downloads# --> <td style="vertical-align: top;"><a
!  href="../VersionHistory.html">Downloads</a></td>
  <!-- #Bar# --> <td
   style="vertical-align: top; background-color: rgb(0, 0, 0);"><br>
        </td>
  <!-- #Tutorials# --> <td style="vertical-align: top;"><a
!  href="../Tutorials.html">Tutorials</a></td>
  <!-- #Bar# --> <td
   style="vertical-align: top; background-color: rgb(0, 0, 0);"><br>
        </td>
--- 1,44 ----
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  <html>
  <head>
!   <meta content="text/html;charset=iso-8859-1" http-equiv="Content-Type">
    <title>Tekkotsu Framework</title>
!   <link type="text/css" rel="stylesheet" href="doxygen.css">
!   <link href="../index.html" rel="home">
!   <link href="../index.html" rel="up">
!   <link href="../index.html" rel="first">
!   <link href="../Credits.html" rel="last">
!   <link href="../Tutorials.html" rel="previous">
!   <link href="../Credits.html" rel="next">
!   <link href="favicon.ico" rel="SHORTCUT ICON">
  </head>
  <body>
! <table cellpadding="1" cellspacing="6" border="0"
!  style="text-align: left; margin-left: auto; margin-right: auto;">
    <tbody>
      <tr>
! <!-- #Homepage# --> <td style="vertical-align: top;"><a
!  href="../index.html" target="_top">Homepage</a></td>
  <!-- #Bar# --> <td
   style="vertical-align: top; background-color: rgb(0, 0, 0);"><br>
        </td>
! <!-- #Demos# --> <td style="vertical-align: top;"><a
!  href="../Samples.html" target="_top">Demos</a></td>
  <!-- #Bar# --> <td
   style="vertical-align: top; background-color: rgb(0, 0, 0);"><br>
        </td>
  <!-- #Overview# --> <td style="vertical-align: top;"><a
!  href="../Overview.html" target="_top">Overview</a></td>
  <!-- #Bar# --> <td
   style="vertical-align: top; background-color: rgb(0, 0, 0);"><br>
        </td>
  <!-- #Downloads# --> <td style="vertical-align: top;"><a
!  href="../QuickStart.html" target="_top">Downloads</a></td>
  <!-- #Bar# --> <td
   style="vertical-align: top; background-color: rgb(0, 0, 0);"><br>
        </td>
  <!-- #Tutorials# --> <td style="vertical-align: top;"><a
!  href="../Tutorials.html" target="_top">Tutorials</a></td>
  <!-- #Bar# --> <td
   style="vertical-align: top; background-color: rgb(0, 0, 0);"><br>
        </td>
***************
*** 46,119 ****
   style="vertical-align: top; background-color: rgb(0, 0, 0);"><br>
        </td>
  <!-- #Credits# --> <td style="vertical-align: top;"><a
!  href="../Credits.html">Credits</a> </td>
!    </tr>
    </tbody>
  </table>
! <h1><br>
! </h1>
  <center>
  <h1>Tekkotsu Source Documentation</h1>
  </center>
! <table cellpadding="2" cellspacing="2" border="0"
!  style="text-align: left; width: 620px; margin-left: auto; margin-right: auto; height: 100%;">
    <tbody>
      <tr>
        <td style="vertical-align: top;">
        <div style="text-align: center;"> </div>
!       <p style="text-align: left;">These documents will give you
  nitty-gritty details on the individual functions, classes, and data
  structures. &nbsp;It is collated from comments embedded in the source
  code by <a href="http://www.doxygen.org/">doxygen</a>.&nbsp; Expect a
  few rough edges, this started life as an internal resource.&nbsp; It's
  not that we don't know proper grammar, it's just that we'd rather be
  writing code. ;-)&nbsp; If something is unclear, please feel free to <a
!  href="../Credits.html#contact">drop us a line</a>!<br>
        </p>
!       <p style="text-align: left;">If you want a more general overview
! of what this software does and how the pieces fit together, you may want
! to visit the <a href="../Overview.html">overview</a>.<br>
        </p>
!       <h3>Documentation Contents:</h3>
!       <ul>
!         <li><a href="namespaces.html">Namespace List</a> - Lists the
! global namespaces</li>
!         <li><a href="hierarchy.html">Class Hierarchy</a> - Lists all
! classes and structs, grouped by inheritance</li>
!         <li><a href="classes.html">Alphabetical Index</a> - Lists all
! classes and structs alphabetically</li>
!         <li><a href="annotated.html">Compound List</a> - Lists all
! classes and structs alphabetically, gives a short description</li>
!         <li><a href="files.html">File List</a> - Lists all source code
! files, gives a short description</li>
!         <li><a href="namespacemembers.html">Namespace Members</a> -
! Lists the members of all namespaces</li>
!         <li><a href="functions.html">Compound Members</a> - Lists the
! member functions and variables of all classes</li>
!         <li><a href="globals.html">File Members</a> - Lists the global
! variables and macros across all files</li>
!         <li><a href="pages.html">Related Pages</a> - Links to the <a
!  href="todo.html">todo</a> and bug lists.<br>
!         </li>
        </ul>
!       <p> This code is originally based on an early version of CMU's
  2002 Legged RoboSoccer entry, <a
   href="http://www-2.cs.cmu.edu/%7Erobosoccer/legged/legged-team.html">CMPack</a>.
! &nbsp;<a href="classWalkMC.html">WalkMC</a> and the <a
!  href="http://www.cs.cmu.edu/%7Ejbruce/cmvision">CMVision</a> library
! still fall under their <a href="../CMPack_license.txt">license</a>.
  &nbsp;This license is also included in the files themselves.<br>
        </p>
!       <p>Note that CMVision is not documented in this project.&nbsp;
  There is some documentation as <a
   href="http://www-2.cs.cmu.edu/%7Ejbruce/cmvision/papers/JBThesis00.ps.gz">compressed
  postscript</a> and <a
!  href="http://www-2.cs.cmu.edu/%7Ejbruce/cmvision/papers/JBThesis00.pdf">PDF</a>.<br>
!       </p>
!       <p>You can regenerate a local copy of these pages if you install
! the doxygen package. &nbsp;A nice reason to do this is you can build a
! searchable database to run on your local web server. &nbsp;This file is
! found at docs/index.html, which overwrites the doxygen generated page.<br>
        </p>
        </td>
      </tr>
--- 48,160 ----
   style="vertical-align: top; background-color: rgb(0, 0, 0);"><br>
        </td>
  <!-- #Credits# --> <td style="vertical-align: top;"><a
!  href="../Credits.html" target="_top">Credits</a> </td>
!     </tr>
    </tbody>
  </table>
! <div style="text-align: center;"><a class="qindex" href="main.html">Main&nbsp;Page</a>
! | <a class="qindexHL" href="namespaces.html">Namespace List</a> | <a
!  class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a
!  class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a
!  class="qindex" href="annotated.html">Class&nbsp;List</a> | <a
!  class="qindex" href="files.html">File&nbsp;List</a> | <a
!  class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a>
! | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a
!  class="qindex" href="globals.html">File&nbsp;Members</a> | <a
!  class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
  <center>
  <h1>Tekkotsu Source Documentation</h1>
  </center>
! <table
!  style="text-align: left; width: 620px; margin-left: auto; margin-right: auto; height: 100%;"
!  border="0" cellspacing="2" cellpadding="2">
    <tbody>
      <tr>
        <td style="vertical-align: top;">
        <div style="text-align: center;"> </div>
!       <p style="text-align: center;"><a target="_top" href="index.html">Frames</a>
! | <a target="_top" href="main.html">No Frames</a><br>
!       </p>
!       <h3>Documentation Contents:</h3>
!       <p style="margin-left: 40px;">If you want a more general overview
! of what this software does and how the pieces fit together, you may
! want
! to visit the <a target="_top" href="../Overview.html">overview</a>.</p>
!       <ul style="margin-left: 40px;">
!         <li><a href="classes.htm">Alphabetical Index</a> - Lists all
! classes and structs<br>
!         </li>
!         <li><a href="annotated.html">Compound List</a> - Gives a short
! description of each class and struct<br>
!         </li>
!         <li><a href="namespacemembers.html">Namespace Members</a> -
! Lists the global constants which are organized into namespaces</li>
!         <li><a href="globals.html">File Members</a> - Lists all of the
! global
! variables and macros which aren't in namespaces<br>
!         </li>
!         <li><a href="pages.html">Related Pages</a> - Links to the <a
!  href="todo.html">todo</a> and <a href="bug.htm">bug</a> lists.</li>
!         <li>You can also search the framework:<br>
!           <form action="search.php" method="get" name="doxyform"><input
!  value="0" name="page" type="hidden"><input value="" maxlength="1000"
!  wrap="virtual" size="44" name="query"><input alt="Search" title=""
!  name="search" border="0" width="74" height="16" src="search.png"
!  type="image"><a
!  href="http://cvs.tekkotsu.org/cgi-bin/search.cgi?help=on"><font
!  size="-1"></font></a><br>
!           </form>
!         </li>
!       </ul>
!       <ul style="margin-left: 40px;">
!       </ul>
!       <div style="margin-left: 40px;"> </div>
!       <p style="margin-left: 40px;">These documents will give you
  nitty-gritty details on the individual functions, classes, and data
  structures. &nbsp;It is collated from comments embedded in the source
  code by <a href="http://www.doxygen.org/">doxygen</a>.&nbsp; Expect a
  few rough edges, this started life as an internal resource.&nbsp; It's
  not that we don't know proper grammar, it's just that we'd rather be
  writing code. ;-)&nbsp; If something is unclear, please feel free to <a
!  href="file:///usr0/ejt/Tekkotsu/docs/Credits.html#contact">drop us a
! line</a>!<br>
        </p>
!       <h3>Documentation Download:</h3>
!       <p style="margin-left: 40px;">If you would like to obtain local
! static copies of the documentation, there are two formats:<br>
        </p>
!       <ul style="margin-left: 40px;">
!         <li><a href="../media/Tekkotsu_doc_1.5.tar.gz">HTML</a> (v1.5,
! 3.0MB)</li>
!         <li><a href="../media/Tekkotsu_doc_1.5.pdf">PDF</a> (v1.5,
! 9.8MB)</li>
        </ul>
!       <div style="margin-left: 40px;">If you're using the most recent
! version from the <a href="http://cvs.tekkotsu.org/">CVS repository</a>,
! you can build the corresponding documentation locally by typing <span
!  style="font-family: monospace;">make docs</span> in the root Tekkotsu
! directory.<br>
!       </div>
!       <h3>External Documentation:<br>
!       </h3>
!       <p style="margin-left: 40px;"> This code is originally based on
! an early version of CMU's
  2002 Legged RoboSoccer entry, <a
   href="http://www-2.cs.cmu.edu/%7Erobosoccer/legged/legged-team.html">CMPack</a>.
! &nbsp;<a href="file:///usr0/ejt/Tekkotsu/docs/html/classWalkMC.html">WalkMC</a>
! and the <a href="http://www.cs.cmu.edu/%7Ejbruce/cmvision">CMVision</a>
! library
! still fall under their <a
!  href="file:///usr0/ejt/Tekkotsu/docs/CMPack_license.txt">license</a>.
  &nbsp;This license is also included in the files themselves.<br>
        </p>
!       <p style="margin-left: 40px;"> Note that CMVision is not
! documented in this project.&nbsp;
  There is some documentation as <a
   href="http://www-2.cs.cmu.edu/%7Ejbruce/cmvision/papers/JBThesis00.ps.gz">compressed
  postscript</a> and <a
!  href="http://www-2.cs.cmu.edu/%7Ejbruce/cmvision/papers/JBThesis00.pdf">PDF</a>.</p>
!       <p><br>
        </p>
        </td>
      </tr>
***************
*** 124,138 ****
  <br>
  <br>
  <br>
! <br>
! Last Modified: $Date: 2003/10/10 20:25:03 $ GMT
  &nbsp;
! <script type="text/javascript" language="javascript">
  <!--
  s="na";c="na";j="na";f=""+escape(document.referrer)
  //-->
  </script>
! <script type="text/javascript" language="javascript1.2">
  <!--
  s=screen.width;v=navigator.appName
  if (v != "Netscape") {c=screen.colorDepth}
--- 165,184 ----
  <br>
  <br>
  <br>
! </span></small>
! <div style="text-align: center;"><small>This file is
! found at <span style="font-family: monospace;">docs/html/index.html</span>,
! which overwrites the doxygen generated page.</small><br>
! </div>
! <small><span style="font-style: italic;">Last Modified: $Date:
! 2003/04/15 02:33:56 $ GMT
  &nbsp;
! <script language="javascript" type="text/javascript">
  <!--
  s="na";c="na";j="na";f=""+escape(document.referrer)
  //-->
  </script>
! <script language="javascript1.2" type="text/javascript">
  <!--
  s=screen.width;v=navigator.appName
  if (v != "Netscape") {c=screen.colorDepth}
***************
*** 140,146 ****
  j=navigator.javaEnabled()
  //-->
  </script>
! <script type="text/javascript" language="javascript">
  <!--
  function pr(n) {document.write(n,"\n");}
  NS2Ch=0
--- 186,192 ----
  j=navigator.javaEnabled()
  //-->
  </script>
! <script language="javascript" type="text/javascript">
  <!--
  function pr(n) {document.write(n,"\n");}
  NS2Ch=0
***************
*** 150,161 ****
  r="size="+s+"&colors="+c+"&referer="+f+"&java="+j+"&stamp="+(new Date()).getTime()+""
  pr("<IMG BORDER=0 width=16 height=16 align=\"middle\" SRC=\"http://aibo2.boltz.cs.cmu.edu/head.gif?"+r+"\">")}
  //-->
! </script> 
! 
! <noscript>
! <img src="http://aibo2.boltz.cs.cmu.edu/head.gif" border="0" width=16 height=16 align="middle">
  </noscript>
- 
  </span></small></div>
  </body>
  </html>
--- 196,205 ----
  r="size="+s+"&colors="+c+"&referer="+f+"&java="+j+"&stamp="+(new Date()).getTime()+""
  pr("<IMG BORDER=0 width=16 height=16 align=\"middle\" SRC=\"http://aibo2.boltz.cs.cmu.edu/head.gif?"+r+"\">")}
  //-->
! </script>
! <noscript><img src="http://aibo2.boltz.cs.cmu.edu/head.gif" border="0"
! width=16 height=16 align="middle">
  </noscript>
  </span></small></div>
  </body>
  </html>
Index: AiboPup/project/Makefile
diff -c AiboPup/project/Makefile:1.24 AiboPup/project/Makefile:1.46
*** AiboPup/project/Makefile:1.24	Mon Jul  7 14:08:13 2003
--- AiboPup/project/Makefile	Thu Oct  9 20:45:32 2003
***************
*** 1,39 ****
  all:
  
! TEKKOTSU_ROOT?=/usr/local/Tekkotsu
! MEMSTICK_ROOT?=/mnt/memstick
! TEKKOTSU_TARGET_MODEL?=TGT_ERS2xx
  
! # Find all of the source files: (outside of build directory)
  
  BUILDDIR=build
  $(shell mkdir -p $(BUILDDIR))
  SRCSUFFIX=.cc
! SRCS:=$(shell find . -name "*$(SRCSUFFIX)" \! -path "*/$(BUILDDIR)/*")
! OBJS:=$(foreach file,$(SRCS),$(addsuffix .o,$(basename $(file))))
! DEPENDS:=$(foreach file,$(SRCS),$(addsuffix .d,$(basename $(file))))
! 
! # We're assuming all of the source files we found are to be linked into MMCombo
! # It should be pretty easy to add a new process here if you're inclined to do so.
! 
! # It's important that the process names and variables are the same case as your
! # memory stick reader - memsticks don't store case, and some drivers may convert
! # all file names to uppercase, others to lower case.  Ours is lower case.
! # This only really matters if you want to update a stick instead of recopying it
! # (make update vs. make install)
! 
! # in case your is uppercase, you'll need to change as 'FILENAME_CASE = upper'
! FILENAME_CASE ?= lower
  
  ifeq ($(FILENAME_CASE),lower)
  
  PROCESSES=mmcombo tinyftpd sndplay
! mmcombo_OBJS:=$(OBJS) $(TEKKOTSU_ROOT)/build/MMCombo.o
! mmcombo_OCF:=$(TEKKOTSU_ROOT)/build/MMCombo.ocf
! tinyftpd_OBJS:=$(TEKKOTSU_ROOT)/build/TinyFTPD.o
! tinyftpd_OCF:=$(TEKKOTSU_ROOT)/build/TinyFTPD.ocf
! sndplay_OBJS:=$(TEKKOTSU_ROOT)/build/SoundPlay.o
! sndplay_OCF:=$(TEKKOTSU_ROOT)/build/SoundPlay.ocf
  CONVERTCASE=$(TEKKOTSU_ROOT)/tools/makelowercase
  
  BINSUFFIX=.bin
--- 1,121 ----
+ # Make sure the default target is 'all' by listing it first
  all:
  
! ###################################################
! ##             ENVIRONMENT SETUP                 ##
! ###################################################
  
! 
! ###########  ENVIRONMENT VARIABLES  ###############
! # If you need to modify these, you should set them as environment
! # variables instead of changing them here - that way other tools (such
! # as mntmem and crashDebug) can use these as well.
! 
! # Directory the Tekkotsu framework is stored
! TEKKOTSU_ROOT ?= /usr/local/Tekkotsu
! 
! # Location where the memstick will be mounted
! MEMSTICK_ROOT ?= /mnt/memstick
! 
! # Directory where the OPEN-R SDK was installed
! # See http://www.tekkotsu.org/SDKInstall.html
! # or the OPEN-R website: http://openr.aibo.com/
! OPENRSDK_ROOT ?= /usr/local/OPEN_R_SDK
! 
! # in case your memory stick drivers use uppercase, you'll need to
! # set 'FILENAME_CASE' to 'upper'
! FILENAME_CASE ?= lower
! 
! # this will delete files from the memory stick that aren't also in
! # your build image - except files at the root level of the memstick,
! # like memstick.ind
! # default: OFF (empty string) - any non-empty string is ON
! STRICT_MEMSTICK_IMAGE ?=
! 
! 
! #############  MAKEFILE VARIABLES  ################
! # Change these right here in the Makefile
! 
! # Want any other libraries passed to the compiler?  Put them here.
! LIBS=-lObjectComm -lOPENR -lInternet -lantMCOOP
! 
! # What model AIBO are you targeting?  This will look at the
! # $TEKKOTSU_ROOT/TARGET_MODEL file to find out.  If the file is not
! # found, it is created with the default setting TGT_ERS2xx.
! # change the target model, make will automatically recompile
! # everything for you.
! # Legal values: TGT_ERS210 TGT_ERS220 TGT_ERS2xx 
! # If you want to change this, edit the TARGET_MODEL file, not this line!
! TEKKOTSU_TARGET_MODEL:=$(shell if [ ! -r "$(TEKKOTSU_ROOT)/TARGET_MODEL" ] ; then echo "TGT_ERS2xx" > $(TEKKOTSU_ROOT)/TARGET_MODEL ; fi ; cat $(TEKKOTSU_ROOT)/TARGET_MODEL )
! 
! # Would you like some more compiler flags?  We like lots of warnings.
! # There are some files with exceptions to these flags - MMCombo*.cc
! # need to have optimizations turned off, and several TinyFTPD sources
! # have -Weffc++ and -DOPENR_DEBUG turned off.  If you want to modify
! # these exceptions, look in the middle of the 'Makefile Machinery'
! # section.
! CXXFLAGS= \
! 	-g -O2 \
! 	-Wall -W -Wshadow -Wlarger-than-8192 -Wpointer-arith -Wcast-qual \
! 	-Woverloaded-virtual -Weffc++ -Winline -Wdeprecated -Wnon-virtual-dtor \
! 	-I"`pwd`" -I$(TEKKOTSU_ROOT) \
! 	-isystem $(OPENRSDK_ROOT)/OPEN_R/include/MCOOP \
! 	-isystem $(OPENRSDK_ROOT)/OPEN_R/include/R4000 -isystem $(OPENRSDK_ROOT)/OPEN_R/include \
! 	-DPLATFORM_APERIOS -DDEBUG -DOPENR_DEBUG -D$(TEKKOTSU_TARGET_MODEL) $(GLOBAL_MAP) \
! 
! 
! ###################################################
! ##              SOURCE CODE LIST                 ##
! ###################################################
! # Find all of the source files: (except temp files in build directory)
! # You shouldn't need to change anything here unless you want to add
! # external libraries
  
  BUILDDIR=build
  $(shell mkdir -p $(BUILDDIR))
+ $(shell mkdir -p $(TEKKOTSU_ROOT)/$(BUILDDIR))
  SRCSUFFIX=.cc
! PROJ_SRCS:=$(shell find . -name "*$(SRCSUFFIX)" \! -path "*/$(BUILDDIR)/*")
! # We're assuming all of the source files we found are to be linked
! # into MMCombo.
! MAIN_SRCS:=$(PROJ_SRCS)
! 
! 
! ###################################################
! ##               PROCESS SETUP                   ##
! ###################################################
! # This part will set up the four processes:
! # MMCombo is forked into Main and Motion
! # TinyFTPD is the FTP server
! # SoundPlay handles sound output
! 
! # It should be pretty easy to add a new process here if
! # you're inclined to do so.
! 
! # These all are relative to TEKKOTSU_ROOT
! PROCESS_OBJS=MMCombo TinyFTPD SoundPlay
! MMCombo_COMP=MMCombo MMCombo/MMComboStub.o Behaviors Events Motion Shared SoundPlay/SoundManager.o SoundPlay/WAV.o Vision Wireless WorldModel2
! TinyFTPD_COMP=TinyFTPD TinyFTPD/TinyFTPDStub.o
! SoundPlay_COMP=SoundPlay SoundPlay/SoundPlayStub.o Shared/Config.o Shared/ProcessID.o Events/EventRouter.o Events/EventTranslator.o Events/EventBase.o Shared/LoadSave.o Shared/get_time.o
! STUB_FILES:=$(addprefix $(TEKKOTSU_ROOT)/,$(addsuffix /stub.cfg,$(PROCESS_OBJS)))
! STUB_CHECK_FILES:=$(addprefix $(TEKKOTSU_ROOT)/$(BUILDDIR)/,$(subst /,-,$(STUB_FILES)))
! 
! # It's important that the process names and variables are the same
! # case as your memory stick reader - memsticks don't store case, and
! # some drivers may convert all file names to uppercase, others to
! # lower case.  Ours is lower case.  I think this only really matters
! # if you want to update a stick instead of recopying it (make update
! # vs. make install)
  
  ifeq ($(FILENAME_CASE),lower)
  
  PROCESSES=mmcombo tinyftpd sndplay
! mmcombo_OBJS:=$(MAIN_SRCS:$(SRCSUFFIX)=.o) $(TEKKOTSU_ROOT)/$(BUILDDIR)/MMCombo.o
! mmcombo_OCF:=$(TEKKOTSU_ROOT)/MMCombo/MMCombo.ocf
! tinyftpd_OBJS:=$(TEKKOTSU_ROOT)/$(BUILDDIR)/TinyFTPD.o
! tinyftpd_OCF:=$(TEKKOTSU_ROOT)/TinyFTPD/TinyFTPD.ocf
! sndplay_OBJS:=$(TEKKOTSU_ROOT)/$(BUILDDIR)/SoundPlay.o
! sndplay_OCF:=$(TEKKOTSU_ROOT)/SoundPlay/SoundPlay.ocf
  CONVERTCASE=$(TEKKOTSU_ROOT)/tools/makelowercase
  
  BINSUFFIX=.bin
***************
*** 45,56 ****
  else
  
  PROCESSES=MMCOMBO TINYFTPD SNDPLAY
! MMCOMBO_OBJS:=$(OBJS) $(TEKKOTSU_ROOT)/build/MMCombo.o
! MMCOMBO_OCF:=$(TEKKOTSU_ROOT)/build/MMCombo.ocf
! TINYFTPD_OBJS:=$(TEKKOTSU_ROOT)/build/TinyFTPD.o
! TINYFTPD_OCF:=$(TEKKOTSU_ROOT)/build/TinyFTPD.ocf
! SNDPLAY_OBJS:=$(TEKKOTSU_ROOT)/build/SoundPlay.o
! SNDPLAY_OCF:=$(TEKKOTSU_ROOT)/build/SoundPlay.ocf
  CONVERTCASE=$(TEKKOTSU_ROOT)/tools/makeuppercase
  
  BINSUFFIX=.BIN
--- 127,138 ----
  else
  
  PROCESSES=MMCOMBO TINYFTPD SNDPLAY
! MMCOMBO_OBJS:=$(MAIN_SRCS:$(SRCSUFFIX)=.o) $(TEKKOTSU_ROOT)/$(BUILDDIR)/MMCombo.o
! MMCOMBO_OCF:=$(TEKKOTSU_ROOT)/MMCombo/MMCombo.ocf
! TINYFTPD_OBJS:=$(TEKKOTSU_ROOT)/$(BUILDDIR)/TinyFTPD.o
! TINYFTPD_OCF:=$(TEKKOTSU_ROOT)/TinyFTPD/TinyFTPD.ocf
! SNDPLAY_OBJS:=$(TEKKOTSU_ROOT)/$(BUILDDIR)/SoundPlay.o
! SNDPLAY_OCF:=$(TEKKOTSU_ROOT)/SoundPlay/SoundPlay.ocf
  CONVERTCASE=$(TEKKOTSU_ROOT)/tools/makeuppercase
  
  BINSUFFIX=.BIN
***************
*** 61,112 ****
  
  endif
  
! #this will delete files from the memory stick that aren't also in your build image
! #except files at the root level of the memory stick
! #STRICT_MEMSTICK_IMAGE=true
  
! #the automatic way of doing this part is messy, just add a rule for each processes: (skip lines!)
! $(BUILDDIR)/$(word 1,$(PROCESSES))$(BINSUFFIX): $($(word 1,$(PROCESSES))_OBJS) $($(word 1,$(PROCESSES))_OCF)
  
! $(BUILDDIR)/$(word 2,$(PROCESSES))$(BINSUFFIX): $($(word 2,$(PROCESSES))_OBJS) $($(word 2,$(PROCESSES))_OCF)
  
! $(BUILDDIR)/$(word 3,$(PROCESSES))$(BINSUFFIX): $($(word 3,$(PROCESSES))_OBJS) $($(word 3,$(PROCESSES))_OCF)
  
  
- ######################
- # You shouldn't have to change anything after this point, hopefully....
- #####################
  
! PROC_BINS:=$(addprefix $(BUILDDIR)/,$(addsuffix $(BINSUFFIX),$(PROCESSES)))
  INSTALL_BINS:=$(addprefix $(INSTALLDIR)/,$(addsuffix $(BINSUFFIX),$(PROCESSES)))
  
- OPENRSDK_ROOT?=/usr/local/OPEN_R_SDK
  CXX=$(OPENRSDK_ROOT)/bin/mipsel-linux-g++
  LD=$(OPENRSDK_ROOT)/bin/mipsel-linux-ld
  STRIP=$(OPENRSDK_ROOT)/bin/mipsel-linux-strip
  MKBIN=$(OPENRSDK_ROOT)/OPEN_R/bin/mkbin
  STUBGEN=$(OPENRSDK_ROOT)/OPEN_R/bin/stubgen2
! FILTERSYSWARN=$(TEKKOTSU_ROOT)/tools/filtersyswarn/filtersyswarn
  MKBINFLAGS=-p $(OPENRSDK_ROOT)
! LIBS=-lObjectComm -lOPENR -lInternet -lantMCOOP
! CXXFLAGS= \
! 	-g -O2 \
! 	-Wall -W -Wshadow -Wlarger-than-8192 -Wpointer-arith -Wcast-qual \
! 	-Woverloaded-virtual -Weffc++ -Winline -Wdeprecated \
! 	-I. -I$(TEKKOTSU_ROOT) \
! 	-isystem $(OPENRSDK_ROOT)/OPEN_R/include/MCOOP \
! 	-isystem $(OPENRSDK_ROOT)/OPEN_R/include/R4000 -isystem $(OPENRSDK_ROOT)/OPEN_R/include \
! 	-DPLATFORM_APERIOS -DDEBUG -DOPENR_DEBUG -D$(TEKKOTSU_TARGET_MODEL) $(GLOBAL_MAP) \
  
  all: compile
  	@echo "Build successful."
! 	@echo "Type: '$(MAKE) install' to copy files to the memory stick"
  	@echo "  or: '$(MAKE) update' to copy only changed files"
  
- .PHONY: all compile install clean Tekkotsu reportTarget newstick update newstick $(INSTALLDIR)/$(MMCOMBOBIN) docs
- 
  #the touch at the end is because memsticks seem to round time to even seconds, which screws up updates.  Grr.
! compile: reportTarget Tekkotsu $(OBJS) $(PROC_BINS) $(INSTALL_BINS)
  	@image="$(BUILDDIR)/$(notdir $(MEMSTICK_ROOT))" ; \
  	if [ \! -d $$image ] ; then \
  		if [ \! -d $(OPENRSDK_ROOT)/OPEN_R/MS/WCONSOLE/nomemprot ] ; then \
--- 143,226 ----
  
  endif
  
! # creates process build target names: MMCombo -> build/MMCombo.o
! BUILDS:=$(foreach proc,$(PROCESS_OBJS),$(TEKKOTSU_ROOT)/$(BUILDDIR)/$(proc).o)
  
! # Each process build target depends on the component object files that
! # should be linked together.  These live in the
! # $TEKKOTSU_ROOT/$BUILDDIR directory and should be fairly static
! # unless you're editing the framework itself.  The automatic way of
! # creating these dependancies automatically is too messy, just add a
! # rule for each process by hand: (skip lines!)
! $(word 1,$(BUILDS)): $(foreach comp,$(addprefix $(TEKKOTSU_ROOT)/,$($(word 1,$(PROCESS_OBJS))_COMP)), $(if $(suffix $(comp)),$(comp),$(patsubst %.cc,%.o,$(shell find $(comp) -name "*.cc") )))
! 
! $(word 2,$(BUILDS)): $(foreach comp,$(addprefix $(TEKKOTSU_ROOT)/,$($(word 2,$(PROCESS_OBJS))_COMP)), $(if $(suffix $(comp)),$(comp),$(patsubst %.cc,%.o,$(shell find $(comp) -name "*.cc") )))
! 
! $(word 3,$(BUILDS)): $(foreach comp,$(addprefix $(TEKKOTSU_ROOT)/,$($(word 3,$(PROCESS_OBJS))_COMP)), $(if $(suffix $(comp)),$(comp),$(patsubst %.cc,%.o,$(shell find $(comp) -name "*.cc") )))
! 
! # Each of the executable binaries depends on the corresponding
! # framework build target(s) plus any project files which were
! # specified above. (by default, all project files are linked into
! # MMCombo) These live in the project directory's $BUILDDIR and will
! # need to be recompiled any time you change source that's part of that
! # process (but not otherwise ;)
! # Again, the automatic way of creating these dependancies
! # automatically is too messy, just add a rule for each process by
! # hand: (skip lines!)
! PROC_BINS:=$(addprefix $(BUILDDIR)/,$(addsuffix $(BINSUFFIX),$(PROCESSES)))
  
! $(word 1,$(PROC_BINS)): $($(word 1,$(PROCESSES))_OBJS) $($(word 1,$(PROCESSES))_OCF)
  
! $(word 2,$(PROC_BINS)): $($(word 2,$(PROCESSES))_OBJS) $($(word 2,$(PROCESSES))_OCF)
  
+ $(word 3,$(PROC_BINS)): $($(word 3,$(PROCESSES))_OBJS) $($(word 3,$(PROCESSES))_OCF)
  
  
! ###################################################
! ##             MAKEFILE MACHINERY                ##
! ###################################################
! # Hopefully, you shouldn't have to change anything down here,
! # except one or two little things ;)
! 
! # List of all components for all processes, sorted to
! # remove duplicates.
! COMPONENTS:=$(sort $(foreach proc,$(PROCESS_OBJS),$($(proc)_COMP)))
! 
! # list of all source files of all components, sorted to remove
! # duplicates.  This gives us all the source files which we care about,
! # all in one place.
! SRCS:=$(sort $(foreach comp,$(COMPONENTS), $(if $(suffix $(comp)),$(TEKKOTSU_ROOT)/$(basename $(comp)).cc,$(shell find $(TEKKOTSU_ROOT)/$(comp) -name "*.cc") ))) $(MAIN_SRCS)
! OBJS:=$(SRCS:$(SRCSUFFIX)=.o)
! DEPENDS:=$(SRCS:$(SRCSUFFIX)=.d)
! 
! # These are the file names of the final executable binaries, in the
! # memstick image directory
  INSTALL_BINS:=$(addprefix $(INSTALLDIR)/,$(addsuffix $(BINSUFFIX),$(PROCESSES)))
  
  CXX=$(OPENRSDK_ROOT)/bin/mipsel-linux-g++
  LD=$(OPENRSDK_ROOT)/bin/mipsel-linux-ld
  STRIP=$(OPENRSDK_ROOT)/bin/mipsel-linux-strip
  MKBIN=$(OPENRSDK_ROOT)/OPEN_R/bin/mkbin
  STUBGEN=$(OPENRSDK_ROOT)/OPEN_R/bin/stubgen2
! COLORFILT=${TEKKOTSU_ROOT}/tools/colorfilt
! FILTERSYSWARN=$(TEKKOTSU_ROOT)/tools/filtersyswarn/filtersyswarn $(OPENRSDK_ROOT)
  MKBINFLAGS=-p $(OPENRSDK_ROOT)
! 
! .PHONY: all compile install clean cleanDeps cleanProj cleanTemps Tekkotsu reportTarget newstick update $(INSTALLDIR)/$(MMCOMBOBIN) docs dox doc cleandoc updateTools
  
  all: compile
  	@echo "Build successful."
! 	@echo "Type: '$(MAKE) install' to copy all files to the memory stick"
  	@echo "  or: '$(MAKE) update' to copy only changed files"
  
  #the touch at the end is because memsticks seem to round time to even seconds, which screws up updates.  Grr.
! reportTarget:
! 	@echo " ** Targeting $(TEKKOTSU_TARGET_MODEL) for build ** ";
! 
! updateTools:
! 	cd $(TEKKOTSU_ROOT)/tools && $(MAKE);
! 
! compile: reportTarget cleanTemps updateTools $(INSTALL_BINS)
  	@image="$(BUILDDIR)/$(notdir $(MEMSTICK_ROOT))" ; \
  	if [ \! -d $$image ] ; then \
  		if [ \! -d $(OPENRSDK_ROOT)/OPEN_R/MS/WCONSOLE/nomemprot ] ; then \
***************
*** 122,139 ****
  		find $$image -exec touch -ft $$curt \{\} \; ; \
  	fi
  
- reportTarget:
- 	@echo " ** Targeting $(TEKKOTSU_TARGET_MODEL) for build ** ";
  
! ifdef BUILD_TEKKOTSU
! Tekkotsu:
! 	(cd $(TEKKOTSU_ROOT) && $(MAKE));
  endif
  
  #PROC_BINS:    (executable binaries, uncompressed)
  #we have to do a couple extra steps to cd into the builddir because mkbin doesn't support
  # -o target in a different directory... drops an intermediate file in . and then complains
  $(BUILDDIR)/%$(BINSUFFIX):
  	@echo "Creating executable binary..."
  	@echo "$@ <- $($(basename $(notdir $@))_OBJS), $($(basename $(notdir $@))_OCF)"
  	@$(LD) -i $($(basename $(notdir $@))_OBJS) -o $(BUILDDIR)/tmp.o
--- 236,380 ----
  		find $$image -exec touch -ft $$curt \{\} \; ; \
  	fi
  
  
! ifneq ($(MAKECMDGOALS),clean)
! ifneq ($(MAKECMDGOALS),cleanProj)
! ifneq ($(MAKECMDGOALS),cleanTemps)
! ifneq ($(MAKECMDGOALS),cleanDeps)
! -include $(DEPENDS)
! endif
! endif
  endif
+ endif
+ 
+ $(STUB_CHECK_FILES):
+ 	@thedir=`echo $@ | sed 's/.*-\(.*\)-.*/\1/g'`; \
+ 	cd $(TEKKOTSU_ROOT)/$$thedir ; \
+ 	$(STUBGEN) stub.cfg ; \
+ 	touch $@ ;
+ 
+ %.d : $(STUB_CHECK_FILES) %$(SRCSUFFIX)
+ 	@echo Building $@ for $*$(SRCSUFFIX)
+ 	@$(CXX) $(CXXFLAGS) -MP -MG -MT $@ -MT $*.o -MM $*$(SRCSUFFIX) > $@
+ 
+ %/def.h %/entry.h: %/stub.cfg
+ 	@echo "Doing $@"
+ 	cd $* && $(STUBGEN) stub.cfg
+ 	@echo "Done with $@"
+ 
+ #%/entry.h: %/stub.cfg
+ #	cd $(TEKKOTSU_ROOT)/$* && $(STUBGEN) stub.cfg
+ 
+ %Stub.h %Stub.cc: 
+ 	@echo "Doing $@"
+ 	cd $(dir $@) && $(STUBGEN) stub.cfg
+ 	@echo "Done with $@"
+ 
+ #%Stub.cc: 
+ #	cd $(dir $@) && $(STUBGEN) stub.cfg
+ #	@echo "Done with $@"
+ 
+ %.h :
+ 	@if [ "$(notdir $@)" = "def.h" -o "$(notdir $@)" = "entry.h" ] ; then \
+ 		echo "WARNING: You shouldn't be seeing this message.  Report that you did." ; \
+ 		echo "         Try a clean recompile." ; \
+ 	fi;
+ 	@echo "ERROR: Seems to be a missing header file '$@'...";
+ 	@echo "       Someone probably forgot to check a file into CVS.";
+ 	@echo "       I'll try to find where it's being included from:";
+ 	@find . -name "*.h" -exec grep -H "$(notdir $@)" \{\} \; ;
+ 	@find . -name "*.cc" -exec grep -H "$(notdir $@)" \{\} \; ;
+ 	@find $(TEKKOTSU_ROOT) -name "*.h" -exec grep -H "$(notdir $@)" \{\} \; ;
+ 	@find $(TEKKOTSU_ROOT) -name "*.cc" -exec grep -H "$(notdir $@)" \{\} \; ;
+ 	@echo "You might need to remove all the .d files (make cleanDeps) to get rid of this error.";
+ 	@exit 1
+ 
+ #The "fork" we do of MMCombo into MainObj and MotoObj crashes with optimization... not a big loss, just turn it off for these files
+ $(TEKKOTSU_ROOT)/MMCombo/MMCombo.o $(TEKKOTSU_ROOT)/MMCombo/MMComboStub.o: %.o: %$(SRCSUFFIX) %.d $(FILTERSYSWARN)  $(TEKKOTSU_ROOT)/TARGET_MODEL
+ 	@if [ -r dist_hosts.txt ] ; then \
+ 		echo "Adding $@ to job list"; \
+ 		echo "$(CXX) $(filter-out -O2,$(CXXFLAGS)) -o $@ -c $< > $*.log 2>&1; retval=\$$?; cat $*.log | $(FILTERSYSWARN) | $(COLORFILT); test \$$retval -eq 0;" >> $(BUILDDIR)/joblist.txt ; \
+ 		touch $@; \
+ 		echo "$@" >> $(BUILDDIR)/touched.txt ; \
+ 	else \
+ 		echo "Compiling $< into $@... (no -O2)"; \
+ 		$(CXX) $(filter-out -O2,$(CXXFLAGS)) -o $@ -c $< > $*.log 2>&1; \
+ 		retval=$$?; \
+ 		cat $*.log | $(FILTERSYSWARN) | $(COLORFILT); \
+ 		test $$retval -eq 0; \
+ 	fi;
+ 
+ $(TEKKOTSU_ROOT)/TinyFTPD/TinyFTPD.o $(TEKKOTSU_ROOT)/TinyFTPD/FtpMethod.o $(TEKKOTSU_ROOT)/TinyFTPD/FtpRequest.o $(TEKKOTSU_ROOT)/TinyFTPD/FtpDTP.o $(TEKKOTSU_ROOT)/TinyFTPD/FtpPI.o: %.o: %$(SRCSUFFIX) %.d $(FILTERSYSWARN) $(TEKKOTSU_ROOT)/TARGET_MODEL
+ 	@if [ -r dist_hosts.txt ] ; then \
+ 		echo "Adding $@ to job list"; \
+ 		echo "$(CXX) $(filter-out -DOPENR_DEBUG,$(filter-out -Weffc++,$(CXXFLAGS))) -o $@ -c $< > $*.log 2>&1; retval=\$$?; cat $*.log | $(FILTERSYSWARN) | $(COLORFILT); test \$$retval -eq 0;" >> $(BUILDDIR)/joblist.txt ; \
+ 		touch $@; \
+ 		echo "$@" >> $(BUILDDIR)/touched.txt ; \
+ 	else \
+ 		echo "Compiling $< into $@... (reduced warnings, no OPENR_DEBUG)"; \
+ 		$(CXX) $(filter-out -DOPENR_DEBUG,$(filter-out -Weffc++,$(CXXFLAGS))) -o $@ -c $< > $*.log 2>&1; \
+ 		retval=$$?; \
+ 		cat $*.log | $(FILTERSYSWARN) | $(COLORFILT); \
+ 		test $$retval -eq 0; \
+ 	fi;
+ 
+ $(TEKKOTSU_ROOT)/SoundPlay/WAV.o $(TEKKOTSU_ROOT)/Vision/Vision.o: %.o: %$(SRCSUFFIX) %.d $(FILTERSYSWARN) $(TEKKOTSU_ROOT)/TARGET_MODEL
+ 	@if [ -r dist_hosts.txt ] ; then \
+ 		echo "Adding $@ to job list"; \
+ 		echo "$(CXX) $(filter-out -Weffc++,$(CXXFLAGS)) -o $@ -c $< > $*.log 2>&1; retval=\$$?; cat $*.log | $(FILTERSYSWARN) | $(COLORFILT); test \$$retval -eq 0;" >> $(BUILDDIR)/joblist.txt ; \
+ 		touch $@; \
+ 		echo "$@" >> $(BUILDDIR)/touched.txt ; \
+ 	else \
+ 		echo "Compiling $< into $@... (reduced warnings)"; \
+ 		$(CXX) $(filter-out -Weffc++,$(CXXFLAGS)) -o $@ -c $< > $*.log 2>&1; \
+ 		retval=$$?; \
+ 		cat $*.log | $(FILTERSYSWARN) | $(COLORFILT); \
+ 		test $$retval -eq 0; \
+ 	fi;
+ 
+ %.o: %$(SRCSUFFIX) %.d $(FILTERSYSWARN) $(TEKKOTSU_ROOT)/TARGET_MODEL
+ 	@if [ -r dist_hosts.txt ] ; then \
+ 		echo "Adding $@ to job list"; \
+ 		echo "$(CXX) $(CXXFLAGS) -o $@ -c $< > $*.log 2>&1; retval=\$$?; cat $*.log | $(FILTERSYSWARN) | $(COLORFILT); test \$$retval -eq 0;" >> $(BUILDDIR)/joblist.txt ; \
+ 		touch $@; \
+ 		echo "$@" >> $(BUILDDIR)/touched.txt ; \
+ 	else \
+ 		echo "Compiling $< into $@..."; \
+ 		$(CXX) $(CXXFLAGS) -o $@ -c $< > $*.log 2>&1; \
+ 		retval=$$?; \
+ 		cat $*.log | $(FILTERSYSWARN) | $(COLORFILT); \
+ 		test $$retval -eq 0; \
+ 	fi;
+ 
+ $(TEKKOTSU_ROOT)/TARGET_MODEL:
+ 	$(error Could not find $(TEKKOTSU_ROOT)/TARGET_MODEL)
+ 
+ #BUILDS:   (framework object files, one per process - resides in framework)
+ $(BUILDS):
+ 	@if [ -r dist_hosts.txt -a -r $(BUILDDIR)/joblist.txt ] ; then \
+ 		echo "Distributing compiles..."; \
+ 		../tools/pm.pl dist_hosts.txt $(BUILDDIR)/joblist.txt ; \
+ 	fi
+ 	@rm -f $(BUILDDIR)/joblist.txt; #this is so we don't rebuild multiple times
+ 	@echo "Linking component object files..."
+ 	@if [ $(words $(sort $(foreach comp,$(addprefix $(TEKKOTSU_ROOT)/,$($(basename $(notdir $@))_COMP)), $(if $(suffix $(comp)),$(comp),$(patsubst %.cc,%.o,$(shell find $(comp) -name "*.cc")))))) -gt 20 ] ; then \
+ 		echo "$@ <- [...]"; \
+ 	else \
+ 		echo "$@ <- $(sort $(foreach comp,$(addprefix $(TEKKOTSU_ROOT)/,$($(basename $(notdir $@))_COMP)), $(if $(suffix $(comp)),$(comp),$(patsubst %.cc,%.o,$(shell find $(comp) -name "*.cc") ))))"; \
+ 	fi;
+ 	@$(LD) -i $(sort $(foreach comp,$(addprefix $(TEKKOTSU_ROOT)/,$($(basename $(notdir $@))_COMP)), $(if $(suffix $(comp)),$(comp),$(patsubst %.cc,%.o,$(shell find $(comp) -name "*.cc") )))) -o $@ ; \
+ 		if [ $$? -ne 0 ] ; then exit 1; fi;
+ 
  
  #PROC_BINS:    (executable binaries, uncompressed)
  #we have to do a couple extra steps to cd into the builddir because mkbin doesn't support
  # -o target in a different directory... drops an intermediate file in . and then complains
  $(BUILDDIR)/%$(BINSUFFIX):
+ 	@if [ -r dist_hosts.txt -a -r $(BUILDDIR)/joblist.txt ] ; then \
+ 		echo "Distributing compiles..."; \
+ 		../tools/pm.pl dist_hosts.txt $(BUILDDIR)/joblist.txt ; \
+ 	fi
+ 	@rm -f $(BUILDDIR)/joblist.txt; #this is so we don't rebuild multiple times
  	@echo "Creating executable binary..."
  	@echo "$@ <- $($(basename $(notdir $@))_OBJS), $($(basename $(notdir $@))_OCF)"
  	@$(LD) -i $($(basename $(notdir $@))_OBJS) -o $(BUILDDIR)/tmp.o
***************
*** 155,189 ****
  
  $(INSTALLDIR)/$(MMCOMBOBIN): $(INSTALLDIR)/$(MAINFORK) $(INSTALLDIR)/$(MOTOFORK)
  
! $(INSTALLDIR)/$(MAINFORK): $(BUILDDIR)/$(MMCOMBOBIN)
  	@echo "Compressing $< ~> $@"
  	@$(TEKKOTSU_ROOT)/tools/binstrswap/binstrswap $< MMCombo MainObj | gzip -c > $@
  #	@sed 's/MMCombo/MainObj/g;s/mmcombo/mainobj/g' $< | gzip -c > $@
  
! $(INSTALLDIR)/$(MOTOFORK): $(BUILDDIR)/$(MMCOMBOBIN)
  	@echo "Compressing $< ~> $@"
  	@$(TEKKOTSU_ROOT)/tools/binstrswap/binstrswap $< MMCombo MotoObj | gzip -c > $@
  #	@sed 's/MMCombo/MotoObj/g;s/mmcombo/motoobj/g' $< | gzip -c > $@
  
- #OBJS:    (for user project files)
- 
- %.o: %$(SRCSUFFIX) %.d $(FILTERSYSWARN)
- 	@echo Compiling $< into $@...
- 	@$(CXX) $(CXXFLAGS) -o $@ -c $< > $*.log 2>&1; \
- 	retval=$$?; \
- 	cat $*.log | $(FILTERSYSWARN); \
- 	test $$retval -eq 0;
- 
- %.d : %$(SRCSUFFIX)
- 	@echo Building $@ for $<
- 	@$(CXX) $(CXXFLAGS) -MP -MG -MT $@ -MT $*.o -MM $< > $@
- 
  install: compile
  	@echo "Installing files to memory stick at $(MEMSTICK_ROOT)"
  	@$(TEKKOTSU_ROOT)/tools/cpymem --all --img ms --tgt $(MEMSTICK_ROOT) --tools $(TEKKOTSU_ROOT)/tools
  
! update: compile
  	@echo "Syncing ms and $(MEMSTICK_ROOT)"
  	@$(TEKKOTSU_ROOT)/tools/mntmem $(MEMSTICK_ROOT)
  	@if [ $(STRICT_MEMSTICK_IMAGE) ] ; then \
  		echo "Strict image copy is on." ; \
--- 396,418 ----
  
  $(INSTALLDIR)/$(MMCOMBOBIN): $(INSTALLDIR)/$(MAINFORK) $(INSTALLDIR)/$(MOTOFORK)
  
! $(INSTALLDIR)/$(MAINFORK): $(BUILDDIR)/$(MMCOMBOBIN) $(TEKKOTSU_ROOT)/tools/binstrswap/binstrswap
  	@echo "Compressing $< ~> $@"
  	@$(TEKKOTSU_ROOT)/tools/binstrswap/binstrswap $< MMCombo MainObj | gzip -c > $@
  #	@sed 's/MMCombo/MainObj/g;s/mmcombo/mainobj/g' $< | gzip -c > $@
  
! $(INSTALLDIR)/$(MOTOFORK): $(BUILDDIR)/$(MMCOMBOBIN) $(TEKKOTSU_ROOT)/tools/binstrswap/binstrswap
  	@echo "Compressing $< ~> $@"
  	@$(TEKKOTSU_ROOT)/tools/binstrswap/binstrswap $< MMCombo MotoObj | gzip -c > $@
  #	@sed 's/MMCombo/MotoObj/g;s/mmcombo/motoobj/g' $< | gzip -c > $@
  
  install: compile
  	@echo "Installing files to memory stick at $(MEMSTICK_ROOT)"
  	@$(TEKKOTSU_ROOT)/tools/cpymem --all --img ms --tgt $(MEMSTICK_ROOT) --tools $(TEKKOTSU_ROOT)/tools
  
! update: compile $(TEKKOTSU_ROOT)/tools/evenmodtime/evenmodtime
  	@echo "Syncing ms and $(MEMSTICK_ROOT)"
+ 	@$(TEKKOTSU_ROOT)/tools/evenmodtime/evenmodtime `find ms`
  	@$(TEKKOTSU_ROOT)/tools/mntmem $(MEMSTICK_ROOT)
  	@if [ $(STRICT_MEMSTICK_IMAGE) ] ; then \
  		echo "Strict image copy is on." ; \
***************
*** 195,217 ****
  
  newstick:
  	$(TEKKOTSU_ROOT)/tools/mntmem $(MEMSTICK_ROOT)
  	cp -r $(OPENRSDK_ROOT)/OPEN_R/MS/WCONSOLE/nomemprot/* $(MEMSTICK_ROOT)
  	$(TEKKOTSU_ROOT)/tools/umntmem $(MEMSTICK_ROOT)
  
  $(FILTERSYSWARN):
  	(cd $(TEKKOTSU_ROOT)/tools && $(MAKE));
  
! ifneq ($(MAKECMDGOALS),clean)
! -include $(DEPENDS)
! endif
  
! 
! clean:
! 	rm -f $(OBJS) $(DEPENDS) ${SRCS:$(SRCSUFFIX)=.log} *~
! 	rm -rf build
  	rm -f $(INSTALL_BINS) $(INSTALLDIR)/$(MAINFORK) $(INSTALLDIR)/$(MOTOFORK)
- 	if [ -n "$(BUILD_TEKKOTSU)" ] ; then (cd $(TEKKOTSU_ROOT) && $(MAKE) clean); fi;
  
! docs:
! 	(cd $(TEKKOTSU_ROOT) && $(MAKE) $@)
  
--- 424,467 ----
  
  newstick:
  	$(TEKKOTSU_ROOT)/tools/mntmem $(MEMSTICK_ROOT)
+ 	rm -rf $(MEMSTICK_ROOT)/*
  	cp -r $(OPENRSDK_ROOT)/OPEN_R/MS/WCONSOLE/nomemprot/* $(MEMSTICK_ROOT)
  	$(TEKKOTSU_ROOT)/tools/umntmem $(MEMSTICK_ROOT)
  
  $(FILTERSYSWARN):
  	(cd $(TEKKOTSU_ROOT)/tools && $(MAKE));
  
! cleanTemps:
! 	rm -f $(BUILDDIR)/joblist.txt $(BUILDDIR)/touched.txt
  
! clean: cleanProj
! 	@printf "Cleaning all .o, .d, .log and ~ files corresponding to .cc files..."
! 	@rm -f $(OBJS) $(DEPENDS) $(SRCS:$(SRCSUFFIX)=.log) $(addsuffix ~,$(SRCS)) $(SRCS:$(SRCSUFFIX)=.h~)
! 	@printf "done.\n"
! 	rm -f $(foreach proc,$(PROCESS_OBJS),$(TEKKOTSU_ROOT)/$(proc)/$(proc)Stub.cc $(TEKKOTSU_ROOT)/$(proc)/$(proc)Stub.h $(TEKKOTSU_ROOT)/$(proc)/def.h $(TEKKOTSU_ROOT)/$(proc)/entry.h)
! 	rm -rf $(TEKKOTSU_ROOT)/$(BUILDDIR)
! 	cd $(TEKKOTSU_ROOT)/tools ; $(MAKE) clean
! 
! cleanDeps:
! 	@printf "Cleaning all .d files corresponding to .cc files..."
! 	@rm -f $(DEPENDS)
! 	@printf "done.\n"
! 
! cleanProj:
! 	@printf "Cleaning all .o, .d, .log and ~ files corresponding to project .cc files..."
! 	@rm -f $(PROJ_SRCS:$(SRCSUFFIX)=.o)
! 	@rm -f $(PROJ_SRCS:$(SRCSUFFIX)=.d)
! 	@rm -f $(PROJ_SRCS:$(SRCSUFFIX)=.log)
! 	@rm -f $(addsuffix ~,$(PROJ_SRCS)) $(PROJ_SRCS:$(SRCSUFFIX)=.h~)
! 	@printf "done.\n"
! 	rm -rf $(BUILDDIR)
  	rm -f $(INSTALL_BINS) $(INSTALLDIR)/$(MAINFORK) $(INSTALLDIR)/$(MOTOFORK)
  
! dox doc docs:
! 	cd $(TEKKOTSU_ROOT) && $(MAKE) $@
! 
! cleandoc:
! 	docs/builddocs --clean
! 
! 
  
Index: AiboPup/project/StartupBehavior.cc
diff -c AiboPup/project/StartupBehavior.cc:1.36 AiboPup/project/StartupBehavior.cc:1.43
*** AiboPup/project/StartupBehavior.cc:1.36	Tue Jul  8 18:29:11 2003
--- AiboPup/project/StartupBehavior.cc	Tue Sep  2 17:10:53 2003
***************
*** 1,50 ****
  #include "StartupBehavior.h"
  
  #include "Behaviors/Controller.h"
- #include "Shared/SharedObject.h"
- 
  #include "Behaviors/Controls/BatteryCheckControl.h"
- #include "Behaviors/Controls/BehaviorActivatorControl.h"
- #include "Behaviors/Controls/BehaviorSwitchControl.h"
  #include "Behaviors/Controls/ControlBase.h"
- #include "Behaviors/Controls/DumpFileControl.h"
- #include "Behaviors/Controls/FileBrowserControl.h"
- #include "Behaviors/Controls/FreeMemReportControl.h"
  #include "Behaviors/Controls/HelpControl.h"
- #include "Behaviors/Controls/LoadPostureControl.h"
- #include "Behaviors/Controls/LoadWalkControl.h"
- #include "Behaviors/Controls/MCValueEditControl.h"
- #include "Behaviors/Controls/PlaySoundControl.h"
- #include "Behaviors/Controls/ProfilerCheckControl.h"
  #include "Behaviors/Controls/RebootControl.h"
- #include "Behaviors/Controls/RunSequenceControl.h"
- #include "Behaviors/Controls/SavePostureControl.h"
- #include "Behaviors/Controls/SaveWalkControl.h"
  #include "Behaviors/Controls/ShutdownControl.h"
- #include "Behaviors/Controls/ValueEditControl.h"
- #include "Behaviors/Controls/ValueSetControl.h"
- 
- #include "Behaviors/Controls/EventLogger.h"
- 
- #include "Behaviors/Demos/AutoGetupBehavior.h"
- #include "Behaviors/Demos/BatteryMonitorBehavior.h"
- #include "Behaviors/Demos/ChaseBallBehavior.h"
- #include "Behaviors/Demos/SimpleChaseBallBehavior.h"
- #include "Behaviors/Demos/StareAtBallBehavior.h"
- #include "Behaviors/Demos/FollowHeadBehavior.h"
- #include "Behaviors/Demos/HeadLevelBehavior.h"
- #include "Behaviors/Demos/EvtRptBehavior.h"
- #include "Behaviors/Demos/WalkToTargetMachine.h"
- #include "Behaviors/Demos/BanditMachine.h"
- #include "Behaviors/Demos/WorldModel2Behavior.h"
- #include "Behaviors/Demos/DumbWM2Behavior.h"
- #include "Behaviors/Demos/SoundTestBehavior.h"
- #include "Behaviors/Demos/ToggleHeadLightBehavior.h"
- #include "Behaviors/Demos/WalkControllerBehavior.h"
- #include "Behaviors/Demos/HeadPointControllerBehavior.h"
- #include "Behaviors/Demos/Aibo3DControllerBehavior.h"
- #include "Behaviors/Demos/Aibo3DMonitorBehavior.h"
- #include "Behaviors/Demos/EStopControllerBehavior.h"
  
  #include "Motion/MotionCommand.h"
  #include "Motion/PostureMC.h"
--- 1,11 ----
***************
*** 52,66 ****
  #include "Motion/PIDMC.h"
  #include "Motion/MotionSequenceMC.h"
  #include "Motion/MMAccessor.h"
! #include "Shared/ERS210Info.h"
  
  #include "SoundPlay/SoundManager.h"
  
! StartupBehavior gStartup; //!< used to initialize the global ::startupBehavior, used by MMCombo
! BehaviorBase& startupBehavior=gStartup; //!< used by MMCombo as the init behavior
  
  StartupBehavior::StartupBehavior()
! 	: BehaviorBase(), spawned(),
  		stop_id(MotionManager::invalid_MC_ID),
  		pid_id(MotionManager::invalid_MC_ID)
  {
--- 13,30 ----
  #include "Motion/PIDMC.h"
  #include "Motion/MotionSequenceMC.h"
  #include "Motion/MMAccessor.h"
! 
! #include "Vision/Vision.h"
  
  #include "SoundPlay/SoundManager.h"
  
! #include "Shared/ERS210Info.h"
! 
! StartupBehavior theStartup; //!< used to initialize the global ::startupBehavior, used by MMCombo
! BehaviorBase& startupBehavior=theStartup; //!< used by MMCombo as the init behavior
  
  StartupBehavior::StartupBehavior()
! 	: BehaviorBase(), spawned(),setup(),
  		stop_id(MotionManager::invalid_MC_ID),
  		pid_id(MotionManager::invalid_MC_ID)
  {
***************
*** 100,106 ****
  	spawned.push_back(controller);
  	
  	sndman->PlayFile("roar.wav");
! 	
  	//This will close the mouth so it doesn't look stupid
  	//Now done by setting the emergency stop directly in processEvent, but left as demo code:
  	/*	const SharedObject<PostureMC> closemouth;
--- 64,70 ----
  	spawned.push_back(controller);
  	
  	sndman->PlayFile("roar.wav");
! 
  	//This will close the mouth so it doesn't look stupid
  	//Now done by setting the emergency stop directly in processEvent, but left as demo code:
  	/*	const SharedObject<PostureMC> closemouth;
***************
*** 147,244 ****
  ControlBase*
  StartupBehavior::SetupMenus() {
  	std::cout << "CONTROLLER-INIT..." << std::flush;
! 	std::stack< ControlBase* > mcsetup;
  	{
! 		ControlBase* root=new ControlBase("Root Control");
! 		mcsetup.push(root);
! 		mcsetup.top()->pushSlot(new ControlBase("Mode Switch","Contains the \"major\" applications - mutually exclusive selection"));
! 		{
! 			mcsetup.push(mcsetup.top()->getSlots().back());
! 			BehaviorSwitchControlBase::BehaviorGroup * bg = new BehaviorSwitchControlBase::BehaviorGroup();
! 			//put behaviors here
! 			mcsetup.top()->pushSlot(new BehaviorSwitchControl<FollowHeadBehavior>("FollowHeadBehavior",bg,false));
! 			//			mcsetup.top()->pushSlot(new BehaviorSwitchControl<CameraBehavior>("Camera",bg,false));
! 			mcsetup.top()->pushSlot(new BehaviorSwitchControl<SoundTestBehavior>("SoundTestBehavior",bg,false));
! 			mcsetup.top()->pushSlot(new BehaviorSwitchControl<ChaseBallBehavior>("ChaseBallBehavior",bg,false));
! 			mcsetup.top()->pushSlot(new BehaviorSwitchControl<SimpleChaseBallBehavior>("SimpleChaseBallBehavior",bg,false));
! 			mcsetup.top()->pushSlot(new BehaviorSwitchControl<StareAtBallBehavior>("StareAtBallBehavior",bg,false));
! 			mcsetup.top()->pushSlot(new BehaviorSwitchControl<WalkToTargetMachine,Factory1Arg<WalkToTargetMachine,VisionEventNS::VisionSourceID_t,VisionEventNS::PinkBallSID> >("WalkToPinkBall",bg,false));
! 			mcsetup.top()->pushSlot(new BehaviorSwitchControl<BanditMachine>("BanditMachine",bg,false));
! 			mcsetup.top()->pushSlot(new BehaviorSwitchControl<WorldModel2Behavior>("WorldModel2Behavior",bg,false));
! 			mcsetup.pop();
! 		}
! 		mcsetup.top()->pushSlot(new ControlBase("Background Behaviors","Background daemons and monitors"));
! 		{ 
! 			mcsetup.push(mcsetup.top()->getSlots().back());
! 			mcsetup.top()->pushSlot((new BehaviorSwitchControl<AutoGetupBehavior>("AutoGetupBehavior",false))->start());
! 			mcsetup.top()->pushSlot((new BehaviorSwitchControl<BatteryMonitorBehavior>("BatteryMonitorBehavior",false))->start());
! 			mcsetup.top()->pushSlot(new BehaviorSwitchControl<EvtRptBehavior>("EvtRptBehavior",false));
! 			mcsetup.top()->pushSlot(new BehaviorSwitchControl<DumbWM2Behavior>("DumbWM2Behavior",false));
! 			BehaviorSwitchControlBase::BehaviorGroup * aibo3D_bg = new BehaviorSwitchControlBase::BehaviorGroup();
! 			mcsetup.top()->pushSlot((new BehaviorSwitchControl<Aibo3DControllerBehavior>("Aibo3DController",aibo3D_bg,false)));
! 			mcsetup.top()->pushSlot((new BehaviorSwitchControl<Aibo3DMonitorBehavior>("Aibo3DMonitor",aibo3D_bg,false)));
! 			mcsetup.top()->pushSlot(new BehaviorSwitchControl<HeadLevelBehavior>("HeadLevelBehavior",false));
! 			if(state->robotDesign & WorldState::ERS220Mask)
! 				mcsetup.top()->pushSlot(new BehaviorSwitchControl<ToggleHeadLightBehavior>("ToggleHeadLightBehavior",false));
! 			mcsetup.pop();
! 		}
! 		mcsetup.top()->pushSlot(new ControlBase("TekkotsuMon","Servers for GUIs"));
  		{ 
! 			mcsetup.push(mcsetup.top()->getSlots().back());
! 			mcsetup.top()->pushSlot((new BehaviorSwitchControl<HeadPointControllerBehavior>("Head Remote Control",false)));
! 			mcsetup.top()->pushSlot((new BehaviorSwitchControl<WalkControllerBehavior>("Walk Remote Control",false)));
! 			BehaviorSwitchControlBase::BehaviorGroup * aibo3D_bg = new BehaviorSwitchControlBase::BehaviorGroup();
! 			mcsetup.top()->pushSlot((new BehaviorSwitchControl<Aibo3DControllerBehavior>("Aibo3D Controller",aibo3D_bg,false)));
! 			mcsetup.top()->pushSlot((new BehaviorSwitchControl<Aibo3DMonitorBehavior>("Aibo3D Monitor",aibo3D_bg,false)));
! 			EStopControllerBehavior * ESCB=new EStopControllerBehavior(stop_id);
! 			mcsetup.top()->pushSlot((new BehaviorSwitchControl<EStopControllerBehavior,Factory1Arg<EStopControllerBehavior,MotionManager::MC_ID,MotionManager::invalid_MC_ID> >("EStop Remote Control",ESCB))->start());
! 			mcsetup.pop();
  		}
! 		mcsetup.top()->pushSlot(new ControlBase("Status Reports","Displays information about the runtime environment on the console"));
! 		{ 
! 			mcsetup.push(mcsetup.top()->getSlots().back());
! 			mcsetup.top()->pushSlot(new BatteryCheckControl());
! 			mcsetup.top()->pushSlot(new ProfilerCheckControl());
! 			mcsetup.top()->pushSlot(new EventLogger());
! 			FreeMemReportControl * tmp=new FreeMemReportControl();
! 			tmp->DoStart();
! 			mcsetup.top()->pushSlot(tmp);
! 			mcsetup.pop();
! 		}
! 		mcsetup.top()->pushSlot(new ControlBase("File Access","Access/load files on the memory stick"));
! 		{ 
! 			mcsetup.push(mcsetup.top()->getSlots().back());
! 			mcsetup.top()->pushSlot(new LoadPostureControl("Load Posture",stop_id));
! 			mcsetup.top()->pushSlot(new SavePostureControl("Save Posture"));
! 			mcsetup.top()->pushSlot(new RunSequenceControl<MotionSequence::SizeXLarge>("Run Motion Sequence",stop_id));
! 			mcsetup.top()->pushSlot(new PlaySoundControl("Play Sound"));
! 			mcsetup.top()->pushSlot(new DumpFileControl("Files","/ms"));
! 			mcsetup.pop();
! 		}
! 		mcsetup.top()->pushSlot(new ControlBase("Shutdown?"));
! 		{ 
! 			mcsetup.push(mcsetup.top()->getSlots().back());
! 			mcsetup.top()->pushSlot(new ShutdownControl());
! 			mcsetup.top()->pushSlot(new RebootControl());
! 			mcsetup.pop();
! 		}
! 		mcsetup.top()->pushSlot(new HelpControl(root));
  	}
! 	if(mcsetup.size()!=1)
! 		cout << "*** WARNING *** menu setup stack more than one or empty" << endl;
  	cout << "DONE" << endl;
! 	return mcsetup.top();
  }
  
! 			/*			XORBehavior* xorbeh=new XORBehavior(); //i make other controls which reference xorbeh below
! 			mcsetup.top()->pushSlot(new BehaviorSwitchControl<XORBehavior>("AI Control",xorbeh,bg));
! 			{ // I don't necessarily like this method of adding sub menus to control behavior parameters, but you can do it quickly. (cleaner to subclass the behavior, have it add its own)
! 				mcsetup.push(mcsetup.top()->getSlots().back());
! 				mcsetup.top()->pushSlot(new BehaviorActivatorControl("Toggle",(BehaviorSwitchControlBase*)mcsetup.top()));
! 				mcsetup.top()->pushSlot(new ValueSetControl<float>("Enable learning (0.035)",&xorbeh->getModel()->learn_rate,0.035));
! 				mcsetup.top()->pushSlot(new ValueSetControl<float>("Disable learning",&xorbeh->getModel()->learn_rate,0));
! 				mcsetup.top()->pushSlot(new LoadAIControl("Load AI",xorbeh->getModel()));
! 				mcsetup.top()->pushSlot(new SaveAIControl("Save AI",xorbeh->getModel()));
! 				mcsetup.pop();
! 			}
! 			*/
--- 111,156 ----
  ControlBase*
  StartupBehavior::SetupMenus() {
  	std::cout << "CONTROLLER-INIT..." << std::flush;
! 	ControlBase* root=new ControlBase("Root Control");
! 	setup.push(root);
! 
! 	// additional controls will be submenus of root:
  	{
! 		SetupModeSwitch();
! 		SetupBackgroundBehaviors();
! 		SetupTekkotsuMon();
! 		SetupStatusReports();
! 		SetupFileAccess();
! 		SetupWalkEdit();
! 		addItem(new ControlBase("Shutdown?"));
! 		startSubMenu();
  		{ 
! 			addItem(new ShutdownControl());
! 			addItem(new RebootControl());
  		}
! 		endSubMenu();
! 		addItem(new HelpControl(root));
  	}
! 	
! 	if(endSubMenu()!=root)
! 		cout << "\n*** WARNING *** menu setup stack corrupted" << endl;
  	cout << "DONE" << endl;
! 	return root;
  }
  
! void
! StartupBehavior::startSubMenu() {
! 	setup.push(setup.top()->getSlots().back());
! }
! 
! void
! StartupBehavior::addItem(ControlBase * control) {
! 	setup.top()->pushSlot(control);
! }
! 
! ControlBase*
! StartupBehavior::endSubMenu() {
! 	ControlBase * tmp=setup.top();
! 	setup.pop();
! 	return tmp;
! }
Index: AiboPup/project/StartupBehavior.h
diff -c AiboPup/project/StartupBehavior.h:1.4 AiboPup/project/StartupBehavior.h:1.8
*** AiboPup/project/StartupBehavior.h:1.4	Thu Jun 12 19:41:41 2003
--- AiboPup/project/StartupBehavior.h	Tue Sep  2 23:23:39 2003
***************
*** 4,15 ****
  #include "Behaviors/BehaviorBase.h"
  #include "Motion/MotionManager.h"
  #include <vector>
  
  class Controller; // defined in Controller.h, don't actually need header file yet
  class ControlBase; // defined in ControlBase.h, don't actually need header file yet
  
  //! This Behavior is the only hardcoded behavior by the framework to start up once all the data structures and such are set up
! /*! Similar in idea to the init process in unix/linux. */
  class StartupBehavior : public BehaviorBase {
  public:
  	//! Constructor
--- 4,26 ----
  #include "Behaviors/BehaviorBase.h"
  #include "Motion/MotionManager.h"
  #include <vector>
+ #include <stack>
  
  class Controller; // defined in Controller.h, don't actually need header file yet
  class ControlBase; // defined in ControlBase.h, don't actually need header file yet
  
  //! This Behavior is the only hardcoded behavior by the framework to start up once all the data structures and such are set up
! 
! /*! This is done by assigning an instance of StartupBehavior to the
!  *  global ::startupBehavior variable.  Note that there's nothing
!  *  special about the type of this class, it's just another
!  *  BehaviorBase - ::startupBehavior could be any behavior.  If you
!  *  want some other behavior to run automatically at startup, simply
!  *  remove StartupBehavior from the project and assign an instance of
!  *  your own class to ::startupBehavior instead.
!  *
!  *  By default, this behavior is similar in idea to the init process
!  *  in unix/linux. */
  class StartupBehavior : public BehaviorBase {
  public:
  	//! Constructor
***************
*** 17,24 ****
  	//! Destructor
  	virtual ~StartupBehavior();
  
! 	//!Inherited
! 	//@{
  	virtual void DoStart();
  	virtual void DoStop();
  	virtual void processEvent(const EventBase&);
--- 28,34 ----
  	//! Destructor
  	virtual ~StartupBehavior();
  
! 	//! @name Inherited
  	virtual void DoStart();
  	virtual void DoStop();
  	virtual void processEvent(const EventBase&);
***************
*** 26,35 ****
  	static std::string getClassDescription() { return "The initial behavior, when run, sets up everything else"; }
  	//@}
  protected:
! 	//! Initializes the Controller menu structure
  	virtual ControlBase* SetupMenus();
  
  	std::vector<BehaviorBase*> spawned; //!< Behaviors spawned from DoStart, so they can automatically be stopped on DoStop
  	MotionManager::MC_ID stop_id; //!< the main EmergencyStopMC
  	MotionManager::MC_ID pid_id; //!< used to fade in the PIDs up to full strength (from initial zero) This is so the joints don't jerk on startup.
  };
--- 36,58 ----
  	static std::string getClassDescription() { return "The initial behavior, when run, sets up everything else"; }
  	//@}
  protected:
! 	//! Initializes the Controller menu structure - calls each of the other Setup functions in turn
! 	/*! Also adds Shutdown and Help items at the end */
  	virtual ControlBase* SetupMenus();
  
+ 	virtual ControlBase* SetupModeSwitch();          //!< sets up Mode Switch menu
+ 	virtual ControlBase* SetupBackgroundBehaviors(); //!< sets up Background Behaviors menu
+ 	virtual ControlBase* SetupTekkotsuMon();         //!< sets up TekkotsuMon menu
+ 	virtual ControlBase* SetupStatusReports();       //!< sets up Status Reports menu
+ 	virtual ControlBase* SetupFileAccess();          //!< sets up File Access menu
+ 	virtual ControlBase* SetupWalkEdit();            //!< sets up Walk Editing menus (contributed by PGSS 2003 team project - see StartupBehavior_SetupWalkEdit.cc )
+ 
+ 	virtual void startSubMenu(); //!< future calls to addItem() will be placed under the most recently added item
+ 	virtual void addItem(ControlBase * control); //!< inserts a control at the end of the menu
+ 	virtual ControlBase* endSubMenu();  //!< closes out a submenu so that future calls to addItem() will be added to the enclosing menu, returns the menu being closed out
+ 
  	std::vector<BehaviorBase*> spawned; //!< Behaviors spawned from DoStart, so they can automatically be stopped on DoStop
+ 	std::stack<ControlBase*> setup;     //!< only used during setup - easier than passing it around all the functions
  	MotionManager::MC_ID stop_id; //!< the main EmergencyStopMC
  	MotionManager::MC_ID pid_id; //!< used to fade in the PIDs up to full strength (from initial zero) This is so the joints don't jerk on startup.
  };
Index: AiboPup/project/StartupBehavior_SetupBackgroundBehaviors.cc
diff -c /dev/null AiboPup/project/StartupBehavior_SetupBackgroundBehaviors.cc:1.3
*** /dev/null	Fri Oct 10 14:37:51 2003
--- AiboPup/project/StartupBehavior_SetupBackgroundBehaviors.cc	Thu Oct  2 23:41:27 2003
***************
*** 0 ****
--- 1,34 ----
+ #include "StartupBehavior.h"
+ 
+ #include "Behaviors/Controls/ControlBase.h"
+ #include "Behaviors/Controls/BehaviorSwitchControl.h"
+ 
+ #include "Behaviors/Demos/AutoGetupBehavior.h"
+ #include "Behaviors/Demos/BatteryMonitorBehavior.h"
+ #include "Behaviors/Demos/HeadLevelBehavior.h"
+ #include "Behaviors/Demos/EvtRptBehavior.h"
+ #include "Behaviors/Demos/DumbWM2Behavior.h"
+ #include "Behaviors/Demos/ToggleHeadLightBehavior.h"
+ #include "Behaviors/Demos/HelloWorldBehavior.h"
+ #include "Behaviors/Demos/CrashTestBehavior.h"
+ 
+ #include "Shared/WorldState.h"
+ #include "Shared/ERS210Info.h"
+ 
+ ControlBase*
+ StartupBehavior::SetupBackgroundBehaviors() {
+ 	addItem(new ControlBase("Background Behaviors","Background daemons and monitors"));
+ 	startSubMenu();
+ 	{ 
+ 		addItem((new BehaviorSwitchControl<AutoGetupBehavior>("AutoGetupBehavior",false))->start());
+ 		addItem((new BehaviorSwitchControl<BatteryMonitorBehavior>("BatteryMonitorBehavior",false))->start());
+ 		addItem(new BehaviorSwitchControl<EvtRptBehavior>("EvtRptBehavior",false));
+ 		addItem(new BehaviorSwitchControl<DumbWM2Behavior>("DumbWM2Behavior",false));
+ 		addItem(new BehaviorSwitchControl<HeadLevelBehavior>("HeadLevelBehavior",false));
+ 		if(state->robotDesign & WorldState::ERS220Mask)
+ 			addItem(new BehaviorSwitchControl<ToggleHeadLightBehavior>("ToggleHeadLightBehavior",false));
+ 		addItem(new BehaviorSwitchControl<HelloWorldBehavior>("HelloWorldBehavior",false));
+ 		addItem(new BehaviorSwitchControl<CrashTestBehavior>("CrashTestBehavior",false));
+ 	}
+ 	return endSubMenu();
+ }
Index: AiboPup/project/StartupBehavior_SetupFileAccess.cc
diff -c /dev/null AiboPup/project/StartupBehavior_SetupFileAccess.cc:1.1
*** /dev/null	Fri Oct 10 14:37:51 2003
--- AiboPup/project/StartupBehavior_SetupFileAccess.cc	Fri Jul 25 21:48:59 2003
***************
*** 0 ****
--- 1,23 ----
+ #include "StartupBehavior.h"
+ 
+ #include "Behaviors/Controls/ControlBase.h"
+ 
+ #include "Behaviors/Controls/LoadPostureControl.h"
+ #include "Behaviors/Controls/SavePostureControl.h"
+ #include "Behaviors/Controls/RunSequenceControl.h"
+ #include "Behaviors/Controls/PlaySoundControl.h"
+ #include "Behaviors/Controls/DumpFileControl.h"
+ 
+ ControlBase*
+ StartupBehavior::SetupFileAccess() {
+ 	addItem(new ControlBase("File Access","Access/load files on the memory stick"));
+ 	startSubMenu();
+ 	{ 
+ 		addItem(new LoadPostureControl("Load Posture",stop_id));
+ 		addItem(new SavePostureControl("Save Posture"));
+ 		addItem(new RunSequenceControl<MotionSequence::SizeXLarge>("Run Motion Sequence",stop_id));
+ 		addItem(new PlaySoundControl("Play Sound"));
+ 		addItem(new DumpFileControl("Files","/ms"));
+ 	}
+ 	return endSubMenu();
+ }
Index: AiboPup/project/StartupBehavior_SetupModeSwitch.cc
diff -c /dev/null AiboPup/project/StartupBehavior_SetupModeSwitch.cc:1.7
*** /dev/null	Fri Oct 10 14:37:51 2003
--- AiboPup/project/StartupBehavior_SetupModeSwitch.cc	Fri Oct 10 01:57:47 2003
***************
*** 0 ****
--- 1,40 ----
+ #include "StartupBehavior.h"
+ 
+ #include "Behaviors/Controls/ControlBase.h"
+ #include "Behaviors/Controls/BehaviorSwitchControl.h"
+ 
+ #include "Behaviors/Demos/AlanBehavior.h"
+ #include "Behaviors/Demos/ChaseBallBehavior.h"
+ #include "Behaviors/Demos/SimpleChaseBallBehavior.h"
+ #include "Behaviors/Demos/StareAtBallBehavior.h"
+ #include "Behaviors/Demos/FollowHeadBehavior.h"
+ #include "Behaviors/Demos/WalkToTargetMachine.h"
+ #include "Behaviors/Demos/BanditMachine.h"
+ #include "Behaviors/Demos/WorldModel2Behavior.h"
+ #include "Behaviors/Demos/SoundTestBehavior.h"
+ #include "Behaviors/Demos/ExploreMachine.h"
+ 
+ ControlBase*
+ StartupBehavior::SetupModeSwitch() {
+ 	addItem(new ControlBase("Mode Switch","Contains the \"major\" applications - mutually exclusive selection"));
+ 	startSubMenu();
+ 	{
+ 		//this group allows the behaviors to turn each other off when you start a new one so
+ 		//only one is running at a time - like radio buttons
+ 		BehaviorSwitchControlBase::BehaviorGroup * bg = new BehaviorSwitchControlBase::BehaviorGroup();
+ 
+ 		//put behaviors here:
+ 		addItem(new BehaviorSwitchControl<AlanBehavior>("AlanBehavior",bg,false));
+ 		addItem(new BehaviorSwitchControl<FollowHeadBehavior>("FollowHeadBehavior",bg,false));
+ 		addItem(new BehaviorSwitchControl<SoundTestBehavior>("SoundTestBehavior",bg,false));
+ 		addItem(new BehaviorSwitchControl<ChaseBallBehavior>("ChaseBallBehavior",bg,false));
+ 		addItem(new BehaviorSwitchControl<SimpleChaseBallBehavior>("SimpleChaseBallBehavior",bg,false));
+ 		addItem(new BehaviorSwitchControl<StareAtBallBehavior>("StareAtBallBehavior",bg,false));
+ 		addItem(new BehaviorSwitchControl<WalkToTargetMachine,Factory1Arg<WalkToTargetMachine,VisionEventNS::VisionSourceID_t,VisionEventNS::PinkBallSID> >("WalkToPinkBall",bg,false));
+ 		addItem(new BehaviorSwitchControl<BanditMachine>("BanditMachine",bg,false));
+ 		addItem(new BehaviorSwitchControl<WorldModel2Behavior>("WorldModel2Behavior",bg,false));
+ 		addItem(new BehaviorSwitchControl<ExploreMachine>("ExploreMachine",bg,false));
+ 	}
+ 	return endSubMenu();
+ }
+ 
Index: AiboPup/project/StartupBehavior_SetupStatusReports.cc
diff -c /dev/null AiboPup/project/StartupBehavior_SetupStatusReports.cc:1.1
*** /dev/null	Fri Oct 10 14:37:51 2003
--- AiboPup/project/StartupBehavior_SetupStatusReports.cc	Fri Jul 25 21:48:59 2003
***************
*** 0 ****
--- 1,23 ----
+ #include "StartupBehavior.h"
+ 
+ #include "Behaviors/Controls/ControlBase.h"
+ 
+ #include "Behaviors/Controls/BatteryCheckControl.h"
+ #include "Behaviors/Controls/FreeMemReportControl.h"
+ #include "Behaviors/Controls/ProfilerCheckControl.h"
+ #include "Behaviors/Controls/EventLogger.h"
+ 
+ ControlBase*
+ StartupBehavior::SetupStatusReports() {
+ 	addItem(new ControlBase("Status Reports","Displays information about the runtime environment on the console"));
+ 	startSubMenu();
+ 	{ 
+ 		addItem(new BatteryCheckControl());
+ 		addItem(new ProfilerCheckControl());
+ 		addItem(new EventLogger());
+ 		FreeMemReportControl * tmp=new FreeMemReportControl();
+ 		tmp->DoStart();
+ 		addItem(tmp);
+ 	}
+ 	return endSubMenu();
+ }
Index: AiboPup/project/StartupBehavior_SetupTekkotsuMon.cc
diff -c /dev/null AiboPup/project/StartupBehavior_SetupTekkotsuMon.cc:1.7
*** /dev/null	Fri Oct 10 14:37:51 2003
--- AiboPup/project/StartupBehavior_SetupTekkotsuMon.cc	Thu Oct  9 20:47:55 2003
***************
*** 0 ****
--- 1,28 ----
+ #include "StartupBehavior.h"
+ 
+ #include "Behaviors/Controls/ControlBase.h"
+ #include "Behaviors/Controls/BehaviorSwitchControl.h"
+ 
+ #include "Behaviors/Mon/ViewWMVarsBehavior.h"
+ #include "Behaviors/Mon/WalkControllerBehavior.h"
+ #include "Behaviors/Mon/HeadPointControllerBehavior.h"
+ #include "Behaviors/Mon/Aibo3DControllerBehavior.h"
+ #include "Behaviors/Mon/EStopControllerBehavior.h"
+ #include "Behaviors/Mon/WMMonitorBehavior.h"
+ 
+ ControlBase*
+ StartupBehavior::SetupTekkotsuMon() {
+ 	addItem(new ControlBase("TekkotsuMon","Servers for GUIs"));
+ 	startSubMenu();
+ 	{ 
+ 		addItem((new BehaviorSwitchControl<HeadPointControllerBehavior>("Head Remote Control",false)));
+ 		addItem((new BehaviorSwitchControl<WalkControllerBehavior>("Walk Remote Control",false)));
+ 		addItem((new BehaviorSwitchControl<ViewWMVarsBehavior>("View WMVars",false)));
+ 		addItem((new BehaviorSwitchControl<WMMonitorBehavior>("Watchable Memory Monitor",false))->start());
+ 		BehaviorSwitchControlBase::BehaviorGroup * aibo3D_bg = new BehaviorSwitchControlBase::BehaviorGroup();
+ 		addItem((new BehaviorSwitchControl<Aibo3DControllerBehavior>("Aibo 3D",aibo3D_bg,false)));
+ 		EStopControllerBehavior * ESCB=new EStopControllerBehavior(stop_id);
+ 		addItem((new BehaviorSwitchControl<EStopControllerBehavior,Factory1Arg<EStopControllerBehavior,MotionManager::MC_ID,MotionManager::invalid_MC_ID> >("EStop Remote Control",ESCB))->start());
+ 	}
+ 	return endSubMenu();
+ }
Index: AiboPup/project/StartupBehavior_SetupWalkEdit.cc
diff -c /dev/null AiboPup/project/StartupBehavior_SetupWalkEdit.cc:1.2
*** /dev/null	Fri Oct 10 14:37:51 2003
--- AiboPup/project/StartupBehavior_SetupWalkEdit.cc	Thu Oct  9 20:45:32 2003
***************
*** 0 ****
--- 1,127 ----
+ /*! @file
+  * @brief Sets up menus for runtime editing of parameters for the CMPack'02 walk engine
+  *
+  * Contributed by:
+  * Pennsylvania Governor's School for the Sciences 2003 Team Project
+  * Group name: "See, Spot; Run"
+  * Members: Haoqian Chen, Elena Glassman, Chengjou Liao, Yantian Martin, Lisa Shank, Jon Stahlman
+  *
+  * @author PA Gov. School for the Sciences 2003 Team Project - Motion group: Haoqian Chen, Yantian Martin, Jon Stahlman (creators)
+  * 
+  * $Author: ejt $
+  * $Name: HEAD $
+  * $Revision: 1.2 $
+  * $State: Exp $
+  * $Date: 2003/10/10 20:25:03 $
+  */
+ 
+ #include "StartupBehavior.h"
+ 
+ #include "Behaviors/Controls/ControlBase.h"
+ 
+ #include "Behaviors/Mon/WalkControllerBehavior.h"
+ #include "Behaviors/Controls/BehaviorSwitchControl.h"
+ #include "Behaviors/Controls/LoadWalkControl.h"
+ #include "Behaviors/Controls/SaveWalkControl.h"
+ #include "Behaviors/Controls/ValueEditControl.h"
+ 
+ ControlBase*
+ StartupBehavior::SetupWalkEdit() {
+ 	addItem(new ControlBase("Walk Edit","Edit the walk parameters"));
+ 	startSubMenu();
+ 	{ 
+ 		WalkControllerBehavior * walker = new WalkControllerBehavior ;
+ 		addItem((new BehaviorSwitchControl<WalkControllerBehavior>("Walk Remote Control",walker)));
+ 
+ 		addItem(new ValueEditControl<float>("Slow Motion",walker->getWalkMC()->getSlowMo()));
+ 
+ 		addItem(new ControlBase("Body","Edit the walk parameters"));
+ 		startSubMenu();
+ 		{ 
+ 			addItem(new ValueEditControl<double>("Body Height",&walker->getWalkMC()->getWP().body_height));
+ 			addItem(new ValueEditControl<double>("Body Angle",&walker->getWalkMC()->getWP().body_angle));
+ 			addItem(new ValueEditControl<double>("Hop",&walker->getWalkMC()->getWP().hop));
+ 			addItem(new ValueEditControl<double>("Sway",&walker->getWalkMC()->getWP().sway));
+ 			addItem(new ValueEditControl<long>("Period",&walker->getWalkMC()->getWP().period));
+ 		}
+ 		endSubMenu();
+ 
+ 		addItem(new ControlBase("Neutral","Edit the walk parameters"));
+ 		startSubMenu();
+ 		{ 
+ 			addItem(new ValueEditControl<double>("NeuLeg[xFL]",&walker->getWalkMC()->getWP().leg[0].neutral.x));
+ 			addItem(new ValueEditControl<double>("NeuLeg[xFR]",&walker->getWalkMC()->getWP().leg[1].neutral.x));
+ 			addItem(new ValueEditControl<double>("NeuLeg[xBL]",&walker->getWalkMC()->getWP().leg[2].neutral.x));
+ 			addItem(new ValueEditControl<double>("NeuLeg[xBR]",&walker->getWalkMC()->getWP().leg[3].neutral.x));
+ 			addItem(new ValueEditControl<double>("NeuLeg[yFL]",&walker->getWalkMC()->getWP().leg[0].neutral.y));
+ 			addItem(new ValueEditControl<double>("NeuLeg[yFR]",&walker->getWalkMC()->getWP().leg[1].neutral.y));
+ 			addItem(new ValueEditControl<double>("NeuLeg[yBL]",&walker->getWalkMC()->getWP().leg[2].neutral.y));
+ 			addItem(new ValueEditControl<double>("NeuLeg[yBR]",&walker->getWalkMC()->getWP().leg[3].neutral.y));
+ 			addItem(new ValueEditControl<double>("NeuLeg[zFL]",&walker->getWalkMC()->getWP().leg[0].neutral.z));
+ 			addItem(new ValueEditControl<double>("NeuLeg[zFR]",&walker->getWalkMC()->getWP().leg[1].neutral.z));
+ 			addItem(new ValueEditControl<double>("NeuLeg[zBL]",&walker->getWalkMC()->getWP().leg[2].neutral.z));
+ 			addItem(new ValueEditControl<double>("NeuLeg[zBR]",&walker->getWalkMC()->getWP().leg[3].neutral.z));
+ 		}
+ 		endSubMenu();
+ 
+ 		addItem(new ControlBase("lift_vel","Edit the walk parameters"));
+ 		startSubMenu();
+ 		{ 
+ 			addItem(new ValueEditControl<double>("liftLeg[xFL]",&walker->getWalkMC()->getWP().leg[0].lift_vel.x));
+ 			addItem(new ValueEditControl<double>("liftLeg[xFR]",&walker->getWalkMC()->getWP().leg[1].lift_vel.x));
+ 			addItem(new ValueEditControl<double>("liftLeg[xBL]",&walker->getWalkMC()->getWP().leg[2].lift_vel.x));
+ 			addItem(new ValueEditControl<double>("liftLeg[xBR]",&walker->getWalkMC()->getWP().leg[3].lift_vel.x));
+ 			addItem(new ValueEditControl<double>("liftLeg[yFL]",&walker->getWalkMC()->getWP().leg[0].lift_vel.y));
+ 			addItem(new ValueEditControl<double>("liftLeg[yFR]",&walker->getWalkMC()->getWP().leg[1].lift_vel.y));
+ 			addItem(new ValueEditControl<double>("liftLeg[yBL]",&walker->getWalkMC()->getWP().leg[2].lift_vel.y));
+ 			addItem(new ValueEditControl<double>("liftLeg[yBR]",&walker->getWalkMC()->getWP().leg[3].lift_vel.y));
+ 			addItem(new ValueEditControl<double>("liftLeg[zFL]",&walker->getWalkMC()->getWP().leg[0].lift_vel.z));
+ 			addItem(new ValueEditControl<double>("liftLeg[zFR]",&walker->getWalkMC()->getWP().leg[1].lift_vel.z));
+ 			addItem(new ValueEditControl<double>("liftLeg[zBL]",&walker->getWalkMC()->getWP().leg[2].lift_vel.z));
+ 			addItem(new ValueEditControl<double>("liftLeg[zBR]",&walker->getWalkMC()->getWP().leg[3].lift_vel.z));
+ 		}
+ 		endSubMenu();
+ 
+ 		addItem(new ControlBase("down_vel","Edit the walk parameters"));
+ 		startSubMenu();
+ 		{ 
+ 			addItem(new ValueEditControl<double>("downLeg[xFL]",&walker->getWalkMC()->getWP().leg[0].down_vel.x));
+ 			addItem(new ValueEditControl<double>("downLeg[xFR]",&walker->getWalkMC()->getWP().leg[1].down_vel.x));
+ 			addItem(new ValueEditControl<double>("downLeg[xBL]",&walker->getWalkMC()->getWP().leg[2].down_vel.x));
+ 			addItem(new ValueEditControl<double>("downLeg[xBR]",&walker->getWalkMC()->getWP().leg[3].down_vel.x));
+ 			addItem(new ValueEditControl<double>("downLeg[yFL]",&walker->getWalkMC()->getWP().leg[0].down_vel.y));
+ 			addItem(new ValueEditControl<double>("downLeg[yFR]",&walker->getWalkMC()->getWP().leg[1].down_vel.y));
+ 			addItem(new ValueEditControl<double>("downLeg[yBL]",&walker->getWalkMC()->getWP().leg[2].down_vel.y));
+ 			addItem(new ValueEditControl<double>("downLeg[yBR]",&walker->getWalkMC()->getWP().leg[3].down_vel.y));
+ 			addItem(new ValueEditControl<double>("downLeg[zFL]",&walker->getWalkMC()->getWP().leg[0].down_vel.z));
+ 			addItem(new ValueEditControl<double>("downLeg[zFR]",&walker->getWalkMC()->getWP().leg[1].down_vel.z));
+ 			addItem(new ValueEditControl<double>("downLeg[zBL]",&walker->getWalkMC()->getWP().leg[2].down_vel.z));
+ 			addItem(new ValueEditControl<double>("downLeg[zBR]",&walker->getWalkMC()->getWP().leg[3].down_vel.z));
+ 		}
+ 		endSubMenu();
+ 
+ 		addItem(new ControlBase("lift_time","Edit the walk parameters"));
+ 		startSubMenu();
+ 		{ 
+ 			addItem(new ValueEditControl<double>("liftimeLeg[FL]",&walker->getWalkMC()->getWP().leg[0].lift_time));
+ 			addItem(new ValueEditControl<double>("liftimeLeg[FR]",&walker->getWalkMC()->getWP().leg[1].lift_time));
+ 			addItem(new ValueEditControl<double>("liftimeLeg[BL]",&walker->getWalkMC()->getWP().leg[2].lift_time));
+ 			addItem(new ValueEditControl<double>("liftimeLeg[BR]",&walker->getWalkMC()->getWP().leg[3].lift_time));
+ 		}
+ 		endSubMenu();
+ 
+ 		addItem(new ControlBase("down_time","Edit the walk parameters"));
+ 		startSubMenu();
+ 		{ 
+ 			addItem(new ValueEditControl<double>("downimeLeg[FL]",&walker->getWalkMC()->getWP().leg[0].down_time));
+ 			addItem(new ValueEditControl<double>("downimeLeg[FR]",&walker->getWalkMC()->getWP().leg[1].down_time));
+ 			addItem(new ValueEditControl<double>("downimeLeg[BL]",&walker->getWalkMC()->getWP().leg[2].down_time));
+ 			addItem(new ValueEditControl<double>("downimeLeg[BR]",&walker->getWalkMC()->getWP().leg[3].down_time));
+ 		}
+ 		endSubMenu();
+ 
+ 		addItem(new LoadWalkControl("Load Walk",walker->getWalkMC()));
+ 		addItem(new SaveWalkControl("Save Walk",walker->getWalkMC()));
+ 	}
+ 	return endSubMenu();
+ }
Index: AiboPup/project/ms/config/default.col
diff -c AiboPup/project/ms/config/default.col:1.1 AiboPup/project/ms/config/default.col:1.2
*** AiboPup/project/ms/config/default.col:1.1	Sat Mar  1 16:08:27 2003
--- AiboPup/project/ms/config/default.col	Mon Jul 28 02:58:16 2003
***************
*** 1,12 ****
! # <index> (color) "name" <min size> <merge threshold>
! 0  (  0   0   0) "black"                8 1.00
! 1  (  0 128 255) "blue"                 8 0.75
! 2  (  0 128   0) "green"                8 0.75
! 3  (255 128   0) "orange"               8 0.75
! 4  (  0 255   0) "bgreen"               8 0.75
! 5  (128   0 255) "purple"               8 0.75
! 6  (255   0   0) "red"                  8 0.75
! 7  (255 128 224) "pink"                 8 0.75
! 8  (255 255   0) "yellow"               8 0.75
! 9  (200 200 200) "gray"                 8 0.75
! 10 (150 100   0) "skin"                 8 0.75
--- 1,10 ----
! 0 (128 128 128) "unclassified" 8 1.00
! 1 (24 43 93) "blue" 8 0.75
! 2 (255 255 255) "white" 8 0.75
! 3 (237 131 54) "orange" 8 0.75
! 4 (43 150 180) "azure" 8 0.75
! 5 (36 67 23) "green" 8 0.75
! 6 (209 60 97) "red" 8 0.75
! 7 (200 189 123) "yellow" 8 0.75
! 8 (0 0 0) "black" 8 0.75
! 9 (113 80 34) "brown" 8 0.75
Index: AiboPup/project/ms/config/default.tm
Index: AiboPup/project/ms/config/general.tm
Index: AiboPup/project/ms/config/pb.tm
Index: AiboPup/project/ms/config/phb.tm
Index: AiboPup/project/ms/config/tekkotsu.cfg
diff -c AiboPup/project/ms/config/tekkotsu.cfg:1.17 AiboPup/project/ms/config/tekkotsu.cfg:1.21
*** AiboPup/project/ms/config/tekkotsu.cfg:1.17	Mon Jul  7 00:32:47 2003
--- AiboPup/project/ms/config/tekkotsu.cfg	Thu Oct  9 02:25:30 2003
***************
*** 12,24 ****
  # shutter_speed  slow|mid|fast
  shutter_speed=mid
  # resolution     quarter|half|full
! resolution=half
  
! thresh=/ms/config/ball.tm
  colors=/ms/config/default.col
  raw_port=10011
  rle_port=10012
  obj_port=10013
  
  [Main]
  console_port=10001
--- 12,32 ----
  # shutter_speed  slow|mid|fast
  shutter_speed=mid
  # resolution     quarter|half|full
! resolution=full
  
! thresh=/ms/config/phb.tm
! # other included options for thresh:
! # general.tm - general colors, previously 'default'
! # ball.tm - standard Sony pink ball definition
! # pb.tm - pink and blue
! # phb.tm - pink, skin, and blue
! #   note: "skin" is that of people who work in our lab - not a general sampling... :(
  colors=/ms/config/default.col
  raw_port=10011
  rle_port=10012
  obj_port=10013
+ # raw_encoding   half|yfull_uvhalf|full
+ raw_encoding=yfull_uvhalf
  
  [Main]
  console_port=10001
***************
*** 32,37 ****
--- 40,46 ----
  aibo3d_port=10051
  headControl_port=10052
  estopControl_port=10053
+ wmmonitor_port=10061
  use_VT100=true
  
  [Behaviors]
***************
*** 48,53 ****
--- 57,65 ----
  root=/ms/data/motion
  estop_on_snd=skid.wav
  estop_off_snd=yap.wav
+ max_head_tilt_speed=2.1
+ max_head_pan_speed=3.0
+ max_head_roll_speed=3.0
  
  [Sound]
  root=/ms/data/sound
Index: AiboPup/project/ms/data/motion/leftkick.pos
diff -c /dev/null AiboPup/project/ms/data/motion/leftkick.pos:1.1
*** /dev/null	Fri Oct 10 14:37:51 2003
--- AiboPup/project/ms/data/motion/leftkick.pos	Sun Sep 21 15:44:14 2003
***************
*** 0 ****
--- 1,44 ----
+ #POS
+ LFr:rotor	-0.3080	 1.0000
+ LFr:elvtr	 0.0456	 1.0000
+ LFr:knee~	 0.7328	 1.0000
+ RFr:rotor	 0.2871	 1.0000
+ RFr:elvtr	-0.0873	 1.0000
+ RFr:knee~	 0.0000	 1.0000
+ LBk:rotor	-0.4014	 1.0000
+ LBk:elvtr	 0.1824	 1.0000
+ LBk:knee~	 0.3916	 1.0000
+ RBk:rotor	-0.8500	 1.0000
+ RBk:elvtr	 0.3306	 1.0000
+ RBk:knee~	 1.1985	 1.0000
+ NECK:tilt	 0.0000	 1.0000
+ NECK:pan~	 0.0000	 1.0000
+ NECK:roll	-0.0038	 1.0000
+ TAIL:tilt	-0.0172	 1.0000
+ TAIL:pan~	 0.0172	 1.0000
+ MOUTH~~~~	-0.0524	 1.0000
+ LED:botL~	 0.0000	 1.0000
+ LED:botR~	 0.0000	 1.0000
+ LED:midL~	 0.0000	 1.0000
+ LED:midR~	 0.0000	 1.0000
+ LED:topL~	 0.0000	 1.0000
+ LED:topR~	 0.0000	 1.0000
+ LED:topBr	 0.0000	 1.0000
+ LED:bkL1~	 0.0000	 1.0000
+ LED:bkL2~	 0.0000	 1.0000
+ LED:bkL3~	 0.0000	 1.0000
+ LED:bkR3~	 0.0000	 1.0000
+ LED:bkR2~	 0.0000	 1.0000
+ LED:bkR1~	 0.0000	 1.0000
+ LED:tailL	 0.0000	 1.0000
+ LED:tailC	 0.0000	 1.0000
+ LED:tailR	 0.0000	 1.0000
+ LED:faceB	 0.0000	 1.0000
+ LED:faceA	 0.0000	 1.0000
+ LED:faceC	 0.0000	 1.0000
+ LED:light	 0.0000	 1.0000
+ LED:tlRed	 0.0000	 1.0000
+ LED:tlBlu	 0.0000	 1.0000
+ EAR:left~	 0.0000	 1.0000
+ EAR:right	 0.0000	 1.0000
+ #END
Index: AiboPup/project/ms/data/motion/pace.prm
Index: AiboPup/project/ms/data/motion/rightkick.pos
diff -c /dev/null AiboPup/project/ms/data/motion/rightkick.pos:1.1
*** /dev/null	Fri Oct 10 14:37:51 2003
--- AiboPup/project/ms/data/motion/rightkick.pos	Sun Sep 21 15:44:14 2003
***************
*** 0 ****
--- 1,44 ----
+ #POS
+ LFr:rotor	 0.1654	 1.0000
+ LFr:elvtr	 0.0228	 1.0000
+ LFr:knee~	 0.4531	 1.0000
+ RFr:rotor	 0.1858	 1.0000
+ RFr:elvtr	-0.0349	 1.0000
+ RFr:knee~	 0.9183	 1.0000
+ LBk:rotor	 0.2493	 1.0000
+ LBk:elvtr	 0.4389	 1.0000
+ LBk:knee~	 0.8055	 1.0000
+ RBk:rotor	-0.4930	 1.0000
+ RBk:elvtr	 0.4275	 1.0000
+ RBk:knee~	 1.1636	 1.0000
+ NECK:tilt	-0.0038	 1.0000
+ NECK:pan~	 0.0000	 1.0000
+ NECK:roll	 0.0038	 1.0000
+ TAIL:tilt	-0.0229	 1.0000
+ TAIL:pan~	 0.0000	 1.0000
+ MOUTH~~~~	-0.0524	 1.0000
+ LED:botL~	 1.0000	 1.0000
+ LED:botR~	 1.0000	 1.0000
+ LED:midL~	 0.0400	 1.0000
+ LED:midR~	 0.0400	 1.0000
+ LED:topL~	 0.0000	 1.0000
+ LED:topR~	 0.0000	 1.0000
+ LED:topBr	 0.0000	 1.0000
+ LED:bkL1~	 0.0000	 1.0000
+ LED:bkL2~	 0.0000	 1.0000
+ LED:bkL3~	 0.0000	 1.0000
+ LED:bkR3~	 0.0000	 1.0000
+ LED:bkR2~	 0.0000	 1.0000
+ LED:bkR1~	 0.0000	 1.0000
+ LED:tailL	 0.0000	 1.0000
+ LED:tailC	 0.0000	 1.0000
+ LED:tailR	 0.0000	 1.0000
+ LED:faceB	 0.0000	 1.0000
+ LED:faceA	 0.0000	 1.0000
+ LED:faceC	 0.0000	 1.0000
+ LED:light	 0.0000	 1.0000
+ LED:tlRed	 0.0000	 1.0000
+ LED:tlBlu	 0.0000	 1.0000
+ EAR:left~	 1.0000	 1.0000
+ EAR:right	 1.0000	 1.0000
+ #END
Index: AiboPup/project/ms/data/motion/tiger.prm
Index: AiboPup/project/ms/open-r/mw/conf/passwd
diff -c AiboPup/project/ms/open-r/mw/conf/passwd:1.3 AiboPup/project/ms/open-r/mw/conf/passwd:1.4
*** AiboPup/project/ms/open-r/mw/conf/passwd:1.3	Tue Jul  8 14:01:21 2003
--- AiboPup/project/ms/open-r/mw/conf/passwd	Mon Jul 28 02:58:30 2003
***************
*** 2,5 ****
  #guest * /MS/OPEN-R/MW/
  config config /MS/CONFIG/
  data data /MS/DATA/
! 
--- 2,5 ----
  #guest * /MS/OPEN-R/MW/
  config config /MS/CONFIG/
  data data /MS/DATA/
! ftpinst ftpinst /MS/
Index: AiboPup/project/ms/open-r/system/conf/wlandflt.txt
diff -c AiboPup/project/ms/open-r/system/conf/wlandflt.txt:1.12 AiboPup/project/ms/open-r/system/conf/wlandflt.txt:1.17
*** AiboPup/project/ms/open-r/system/conf/wlandflt.txt:1.12	Sun Jul  6 21:00:09 2003
--- AiboPup/project/ms/open-r/system/conf/wlandflt.txt	Fri Oct 10 13:02:38 2003
***************
*** 1,9 ****
! HOSTNAME=lycra
! ETHER_IP=192.168.0.5
! ETHER_NETMASK=255.255.255.0
! IP_GATEWAY=192.168.0.1
  ESSID=AIBONET
  WEPENABLE=0
  WEPKEY=
  APMODE=1
! CHANNEL=1
--- 1,31 ----
! # Make this your "human readable" name
! # This only really works if you have a DNS server also
! # configured with this name
! HOSTNAME=
! 
! # The name of the Wireless network to join
  ESSID=AIBONET
+ 
+ # Do you want encryption?
  WEPENABLE=0
  WEPKEY=
+ 
+ # APMODE=0 - "ad-hoc demo mode" (peer-to-peer)
+ #       =1 - "infrastructure mode" (access point)
+ #       =2 - "auto-detect" (defaults to infrastructure if both are found)
  APMODE=1
! 
! # Channel of wireless network - is only needed with APMODE=0
! #CHANNEL=1
! 
! # Dynamic Host Configuration Protocol - automatically gets IP address
! # from DHCP server.  Note that you will need either a DNS server or a
! # static IP from the DHCP server or you won't know what IP address the
! # Aibo is running under
! USE_DHCP=1
! 
! # If you don't have DHCP, you'll need to set these manually
! #ETHER_IP=192.168.0.5
! #ETHER_NETMASK=255.255.255.0
! #IP_GATEWAY=192.168.0.1
! 
Index: AiboPup/tools/Makefile
diff -c AiboPup/tools/Makefile:1.2 AiboPup/tools/Makefile:1.5
*** AiboPup/tools/Makefile:1.2	Sun Apr  6 16:57:48 2003
--- AiboPup/tools/Makefile	Sun Aug 24 17:18:59 2003
***************
*** 1,7 ****
! COMPONENTS=binstrswap filtersyswarn mon
  TARGETS=all clean
  
! .PHONY: $(TARGETS) install all clean
  
  $(TARGETS):
  	@for dir in $(COMPONENTS); do \
--- 1,7 ----
! COMPONENTS=binstrswap filtersyswarn evenmodtime mon mipaltools
  TARGETS=all clean
  
! .PHONY: $(TARGETS)
  
  $(TARGETS):
  	@for dir in $(COMPONENTS); do \
***************
*** 11,15 ****
  			exit 1; \
  		fi; \
  	done
- 
- install:
--- 11,13 ----
Index: AiboPup/tools/buildDocs
diff -c /dev/null AiboPup/tools/buildDocs:1.1
*** /dev/null	Fri Oct 10 14:37:52 2003
--- AiboPup/tools/buildDocs	Sun Jul 20 15:25:38 2003
***************
*** 0 ****
--- 1,44 ----
+ #!/bin/sh
+ 
+ 
+ #initialization
+ 
+ tmp="/tmp";
+ if [ -z "$MEMSTICK_ROOT" ] ; then
+ 	MEMSTICK_ROOT=/mnt/memstick
+ fi;
+ 
+ if [ $# -lt 1 ] ; then
+ 	echo "Usage $0 <newversion>";
+ 	exit 2;
+ fi;
+ newtag=tekkotsu-`echo $1 | tr . _`;
+ 
+ echo New tag: ${newtag}
+ 
+ 
+ 
+ #cvs export source
+ 
+ cd ${tmp};
+ rm -rf Tekkotsu_$1
+ 
+ cvs export -r ${newtag} -d Tekkotsu_$1 Tekkotsu
+ 
+ if [ ! -d Tekkotsu_$1 ] ; then
+ 	echo "cvs export failed"
+ 	exit 1;
+ fi;
+ 
+ 
+ 
+ #build documentation
+ 
+ cd ${tmp}/Tekkotsu_$1;
+ docs/builddocs -a -c -r -s -t;
+ cd docs/generated;
+ mv html Tekkotsu_doc_$1;
+ tar -cvzf Tekkotsu_doc_$1.tar.gz --exclude Tekkotsu_doc_$1/search.idx Tekkotsu_doc_$1;
+ mv Tekkotsu_doc_$1.tar.gz ${tmp};
+ 
+ 
Index: AiboPup/tools/buildRelease
diff -c /dev/null AiboPup/tools/buildRelease:1.23
*** /dev/null	Fri Oct 10 14:37:52 2003
--- AiboPup/tools/buildRelease	Fri Oct 10 02:14:23 2003
***************
*** 0 ****
--- 1,142 ----
+ #!/bin/sh
+ 
+ 
+ #initialization
+ 
+ tmp="/tmp";
+ if [ -z "$MEMSTICK_ROOT" ] ; then
+ 	MEMSTICK_ROOT=/mnt/memstick
+ fi;
+ 
+ if [ $# -lt 2 ] ; then
+ 	echo "Usage $0 <newversion> <prevversion>";
+ 	exit 2;
+ fi;
+ newtag=tekkotsu-`echo $1 | tr . _`;
+ oldtag=tekkotsu-`echo $2 | tr . _`;
+ 
+ echo New tag: ${newtag}
+ echo Old tag: ${oldtag}
+ 
+ 
+ 
+ #cvs export source
+ 
+ cd ${tmp};
+ rm -rf Tekkotsu_$1
+ rm -rf Tekkotsu_$1.tar.gz
+ rm -rf Tekkotsu_memstick_$1
+ rm -rf Tekkotsu_memstick_$1.tar.gz
+ 
+ cvs export -r ${newtag} -d Tekkotsu_$1 Tekkotsu
+ if [ ! -d Tekkotsu_$1 ] ; then
+ 	echo "cvs export failed"
+ 	exit 1;
+ fi;
+ 
+ 
+ 
+ #build source tarball
+ 
+ cd Tekkotsu_$1;
+ 
+ #if [ `grep -c default.tm project/ms/config/tekkotsu.cfg` -gt 0 ] ; then
+ #	echo "You forgot to switch the thresholds file to the more general ball one";
+ #	exit 1;
+ #fi;
+ 
+ if [ `grep PROJECT_NUMBER docs/doxygencfg | grep -c $1` -eq 0 ] ; then
+ 	echo "Version mismatch with docs/doxygencfg - you forgot to update PROJECT_NUMBER";
+ 	exit 1;
+ fi;
+ 
+ for x in project/SampleMC.h project/SampleBehavior.h ; do
+ 	if [ -d "$x" ] ; then
+ 		echo "You forgot to untag the sample file"
+ 		exit 1;
+ 	fi;
+ done;
+ 
+ curt=`date +%Y%m%d%H%M`;
+ find project/ms -exec touch -ft $curt \{\} \; ;
+ 
+ cd ${tmp};
+ tar -cvzf Tekkotsu_$1.tar.gz Tekkotsu_$1;
+ 
+ 
+ 
+ #build memstick image tarball
+ 
+ cd Tekkotsu_$1;
+ cd project;
+ 
+ export TEKKOTSU_ROOT=..
+ 
+ for x in TGT_ERS210 TGT_ERS220 TGT_ERS2xx ; do
+ 	echo $x > ${TEKKOTSU_ROOT}/TARGET_MODEL;
+ 	printf "\n\nTesting $x build\n\n\n";
+ 	gmake clean
+ 	if [ $? -ne 0 ] ; then
+ 		echo "Framework clean failed"
+ 		exit 1;
+ 	fi;
+ 	gmake;
+ 	if [ $? -ne 0 ] ; then
+ 		echo "Framework Build failed"
+ 		exit 1;
+ 	fi;
+ done;
+ 
+ echo "Enter memstick to be built onto - this memstick will be erased";
+ mntmem $MEMSTICK_ROOT;
+ rm -rf /mnt/memstick;
+ gmake update;
+ if [ $? -ne 0 ] ; then
+ 	echo "Project build failed"
+ 	exit 1;
+ fi;
+ 
+ mntmem $MEMSTICK_ROOT;
+ cp -arp /mnt/memstick ${tmp}/Tekkotsu_memstick_$1;
+ umntmem $MEMSTICK_ROOT;
+ chmod a+rx ${tmp}/Tekkotsu_memstick_$1
+ 
+ cd ${tmp};
+ tar -cvzf Tekkotsu_memstick_$1.tar.gz Tekkotsu_memstick_$1;
+ 
+ echo "Build done - don't forget to double check the image actually works"
+ 
+ 
+ 
+ #build TekkotsuMon tarball
+ 
+ cd ${tmp};
+ cp -r Tekkotsu_$1/tools/mon Tekkotsu_mon_$1;
+ tar -czvf Tekkotsu_mon_$1.tar.gz Tekkotsu_mon_$1;
+ 
+ 
+ 
+ #build patch file
+ 
+ cd ${tmp}
+ cvs rdiff -r ${oldtag} -r ${newtag} AiboPup > Tekkotsu_patch_$2_to_$1.diff;
+ 
+ 
+ 
+ #build documentation
+ 
+ cd ${tmp}/Tekkotsu_$1;
+ docs/builddocs -a -c -r -s -t;
+ cd docs/generated;
+ mv html Tekkotsu_doc_$1;
+ tar -cvzf Tekkotsu_doc_$1.tar.gz --exclude Tekkotsu_doc_$1/search.idx Tekkotsu_doc_$1;
+ mv Tekkotsu_doc_$1.tar.gz ${tmp};
+ 
+ 
+ 
+ #final notice
+ 
+ echo "Done!"
+ echo ""
+ echo "If you disabled robot access on the staging website, don't forget to"
+ echo "turn it back on!"
Index: AiboPup/tools/cmake
diff -c /dev/null AiboPup/tools/cmake:1.1
*** /dev/null	Fri Oct 10 14:37:52 2003
--- AiboPup/tools/cmake	Mon Jul 28 02:34:13 2003
***************
*** 0 ****
--- 1,21 ----
+ #!/usr/bin/perl
+ 
+ use Term::ANSIColor;
+ 
+ $args="";
+ for ($i=0; $i<=$#ARGV; $i++) {
+   $args.=" ".$ARGV[$i];
+ }
+ 
+ open (IN, "make $args |");
+ 
+ while (<IN>) {
+   chomp;
+   if (/^Building/ || /^Compiling/ || /^Linking/) {
+     print (color("bold blue"), $_, color("reset"), "\n");
+   } else {
+     print "$_\n";
+   }
+ }
+ 
+ close (IN);
Index: AiboPup/tools/colorfilt
diff -c /dev/null AiboPup/tools/colorfilt:1.1
*** /dev/null	Fri Oct 10 14:37:52 2003
--- AiboPup/tools/colorfilt	Mon Jul 28 02:34:13 2003
***************
*** 0 ****
--- 1,77 ----
+ #!/usr/bin/perl
+ # from:
+ # colorgcc
+ # Author: Jamie Moyers <jmoyers@geeks.com>
+ # Started: April 20, 1999
+ # Licence: GNU Public License
+ 
+ # Alok Ladsariya
+ 
+ use Term::ANSIColor;
+ 
+ $colors{"src_color"} = color("cyan");
+ $colors{"intro_color"} = color("green");
+ $colors{"loc_color"} = color("bold yellow");
+ $colors{"warning_color"} = color("yellow");
+ $colors{"error_color"} = color("bold red");
+ 
+ $line="";
+ $nextline="";
+ while (<stdin>) {
+   chomp;
+   if (/^   (.*)/) {
+     $nextline.=$1;
+     next;
+   } else {
+     $line=$nextline;
+     $nextline=$_;
+   }
+   $_=$line."\n";
+ 
+   if (m/^In file included from/) {
+     print($colors{"loc_color"}, $_, color("reset"));
+   } elsif (m/^(.*?):([0-9]+):(.*)$/) {
+     $field1 = $1 || "";
+     $field2 = $2 || "";
+     $field3 = $3 || "";
+ 
+     if ($field3 =~ m/\s+warning:.*/) {
+       print($colors{"warning_color"}, "$field1:$field2:", color("reset"));
+       srcscan($field3, $colors{"warning_color"});
+     } elsif ($field3 =~ m/instantiated from/) {
+       srcscan($_, $colors{"intro_color"});
+     } else {
+       print($colors{"error_color"}, "$field1:$field2:", color("reset"));
+       srcscan($field3, $colors{"error_color"});
+     }
+     print("\n");
+   } elsif (m/^(.*?):(.+):$/) {
+     srcscan($_, $colors{"intro_color"});
+   } else {
+     print(color("reset"), $_);
+   }
+ }
+ 
+ sub srcscan
+ {
+ # Usage: srcscan($text, $normalColor)
+ #    $text -- the text to colorize
+ #    $normalColor -- The escape sequence to use for non-source text.
+ 
+ # Looks for text between ` and ', and colors it src_color.
+ 
+   my($line, $normalColor) = @_;
+ 
+   my($srcon) = color("reset") . $colors{"src_color"};
+   my($srcoff) = color("reset") . $normalColor;
+ 
+   $line = $normalColor . $line;
+ 
+ # This substitute replaces `foo' with `AfooB' where A is the escape
+ # sequence that turns on the the desired source color, and B is the
+ # escape sequence that returns to $normalColor.
+   $line =~ s/\`(.*?)\'/\`$srcon$1$srcoff\'/g;
+ 
+   print($line, color("reset"));
+ }
+ 
Index: AiboPup/tools/crashDebug
diff -c /dev/null AiboPup/tools/crashDebug:1.11
*** /dev/null	Fri Oct 10 14:37:52 2003
--- AiboPup/tools/crashDebug	Thu Oct  9 20:45:46 2003
***************
*** 0 ****
--- 1,133 ----
+ #!/bin/bash
+ 
+ if [ "$1" = "-h" -o "$1" = "--help" -o ! -r Makefile ] ; then
+ 	echo "Usage: $0 [-q] [-mipal [mi-pal_options]]";
+ 	echo "       -q     will do a quick analysis using emonLogParser (from Sony)";
+ 	echo "       -mipal will use the Mi-Pal tools from Griffith University";
+ 	echo "              mi-pal_options (if any) are passed to StackedIt";
+ 	echo "       If no options are given, '-q -mipal -2' is assumed.";
+ 	echo "       This command will read the value of the MEMSTICK_ROOT, TEKKOTSU_ROOT,";
+ 	echo "       and FILENAME_CASE environment variables to find the emon.log file";
+ 	echo "       and other tools.";
+ 	echo "       This should be run from within the project directory";
+ 	echo "       which caused the crash";
+ fi;
+ 
+ if [ "$1" = "-h" -o "$1" = "--help" ] ; then
+ 	exit 2;
+ fi;
+ 
+ BUILDDIR=`grep "^BUILDDIR.*=" Makefile | cut -f 2- -d =`;
+ if [ ! "$BUILDDIR" ] ; then
+ 	echo "WARNING: could not find BUILDDIR specification in Makefile.";
+ 	echo "         Defaulting to 'build'.";
+ 	BUILDDIR=build;
+ fi;
+ 
+ if [ ! -d "$BUILDDIR" ] ; then
+ 	echo "ERROR: Build directory '$BUILDDIR' does not exist";
+ 	exit 1;
+ fi;
+ 
+ runquick=;
+ if [ "$1" = "-q" ] ; then
+ 	runquick=true;
+ 	shift;
+ fi;
+ 
+ runmipal=;
+ if [ "$1" = "-mipal" ] ; then
+ 	runmipal=true;
+ 	shift;
+ 
+ 	options=$*;
+ 	if [ ! "$options" ] ; then
+ 		options=-2
+ 	fi;
+ fi;
+ 
+ if [ -z "$runquick" -a -z "$runmipal" -a $# -eq 0 ] ; then
+ 	runquick=true;
+ 	runmipal=true;
+ 	options=-2;
+ fi;
+ 
+ if [ -z "$TEKKOTSU_ROOT" ] ; then
+ 	TEKKOTSU_ROOT=/usr/local/Tekkotsu;
+ fi;
+ if [ ! -d "$TEKKOTSU_ROOT" ] ; then
+ 	echo "ERROR: Could not find TEKKOTSU_ROOT: $TEKKOTSU_ROOT";
+ 	exit 1;
+ fi;
+ 
+ if [ -z "$MEMSTICK_ROOT" ] ; then
+ 	MEMSTICK_ROOT=/mnt/memstick;
+ fi;
+ 
+ if [ -z "FILENAME_CASE" ] ; then
+ 	FILENAME_CASE=lower;
+ fi;
+ 
+ cd "$BUILDDIR"
+ 
+ if [ "$FILENAME_CASE"="lower" ] ; then
+ 	ln -sf mmcombo.nosnap.elf MainObj.nosnap.elf;
+ 	ln -sf mmcombo.nosnap.elf MotoObj.nosnap.elf;
+ 	ln -sf sndplay.nosnap.elf SoundPlay.nosnap.elf;
+ 	EMON=open-r/emon.log;
+ else
+ 	ln -sf MMCOMBO.nosnap.elf MainObj.nosnap.elf;
+ 	ln -sf MMCOMBO.nosnap.elf MotoObj.nosnap.elf;
+ 	ln -sf SNDPLAY.nosnap.elf SoundPlay.nosnap.elf;
+ 	EMON=OPEN-R/EMON.LOG;
+ fi;
+ 
+ # remove any previous disassembly files
+ rm -f aiboDis*.ass;
+ # just so the elp.pl doesn't complain about not finding any previous
+ touch aiboDis0.ass;
+ 
+ ${TEKKOTSU_ROOT}/tools/mntmem;
+ if [ $? -ne 0 ] ; then
+ 
+ 	echo "ERROR: Memory stick not mounted.";
+ 	exit 1;
+ 
+ else
+ 
+ 	if [ "$runquick" ] ; then
+ 		${TEKKOTSU_ROOT}/tools/emonLogParser ${MEMSTICK_ROOT}/${EMON} > quick-out.txt;
+ 		file=`sed -n '/object:/s/object:	*//p' quick-out.txt`;
+ 		${TEKKOTSU_ROOT}/tools/emonLogParser ${MEMSTICK_ROOT}/${EMON} ${file}.nosnap.elf;
+ 	fi;
+ 
+ 	if [ "$runmipal" ] ; then
+ 		if [ "$runquick" ] ; then
+ 			echo "";
+ 		fi;
+ 		printf "Using StackedIt options: $options\n";
+ 		printf "Generating disassembly...";
+ 		${TEKKOTSU_ROOT}/tools/mipaltools/elp.pl -e ${MEMSTICK_ROOT}/${EMON} > elp-out.txt;
+ 		echo "done.";
+ 		
+ 		LINES=`cat elp-out.txt | wc -l`
+ 		
+ 		echo "*** Using elp.pl by Stuart Seymon (v2.0, 5/9/2003) ***"
+ 		echo "***  Mi-Pal,  Griffith University, Australia  ***"
+ 		echo " see ${TEKKOTSU_ROOT}/tools/mipaltools/ for more info"
+ 		head -`expr $LINES - 7` elp-out.txt;
+ 		
+ 		EPC=`grep "^EPC:" elp-out.txt | cut -f 2 -d x`;
+ 		RT=`grep "^linkTimeAddr:" elp-out.txt | cut -f 2 -d x`;
+ 		
+ 		echo
+ 		echo "*** Using StackedIt by Joel Fenwick (v2.0, 1/9/2003) ***"
+ 		echo "***   Mi-Pal,  Griffith University, Australia    ***"
+ 		echo " see ${TEKKOTSU_ROOT}/tools/mipaltools/ for more info"
+ 		${TEKKOTSU_ROOT}/tools/mipaltools/StackedIt $options $EPC $RT aiboDis1.ass ${MEMSTICK_ROOT}/${EMON};
+ 		
+ 		${TEKKOTSU_ROOT}/tools/umntmem;
+ 	fi;
+ 
+ fi;
+ 
Index: AiboPup/tools/dist_hosts.txt
diff -c /dev/null AiboPup/tools/dist_hosts.txt:1.2
*** /dev/null	Fri Oct 10 14:37:52 2003
--- AiboPup/tools/dist_hosts.txt	Thu Sep 25 11:32:15 2003
***************
*** 0 ****
--- 1,8 ----
+ #machine		basepath		priority	force
+ unix44.andrew.cmu.edu	~/Tekkotsu/project	17		0
+ unix45.andrew.cmu.edu	~/Tekkotsu/project	17		0
+ unix46.andrew.cmu.edu	~/Tekkotsu/project	17		0
+ unix47.andrew.cmu.edu	~/Tekkotsu/project	17		0
+ unix48.andrew.cmu.edu	~/Tekkotsu/project	17		0
+ unix49.andrew.cmu.edu	~/Tekkotsu/project	17		0
+ unix50.andrew.cmu.edu	~/Tekkotsu/project	17		0
Index: AiboPup/tools/ftpinstall
diff -c /dev/null AiboPup/tools/ftpinstall:1.1
*** /dev/null	Fri Oct 10 14:37:52 2003
--- AiboPup/tools/ftpinstall	Mon Jul 28 02:34:13 2003
***************
*** 0 ****
--- 1,177 ----
+ #!/usr/bin/perl
+ #
+ # mstreeput 
+ #
+ # Copyright 2002 Sony Corporation
+ #
+ $|=1;
+ 
+ use Socket;
+ $username = "lycra";
+ $password = "lives";
+ 
+ #----- set default options -----
+ $message        = "\n ftpinstall - install MS tree using TinyFTP\n\n"
+                 ."  usage:\n       mstreeput [options] addr dir\n"
+                 ."  options:\n"
+                 ."      -u    : username\n"
+                 ."      -p    : password\n"
+                 ."      -h    : help\n"
+                 ."\n";
+ 
+ use Getopt::Std;
+ getopts('u:p:hH');
+ die $message if ($opt_h || $opt_H);
+ $username = $opt_u if ($opt_u);
+ $password = $opt_p if ($opt_p);
+ 
+ 
+ #----- main -----
+ die $message if @ARGV <= 1;
+ $hostname = shift(@ARGV);
+ $localdir = shift(@ARGV);
+ 
+ chdir($localdir);
+ makecopylist(".");
+ 
+ login();
+ open (ST, "> ".$ENV{"HOME"}."/.tekkotsu_ftplist");
+ for ($i = 0; $i < $numoflist; $i++) {
+     if ($LIST[$i] =~ /\/$/) {
+         ftpmkdir($LIST[$i]);
+     } else {
+         print "$LIST[$i]\n";
+         listenData();
+         ftpput($LIST[$i]);
+ 
+         ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
+          $atime,$mtime,$ctime,$blksize,$blocks)
+           = stat($LIST[$i]);
+         print ST $LIST[$i]."|$mtime\n";
+     }
+ }
+ logout();
+ close(ST);
+ 
+ #----- sub -----
+ sub makecopylist {
+     my $directory = shift(@_);
+     my $numofdir;
+     my @DIRLIST;
+     my $i;
+ 
+     opendir(DIR, $directory);
+     while ($filename = readdir(DIR)) {
+         next if ($filename =~ /^\./);
+         next if ($filename =~ /^CVS$/);
+         $path = "$directory/$filename";
+         $LIST[$numoflist++] = $path if -f $path;
+         if (-d $path) {
+             $LIST[$numoflist++] = "$path/";
+             $DIRLIST[$numofdir++] = $path;
+         }
+     }
+     close(DIR);
+ 
+     for ($i = 0; $i < $numofdir; $i++) {
+         makecopylist($DIRLIST[$i]);
+     }
+ }
+ 
+ sub login {
+     $proto = getprotobyname('tcp');
+     $port = getservbyname('ftp', 'tcp');
+     socket(COMMAND, PF_INET, SOCK_STREAM, $proto)
+         || die "can't creat socket.\n";
+     
+     $sock_addr = pack_sockaddr_in($port, inet_aton($hostname));
+     connect(COMMAND, $sock_addr) || die "cant't connect\n";
+     select(COMMAND); $|=1; select(STDOUT);
+ 
+     while(<COMMAND>) {
+         die $_ if (/^[^123]\d+\s/);
+         last if (/^\d+\s/);
+     }
+     
+     print COMMAND "USER $username\r\n";
+     while(<COMMAND>) {
+         die $_ if (/^[^123]\d+\s/);
+         last if (/^\d+\s/);
+     }
+     
+     print COMMAND "PASS $password\r\n";
+     while(<COMMAND>) {
+         die $_ if (/^[^123]\d+\s/);
+         last if (/^\d+\s/);
+     }
+ }
+ 
+ sub logout {
+     print COMMAND "REBT\r\n";
+     close(COMMAND);
+ }
+ 
+ sub listenData {
+     for ($data_port = 5000; $data_port < 65536; $data_port++) {
+         socket(DATA, PF_INET, SOCK_STREAM, $proto)
+             || die "cant't connect\n";
+         
+         if (bind(DATA, pack_sockaddr_in($data_port, INADDR_ANY))) {
+             last;
+         } else {
+             die "can't bind port\n" if ($data_port == 65535);
+         }
+     }
+ 
+     listen(DATA, 1) || die "listen: $!";
+     $local_sock_addr = getsockname(COMMAND);
+     ($local_port, $local_addr) = unpack_sockaddr_in($local_sock_addr);
+     $local_ip = inet_ntoa($local_addr);
+     $local_ip =~ s/\./,/g;
+ 
+     printf COMMAND "PORT $local_ip,%d,%d\r\n" 
+         ,$data_port/256,$data_port%256;
+     while(<COMMAND>) {
+         die $_ if (/^[^123]\d+\s/);
+         last if (/^\d+\s/);
+     }
+ }
+ 
+ sub ftpmkdir {
+     my $direstory = shift(@_);
+ 
+     print COMMAND "MKD $direstory\r\n";
+     while(<COMMAND>) {
+         last if (/^\d+\s/);
+     }
+ }
+ 
+ sub ftpput {
+     my $filename = shift(@_);
+ 
+     print COMMAND "TYPE I\r\n";
+     while(<COMMAND>) {
+         die $_ if (/^[^123]\d+\s/);
+         last if (/^\d+\s/);
+     }
+     print COMMAND "STOR $filename\r\n";
+     while(<COMMAND>) {
+         die $_ if (/^[^123]\d+\s/);
+         last if (/^\d+\s/);
+     }
+     accept(IN, DATA);
+     open (FILE, "$filename");
+     binmode(FILE);
+ 
+     while(read(FILE, $tmp, 1024)) {
+         print IN $tmp;
+     }
+     close(IN);
+     close(DATA);
+     while(<COMMAND>) {
+         die $_ if (/^[^123]\d+\s/);
+         last if (/^\d+\s/);
+     }
+ }
+     
+     
Index: AiboPup/tools/ftpupdate
diff -c /dev/null AiboPup/tools/ftpupdate:1.1
*** /dev/null	Fri Oct 10 14:37:52 2003
--- AiboPup/tools/ftpupdate	Mon Jul 28 02:34:13 2003
***************
*** 0 ****
--- 1,189 ----
+ #!/usr/bin/perl
+ #
+ # mstreeput 
+ #
+ # Copyright 2002 Sony Corporation
+ #
+ $|=1;
+ 
+ use Socket;
+ $username = "lycra";
+ $password = "lives";
+ 
+ #----- set default options -----
+ $message        = "\n ftpupdate - install MS tree using TinyFTP\n\n"
+                 ."  usage:\n       mstreeput [options] addr dir\n"
+                 ."  options:\n"
+                 ."      -u    : username\n"
+                 ."      -p    : password\n"
+                 ."      -h    : help\n"
+                 ."\n";
+ 
+ use Getopt::Std;
+ getopts('u:p:hH');
+ die $message if ($opt_h || $opt_H);
+ $username = $opt_u if ($opt_u);
+ $password = $opt_p if ($opt_p);
+ 
+ 
+ #----- main -----
+ die $message if @ARGV <= 1;
+ $hostname = shift(@ARGV);
+ $localdir = shift(@ARGV);
+ 
+ chdir($localdir);
+ makecopylist(".");
+ 
+ open (ST, $ENV{"HOME"}."/.tekkotsu_ftplist");
+ %oldlist={};
+ while (<ST>) {
+   chomp;
+   ($file, $lmtime) = split(/\|/);
+   $oldlist{$file}=$lmtime;
+ }
+ close (ST);
+ login();
+ 
+ open (ST, "> ".$ENV{"HOME"}."/.tekkotsu_ftplist");
+ 
+ for ($i = 0; $i < $numoflist; $i++) {
+     if ($LIST[$i] =~ /\/$/) {
+         ftpmkdir($LIST[$i]);
+     } else {
+         ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
+          $atime,$mtime,$ctime,$blksize,$blocks)
+           = stat($LIST[$i]);
+         if ($mtime==$oldlist{$LIST[$i]}) {
+         } else {
+           print "$LIST[$i]\n";
+           listenData();
+           ftpput($LIST[$i]);
+         }
+         print ST $LIST[$i]."|$mtime\n";
+     }
+ }
+ logout();
+ close(ST);
+ 
+ #----- sub -----
+ sub makecopylist {
+     my $directory = shift(@_);
+     my $numofdir;
+     my @DIRLIST;
+     my $i;
+ 
+     opendir(DIR, $directory);
+     while ($filename = readdir(DIR)) {
+         next if ($filename =~ /^\./);
+         next if ($filename =~ /^CVS$/);
+         $path = "$directory/$filename";
+         $LIST[$numoflist++] = $path if -f $path;
+         if (-d $path) {
+             $LIST[$numoflist++] = "$path/";
+             $DIRLIST[$numofdir++] = $path;
+         }
+     }
+     close(DIR);
+ 
+     for ($i = 0; $i < $numofdir; $i++) {
+         makecopylist($DIRLIST[$i]);
+     }
+ }
+ 
+ sub login {
+     $proto = getprotobyname('tcp');
+     $port = getservbyname('ftp', 'tcp');
+     socket(COMMAND, PF_INET, SOCK_STREAM, $proto)
+         || die "can't creat socket.\n";
+     
+     $sock_addr = pack_sockaddr_in($port, inet_aton($hostname));
+     connect(COMMAND, $sock_addr) || die "cant't connect\n";
+     select(COMMAND); $|=1; select(STDOUT);
+ 
+     while(<COMMAND>) {
+         die $_ if (/^[^123]\d+\s/);
+         last if (/^\d+\s/);
+     }
+     
+     print COMMAND "USER $username\r\n";
+     while(<COMMAND>) {
+         die $_ if (/^[^123]\d+\s/);
+         last if (/^\d+\s/);
+     }
+     
+     print COMMAND "PASS $password\r\n";
+     while(<COMMAND>) {
+         die $_ if (/^[^123]\d+\s/);
+         last if (/^\d+\s/);
+     }
+ }
+ 
+ sub logout {
+     print COMMAND "REBT\r\n";
+     close(COMMAND);
+ }
+ 
+ sub listenData {
+     for ($data_port = 5000; $data_port < 65536; $data_port++) {
+         socket(DATA, PF_INET, SOCK_STREAM, $proto)
+             || die "cant't connect\n";
+         
+         if (bind(DATA, pack_sockaddr_in($data_port, INADDR_ANY))) {
+             last;
+         } else {
+             die "can't bind port\n" if ($data_port == 65535);
+         }
+     }
+ 
+     listen(DATA, 1) || die "listen: $!";
+     $local_sock_addr = getsockname(COMMAND);
+     ($local_port, $local_addr) = unpack_sockaddr_in($local_sock_addr);
+     $local_ip = inet_ntoa($local_addr);
+     $local_ip =~ s/\./,/g;
+ 
+     printf COMMAND "PORT $local_ip,%d,%d\r\n" 
+         ,$data_port/256,$data_port%256;
+     while(<COMMAND>) {
+         die $_ if (/^[^123]\d+\s/);
+         last if (/^\d+\s/);
+     }
+ }
+ 
+ sub ftpmkdir {
+     my $direstory = shift(@_);
+ 
+     print COMMAND "MKD $direstory\r\n";
+     while(<COMMAND>) {
+         last if (/^\d+\s/);
+     }
+ }
+ 
+ sub ftpput {
+     my $filename = shift(@_);
+ 
+     print COMMAND "TYPE I\r\n";
+     while(<COMMAND>) {
+         die $_ if (/^[^123]\d+\s/);
+         last if (/^\d+\s/);
+     }
+     print COMMAND "STOR $filename\r\n";
+     while(<COMMAND>) {
+         die $_ if (/^[^123]\d+\s/);
+         last if (/^\d+\s/);
+     }
+     accept(IN, DATA);
+     open (FILE, "$filename");
+     binmode(FILE);
+ 
+     while(read(FILE, $tmp, 1024)) {
+         print IN $tmp;
+     }
+     close(IN);
+     close(DATA);
+     while(<COMMAND>) {
+         die $_ if (/^[^123]\d+\s/);
+         last if (/^\d+\s/);
+     }
+ }
+     
+     
Index: AiboPup/tools/mstreeput
diff -c AiboPup/tools/mstreeput:1.2 AiboPup/tools/mstreeput:1.3
*** AiboPup/tools/mstreeput:1.2	Mon Oct 28 13:54:00 2002
--- AiboPup/tools/mstreeput	Mon Jul 28 02:34:13 2003
***************
*** 56,62 ****
  
      opendir(DIR, $directory);
      while ($filename = readdir(DIR)) {
!         next if ($filename =~ /^\.{1,2}$/);
          next if ($filename =~ /^CVS$/);
          $path = "$directory/$filename";
          $LIST[$numoflist++] = $path if -f $path;
--- 56,62 ----
  
      opendir(DIR, $directory);
      while ($filename = readdir(DIR)) {
!         next if ($filename =~ /^\./);
          next if ($filename =~ /^CVS$/);
          $path = "$directory/$filename";
          $LIST[$numoflist++] = $path if -f $path;
Index: AiboPup/tools/pm.pl
diff -c /dev/null AiboPup/tools/pm.pl:1.2
*** /dev/null	Fri Oct 10 14:37:52 2003
--- AiboPup/tools/pm.pl	Thu Sep 25 11:32:15 2003
***************
*** 0 ****
--- 1,200 ----
+ #!/afs/cs/project/skinnerbots/sw/perl/bin/perl -I/afs/cs/project/skinnerbots/sw/perl/lib/5.8.0/i686-linux-thread-multi -I/afs/cs/project/skinnerbots/sw/perl/lib/5.8.0
+ # Alok Ladsariya 
+ 
+ use threads;
+ use threads::shared;
+ use Config;
+ use Thread::Queue;
+ 
+ $nonice=0;        # don't be nice: use with CAUTION!
+ $verbose=0;
+ $max_processes=1; # awwww
+ 
+ my $jobs = new Thread::Queue;
+ my $log = new Thread::Queue;
+ my $stats = new Thread::Queue;
+ my $progress : shared = 0;
+ my $running : shared = 1;
+ 
+ sub usage {
+   die "usage: ./pm.pl machines_file commands_file\n";
+ }
+ 
+ sub machine_th {
+   my ($jobs, $log, $stats, $cmd, $verbose, $mPtr) = @_;
+ 
+   $SIG{INT}=\&ignorer;
+   $SIG{TERM}=\&ignorer;
+   my %mInfo = %{$mPtr};
+   $name=$mInfo{"name"};
+   $basedir=$mInfo{"basedir"};
+   $priority=$nonice?0:$mInfo{"priority"};
+ 
+   while (1) {
+     last if ($jobs->pending<1);
+     my $job=$jobs->dequeue;
+ 
+     $cmdcpy=$job;
+     $cmdcpy=~s/_BD_/$basedir/g;
+     $cmdcpy=~s/\$/\\\$/g;
+ 
+     $ccolorcmd="ssh -x $name \"cd $basedir ; sh -c '/bin/nice -n+$priority $cmdcpy'\" 2>&1";
+ 
+     $ret=system($ccolorcmd); 
+     if ($ret) {
+       $jobs->enqueue($job);
+       print "(ERR) $ccolorcmd\n";
+       sleep (50); 
+       next;
+     }
+ 
+     $log->enqueue($cmdcpy);
+     $stats->enqueue($cmdcpy);
+     $progress++;
+   }
+ }
+ 
+ sub status {
+   my ($jobsNum, $log, $stats)=@_;
+   $reported=-1;
+   open (LOG, ">>logfile");
+   open (STATS, ">statfile");
+   while ($progress<$jobsNum) {
+     if ($progress>$reported) {
+       while ($log->pending>0) {
+         print LOG $log->dequeue;
+       }
+       select((select(LOG), $| = 1)[0]);
+       while ($stats->pending>0) {
+         print STATS $stats->dequeue."\n";
+       }
+       select((select(STATS), $| = 1)[0]);
+       print "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bstatus: $progress/$jobsNum"; $|=1;
+       $reported=$progress;
+     }
+     sleep(1);
+   }
+   print "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bstatus: $progress/$jobsNum\n";
+   while ($log->pending>0) {
+     print LOG $log->dequeue;
+   }
+   while ($stats->pending>0) {
+     print STATS $stats->dequeue;
+   }
+   close (LOG);
+   close (STATS);
+ }
+ 
+ sub reaper {
+   my $signame = shift;
+   print "SIG$signame received\n" if $verbose;
+   $running = 0;
+   cleanup();
+   exit(1);
+ }
+ 
+ sub ignorer {
+   # just go to sleep and timeout the cleanup process
+   sleep(25);
+   exit(1);
+ }
+ 
+ sub cleanup {
+   print "\ncleaning up: "; $|=1;
+   sleep (1);
+   foreach $mPtr (@machinesList) { 
+     %mInfo=%{$mPtr};
+     $name=$mInfo{"name"};
+     $basedir=$mInfo{"basedir"};
+     # kill processes
+     system("ssh -x $name \"killall g++\" 2>&1 | cat > /dev/null");
+     print "*";
+   }
+   print "\n";
+ }
+ 
+ $SIG{INT}=\&reaper;
+ $SIG{TERM}=\&reaper;
+ 
+ $cmd="";
+ $listFilename=$ARGV[1];
+ $machinesFilename=$ARGV[0];
+ $max_processes=100 unless ($max_processes);
+ $jobsNum=0;
+ $id=0;
+ 
+ usage() if (@ARGV < 2);
+ 
+ unless (-r $listFilename) { die "can't read: $listFilename\n"; } 
+ unless (-r $machinesFilename) { die "can't read: $machinesFilename\n"; } 
+ unless ($Config{useithreads}) { die "require perl 5.8.0+ with ithreads\n"; }
+ 
+   for ($i=0; $i<@ARGV; $i++) {
+     $cmd=$cmd." ".$ARGV[$i];
+   }
+ 
+ # initialize jobs
+   open (LIST,$listFilename);
+   while (<LIST>) {
+     chomp;
+     next if (/^#/ || /^$/);
+     $jobs->enqueue($_);
+     $jobsNum++;
+   }
+   close (LIST);
+   open (LOG, ">logfile");
+   print LOG "# $cmd\n"; 
+   close (LOG);
+ 
+ # initialize machines
+ $machinesNum=0;
+ @machinesList={};
+ open (MACHINES,$machinesFilename);
+ while (<MACHINES>) {
+   chomp;
+   next if (/^#/ || /^$/);
+   @attrs=split;
+   if (@attrs==4) {
+     my %mach=("name"=>$attrs[0],
+               "basedir"=>$attrs[1],
+               "priority"=>$attrs[2],
+               "forceprocesses"=>$attrs[3]
+               );
+     $machinesList[$machinesNum]=\%mach;
+     $machinesNum++;
+   }
+ }
+ close (MACHINES);
+ print "$jobsNum jobs, $machinesNum machines\n";
+ print "checking machines: ";
+ #stat
+ $threadsNum=0;
+ foreach $mPtr (@machinesList) { 
+   %mInfo=%{$mPtr};
+   $num_processors=0;
+   $free_pct=0;
+   $name=$mInfo{"name"};
+ #  open (ST, "ssh -x $name \"top -b -n 1 | grep CPU\" |");
+ #  while (<ST>) {
+ #    if (/\s+([\d\.]+?)%\s+idle/) {
+ #      $free_pct+=$1;
+ #      $num_processors++;
+ #    }
+ #  }
+ #  close (ST);
+ #  $processes=int($free_pct/100+0.5);
+ #  $processes=($processes>$max_processes)?$max_processes:$processes;
+ #  $min_processes=$mInfo{"forceprocesses"};
+ #  $processes=($processes<$min_processes)?$min_processes:$processes;
+ #  $verbose?print "\n  $name: $num_processors processors, $free_pct % free, $processes processes":print "*";
+ $processes=1;
+   for ($i=0; $i<$processes; $i++) {
+     $m_th = threads->new(\&machine_th, $jobs, $log, $stats, $cmd, $verbose, $mPtr);
+     $threadsNum++;
+   }
+ }
+ print "\n";
+ print "$threadsNum workers created\n";
+ status($jobsNum,$log,$stats);
+ sleep(1); # give the threads a chance to exit
+ #cleanup(); disable safety cleanup
Index: AiboPup/tools/umntmem
diff -c AiboPup/tools/umntmem:1.5 AiboPup/tools/umntmem:1.7
*** AiboPup/tools/umntmem:1.5	Sat Jun 28 14:03:57 2003
--- AiboPup/tools/umntmem	Thu Aug 21 18:34:43 2003
***************
*** 11,23 ****
  		exit 0;
  		;;
  	Darwin)
! 		echo "Attempting to unmount... if this hangs excessively, do it manually";
  		drive=`disktool -l | grep "$pt" | cut -f 2 -d \'`;
  		disktool -e $drive > /dev/null;
  		echo "$pt unmounted, you may remove the memstick";
  		;;
  	*)
! 		printf "Attempting to unmount...";
  		umount $pt;
  		if [ $? -eq 0 ] ; then
  			printf "successful.\n";
--- 11,23 ----
  		exit 0;
  		;;
  	Darwin)
! 		echo "Waiting for unmount... this may take a few seconds for buffered writes to complete";
  		drive=`disktool -l | grep "$pt" | cut -f 2 -d \'`;
  		disktool -e $drive > /dev/null;
  		echo "$pt unmounted, you may remove the memstick";
  		;;
  	*)
! 		printf "Waiting for unmount...";
  		umount $pt;
  		if [ $? -eq 0 ] ; then
  			printf "successful.\n";
Index: AiboPup/tools/untag.txt
diff -c AiboPup/tools/untag.txt:1.3 AiboPup/tools/untag.txt:1.7
*** AiboPup/tools/untag.txt:1.3	Thu Jun  5 13:03:16 2003
--- AiboPup/tools/untag.txt	Fri Oct 10 14:22:50 2003
***************
*** 1,12 ****
- tools/emonParser
- tools/buildRelease
- docs/PIDInfo.txt
- docs/untag.txt
- SoundPlay/clips/originals/junglewalk.com/animal_sounds_01-dog.mp3
- SoundPlay/clips/originals/junglewalk.com/animal_sounds_11-wolf.mp3
  project/SampleBehavior.h
  project/SampleMC.h
- Behaviors/Controls/LoadAIControl.h
- Behaviors/Controls/SaveAIControl.h
  Behaviors/Demos/PaceTargetsMachine.h
  Behaviors/Demos/PaceTargetsMachine.cc
--- 1,4 ----
Index: AiboPup/tools/aibo3d/Aibo3D.java
diff -c AiboPup/tools/aibo3d/Aibo3D.java:1.3 AiboPup/tools/aibo3d/Aibo3D.java:removed
*** AiboPup/tools/aibo3d/Aibo3D.java:1.3	Sat Jun 28 14:03:57 2003
--- AiboPup/tools/aibo3d/Aibo3D.java	Fri Oct 10 14:37:52 2003
***************
*** 1,160 ****
- import java.awt.*;
- import java.awt.event.*;
- import javax.media.j3d.*;
- import java.io.*;
- import javax.vecmath.*;
- import java.util.*;
- import java.lang.*;
- 
- import com.sun.j3d.loaders.lw3d.Lw3dLoader;
- import com.sun.j3d.loaders.Loader;
- import com.sun.j3d.loaders.Scene;
- import com.sun.j3d.utils.applet.MainFrame;
- import com.sun.j3d.utils.universe.SimpleUniverse;
- import com.sun.j3d.utils.behaviors.mouse.*;
- import com.sun.j3d.utils.picking.behaviors.*;
- import com.sun.j3d.utils.picking.*;
- 
- public class Aibo3D extends Frame {
-   public static void main(String args[]) {
- 		if(args.length<1) {
- 			System.out.println("Usage: java Aibo3D host [port]");
- 			System.out.println("       if port is not specified, it defaults to 10031");
- 			System.exit(2);
- 		}
- 		int port=10031;
- 		if(args.length>1)
- 			port=Integer.parseInt(args[1]);
-     new Aibo3D(args[0],port,null);
-   }
- 
-   public Aibo3D(String host, int port, String args[]) {
-     super("Aibo 3D");
-     setSize(500,500);
- 
-     setup3DCanvas();
-     loadLW3D("aibo3d.lws");
-     forward=new Aibo3DForward(scene);
-     showScene();
-   
-     wsj=new WorldStateJointsListener(host,port);
-     while (true) {
-       if (wsj.isConnected()) {
-         if (wsj.hasData()) {
-           Joints j=wsj.getData();
-           float[] p=j.positions;
-           forward.knee_fl.setX(-p[2]);
-           forward.thigh_fl.set(-p[0],0.0f,p[1]);
-           forward.knee_fr.setX(-p[5]);
-           forward.thigh_fr.set(-p[3],0.0f,-p[4]);
-           forward.knee_bl.setX(p[8]);
-           forward.thigh_bl.set(p[6],0.0f,p[7]);
-           forward.knee_br.setX(p[11]);
-           forward.thigh_br.set(p[9],0.0f,-p[10]);
-           forward.neck.setX(-p[12]);
-           forward.head.set(0.0f,p[13],p[14]);
-           forward.tail.set(p[15],p[16],0.0f);
-           forward.jaw.setX(-p[17]);
-         }
-       }
-       sleep(10);
-     }
-   
- //    testLimits(forward.thigh_bl,50);
-   }
- 
- 	void close() {
- 		dispose();
- 	}
- 
-   void testLimits(AiboJoint j) {
-     float step;
-     step=(j.maxX-j.minX)/100;
-     for (float x=j.minX; x<j.maxX; x+=step) { j.setX(x); sleep(10); }
-     for (float x=j.maxX; x>j.minX; x-=step) { j.setX(x); sleep(10); }
-     j.setX(0.0f);
-     step=(j.maxY-j.minY)/100;
-     for (float y=j.minY; y<j.maxY; y+=step) { j.setY(y); sleep(10); }
-     for (float y=j.maxY; y>j.minY; y-=step) { j.setY(y); sleep(10); }
-     j.setY(0.0f);
-     step=(j.maxZ-j.minZ)/100;
-     for (float z=j.minZ; z<j.maxZ; z+=step) { j.setZ(z); sleep(10); }
-     for (float z=j.maxZ; z>j.minZ; z-=step) { j.setZ(z); sleep(10); }
-     j.setZ(0.0f);
-   }
- 
-   void testLimits(AiboJoint j, int n) {
-     for (int i=0; i<n; i++) {
-       testLimits(j);
-     }
-   }
- 
-   void sleep(long ms) {
-     try { Thread.sleep(ms); } catch (Exception e) {}
-   }
- 
-   void loadLW3D(String filename) {
-     Loader loader=new Lw3dLoader(Loader.LOAD_ALL);
-     try {
-       scene=loader.load(filename);
-     } catch (Exception ex) {
-       System.out.println("error loading "+filename);
-       System.exit(1);
-     }
-   }
- 
-   void setup3DCanvas() {
-     canvas3d=new Canvas3D(SimpleUniverse.getPreferredConfiguration());
-     add("Center",canvas3d);
-     setVisible(true);
-     addWindowListener(new WindowAdapter()         // cleans up properly
-       { public void windowClosing(WindowEvent e)
-           { dispose(); System.exit(0); } });
-   }
- 
-   Scene scene=null;
-   Canvas3D canvas3d=null;
-   Aibo3DForward forward=null;
-   WorldStateJointsListener wsj=null;
- 
-   void showScene() {
-     GraphicsConfiguration config =
-       SimpleUniverse.getPreferredConfiguration();
- 
- 
-     SimpleUniverse universe = new SimpleUniverse(canvas3d);
-     universe.getViewingPlatform().setNominalViewingTransform();
- 
-     BranchGroup bg = createSceneGraph(scene);
-     universe.addBranchGraph(bg);
-   }
- 
-   BranchGroup createSceneGraph(Scene scene) {
-     BranchGroup root = new BranchGroup();
- 
-     TransformGroup trans = new TransformGroup();
-     trans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
-     trans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
- 
-     BoundingSphere bounds = new BoundingSphere(new Point3d(), 100.0);
- 
-     MouseRotate rotator = new MouseRotate(trans);
-     rotator.setSchedulingBounds(bounds);
-     root.addChild(rotator);
- 
-     MouseTranslate translator = new MouseTranslate(trans);
-     translator.setSchedulingBounds(bounds);
-     root.addChild(translator);
- 
-     MouseZoom zoomer = new MouseZoom(trans);
-     zoomer.setSchedulingBounds(bounds);
-     root.addChild(zoomer); 
- 
-     if (scene.getSceneGroup() != null) {
-       trans.addChild(scene.getSceneGroup());
-       root.addChild(trans);
-     }
- 
-     return root;
-   }
- }
--- 0 ----
Index: AiboPup/tools/aibo3d/Aibo3DForward.java
diff -c AiboPup/tools/aibo3d/Aibo3DForward.java:1.1 AiboPup/tools/aibo3d/Aibo3DForward.java:removed
*** AiboPup/tools/aibo3d/Aibo3DForward.java:1.1	Thu May 29 16:02:04 2003
--- AiboPup/tools/aibo3d/Aibo3DForward.java	Fri Oct 10 14:37:52 2003
***************
*** 1,136 ****
- import javax.media.j3d.*;
- import javax.vecmath.*;
- import java.util.*;
- import java.lang.*;
- 
- import com.sun.j3d.loaders.Scene;
- 
- public class Aibo3DForward {
-   Scene _scene;
-   Hashtable _namedObjects;
- 
-   AiboJoint head;
-   AiboJoint neck;
-   AiboJoint jaw;
-   AiboJoint tail;
-   AiboJoint thigh_fl;
-   AiboJoint knee_fl;
-   AiboJoint thigh_fr;
-   AiboJoint knee_fr;
-   AiboJoint thigh_bl;
-   AiboJoint knee_bl;
-   AiboJoint thigh_br;
-   AiboJoint knee_br;
-   List aiboJoints;
-   
-   public Aibo3DForward(Scene scene) {
-     _scene=scene;
-     _namedObjects=scene.getNamedObjects();
- 
-     makeSceneTransformable();
-     initERS210();
-   }
- 
-   public List getAiboJoints() {
-     return aiboJoints;    
-   }
- 
-   void makeSceneTransformable() {
-     for (Enumeration e=_namedObjects.keys(); e.hasMoreElements();)
-       makeObjectTransformable(e.nextElement());
-   }
- 
-   void makeObjectTransformable(Object key) {
-     TransformGroup objtg=getTG(key);
-     objtg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
-     objtg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
-   }
- 
-   void printNamedObjects() {
-     for (Enumeration e=_namedObjects.keys(); e.hasMoreElements();)
-       System.out.println(e.nextElement());
-   }
- 
-   void printNamedObjectTransformationMatrices() {
-     for (Enumeration e=_namedObjects.keys(); e.hasMoreElements();) {
-       System.out.println(e.nextElement()+": ");
-       printNamedObjectTransformationMatrix(e.nextElement());
-     }
-   }
- 
-   void printNamedObjectTransformationMatrix(Object key) {
-     TransformGroup objtg=getTG(key);
-     Transform3D t3d=new Transform3D();
-     objtg.getTransform(t3d);
-     System.out.println(t3d);
-   }
- 
-   public TransformGroup getTG(Object key) {
-     return (TransformGroup)_namedObjects.get(key);
-   }
- 
-   void initERS210 () {
-     neck=new AiboJoint(getTG("objects/neck.lwo"), "neck",
-                        -46.0f,   85.0f,
-                        0.0f,     0.0f,
-                        0.0f,     0.0f);
-     head=new AiboJoint(getTG("objects/head.lwo"), "head",
-                        0.0f,     0.0f,
-                        -92.6f,   92.6f,
-                        -32.0f,   32.0f);
-     jaw=new AiboJoint(getTG("objects/jaw.lwo"), "jaw",
-                        0.0f,     50.0f,
-                        0.0f,     0.0f,
-                        0.0f,     0.0f);
-     tail=new AiboJoint(getTG("objects/tail2.lwo"), "tail",
-                        -25.0f,   25.0f,
-                        -25.0f,   25.0f,
-                        0.0f,     0.0f);
-     thigh_fl=new AiboJoint(getTG("objects/leg-f-up-l.lwo"), "thigh_fl",
-                        -120.0f,  120.0f,
-                        0.0f,     0.0f,
-                        -15.0f,   92.0f);
-     thigh_fr=new AiboJoint(getTG("objects/leg-f-up-r.lwo"), "thigh_fr",
-                        -120.0f,  120.0f,
-                        0.0f,     0.0f,
-                        -92.0f,   15.0f);
-     thigh_bl=new AiboJoint(getTG("objects/leg-b-up-l.lwo"), "thigh_bl",
-                        -120.0f,  120.0f,
-                        0.0f,     0.0f,
-                        -15.0f,   92.0f);
-     thigh_br=new AiboJoint(getTG("objects/leg-b-up-r.lwo"), "thigh_br",
-                        -120.0f,  120.0f,
-                        0.0f,     0.0f,
-                        -92.0f,   15.0f);
-     knee_fl=new AiboJoint(getTG("objects/leg-f-low-l.lwo"), "knee_fl",
-                        -115.0f,  65.0f,
-                        0.0f,     0.0f,
-                        0.0f,     0.0f);
-     knee_fr=new AiboJoint(getTG("objects/leg-f-low-r.lwo"), "knee_fr",
-                        -115.0f,  65.0f,
-                        0.0f,     0.0f,
-                        0.0f,     0.0f);
-     knee_bl=new AiboJoint(getTG("objects/leg-b-low-l.lwo"), "knee_bl",
-                        -65.0f,   115.0f,
-                        0.0f,     0.0f,
-                        0.0f,     0.0f);
-     knee_br=new AiboJoint(getTG("objects/leg-b-low-r.lwo"), "knee_br",
-                        -65.0f,   115.0f,
-                        0.0f,     0.0f,
-                        0.0f,     0.0f);
-     aiboJoints=new ArrayList(20);
- 
-     aiboJoints.add(head);
-     aiboJoints.add(neck);
-     aiboJoints.add(jaw);
-     aiboJoints.add(tail);
-     aiboJoints.add(thigh_fl);
-     aiboJoints.add(knee_fl);
-     aiboJoints.add(thigh_fr);
-     aiboJoints.add(knee_fr);
-     aiboJoints.add(thigh_bl);
-     aiboJoints.add(knee_bl);
-     aiboJoints.add(thigh_br);
-     aiboJoints.add(knee_br);
-   }
- }
--- 0 ----
Index: AiboPup/tools/aibo3d/Aibo3DPick.java
diff -c AiboPup/tools/aibo3d/Aibo3DPick.java:1.6 AiboPup/tools/aibo3d/Aibo3DPick.java:removed
*** AiboPup/tools/aibo3d/Aibo3DPick.java:1.6	Thu Jul  3 06:01:49 2003
--- AiboPup/tools/aibo3d/Aibo3DPick.java	Fri Oct 10 14:37:52 2003
***************
*** 1,300 ****
- import java.awt.*;
- import java.awt.event.*;
- import javax.media.j3d.*;
- import java.io.*;
- import javax.vecmath.*;
- import java.util.*;
- import java.lang.*;
- 
- import com.sun.j3d.loaders.lw3d.Lw3dLoader;
- import com.sun.j3d.loaders.Loader;
- import com.sun.j3d.loaders.Scene;
- import com.sun.j3d.utils.applet.MainFrame;
- import com.sun.j3d.utils.universe.SimpleUniverse;
- import com.sun.j3d.utils.behaviors.mouse.*;
- import com.sun.j3d.utils.picking.behaviors.*;
- import com.sun.j3d.utils.picking.*;
- 
- public class Aibo3DPick extends Frame {
-   Canvas3D canvas3d;
-   Scene scene;
-   Aibo3DForward forward;
-   PickMoveBehavior picker;
-   BranchGroup branchGroup;
-   SimpleUniverse universe;
-   BranchGroup root;
-   
-   public static void main(String args[]) {
- 		if(args.length<1) {
- 			System.out.println("Usage: java Aibo3DPick host [port]");
- 			System.out.println("       if port is not specified, it defaults to 10051");
- 			System.exit(2);
- 		}
- 		int port=10051;
- 		if(args.length>1)
- 			port=Integer.parseInt(args[1]);
-     new Aibo3DPick(args[0],port,null);
-   }
- 
-   public Aibo3DPick(String host, int port, String args[]) {
-     super("Aibo 3D");
-     setSize(600,400);
- 
-     setup3DCanvas();
-     loadLW3D("aibo3d.lws");
-     forward=new Aibo3DForward(scene);
-     showScene();
- 
-     picker.createPicker();
- 		mirrorServer(host,port);
-   }
- 
- 	void close() {
- 		dispose();
- 	}
- 
-   void mirrorListener(String host, int port) {
-     WorldStateJointsListener wsj=
-       new WorldStateJointsListener(host,port);
-     while (true) {
-       if (wsj.isConnected()) {
-         if (wsj.hasData()) {
-           Joints j=wsj.getData();
-           float[] p=j.positions;
-           forward.knee_fl.setX(-p[2]);
-           forward.thigh_fl.set(-p[0],0.0f,p[1]);
-           forward.knee_fr.setX(-p[5]);
-           forward.thigh_fr.set(-p[3],0.0f,-p[4]);
-           forward.knee_bl.setX(p[8]);
-           forward.thigh_bl.set(p[6],0.0f,p[7]);
-           forward.knee_br.setX(p[11]);
-           forward.thigh_br.set(p[9],0.0f,-p[10]);
-           forward.neck.setX(-p[12]);
-           forward.head.set(0.0f,p[13],p[14]);
-           forward.tail.set(p[15],p[16],0.0f);
-           forward.jaw.setX(-p[17]);
-         }
-       }
-       sleep(20);
-     }
-   }
- 
-   void mirrorServer(String host, int port) {
-     WorldStateJointsWriter wsj=
-       new WorldStateJointsWriter(host,port);
-     while (true) {
-       if (wsj.isConnected()) {
-         float[] p=new float[18];
-         p[0]=-forward.thigh_fl.x;
-         p[1]=forward.thigh_fl.z;
-         p[2]=-forward.knee_fl.x;
-         p[3]=-forward.thigh_fr.x;
-         p[4]=-forward.thigh_fr.z;
-         p[5]=-forward.knee_fr.x;
-         p[6]=forward.thigh_bl.x;
-         p[7]=forward.thigh_bl.z;
-         p[8]=forward.knee_bl.x;
-         p[9]=forward.thigh_br.x;
-         p[10]=-forward.thigh_br.z;
-         p[11]=forward.knee_br.x;
-         p[12]=-forward.neck.x;
-         p[13]=forward.head.y;
-         p[14]=forward.head.z;
-         p[15]=forward.tail.x;
-         p[16]=forward.tail.y;
-         p[17]=-forward.jaw.x;
-         wsj.write(p);
-       }
-       sleep(30);
-     }
-   }
- 
-   void testLimits(AiboJoint j) {
-     float step;
-     step=(j.maxX-j.minX)/100;
-     for (float x=j.minX; x<j.maxX; x+=step) { j.setX(x); sleep(10); }
-     for (float x=j.maxX; x>j.minX; x-=step) { j.setX(x); sleep(10); }
-     j.setX(0.0f);
-     step=(j.maxY-j.minY)/100;
-     for (float y=j.minY; y<j.maxY; y+=step) { j.setY(y); sleep(10); }
-     for (float y=j.maxY; y>j.minY; y-=step) { j.setY(y); sleep(10); }
-     j.setY(0.0f);
-     step=(j.maxZ-j.minZ)/100;
-     for (float z=j.minZ; z<j.maxZ; z+=step) { j.setZ(z); sleep(10); }
-     for (float z=j.maxZ; z>j.minZ; z-=step) { j.setZ(z); sleep(10); }
-     j.setZ(0.0f);
-   }
- 
-   void testLimits(AiboJoint j, int n) {
-     for (int i=0; i<n; i++) {
-       testLimits(j);
-     }
-   }
- 
-   void sleep(long ms) {
-     try { Thread.sleep(ms); } catch (Exception e) {}
-   }
- 
-   void loadLW3D(String filename) {
-     Loader loader=new Lw3dLoader(Loader.LOAD_ALL);
-     try {
-       scene=loader.load(filename);
-     } catch (Exception ex) {
-       System.out.println("error loading "+filename);
-       System.exit(1);
-     }
-   }
- 
-   void setup3DCanvas() {
-     canvas3d=new Canvas3D(SimpleUniverse.getPreferredConfiguration());
-     add("Center",canvas3d);
-     setVisible(true);
-     addWindowListener(new WindowAdapter()         // cleans up properly
-       { public void windowClosing(WindowEvent e)
-           { dispose(); System.exit(0); } });
-   }
- 
-   void showScene() {
-     GraphicsConfiguration config =
-       SimpleUniverse.getPreferredConfiguration();
- 
-     universe = new SimpleUniverse(canvas3d);
-     universe.getViewingPlatform().setNominalViewingTransform();
- 
-     branchGroup = createSceneGraph(scene);
-     universe.addBranchGraph(branchGroup);
-   }
- 
-   BranchGroup createSceneGraph(Scene scene) {
-     root = new BranchGroup();
-     TransformGroup transformGroup;
- 
-     transformGroup = new TransformGroup();
-     transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
-     transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
- 
-     Hashtable namedObjects = scene.getNamedObjects( );
- 
-     // recursively set the user data here
-     // so we can find our objects when they are picked
-     
-     java.util.Enumeration enumValues = namedObjects.elements( );
-     java.util.Enumeration enumKeys = namedObjects.keys( );
-     if( enumValues != null )
-     {
-       while( enumValues.hasMoreElements( ) != false )
-       {
-         Object value = enumValues.nextElement( );
-         Object key = enumKeys.nextElement( );
- 
-         recursiveSetUserData( value, key );
-       }
-     }
- 
- 
-     Bounds bounds=new BoundingSphere(new Point3d(0.0,0.0,0.0), 1.0);
- /*
-     MouseRotate rotator = new MouseRotate(transformGroup);
-     rotator.setSchedulingBounds(bounds);
-     root.addChild(rotator);
- 
-     MouseTranslate translator = new MouseTranslate(transformGroup);
-     translator.setSchedulingBounds(bounds);
-     root.addChild(translator);
- */
-     MouseZoom zoomer = new MouseZoom(transformGroup);
-     zoomer.setSchedulingBounds(bounds);
-     root.addChild(zoomer); 
- 
-     picker=new PickMoveBehavior (canvas3d, scene.getSceneGroup(), scene,
-                                  forward, transformGroup);
-     picker.setSchedulingBounds(bounds);
-     root.addChild(picker);
- 
-     if (scene.getSceneGroup() != null) {
-       transformGroup.addChild(scene.getSceneGroup());
-       root.addChild(transformGroup);
-     }
- 
-     moveLights(scene.getSceneGroup(), root);
- //    recursivePrintGroup(root);
- 
-     return root;
-   }
- 
-   void moveLights(Group from, Group to) {
-     from.setCapability(Group.ALLOW_CHILDREN_READ);
- 
-     java.util.Enumeration enumKids = from.getAllChildren();
-     while( enumKids.hasMoreElements( ) != false ) {
-       Object o = enumKids.nextElement();
-       if (o instanceof Group) {
-         moveLights((Group)o, to);
-       } else if (o instanceof DirectionalLight || o instanceof PointLight) {
-         from.setCapability(Group.ALLOW_CHILDREN_WRITE);
-         to.setCapability(Group.ALLOW_CHILDREN_READ);
-         to.setCapability(Group.ALLOW_CHILDREN_WRITE);
-         from.removeChild((Node)o);
-         to.addChild((Node)o);
-       }
-     }
- 
-   }
- 
-   void recursivePrintGroup(Object sgo) {
-     recursivePrintGroup(sgo,"");
-   }
- 
-   void recursivePrintGroup(Object sgo, String indent) {
-     if( sgo instanceof SceneGraphObject != false )
-     {
-       SceneGraphObject sg = (SceneGraphObject) sgo;
-                                                                                 
-       // recursively process group
-       if( sg instanceof Group )
-       {
-         Group g = (Group) sg;
-         g.setCapability(Group.ALLOW_CHILDREN_READ);
-                                                                                 
-         // recurse on child nodes
-         java.util.Enumeration enumKids = g.getAllChildren( );
-                                                                                 
-         while( enumKids.hasMoreElements( ) != false )
-           recursivePrintGroup( enumKids.nextElement( ), indent+"  ");
-       }
-       else if ( sg instanceof Node || sg instanceof NodeComponent)
-       {
-         System.out.println(indent+sg);
-       }
-     }
-   
-   }
- 
-   void recursiveSetUserData( Object value, Object key )
-   {
-     if( value instanceof SceneGraphObject != false )
-     {
-       // set the user data for the item
-       SceneGraphObject sg = (SceneGraphObject) value;
-       sg.setUserData( key );
-                                                                                 
-       // recursively process group
-       if( sg instanceof Group )
-       {
-         Group g = (Group) sg;
-         g.setCapability(Group.ALLOW_CHILDREN_READ);
-                                                                                 
-         // recurse on child nodes
-         java.util.Enumeration enumKids = g.getAllChildren( );
-                                                                                 
-         while( enumKids.hasMoreElements( ) != false )
-           recursiveSetUserData( enumKids.nextElement( ), key );
-       }
-       else if ( sg instanceof Shape3D || sg instanceof Morph )
-       {
-         PickTool.setCapabilities( (Node) sg, PickTool.INTERSECT_FULL );
-       }
-     }
-   }
- 
- }
--- 0 ----
Index: AiboPup/tools/aibo3d/AiboJoint.java
diff -c AiboPup/tools/aibo3d/AiboJoint.java:1.2 AiboPup/tools/aibo3d/AiboJoint.java:removed
*** AiboPup/tools/aibo3d/AiboJoint.java:1.2	Thu Jun  5 16:25:44 2003
--- AiboPup/tools/aibo3d/AiboJoint.java	Fri Oct 10 14:37:52 2003
***************
*** 1,129 ****
- import javax.media.j3d.*;
- import javax.vecmath.*;
- import java.util.*;
- import java.lang.*;
- 
- public class AiboJoint {
-   public static final int RADIANS=0;
-   public static final int DEGREES=1;
- 
-   public String name;
-   public TransformGroup obj;
-   public float minX;
-   public float maxX;
-   public float minY;
-   public float maxY;
-   public float minZ;
-   public float maxZ;
-   public float x;
-   public float y;
-   public float z;
- 
-   float bound(float n, float l, float h) {
-     return Math.max(Math.min(h, n),l);
-   }
- 
-   public void setX(float X) {
-     x=bound(X, minX, maxX);
-     setJoints();
-   }
- 
-   public void setY(float Y) {
-     y=bound(Y, minY, maxY);
-     setJoints();
-   }
- 
-   public void setZ(float Z) {
-     z=bound(Z, minZ, maxZ);
-     setJoints();
-   }
- 
-   public void setX(double X) {
-     setX((float)X);
-   }
- 
-   public void setY(double Y) {
-     setY((float)Y);
-   }
- 
-   public void setZ(double Z) {
-     setZ((float)Z);
-   }
- 
-   public void setXDiff(int X) {
-     setX(x+((float)X*0.03f));
-   }
- 
-   public void setYDiff(int Y) {
-     setY(y+((float)Y*0.03f));
-   }
-   
-   public void setZDiff(int Z) {
-     setZ(z+((float)Z*0.03f));
-   }
- 
-   public void set(float X, float Y, float Z) {
-     x=bound(X, minX, maxX);
-     y=bound(Y, minY, maxY);
-     z=bound(Z, minZ, maxZ);
-     setJoints();
-   }
- 
-   // TODO: Lots of crazy speedups possible
-   void setJoints() {
-     Transform3D t3d=new Transform3D();
-     Matrix3f accum=new Matrix3f();
-     Matrix3f rot=new Matrix3f();
-     obj.getTransform(t3d);
-     accum.setIdentity();
-     rot.rotX(x);
-     accum.mul(rot);
-     rot.rotY(y);
-     accum.mul(rot);
-     rot.rotZ(z);
-     accum.mul(rot);
-     t3d.setRotation(accum);
-     obj.setTransform(t3d);
-   }
- 
-   public AiboJoint (TransformGroup tg, String n, float minx, float maxx,
-                     float miny, float maxy, float minz, float maxz) {
-     this(tg, n, minx, maxx, miny, maxy, minz, maxz, DEGREES);
-   }
-  
-   public AiboJoint (TransformGroup tg, String n, float minx, float maxx,
-                     float miny, float maxy, float minz, float maxz, int units) {
-     if (units==RADIANS) {
-       obj=tg;
-       minX=minx;
-       maxX=maxx;
-       minY=miny;
-       maxY=maxy;
-       minZ=minz;
-       maxZ=maxz;
-     } else if (units==DEGREES) {
-       obj=tg;
-       minX=deg2rad(minx);
-       maxX=deg2rad(maxx);
-       minY=deg2rad(miny);
-       maxY=deg2rad(maxy);
-       minZ=deg2rad(minz);
-       maxZ=deg2rad(maxz);
-     } else {
-       System.out.println("error: unknown units");
-       System.exit(1);
-     }
-     x=0.0f;
-     y=0.0f;
-     z=0.0f;
-     name=n;
-   }
- 
-   public float deg2rad (float deg) {
-     return (deg*(float)Math.PI)/180.0f;
-   }
- 
-   public String toString () {
-     return name;
-   }
- }
--- 0 ----
Index: AiboPup/tools/aibo3d/AiboPicker.java
diff -c AiboPup/tools/aibo3d/AiboPicker.java:1.1 AiboPup/tools/aibo3d/AiboPicker.java:removed
*** AiboPup/tools/aibo3d/AiboPicker.java:1.1	Thu May 29 16:02:06 2003
--- AiboPup/tools/aibo3d/AiboPicker.java	Fri Oct 10 14:37:52 2003
***************
*** 1,88 ****
- import java.util.*;
- import java.lang.*;
- import javax.media.j3d.*;
- 
- import com.sun.j3d.loaders.Scene;
- 
- public class AiboPicker {
-   Hashtable _namedObjects;
-   Hashtable _shapeToTG;
- 
-   public static final String head="head";
-   public static final String tail="tail";
-   public static final String body="body";
-   public static final String foot_fl="foot_fl";
-   public static final String foot_fr="foot_fr";
-   public static final String foot_bl="foot_bl";
-   public static final String foot_br="foot_br";
-   public static final String leg_fl="leg_fl";
-   public static final String leg_fr="leg_fr";
-   public static final String leg_bl="leg_bl";
-   public static final String leg_br="leg_br";
-   public static final String knee_fl="knee_fl";
-   public static final String knee_fr="knee_fr";
-   public static final String knee_bl="knee_bl";
-   public static final String knee_br="knee_br";
-   public static final String jaw="jaw";
- 
-   public AiboPicker (Scene scene) {
-     _namedObjects=scene.getNamedObjects();
-     _shapeToTG=new Hashtable();
-     initERS210();
-   }
- 
-   public String pick(Object shape) {
-     return (String)_shapeToTG.get(shape);
-   }
- 
-   public TransformGroup getTG(Object key) {
-     return (TransformGroup)_namedObjects.get(key);
-   }
- 
-   void addShapesFor(TransformGroup key, String name) {
-     Enumeration shapes = key.getAllChildren();
-     while (shapes.hasMoreElements()) {
-       Object s=shapes.nextElement();
-       if (s instanceof Shape3D) {
-         _shapeToTG.put(s, name);
-       }
-     }
-   }
- 
-   void initERS210() {
-     addShapesFor(getTG("objects/neck.lwo"), head);
-     addShapesFor(getTG("objects/head.lwo"), head);
-     addShapesFor(getTG("objects/LED_g01.lwo"), head);
-     addShapesFor(getTG("objects/LED_g02.lwo"), head);
-     addShapesFor(getTG("objects/LED_g03.lwo"), head);
-     addShapesFor(getTG("objects/LED_r01.lwo"), head);
-     addShapesFor(getTG("objects/LED_r02.lwo"), head);
-     addShapesFor(getTG("objects/LED_r03.lwo"), head);
-     addShapesFor(getTG("objects/ear-l.lwo"), head);
-     addShapesFor(getTG("objects/ear-r.lwo"), head);
- 
-     addShapesFor(getTG("objects/jaw.lwo"), jaw);
-     addShapesFor(getTG("objects/body2.lwo"), body);
-     addShapesFor(getTG("objects/tail2.lwo"), tail);
-    
-     addShapesFor(getTG("objects/foot-b-r.lwo"), foot_br);
-     addShapesFor(getTG("objects/leg-b-low-r.lwo"), knee_br);
-     addShapesFor(getTG("objects/leg-b-up-r.lwo"), leg_br);
- 
-     addShapesFor(getTG("objects/foot-b-l.lwo"), foot_bl);
-     addShapesFor(getTG("objects/leg-b-low-l.lwo"), knee_bl);
-     addShapesFor(getTG("objects/leg-b-up-l.lwo"), leg_bl);
- 
-     addShapesFor(getTG("objects/foot-f-r.lwo"), foot_fr);
-     addShapesFor(getTG("objects/leg-f-low-r.lwo"), knee_fr);
-     addShapesFor(getTG("objects/leg-f-up-r.lwo"), leg_fr);
- 
-     addShapesFor(getTG("objects/foot-f-l.lwo"), foot_fl);
-     addShapesFor(getTG("objects/leg-f-low-l.lwo"), knee_fl);
-     addShapesFor(getTG("objects/leg-f-up-l.lwo"), leg_fl);
-     for (Enumeration e=_shapeToTG.keys(); e.hasMoreElements();) {
-       Object o=e.nextElement();
-       // System.out.println(o + "->" + _shapeToTG.get(o));
-     }
-   }
- }
--- 0 ----
Index: AiboPup/tools/aibo3d/InverseKinematics.java
diff -c AiboPup/tools/aibo3d/InverseKinematics.java:1.1 AiboPup/tools/aibo3d/InverseKinematics.java:removed
*** AiboPup/tools/aibo3d/InverseKinematics.java:1.1	Thu May 29 16:02:06 2003
--- AiboPup/tools/aibo3d/InverseKinematics.java	Fri Oct 10 14:37:52 2003
***************
*** 1,4 ****
- public class InverseKinematics {
-   public InverseKinematics () {
-   }
- }
--- 0 ----
Index: AiboPup/tools/aibo3d/Joints.java
diff -c AiboPup/tools/aibo3d/Joints.java:1.1 AiboPup/tools/aibo3d/Joints.java:removed
*** AiboPup/tools/aibo3d/Joints.java:1.1	Thu May 29 16:02:06 2003
--- AiboPup/tools/aibo3d/Joints.java	Fri Oct 10 14:37:52 2003
***************
*** 1,14 ****
- public class Joints {
-   public float[] positions;
-   public float[] duties;
-   public float[] sensors;
-   public float[] buttons;
-   int timestamp;
- 
-   Joints() {
-     positions=new float[18];
-     duties=new float[18];
-     sensors=new float[6];
-     buttons=new float[8];
-   } 
- }
--- 0 ----
Index: AiboPup/tools/aibo3d/Kinematics.java
diff -c AiboPup/tools/aibo3d/Kinematics.java:1.1 AiboPup/tools/aibo3d/Kinematics.java:removed
*** AiboPup/tools/aibo3d/Kinematics.java:1.1	Thu Jun  5 16:25:44 2003
--- AiboPup/tools/aibo3d/Kinematics.java	Fri Oct 10 14:37:52 2003
***************
*** 1,160 ****
- import javax.vecmath.*;
- 
- public class Kinematics {
-   public static final int FRONT_LEFT=0;
-   public static final int FRONT_RIGHT=1;
-   public static final int BACK_LEFT=2;
-   public static final int BACK_RIGHT=3;
-  
-   static final Vector3d f_body_to_shoulder=
-                                    new Vector3d( 59.50, 59.20,   0.00); 
-   static final Vector3d f_leg_shoulder_to_knee=
-                                    new Vector3d( 12.80,  0.50, -64.00);
-   static final Vector3d f_leg_knee_to_ball=
-                                    new Vector3d(-18.00,  0.00, -67.23);
-   static final Vector3d h_body_to_shoulder=
-                                    new Vector3d(-59.50, 59.20,   0.00); 
-   static final Vector3d h_leg_shoulder_to_knee=
-                                    new Vector3d(-12.80,  0.50, -64.00);
-   static final Vector3d h_leg_knee_to_ball=
-                                    new Vector3d( 18.00,  0.00, -74.87);
-   static final Vector3d f_upper=f_leg_shoulder_to_knee;
-   static final Vector3d f_lower=f_leg_knee_to_ball;
-   static final Vector3d h_upper=h_leg_shoulder_to_knee;
-   static final Vector3d h_lower=h_leg_knee_to_ball;
- 
-   static final double rotator_min  = RAD(-117.0);
-   static final double rotator_max  = RAD( 117.0);
-   static final double shoulder_min = RAD( -11.0);
-   static final double shoulder_max = RAD(  97.0);
-   static final double knee_max     = RAD( 147.0);
-   static final double knee_min     = RAD( -27.0);
- 
-   static final double rotator_kmin  = RAD(-90.0);
-   static final double rotator_kmax  = RAD( 90.0);
-   static final double shoulder_kmin = shoulder_min;
-   static final double shoulder_kmax = RAD( 90.0);
-   static final double knee_kmax     = knee_max;
-   static final double f_knee_kmin   = 0.2616;
-   static final double h_knee_kmin   = 0.2316;
- 
-   public Kinematics () {
-   }
- 
-   public static void main(String args[]) {
-     Vector3d target=getForward(0, new LegConfiguration(0.0,0.0,0.0));
-     System.out.println(target);
-     target.y=target.y+20.0;
-     LegConfiguration angles=getInverse(0, target);
-     System.out.println(angles);
-     System.out.println(getForward(0, angles));
-   }
- 
-   final static double RAD(double deg) {
-     return (deg*Math.PI)/180.0;
-   }
- 
-   public static LegConfiguration getInverse(int leg, Vector3d target) {
-     Vector3d pos=new Vector3d();
-     Vector3d targ=new Vector3d(target);
-     Matrix3d rot=new Matrix3d();
-     double rotator=0.0, shoulder=0.0, knee=0.0;
-     double a, b, d, dist;
- 
-     if (leg%2!=0) targ.y = -targ.y;
- 
-     if (leg<2) {
-       targ.sub(f_body_to_shoulder);
-       dist=targ.lengthSquared();
- 
-       a=-2*(f_upper.x*f_lower.z - f_upper.z*f_lower.x);
-       b= 2*(f_upper.x*f_lower.x + f_upper.z*f_lower.z);
-       d=(dist-f_upper.lengthSquared()-f_lower.lengthSquared()
-          -2*f_upper.y*f_lower.y);
-       knee=GetTrigAngle(a,b,d,f_knee_kmin,knee_kmax,true);
- 
-       rot.rotY(-knee);
-       rot.transform(f_leg_knee_to_ball, pos);
-       pos.add(f_leg_shoulder_to_knee);
-       shoulder=GetTrigAngle(-pos.z,pos.y,targ.y,shoulder_kmin,
-                             shoulder_kmax,false);
- 
-       pos.z=Math.sin(shoulder)*pos.y + Math.cos(shoulder)*pos.z;
-       rotator=GetTrigAngle(-pos.z, pos.x, targ.x, rotator_min, rotator_max,
-                            targ.z>0.0);
-     } else {
-       targ.sub(h_body_to_shoulder);
-       dist=targ.lengthSquared();
- 
-       a= 2*(h_upper.x*h_lower.z - h_upper.z*h_lower.x);
-       b= 2*(h_upper.x*h_lower.x + h_upper.z*h_lower.z);
-       d=(dist-h_upper.lengthSquared()-h_lower.lengthSquared()
-          -2*h_upper.y*h_lower.y);
-       knee=GetTrigAngle(a,b,d,h_knee_kmin,knee_kmax,true);
- 
-       rot.rotY(knee);
-       rot.transform(h_leg_knee_to_ball, pos);
-       pos.add(h_leg_shoulder_to_knee);
-       shoulder=GetTrigAngle(-pos.z,pos.y,targ.y,shoulder_kmin,
-                             shoulder_kmax,false);
- 
-       pos.z=Math.sin(shoulder)*pos.y + Math.cos(shoulder)*pos.z;
-       rotator=GetTrigAngle(-pos.z, -pos.x, -targ.x, rotator_min, rotator_max,
-                            targ.z>0.0);
- 
-     }
-     
-     return new LegConfiguration (rotator, shoulder, knee);
-   }
- 
-   static double GetTrigAngle(double a, double b, double d, double min, double max,
-                      boolean add) {
-     double theta;
-     double t, f, c;
- 
-     f=d/Math.sqrt(a*a + b*b);
-     if (Math.abs(f) > 1.0) f=(f > 0.0) ? 1.0 : -1.0;
- 
-     t=Math.atan2(a,b);
-     c=Math.acos(f);
- 
-     theta=add?(t+c):(t-c);
-     if (theta<min) return min;
-     if (theta>max) return max;
-     return theta;
-   }
-  
-   public static Vector3d getForward(int leg, LegConfiguration angles) {
-     Vector3d pos=new Vector3d();
-     Matrix3d rot1=new Matrix3d();
-     Matrix3d rot2=new Matrix3d();
- 
-     if (leg < 2) {
-       rot1.rotY(-angles.knee);
-       rot1.transform(f_leg_knee_to_ball,pos);
- 
-       pos.add(f_leg_shoulder_to_knee);
-       rot1.rotX(angles.shoulder);
-       rot2.rotY(-angles.rotator);
-       rot1.mul(rot2);
-       rot1.transform(pos);
- 
-       pos.add(f_body_to_shoulder);
-     } else {
-       rot1.rotY(angles.knee);
-       rot1.transform(h_leg_knee_to_ball,pos);
- 
-       pos.add(h_leg_shoulder_to_knee);
-       rot1.rotX(angles.shoulder);
-       rot2.rotY(angles.rotator);
-       rot1.mul(rot2);
-       rot1.transform(pos);
- 
-       pos.add(h_body_to_shoulder);
-     }
-     if (leg%2!=0) {
-       pos.y=-pos.y;  
-     }
-     return pos; 
-   }
- }
--- 0 ----
Index: AiboPup/tools/aibo3d/LegConfiguration.java
diff -c AiboPup/tools/aibo3d/LegConfiguration.java:1.1 AiboPup/tools/aibo3d/LegConfiguration.java:removed
*** AiboPup/tools/aibo3d/LegConfiguration.java:1.1	Thu Jun  5 16:25:44 2003
--- AiboPup/tools/aibo3d/LegConfiguration.java	Fri Oct 10 14:37:52 2003
***************
*** 1,17 ****
- public class LegConfiguration {
-   public double rotator;
-   public double shoulder;
-   public double knee;
- 
-   public LegConfiguration (double rotator, double shoulder, double knee) {
-     this.rotator=rotator;
-     this.shoulder=shoulder;
-     this.knee=knee;
-   }
- 
-   public String toString() {
-     return "rotator = " + String.valueOf(rotator) + ", " +
-            "shoulder = " + String.valueOf(shoulder) + ", " +
-            "knee = " + String.valueOf(knee);
-   }
- }
--- 0 ----
Index: AiboPup/tools/aibo3d/Listener.java
diff -c AiboPup/tools/aibo3d/Listener.java:1.1 AiboPup/tools/aibo3d/Listener.java:removed
*** AiboPup/tools/aibo3d/Listener.java:1.1	Thu May 29 16:02:07 2003
--- AiboPup/tools/aibo3d/Listener.java	Fri Oct 10 14:37:52 2003
***************
*** 1,149 ****
- import java.net.ServerSocket;
- import java.net.Socket;
- import java.io.InputStream;
- import java.io.OutputStream;
- import java.io.IOException;
- 
- public abstract class Listener implements Runnable {
-   public Listener() { _port=-1; _isConnected=false; }
-   public Listener(int port) { this(); setPort(port); }
-   public Listener(String host, int port) { this(); setHostPort(host, port); }
- 
-   public void setPort(int port) {
-     _isServer=true;
-     _port=port;
-     startThread();
-   }
- 
-   public void setHostPort(String host, int port) {
-     _isServer=false;
-     _host=host;
-     _port=port;
-     startThread();
-   }
-   
-   public void startThread() {
-     _listenerThread=new Thread(this);
-     _listenerThread.start();
-   }
- 
-   public void run() {
-     if (_port >= 0) {
-       if (_isServer)
-         runServer();
-       else
-         runConnect();
-     } else {
-       System.out.println("can't start Listener without [host],port");
-     }
-   }
- 
-   void frameTimer() {
-     _frametimer_numframes++;
-     if (System.currentTimeMillis()-_frametimer_timer>1000) {
-       System.out.println("updated at "+_frametimer_numframes+"hz");
-       _frametimer_numframes=0;
-       _frametimer_timer=System.currentTimeMillis();
-     }
-   }
- 
-   double readDouble(InputStream in) throws IOException {
-     return Double.longBitsToDouble(readLong(in));
-   }
- 
-   void writeDouble(OutputStream out, double x) throws IOException {
-     writeLong(out,Double.doubleToLongBits(x));
-   }
- 
-   long readLong(InputStream in) throws IOException {
-     int read=0;
-     int last=0;
-     byte[] buf=new byte[8];
-     while (read<8 && last>=0) { last=in.read(buf,read,8-read); read+=last; }
-     if(last<0)
-     	_isConnected=false;
-     return (b2l(buf[7])<<56) | (b2l(buf[6])<<48) |
-            (b2l(buf[5])<<40) | (b2l(buf[4])<<32) |
-            (b2l(buf[3])<<24) | (b2l(buf[2])<<16) |
-            (b2l(buf[1])<< 8) | b2l(buf[0]);
-   }
- 
-   void writeLong(OutputStream out, long x) throws IOException {
-     int bytelen=8;
-     byte[] buf=new byte[bytelen];
-     for(int i=0; i<bytelen; i++)
-       buf[i]=(new Long((x>>(8*i)) & 0xff)).byteValue();
-     out.write(buf,0,bytelen);
-   }
- 
-   float readFloat(InputStream in) throws IOException {
-     return Float.intBitsToFloat(readInt(in));
-   }
-   
-   void writeFloat(OutputStream out, float x) throws IOException {
-     writeInt(out,Float.floatToIntBits(x));
-   }
- 
-   int readInt(InputStream in) throws IOException {
-     int read=0;
-     int last=0;
-     byte[] buf=new byte[4];
-     while (read<4 && last>=0) { last=in.read(buf,read,4-read); read+=last; }
-     if(last<0)
-     	_isConnected=false;
-     return (b2i(buf[3])<<24) | (b2i(buf[2])<<16) |
-            (b2i(buf[1])<< 8) | b2i(buf[0]);
-   }
-   
-   void writeInt(OutputStream out, int x) throws IOException {
-     int bytelen=4;
-     byte[] buf=new byte[bytelen];
-     for(int i=0; i<bytelen; i++)
-       buf[i]=(new Integer((x>>(8*i)) & 0xff)).byteValue();
-     out.write(buf,0,bytelen);
-   }
- 
-   void readBytes(byte[] buf, InputStream in, int bytes) throws IOException {
-     int read=0;
-     int last=0;
-     while (read<bytes && last>=0) { last=in.read(buf, read, bytes-read); read+=last;}
-     if(last<0)
-     	_isConnected=false;
-   }
- 
-   String readLine(InputStream in) throws java.io.IOException{
-     StringBuffer sbuf=new StringBuffer();
-     int x=in.read();
-     if(x==-1) {
-       _isConnected=false;
-       return sbuf.toString();
-     }
-     char c=(char)x;
-     while(c!='\n') {
-       sbuf.append(c);
-       x=in.read();
-       if(x==-1) {
-         _isConnected=false;
-         return sbuf.toString();
-       }
-       c=(char)x;
-     }
-     return sbuf.toString();
-   }
-   
-   int b2i(byte b) { return (b>=0)?(int)b:((int)b)+256; }
-   long b2l(byte b) { return (b>=0)?(long)b:((long)b)+256; }
- 
-   abstract void runServer();
-   abstract void runConnect();
-   abstract public void close();
- 
-   boolean _isServer;
-   int _port;
-   String _host;
-   boolean _isConnected;
-   volatile Thread _listenerThread;
- 
-   int _frametimer_numframes=0;
-   long _frametimer_timer=System.currentTimeMillis();
- }
--- 0 ----
Index: AiboPup/tools/aibo3d/PickMoveBehavior.java
diff -c AiboPup/tools/aibo3d/PickMoveBehavior.java:1.2 AiboPup/tools/aibo3d/PickMoveBehavior.java:removed
*** AiboPup/tools/aibo3d/PickMoveBehavior.java:1.2	Thu Jun  5 16:25:45 2003
--- AiboPup/tools/aibo3d/PickMoveBehavior.java	Fri Oct 10 14:37:52 2003
***************
*** 1,281 ****
- import java.awt.*;
- import java.awt.event.*;
- import java.util.*;
- import javax.media.j3d.*;
- import javax.vecmath.*;
- import javax.media.j3d.*;
- import com.sun.j3d.utils.picking.*;
- import com.sun.j3d.loaders.Scene;
- 
- public class PickMoveBehavior extends Behavior {
-   Canvas3D canvas3d;
-   BranchGroup branchGroup;
-   Scene scene;
-   AiboPicker picker;
-   PickCanvas pickCanvas;
-   WakeupCriterion[] mouseEvents;
-   WakeupOr mouseCriterion;
-   String currentLink;
-   int currentDragButton;
-   Vector3d currentPos;
-   Aibo3DForward forward;
- 
-   TransformGroup viewTransformGroup;
-   Transform3D viewTransformX;
-   Transform3D viewTransformY;
-   Transform3D currTransform;
-   Vector3d viewTranslation;
- 
-   int x, y, dx, dy, x_last, y_last;
-   
-   public PickMoveBehavior (Canvas3D canvas3d, BranchGroup branchGroup,
-       Scene scene, Aibo3DForward forward, TransformGroup viewTransformGroup) {
-     this.canvas3d=canvas3d;
-     this.branchGroup=branchGroup;
-     this.scene=scene;
-     this.forward=forward;
-     this.viewTransformGroup=viewTransformGroup;
-     viewTransformX=new Transform3D();
-     viewTransformY=new Transform3D();
-     currTransform=new Transform3D();
-     viewTranslation=new Vector3d();
-   }
- 
-   public void initialize() {
-     pickCanvas = new PickCanvas (canvas3d, branchGroup);
-     pickCanvas.setMode(PickTool.GEOMETRY_INTERSECT_INFO);
-     pickCanvas.setTolerance(0.0f); // extra bit of speed
- 
-     mouseEvents = new WakeupCriterion[3];
-     mouseEvents[0] = new WakeupOnAWTEvent(MouseEvent.MOUSE_DRAGGED);
-     mouseEvents[1] = new WakeupOnAWTEvent(MouseEvent.MOUSE_PRESSED);
-     mouseEvents[2] = new WakeupOnAWTEvent(MouseEvent.MOUSE_RELEASED);
-     mouseCriterion = new WakeupOr(mouseEvents);
-     wakeupOn(mouseCriterion);
-   }
- 
-   public void createPicker() {
-     picker=new AiboPicker(scene);
-   }
- 
-   void selectLink(MouseEvent event) {
-     if (currentLink!=null) return;
-     if (picker==null) return;
- 
-     pickCanvas.setShapeLocation (event);
-     PickResult result = pickCanvas.pickClosest();
-     if (result!=null) {
-       currentLink=picker.pick(result.getObject());
-       x = x_last = event.getX();
-       y = y_last = event.getY();
-       currentDragButton = event.getButton();
- 
-       if (currentLink==AiboPicker.leg_fl ||
-           currentLink==AiboPicker.foot_fl ||
-           currentLink==AiboPicker.knee_fl) {
-         currentPos=Kinematics.getForward(Kinematics.FRONT_LEFT,
-           new LegConfiguration(-forward.thigh_fl.x,
-                                 forward.thigh_fl.z,
-                                -forward.knee_fl.x));
-       } else if (currentLink==AiboPicker.leg_fr ||
-           currentLink==AiboPicker.foot_fr ||
-           currentLink==AiboPicker.knee_fr) {
-         currentPos=Kinematics.getForward(Kinematics.FRONT_RIGHT,
-           new LegConfiguration(-forward.thigh_fr.x,
-                                -forward.thigh_fr.z,
-                                -forward.knee_fr.x));
- 
-       } else if (currentLink==AiboPicker.leg_bl ||
-           currentLink==AiboPicker.foot_bl ||
-           currentLink==AiboPicker.knee_bl) {
-               currentPos=Kinematics.getForward(Kinematics.BACK_LEFT,
-           new LegConfiguration( forward.thigh_bl.x,
-                                 forward.thigh_bl.z,
-                                 forward.knee_bl.x));
- 
-       } else if (currentLink==AiboPicker.leg_br ||
-           currentLink==AiboPicker.foot_br ||
-           currentLink==AiboPicker.knee_br) {
-         currentPos=Kinematics.getForward(Kinematics.BACK_RIGHT,
-           new LegConfiguration( forward.thigh_br.x,
-                                -forward.thigh_br.z,
-                                 forward.knee_br.x));
- 
-       }
-     }
-   }
- 
-   void rotateViewTransform() {
-     double x_angle, y_angle;
-     double x_factor = 0.03, y_factor = 0.03;
-     x_angle = dy * y_factor;
-     y_angle = dx * x_factor;
- 
-     viewTransformX.rotX(x_angle);
-     viewTransformY.rotY(y_angle);
-     
-     viewTransformGroup.getTransform(currTransform);
- 
-     Matrix4d mat = new Matrix4d();
-     currTransform.get(mat);
- 
-     currTransform.setTranslation(new Vector3d(0.0,0.0,0.0));
-     currTransform.mul(viewTransformX, currTransform);
-     currTransform.mul(viewTransformY, currTransform);
- 
-     Vector3d translation = new Vector3d(mat.m03, mat.m13, mat.m23);
-     currTransform.setTranslation(translation);
- 
-     viewTransformGroup.setTransform(currTransform);
-   }
- 
-   void translateViewTransform() {
-     double x_factor = 0.01, y_factor = 0.01;
- 
-     viewTransformGroup.getTransform(currTransform);
-     viewTranslation.x = dx*x_factor;
-     viewTranslation.y = -dy*y_factor;
- 
-     viewTransformX.set(viewTranslation);
-     currTransform.mul(viewTransformX, currTransform);
-     viewTransformGroup.setTransform(currTransform);
-   }
- 
-   void dragLink(MouseEvent event) {
-     if (currentLink==null) return;
- 
-     x = event.getX();
-     y = event.getY();
- 
-     dx = x - x_last;
-     dy = y - y_last;
- 
-     if (currentLink==AiboPicker.body) {
-       if (currentDragButton==MouseEvent.BUTTON1) {
-         rotateViewTransform();
-       } else if (currentDragButton==MouseEvent.BUTTON3) {
-         translateViewTransform();
-       }
-     } else if (currentLink==AiboPicker.head) {
-       if (currentDragButton==MouseEvent.BUTTON1) { 
-         forward.head.setYDiff(dx);
-         forward.neck.setXDiff(dy);
-       } else if (currentDragButton==MouseEvent.BUTTON3) {
-         forward.head.setZDiff(-dx);
-       }
-     } else if (currentLink==AiboPicker.jaw) {
-       forward.jaw.setXDiff(dy);
-     } else if (currentLink==AiboPicker.tail) {
-       forward.tail.setXDiff(-dy);
-       forward.tail.setYDiff(dx);
-     } else if (currentLink==AiboPicker.leg_fl) {
-       if (currentDragButton==MouseEvent.BUTTON1)
-         forward.thigh_fl.setXDiff(dy);
-       else if (currentDragButton==MouseEvent.BUTTON3)
-         forward.thigh_fl.setZDiff(dx);
-     } else if (currentLink==AiboPicker.knee_fl) {
-       forward.knee_fl.setXDiff(dy);
-     } else if (currentLink==AiboPicker.leg_fr) {
-       if (currentDragButton==MouseEvent.BUTTON1)
-         forward.thigh_fr.setXDiff(dy);
-       else if (currentDragButton==MouseEvent.BUTTON3)
-         forward.thigh_fr.setZDiff(dx);
-     } else if (currentLink==AiboPicker.knee_fr) {
-       forward.knee_fr.setXDiff(dy);
-     } else if (currentLink==AiboPicker.leg_bl) {
-       if (currentDragButton==MouseEvent.BUTTON1)
-         forward.thigh_bl.setXDiff(dy);
-       else if (currentDragButton==MouseEvent.BUTTON3)
-         forward.thigh_bl.setZDiff(dx);
-     } else if (currentLink==AiboPicker.knee_bl) {
-       forward.knee_bl.setXDiff(dy);
-     } else if (currentLink==AiboPicker.leg_br) {
-       if (currentDragButton==MouseEvent.BUTTON1)
-         forward.thigh_br.setXDiff(dy);
-       else if (currentDragButton==MouseEvent.BUTTON3)
-         forward.thigh_br.setZDiff(dx);
-     } else if (currentLink==AiboPicker.knee_br) {
-       forward.knee_br.setXDiff(dy);
-     } else if (currentLink==AiboPicker.foot_fl) {
-       if (currentDragButton==MouseEvent.BUTTON1) {
-         currentPos.x=currentPos.x-dx*0.3;
-         currentPos.z=currentPos.z-dy*0.3;
-       } else if (currentDragButton==MouseEvent.BUTTON3) {
-         currentPos.y=currentPos.y+dx*0.3;
-       }
-       LegConfiguration l=Kinematics.getInverse(Kinematics.FRONT_LEFT,
-                                                currentPos);
-       forward.thigh_fl.setX(-l.rotator);
-       forward.thigh_fl.setZ(l.shoulder);
-       forward.knee_fl.setX(-l.knee);
-     } else if (currentLink==AiboPicker.foot_fr) {
-       if (currentDragButton==MouseEvent.BUTTON1) {
-         currentPos.x=currentPos.x-dx*0.3;
-         currentPos.z=currentPos.z-dy*0.3;
-       } else if (currentDragButton==MouseEvent.BUTTON3) {
-         currentPos.y=currentPos.y+dx*0.3;
-       }
-       LegConfiguration l=Kinematics.getInverse(Kinematics.FRONT_RIGHT,
-                                                currentPos);
-       forward.thigh_fr.setX(-l.rotator);
-       forward.thigh_fr.setZ(-l.shoulder);
-       forward.knee_fr.setX(-l.knee);
-     } else if (currentLink==AiboPicker.foot_bl) {
-       if (currentDragButton==MouseEvent.BUTTON1) {
-         currentPos.x=currentPos.x-dx*0.3;
-         currentPos.z=currentPos.z-dy*0.3;
-       } else if (currentDragButton==MouseEvent.BUTTON3) {
-         currentPos.y=currentPos.y+dx*0.3;
-       }
-       LegConfiguration l=Kinematics.getInverse(Kinematics.BACK_LEFT,
-                                                currentPos);
-       forward.thigh_bl.setX(l.rotator);
-       forward.thigh_bl.setZ(l.shoulder);
-       forward.knee_bl.setX(l.knee);
-     } else if (currentLink==AiboPicker.foot_br) {
-       if (currentDragButton==MouseEvent.BUTTON1) {
-         currentPos.x=currentPos.x-dx*0.3;
-         currentPos.z=currentPos.z-dy*0.3;
-       } else if (currentDragButton==MouseEvent.BUTTON3) {
-         currentPos.y=currentPos.y+dx*0.3;
-       }
-       LegConfiguration l=Kinematics.getInverse(Kinematics.BACK_RIGHT,
-                                                currentPos);
-       forward.thigh_br.setX(l.rotator);
-       forward.thigh_br.setZ(-l.shoulder);
-       forward.knee_br.setX(l.knee);
-     }
- 
-     x_last = x;
-     y_last = y;
-   }
- 
-   void unselectLink() {
-     currentLink=null;
-   }
- 
-   public void processStimulus (Enumeration criteria) {
-     WakeupCriterion wakeup;
-     AWTEvent[] event;
-     int id;
- 
-     while (criteria.hasMoreElements()) {
-       wakeup=(WakeupCriterion) criteria.nextElement();
-       if (wakeup instanceof WakeupOnAWTEvent) {
-         event=((WakeupOnAWTEvent)wakeup).getAWTEvent();
-         for (int i=0; i<event.length; i++) {
-           id=event[i].getID();
-           if (id == MouseEvent.MOUSE_DRAGGED) {
-             dragLink((MouseEvent)event[i]);
-           } else if (id == MouseEvent.MOUSE_PRESSED) {
-             selectLink((MouseEvent)event[i]);
-           } else if (id == MouseEvent.MOUSE_RELEASED) {
-             unselectLink();
-           }
-         }
-       }
-     }
-     wakeupOn(mouseCriterion);
-   }
- 
- }
--- 0 ----
Index: AiboPup/tools/aibo3d/TCPListener.java
diff -c AiboPup/tools/aibo3d/TCPListener.java:1.1 AiboPup/tools/aibo3d/TCPListener.java:removed
*** AiboPup/tools/aibo3d/TCPListener.java:1.1	Thu May 29 16:02:09 2003
--- AiboPup/tools/aibo3d/TCPListener.java	Fri Oct 10 14:37:52 2003
***************
*** 1,47 ****
- import java.net.ServerSocket;
- import java.net.Socket;
- 
- public abstract class TCPListener extends Listener {
-   abstract void connected(Socket socket);
- 
-   void runServer() {
-     Thread me = Thread.currentThread();
-     try { _serverSocket=new ServerSocket(_port); }
-     catch (Exception ex) {
-       System.out.println("port "+_port+": "+ex);
-       return;
-     }
- 
-     while (me == _listenerThread) {
-       try {
-         _socket=_serverSocket.accept();
-         connected(_socket);
-       } catch (Exception ex) { }
-     }
-   }
- 
-   void runConnect() {
-     Thread me = Thread.currentThread();
-     while (me==_listenerThread) {
-       try {
-         _socket=new Socket(_host,_port);
-         connected(_socket);
-         Thread.sleep(500);
-       } catch (Exception ex) { }
-     }
-   }
- 
-   public void close() {
-     _listenerThread=null;
-     try { _socket.close(); } catch (Exception ex) { }
-     if (_isServer)
-       try { _serverSocket.close(); } catch (Exception ex) { }
-   }
- 
-   public TCPListener() { super(); }
-   public TCPListener(int port) { super(port); }
-   public TCPListener(String host, int port) { super(host,port); }
- 
-   Socket _socket;
-   ServerSocket _serverSocket;
- }
--- 0 ----
Index: AiboPup/tools/aibo3d/WorldStateJointsListener.java
diff -c AiboPup/tools/aibo3d/WorldStateJointsListener.java:1.1 AiboPup/tools/aibo3d/WorldStateJointsListener.java:removed
*** AiboPup/tools/aibo3d/WorldStateJointsListener.java:1.1	Thu May 29 16:02:10 2003
--- AiboPup/tools/aibo3d/WorldStateJointsListener.java	Fri Oct 10 14:37:52 2003
***************
*** 1,57 ****
- import java.io.InputStream;
- import java.net.Socket;
- 
- public class WorldStateJointsListener extends TCPListener {
-   boolean _updatedFlag=false;
-   Joints _data;
-   Joints _outd;
- 
-   void connected(Socket socket) {
-     _isConnected=true;
-     _data=new Joints();
-     _outd=new Joints();
-     try {
-       InputStream in=socket.getInputStream();
-       while (true) {
-         _data.timestamp=readInt(in);
-         for (int i=0; i<18; i++)
-           _data.positions[i]=readFloat(in);
-         for (int i=0; i<6; i++)
-           _data.sensors[i]=readFloat(in);
-         for (int i=0; i<8; i++)
-           _data.buttons[i]=readFloat(in);
-         for (int i=0; i<18; i++)
-           _data.duties[i]=readFloat(in);
- 
-         synchronized(_outd) {
-           Joints temp=_data;
-           _data=_outd;
-           _outd=temp;
-           _updatedFlag=true;
-         }
-       }
-     } catch (Exception ex) { }
- 
-     try { socket.close(); } catch (Exception ex) { }
-     _isConnected=false;
-   }
-  
-   public boolean hasData() {
-     return _updatedFlag;
-   }
- 
-   public Joints getData() {
-     synchronized (_outd) {
-       _updatedFlag=false;
-       return _outd;
-     }
-   }
- 
-   public boolean isConnected() {
-     return _isConnected;
-   }
- 
-   public WorldStateJointsListener() { super(); }
-   public WorldStateJointsListener(int port) { super(port); }
-   public WorldStateJointsListener(String host, int port) { super(host,port); }
- }
--- 0 ----
Index: AiboPup/tools/aibo3d/WorldStateJointsWriter.java
diff -c AiboPup/tools/aibo3d/WorldStateJointsWriter.java:1.1 AiboPup/tools/aibo3d/WorldStateJointsWriter.java:removed
*** AiboPup/tools/aibo3d/WorldStateJointsWriter.java:1.1	Thu May 29 16:02:10 2003
--- AiboPup/tools/aibo3d/WorldStateJointsWriter.java	Fri Oct 10 14:37:52 2003
***************
*** 1,42 ****
- import java.io.InputStream;
- import java.io.OutputStream;
- import java.net.Socket;
- 
- public class WorldStateJointsWriter extends TCPListener {
-   OutputStream _out;
- 
-   void connected(Socket socket) {
-     try {
-       _out=socket.getOutputStream();
-     } catch (Exception ex) { return; }
-     _isConnected=true;
-   }
- 
-   public boolean hasData() {
-     return false;
-   }
- 
-   public Joints getData() {
-     return null;
-   }
- 
-   public void close() {
-     _isConnected=false;
-     super.close();
-   }
- 
-   public void write(float[] f) {
-     try {
-       for (int i=0; i<f.length; i++)
-         writeFloat(_out, f[i]);
-     } catch (Exception ex) { close(); }
-   }
- 
-   public boolean isConnected() {
-     return _isConnected;
-   }
- 
-   public WorldStateJointsWriter() { super(); }
-   public WorldStateJointsWriter(int port) { super(port); }
-   public WorldStateJointsWriter(String host, int port) { super(host,port); }
- }
--- 0 ----
Index: AiboPup/tools/aibo3d/aibo3d.lws
diff -c AiboPup/tools/aibo3d/aibo3d.lws:1.3 AiboPup/tools/aibo3d/aibo3d.lws:removed
*** AiboPup/tools/aibo3d/aibo3d.lws:1.3	Thu Jul  3 06:01:26 2003
--- AiboPup/tools/aibo3d/aibo3d.lws	Fri Oct 10 14:37:52 2003
***************
*** 1,386 ****
- LWSC
- 1
- 
- FirstFrame 1
- LastFrame 60
- FrameStep 1
- PreviewFirstFrame 1
- PreviewLastFrame 60
- PreviewFrameStep 1
- FramesPerSecond 30.000000
- 
- LoadObject objects/body2.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0 0.177 0.014 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- ShadowOptions 7
- 
- LoadObject objects/tail2.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0 0.05715 0.08279999 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- ParentObject 1
- ShadowOptions 7
- 
- LoadObject objects/neck.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0 0.0627 -0.10004999 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- ParentObject 1
- ShadowOptions 7
- 
- LoadObject objects/head.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0 0.02689999 -0.0004500076 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- ParentObject 3
- ShadowOptions 7
- 
- LoadObject objects/jaw.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0 -0.00475 -0.02945 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- ParentObject 4
- ShadowOptions 7
- 
- LoadObject objects/ear-l.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0.02704999 0.06610002 0.006099998 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- LockedChannels 6
- ParentObject 4
- ShadowOptions 7
- 
- LoadObject objects/ear-r.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   -0.02705 0.06610002 0.006149998 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- LockedChannels 7
- ParentObject 4
- ShadowOptions 7
- 
- LoadObject objects/leg-b-up-l.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0.07045 0.0033 0.06394999 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- LockedChannels 6
- ParentObject 1
- ShadowOptions 7
- 
- LoadObject objects/leg-b-low-l.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   -0.001850001 -0.09015001 0.0225 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- LockedChannels 6
- ParentObject 8
- ShadowOptions 7
- 
- LoadObject objects/foot-b-l.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0 -0.07345001 0.02495 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- LockedChannels 1
- ParentObject 9
- ShadowOptions 7
- 
- LoadObject objects/leg-b-up-r.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   -0.07064998 0.003349999 0.06394999 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- LockedChannels 6
- ParentObject 1
- ShadowOptions 7
- 
- LoadObject objects/leg-b-low-r.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0.00205 -0.09019998 0.0225 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- LockedChannels 6
- ParentObject 11
- ShadowOptions 7
- 
- LoadObject objects/foot-b-r.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0 -0.0735 0.025 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- LockedChannels 1
- ParentObject 12
- ShadowOptions 7
- 
- LoadObject objects/leg-f-up-l.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0.07045001 -0.0007499999 -0.07510001 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- LockedChannels 6
- ParentObject 1
- ShadowOptions 7
- 
- LoadObject objects/leg-f-low-l.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   -0.00165 -0.09469999 -0.01165 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- LockedChannels 6
- ParentObject 14
- ShadowOptions 7
- 
- LoadObject objects/foot-f-l.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0 -0.06485 -0.02929999 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- LockedChannels 1
- ParentObject 15
- ShadowOptions 7
- 
- LoadObject objects/leg-f-up-r.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   -0.07044999 -0.0006499998 -0.07515001 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- LockedChannels 6
- ParentObject 1
- ShadowOptions 7
- 
- LoadObject objects/leg-f-low-r.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0.00105 -0.0948 -0.0116 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- LockedChannels 6
- ParentObject 17
- ShadowOptions 7
- 
- LoadObject objects/foot-f-r.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0 -0.0649 -0.0293 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- LockedChannels 1
- ParentObject 18
- ShadowOptions 7
- 
- LoadObject objects/LED_g01.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0 0 0 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- ParentObject 4
- ShadowOptions 7
- 
- LoadObject objects/LED_g02.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0 0 0 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- ParentObject 4
- ShadowOptions 7
- 
- LoadObject objects/LED_g03.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0 0 0 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- ParentObject 4
- ShadowOptions 7
- 
- LoadObject objects/LED_r01.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0 0 0 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- ParentObject 4
- ShadowOptions 7
- 
- LoadObject objects/LED_r02.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0 0 0 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- ParentObject 4
- ShadowOptions 7
- 
- LoadObject objects/LED_r03.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0 0 0 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- ParentObject 4
- ShadowOptions 7
- 
- LoadObject objects/LED_r04.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0 0 0 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- ParentObject 4
- ShadowOptions 7
- 
- LoadObject objects/LED_tail.lwo
- ShowObject 8 7
- ObjectMotion (unnamed)
-   9
-   1
-   0 0 0 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- ParentObject 2
- ShadowOptions 7
- 
- AmbientColor 255 255 255
- AmbIntensity 0.50000
- 
- AddLight
- LightName Light
- ShowLight 1 7
- LightMotion (unnamed)
-   9
-   1
-   -2 2 -2 45 35 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- LightColor 255 255 255
- LgtIntensity 0.700000
- LightType 0
- ShadowType 1
- 
- ShowCamera 1 7
- CameraMotion (unnamed)
-   9
-   1
-   -0.6381658 0.5205013 -0.6771318 0 0 0 1 1 1
-   0 0 0 0 0
- EndBehavior 1
- TargetObject 1
- ZoomFactor 3.200000
- Resolution 1
- PixelAspectRatio 2
- SegmentMemory 2200000
- Antialiasing 0
- AdaptiveSampling 1
- AdaptiveThreshold 16
- FilmSize 2
- FieldRendering 0
- MotionBlur 0
- DepthOfField 0
- 
- SolidBackdrop 1
- BackdropColor 80 80 180 
- ZenithColor 0 40 80
- SkyColor 120 180 240
- GroundColor 50 40 30
- NadirColor 100 80 60
- FogType 0
- DitherIntensity 1
- AnimatedDither 0
- 
- RenderMode 2
- RayTraceEffects 0
- ClipRayColors 0
- DataOverlayLabel  
- FullSceneParamEval 0
- 
- ViewMode 5
- ViewAimpoint -0.006362 0.165064 -0.119767
- ViewDirection 0.300197 -0.314159 0.000000
- ViewZoomFactor 0.526749
- GridNumber 40
- GridSize 0.010000
- ShowMotionPath 1
- ShowBGImage 0
- ShowFogRadius 0
- ShowRedraw 0
- ShowSafeAreas 0
- ShowFieldChart 0
--- 0 ----
Index: AiboPup/tools/aibo3d/objects/LED_g01.lwo
Index: AiboPup/tools/aibo3d/objects/LED_g02.lwo
Index: AiboPup/tools/aibo3d/objects/LED_g03.lwo
Index: AiboPup/tools/aibo3d/objects/LED_r01.lwo
Index: AiboPup/tools/aibo3d/objects/LED_r02.lwo
Index: AiboPup/tools/aibo3d/objects/LED_r03.lwo
Index: AiboPup/tools/aibo3d/objects/LED_r04.lwo
Index: AiboPup/tools/aibo3d/objects/LED_tail.lwo
Index: AiboPup/tools/aibo3d/objects/body2.lwo
Index: AiboPup/tools/aibo3d/objects/ear-l.lwo
Index: AiboPup/tools/aibo3d/objects/ear-r.lwo
Index: AiboPup/tools/aibo3d/objects/foot-b-l.lwo
Index: AiboPup/tools/aibo3d/objects/foot-b-r.lwo
Index: AiboPup/tools/aibo3d/objects/foot-f-l.lwo
Index: AiboPup/tools/aibo3d/objects/foot-f-r.lwo
Index: AiboPup/tools/aibo3d/objects/head.lwo
Index: AiboPup/tools/aibo3d/objects/jaw.lwo
Index: AiboPup/tools/aibo3d/objects/leg-b-low-l.lwo
Index: AiboPup/tools/aibo3d/objects/leg-b-low-r.lwo
Index: AiboPup/tools/aibo3d/objects/leg-b-up-l.lwo
Index: AiboPup/tools/aibo3d/objects/leg-b-up-r.lwo
Index: AiboPup/tools/aibo3d/objects/leg-f-low-l.lwo
Index: AiboPup/tools/aibo3d/objects/leg-f-low-r.lwo
Index: AiboPup/tools/aibo3d/objects/leg-f-up-l.lwo
Index: AiboPup/tools/aibo3d/objects/leg-f-up-r.lwo
Index: AiboPup/tools/aibo3d/objects/neck.lwo
Index: AiboPup/tools/aibo3d/objects/tail2.lwo
Index: AiboPup/tools/binstrswap/Makefile
diff -c AiboPup/tools/binstrswap/Makefile:1.1 AiboPup/tools/binstrswap/Makefile:1.2
*** AiboPup/tools/binstrswap/Makefile:1.1	Thu Oct 24 20:36:37 2002
--- AiboPup/tools/binstrswap/Makefile	Sun Aug 24 17:19:21 2003
***************
*** 1,4 ****
! .PHONY: all
  
  all: binstrswap
  
--- 1,4 ----
! .PHONY: all clean
  
  all: binstrswap
  
Index: AiboPup/tools/binstrswap/binstrswap.cc
diff -c AiboPup/tools/binstrswap/binstrswap.cc:1.2 AiboPup/tools/binstrswap/binstrswap.cc:1.3
*** AiboPup/tools/binstrswap/binstrswap.cc:1.2	Thu Feb  6 22:47:18 2003
--- AiboPup/tools/binstrswap/binstrswap.cc	Sat Jul 26 11:35:01 2003
***************
*** 44,50 ****
  		return 1;
  	}
  	
! 	unsigned int bufsize=srchlen*8;
  	byte * buf = new byte[bufsize];
  	f.read(buf,srchlen-1);
  	unsigned int cur=f.gcount();
--- 44,50 ----
  		return 1;
  	}
  	
! 	unsigned int bufsize=srchlen*4096;
  	byte * buf = new byte[bufsize];
  	f.read(buf,srchlen-1);
  	unsigned int cur=f.gcount();
Index: AiboPup/tools/evenmodtime/Makefile
diff -c /dev/null AiboPup/tools/evenmodtime/Makefile:1.2
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/evenmodtime/Makefile	Sun Aug 24 17:19:27 2003
***************
*** 0 ****
--- 1,10 ----
+ .PHONY: all clean
+ 
+ all: evenmodtime
+ 
+ evenmodtime: evenmodtime.cc
+ 	g++ -o evenmodtime -Wall -O2 evenmodtime.cc
+ 
+ clean:
+ 	rm -f evenmodtime
+ 
Index: AiboPup/tools/evenmodtime/evenmodtime.cc
diff -c /dev/null AiboPup/tools/evenmodtime/evenmodtime.cc:1.1
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/evenmodtime/evenmodtime.cc	Mon Jul 28 14:39:19 2003
***************
*** 0 ****
--- 1,54 ----
+ #include <stdlib.h>
+ #include <unistd.h>
+ #include <time.h>
+ #include <iostream>
+ #include <sys/stat.h>
+ #include <utime.h>
+ 
+ using namespace std;
+ 
+ int usage(unsigned int argc, const char* argv[]) {
+ 	cerr << "Usage: "<<argv[0]<<" filename ... \n"
+ 			 << "       This will round the modification time of filename up to the\n"
+ 			 << "       nearest even second.\n"
+ 			 << "       \n"
+ 			 << "       This is useful for cleaning up modification times on a PC before\n"
+ 			 << "       synchronizing with a memory stick, since memory sticks apparently\n"
+ 			 << "       do not store odd seconds, which causes confusion for programs\n"
+ 			 << "       such as rsync" << endl;
+ 	return 2;
+ }
+ 
+ 
+ /*	   << "       This will then output the modification time of filename rounded\n"
+ 			 << "       up to the nearest even second in the format YYYYMMDDHHMMSS.\n"
+ */
+ 
+ int main(unsigned int argc, const char* argv[]) {
+ 	int status;
+ 	if(argc<2)
+ 		return usage(argc,argv);
+ 	for(unsigned int i=1; i<argc; i++) {
+ 		struct stat stat_buf;
+ 		status=lstat(argv[i],&stat_buf);
+ 		if(status) {
+ 			cerr << argv[0] << ": Bad file '" << argv[i] << "'" << endl;
+ 			return 1;
+ 		}
+ 		stat_buf.st_mtime=(stat_buf.st_mtime+1) & ~1;
+ 		//  struct tm * tm_buf;
+ 		//	tm_buf=localtime(&stat_buf.st_mtime);
+ 		//	char out[1024];
+ 		//	strftime(out,1024,"%Y%m%d%H%M.%S",tm_buf);
+ 		//	cout << out << endl;
+ 		struct utimbuf  ut_buf;
+ 		ut_buf.actime=stat_buf.st_atime;
+ 		ut_buf.modtime=stat_buf.st_mtime;
+ 		status=utime(argv[i],&ut_buf);
+ 		if(status) {
+ 			cerr << argv[0] << ": Bad file '" << argv[i] << "'" << endl;
+ 			return 1;
+ 		}
+ 	}
+ 	return 0;
+ }
Index: AiboPup/tools/filtersyswarn/Makefile
diff -c AiboPup/tools/filtersyswarn/Makefile:1.1 AiboPup/tools/filtersyswarn/Makefile:1.2
*** AiboPup/tools/filtersyswarn/Makefile:1.1	Thu Oct 24 20:36:37 2002
--- AiboPup/tools/filtersyswarn/Makefile	Sun Aug 24 17:19:32 2003
***************
*** 1,4 ****
! .PHONY: all
  
  all: filtersyswarn
  
--- 1,4 ----
! .PHONY: all clean
  
  all: filtersyswarn
  
Index: AiboPup/tools/filtersyswarn/filtersyswarn.cc
diff -c AiboPup/tools/filtersyswarn/filtersyswarn.cc:1.4 AiboPup/tools/filtersyswarn/filtersyswarn.cc:1.6
*** AiboPup/tools/filtersyswarn/filtersyswarn.cc:1.4	Sat Nov 30 17:50:29 2002
--- AiboPup/tools/filtersyswarn/filtersyswarn.cc	Thu Sep 25 11:32:15 2003
***************
*** 6,21 ****
  
  using namespace std;
  
  int main(int argc, const char** argv) {
  	regex_t sysmsg, instbegin, inststat, ignorebegin, warnstat, inclbegin, inclstat;
  	
! 	string OPENR="^/usr/local/OPEN_R_SDK/";
  	string clip="  [...]";
  	
  	regcomp(&inclbegin,"^In file included from",REG_EXTENDED|REG_NOSUB);
  	regcomp(&inclstat, "^                 from",REG_EXTENDED|REG_NOSUB);
  
! 	string instbeginstr=".*: (At global scope:|In instantiation of |In method |In member function|In destructor |In constructor |In function |In static )";
  	string inststatstr=instbeginstr+"|   instantiated from |^   ";
  	regcomp(&sysmsg,OPENR.c_str(),REG_EXTENDED|REG_NOSUB);
  	regcomp(&instbegin,instbeginstr.c_str(),REG_EXTENDED|REG_NOSUB);
--- 6,32 ----
  
  using namespace std;
  
+ //you can pass a replacement path to override OPENRSDK_ROOT
+ 
  int main(int argc, const char** argv) {
  	regex_t sysmsg, instbegin, inststat, ignorebegin, warnstat, inclbegin, inclstat;
  	
! 	string OPENR="^";
! 	if(argc>1)
! 		OPENR+=argv[1];
! 	else {
! 		char* OPENRSDK_ROOT=getenv("OPENRSDK_ROOT");
! 		OPENR+=(OPENRSDK_ROOT!=NULL)?OPENRSDK_ROOT:"/usr/local/OPEN_R_SDK/";
! 	}
  	string clip="  [...]";
  	
  	regcomp(&inclbegin,"^In file included from",REG_EXTENDED|REG_NOSUB);
  	regcomp(&inclstat, "^                 from",REG_EXTENDED|REG_NOSUB);
  
! 	//string instbeginstr=".*: (At global scope:|In instantiation of |In method |In member function|In destructor |In constructor |In function |In static )";
! 	// problems with line wrapping on long paths... but does this filter too much now?
! 
! 	string instbeginstr=".*: (At|In)";
  	string inststatstr=instbeginstr+"|   instantiated from |^   ";
  	regcomp(&sysmsg,OPENR.c_str(),REG_EXTENDED|REG_NOSUB);
  	regcomp(&instbegin,instbeginstr.c_str(),REG_EXTENDED|REG_NOSUB);
***************
*** 43,49 ****
  		if(regexec(&instbegin,s.c_str(),0,NULL,0)==0) {
  			instant="";
  			do {
! 				instant+="  "+s+'\n';
  				getline(cin,s);
  			} while(regexec(&inststat,s.c_str(),0,NULL,0)==0);
  			outinstant=false;
--- 54,60 ----
  		if(regexec(&instbegin,s.c_str(),0,NULL,0)==0) {
  			instant="";
  			do {
! 				instant+=s+'\n';
  				getline(cin,s);
  			} while(regexec(&inststat,s.c_str(),0,NULL,0)==0);
  			outinstant=false;
***************
*** 77,83 ****
  			cout << clip << endl;
  			warnclipped=false;
  		}
! 		cout << "  " << s << endl;
  		getline(cin,s);
  	}
  	if(warnclipped)
--- 88,94 ----
  			cout << clip << endl;
  			warnclipped=false;
  		}
! 		cout << s << endl;
  		getline(cin,s);
  	}
  	if(warnclipped)
Index: AiboPup/tools/mipaltools/Makefile
diff -c /dev/null AiboPup/tools/mipaltools/Makefile:1.5
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/mipaltools/Makefile	Thu Oct  9 15:51:28 2003
***************
*** 0 ****
--- 1,9 ----
+ .PHONY: all
+ 
+ all: StackedIt
+ 
+ StackedIt: src/*.h src/*.cc
+ 	make -C src
+ 
+ clean:
+ 	make -C src clean
Index: AiboPup/tools/mipaltools/README.txt
diff -c /dev/null AiboPup/tools/mipaltools/README.txt:1.2
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/mipaltools/README.txt	Wed Sep 10 15:21:53 2003
***************
*** 0 ****
--- 1,12 ----
+ Mi-Pal crash analysis tools.
+ ============================
+ 
+ Mi-Pal Griffith University
+ Australia
+ 
+ This package contains two tools we use in debugging crashes on the Aibos.
+ For details on the exception log parser (elp) please see doc/ELPREADME.txt.
+ For instructions on StackedIt (previously called StackCheck) see doc/StackedIt_Readme.txt.
+ 
+ These programs copyrighted to the respective authors and are licensed under the GPL(version2) (see doc/license.txt)
+ No warantee is provided for these programs so use at your own risk. If you redistribute the programs in this package you must include license.txt as well.
Index: AiboPup/tools/mipaltools/elp.pl
diff -c /dev/null AiboPup/tools/mipaltools/elp.pl:1.4
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/mipaltools/elp.pl	Wed Sep 10 16:19:57 2003
***************
*** 0 ****
--- 1,386 ----
+ #!/usr/bin/perl -w
+ use strict;
+ 
+ ###############################################################################
+ #
+ #  Author: Stuart Seymon
+ #  Mi-Pal Griffith University Australia
+ #
+ #  This program is copyrighted to the Author and released under the GPL(version2).
+ #  See doc/license.txt
+ #
+ #  elp.pl   parse the emon.log error file
+ #
+ #  Usage
+ #
+ #  ./epl.pl [-e emonFile][-A]
+ #
+ #  -e specifies the EMON.LOG file to be "emonFile"
+ #     default emonFile: ./EMON.LOG
+ #  -A stop assembly code being printed to stdout
+ #
+ #  
+ #  This script will print out all the relevant information to be ascertained 
+ #  from the EMON.LOG file that is produced whenever the AIBO crashes.  It will 
+ #  use this information to determine the assembly code address that caused the
+ #  exception.  If '-A' is not used, it will print out a section of the assembly
+ #  code, as well as the important aspects of EMON.LOG.  
+ #
+ #  Regardless of the 'A' switch being used, it will print out the entire 
+ #  assembly code to a file in the cwd labelled: 
+ #  aiboDis<n>.ass  
+ #  where:
+ #  n is the number of disassemblies residing in the cwd
+ #  
+ #  N.B.  the *ass files by their nature are quite large, so be sure to 
+ #  remove your .ass files when you are finished with them.
+ 
+ my $TRUE    = 0;
+ my $FALSE   = 1;
+ 
+ my $line;
+ my @lines;
+ my @output;
+ my @throwaway;
+ my $continue;
+ 
+ my $excepDescrip;       
+ my $objContextId;       
+ my $excepObj;           
+ my $BadVAddr;
+ my $epc;
+ my $gpVal;
+ my $objDir;
+ my $addr_gp;
+ my $ra;
+ my $linkTimeAddr;
+ 
+ my $showAssembly = $TRUE;
+ my $assemFile;
+ my $timeStamp = time();
+ 
+ my $crashLine;
+ 
+ my $lineCounter    = 0;
+ my $genericCounter = 0;
+ my $blah;
+ my @stuff;                 #used to split a line into its individual pieces
+ 
+ my $emonFile   = "./EMON.LOG";
+ my $PREFIX     = "aiboDis";
+ my $EXTENSION  = "ass";
+ 
+ my $assemCount;   #the number of disassems in cwd
+ my $ls         = "ls";
+ my $wc         = "wc -l";
+ my $OPENRSDK_ROOT = "/usr/local/OPEN_R_SDK";        #can be overridden by environment variable of the same name
+ if( defined $ENV{"OPENRSDK_ROOT"} ) {
+ 	$OPENRSDK_ROOT = $ENV{"OPENRSDK_ROOT"};
+ }
+ my $mlr        = "$OPENRSDK_ROOT/bin/mipsel-linux-readelf -s";    #relative to OPENRSDK_ROOT
+ my $mlo        = "$OPENRSDK_ROOT/bin/mipsel-linux-objdump -S -C"; #relative to OPENRSDK_ROOT
+ 
+ my $OBJ_NAME_POS     = 0;  #pos of each value in each relevant line
+ my $BADVADDR_POS     = 5;  
+ my $EPC_POS          = 9;
+ my $OB_CONT_ID_POS   = 2;  
+ my $GPVAL_POS        = 5;
+ my $RA_POS           = 2;
+ 
+ my $MAX_ASSEMBLY_OUTPUT = 100;   
+ 
+ select(STDOUT);
+ $| = 1;
+ 
+ @stuff = split(/^\s*/, `$ls $PREFIX*|$wc`);
+ $assemCount = $stuff[1];   
+ chomp $assemCount;
+ 
+ $assemFile = "$PREFIX$assemCount.$EXTENSION";
+ 
+ 
+ #get command line arguments
+ foreach(@ARGV)
+ {
+    if($ARGV[$genericCounter] eq "-e")
+    {
+       if(($genericCounter + 1) < scalar@ARGV)
+       {
+          $emonFile = $ARGV[$genericCounter + 1];
+       }
+       else 
+       {
+          &usage();
+          exit(1);
+       }
+    }
+    elsif($ARGV[$genericCounter] eq "-A")
+    {
+       $showAssembly = $FALSE;
+    }
+    elsif($ARGV[$genericCounter] eq "-help")
+    {
+       &usage();
+       exit(1);
+    }
+     
+    $genericCounter++;
+ }
+ 
+ #############################################################################
+ #  
+ #  parse EMON.LOG
+ #
+ open (EMON, $emonFile) || die "Cannot open $emonFile";
+ while ($line = <EMON>)
+ {
+    chomp($line);
+    push(@lines, $line);
+    
+    if($objContextId)
+    {
+       if ($line =~/\Q$objContextId/)
+       {
+          @stuff = split(/\s+/, $line);
+          $excepObj = $stuff[$OBJ_NAME_POS];
+       }
+    }
+    
+    if($line =~/^exception code/)
+    {
+       $excepDescrip = $line;
+    }
+    
+    if($line =~/badvaddr.*epc/)
+    {
+       @stuff      = split(/\s+|:/, $line);
+       $BadVAddr   = $stuff[$BADVADDR_POS];
+       ($BadVAddr, @throwaway) = split(/,/, $BadVAddr);
+       $epc        = $stuff[$EPC_POS];
+    }
+    
+    if($line =~/ra:r31/)
+    {
+       @stuff = split(/\s+|,/, $line);
+       $ra    = $stuff[$RA_POS];
+    }   
+       
+    if($line =~/gp:r28/)
+    {
+       @stuff = split(/\s+|,/, $line);
+       $gpVal = $stuff[$GPVAL_POS];
+    }
+ 
+    #get the object context_id that caused the exception
+    if($line =~/context.*state/)
+    {
+       @stuff = split(/\s+|,/, $line);
+       $objContextId = $stuff[$OB_CONT_ID_POS];
+    }
+    
+       
+    $lineCounter++;
+ }
+ close EMON;
+ 
+ #############################################################################
+ #
+ #  error checking and analysis of grabbed data
+ #
+ if(!$excepObj)  
+ {
+    print "Unable to match context address with object\n";
+    exit(1);
+ }
+ 
+ if($excepDescrip =~/ddress/)
+ {  
+    push(@output, ("Address that failed to have a valid reference:\n\t" . $BadVAddr));
+ }
+ elsif($excepDescrip =~/TLB/)
+ {
+    push(@output, ("Virtual address that failed to have a valid translation:\n\t\t\t" . $BadVAddr));
+ }
+ 
+ if($BadVAddr eq $epc)
+ {
+    push(@output, ("Jumped to an invalid address"));
+ }
+ 
+ 
+ #############################################################################
+ #
+ #  get the address of _gp using mipsel-linux-readelf
+ #
+ $blah = $excepObj . ".nosnap.elf|grep \'_gp\$\'";
+ @stuff = `$mlr $blah`;
+ 
+ if(!@stuff)          #object was not made in cwd
+ {
+    print "\nPlease specify the directory where $excepObj was made:\n";
+    $objDir = <STDIN>;
+    chomp $objDir;
+       
+    if(!($objDir =~/\/$/))
+    {
+       $objDir = $objDir . "/";
+    }
+ 
+    $blah = $objDir . $excepObj . ".nosnap.elf |grep \'_gp\$\'";
+    @stuff = `$mlr $blah`;
+    
+    if(!@stuff)       #still wrong
+    {
+       die "unable to find $excepObj.nosnap.elf in $objDir\n";
+    }
+ }
+ 
+ @stuff = split(/ /, $stuff[0]);
+ 
+ $genericCounter = 0;
+ while($genericCounter < scalar@stuff)
+ {
+    if($stuff[$genericCounter] =~/[\dabcdef]{8}/)
+    {
+       $addr_gp = "0x". $stuff[$genericCounter];
+    }
+    $genericCounter++;
+ } 
+ 
+ 
+ 
+ ############################################################################
+ #
+ #  Do the hex addition/subtraction
+ #
+ 
+ $linkTimeAddr = hex($epc) - hex($gpVal);
+ $linkTimeAddr += hex($addr_gp);
+ $linkTimeAddr = sprintf("%x", $linkTimeAddr);
+ 
+ 
+ ############################################################################         
+ #                                                                                    
+ #  Time to look at the assembly code                                                 
+ if ($objDir)                                                                         
+ {
+    $blah = $objDir . $excepObj . ".nosnap.elf";
+ }
+ else
+ {
+    $blah = $excepObj . ".nosnap.elf";
+ }
+ 
+ @stuff = `$mlo $blah`;     #the output of this is quite large, and thus
+                            #takes a while to execute
+ 
+ open (BLAH, ">$assemFile");
+ 
+ print BLAH $excepDescrip;                                
+ print BLAH "\nObject Name:        " . $excepObj;         
+ print BLAH "\nObject Context ID:  " . $objContextId;     
+ print BLAH "\nBadVAddr:           " . $BadVAddr;         
+ print BLAH "\nEPC:                " . $epc;
+ print BLAH "\ngpVal               " . $gpVal;
+ print BLAH "\nLink Time Address:  " . $linkTimeAddr;   
+ print BLAH "\naddr_gp:            " . $addr_gp;
+ print BLAH "\nra:                 " . $ra;
+ print BLAH "\n\n";                                       
+ 
+ $genericCounter = 0;
+ while($genericCounter < scalar@stuff)
+ {  
+    if($genericCounter % 1000 == 0)
+    {
+       #print ".";
+       #$! = 1;
+    }
+    print BLAH $stuff[$genericCounter];
+    chomp($stuff[$genericCounter]);
+    if($stuff[$genericCounter] =~/^(\s{0,4})?\Q$linkTimeAddr/)
+    {
+       $crashLine = $genericCounter;
+    }
+    $genericCounter++;
+ }
+ print "\n";
+ close (BLAH);
+ 
+ if(!$crashLine)
+ {
+    &printResults(@output);
+    die "unable to find link time address in assembly code\n";
+ }
+ 
+ $genericCounter = $crashLine;
+ while(!($stuff[$genericCounter] =~ /^\s*$/))
+ {
+    $genericCounter--;
+ }
+ 
+ $continue = $TRUE;
+ if($showAssembly == $TRUE)
+ {
+    $blah = $genericCounter;
+    while (($genericCounter < ($crashLine + 10)) && ($continue == $TRUE))
+    {
+       if($genericCounter > $crashLine)
+       {
+          if($stuff[$genericCounter] =~ /^\s*$/)
+          {
+             $continue = $FALSE;
+          }
+       }
+       push(@output, $stuff[$genericCounter]);
+ 
+       if($genericCounter == $crashLine)
+       {
+          push(@output, "  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
+       }
+       
+       $genericCounter++;
+    }
+    if($genericCounter - $blah > $MAX_ASSEMBLY_OUTPUT)
+    {
+       push(@output, "\nExcessive ouput detected: use \'-A\' to stop assembly output");
+       push(@output, "Entire assembly code has been written to file, \"$assemFile\"\n");
+    }
+ }
+ 
+ push(@output, $excepDescrip);
+ push(@output, ("\nObject Name: \t\t" . $excepObj));
+ push(@output, ("object Context id: \t" . $objContextId));
+ push(@output, ("BadVAddr:\t\t" . $BadVAddr));
+ push(@output, ("EPC: \t\t\t" . $epc));
+ push(@output, ("gpVal: \t\t\t" . $gpVal));
+ push(@output, ("linkTimeAddr: \t\t  0x" . $linkTimeAddr));
+ push(@output, ("addr_gp: \t\t" . $addr_gp));
+ push(@output, ("ra: \t\t\t" . $ra));
+ 
+ print "\n";
+ 
+ &printResults(@output);
+ 
+ ####### END script
+ 
+ 
+ 
+ 
+ sub printResults
+ {
+    my $count = 0;
+    
+    while ($count < scalar@_)
+    {
+       print $_[$count++] . "\n";
+    }
+ }
+ 
+ sub usage
+ {
+    print "usage:\n";
+    print "\n./elp.pl [-e emonFile][-A]\n\n";
+    print "-e specify the location of EMON.LOG to be <emonFile>\n";
+    print "   default: ./EMON.LOG\n";
+    print "-A stops the output of assembly code to stdout.\n";
+ }
Index: AiboPup/tools/mipaltools/modifications.diff
diff -c /dev/null AiboPup/tools/mipaltools/modifications.diff:1.1
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/mipaltools/modifications.diff	Wed Sep 10 16:21:00 2003
***************
*** 0 ****
--- 1,39 ----
+ Index: Makefile
+ ===================================================================
+ RCS file: /afs/cs/project/skinnerbots/aibo/Tekkotsu/tools/mipaltools/Makefile,v
+ retrieving revision 1.2
+ retrieving revision 1.3
+ diff -u -b -B -r1.2 -r1.3
+ --- Makefile	10 Sep 2003 19:21:53 -0000	1.2
+ +++ Makefile	10 Sep 2003 20:14:40 -0000	1.3
+ @@ -1,3 +1,7 @@
+ +.PHONY: all
+ +
+ +all: StackedIt
+ +
+  StackedIt:	
+  	make -C src
+  	
+ Index: elp.pl
+ ===================================================================
+ RCS file: /afs/cs/project/skinnerbots/aibo/Tekkotsu/tools/mipaltools/elp.pl,v
+ retrieving revision 1.2
+ retrieving revision 1.4
+ diff -u -b -B -r1.2 -r1.4
+ --- elp.pl	10 Sep 2003 19:21:53 -0000	1.2
+ +++ elp.pl	10 Sep 2003 20:19:57 -0000	1.4
+ @@ -73,8 +73,12 @@
+  my $assemCount;   #the number of disassems in cwd
+  my $ls         = "ls";
+  my $wc         = "wc -l";
+ -my $mlr        = "/usr/local/OPEN_R_SDK/bin/mipsel-linux-readelf -s";
+ -my $mlo        = "/usr/local/OPEN_R_SDK/bin/mipsel-linux-objdump -S -C";
+ +my $OPENRSDK_ROOT = "/usr/local/OPEN_R_SDK";        #can be overridden by environment variable of the same name
+ +if( defined $ENV{"OPENRSDK_ROOT"} ) {
+ +	$OPENRSDK_ROOT = $ENV{"OPENRSDK_ROOT"};
+ +}
+ +my $mlr        = "$OPENRSDK_ROOT/bin/mipsel-linux-readelf -s";    #relative to OPENRSDK_ROOT
+ +my $mlo        = "$OPENRSDK_ROOT/bin/mipsel-linux-objdump -S -C"; #relative to OPENRSDK_ROOT
+  
+  my $OBJ_NAME_POS     = 0;  #pos of each value in each relevant line
+  my $BADVADDR_POS     = 5;  
Index: AiboPup/tools/mipaltools/doc/ELPREADME.TXT
diff -c /dev/null AiboPup/tools/mipaltools/doc/ELPREADME.TXT:1.1
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/mipaltools/doc/ELPREADME.TXT	Wed Sep 10 15:21:58 2003
***************
*** 0 ****
--- 1,66 ----
+ elp.pl
+ 
+ Author : Stuart Seymon
+ Mi-Pal,  Griffith University, Australia
+ 31/7/2003
+ 
+ Changes (5/9/2003)
+ =======
+ Thanks to the tekkotsu team for pointing out a bug regarding ls.
+ 
+ Description
+ ===========
+ 
+ elp is a perl script which parses the "EMON.LOG" files, which are generated 
+ when code on a Sony Aibo crashes.  This script can be used in conjunction with
+ the StackTrace program developed by Joel Fenwick.
+ 
+ Yes, this is similar to the EmonLogParser script supplied by Sony, however, in addition to obtaining the relevant information, elp goes on to call the Sony supplied program, 
+ "mipsel-linux-objdump".  The assembly code generated by this call is written 
+ to an "aiboDis*.ass" file, and the code around the crash is printed to stdout.
+ 
+ Requirements
+ ============
+ 
+ elp.pl was written for use in the cygwin environment, however it should also 
+ work on any unix derivative machine.  Having said that, you may need to alter 
+ the path locations of the following to what it corresponds to on your machine:
+ 
+ /usr/bin/perl
+ /usr/bin/ls
+ /usr/bin/wc
+ /usr/local/OPEN_R_SDK/bin/mipsel-linux-readelf -s
+ /usr/local/OPEN_R_SDK/bin/mipsel-linux-objdump
+ 
+ the commands "which" or "whereis" should help you if are unsure as to their 
+ location.
+ 
+ 
+ Usage
+ =====
+ 
+ "elp.pl" should be placed in the directory where you want the assembly code to
+ be written, as the resulting file is written to the current working directory.  
+ It is also a good idea to keep it where the relevant ".nosnap.elf" file resides 
+ (wherever the object that caused the problem was made), provided the offending 
+ object is known beforehand.  However, elp will prompt you for the directory 
+ where the object was made if it is not the same as the cwd.
+ 
+ 
+ at the prompt, type:
+ 
+ ./epl.pl [-e emonFile][-A]
+ 
+ where
+   -e specifies the EMON.LOG file to be "emonFile"
+      default emonFile: ./EMON.LOG
+   -A stop assembly code being printed to stdout
+ 
+ The assembly code is written to a file "aiboDis*.ass", where * is an integer 
+ that represents the number of disassemblies currently in the cwd (hence, it 
+ starts at zero, and increments with each new disassembly).  
+ 
+ The *ass files by the nature can be quite large (ours were around 10M), so it
+ is a good idea to delete them once you are finished with them.
+ 
+ 
Index: AiboPup/tools/mipaltools/doc/StackedIt_Readme.txt
diff -c /dev/null AiboPup/tools/mipaltools/doc/StackedIt_Readme.txt:1.2
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/mipaltools/doc/StackedIt_Readme.txt	Thu Oct  9 11:23:27 2003
***************
*** 0 ****
--- 1,200 ----
+ About the StackedIt tool.
+ ==========================
+ 
+ Author: Joel Fenwick
+ Mi-Pal,  Griffith University, Australia
+ 29/7/2003
+ Latest updates 
+ (V2.0.1): 9/10/2003
+ (V2.0): 1/9/2003
+ 
+ 
+ 
+ Naming:
+ ======
+ Version 2 is almost a complete rewrite of the code (from 1 file up to 13 files). At the suggestion of Nathan Lovell the name was changed from StackCheck to StackedIt. 
+ The main reason for this is that the new name is more amusing.
+ 
+ Note:
+ =====
+ In this document method 1 refers to the way V1 of this program derived its traces. 
+ 
+ Changes in V2.0.1
+ =============
+ Bug fix related to very long function signatures.
+ 
+ 
+ Changes in V2.0
+ ============
+ A better method of getting traces has been added.
+ The output of method 1 has been modified. It now shows the location on the stack of the match and the name of the function.
+ 
+ 
+ What does it do?
+ ============
+ 	StackedIt will tell you which functions were called immediately before the crash. The accuracy of this trace depends on the method used to get the trace. The newer method is more accurate and "shouldn't" give any false positives unless it is told to. The older method is still available via command line arguments.
+ 
+ 
+ What doesn't it do?
+ ==============
+ 	StackedIt won't tell you what arguments were passed to those functions, or why the crash happened.
+ 	
+ Detail:
+ =====
+ 	Both methods make use of information from a dissassembly of the .nosnap.elf of the offending object. This dissassembly can be produced using the elp.pl tool or some other method.
+ 
+ New method:
+ 	Starting with the function where the crash occurred the stack usage of each function is determined and the relative location of the return address is found. From this info the previous function in the trace
+ is determined and the process repeats. Once this "trace" is completed any values in the stack that could be return addresses can also be checked. These other checks will produce false positives in most circumstances so the output of these extra traces is clearly indicated and can be controlled with command line arguements.
+ 
+ Old method: 
+ 	StackedIt will output any values in the stack dump section of EMON.LOG which fall in the range of addresses in the dissassembly of .nosnap.elf. Any values that fit this range are mapped to the name of the function that contains that address. Since in some cases the return address is stored on the stack when a call is made we can work out which function called this one. 
+ _Warning_: Not all values that appear on the stack are addresses so just because a value maps to a function doesn't mean that function is part of the "call trace".
+   
+ Preparation:
+ =============
+ To use StackedIt you will need:
+ * A compiled version of the tool. 'make' in the top directory for these tools will do it.
+ * EMON.LOG for the crash.  
+ * A file containing the diassassembly (with interleved source) of X.nosnap where X is the object that crashed.
+ * The runtime address of the crash (epc in EMON.LOG).
+ * The corresponding linktime address of the crash (the Programmer's guide describes how to find this value or use elp).
+ 
+ Usage:
+ ======
+ StackedIt [options] rt lt dis emon
+ Where:	[options] is a list of options starting with - or --help
+ 	* 1	Use method 1 to generate trace.
+ 	* 2	Use method 2 to generate trace.
+ 	* p 	Attempt to follow other traces.
+ 	* n	Only show names of functions not address data.
+ 
+ 	rt is the runtime address of the crash (epc from EMON.LOG).
+ 	lt is the link time address of the crash (calculated using the process described in the programmers guide).
+ 	dis is the disassembly of the object which crashed (see programmer's guide).
+ 	emon is your EMON.LOG file.
+ Note: The elp script will automate finding the above values.
+ 
+ Note: the addresses are expected to be in hex.
+ eg:
+ ./StackedIt 2260a884 40a884 disassembly.txt EMON.LOG
+ 
+ would produce output like:
+ 
+ Method 1 - simple matching:
+ In the stack
+ StackLoc Name
+ 22411354 GUObj::v32()
+ 22411374 GUObj::v31()
+ 22411394 GUObj::v30()
+ 224113b4 GUObj::v29()
+ 224113c0 void AlgUtil::QuickSortEx<BF_BLOB>(BF_BLOB*, int, int)
+ 224113d4 GUObj::v28()
+ 224113f4 GUObj::v27()
+ 224113f8 void AlgUtil::QuickSortEx<BF_BLOB>(BF_BLOB*, int, int)
+ 22411414 GUObj::v26()
+ 22411434 GUObj::v25()
+ 22411454 GUObj::v24()
+ 22411474 GUObj::v23()
+ 22411494 GUObj::v22()
+ 224114a0 void AlgUtil::QuickSortEx<BF_BLOB>(BF_BLOB*, int, int)
+ 224114b4 GUObj::v21()
+ 224114d4 GUObj::v20()
+ 224114f4 GUObj::v19()
+ 22411514 GUObj::v18()
+ 22411534 GUObj::v17()
+ 22411554 GUObj::v16()
+ 22411574 GUObj::v15()
+ 22411594 GUObj::v14()
+ 224115b4 GUObj::v13()
+ 224115d4 GUObj::v12()
+ 224115f4 GUObj::v11()
+ 22411614 GUObj::v10()
+ 22411634 GUObj::v9()
+ 22411654 GUObj::v8()
+ 22411674 GUObj::v6()
+ 22411694 GUObj::v5()
+ 224116b4 GUObj::v4()
+ 224116d4 GUObj::v3()
+ 224116f4 GUObj::v2()
+ 2241170c ConsistencyEngine::ProcessInput()
+ 22411714 GUObj::v1()
+ 22411734 GUObj::NewImage(ONotifyEvent const&)
+ 2241175c _Notify2
+ 22411764 _connectstub2
+ 224117bc _Ready0
+ 224117d4 _notifystub2
+ 224117dc _readystub0
+ 
+ 
+ Method 2 using return addresses:
+ Crash at 439cb8 = 22339cb8 in function GUObj::v7()
+ Frame    Name
+ 22411338 GUObj::v7()
+ 22411358 GUObj::v32()
+ 22411378 GUObj::v31()
+ 22411398 GUObj::v30()
+ 224113b8 GUObj::v29()
+ 224113d8 GUObj::v28()
+ 224113f8 GUObj::v27()
+ 22411418 GUObj::v26()
+ 22411438 GUObj::v25()
+ 22411458 GUObj::v24()
+ 22411478 GUObj::v23()
+ 22411498 GUObj::v22()
+ 224114b8 GUObj::v21()
+ 224114d8 GUObj::v20()
+ 224114f8 GUObj::v19()
+ 22411518 GUObj::v18()
+ 22411538 GUObj::v17()
+ 22411558 GUObj::v16()
+ 22411578 GUObj::v15()
+ 22411598 GUObj::v14()
+ 224115b8 GUObj::v13()
+ 224115d8 GUObj::v12()
+ 224115f8 GUObj::v11()
+ 22411618 GUObj::v10()
+ 22411638 GUObj::v9()
+ 22411658 GUObj::v8()
+ 22411678 GUObj::v6()
+ 22411698 GUObj::v5()
+ 224116b8 GUObj::v4()
+ 224116d8 GUObj::v3()
+ 224116f8 GUObj::v2()
+ 22411718 GUObj::v1()
+ 22411738 GUObj::NewImage(ONotifyEvent const&)
+ 22411760 _Notify2
+ 224117d8 _notifystub2
+ Dead end. This function doesn't store a return address
+ 
+ Other traces:
+ Frame    Name
+ 224113c4 void AlgUtil::QuickSortEx<BF_BLOB>(BF_BLOB*, int, int)
+ 224113f8 GUObj::v27()
+ Not a valid return address
+ ------
+ Frame    Name
+ 224113fc void AlgUtil::QuickSortEx<BF_BLOB>(BF_BLOB*, int, int)
+ Not a valid return address
+ ------
+ Frame    Name
+ 224114a4 void AlgUtil::QuickSortEx<BF_BLOB>(BF_BLOB*, int, int)
+ 224114d8 GUObj::v20()
+ Not a valid return address
+ ------
+ Frame    Name
+ 22411710 ConsistencyEngine::ProcessInput()
+ 22411738 GUObj::NewImage(ONotifyEvent const&)
+ 22411760 _Notify2
+ 224117d8 _notifystub2
+ Dead end. This function doesn't store a return address
+ ------
+ Frame    Name
+ 22411768 _connectstub2
+ Dead end. This function doesn't store a return address
+ ------
+ Frame    Name
+ 224117c0 _Ready0
+ 224117e0 _readystub0
+ Dead end. This function doesn't store a return address
+ ------
Index: AiboPup/tools/mipaltools/doc/license.txt
diff -c /dev/null AiboPup/tools/mipaltools/doc/license.txt:1.1
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/mipaltools/doc/license.txt	Wed Sep 10 15:21:58 2003
***************
*** 0 ****
--- 1,340 ----
+ 		    GNU GENERAL PUBLIC LICENSE
+ 		       Version 2, June 1991
+ 
+  Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                        59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+  Everyone is permitted to copy and distribute verbatim copies
+  of this license document, but changing it is not allowed.
+ 
+ 			    Preamble
+ 
+   The licenses for most software are designed to take away your
+ freedom to share and change it.  By contrast, the GNU General Public
+ License is intended to guarantee your freedom to share and change free
+ software--to make sure the software is free for all its users.  This
+ General Public License applies to most of the Free Software
+ Foundation's software and to any other program whose authors commit to
+ using it.  (Some other Free Software Foundation software is covered by
+ the GNU Library General Public License instead.)  You can apply it to
+ your programs, too.
+ 
+   When we speak of free software, we are referring to freedom, not
+ price.  Our General Public Licenses are designed to make sure that you
+ have the freedom to distribute copies of free software (and charge for
+ this service if you wish), that you receive source code or can get it
+ if you want it, that you can change the software or use pieces of it
+ in new free programs; and that you know you can do these things.
+ 
+   To protect your rights, we need to make restrictions that forbid
+ anyone to deny you these rights or to ask you to surrender the rights.
+ These restrictions translate to certain responsibilities for you if you
+ distribute copies of the software, or if you modify it.
+ 
+   For example, if you distribute copies of such a program, whether
+ gratis or for a fee, you must give the recipients all the rights that
+ you have.  You must make sure that they, too, receive or can get the
+ source code.  And you must show them these terms so they know their
+ rights.
+ 
+   We protect your rights with two steps: (1) copyright the software, and
+ (2) offer you this license which gives you legal permission to copy,
+ distribute and/or modify the software.
+ 
+   Also, for each author's protection and ours, we want to make certain
+ that everyone understands that there is no warranty for this free
+ software.  If the software is modified by someone else and passed on, we
+ want its recipients to know that what they have is not the original, so
+ that any problems introduced by others will not reflect on the original
+ authors' reputations.
+ 
+   Finally, any free program is threatened constantly by software
+ patents.  We wish to avoid the danger that redistributors of a free
+ program will individually obtain patent licenses, in effect making the
+ program proprietary.  To prevent this, we have made it clear that any
+ patent must be licensed for everyone's free use or not licensed at all.
+ 
+   The precise terms and conditions for copying, distribution and
+ modification follow.
+ 
+ 		    GNU GENERAL PUBLIC LICENSE
+    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+ 
+   0. This License applies to any program or other work which contains
+ a notice placed by the copyright holder saying it may be distributed
+ under the terms of this General Public License.  The "Program", below,
+ refers to any such program or work, and a "work based on the Program"
+ means either the Program or any derivative work under copyright law:
+ that is to say, a work containing the Program or a portion of it,
+ either verbatim or with modifications and/or translated into another
+ language.  (Hereinafter, translation is included without limitation in
+ the term "modification".)  Each licensee is addressed as "you".
+ 
+ Activities other than copying, distribution and modification are not
+ covered by this License; they are outside its scope.  The act of
+ running the Program is not restricted, and the output from the Program
+ is covered only if its contents constitute a work based on the
+ Program (independent of having been made by running the Program).
+ Whether that is true depends on what the Program does.
+ 
+   1. You may copy and distribute verbatim copies of the Program's
+ source code as you receive it, in any medium, provided that you
+ conspicuously and appropriately publish on each copy an appropriate
+ copyright notice and disclaimer of warranty; keep intact all the
+ notices that refer to this License and to the absence of any warranty;
+ and give any other recipients of the Program a copy of this License
+ along with the Program.
+ 
+ You may charge a fee for the physical act of transferring a copy, and
+ you may at your option offer warranty protection in exchange for a fee.
+ 
+   2. You may modify your copy or copies of the Program or any portion
+ of it, thus forming a work based on the Program, and copy and
+ distribute such modifications or work under the terms of Section 1
+ above, provided that you also meet all of these conditions:
+ 
+     a) You must cause the modified files to carry prominent notices
+     stating that you changed the files and the date of any change.
+ 
+     b) You must cause any work that you distribute or publish, that in
+     whole or in part contains or is derived from the Program or any
+     part thereof, to be licensed as a whole at no charge to all third
+     parties under the terms of this License.
+ 
+     c) If the modified program normally reads commands interactively
+     when run, you must cause it, when started running for such
+     interactive use in the most ordinary way, to print or display an
+     announcement including an appropriate copyright notice and a
+     notice that there is no warranty (or else, saying that you provide
+     a warranty) and that users may redistribute the program under
+     these conditions, and telling the user how to view a copy of this
+     License.  (Exception: if the Program itself is interactive but
+     does not normally print such an announcement, your work based on
+     the Program is not required to print an announcement.)
+ 
+ These requirements apply to the modified work as a whole.  If
+ identifiable sections of that work are not derived from the Program,
+ and can be reasonably considered independent and separate works in
+ themselves, then this License, and its terms, do not apply to those
+ sections when you distribute them as separate works.  But when you
+ distribute the same sections as part of a whole which is a work based
+ on the Program, the distribution of the whole must be on the terms of
+ this License, whose permissions for other licensees extend to the
+ entire whole, and thus to each and every part regardless of who wrote it.
+ 
+ Thus, it is not the intent of this section to claim rights or contest
+ your rights to work written entirely by you; rather, the intent is to
+ exercise the right to control the distribution of derivative or
+ collective works based on the Program.
+ 
+ In addition, mere aggregation of another work not based on the Program
+ with the Program (or with a work based on the Program) on a volume of
+ a storage or distribution medium does not bring the other work under
+ the scope of this License.
+ 
+   3. You may copy and distribute the Program (or a work based on it,
+ under Section 2) in object code or executable form under the terms of
+ Sections 1 and 2 above provided that you also do one of the following:
+ 
+     a) Accompany it with the complete corresponding machine-readable
+     source code, which must be distributed under the terms of Sections
+     1 and 2 above on a medium customarily used for software interchange; or,
+ 
+     b) Accompany it with a written offer, valid for at least three
+     years, to give any third party, for a charge no more than your
+     cost of physically performing source distribution, a complete
+     machine-readable copy of the corresponding source code, to be
+     distributed under the terms of Sections 1 and 2 above on a medium
+     customarily used for software interchange; or,
+ 
+     c) Accompany it with the information you received as to the offer
+     to distribute corresponding source code.  (This alternative is
+     allowed only for noncommercial distribution and only if you
+     received the program in object code or executable form with such
+     an offer, in accord with Subsection b above.)
+ 
+ The source code for a work means the preferred form of the work for
+ making modifications to it.  For an executable work, complete source
+ code means all the source code for all modules it contains, plus any
+ associated interface definition files, plus the scripts used to
+ control compilation and installation of the executable.  However, as a
+ special exception, the source code distributed need not include
+ anything that is normally distributed (in either source or binary
+ form) with the major components (compiler, kernel, and so on) of the
+ operating system on which the executable runs, unless that component
+ itself accompanies the executable.
+ 
+ If distribution of executable or object code is made by offering
+ access to copy from a designated place, then offering equivalent
+ access to copy the source code from the same place counts as
+ distribution of the source code, even though third parties are not
+ compelled to copy the source along with the object code.
+ 
+   4. You may not copy, modify, sublicense, or distribute the Program
+ except as expressly provided under this License.  Any attempt
+ otherwise to copy, modify, sublicense or distribute the Program is
+ void, and will automatically terminate your rights under this License.
+ However, parties who have received copies, or rights, from you under
+ this License will not have their licenses terminated so long as such
+ parties remain in full compliance.
+ 
+   5. You are not required to accept this License, since you have not
+ signed it.  However, nothing else grants you permission to modify or
+ distribute the Program or its derivative works.  These actions are
+ prohibited by law if you do not accept this License.  Therefore, by
+ modifying or distributing the Program (or any work based on the
+ Program), you indicate your acceptance of this License to do so, and
+ all its terms and conditions for copying, distributing or modifying
+ the Program or works based on it.
+ 
+   6. Each time you redistribute the Program (or any work based on the
+ Program), the recipient automatically receives a license from the
+ original licensor to copy, distribute or modify the Program subject to
+ these terms and conditions.  You may not impose any further
+ restrictions on the recipients' exercise of the rights granted herein.
+ You are not responsible for enforcing compliance by third parties to
+ this License.
+ 
+   7. If, as a consequence of a court judgment or allegation of patent
+ infringement or for any other reason (not limited to patent issues),
+ conditions are imposed on you (whether by court order, agreement or
+ otherwise) that contradict the conditions of this License, they do not
+ excuse you from the conditions of this License.  If you cannot
+ distribute so as to satisfy simultaneously your obligations under this
+ License and any other pertinent obligations, then as a consequence you
+ may not distribute the Program at all.  For example, if a patent
+ license would not permit royalty-free redistribution of the Program by
+ all those who receive copies directly or indirectly through you, then
+ the only way you could satisfy both it and this License would be to
+ refrain entirely from distribution of the Program.
+ 
+ If any portion of this section is held invalid or unenforceable under
+ any particular circumstance, the balance of the section is intended to
+ apply and the section as a whole is intended to apply in other
+ circumstances.
+ 
+ It is not the purpose of this section to induce you to infringe any
+ patents or other property right claims or to contest validity of any
+ such claims; this section has the sole purpose of protecting the
+ integrity of the free software distribution system, which is
+ implemented by public license practices.  Many people have made
+ generous contributions to the wide range of software distributed
+ through that system in reliance on consistent application of that
+ system; it is up to the author/donor to decide if he or she is willing
+ to distribute software through any other system and a licensee cannot
+ impose that choice.
+ 
+ This section is intended to make thoroughly clear what is believed to
+ be a consequence of the rest of this License.
+ 
+   8. If the distribution and/or use of the Program is restricted in
+ certain countries either by patents or by copyrighted interfaces, the
+ original copyright holder who places the Program under this License
+ may add an explicit geographical distribution limitation excluding
+ those countries, so that distribution is permitted only in or among
+ countries not thus excluded.  In such case, this License incorporates
+ the limitation as if written in the body of this License.
+ 
+   9. The Free Software Foundation may publish revised and/or new versions
+ of the General Public License from time to time.  Such new versions will
+ be similar in spirit to the present version, but may differ in detail to
+ address new problems or concerns.
+ 
+ Each version is given a distinguishing version number.  If the Program
+ specifies a version number of this License which applies to it and "any
+ later version", you have the option of following the terms and conditions
+ either of that version or of any later version published by the Free
+ Software Foundation.  If the Program does not specify a version number of
+ this License, you may choose any version ever published by the Free Software
+ Foundation.
+ 
+   10. If you wish to incorporate parts of the Program into other free
+ programs whose distribution conditions are different, write to the author
+ to ask for permission.  For software which is copyrighted by the Free
+ Software Foundation, write to the Free Software Foundation; we sometimes
+ make exceptions for this.  Our decision will be guided by the two goals
+ of preserving the free status of all derivatives of our free software and
+ of promoting the sharing and reuse of software generally.
+ 
+ 			    NO WARRANTY
+ 
+   11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+ REPAIR OR CORRECTION.
+ 
+   12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGES.
+ 
+ 		     END OF TERMS AND CONDITIONS
+ 
+ 	    How to Apply These Terms to Your New Programs
+ 
+   If you develop a new program, and you want it to be of the greatest
+ possible use to the public, the best way to achieve this is to make it
+ free software which everyone can redistribute and change under these terms.
+ 
+   To do so, attach the following notices to the program.  It is safest
+ to attach them to the start of each source file to most effectively
+ convey the exclusion of warranty; and each file should have at least
+ the "copyright" line and a pointer to where the full notice is found.
+ 
+     <one line to give the program's name and a brief idea of what it does.>
+     Copyright (C) <year>  <name of author>
+ 
+     This program is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published by
+     the Free Software Foundation; either version 2 of the License, or
+     (at your option) any later version.
+ 
+     This program is distributed in the hope that it will be useful,
+     but WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+     GNU General Public License for more details.
+ 
+     You should have received a copy of the GNU General Public License
+     along with this program; if not, write to the Free Software
+     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ 
+ 
+ Also add information on how to contact you by electronic and paper mail.
+ 
+ If the program is interactive, make it output a short notice like this
+ when it starts in an interactive mode:
+ 
+     Gnomovision version 69, Copyright (C) year name of author
+     Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+     This is free software, and you are welcome to redistribute it
+     under certain conditions; type `show c' for details.
+ 
+ The hypothetical commands `show w' and `show c' should show the appropriate
+ parts of the General Public License.  Of course, the commands you use may
+ be called something other than `show w' and `show c'; they could even be
+ mouse-clicks or menu items--whatever suits your program.
+ 
+ You should also get your employer (if you work as a programmer) or your
+ school, if any, to sign a "copyright disclaimer" for the program, if
+ necessary.  Here is a sample; alter the names:
+ 
+   Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+   `Gnomovision' (which makes passes at compilers) written by James Hacker.
+ 
+   <signature of Ty Coon>, 1 April 1989
+   Ty Coon, President of Vice
+ 
+ This General Public License does not permit incorporating your program into
+ proprietary programs.  If your program is a subroutine library, you may
+ consider it more useful to permit linking proprietary applications with the
+ library.  If this is what you want to do, use the GNU Library General
+ Public License instead of this License.
Index: AiboPup/tools/mipaltools/src/EmonLog.cc
diff -c /dev/null AiboPup/tools/mipaltools/src/EmonLog.cc:1.1
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/mipaltools/src/EmonLog.cc	Wed Sep 10 15:22:01 2003
***************
*** 0 ****
--- 1,67 ----
+ // -----------------------------------------------------------------------------
+ // File: EmonLog.cc
+ // Date: 28/8/2003
+ // Part of StackedIt V2.0
+ // By: Joel Fenwick, Mi-Pal, Griffith University
+ //
+ // This program is copyrighted to the author and released under the GPL (V2.0).
+ // There is no warantee associated with this code. Especially not for use
+ // in nuclear plants, aircraft control systems or hedgehogs. Use at your
+ // own risk.
+ // See license.txt for details
+ // -----------------------------------------------------------------------------
+ 
+ #include "EmonLog.h"
+ #include "StackAnalyserException.h"
+ #include <cstring>
+ using namespace std;
+ 
+ EmonLog::EmonLog(istream& is)   throw (StackAnalyserException)
+ {
+ 	stack=0;
+ 	ra=0;
+ 	ReadRegisters(is);
+ 	if (!FindStack(is))
+ 	{
+ 		throw StackAnalyserException("Unable to find [stack info].");
+ 	}
+ 	stack=new StackDump(is);
+ }
+ 
+ EmonLog::~EmonLog()
+ {
+ 	delete stack;
+ }
+ 
+ // get values for any registers we'll need later
+ void EmonLog::ReadRegisters(istream& is)
+ {
+ 	char buffer[200];
+ 	while (is.getline(buffer,200),cin.good())
+ 	{
+ 		if (buffer[0]=='\0')
+ 		{
+ 			// unable to find the value of ra
+ 			break;
+ 		}
+ 		if (strncmp(buffer," ra:r31: 0x",11)==0)
+ 		{
+ 			ra=static_cast<unsigned int>(strtoul(buffer+11,0,16));
+ 			break;
+ 		}
+ 	}
+ }
+ 
+ // Scan through an EMON file looking for the start of the stack
+ bool EmonLog::FindStack(istream& is)
+ {
+ 	char buffer[200];
+ 	while (is.getline(buffer,200),is.good())
+ 	{
+ 		if (strncmp(buffer,"[stack info]",11)==0)
+ 		{
+ 			return true;
+ 		}
+ 	}
+ 	return false;
+ }
Index: AiboPup/tools/mipaltools/src/EmonLog.h
diff -c /dev/null AiboPup/tools/mipaltools/src/EmonLog.h:1.1
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/mipaltools/src/EmonLog.h	Wed Sep 10 15:22:01 2003
***************
*** 0 ****
--- 1,36 ----
+ // -----------------------------------------------------------------------------
+ // File: EmonLog.h
+ // Date: 28/8/2003
+ // Part of StackedIt V2.0
+ // By: Joel Fenwick, Mi-Pal, Griffith University
+ //
+ // This program is copyrighted to the author and released under the GPL (V2.0).
+ // There is no warantee associated with this code. Especially not for use
+ // in nuclear plants, aircraft control systems or hedgehogs. Use at your
+ // own risk.
+ // See license.txt for details
+ // -----------------------------------------------------------------------------
+ 
+ #ifndef EMONLOG_H
+ #define EMONLOG_H
+ #include <iostream>
+ #include "StackDump.h" 
+ 
+ // class to encapsulate all information gathered from an EMON.LOG file
+ class EmonLog
+ {
+ public:
+ 	EmonLog(std::istream& is) throw (StackAnalyserException);
+ 	~EmonLog();
+ 	StackDump* GetStackDump(){return stack;}
+ 	unsigned int GetRegister_ra(){return ra;}		
+ private:
+ 	StackDump* stack;
+ 	void ReadRegisters(std::istream& is);	
+ 	bool FindStack(std::istream& is);	// move stream pointer to start 
+ 									//of stack dump
+ 	unsigned int ra;	// value of the ra register
+ };
+ 
+ 
+ #endif	// EMONLOG_H
Index: AiboPup/tools/mipaltools/src/Function.cc
diff -c /dev/null AiboPup/tools/mipaltools/src/Function.cc:1.1
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/mipaltools/src/Function.cc	Wed Sep 10 15:22:01 2003
***************
*** 0 ****
--- 1,105 ----
+ // -----------------------------------------------------------------------------
+ // File: Function.cc
+ // Date: 28/8/2003
+ // Part of StackedIt V2.0
+ // By: Joel Fenwick, Mi-Pal, Griffith University
+ //
+ // This program is copyrighted to the author and released under the GPL (V2.0).
+ // There is no warantee associated with this code. Especially not for use
+ // in nuclear plants, aircraft control systems or hedgehogs. Use at your
+ // own risk.
+ // See license.txt for details
+ // -----------------------------------------------------------------------------
+ 
+ #include "Function.h"
+ #include <cstring>
+ #include <cstdlib>
+ #include <cstdio>	// Not so happy about this but sscanf is just too useful
+ 
+ // Extract name and starting address from the line
+ // line must be in the following form
+ // 00address <name>:
+ Function::Function(char* line)
+ {
+ 	haveretoffset=false;
+ 	stacksize=0;
+ 	retoffset=0;
+ 	start=0;
+ 	linecount=0;
+ 	int ln=strlen(line);			// had a lot of trouble with the string manip here
+ 	name=new char[ln-11];			// may need to be tuned
+ 	start=strtol((line+2),0,16);
+ 	strncpy(name,line+10,ln-13);		// remove >: from the line
+ 	name[ln-13]='\0';	
+ }
+ 
+ Function::~Function()
+ {
+ 	delete name;
+ }
+ 
+ // This test isn't rigourous at the moment. I haven't tested whether it is always possible to 
+ // differentiate between source and function headers anyway
+ bool Function::IsHeader(char* line)
+ {
+ 	// first two chars on the line must be 00
+ 	if ((line==0) || (line[0]=='\0') || (line[1]=='\0') || (line[0]!='0') || (line[1]!='0'))
+ 	{
+ 		return false;
+ 	}
+ 	return true;
+ }
+ 
+ // Return true if the line has been processed
+ bool Function::Process(char* line)
+ {
+ 	// Assumptions based on number of lines into the function can be thrown off by source
+ 	// inclusions
+ 	linecount++;			// line count should be the number of lines of assembly
+ 
+ 	// normally the stack size would occur 4 lines into the function if at all
+ 	// however source code interleaving may cause problems here
+ 	if ((stacksize==0) && (linecount>=4))
+ 	{
+ 		stacksize=GetStackSize(line);
+ 		// Assuming there are no other stack allocations
+ 	}
+ 	if ((retoffset==0) && (stacksize!=0))
+ 	{
+ 		retoffset=GetRetOffset(line);
+ 		if (retoffset!=0)
+ 		{
+ 			haveretoffset=true;
+ 		}
+ 	}
+ 	return true;
+ }
+ 
+ // Attempt to find the size of the stackframe from this line
+ //  4000fc:       27bdffd0        addiu   sp,sp,-48
+ unsigned int Function::GetStackSize(char* line)
+ {
+ 	unsigned int size=0;
+ 	// This could have been done more quickly with array indexes but this is clearer
+ 	// I'm pretty sure that the parameter of this is in deciaml not hex (since $32 is not a multiple of 4)
+ 	if (sscanf(line,"%*s %*s addiu sp,sp,-%u",&size)==1)
+ 	{
+ 		return size;
+ 	}
+ 	return 0;
+ }
+ 
+ // attempt to find the offset where the return address is stored
+ // return 0 if not found.
+ // This code assumes that the offset is never 0
+ unsigned int Function::GetRetOffset(char* line)
+ {
+ 	unsigned int offset=0;
+ 	char reg[3];
+ 	if ((sscanf(line,"%*s %*s sw ra,%u(%2s)",&offset,reg)==2) 
+ 			&& (strcmp(reg,"sp")==0))
+ 	{
+ 		return offset;
+ 	}
+ 	return 0;
+ }
Index: AiboPup/tools/mipaltools/src/Function.h
diff -c /dev/null AiboPup/tools/mipaltools/src/Function.h:1.1
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/mipaltools/src/Function.h	Wed Sep 10 15:22:01 2003
***************
*** 0 ****
--- 1,46 ----
+ // -----------------------------------------------------------------------------
+ // File: Function.h
+ // Date: 28/8/2003
+ // Part of StackedIt V2.0
+ // By: Joel Fenwick, Mi-Pal, Griffith University
+ //
+ // This program is copyrighted to the author and released under the GPL (V2.0).
+ // There is no warantee associated with this code. Especially not for use
+ // in nuclear plants, aircraft control systems or hedgehogs. Use at your
+ // own risk.
+ // See license.txt for details
+ // -----------------------------------------------------------------------------
+ 
+ #ifndef FUNCTION_H
+ #define FUNCTION_H
+ 
+ // class to encapsulate all data about a single function from a dissassembly
+ class Function
+ {
+ public:
+ 	Function(char* line);		// line contains the function header
+ 	~Function();
+ 	bool Process(char* c);		// process another line of dissassembly
+ 	char* name;
+ 	unsigned int stacksize;
+ 	unsigned int retoffset;			// location in the function where return addr is stored
+ 	unsigned int start;		// the start address of this function
+ 	static bool IsHeader(char* line);	// Does this line represent a function header
+ 	bool HaveRetOffset(){return haveretoffset;}	// maybe should have a better
+ private:
+ 	int linecount;
+ 	bool haveretoffset;	// do we have a return address offset in the "frame" yet
+ 
+ 	// return size of stack "frame" allocated by this line
+ 	// 0 if not an allocation line
+ 	unsigned int GetStackSize(char* line);
+ 	
+ 	// read the offset in the frame where the return address is stored
+ 	// 0 if not a relevant line
+ 	// This assumes that the offset will always be >0 
+ 	// One day I might fix this but it seems ok for now
+ 	unsigned int GetRetOffset(char* line);	
+ };
+ 
+ 
+ #endif //FUNCTION_H
Index: AiboPup/tools/mipaltools/src/FunctionStore.cc
diff -c /dev/null AiboPup/tools/mipaltools/src/FunctionStore.cc:1.3
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/mipaltools/src/FunctionStore.cc	Thu Oct  9 11:29:24 2003
***************
*** 0 ****
--- 1,162 ----
+ //-------------------------------------------------------------------------------------
+ // File: FunctionStore.cc
+ // Date: 28/8/2003
+ // Part of StackedIt V2.0
+ // By: Joel Fenwick, Mi-Pal, Griffith University
+ //
+ // This program is copyrighted to the author and released under the GPL (V2.0).
+ // There is no warantee associated with this code. Especially not for use
+ // in nuclear plants, aircraft control systems or hedgehogs. Use at your
+ // own risk.
+ // See license.txt for details
+ // ------------------------------------------------------------------------------------
+ // Updated 9/9/2003 (EST - this is actually *later* than the one below ;) - Increased bsize even more, just in case - ejt
+ // Updated 9/10/2003 for StackedIt V2.0.1 - bug related to getline
+ //-------------------------------------------------------------------------------------
+ #include "FunctionStore.h"
+ 
+ using namespace std;
+ 
+ FunctionStore::FunctionStore()
+ {
+ 	fp=0;
+ }
+ 
+ 
+ //Design note: I may change this to use the string function later. The advantage of 
+ //this is that a very large line won't fill memory
+ 
+ // reads at most maxlen chars (including end of string) from a line
+ // if the end of line is not reached in maxlen chars characters up to the end of line
+ // are silently consumed. (Both \n and \r count as end-of-line chars).
+ void SafeGetline(istream& is,char* buffer, int maxlen)
+ {
+ 	char c;
+ 	int i=0;
+ 	for (c=is.get();(i<maxlen-1) && is.good() && (c!='\r') && (c!='\n');i++,c=is.get())
+ 	{
+ 		buffer[i]=c;
+ 	}
+ 	buffer[i]='\0';
+ 	while (is.good() && (c!='\r') && (c!='\n'))
+ 	{
+ 		c=is.get();
+ 	}
+ }
+ 
+ 
+ 
+ FunctionStore::FunctionStore(istream& is)
+ {
+ 	const int bsize=2048;
+ 	fp=0;
+ 	char buffer[bsize];		
+ 	while (SafeGetline(is, buffer, bsize),is.good())
+ 	{
+ 		Process(buffer);
+ 	}
+ }
+ 
+ 
+ FunctionStore::~FunctionStore()
+ {
+ 	for (vector<Function*>::iterator i=fns.begin();i!=fns.end();++i)
+ 	{
+ 		delete *i;
+ 	}
+ }
+ 
+ // process a line of dissassembly
+ void FunctionStore::Process(char* line)
+ {
+ 	if (Function::IsHeader(line))
+ 	{
+ 		fp=new Function(line);
+ 		fns.push_back(fp);	
+ 	}
+ 	else if (fp!=0)
+ 	{
+ 		if (!fp->Process(line))
+ 		{
+ 			// Not sure why the function would return false at this point
+ 			// Maybe it shouldn't return anything???
+ 		}
+ 	}
+ }
+ 
+ // Return the function which contains the address
+ // This assumes that everything that appears between the heading of A and the heading of B
+ // belongs to A. This may not be a good assumption
+ Function* FunctionStore::ContainsAddress(unsigned int addr)
+ {
+ 	int index=BinarySearch(0,fns.size()-1, addr);
+ 	if (index==-1)
+ 	{
+ 		return 0;
+ 	}
+ 	return fns[index];
+ }
+ 
+ // find an index x such that val comes after [x] but before [x+1] if it
+ // exists (return -1 on failure)
+ // This function is a bit hard to read because 'start' refers to the start address of the
+ // function not the 'begin'ing of the search range
+ int FunctionStore::BinarySearch(int begin, int end, unsigned int val)
+ {
+ 	if (begin>end)
+ 	{
+ 		return -1;
+ 	}
+ 	if (fns[begin]->start==val)
+ 	{
+ 		return begin;
+ 	}
+ 	if (begin==end)
+ 	{
+ 		return -1;		//since val!=[begin]
+ 	}
+ 	if (fns[begin]->start>val)
+ 	{
+ 		return -1;
+ 	}
+ 	if (fns[end]->start<=val)
+ 	{
+ 		return end;
+ 	}
+ 	if ((end-begin==1) && (fns[end]->start>val))
+ 	{
+ 		return begin;		
+ 	}
+ 	if (fns[(begin+end)/2]->start<val)
+ 	{
+ 		return BinarySearch((begin+end)/2,end,val);
+ 	}
+ 	else
+ 	{
+ 		return BinarySearch(begin,(begin+end)/2,val);
+ 	}
+ }
+ 
+ // return the range of addresses covered by functions in this store
+ void FunctionStore::GetAddressRange(unsigned int& lower, unsigned int& upper)
+ {
+ 	if (fns.size()==0)
+ 	{
+ 		lower=0;
+ 		upper=0;
+ 	}
+ 	else
+ 	{
+ 		lower=fns[0]->start;
+ 		upper=fns[fns.size()-1]->start;	// since the last function is .fini this is good enough
+ 	}
+ }
+ 
+ // For debug only 
+ void FunctionStore::Dump(ostream& os)
+ {
+ 	for (vector<Function*>::iterator i=fns.begin();i!=fns.end();++i)
+ 	{
+ 		os << hex <<(*i)->start << " " << (*i)->name << " " << (*i)->stacksize << endl;
+ 	}
+ }
Index: AiboPup/tools/mipaltools/src/FunctionStore.h
diff -c /dev/null AiboPup/tools/mipaltools/src/FunctionStore.h:1.1
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/mipaltools/src/FunctionStore.h	Wed Sep 10 15:22:02 2003
***************
*** 0 ****
--- 1,39 ----
+ // -----------------------------------------------------------------------------
+ // File: FunctionStore.h
+ // Date: 28/8/2003
+ // Part of StackedIt V2.0
+ // By: Joel Fenwick, Mi-Pal, Griffith University
+ //
+ // This program is copyrighted to the author and released under the GPL (V2.0).
+ // There is no warantee associated with this code. Especially not for use
+ // in nuclear plants, aircraft control systems or hedgehogs. Use at your
+ // own risk.
+ // See license.txt for details
+ // -----------------------------------------------------------------------------
+ 
+ #ifndef FUNCTION_STORE_H
+ #define FUNCTION_STORE_H
+ 
+ #include "Function.h"
+ #include <vector>
+ #include <iostream>
+ class FunctionStore
+ {
+ public:
+ 	FunctionStore();
+ 	FunctionStore(std::istream& is);	// functions must be in increasing address order
+ 	~FunctionStore();
+ 	Function* ContainsAddress(unsigned int addr);
+ 	void GetAddressRange(unsigned int& lower, unsigned int& upper);
+ 	inline int FunctionCount(){return fns.size();}
+ 	void Dump(std::ostream& os);
+ 	
+ private:
+ 	std::vector<Function*> fns;
+ 	Function* fp;				// current function
+ 
+ 	int BinarySearch(int begin, int end, unsigned int val);
+ 	void Process(char* line);		// Process this line of dissassembly
+ };
+ 
+ #endif	// FUNCTION_STORE_H
Index: AiboPup/tools/mipaltools/src/Makefile
diff -c /dev/null AiboPup/tools/mipaltools/src/Makefile:1.2
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/mipaltools/src/Makefile	Fri Sep 12 12:24:51 2003
***************
*** 0 ****
--- 1,23 ----
+ all: EmonLog.o  Function.o  FunctionStore.o  StackAnalyser.o  StackDump.o  main.o
+ 	g++ -o ../StackedIt EmonLog.o  Function.o  FunctionStore.o  StackAnalyser.o  StackDump.o  main.o 
+ 
+ Function.o: Function.cc Function.h
+ 	g++ -c   Function.cc
+ 
+ FunctionStore.o: FunctionStore.cc FunctionStore.h Function.h 
+ 	g++ -c   FunctionStore.cc
+ 
+ StackAnalyser.o: StackAnalyser.cc StackAnalyser.h StackDump.h FunctionStore.h Function.h Trace.h
+ 	g++ -c   StackAnalyser.cc
+ 
+ StackDump.o: StackDump.cc StackDump.h 
+ 	g++ -c   StackDump.cc
+ 
+ main.o: main.cc StackDump.h FunctionStore.h Function.h StackAnalyser.h
+ 	g++ -c   main.cc
+ 
+ EmonLog.o:	EmonLog.h EmonLog.cc
+ 	g++ -c   EmonLog.cc
+ 
+ clean:
+ 	rm -f *.o ../StackedIt ../StackedIt.exe
Index: AiboPup/tools/mipaltools/src/StackAnalyser.cc
diff -c /dev/null AiboPup/tools/mipaltools/src/StackAnalyser.cc:1.1
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/mipaltools/src/StackAnalyser.cc	Wed Sep 10 15:22:02 2003
***************
*** 0 ****
--- 1,339 ----
+ // -----------------------------------------------------------------------------
+ // File: StackAnalyser.cc
+ // Date: 28/8/2003
+ // Part of StackedIt V2.0
+ // By: Joel Fenwick, Mi-Pal, Griffith University
+ //
+ // This program is copyrighted to the author and released under the GPL (V2.0).
+ // There is no warantee associated with this code. Especially not for use
+ // in nuclear plants, aircraft control systems or hedgehogs. Use at your
+ // own risk.
+ // See license.txt for details
+ // -----------------------------------------------------------------------------
+ 
+ #include "StackAnalyser.h"
+ #include <iostream>
+ using namespace std;
+ 
+ StackAnalyser::StackAnalyser(istream& emondata, istream& functiondata, 
+ 		unsigned int runtimeoffset) 
+ 	throw (StackAnalyserException)
+ {
+ 	emon=new EmonLog(emondata);	// throw StackAnalyserException
+ 	stack=emon->GetStackDump();
+ 	fns=new FunctionStore(functiondata);
+ 	if (fns->FunctionCount()==0)
+ 	{
+ 		throw StackAnalyserException("No function headers found in data.");
+ 	}
+ 	offset=runtimeoffset;
+ }
+ 
+ StackAnalyser::~StackAnalyser()
+ {
+ 	if (stack!=0)
+ 	{
+ 		delete stack;
+ 	}
+ 	if (fns!=0)
+ 	{
+ 		delete fns;
+ 	}
+ }
+ 
+ // Scan through an EMON file looking for the start of the stack
+ bool StackAnalyser::FindStack(istream& is)
+ {
+ 	char buffer[200];
+ 	while (is.getline(buffer,200),is.good())
+ 	{
+ 		if (strncmp(buffer,"[stack info]",11)==0)
+ 		{
+ 			return true;
+ 		}
+ 	}
+ 	return false;
+ }
+ 
+ // return enough 0s to padd a hex number to 8 digits
+ char* Padding(unsigned int i)
+ {
+ 	if (i<0x10)
+ 	{
+ 		return "0000000";
+ 	}
+ 	if (i<0x100)
+ 	{
+ 		return "000000";
+ 	}
+ 	if (i<0x1000)
+ 	{
+ 		return "00000";
+ 	}	
+ 	if (i<0x10000)
+ 	{
+ 		return "0000";
+ 	}
+ 	if (i<0x100000)
+ 	{
+ 		return "000";
+ 	}
+ 	if (i<0x1000000)
+ 	{
+ 		return "00";
+ 	}
+ 	if (i<0x10000000)
+ 	{
+ 		return "0";
+ 	}
+ 	return "";
+ }
+ 
+ // populates list with addresses in the stack which store potential functions
+ // "locations" stores locations in the stack proper while above stack stores locations
+ // between llimit and top of stack
+ void StackAnalyser::FindMatches(list<FunctionOnStack>& locations, list<FunctionOnStack>& abovestack)
+ {
+ 	unsigned int lower=0;
+ 	unsigned int upper=0;
+ 	fns->GetAddressRange(lower,upper);
+ 	lower+=offset;
+ 	upper+=offset;
+ 	
+ 	// check for useful data past the top of the stack
+ 	for (unsigned int i=stack->GetLLimit();i<stack->GetTop();i+=4)
+ 	{
+ 		unsigned int data=(*stack)[i];
+ 		if ((data>=lower) && (data<upper))
+ 		{
+ 			Function* fp=fns->ContainsAddress(data-offset);
+ 			if (fp!=0)
+ 			{
+ 				FunctionOnStack fos(i,fp);
+ 				abovestack.push_back(fos);
+ 			}
+ 		}
+ 	}
+ 	for (unsigned int i=stack->GetTop();i<=stack->GetULimit();i+=4)
+ 	{
+ 		unsigned int data=(*stack)[i];
+ 		if ((data>=lower) && (data<upper))
+ 		{
+ 			Function* fp=fns->ContainsAddress(data-offset);
+ 			if (fp!=0)
+ 			{
+ 				FunctionOnStack fos(i,fp);
+ 				locations.push_back(fos);
+ 			}
+ 		}	
+ 	}
+ }
+ 
+ // Returns the names of any addresses in the stack that match functions
+ // if shownumbers is false only the names of the functions are displayed
+ void StackAnalyser::SimpleCheck(ostream& os, bool shownumbers)
+ {
+ 	list<FunctionOnStack> instack, abovestack;
+ 	FindMatches(instack,abovestack);
+ 	if (abovestack.size() >0)
+ 	{
+ 		os << "Above the stack\n";
+ 		SimpleCheckDriver(abovestack, os,shownumbers);
+ 		os << endl;
+ 	}
+ 	if (instack.size()>0)
+ 	{
+ 		os << "In the stack\n";
+ 		SimpleCheckDriver(instack, os,shownumbers);
+ 		os << endl;
+ 	}
+ }
+ 
+ // Outputs results for SimpleCheck
+ void StackAnalyser::SimpleCheckDriver(list<FunctionOnStack>& fos, ostream& os, bool shownumbers)
+ {
+ 	if (shownumbers)
+ 	{
+ 		os << "StackLoc Name\n";
+ 	}
+ 	else
+ 	{
+ 		os << "Name\n";
+ 	}
+ 	for (list<FunctionOnStack>::iterator i=fos.begin();i!=fos.end();++i)
+ 	{
+ 		if (shownumbers)
+ 		{
+ 			os << hex << Padding((*i).GetAddress()) << (*i).GetAddress() << ' ';	// address on stack
+ 		}
+ 		os << (*i).GetFunction()->name << endl;
+ 	}
+ }
+ 
+ // start at this point in the stack for this function and trace back
+ void StackAnalyser::TraceBack(Trace& tr,  unsigned int stacklocation, Function* f)
+ {
+ 	unsigned int retlocation=stacklocation+f->retoffset;	// where is the return address stored
+ 	unsigned int lower,upper;
+ 	
+ 	fns->GetAddressRange(lower, upper);
+ 	if (!f->HaveRetOffset())
+ 	{
+ 		tr.reason="Dead end. This function doesn't store a return address";
+ 		return;
+ 	}
+ 	if (f->stacksize==0)
+ 	{
+ 		tr.reason="Dead end. This function has no stack frame";	
+ 		return;
+ 	}
+ 
+ 	// sanity check the address
+ 	if (retlocation>stack->GetULimit())
+ 	{
+ 		tr.reason="Frame extends beyond visible region";
+ 		return;
+ 	}
+ 	if (!stack->IsValid(retlocation))
+ 	{
+ 		tr.reason="Return address lies in a forbidden zone";
+ 		return;
+ 	}
+ 	unsigned int retaddress=(*stack)[retlocation];
+ 	if ((retaddress<offset) || (retaddress-offset<lower) || (retaddress-offset>upper))
+ 	{
+ 		tr.reason="Not a valid return address";
+ 		return;
+ 	}
+ 	Function* f2=fns->ContainsAddress(retaddress-offset);
+ 	if (f2==0)
+ 	{
+ 		tr.reason="Unable to match function to return address";
+ 		return;
+ 	}
+ 	// Add function f2 to the trace
+ 	FunctionOnStack fos(retlocation,f2);	
+ 	tr.fns.push_back(fos);	
+ 	TraceBack(tr, stacklocation+f->stacksize,f2);
+ }
+ 
+ // attempt restart determines whether to try any other traces after the main one ends
+ void StackAnalyser::Filtering(ostream& os, unsigned int crashaddress, bool attemptrestart, bool shownumbers)
+ {
+ 	Trace tr;
+ 	Function* f=fns->ContainsAddress(crashaddress);
+ 	if (f==0)
+ 	{
+ 		os << "Error: Can't find a function containing address " << hex << crashaddress << endl;
+ 		return;
+ 	}
+ 	os << "Crash at " << crashaddress << " = " << crashaddress+offset << " in function ";
+ 	os << f->name << endl;
+ 	list<FunctionOnStack> instack, abovestack;
+ 	FindMatches(instack,abovestack);
+ 	tr.fns.push_back(FunctionOnStack(/*0*/stack->GetTop()-4,f));	// to make sure the frame starts at the top of the stack	
+ 	if ((f->stacksize!=0) && (f->HaveRetOffset()))	// the crash function saved ra to then stack
+ 	{
+ 		TraceBack(tr,stack->GetTop(),f);
+ 	}
+ 	else
+ 	{	// try to get the return address from the ra register
+ 		if ((emon->GetRegister_ra()!=0) 	
+ 			&& (emon->GetRegister_ra()>=offset))
+ 		{
+ 			Function* raf=fns->ContainsAddress(emon->GetRegister_ra()-offset);
+ 			if (raf!=0)
+ 			{
+ 				tr.fns.push_back(FunctionOnStack(/*0*/stack->GetTop()-4,raf));		
+ 				TraceBack(tr,stack->GetTop()+f->stacksize,raf);
+ 			}
+ 			else
+ 			{
+ 				// ra doesn't contain a valid address
+ 			}
+ 		}
+ 		else
+ 		{
+ 			os << "Error: attempted to use ra register but it contained the invalid value " <<hex << emon->GetRegister_ra() <<  endl;
+ 		}
+ 	}
+ 	if (!tr.fns.empty())
+ 	{	// display the functions in the trace
+ 		ShowFilterTrace(os,tr,shownumbers);
+ 		for (list<FunctionOnStack>::iterator i=tr.fns.begin();i!=tr.fns.end();++i)
+ 		{
+ 			instack.remove((*i));
+ 		}
+ 	}
+ 	os << endl;
+ 	if (attemptrestart)
+ 	{
+ 		// looks at any matches on the stack that weren't picked as part of the initial trace.
+ 		// This could be because they are wrong or because the trace was interrupted.
+ 		// In this second case using this option may allow you to pick up the trace again
+ 		// at the price of some false positives
+ 		// This method isn't overly smart. It assumes that the return address is stored in the
+ 		// last address of the stack frame. Which isn't a good assumption at all.
+ 		
+ 		list<Trace*> tr2;
+ 		while (!instack.empty())
+ 		{
+ 			list<FunctionOnStack>::iterator i=instack.begin();
+ 			Trace* trp=new Trace();
+ 			trp->fns.push_back(*i);
+ 			TraceBack(*trp,(*i).GetAddress()+4,(*i).GetFunction());
+ 			tr2.push_back(trp);
+ 			// Remove items that appear in the trace
+ 			for (list<FunctionOnStack>::iterator i=trp->fns.begin();i!=trp->fns.end();++i)
+ 			{
+ 				instack.remove((*i));
+ 			}
+ 		}
+ 		os << "Other traces:\n";
+ 		if (tr2.empty())
+ 		{
+ 			os << "None\n";
+ 		}
+ 		else
+ 		{
+ 			for (list<Trace*>::iterator j=tr2.begin();j!=tr2.end();++j)
+ 			{
+ 				ShowFilterTrace(os, *(*j), shownumbers);
+ 				os << "------" << endl;	
+ 			}
+ 		}  // !tr2.isEmpty()
+ 	}	// attemptrestart
+ }
+ 
+ // Displays a trace generated by filter
+ // shownumbers determines whether data is displayed for each function or just its name
+ void StackAnalyser::ShowFilterTrace(ostream& os, Trace& tr, bool shownumbers)
+ {
+ 	if (shownumbers)
+ 	{
+ 		os << "Frame    Name\n";
+ 	}
+ 	else
+ 	{
+ 		os << "Name\n";
+ 	}
+ 	for (list<FunctionOnStack>::iterator i=tr.fns.begin();i!=tr.fns.end();++i)
+ 	{
+ 		if (shownumbers)
+ 		{
+ 			unsigned int addr=(*i).GetAddress();
+ 			if (addr!=0)
+ 			{
+ 				// +4 to show the actual start of the stack frame
+ 				os << hex <<  Padding(addr+4) << addr+4 << ' ';
+ 			}
+ 			else
+ 			{
+ 				os << "n/a      ";
+ 			}
+ 		}
+ 		os <<  (*i).GetFunction()->name << endl;
+ 	}
+ 	os << tr.reason << endl;
+ }
+ 
Index: AiboPup/tools/mipaltools/src/StackAnalyser.h
diff -c /dev/null AiboPup/tools/mipaltools/src/StackAnalyser.h:1.1
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/mipaltools/src/StackAnalyser.h	Wed Sep 10 15:22:02 2003
***************
*** 0 ****
--- 1,52 ----
+ // ---------------------------------------------------------------------------------------------------
+ // File: StackAnalyser.h
+ // Date: 28/8/2003
+ // Part of StackedIt V2.0
+ // By: Joel Fenwick, Mi-Pal, Griffith University
+ //
+ // This program is copyrighted to the author and released under the GPL (V2.0).
+ // There is no warantee associated with this code. Especially not for use
+ // in nuclear plants, aircraft control systems or hedgehogs. Use at your
+ // own risk.
+ // See license.txt for details
+ // ----------------------------------------------------------------------------------------------------
+ 
+ #ifndef STACKANALYSER_H
+ #define STACKANALYSER_H
+ 
+ #include "StackDump.h"
+ #include "FunctionStore.h"
+ #include "StackAnalyserException.h"
+ #include <iostream>
+ #include <list>
+ #include "Trace.h"
+ #include "EmonLog.h"
+ 
+ 
+ class StackAnalyser
+ {
+ public:
+ 	StackAnalyser(std::istream& emondata, std::istream& functiondata,unsigned int runtimeoffset)
+ 			throw (StackAnalyserException);
+ 	~StackAnalyser();
+ 	void SimpleCheck(std::ostream& os,bool shownumbers);	// tests used in version1
+ 	void Filtering(std::ostream& os, unsigned int crashaddress, 
+ 			bool attemptrestart, bool shownumbers);		// test added in v2
+ 	
+ private:
+ 	EmonLog* emon;
+ 	StackDump* stack;
+ 	FunctionStore* fns;
+ 	unsigned int offset;	// runtimeaddress - linktime address
+ 	bool FindStack(std::istream& is);	// find the top of the stack dump in EMON
+ 	void FindMatches(std::list<FunctionOnStack>& locations, std::list<FunctionOnStack>& abovestack);
+ 							// find values in stack that match functions
+ 	void TraceBack(Trace& tr, unsigned int stacklocation, Function* f);	// used in method2
+ 	void SimpleCheckDriver(std::list<FunctionOnStack>& fos, std::ostream& os, 
+ 		bool shownumbers);		// display matches from method1
+ 	void ShowFilterTrace(std::ostream& os, Trace& tr, bool shownumbers);	
+ 							// show traces from method2
+ };
+ 
+ #endif   // STACKANALYSER_H
+ 
Index: AiboPup/tools/mipaltools/src/StackAnalyserException.h
diff -c /dev/null AiboPup/tools/mipaltools/src/StackAnalyserException.h:1.1
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/mipaltools/src/StackAnalyserException.h	Wed Sep 10 15:22:02 2003
***************
*** 0 ****
--- 1,28 ----
+ // -----------------------------------------------------------------------------
+ // File: StackAnalyserException.h
+ // Date: 28/8/2003
+ // Part of StackedIt V2.0
+ // By: Joel Fenwick, Mi-Pal, Griffith University
+ //
+ // This program is copyrighted to the author and released under the GPL (V2.0).
+ // There is no warantee associated with this code. Especially not for use
+ // in nuclear plants, aircraft control systems or hedgehogs. Use at your
+ // own risk.
+ // See license.txt for details
+ // -----------------------------------------------------------------------------
+ 
+ #ifndef STACKANALYSEREXCEPTION_H
+ #define STACKANALYSEREXCEPTION_H
+ 
+ // Warning do not pass custom built strings into this class.
+ // Since as you can see it doesn't clean them up properly
+ class StackAnalyserException
+ {
+ public:
+ 	StackAnalyserException(char* m){msg=m;}
+ 	const char* GetMsg(){return msg;}
+ private:
+ 	char* msg;
+ };
+ 
+ #endif // STACKANALYSEREXCEPTION_H
Index: AiboPup/tools/mipaltools/src/StackDump.cc
diff -c /dev/null AiboPup/tools/mipaltools/src/StackDump.cc:1.2
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/mipaltools/src/StackDump.cc	Thu Oct  9 11:23:32 2003
***************
*** 0 ****
--- 1,188 ----
+ // -----------------------------------------------------------------------------
+ // File: StackDump.cc
+ // Date: 28/8/2003
+ // Part of StackedIt V2.0
+ // By: Joel Fenwick, Mi-Pal, Griffith University
+ //
+ // This program is copyrighted to the author and released under the GPL (V2.0).
+ // There is no warantee associated with this code. Especially not for use
+ // in nuclear plants, aircraft control systems or hedgehogs. Use at your
+ // own risk.
+ // See license.txt for details
+ // -----------------------------------------------------------------------------
+ // Updated 9/10/2003 - V2.0.1 fixed a problem with includes
+ // -----------------------------------------------------------------------------
+ 
+ #include "StackDump.h"
+ #include <vector>
+ #include <cstdio>
+ using namespace std;
+ 
+ // Not particularly happy with mixing C and C++ IO here but sscanf is too useful
+ 
+ // The plan for dealing with the missing (or dead lines) is to assign each value in the stack a "valid" attribute
+ // We can then  check to see if we actually know what was at a particular location or not. 
+ 
+ /* Format of stack dump:
+ [stack info]
+  area: 0x220a0c08 - 0x220a1808, sp: 0x220a1430
+ [stack dump]
+ 220a13f0: 22642658 800b4e08 23480008 800b4bac  X&d".N....H#.K..
+ 220a1400: 00000001 00000000 00000000 00000001  ................
+ 220a1410: 226b2dd0 226b2dd0 2791a626 bea5ee4b  .-k".-k"&..'K...
+ */
+ 
+ // assume the stream is at the start of the area line
+ StackDump::StackDump(istream& is) throw (StackAnalyserException)
+ {
+ 	char buffer[80];
+ 	top=0;
+ 	ulimit=0;
+ 	llimit=0;
+ 	// Now to read the stack contents
+ 	is.getline(buffer,80);
+ 	top=static_cast<unsigned int>(strtoul(buffer+38,0,16));
+ 	if (top==0)
+ 	{
+ 		throw StackAnalyserException("Unable to determine top of stack");
+ 	}
+ 	is.getline(buffer,80);	// skip the [stack dump] line
+ 	vector<char*> lines;
+ 	ReadStack(is,lines);
+ 	if (lines.size()==0)
+ 	{
+ 		throw StackAnalyserException("No valid lines in stack dump.");
+ 	}
+ 	else
+ 	{
+ 		ProcessStack(lines);
+ 	}
+ }
+ 
+ // get a list of lines in the stack dump
+ void StackDump::ReadStack(istream& is, vector<char*>& lines)
+ {
+ 	const int LINELENGTH=80;
+ 	char* buffer=new char[LINELENGTH];
+ 	while (is.getline(buffer,LINELENGTH),is.good() && buffer[0]!='\0')
+ 	{
+ 		if (buffer[0]!='*')
+ 		{
+ 			lines.push_back(buffer);
+ 			buffer=new char[LINELENGTH];
+ 		}
+ 		
+ 	}
+ 	delete []buffer;
+ }
+ 
+ // extract data from previously read lines
+ void StackDump::ProcessStack(vector<char*>& lines)
+ {
+ 	unsigned int v[5];
+ 
+ 	// step 1 find the range of addresses we are dealing with
+ 	
+ 	llimit=(unsigned int)strtoul(lines[0],0,16);
+ 	if (llimit==0)
+ 	{	
+ 		throw StackAnalyserException("Unable to determine the lower limit of the stack.");
+ 		return;
+ 	}
+ 	ulimit=(unsigned int)strtoul(lines[lines.size()-1],0,16);
+ 	if (ulimit==0)
+ 	{
+ 		
+ 		throw StackAnalyserException("Unable to determine the upper limit of the stack.");
+ 	}
+ 	ulimit+=15;					// last address is on the end of the line
+ 	if (ulimit<llimit)
+ 	{
+ 		throw StackAnalyserException("Upper limit of the stack is smaller than the lower limit.");
+ 	}
+ 	// Now fill in the lines
+ 	contents=new StackEntry[ulimit-llimit];
+ 	for (vector<char*>::iterator i=lines.begin();i!=lines.end();++i)
+ 	{
+ 		if (sscanf(*i,"%x: %x %x %x %x",&(v[0]),&(v[1]),&(v[2]),&(v[3]),&(v[4]))!=5)
+ 		{
+ 			throw StackAnalyserException("Badly formed line in stack dump.");
+ 		}
+ 		else
+ 		{
+ 			for (int j=0;j<4;j++)
+ 			{
+ 				contents[(v[0]-llimit)/4+j].value=v[j+1];
+ 				contents[(v[0]-llimit)/4+j].valid=true;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ // Read the values from a line in the stack.
+ // cope with some problem lines
+ bool StackDump::ReadStackLine(istream& is, unsigned int vals[])
+ {
+ 	char c=' ';
+ 	is >> c;
+ 	if (!is.good() || c=='*')
+ 	{
+ 		return false;
+ 	}
+ 	is.putback(c);
+ 	is >> hex;
+ 	is >> vals[4] >> c >> vals[0] >> vals[1] >> vals[2] >> vals[3];
+ 	// clear chars at end of the line
+ 	for (int i=0;i<18;i++)
+ 	{
+ 		c=is.get();
+ 	}
+ 	return true;
+ } 
+ 
+ // access data on the stack
+ const unsigned int& StackDump::operator[](unsigned int addr) throw (StackAnalyserException)
+ {
+ 	if ((addr>=llimit) && (addr<=ulimit))
+ 	{
+ 		return contents[(addr-llimit)/4].value;
+ 	}
+ 	else
+ 	{	
+ 		throw StackAnalyserException("Stack access out of bounds");
+ 	}
+ }
+ 
+ // Do we have a value for this location on the stack
+ bool StackDump::IsValid(unsigned int addr)
+ {
+ 	if ((addr>=llimit) && (addr<=ulimit))
+ 	{
+ 		return contents[(addr-llimit)/4].valid;
+ 	}
+ 	else
+ 	{	
+ 		return false;
+ 	}
+ }
+ 
+ void StackDump::DisplayStack(ostream& os)
+ {
+ 	os << hex;
+ 	for (unsigned int i=llimit;i<=ulimit;i+=4)
+ 	{
+ 		os << i << " ";
+ 		if (IsValid(i))
+ 		{
+ 			os << (*this)[i];
+ 		}
+ 		else
+ 		{
+ 			os << "*";
+ 		}
+ 		os << endl;
+ 	}
+ }
+ 
+ 
+ 
Index: AiboPup/tools/mipaltools/src/StackDump.h
diff -c /dev/null AiboPup/tools/mipaltools/src/StackDump.h:1.1
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/mipaltools/src/StackDump.h	Wed Sep 10 15:22:02 2003
***************
*** 0 ****
--- 1,53 ----
+ // -----------------------------------------------------------------------------
+ // File: StackDump.h
+ // Date: 28/8/2003
+ // Part of StackedIt V2.0
+ // By: Joel Fenwick, Mi-Pal, Griffith University
+ //
+ // This program is copyrighted to the author and released under the GPL (V2.0).
+ // There is no warantee associated with this code. Especially not for use
+ // in nuclear plants, aircraft control systems or hedgehogs. Use at your
+ // own risk.
+ // See license.txt for details
+ // -----------------------------------------------------------------------------
+ 
+ 
+ // For storing the details of a stack dump
+ // The idea is to have a mapping from runtime address to stack contents
+ // Note the Upper and Lower limit are numerical bounds (ie: Lower < Top < Upper)
+ 
+ #ifndef STACKDUMP_H
+ #define STACKDUMP_H
+ #include <iostream>
+ #include <vector>
+ #include "StackAnalyserException.h"
+ 
+ class StackDump
+ {
+ public:
+ 	StackDump(std::istream& is) throw (StackAnalyserException);
+ 	inline unsigned int GetTop() {return top;};		// address of the top of the stack
+ 	inline unsigned int GetULimit() {return ulimit;};
+ 	inline unsigned int GetLLimit() {return llimit;};
+ 	const unsigned int& operator[](unsigned int addr) throw (StackAnalyserException);
+ 	bool IsValid(unsigned int);					// do we have a value for that stacklocation
+ 	void DisplayStack(std::ostream& os);
+ private:
+ 	struct StackEntry
+ 	{
+ 		StackEntry(){value=0;valid=false;}
+ 		unsigned int value;
+ 		bool valid;
+ 	};
+ 	StackEntry* contents;
+ 	unsigned int top;
+ 	unsigned int ulimit;
+ 	unsigned int llimit;
+ 	
+ 	bool ReadStackLine(std::istream& is, unsigned int vals[]);	// read a single line
+ 	void ReadStack(std::istream& is, std::vector<char*>& lines);	
+ 				// get lines of text that make up the stack dump
+ 	void ProcessStack(std::vector<char*>& lines);	// extract data from lines	
+ };
+ 
+ #endif // STACKDUMP_H
Index: AiboPup/tools/mipaltools/src/Trace.h
diff -c /dev/null AiboPup/tools/mipaltools/src/Trace.h:1.1
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/mipaltools/src/Trace.h	Wed Sep 10 15:22:02 2003
***************
*** 0 ****
--- 1,46 ----
+ // -----------------------------------------------------------------------------
+ // File: Trace.h
+ // Date: 28/8/2003
+ // Part of StackedIt V2.0
+ // By: Joel Fenwick, Mi-Pal, Griffith University
+ //
+ // This program is copyrighted to the author and released under the GPL (V2.0).
+ // There is no warantee associated with this code. Especially not for use
+ // in nuclear plants, aircraft control systems or hedgehogs. Use at your
+ // own risk.
+ // See license.txt for details
+ // -----------------------------------------------------------------------------
+ 
+ #ifndef TRACE_H
+ #define TRACE_H
+ 
+ #include <list>
+ #include "Function.h"
+ 
+ #include <iostream>
+ // class to link an address on the stack with the function it corresponds to
+ class FunctionOnStack
+ {
+ public:
+ 	FunctionOnStack(unsigned int addr, Function* fn)
+ 		:address(addr),f(fn)
+ 	{};
+ 	inline unsigned int GetAddress(){return address;};
+ 	inline Function* GetFunction(){return f;};
+ 	int operator==(const FunctionOnStack& other){return address==other.address;}
+ private:	
+ 	unsigned int address;	// 4 bytes before the start of the stack frame
+ 	Function* f;			// note this class does not own this pointer
+ };
+ 
+ // Represents a possible stack trace
+ // Do not use non constant strings in this object since there is no cleanup done
+ class Trace
+ {
+ public:
+ 	Trace(){reason="";}
+ 	std::list<FunctionOnStack> fns;
+ 	char* reason;			// why did we stop following this trace
+ };
+ 
+ #endif
Index: AiboPup/tools/mipaltools/src/main.cc
diff -c /dev/null AiboPup/tools/mipaltools/src/main.cc:1.1
*** /dev/null	Fri Oct 10 14:37:53 2003
--- AiboPup/tools/mipaltools/src/main.cc	Wed Sep 10 15:22:02 2003
***************
*** 0 ****
--- 1,197 ----
+ // -----------------------------------------------------------------------------
+ // File: main.cc
+ // Date: 28/8/2003
+ // Part of StackedIt V2.0
+ // By: Joel Fenwick, Mi-Pal, Griffith University
+ //
+ // This program is copyrighted to the author and released under the GPL (V2.0).
+ // There is no warantee associated with this code. Especially not for use
+ // in nuclear plants, aircraft control systems or hedgehogs. Use at your
+ // own risk.
+ // See license.txt for details
+ // -----------------------------------------------------------------------------
+ 
+ #include "StackDump.h"
+ #include "FunctionStore.h"
+ #include "StackAnalyser.h"
+ 
+ #include <iostream>
+ #include <fstream>
+ using namespace std;
+ 
+ // options from cmd line parameters
+ const unsigned int PAR_V1=0x00000001;
+ const unsigned int PAR_V2=0x00000002;
+ const unsigned int PAR_PERSIST=0x00000004;
+ const unsigned int PAR_SHOWNUM=0x000008;
+ const unsigned int PAR_DEF=PAR_V1|PAR_V2|PAR_PERSIST|PAR_SHOWNUM;
+ 
+ // programe is the name used to invoke the program
+ void ShowShortHelp(char* progname)
+ {
+ 	cout << "Usage: " << progname << " [--help | -options] runtime linktime dissassembly EMON\n";
+ }
+ 
+ // programe is the name used to invoke the program
+ void ShowDetailedHelp(char* progname)
+ {
+ 	cout << "StackAnalyser V2.0\n";
+ 	cout << "This program is copyrighted to the author (Joel Fenwick) and licensed under the GPL (v2.0). ";
+ 	cout << "There is no warantee (at all) attached to this program.\n";	
+ 	cout << "\n";
+ 	ShowShortHelp(progname);
+ 	cout << "options: (the options list starts with - and contains no spaces.)\n";
+ 	cout << "	--help	This message.\n";
+ 	cout << "	1	Displays a trace using the method from version 1 of this \n\t\tprogram. \n\t\t(any matching numbers are mapped and displayed).\n";
+ 	cout << "	2	Displays a trace using the return address in the stack frames \n\t\tto determine the calling function - leading to much\n\t\tfewer false positives.\n";
+ 	cout << "	p	Persist. If using method 2 try to find other possible trace\n\t\tfragments.\n";
+ 	cout << "	n	Only show the names of functions.\n";	
+ 	cout << "\n";
+ 	cout << "If no options are specified the default is to return as much information as possible. Currently this means -12p.\n";
+ 	cout << "\nParameters:\n";
+ 	cout << "disassembly - text file containing the dissassembly of the code that crashed.\n";
+ 	cout << "EMON - the exception monitor log file. This must contain a register dump and a stack dump (as a minimum).\n";
+ 	cout << "runtime - the runtime address of the crash.\n";
+ 	cout << "linktime - the corresponding link time address of the crash.\n";
+ 	cout << "\nNotes:\n";
+ 	cout << " * The persist option will produce false positives in the \"other traces\" \nsection. In most cases the first trace produced by method two should be enough\nfor debugging purposes.\n";
+ }
+ 
+ // Does the char target appear in string pars
+ bool HasParam(char* pars,char target)
+ {
+ 	while (*pars!='\0')
+ 	{
+ 		if (*pars==target)
+ 		{
+ 			return true;
+ 		}
+ 		pars++;
+ 	}
+ 	return false;
+ }
+ 
+ // Sets up the params for the analyser object.
+ // If non-zero is returned the program should be halted
+ int ValidateArgs(int argc, char** argv, unsigned int& runtime, unsigned  int& linktime, 
+ 	std::ifstream& assemblyf, std::ifstream& emonf, int& options)
+ {
+ 	int paramoffset=0;
+ 	options=0;
+ 	if ((argc>1) && (strcmp(argv[1],"--help")==0))
+ 	{
+ 		ShowDetailedHelp(argv[0]);
+ 		return 7;
+ 	}
+ 	if (argc<5)
+ 	{
+ 		ShowShortHelp(argv[0]);
+ 		return 1;
+ 	}
+ 	if (argv[1][0]=='-')	// were options specified
+ 	{
+ 		bool optionspresent=false;
+ 		paramoffset=1;
+ 		if (HasParam(argv[1],'1'))
+ 		{
+ 			options=options|PAR_V1;	
+ 			optionspresent=true;
+ 		}
+ 		if (HasParam(argv[1],'2'))
+ 		{
+ 			options=options|PAR_V2;
+ 			optionspresent=true;
+ 		}
+ 		if (HasParam(argv[1],'p'))
+ 		{
+ 			options=options|PAR_PERSIST;
+ 			optionspresent=true;
+ 		}
+ 		if (!HasParam(argv[1],'n'))
+ 		{
+ 			options=options|PAR_SHOWNUM;
+ 		}
+ 		else
+ 		{
+ 			optionspresent=true;
+ 		}
+ 		if (!optionspresent)
+ 		{
+ 			options=PAR_DEF;
+ 		}
+ 	}
+ 	else
+ 	{
+ 		options=PAR_DEF;
+ 	}	
+ 	runtime=(unsigned int)(strtoul(argv[1+paramoffset],0,16));
+ 	if (runtime==0)
+ 	{
+ 		cout << argv[1+paramoffset] << " is not a valid runtime address\n";
+ 		return 2;
+ 	}
+ 	linktime=(unsigned int)(strtoul(argv[2+paramoffset],0,16));
+ 	if (linktime==0)
+ 	{
+ 		cout << argv[2+paramoffset] << " is not a valid linktime address\n";
+ 		return 3;
+ 	}
+ 	if (runtime <linktime)
+ 	{
+ 		// This limitation simplifies things so 
+ 		cout << "Runtime address must be greater than linktime address\n";
+ 		return 4;
+ 	}
+ 	emonf.open(argv[4+paramoffset]);
+ 	if (emonf.fail())
+ 	{
+ 		cout << "Couldn't open EMON.LOG file " << argv[4+paramoffset] << endl;
+ 		return 5;
+ 	}
+ 	assemblyf.open(argv[3+paramoffset]);
+ 	if (assemblyf.fail())
+ 	{
+ 		cout << "Couldn't open disassembly file " << argv[3+paramoffset] << endl;
+ 		emonf.close();
+ 		return 6;
+ 	}
+ 	return 0;
+ }
+ 
+ int main(int argc, char** argv)
+ {
+ 	int options=0;
+ 	unsigned int runtime=0;
+ 	unsigned int linktime=0;
+ 	unsigned int offset=0;
+ 	ifstream assemblyf, emonf;
+ 	int ret=ValidateArgs(argc,argv,runtime, linktime, assemblyf, emonf,options);
+ 	if (ret!=0)
+ 	{
+ 		exit(ret);
+ 	}
+ 	offset=runtime-linktime;
+ 	try
+ 	{
+ 		StackAnalyser sa(emonf, assemblyf, offset);
+ 		if (options&PAR_V1)
+ 		{
+ 			cout << "Method 1 - simple matching:\n";
+ 			sa.SimpleCheck(cout,options&PAR_SHOWNUM);
+ 			cout << "\n";
+ 		}
+ 		if (options&PAR_V2)
+ 		{
+ 			cout << "Method 2 using return addresses:\n";
+ 			sa.Filtering(cout, linktime,(options&PAR_PERSIST)!=0,options&PAR_SHOWNUM);
+ 			cout << "\n";
+ 		}
+ 	}
+ 	catch (StackAnalyserException& s)
+ 	{
+ 		cout << "Error: " << s.GetMsg() << endl;
+ 	}
+ 	assemblyf.close();
+ 	emonf.close();	
+ 	return 0;
+ }
Index: AiboPup/tools/mon/AiboComm.java
diff -c AiboPup/tools/mon/AiboComm.java:1.1 AiboPup/tools/mon/AiboComm.java:removed
*** AiboPup/tools/mon/AiboComm.java:1.1	Thu Feb 20 14:51:16 2003
--- AiboPup/tools/mon/AiboComm.java	Fri Oct 10 14:37:54 2003
***************
*** 1,29 ****
- import java.io.*;
- import java.net.*;
- 
- public class AiboComm {
-   public TCPListener stderr;
-   public TCPListener stdio;
-   public TCPListener visionRLE;
-   public TCPListener visionRaw;
-   public TCPListener visionObjs;
-   public TCPListener worldGrid;
-   public TCPListener localizer;
- 
-   public AiboComm() {
- //    stdio=new TextListener(10001);
-   }
- 
-   public void close() {
-     stdio.close();
-   }
- 
-   public static void sleep(long millis) {
-     try { Thread.sleep(millis); } catch (Exception ex) { }
-   }
-   
-   public static void main(String[] args) {
-     System.out.println("please instantiate from within Matlab");
-     System.exit(1);
-   }
- }
--- 0 ----
Index: AiboPup/tools/mon/ClassPathModifier.java
diff -c AiboPup/tools/mon/ClassPathModifier.java:1.2 AiboPup/tools/mon/ClassPathModifier.java:removed
*** AiboPup/tools/mon/ClassPathModifier.java:1.2	Sun Jul  6 21:00:09 2003
--- AiboPup/tools/mon/ClassPathModifier.java	Fri Oct 10 14:37:54 2003
***************
*** 1,32 ****
- import java.lang.*;
- import java.net.*;
- import java.io.*;
- import java.lang.reflect.*;
- 
- public class ClassPathModifier {
-   private static final Class[] parameters = new Class[]{URL.class};
- 
-   public static void addFile(String s) throws IOException {
-     File f = new File(s);
-     addFile(f);
-   }
- 
-   public static void addFile(File f) throws IOException {
-     addURL(f.toURL());
-   }
- 
-   public static void addURL(URL u) throws IOException {
-     URLClassLoader sysloader =
-       (URLClassLoader)ClassLoader.getSystemClassLoader();
- 
- 		Class sysclass = URLClassLoader.class;
- 
-     try {
-       Method method = sysclass.getDeclaredMethod("addURL",parameters);
-       method.setAccessible(true);
-       method.invoke(sysloader, new Object[]{ u });
-     } catch (Throwable t) {
-       throw new IOException("could not add "+u+" to classpath");
- 		}
-   }
- }
--- 0 ----
Index: AiboPup/tools/mon/ControllerGUI
diff -c /dev/null AiboPup/tools/mon/ControllerGUI:1.2
*** /dev/null	Fri Oct 10 14:37:54 2003
--- AiboPup/tools/mon/ControllerGUI	Fri Sep 26 00:36:02 2003
***************
*** 0 ****
--- 1,2 ----
+ #!/bin/sh
+ java org/tekkotsu/mon/ControllerGUI $*
\ No newline at end of file
Index: AiboPup/tools/mon/ControllerGUI.java
diff -c AiboPup/tools/mon/ControllerGUI.java:1.21 AiboPup/tools/mon/ControllerGUI.java:removed
*** AiboPup/tools/mon/ControllerGUI.java:1.21	Tue Jul  8 14:01:21 2003
--- AiboPup/tools/mon/ControllerGUI.java	Fri Oct 10 14:37:54 2003
***************
*** 1 ****
- import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.event.*;import java.beans.*;import java.util.*;//Admittedly a little sloppy, but I don't want to spend forever on this...public class ControllerGUI extends JFrame implements ActionListener {	JList menu;	JScrollPane menuScroll;	JLabel title;	JLabel status;	JList bookmarks;	ControllerListener comm;	JButton cancelBut;	JButton refreshBut;	JButton reconnectBut;	EStopPanel estop;	JTextField inputField;	boolean isUpdating=false;		ControllerGUI(String addr, int port) {		super();		comm = new ControllerListener(addr,port);		comm.listener=this;		init();		pack();		setLocation(50,50);		show();	}		// Disables the component if there's nothing selected to apply it to	public class AutoDisableListener implements PropertyChangeListener, ListSelectionListener {		JComponent target;		public AutoDisableListener(JComponent target, JList source) {			this.target=target;			source.addPropertyChangeListener(this);			source.addListSelectionListener(this);		}		public void propertyChange(PropertyChangeEvent evt) {			target.setEnabled(!((JList)evt.getSource()).isSelectionEmpty());		}		public void valueChanged(ListSelectionEvent evt) {			target.setEnabled(!((JList)evt.getSource()).isSelectionEmpty());		}	}		final static ImageIcon rarrow = new ImageIcon("images/rarrow.png");	final static ImageIcon larrow = new ImageIcon("images/larrow.png");	final static ImageIcon carrows = new ImageIcon("images/chasingarrows.png");	public class MyCellRenderer implements ListCellRenderer {		public Component getListCellRendererComponent(JList list,Object value,int index,boolean isSelected,boolean cellHasFocus) {			ControllerListener.MenuEntry me=(ControllerListener.MenuEntry)value;			/*			if(me.hasSubmenu) {						setIcon(rarrow);						setHorizontalTextPosition(SwingConstants.RIGHT);						setIconTextGap(5);						} else						setIconTextGap(5+rarrow.getIconWidth());			*/						//System.out.println(this.getText()+" "+me.selected+" "+isSelected);			int numpre=(int)(Math.log(list.getModel().getSize()-1)/Math.log(10))-(index==0?0:(int)(Math.log(index)/Math.log(10)));			StringBuffer pre=new StringBuffer();			for(int i=0;i<numpre;i++)				pre.append(" ");			JLabel title=new JLabel(pre.toString()+index+". "+me.title);			title.setBackground(me.selected?list.getSelectionBackground():list.getBackground());			title.setForeground(me.selected?list.getSelectionForeground():list.getForeground());			title.setEnabled(list.isEnabled());			title.setFont(list.getFont());			title.setOpaque(true);			title.setPreferredSize(new Dimension(list.getSize().width,title.getPreferredSize().height));			//Vector tmp2=new Vector();			//for(int i=0;i<1000000;i++) {tmp2.add(new Integer(0));tmp2.remove(tmp2.size()-1);}			if(me.hasSubmenu) {				Box tmp=Box.createHorizontalBox();				tmp.add(title);				//				tmp.add(Box.createHorizontalGlue());				JLabel arr=new JLabel(rarrow);				arr.setEnabled(list.isEnabled());				tmp.add(arr);				if(me.description.length()!=0)					tmp.setToolTipText(me.description);				return tmp;			} else {				Box tmp=Box.createHorizontalBox();				tmp.add(title);				tmp.add(Box.createHorizontalStrut(rarrow.getIconWidth()));				if(me.description.length()!=0)					tmp.setToolTipText(me.description);				return tmp;			}		}	} 	 	public class JListDoubleClick extends MouseAdapter {		ControllerGUI gui;		JListDoubleClick(ControllerGUI gui) { this.gui=gui; }		public void mouseClicked(MouseEvent e) {			if (e.getClickCount() == 2) {				int index = ((JList)e.getSource()).locationToIndex(e.getPoint());				gui.doubleClicked((JList)e.getSource(),index);			}		}	}	public class MySelectionListener implements ListSelectionListener {		ControllerGUI gui;		MySelectionListener(ControllerGUI gui) { this.gui=gui; }		public void valueChanged(ListSelectionEvent e) {			if(!gui.isUpdating && !e.getValueIsAdjusting())				gui.comm.sendSelection(((JList)e.getSource()).getSelectedIndices());		}	} 		public class EscFilter extends KeyAdapter {		JButton trigger;		EscFilter(JButton trigger) { this.trigger=trigger; }		public void keyReleased(KeyEvent evt) {			if(evt.getKeyChar()==(char)27)				trigger.doClick();		}	}	public class ReturnFilter extends KeyAdapter {		ControllerGUI gui;		ReturnFilter(ControllerGUI gui) { this.gui=gui; }		public void keyReleased(KeyEvent evt) {			if(evt.getKeyCode()==KeyEvent.VK_ENTER)				gui.doubleClicked((JList)evt.getSource(),0);		}	} 		public class ReenableOnClose extends WindowAdapter {		JButton but;		public ReenableOnClose(JButton b) { but=b; }		public void windowClosing(WindowEvent e) {			e.getWindow().dispose();			but.setEnabled(true);		}	}	void updated() {			//		System.out.println("updated");		isUpdating=true;		Point p=menuScroll.getViewport().getViewPosition();  		//		bookmarks.setEnabled(comm._isConnected);		cancelBut.setEnabled(comm._isConnected);		refreshBut.setEnabled(comm._isConnected);		inputField.setEnabled(comm._isConnected);		if(!comm._isConnected) {			title.setText("-");			menu.setListData(new Vector());			status.setText("Reconnecting...");		} else {			synchronized(comm._menus) {				title.setText((String)comm._titles.lastElement());				Vector menuitems=(Vector)comm._menus.lastElement();				menu.setValueIsAdjusting(true);				menu.setListData(menuitems);				Vector sels=new Vector();				for(int i=0; i<menuitems.size(); i++)					if(((ControllerListener.MenuEntry)menuitems.get(i)).selected)						sels.add(new Integer(i));				int[] selsArr=new int[sels.size()];				for(int i=0; i<selsArr.length; i++)					selsArr[i]=((Integer)sels.get(i)).intValue();				menu.setSelectedIndices(selsArr);				menu.setValueIsAdjusting(false);			}			status.setText(comm._status.length()>0?comm._status:"Connected.");		}		menuScroll.getViewport().setViewPosition(p);		isUpdating=false;		comm._updatedFlag=false;	}	public void paint(Graphics g) {		if(comm!=null && comm._updatedFlag)			updated();		super.paint(g);	}		public void actionPerformed(ActionEvent evt) {		if(evt.getSource()==cancelBut) {			//System.out.println("cancel button clicked");			comm.sendReturn();		} else if(evt.getSource()==refreshBut) {			//System.out.println("refresh button clicked");			comm.sendRefresh();		} else if(evt.getSource()==inputField) {			//System.out.println("input: "+inputField.getText());			int[] sel=menu.getSelectedIndices();			if(sel.length==0 || inputField.getText().charAt(0)=='!')				comm.sendInput(inputField.getText());			else				comm.sendInput("!input "+inputField.getText());			/*else if(sel.length==1) {				comm.sendSelectionPath(comm.buildSelectionPath(sel[0]));				comm.sendInput(inputField.getText());			} else				for(int i=0; i<sel.length; i++)					comm.sendInput(inputField.getText(),comm.buildSelectionPath(sel[i]));			*/			inputField.setText("");		} else if(evt.getSource()==reconnectBut) {			int port=comm._port;			String addr=comm._host;			comm.kill();			comm = new ControllerListener(addr,port);			comm.listener=this;		} else if(evt.getActionCommand().compareTo("raw")==0 || evt.getActionCommand().compareTo("rle")==0) {			String[] tmp=new String[1];			tmp[0]=evt.getActionCommand();			VisionGUI vis=new VisionGUI(comm._host,tmp);			((JButton)evt.getSource()).setEnabled(false);			vis.addWindowListener(new ReenableOnClose((JButton)evt.getSource()));			vis.show();			vis.toFront();		}	}		public void doubleClicked(JList list, int index) {		if(list==menu) {			Vector items=(Vector)comm._menus.lastElement();			//System.out.println(items.get(index)+" selected");			comm.sendSelect();			/*			int[] sel=menu.getSelectedIndices();						if(sel.length==1) {						comm.sendSelectionPath(comm.buildSelectionPath(sel[0]));						} else if(sel.length>1) {						Vector selectionPaths=new Vector();						for(int i=0; i<sel.length; i++)						selectionPaths.add(comm.buildSelectionPath(sel[i]));						for(int i=0; i<selectionPaths.size(); i++)						comm.sendSelectionPath((Vector)selectionPaths.get(i));						}			*/			inputField.setText("");		} else if(list==bookmarks) {			//todo		} else {			System.out.println("Unknown list double-clicked");		}	}		public class ConstSizeJButton extends JButton {		Dimension dim;		ConstSizeJButton(String s, ImageIcon i, Dimension d) { super(s,i); dim=d; }		public Dimension getPreferredSize() { return dim; }		public Dimension getMinimumSize() { return dim; }		public Dimension getMaximumSize() { return dim; }		public Dimension getSize() { return dim; }	}	protected void init() {		int spacer_size=10;					setTitle("TekkotsuMon: Controller Menus");		getContentPane().setLayout(new BorderLayout());		getContentPane().add(Box.createHorizontalStrut(spacer_size),BorderLayout.WEST);		getContentPane().add(Box.createHorizontalStrut(spacer_size),BorderLayout.EAST);		getContentPane().add(Box.createVerticalStrut(spacer_size),BorderLayout.NORTH);		getContentPane().add(Box.createVerticalStrut(spacer_size),BorderLayout.SOUTH);				menu=new JList();		menu.setCellRenderer(new MyCellRenderer());		menu.setFixedCellWidth(165);		menu.addMouseListener(new JListDoubleClick(this)); 		menu.addListSelectionListener(new MySelectionListener(this));				JPanel content=new JPanel(new BorderLayout());		Box titleBox=Box.createVerticalBox();		title=new JLabel("-");		title.setFont(new Font(title.getFont().getFontName(),Font.BOLD,title.getFont().getSize()));		title.setAlignmentX(0);		titleBox.add(title);		titleBox.add(Box.createVerticalStrut(spacer_size));		content.add(titleBox,BorderLayout.NORTH);				Box menuBox=Box.createVerticalBox();		menuScroll=new JScrollPane(menu);		menuScroll.setAlignmentX(0.5f);		menuBox.add(menuScroll);		{			Box tmp=Box.createHorizontalBox();			cancelBut=new JButton("Cancel");			Dimension dim=new Dimension(cancelBut.getPreferredSize().width+larrow.getIconWidth()+cancelBut.getIconTextGap(),cancelBut.getPreferredSize().height);			tmp.add(cancelBut=new ConstSizeJButton("Cancel",larrow,dim));			cancelBut.setEnabled(false);			cancelBut.addActionListener(this);			cancelBut.setToolTipText("Returns to previous control");			tmp.add(refreshBut=new JButton("Refresh"));			refreshBut.setEnabled(false);			refreshBut.addActionListener(this);			refreshBut.setToolTipText("Requests a menu refresh (handy if item names are dynamic)");			tmp.setAlignmentX(0.5f);			menuBox.add(tmp);		}		content.add(menuBox,BorderLayout.CENTER);		Box statusbox=Box.createVerticalBox();		statusbox.add(Box.createVerticalStrut(spacer_size));		{			JSeparator sep=new JSeparator(SwingConstants.HORIZONTAL);			statusbox.add(sep);		}		statusbox.add(Box.createVerticalStrut(spacer_size-2));		{			JPanel tmp=new JPanel(new BorderLayout());			status=new JLabel("Connecting...");			tmp.add(status,BorderLayout.CENTER);			{				Box tmp2=Box.createHorizontalBox();				estop=new EStopPanel(new EStopListener(comm._host,EStopListener.defPort));				estop.setPreferredSize(new Dimension(15,15));				tmp2.add(estop);				tmp2.add(Box.createHorizontalStrut(spacer_size));				reconnectBut=new JButton(carrows);				reconnectBut.setPreferredSize(new Dimension(carrows.getIconWidth(),carrows.getIconHeight()));				reconnectBut.addActionListener(this);				reconnectBut.setToolTipText("Drop current connection and try again.");				tmp2.add(reconnectBut);				tmp.add(tmp2,BorderLayout.EAST);			}			statusbox.add(tmp);		}		content.add(statusbox, BorderLayout.SOUTH);				Box p=Box.createVerticalBox();		p.add(new JLabel("Send Input:"));		p.add(inputField=new JTextField());		inputField.setEnabled(false);		inputField.addActionListener(this);		inputField.setMaximumSize(new Dimension(inputField.getMaximumSize().width,inputField.getPreferredSize().height));		inputField.setToolTipText("Text from here is passed to selected controls, or the current control if no selection");		p.add(Box.createVerticalStrut(spacer_size));		{			JSeparator sep=new JSeparator(SwingConstants.HORIZONTAL);			sep.setMaximumSize(new Dimension(sep.getMaximumSize().width,spacer_size));			p.add(sep);		}		p.add(Box.createVerticalStrut(spacer_size-2));				{			Box tmp=Box.createHorizontalBox();			JButton but;			but=new JButton("Raw Cam");			but.setToolTipText("Raw vision");			but.addActionListener(this);			but.setActionCommand("raw");			tmp.add(but);			but=new JButton("Seg. Cam");			but.setToolTipText("Segmented vision");			but.addActionListener(this);			but.setActionCommand("rle");			tmp.add(but);			tmp.setAlignmentX(0.0f);			p.add(tmp);		}				p.add(Box.createVerticalStrut(spacer_size));		{			JSeparator sep=new JSeparator(SwingConstants.HORIZONTAL);			sep.setMaximumSize(new Dimension(sep.getMaximumSize().width,spacer_size));			p.add(sep);		}		p.add(Box.createVerticalStrut(spacer_size-2));				p.add(new JLabel("Bookmarks:"));		String[] test={"Not yet","implemented"};		bookmarks=new JList(test);		bookmarks.setEnabled(false);		{			JScrollPane tmp=new JScrollPane(bookmarks);			tmp.setAlignmentX(0);			p.add(tmp);		}		{			Box bbox=Box.createHorizontalBox();			bbox.setAlignmentX(0);			bbox.add(Box.createHorizontalGlue());			JButton tmp;			bbox.add(tmp=new JButton("Add"));			//			new AutoDisableListener(tmp,menu);			tmp.setEnabled(false);			bbox.add(tmp=new JButton("Remove"));			new AutoDisableListener(tmp,bookmarks);			tmp.setEnabled(false);			bbox.add(Box.createHorizontalGlue());			p.add(bbox);		}		{			JPanel p2=new JPanel(new BorderLayout());			p2.add(p,BorderLayout.EAST);			p2.add(Box.createHorizontalStrut(spacer_size),BorderLayout.WEST);			content.add(p2, BorderLayout.EAST);		}				getContentPane().add(content,BorderLayout.CENTER);		EscFilter esc=new EscFilter(cancelBut);		addKeyListener(esc);		inputField.addKeyListener(esc);		menu.addKeyListener(esc);		menu.addKeyListener(new ReturnFilter(this));			}		public void show() {		super.show();		menu.requestFocus();	}		public static void main(String s[]) throws java.lang.InterruptedException {		if(s.length<1) {			System.out.println("Usage: java ControllerGUI host [port]");			System.out.println("       if port is not specified, it defaults to 10020");			System.exit(2);		}		//    try { ClassPathModifier.addFile("../aibo3d"); }		//    catch (Exception ex) { System.out.println(ex); System.exit(1); }		int port=10020;		if(s.length>1)			port=Integer.parseInt(s[1]);		ControllerGUI f = new ControllerGUI(s[0],port);		f.addWindowListener(new WindowAdapter() {				public void windowClosing(WindowEvent e) {System.exit(0);}			});	}}/*	public class MySelectionModel extends DefaultListSelectionModel {		Vector curmenu;		ControllerGUI gui;		public boolean isUpdate;		public MySelectionModel(ControllerGUI gui) {			this.gui=gui;		}		public void updated(Vector curmenu) {			this.curmenu=curmenu;			Vector sel=getSelection();			super.clearSelection();			//			super.removeSelectionInterval(0,curmenu.size());			for(int i=0; i<sel.size();i++) {				int s=((Integer)sel.get(i)).intValue();				super.addSelectionInterval(s,s);			}			isUpdate=false;		}		public boolean isSelectedIndex(int index) {			return ((ControllerListener.MenuEntry)curmenu.get(index)).selected;		}		public boolean isSelectionEmpty() {			return getSelection().size()>0;		}		public void clearSelection() {			if(!isUpdate)				gui.comm.sendSelection(new Vector());		}		public int getMinSelectionIndex() {			for(int i=0; i<curmenu.size(); i++)				if(((ControllerListener.MenuEntry)curmenu.get(i)).selected)					return i;			return -1;		}		public int getMaxSelectionIndex() {			for(int i=curmenu.size()-1; i>-1; i--)				if(((ControllerListener.MenuEntry)curmenu.get(i)).selected)					return i;			return -1;		}		public void addSelectionInterval(int index0, int index1) {			int min=index0<index1?index0:index1;			int max=index0>index1?index0:index1;			if(min<0) min=0;			if(max>curmenu.size()) max=curmenu.size()-1;			Vector ans=new Vector();			for(int i=0; i<min; i++)				if(((ControllerListener.MenuEntry)curmenu.get(i)).selected)					ans.add(new Integer(i));			for(int i=min; i<=max; i++)				ans.add(new Integer(i));			for(int i=max+1; i<curmenu.size(); i++)				if(((ControllerListener.MenuEntry)curmenu.get(i)).selected)					ans.add(new Integer(i));			if(!isUpdate)				gui.comm.sendSelection(ans);		}		public void removeSelectionInterval(int index0, int index1) {			int min=index0<index1?index0:index1;			int max=index0>index1?index0:index1;			if(min<0) min=0;			if(max>curmenu.size()) max=curmenu.size()-1;			Vector ans=new Vector();			for(int i=0; i<min; i++)				if(((ControllerListener.MenuEntry)curmenu.get(i)).selected)					ans.add(new Integer(i));			for(int i=max+1; i<curmenu.size(); i++)				if(((ControllerListener.MenuEntry)curmenu.get(i)).selected)					ans.add(new Integer(i));			if(!isUpdate)				gui.comm.sendSelection(ans);		}		public void setSelectionInterval(int index0, int index1) {			int min=index0<index1?index0:index1;			int max=index0>index1?index0:index1;			if(min<0) min=0;			if(max>curmenu.size()) max=curmenu.size()-1;			Vector ans=new Vector();			for(int i=min; i<=max; i++)				ans.add(new Integer(i));			if(!isUpdate)				gui.comm.sendSelection(ans);		}		private Vector getSelection() {			Vector ans=new Vector();			for(int i=0; i<curmenu.size(); i++)				if(((ControllerListener.MenuEntry)curmenu.get(i)).selected)					ans.add(new Integer(i));			return ans;		}	}	MySelectionModel selmodel;*/
\ No newline at end of file
--- 0 ----
Index: AiboPup/tools/mon/ControllerListener.java
diff -c AiboPup/tools/mon/ControllerListener.java:1.9 AiboPup/tools/mon/ControllerListener.java:removed
*** AiboPup/tools/mon/ControllerListener.java:1.9	Sun Jul  6 21:00:09 2003
--- AiboPup/tools/mon/ControllerListener.java	Fri Oct 10 14:37:54 2003
***************
*** 1,305 ****
- import java.io.*;
- import java.net.Socket;
- import java.util.Vector;
- import java.lang.Integer;
- import java.util.HashMap;
- import java.lang.Class;
- import java.lang.reflect.Method;
- import java.lang.reflect.Constructor;
- 
- public class ControllerListener extends TCPListener {
- 	boolean _updatedFlag=false;
- 	Vector _titles;
- 	Vector _menus;
- 	Vector _selections;
- 	String _status;
- 	PrintStream _out;
- 	ControllerGUI listener;
- 	HashMap dynObjs=new HashMap();
- 	InputStream sin;
- 	
- 	public class MenuEntry {
- 		boolean hasSubmenu;
- 		boolean selected;
- 		String title;
- 		String description;
- 		MenuEntry(boolean hasSubmenu, boolean selected, String title, String description) {
- 			this.hasSubmenu=hasSubmenu;
- 			this.selected=selected;
- 			this.title=title;
- 			this.description=description;
- 		}
- 		public String toString() { return title; }
- 	}
- 	
- 	static String escapize(Vector path) {
- 		System.out.println("Escapize:"+path);
- 		StringBuffer p=new StringBuffer();
- 		System.out.println("Escapized1:"+p);
- 		for(int i=0; i<path.size(); i++) {
- 			p.append("/");
- 			System.out.println("Escapized2:"+p);
- 			p.append(((String)path.get(i)).replaceAll("\\\\","\\\\\\\\").replaceAll("/","\\\\/"));
- 			System.out.println("Escapized3:"+p);
- 		}
- 		System.out.println("Escapized:"+p);
- 		return p.toString();
- 	}
- 
- 	public Vector buildSelectionPath(int index) {
- 		Vector ans=buildSelectionPath();
- 		ans.add(((Vector)_menus.lastElement()).get(index).toString());
- 		return ans;
- 	}
- 		
- 	public Vector buildSelectionPath() {
- 		Vector ans=new Vector();
- 		for(int i=0; i<_menus.size()-1; i++)
- 			ans.add(((Vector)_menus.get(i)).get(((Integer)_selections.get(i)).intValue()).toString());
- 		return ans;
- 	}
- 		
- 	void sendSelectionPath(Vector path) {
- 		try {
- 			_out.println("!select");
- 		} catch (Exception ex) { }
- 	}
- 	
- 	void sendSelect() {
- 		try {
- 			_out.println("!select");
- 		} catch (Exception ex) { }
- 	}
- 	
- 	void sendReturn() {
- 		try {
- 			_out.println("!cancel");
- 		} catch (Exception ex) { }
- 	}
- 	
- 	void sendRefresh() {
- 		try {
- 			_out.println("!refresh");
- 		} catch (Exception ex) { }
- 	}
- 	
- 	void sendInput(String s,Vector path) {
- 		try {
- 			Vector cur=buildSelectionPath();
- 			sendSelectionPath(path);
- 			_out.println(s);
- 			sendSelectionPath(cur);
- 		} catch (Exception ex) { }
- 	}
- 	
- 	void sendInput(String s) {
- 		try {
- 			_out.println(s);
- 		} catch (Exception ex) { }
- 	}
- 	
- 	void sendSelection(int sel[]) {
- 		try {
- 			String msg="!hilight";
- 			for(int i=0; i<sel.length; i++) {
- 				msg+=" ";
- 				msg+=sel[i];
- 			}
- 			_out.println(msg);
- 		} catch (Exception ex) { }
- 	}
- 
- 	void connected(Socket socket) {
- 		_isConnected=true;
- 		_menus=new Vector();
- 		_menus.add(new Vector());
- 		_titles=new Vector();
- 		_titles.add("Unset");
- 		System.out.println("connection opened");
- 		try {
- 			sin=socket.getInputStream();
- 			_out=new PrintStream(socket.getOutputStream());
- 			_out.println("!refresh");
- 			while (true) {
- 				String msgtype=readLine(sin);
- 				if(!_isConnected) break;
- 				//				System.out.println("Received: "+msgtype);
- 				synchronized(_menus) {
- 					if(msgtype.equals("push")) {
- 						_menus.add(new Vector());
- 						_titles.add("Unset");
- 					}
- 					if(msgtype.equals("refresh") || msgtype.equals("push")) {
- 						String last=readLine(sin);
- 						if(!_isConnected) break;
- 						_titles.set(_titles.size()-1,last);
- 						int len=Integer.parseInt(readLine(sin));
- 						if(!_isConnected) break;
- 						Vector menu=(Vector)_menus.lastElement();
- 						menu.clear();
- 						for(;len>0;len--) {
- 							int x=Integer.parseInt(readLine(sin));
- 							if(x==-1) {
- 								_isConnected=false;
- 								break;
- 							}
- 							int sel=Integer.parseInt(readLine(sin));
- 							if(x==-1) {
- 								_isConnected=false;
- 								break;
- 							}
- 							last=readLine(sin);
- 							if(!_isConnected) break;
- 							String descript=readLine(sin);
- 							if(!_isConnected) break;
- 							menu.add(new MenuEntry((x>0),(sel>0),last,descript));
- 						}
- 						_status="";
- 						if(!_isConnected) break;
- 					} else if(msgtype.equals("pop")) {
- 						_menus.remove(_menus.size()-1);
- 						_titles.remove(_titles.size()-1);
- 					} else if(msgtype.equals("reset")) {
- 						_menus.clear();
- 						_menus.add(new Vector());
- 						_titles.clear();
- 					} else if(msgtype.equals("status")) {
- 						_status=readLine(sin);
- 						if(!_isConnected) break;
- 					} else if(msgtype.equals("load")) {
- 						String type=readLine(sin);
- 						if(!_isConnected) break;
- 						String name=readLine(sin);
- 						if(!_isConnected) break;
- 						int port=Integer.parseInt(readLine(sin));
- 						if(!_isConnected) break;
- 						String args=readLine(sin);
- 						if(!_isConnected) break;
- 						String[] argArr=parseArgs(args);
- 						if(!_isConnected) break;
- 						Class objClass=null;
- 						try {
- 							objClass=Class.forName(type);
- 						} catch(Exception ex) { System.out.println("Could not load "+type+": "+ex); }
- 						if(objClass!=null) {
- 							Class[] consArgClasses=new Class[3];
- 							Object[] consArgs=new Object[3];
- 							consArgs[0]=_host;
- 							consArgs[1]=new Integer(port);
- 							consArgs[2]=argArr;
- 							for(int i=0;i<consArgs.length;i++)
- 								consArgClasses[i]=consArgs[i].getClass();
- 							consArgClasses[1]=Integer.TYPE;
- 							Constructor objCons=objClass.getConstructor(consArgClasses);
- 							Object obj=objCons.newInstance(consArgs);
- 							dynObjs.put(name,obj);
- 						}
- 					} else if(msgtype.equals("close")) {
- 						String name=readLine(sin);
- 						if(!_isConnected) break;
- 						Object obj=dynObjs.get(name);
- 						if(obj==null) {
- 							System.out.println("ControllerGUI: error - could not close "+name+" - not loaded");
- 						} else {
- 							Method m=obj.getClass().getMethod("close",null);
- 							m.invoke(obj,null);
- 						}
- 					} else {
- 						System.err.println("ControllerListener - Invalid message type:"+msgtype);
- 					}
- 					_updatedFlag=true;
- 					if(listener!=null)
- 						listener.repaint();
- 					else
- 						System.out.println("null listener");
- 				}
- 			}
- 		} catch (Exception ex) { ex.printStackTrace(System.out); }
- 		
- 		try { socket.close(); } catch (Exception ex) { }
- 
- 		while(_updatedFlag)
- 				try { Thread.sleep(100); } catch (Exception ex) {}
- 
- 		_isConnected=false;
- 		_updatedFlag=true;
- 		if(listener!=null)
- 			listener.repaint();
- 		//The sleep is to get around the socket still listening after being closed thing
- 		System.out.println("ControllerGUI - connection closed... reconnect after 5 seconds");
- 		try { Thread.sleep(5000); } catch (Exception ex) {}
- 	}
-  
- 	public boolean hasData() {
- 		return _updatedFlag;
- 	}
- 
- 	public boolean isConnected() {
- 		return _isConnected;
- 	}
- 
- 	public String[] parseArgs(String args) throws java.io.IOException {
- 		Vector v=new Vector();
- 		StringBuffer cur=new StringBuffer();
- 		boolean isDoubleQuote=false;
- 		boolean isSingleQuote=false;
- 		do {
- 			for(int i=0; i<args.length(); i++) {
- 				char c=args.charAt(i);
- 				switch(c) {
- 				case ' ':
- 					if(isSingleQuote || isDoubleQuote)
- 						cur.append(c);
- 					else {
- 						v.add(cur.toString());
- 						cur.setLength(0);
- 					}
- 					break;
- 				case '\\':
- 					if(i==args.length()-1) { //escaped line break
- 						args=readLine(sin);  //get next line and continue
- 						if(!isConnected()) {
- 							if(cur.length()>0)
- 								v.add(cur.toString());
- 							return makeArray(v);
- 						}
- 						if(isSingleQuote || isDoubleQuote)
- 							cur.append('\n');
- 						i=-1;
- 					} else
- 						cur.append(args.charAt(++i));
- 					break;
- 				case '"':
- 					if(isSingleQuote)
- 						cur.append(c);
- 					else
- 						isDoubleQuote=!isDoubleQuote;
- 					break;
- 				case '\'':
- 					if(isDoubleQuote)
- 						cur.append(c);
- 					else
- 						isSingleQuote=!isSingleQuote;
- 					break;
- 				default:
- 					cur.append(c);
- 					break;
- 				}
- 			} 
- 		} while(isDoubleQuote || isSingleQuote);
- 		if(cur.length()>0)
- 			v.add(cur.toString());
- 		return makeArray(v);
- 	}
- 
- 	protected String[] makeArray(Vector v) {
- 		String[] ans=new String[v.size()];
- 		for(int i=0; i<v.size(); i++)
- 			ans[i]=(String)v.get(i);
- 		return ans;
- 	}
- 
- 	public ControllerListener() { super(); }
- 	public ControllerListener(int port) { super(port); }
- 	public ControllerListener(String host, int port) { super(host,port); }
- }
--- 0 ----
Index: AiboPup/tools/mon/ControllerMsg.java
diff -c AiboPup/tools/mon/ControllerMsg.java:1.1 AiboPup/tools/mon/ControllerMsg.java:removed
*** AiboPup/tools/mon/ControllerMsg.java:1.1	Sun Jul  6 21:00:09 2003
--- AiboPup/tools/mon/ControllerMsg.java	Fri Oct 10 14:37:54 2003
***************
*** 1,14 ****
- import javax.swing.JOptionPane;
- 
- public class ControllerMsg {
- 
- 	public static void main(String args[]) {
- 		new ControllerMsg("",0,args);
- 	}
- 
- 	public ControllerMsg(String host, int port, String args[]) {
- 		for(int i=0; i<args.length; i++)
- 			System.out.println("<"+args[i]+">");
- 		JOptionPane.showMessageDialog(null,args[1],args[0],JOptionPane.INFORMATION_MESSAGE);
- 	}
- }
--- 0 ----
Index: AiboPup/tools/mon/DogConfig.java
diff -c AiboPup/tools/mon/DogConfig.java:1.1 AiboPup/tools/mon/DogConfig.java:removed
*** AiboPup/tools/mon/DogConfig.java:1.1	Tue Jul  1 05:00:18 2003
--- AiboPup/tools/mon/DogConfig.java	Fri Oct 10 14:37:54 2003
***************
*** 1,169 ****
- import java.util.*;
- import java.io.*;
- 
- public class DogConfig {
-   List IPs;
-   String IP;
-   Hashtable config;
- 
-   public static void main(String args[]) {
-     try { ClassPathModifier.addFile("ftp.jar"); }
-     catch (Exception ex) { System.out.println(ex); System.exit(1); }
- 
-     DogConfig config=new DogConfig(args);
-   }
- 
-   void usage() {
-     System.out.println("java DogConfig [Internet address [Internet address ...]]");
-   }
- 
-   public DogConfig(String args[]) {
-     for (int i=0; i<args.length; i++) {
-       if (args[i].charAt(0)=='-') {
-         usage();
-         System.exit(0);
-       }
-     }
- 
-     readConfig();
-     for (int i=0; i<args.length; i++) {
-       if (tryIP(args[i])) {
-         IP=args[i];
-         break;
-       }
-     }
- 
-     if (IP==null) {
-       for (ListIterator iter = IPs.listIterator(); iter.hasNext(); ) {
-         String cline=(String)iter.next();
-         int clength=cline.length();
-         if (clength!=0 && cline.charAt(0)!='#') {
-           if (tryIP(cline)) {
-             IP=cline;
-             break;
-           }
-         }
-       }
-     } else {
-       int insertpos=0;
-       boolean ipbegun=false;
- 
-       for (ListIterator iter = IPs.listIterator(); iter.hasNext(); ) {
-         String cline=(String)iter.next();
-         int clength=cline.length();
- 
-         if (clength!=0 && cline.charAt(0)!='#') ipbegun=true;
-         else if (!ipbegun) insertpos++;
- 
-         if (cline.compareToIgnoreCase(IP)==0) {
-           insertpos=-1;
-           break;
-         }
-       }
-       
-       if (insertpos>=0) {
-         IPs.add(insertpos,IP); 
-         writeConfig();
-       }
-     }
-   
-     if (IP==null) {
-       // pop up dialog box asking for IP address
-     }
-   }
- 
-   boolean tryIP(String ip) {
-     DogConfigFTP dog_ftp=new DogConfigFTP(ip, 21, "config", "config");
-     System.out.print("Trying "+ip+" ... ");
-     System.out.flush();
-     if (dog_ftp.test()) {
-       System.out.println("found");
-       try {
-         readAiboConfig(dog_ftp.getFile("tekkotsu.cfg"));
-         return true;
-       } catch (Exception ex) {
-         System.out.println("ftp error: "+ ex);
-       }
-     } else {
-       System.out.println("not found");
-     }
-     return false;
-   }
- 
-   public DogConfig() {
-     this(new String[0]);
-   }
- 
-   public String getIP() {
-     return IP;
-   }
- 
-   void readAiboConfig(String conf) {
-     String[] lines=conf.split("[\r\n]");
-     config=new Hashtable();
-     Hashtable current=config;
- 
-     for (int i=0; i<lines.length; i++) {
-       String cline=lines[i];
-       int clength=cline.length();
-       if (clength!=0 && cline.charAt(0)!='#') {
-         if (cline.charAt(0)=='[' && cline.charAt(clength-1)==']') {
-           String category=cline.substring(1,clength-1);
-           current=new Hashtable();
-           config.put(category, current);
-         } else {
-           int ind=cline.indexOf('=');
-           if (ind<0) {
-             System.out.println("warning: line "+(i+1)+" ignored");
-             System.out.println("       > "+cline);
-           } else {
-             String key=cline.substring(0,ind);
-             String value=cline.substring(ind+1,clength);
-             current.put(key, value);
-           }
-         }
-       }
-     }
-   }
- 
-   public String getValue(String section, String key) {
-     Hashtable sectionhash=(Hashtable)config.get(section);
-     if (sectionhash!=null)
-       return (String)sectionhash.get(key);
-     return null;
-   }
- 
-   void readConfig() {
-     IPs=new ArrayList(10);
-     try {
-       BufferedReader in = new BufferedReader
-         ( new FileReader (".aibo_ip") );
-       String curLine=in.readLine();
-       while (curLine!=null) {
-         IPs.add(curLine);
-         curLine=in.readLine();
-       }
-       in.close();
-     } catch (FileNotFoundException ex) {
-       // we just start off with 0 IPs
-       // also creating a new file, so add an intro comment
-       IPs.add("# Ordered list of IPs to be used by Tekkotsu tools\n");
-     } catch (IOException ex) {
-       // we read what we could
-     }
-     // no real need for parsing and verifying correctness of IPs
-   }
- 
-   void writeConfig() {
-     try {
-       PrintWriter out = new PrintWriter ( new BufferedWriter (
-             new FileWriter (".aibo_ip") ));
-       for (ListIterator iter = IPs.listIterator(); iter.hasNext(); ) {
-         out.println(iter.next());
-       }
-       out.close();
-     } catch (IOException ex) {
-       // can't do much about it
-     }
-   }
- }
--- 0 ----
Index: AiboPup/tools/mon/DogConfigFTP.java
diff -c AiboPup/tools/mon/DogConfigFTP.java:1.1 AiboPup/tools/mon/DogConfigFTP.java:removed
*** AiboPup/tools/mon/DogConfigFTP.java:1.1	Tue Jul  1 05:00:18 2003
--- AiboPup/tools/mon/DogConfigFTP.java	Fri Oct 10 14:37:54 2003
***************
*** 1,67 ****
- import com.enterprisedt.net.ftp.*;
- import java.util.*;
- import java.net.*;
- import java.io.*;
- 
- public class DogConfigFTP {
-   String _ip;
-   int _port;
-   String _user;
-   String _pass;
- 
-   public DogConfigFTP(String ip) {
-     this(ip, 21);
-   }
- 
-   public DogConfigFTP(String ip, int port) {
-     _ip=ip;
-     _port=port;
-     _user="anonymous";
-     _pass="blah@tekkotsu.org";
-   }
- 
-   public DogConfigFTP(String ip, int port, String user, String pass) {
-     this(ip, port);
-     _user=user;
-     _pass=pass;
-   }
-   
-   public boolean test() {
-     return test(500);
-   }
- 
-   public boolean test(int millis) {
-     Socket _ftpSocket=new Socket();
-     try {
-       _ftpSocket.connect(new InetSocketAddress(_ip, _port), millis);
-     } catch (Exception ex) { }
-     if (_ftpSocket.isConnected()) {
-       try { _ftpSocket.close(); } catch (Exception ex) { }
-       return true;
-     } else {
-       return false;
-     }
-   }
- 
-   public String getFile(String remotename) throws FTPException, IOException {
-     FTPClient ftp=new FTPClient(_ip, _port);
-     ftp.login(_user, _pass);
-     ftp.setConnectMode(FTPConnectMode.ACTIVE);
-     ftp.setType(FTPTransferType.ASCII);
-     String ret=new String(ftp.get(remotename));
-     ftp.quit();
-     return ret;
-   }
- 
-   public String getFile(String user, String pass, String remotename)
-       throws FTPException, IOException {
-     _user=user;
-     _pass=pass;
-     return getFile(remotename);
-   }
- 
-   public static void main(String args[]) {
-     System.out.println("This is an internal class - run DogConfig instead");
-     System.exit(0);
-   }
- }
--- 0 ----
Index: AiboPup/tools/mon/EStopGUI.java
diff -c AiboPup/tools/mon/EStopGUI.java:1.5 AiboPup/tools/mon/EStopGUI.java:removed
*** AiboPup/tools/mon/EStopGUI.java:1.5	Tue Jul  8 20:10:57 2003
--- AiboPup/tools/mon/EStopGUI.java	Fri Oct 10 14:37:54 2003
***************
*** 1,117 ****
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.WindowAdapter;
- import java.awt.event.WindowEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- 
- public class EStopGUI extends JFrame implements ActionListener, EStopListener.UpdatedListener {
- 	static int defPort=10053;
- 	JLabel status;
- 	JButton reconnectBut;
- 	EStopPanel estop;
- 	final static ImageIcon carrows = new ImageIcon("images/chasingarrows.png");
- 
- 	static public void main(String s[]) {
- 		int port=defPort;
- 		if(s.length<1)
- 			usage();
- 		if(s.length>1)
- 			port=Integer.parseInt(s[1]);
- 		String[] args=new String[s.length-1];
- 		for(int i=0; i<s.length-1; i++)
- 			args[i-1]=s[i];
- 		JFrame frame=new EStopGUI(s[0],port,args);
- 		frame.addWindowListener(new WindowAdapter() {
- 			public void windowClosing(WindowEvent e) { System.exit(0); }
- 			});
- 	}
- 
- 	public static void usage() {
- 		System.out.println("Usage: java EStopGUI host [port]");
- 		System.out.println("			 if port is not specified, it defaults to "+EStopListener.defPort);
- 		System.exit(2);
- 	}
- 
- 	public EStopGUI(String host, int port, String args[]) {
- 		super("TekkotsuMon: EStop Controller");
- 		init(new EStopListener(host,port));
- 	}
- 
- 	public EStopGUI(EStopListener comm) {
- 		super();
- 		init(comm);
- 	}
- 
- 	protected void init(EStopListener comm) {
- 		int spacer_size=10;
- 		Container root = getContentPane();
- 		root.setLayout(new BorderLayout());
- 		root.add(estop=new EStopPanel(comm),BorderLayout.CENTER);
- 		root.add(Box.createVerticalStrut(spacer_size),BorderLayout.NORTH);
- 		root.add(Box.createHorizontalStrut(spacer_size),BorderLayout.EAST);
- 		root.add(Box.createHorizontalStrut(spacer_size),BorderLayout.WEST);
- 		
- 		{
- 			Box statusbox=Box.createVerticalBox();
- 			statusbox.add(Box.createVerticalStrut(spacer_size));
- 			{
- 				JSeparator sep=new JSeparator(SwingConstants.HORIZONTAL);
- 				statusbox.add(sep);
- 			}
- 			statusbox.add(Box.createVerticalStrut(spacer_size-2));
- 			{
- 				JPanel tmp=new JPanel(new BorderLayout());
- 				status=new JLabel("Connecting...");
- 				estopUpdated(comm);
- 				tmp.add(Box.createHorizontalStrut(spacer_size),BorderLayout.WEST);
- 				tmp.add(status,BorderLayout.CENTER);
- 				{
- 					Box tmp2=Box.createHorizontalBox();
- 					reconnectBut=new JButton(carrows);
- 					reconnectBut.setPreferredSize(new Dimension(carrows.getIconWidth(),carrows.getIconHeight()));
- 					reconnectBut.addActionListener(this);
- 					reconnectBut.setToolTipText("Drop current connection and try again.");
- 					tmp2.add(reconnectBut);
- 					tmp2.add(Box.createHorizontalStrut(spacer_size));
- 					tmp.add(tmp2,BorderLayout.EAST);
- 				}
- 				statusbox.add(tmp);
- 			}
- 			statusbox.add(Box.createVerticalStrut(spacer_size));
- 			root.add(statusbox, BorderLayout.SOUTH);
- 		}
- 		addWindowListener(new CloseEStopAdapter(this));
- 		estop.setPreferredSize(new Dimension(150,150));
- 		pack();
- 		estop.setPreferredSize(null);
- 		estop.comm.addUpdatedListener(this);
- 		show();
- 	}
- 
- 	public void actionPerformed(ActionEvent evt) {
- 		if(evt.getSource()==reconnectBut) {
- 			estop.close();
- 			estop.open();
- 		}
- 	}
- 	class CloseEStopAdapter extends WindowAdapter {
- 		EStopGUI gui;
- 		CloseEStopAdapter(EStopGUI gui) {this.gui=gui;}
- 		public void windowClosing(WindowEvent e) {
- 			gui.close();
- 		}
- 	}
- 	public void close() {
- 		estop.remove();
- 		estop.comm.removeUpdatedListener(this);
- 		dispose();
- 	}
- 	public void estopUpdated(EStopListener l) {
- 		if(l.isConnected()) {
- 			status.setText("Connected.");
- 		} else {
- 			status.setText("Reconnecting...");
- 		}
- 	}
- }
--- 0 ----
Index: AiboPup/tools/mon/EStopListener.java
diff -c AiboPup/tools/mon/EStopListener.java:1.3 AiboPup/tools/mon/EStopListener.java:removed
*** AiboPup/tools/mon/EStopListener.java:1.3	Tue Jul  8 20:10:57 2003
--- AiboPup/tools/mon/EStopListener.java	Fri Oct 10 14:37:54 2003
***************
*** 1,101 ****
- import java.lang.Integer;
- import java.lang.String;
- import java.io.PrintStream;
- import java.io.InputStream;
- import java.net.Socket;
- import java.util.Vector;
- import java.net.SocketException;
- 
- public class EStopListener extends TCPListener {
-   // The command output stream
- 	static int defPort=10053;
-   PrintStream out;
- 	boolean stopped=true;
- 	boolean data=false;
-   Socket mysock;
- 	Vector listeners=new Vector();
- 	
- 	public interface UpdatedListener {
- 		public void estopUpdated(EStopListener mc);
- 	}
- 
- 	void addUpdatedListener(UpdatedListener mcl) { listeners.add(mcl); }
- 	void removeUpdatedListener(UpdatedListener mcl) {
- 		listeners.remove(mcl);
- 		if(listeners.size()==0)
- 			kill();
- 	}
- 	void fireUpdated() {
- 		data=true;
- 		for(int i=0;i<listeners.size();i++)
- 			((UpdatedListener)listeners.get(i)).estopUpdated(this);
- 	}
- 
-   // Connect to control socket
-   void connected(Socket socket) {
-     mysock = socket;
- 		fireUpdated();
-     try {
-       out = new PrintStream(mysock.getOutputStream());
- 			out.print("refresh\n");
- 			InputStream sin=socket.getInputStream();
- 			while (true) {
- 				String msgtype=readLine(sin);
- 				if(!_isConnected) break;
- 				if(msgtype.equals("on")) {
- 					if(!stopped) {
- 						stopped=true;
- 						fireUpdated();
- 					}
- 				} else if(msgtype.equals("off")) {
- 					if(stopped) {
- 						stopped=false;
- 						fireUpdated();
- 					}
- 				} else {
- 					System.out.println("Estop Unknown message: "+msgtype);
- 				}
- 			}
-     } catch(Exception e) {if((SocketException)e==null) e.printStackTrace();}
- 
- 		try { socket.close(); } catch (Exception ex) { }
- 
- 		_isConnected=false;
- 		fireUpdated();
- 		//The sleep is to get around the socket still listening after being closed thing
- 		if(!destroy)
- 			System.out.println("EStopGUI - connection closed... reconnect after 5 seconds");
- 		try { Thread.sleep(5000); } catch (Exception ex) {}
-   }
- 
-   // Disconnect from control socket
-   public void close() {
- 		//    try { mysock.close(); } catch(Exception e) {}
-     //_isConnected = false;
-     super.close();
- 		//we'll fire an event to the listeners when the readLine in connected finally fails
-   }
- 
- 	public void setEStop(boolean b) {
- 		if(b!=stopped) {
- 			out.print(b?"stop\n":"start\n");
- 		}
- 	}
- 
- 	public boolean getEStop() {
- 		return stopped;
- 	}
- 
- 	public void toggleEStop() {
- 		setEStop(!stopped);
- 	}
- 
-   // Some state inquiry functions
-   public boolean hasData() { return data; }
-   public boolean isConnected() { return _isConnected; }
- 
-   // Constructors
-   public EStopListener() { super(); }
-   public EStopListener(int port) { super(port); }
-   public EStopListener(String host, int port) { super(host, port); }
- }
--- 0 ----
Index: AiboPup/tools/mon/EStopPanel.java
diff -c AiboPup/tools/mon/EStopPanel.java:1.6 AiboPup/tools/mon/EStopPanel.java:removed
*** AiboPup/tools/mon/EStopPanel.java:1.6	Tue Jul  8 20:10:58 2003
--- AiboPup/tools/mon/EStopPanel.java	Fri Oct 10 14:37:54 2003
***************
*** 1,187 ****
- import javax.swing.JPanel;
- import javax.swing.JFrame;
- import java.awt.event.WindowAdapter;
- import java.awt.event.WindowEvent;
- import java.awt.geom.Ellipse2D;
- import java.awt.geom.Rectangle2D;
- import java.awt.*;
- import java.awt.event.MouseEvent;
- import java.awt.event.InputEvent;
- 
- public class EStopPanel extends JPanel implements EStopListener.UpdatedListener {
- 	EStopListener comm;
- 	int mode;
- 	static final int STOPPED_MODE=0;
- 	static final int NOTSTOPPED_MODE=1;
- 	static final int DISABLED_MODE=2;
- 	static final int MAX_MODE=3;
- 	Shape shape[] = new Shape[MAX_MODE];
- 	BasicStroke stroke[] = new BasicStroke[MAX_MODE];
- 	Paint fill[] = new Color[MAX_MODE];
- 	Paint line[] = new Color[MAX_MODE];
- 	Paint textFill[] = new Color[MAX_MODE];
- 	String text[] = new String[MAX_MODE];
- 	float textSize[] = new float[MAX_MODE];
- 	static final int res=1000;
- 	
- 	static public void main(String s[]) {
- 		int port=EStopListener.defPort;
- 		if(s.length<1)
- 			usage();
- 		if(s.length>1)
- 			port=Integer.parseInt(s[1]);
- 		String[] args=new String[s.length-1];
- 		for(int i=0; i<s.length-1; i++)
- 			args[i-1]=s[i];
- 		JFrame frame=new JFrame("TekkotsuMon: EStop");
- 		frame.setSize(new Dimension(200, 200)); 
- 		EStopPanel estop=new EStopPanel(new EStopListener(s[0],port));
- 		frame.getContentPane().add(estop);
- 		frame.addWindowListener(new WindowAdapter() {
- 				public void windowClosing(WindowEvent e) { System.exit(0); } });
- 		frame.show();
- 	}
- 
- 	public static void usage() {
- 		System.out.println("Usage: java EStopPanel host [port]");
- 		System.out.println("			 if port is not specified, it defaults to "+EStopListener.defPort);
- 		System.exit(2);
- 	}
- 
- 	public EStopPanel(EStopListener comm) {
- 		super();
- 		
- 		this.comm=comm;
- 		mode=comm.isConnected()?(comm.getEStop()?STOPPED_MODE:NOTSTOPPED_MODE):DISABLED_MODE;
- 		setEnabled(mode!=DISABLED_MODE);
- 		comm.addUpdatedListener(this);
- 		
- 		shape[NOTSTOPPED_MODE]=makeStopSign();
- 		stroke[NOTSTOPPED_MODE]=new BasicStroke(res/30);
- 		fill[NOTSTOPPED_MODE]=Color.RED;
- 		line[NOTSTOPPED_MODE]=Color.BLACK;
- 		text[NOTSTOPPED_MODE]="STOP";
- 		textFill[NOTSTOPPED_MODE]=Color.WHITE;
- 		textSize[NOTSTOPPED_MODE]=3.125f;
- 
- 		shape[STOPPED_MODE]=new Ellipse2D.Float(0,0,res,res);
- 		stroke[STOPPED_MODE]=new BasicStroke(res/30);
- 		fill[STOPPED_MODE]=Color.GREEN;
- 		line[STOPPED_MODE]=Color.BLACK;
- 		text[STOPPED_MODE]="GO";
- 		textFill[STOPPED_MODE]=Color.BLACK;
- 		textSize[STOPPED_MODE]=2.5f;
- 
- 		shape[DISABLED_MODE]=new Rectangle2D.Float(res/8,res/8,res*3/4,res*3/4);
- 		stroke[DISABLED_MODE]=new BasicStroke(0);
- 		fill[DISABLED_MODE]=null;
- 		line[DISABLED_MODE]=null;
- 		text[DISABLED_MODE]="><";
- 		textFill[DISABLED_MODE]=Color.BLACK;
- 		textSize[DISABLED_MODE]=1.5f;
- 		
- 		setToolTipText("Toggle Emergency Stop; alt-click to open new window");
- 		enableEvents(AWTEvent.MOUSE_EVENT_MASK);
- 	}
- 
- 	protected Shape makeStopSign() {
- 		int x[] = new int[10];
- 		int y[] = new int[10];
- 		double l=res*Math.tan(22.5/180.0*Math.PI);
- 		x[0]=res/2;
- 		y[0]=0;
- 		x[1]=(int)((res-l)/2+l);
- 		y[1]=0;
- 		x[2]=res;
- 		y[2]=(int)((res-l)/2);
- 		x[3]=res;
- 		y[3]=x[1];
- 		x[4]=x[1];
- 		y[4]=res;
- 		x[5]=y[2];
- 		y[5]=res;
- 		x[6]=0;
- 		y[6]=y[3];
- 		x[7]=0;
- 		y[7]=y[2];
- 		x[8]=y[2];
- 		y[8]=y[0];
- 		x[9]=x[0];
- 		y[9]=y[0];
- 		return new Polygon(x,y,10);
- 	}
- 	
- 	public void close() {
- 		comm.kill();
- 		remove();
- 	}
- 	
- 	public void remove() {
- 		comm.removeUpdatedListener(this);
- 	}
- 	
- 	public void open() {
- 		comm.addUpdatedListener(this);
- 		comm.startThread();
- 	}
- 
- 	public void estopUpdated(EStopListener l) {
- 		if(l.isConnected()) {
- 			if(l.getEStop())
- 				mode=STOPPED_MODE;
- 			else
- 				mode=NOTSTOPPED_MODE;
- 		} else
- 			mode=DISABLED_MODE;
- 		setEnabled(l.isConnected());
- 		repaint();
- 	}
- 	
- 	public void processMouseEvent(MouseEvent e) {
- 		if(e.getID()==MouseEvent.MOUSE_RELEASED) {
- 			if((e.getModifiersEx()&InputEvent.ALT_DOWN_MASK)!=0) {
- 				EStopGUI es=new EStopGUI(comm);
- 			} else {
- 				if(isEnabled()) {
- 					comm.toggleEStop();
- 				}
- 			}
- 		}
- 		super.processMouseEvent(e);
- 	}
- 
- 	public void paint(Graphics graphics) {
- 		super.paint(graphics);
- 		Graphics2D g=(Graphics2D)graphics;
- 		g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
- 		int w=getWidth();
- 		int h=getHeight();
- 		int cons=w>h?h:w;
- 		int ex=(w>h?w:h)-cons;
- 		double scale=cons/(double)(res+stroke[mode].getLineWidth());
- 		if(w>h)
- 			g.translate(ex/2.0,0);
- 		else
- 			g.translate(0,ex/2.0);
- 		g.translate(stroke[mode].getLineWidth()/2*scale,stroke[mode].getLineWidth()/2*scale);
- 		g.scale(scale,scale);
- 		if(fill[mode]!=null) {
- 			g.setPaint(fill[mode]);
- 			g.fill(shape[mode]);
- 		}
- 		if(line[mode]!=null) {
- 			g.setPaint(line[mode]);
- 			g.setStroke(stroke[mode]);
- 			g.draw(shape[mode]);
- 		}
- 		if(textFill[mode]!=null && cons/textSize[mode]>7) {
- 			g.setPaint(textFill[mode]);
- 			g.setFont(new Font("Arial",Font.BOLD,(int)(res/textSize[mode])));
- 			FontMetrics fm=g.getFontMetrics();
- 			float fw=(float)fm.getStringBounds(text[mode],g).getWidth();
- 			float fa=fm.getLineMetrics(text[mode],g).getAscent();
- 			float fd=fm.getLineMetrics(text[mode],g).getDescent();
- 			g.drawString(text[mode],(res-fw)/2.0f,(res-fd+fa)/2.0f);
- 		}
- 	}
- }
--- 0 ----
Index: AiboPup/tools/mon/HeadPointGUI.java
diff -c AiboPup/tools/mon/HeadPointGUI.java:1.1 AiboPup/tools/mon/HeadPointGUI.java:removed
*** AiboPup/tools/mon/HeadPointGUI.java:1.1	Sun Jul  6 21:02:25 2003
--- AiboPup/tools/mon/HeadPointGUI.java	Fri Oct 10 14:37:54 2003
***************
*** 1,333 ****
- import javax.swing.*;
- import java.awt.*;
- import java.awt.geom.*;
- import java.awt.event.*;
- import javax.swing.event.*;
- 
- public class HeadPointGUI extends JFrame implements PointPick.PointPickedListener, ChangeListener, ActionListener, MouseListener, HeadPointListener.HeadPointUpdatedListener {
- 	static int defPort=10052;
- 	PointPick pp;
- 	JSlider tslide;
- 	JSlider pslide;
- 	JSlider rslide;
- 	JButton stopBut;
- 	JRadioButton horizRollBut;
- 	JRadioButton horizPanBut;
- 	boolean horizButFake=false;
- 	JCheckBox resetOnRelease;
- 	JLabel status;
- 	JButton reconnectBut;
- 	HeadPointListener comm;
- 	static int slidermax=10000;
- 	final static ImageIcon carrows = new ImageIcon("images/chasingarrows.png");
- 
- 	static public void main(String s[]) {
- 		int port=defPort;
- 		if(s.length<1)
- 			usage();
- 		if(s.length>1)
- 			port=Integer.parseInt(s[1]);
- 		String[] args=new String[s.length-1];
- 		for(int i=0; i<s.length-1; i++)
- 			args[i-1]=s[i];
- 		JFrame frame=new HeadPointGUI(s[0],port,args);
- 		/*		frame.addWindowListener(new WindowAdapter() {
- 			public void windowClosing(WindowEvent e) { System.exit(0); }
- 			});*/
- 	}
- 	
- 	public static void usage() {
- 		System.out.println("Usage: java HeadPointGUI host [port]");
- 		System.out.println("       if port is not specified, it defaults to: "+defPort);
- 		System.exit(2);
- 	}
- 		
- 	public HeadPointGUI(String host, int port, String args[]) {
- 		super("TekkotsuMon: Head Pointer Control");
- 		pack();
- 		comm=new HeadPointListener(host,port);
- 		comm.addHeadPointUpdatedListener(this);
- 		show();
- 	}
- 
- 	public void close() {
- 		comm.kill();
- 		dispose();
- 	}
- 	
- 	class CloseHeadPointAdapter extends WindowAdapter {
- 		HeadPointGUI gui;
- 		CloseHeadPointAdapter(HeadPointGUI gui) {this.gui=gui;}
- 		public void windowClosing(WindowEvent e) {
- 			gui.close();
- 		}
- 	}
- 
- 	public void pointPicked(Point2D.Float p, MouseEvent e, PointPick pp) {
- 		boolean isBut2=(e.getModifiersEx()&MouseEvent.BUTTON3_DOWN_MASK)==MouseEvent.BUTTON3_DOWN_MASK;
- 		if(!horizButFake && isBut2) {
- 			if(horizPanBut.isSelected())
- 				horizRollBut.setSelected(true);
- 			else
- 				horizPanBut.setSelected(true);
- 			horizButFake=isBut2;
- 		}
- 		if(horizRollBut.isSelected())
- 			rslide.setValue((int)(slidermax*p.x));
- 		if(horizPanBut.isSelected())
- 			pslide.setValue((int)(slidermax*p.x));
- 		tslide.setValue((int)(slidermax*p.y));
- 	}
- 
- 	public void headPointUpdated(HeadPointListener comm) {
- 		if(status!=null) {
- 			pp.setEnabled(comm._isConnected);
- 			tslide.setEnabled(comm._isConnected);
- 			pslide.setEnabled(comm._isConnected);
- 			rslide.setEnabled(comm._isConnected);
- 			stopBut.setEnabled(comm._isConnected);
- 			if(comm._isConnected)
- 				status.setText("Connected.");
- 			else
- 				status.setText("Reconnecting...");
- 		}
- 	}
- 
- 	public void mouseClicked(MouseEvent e) {}
- 	public void mouseEntered(MouseEvent e) {}
- 	public void mouseExited(MouseEvent e) {}
- 	public void mousePressed(MouseEvent e) {
- 		boolean isBut2=(e.getModifiersEx()&MouseEvent.BUTTON3_DOWN_MASK)==MouseEvent.BUTTON3_DOWN_MASK;
- 		if(!horizButFake && isBut2) {
- 			if(horizPanBut.isSelected())
- 				horizRollBut.setSelected(true);
- 			else
- 				horizPanBut.setSelected(true);
- 			horizButFake=isBut2;
- 			updatePP();
- 		}
- 	}
- 	public void mouseReleased(MouseEvent e) {
- 		boolean isBut1=(e.getModifiersEx()&MouseEvent.BUTTON1_DOWN_MASK)==MouseEvent.BUTTON1_DOWN_MASK;
- 		boolean isBut2=(e.getModifiersEx()&MouseEvent.BUTTON3_DOWN_MASK)==MouseEvent.BUTTON3_DOWN_MASK;
- 		if(horizButFake && !isBut2) {
- 			if(horizPanBut.isSelected())
- 				horizRollBut.setSelected(true);
- 			else
- 				horizPanBut.setSelected(true);
- 			horizButFake=isBut2;
- 			updatePP();
- 		}
- 		if(!isBut1 && !isBut2) {
- 			if(resetOnRelease.isSelected())
- 				stopBut.doClick();
- 		}
- 	}
- 
- 	public void stateChanged(ChangeEvent e) {
- 		if(e.getSource()==tslide) {
- 			comm.sendCommand("t",tslide.getValue()/(float)slidermax);
- 			pp.doSetPoint(pp.getXValue(),tslide.getValue()/(float)slidermax);
- 		} else if(e.getSource()==pslide) {
- 			comm.sendCommand("p",-pslide.getValue()/(float)slidermax);
- 			if(horizPanBut.isSelected())
- 				pp.doSetPoint(pslide.getValue()/(float)slidermax,pp.getYValue());
- 		} else if(e.getSource()==rslide) {
- 			// Rotation is both fast and sensitive, so we'll exponentiate it to
- 			// drag out the low end without sacrificing the high end
- 			comm.sendCommand("r",rslide.getValue()/(float)slidermax);
- 			float tmp=pp.getYValue();
- 			if(horizRollBut.isSelected())
- 				pp.doSetPoint(rslide.getValue()/(float)slidermax,pp.getYValue());
- 		}
- 	}
- 
- 	public void actionPerformed(ActionEvent e) {
- 		if(e.getSource()==stopBut) {
- 			tslide.setValue(0);
- 			pslide.setValue(0);
- 			rslide.setValue(0);
- 		} else if(e.getSource()==horizRollBut) {
- 			updatePP();
- 		} else if(e.getSource()==horizPanBut) {
- 			updatePP();
- 		} else if(e.getSource()==reconnectBut) {
- 			int port=comm._port;
- 			String addr=comm._host;
- 			comm.kill();
- 			comm.removeHeadPointUpdatedListener(this);
- 			comm = new HeadPointListener(comm._host,comm._port);
- 			comm.addHeadPointUpdatedListener(this);
- 		}
- 	}
- 	
- 	public void updatePP() {
- 		float x=0;
- 		if(horizPanBut.isSelected())
- 			x=pslide.getValue()/(float)slidermax;
- 		else if(horizRollBut.isSelected())
- 			x=rslide.getValue()/(float)slidermax;
- 		pp.doSetPoint(x,tslide.getValue()/(float)slidermax);
- 	}
- 
- 	public void frameInit() {
- 		super.frameInit();
- 		
- 		int strutsize=10;
- 		int sepsize=5;
- 		getContentPane().setLayout(new BorderLayout());
- 		getContentPane().add(Box.createHorizontalStrut(strutsize),BorderLayout.EAST);
- 		getContentPane().add(Box.createHorizontalStrut(strutsize),BorderLayout.WEST);
- 		getContentPane().add(Box.createVerticalStrut(strutsize),BorderLayout.NORTH);
- 		JPanel p=new JPanel(new SquareRightLayout());
- 		p.setLayout(new SquareRightLayout());
- 		pp=new PointPick(false);
- 		pp.addPointPickedListener(this);
- 		pp.addMouseListener(this);
- 		p.add(pp,SquareRightLayout.SQUARE);
- 		Box tmp=Box.createHorizontalBox();
- 		tmp.add(Box.createHorizontalStrut(strutsize));
- 		JSeparator sep;
- 		sep=new JSeparator(SwingConstants.VERTICAL);
- 		sep.setMaximumSize(new Dimension(sepsize,slidermax));
- 		tmp.add(sep);
- 		tmp.add(Box.createHorizontalStrut(strutsize));
- 		{
- 			Box tmp2=Box.createVerticalBox();
- 			tmp2.add(Box.createVerticalGlue());
- 			int labwidth=45;
- 			tmp2.add(new JLabel("Tilt:"));
- 			{
- 				Box tmp3=Box.createHorizontalBox();
- 				tslide=new JSlider(-slidermax,slidermax,0);
- 				tslide.addChangeListener(this);
- 				JLabel lab;
- 				lab=new JLabel("Down");
- 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
- 				lab.setHorizontalAlignment(SwingConstants.RIGHT);
- 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
- 				tmp3.add(lab);
- 				tmp3.add(tslide);
- 				lab=new JLabel("Up");
- 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
- 				lab.setHorizontalAlignment(SwingConstants.LEFT);
- 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
- 				tmp3.add(lab);
- 				//tmp3.add(new JButton("Zero"));
- 				tmp3.setAlignmentX(0);
- 				tmp2.add(tmp3);
- 			}
- 			tmp2.add(Box.createVerticalStrut(strutsize));
- 			tmp2.add(new JLabel("Pan:"));
- 			{
- 				Box tmp3=Box.createHorizontalBox();
- 				pslide=new JSlider(-slidermax,slidermax,0);
- 				pslide.addChangeListener(this);
- 				JLabel lab;
- 				lab=new JLabel("Left");
- 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
- 				lab.setHorizontalAlignment(SwingConstants.RIGHT);
- 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
- 				tmp3.add(lab);
- 				tmp3.add(pslide);
- 				lab=new JLabel("Right");
- 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
- 				lab.setHorizontalAlignment(SwingConstants.LEFT);
- 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
- 				tmp3.add(lab);
- 				//tmp3.add(new JButton("Zero"));
- 				tmp3.setAlignmentX(0);
- 				tmp2.add(tmp3);
- 			}
- 			tmp2.add(Box.createVerticalStrut(strutsize));
- 			tmp2.add(new JLabel("Roll:"));
- 			{
- 				Box tmp3=Box.createHorizontalBox();
- 				rslide=new JSlider(-slidermax,slidermax,0);
- 				rslide.addChangeListener(this);
- 				JLabel lab;
- 				lab=new JLabel("Counter");
- 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
- 				lab.setHorizontalAlignment(SwingConstants.RIGHT);
- 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
- 				tmp3.add(lab);
- 				tmp3.add(rslide);
- 				lab=new JLabel("Clock");
- 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
- 				lab.setHorizontalAlignment(SwingConstants.LEFT);
- 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
- 				tmp3.add(lab);
- 				//tmp3.add(new JButton("Zero"));
- 				tmp3.setAlignmentX(0);
- 				tmp2.add(tmp3);
- 			}
- 			tmp2.add(Box.createVerticalStrut(strutsize));
- 			{
- 				Box tmp3=Box.createHorizontalBox();
- 				tmp3.add(Box.createHorizontalGlue());
- 				stopBut=new JButton("Center");
- 				stopBut.addActionListener(this);
- 				rootPane.setDefaultButton(stopBut);
- 				tmp3.add(stopBut);
- 				tmp3.add(Box.createHorizontalGlue());
- 				tmp3.setAlignmentX(0);
- 				tmp2.add(tmp3);
- 			}
- 			tmp2.add(Box.createVerticalStrut(strutsize));
- 			ButtonGroup bg = new ButtonGroup();
- 			horizPanBut=new JRadioButton("Horizontal is Pan");
- 			horizPanBut.addActionListener(this);
- 			horizPanBut.setSelected(true);
- 			bg.add(horizPanBut);
- 			tmp2.add(horizPanBut);
- 			horizRollBut=new JRadioButton("Horizontal is Roll");
- 			horizRollBut.addActionListener(this);
- 			bg.add(horizRollBut);
- 			tmp2.add(horizRollBut);
- 			tmp2.add(Box.createVerticalStrut(strutsize));
- 			tmp2.add(resetOnRelease=new JCheckBox("Center on release")); 
- 			tmp2.add(Box.createVerticalGlue());
- 			tmp.add(tmp2);
- //			Dimension d=tmp2.getMinimumSize();
- //			System.out.println(d);
- //			pp.setSize(d);
- //			pp.setMinimumSize(d);
- //			pp.setPreferredSize(d);
- //			pp.setMaximumSize(d);
- 		}
- 		p.add(tmp,SquareRightLayout.RIGHT);
- 		getContentPane().add(p,BorderLayout.CENTER);
- 		{
- 			Box tmp2=Box.createHorizontalBox();
- 			tmp2.add(Box.createHorizontalStrut(strutsize));
- 			{
- 				Box tmp3=Box.createVerticalBox();
- 				tmp3.add(Box.createVerticalStrut(strutsize));
- 				tmp3.add(new JSeparator());
- 				tmp3.add(Box.createVerticalStrut(strutsize-sepsize));
- 				{
- 					Box tmp4=Box.createHorizontalBox();
- 					tmp4.add(status=new JLabel("Connecting..."));
- 					tmp4.add(Box.createHorizontalGlue());
- 					reconnectBut=new JButton(carrows);
- 					reconnectBut.setPreferredSize(new Dimension(carrows.getIconWidth(),carrows.getIconHeight()));
- 					reconnectBut.addActionListener(this);
- 					reconnectBut.setToolTipText("Drop current connection and try again.");
- 					tmp4.add(reconnectBut);
- 					tmp3.add(tmp4);
- 				}
- 				tmp3.add(Box.createVerticalStrut(strutsize));
- 				tmp2.add(tmp3);
- 			}
- 			tmp2.add(Box.createHorizontalStrut(strutsize));
- 			getContentPane().add(tmp2,BorderLayout.SOUTH);
- 		}
- 
- 		pp.setEnabled(false);
- 		tslide.setEnabled(false);
- 		pslide.setEnabled(false);
- 		rslide.setEnabled(false);
- 		stopBut.setEnabled(false);
- 		addWindowListener(new CloseHeadPointAdapter(this));
- 	}
- }
--- 0 ----
Index: AiboPup/tools/mon/HeadPointListener.java
diff -c AiboPup/tools/mon/HeadPointListener.java:1.1 AiboPup/tools/mon/HeadPointListener.java:removed
*** AiboPup/tools/mon/HeadPointListener.java:1.1	Sun Jul  6 21:02:26 2003
--- AiboPup/tools/mon/HeadPointListener.java	Fri Oct 10 14:37:54 2003
***************
*** 1,114 ****
- // Sends "HeadPoint" command data from TekkotsuMon to the AIBO.
- import java.lang.Integer;
- import java.lang.String;
- import java.lang.System;
- import java.io.OutputStream;
- import java.io.InputStream;
- import java.net.Socket;
- import javax.swing.Timer;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.util.Vector;
- import java.net.SocketException;
- 
- // The class itself. Brilliant that even though it does the talking,
- // it extends TCP*Listener*.
- public class HeadPointListener extends TCPListener implements ActionListener {
-   // The command output stream
-   OutputStream out;
-   Socket mysock;
- 	double tilt=0;
- 	double pan=0;
- 	double roll=0;
- 	Vector listeners=new Vector();
- 	
- 	public interface HeadPointUpdatedListener {
- 		public void headPointUpdated(HeadPointListener mc);
- 	}
- 
- 	void addHeadPointUpdatedListener(HeadPointUpdatedListener mcl) { listeners.add(mcl); }
- 	void removeHeadPointUpdatedListener(HeadPointUpdatedListener mcl) { listeners.remove(mcl); }
- 	void fireHeadPointUpdated() {
- 		for(int i=0;i<listeners.size();i++)
- 			((HeadPointUpdatedListener)listeners.get(i)).headPointUpdated(this);
- 	}
- 
-   // Connect to control socket
-   void connected(Socket socket) {
-     mysock = socket;
- 		fireHeadPointUpdated();
-     try {
-       out = mysock.getOutputStream();
- 			InputStream sin=socket.getInputStream();
- 			while (true) { //not that we expect input, but will block until the socket is closed
- 				String msgtype=readLine(sin);
- 				if(!_isConnected) break;
- 			}
-     } catch(Exception e) {if((SocketException)e==null) e.printStackTrace();}
- 
- 		try { socket.close(); } catch (Exception ex) { }
- 
- 		_isConnected=false;
- 		fireHeadPointUpdated();
- 		//The sleep is to get around the socket still listening after being closed thing
- 		if(!destroy)
- 			System.out.println("HeadPoint - connection closed... reconnect after 5 seconds");
- 		try { Thread.sleep(5000); } catch (Exception ex) {}
-   }
- 
-   // Disconnect from control socket
-   public void close() {
- 		//    try { mysock.close(); } catch(Exception e) {}
-     //_isConnected = false;
-     super.close();
- 		//we'll fire an event to the listeners when the readLine in connected finally fails
-   }
- 
- 	public void actionPerformed(ActionEvent e) {
- 		if(_isConnected) {
- 			sendCommand("t",tilt);
- 			sendCommand("p",pan);
- 			sendCommand("r",roll);
- 		}
- 	}
- 
-   // Send a headPoint command
-   public void sendCommand(String command, double param) {
- 		
-     // Extract command byte
-     byte cmdbytes[] = command.getBytes();
- 		if(cmdbytes[0]=='t')
- 			tilt=param;
- 		else if(cmdbytes[0]=='p')
- 			pan=param;
- 		else if(cmdbytes[0]=='r')
- 			roll=param;
- 
-     // Construct the command sequence
-     byte sequence[] = new byte[5];
-     // The commmand byte is the first byte in cmdbytes. The remaining
-     // four bytes belong to the parameter. We have to convert the parameter
-     // (which we send as a float, not a double) to MIPS byte order thanks to
-     // (ahem) prior design decisions.
-     sequence[0] = cmdbytes[0];
-     int pbits = Float.floatToIntBits((float) param);
-     Integer i;
-     i = new Integer((pbits >> 24) & 0xff); sequence[4] = i.byteValue();
-     i = new Integer((pbits >> 16) & 0xff); sequence[3] = i.byteValue();
-     i = new Integer((pbits >>  8) & 0xff); sequence[2] = i.byteValue();
-     i = new Integer(pbits & 0xff);	   sequence[1] = i.byteValue();
-     // Now write the whole command.
-     try {
-       out.write(sequence, 0, 5);
-     } catch(Exception e) { close(); return; }
-   }
- 
-   // Some state inquiry functions
-   public boolean hasData() { return false; }
-   public boolean isConnected() { return _isConnected; }
- 
-   // Constructors
-   public HeadPointListener() { super(); }
-   public HeadPointListener(int port) { super(port); }
-   public HeadPointListener(String host, int port) { super(host, port); }
- }
--- 0 ----
Index: AiboPup/tools/mon/ImageSequenceWriterThread.java
diff -c AiboPup/tools/mon/ImageSequenceWriterThread.java:1.3 AiboPup/tools/mon/ImageSequenceWriterThread.java:removed
*** AiboPup/tools/mon/ImageSequenceWriterThread.java:1.3	Fri Jun 27 02:03:57 2003
--- AiboPup/tools/mon/ImageSequenceWriterThread.java	Fri Oct 10 14:37:54 2003
***************
*** 1,141 ****
- import java.awt.event.*;
- import javax.swing.*;
- import java.lang.String;
- import java.util.LinkedList;
- import java.awt.*;
- import javax.imageio.ImageIO;
- import java.awt.image.BufferedImage;
- import java.awt.image.IndexColorModel;
- import java.awt.image.DataBuffer;
- import java.util.Date;
- import java.io.PrintWriter;
- import java.io.FileOutputStream;
- 
- public class ImageSequenceWriterThread extends Thread implements VisionUpdatedListener {
- 	String dir;
- 	String pre;
- 	String post;
- 	String fmt;
- 	LinkedList imgBufs=new LinkedList();
- 	int dig;
- 	LinkedList q=new LinkedList();
- 	int count=0;
- 	VisionListener listen;
- 	boolean stopping=false;
- 	JButton but;
- 
- 	public ImageSequenceWriterThread(VisionListener l, JButton reenableBut) {
- 		super("ImageSequenceWriter");
- 		int initbufsize=500;
- 		but=reenableBut;
- 		listen=l;
- 		l.addListener(this);
- 		BufferedImage i=l.getImage();
- 		if(i.getColorModel().getTransferType()!=DataBuffer.TYPE_BYTE)
- 			for(int j=0;j<initbufsize;j++)
- 				imgBufs.add(new BufferedImage(i.getWidth(),i.getHeight(),i.getType()));
- 		else {
- 			for(int j=0;j<initbufsize;j++)
- 				imgBufs.add(new BufferedImage(i.getWidth(),i.getHeight(),i.getType(),(IndexColorModel)i.getColorModel()));
- 		}
- 	}
- 
- 	public void setDirectory(String directory) {
- 		dir=directory;
- 	}
- 
- 	public void setName(String prepend, int digits, String append, String format) {
- 		pre=prepend;
- 		post=append;
- 		fmt=format;
- 		dig=digits;
- 	}
- 
- 	public void visionUpdated(VisionListener l) {
- 		push(l.getImage(),l.getTimeStamp());
- 	}
- 
- 	public void push(BufferedImage i, Date t) {
- 		BufferedImage i2;
- 		if(imgBufs.size()>0)
- 			i2=(BufferedImage)imgBufs.removeFirst();
- 		else {
- 			if(i.getColorModel().getTransferType()!=BufferedImage.TYPE_BYTE_INDEXED)
- 				i2=new BufferedImage(i.getWidth(),i.getHeight(),i.getType());
- 			else
- 				i2=new BufferedImage(i.getWidth(),i.getHeight(),i.getType(),(IndexColorModel)i.getColorModel());
- 		}
- 		i.copyData(i2.getRaster());
- 		synchronized(q) {
- 			q.addLast(i2);
- 			q.addLast(t);
- 		}
- 	}
- 
- 	public void run() {
- 		String tmp=null;
- 		PrintWriter log;
- 		try {
- 			log=new PrintWriter(new FileOutputStream(dir+pre+post+".txt"));
- 		} catch(Exception ex) { ex.printStackTrace(); return; }
- 		Date start=null;
- 		try {
- 			while(true) {
- 				while(q.size()>0) {
- 					if(interrupted()) {
- 						if(!stopping) {
- 							stopping=true;
- 							if(but!=null) {
- 								but.setEnabled(false);
- 								tmp=but.getText();
- 								but.setText("Writing...");
- 							}
- 							listen.removeListener(this);
- 						} else { //second interrupt... die!
- 							break;
- 						}
- 					}
- 					BufferedImage i;
- 					Date t;
- 					synchronized(q) {
- 						i=(BufferedImage)q.removeFirst();
- 						t=(Date)q.removeFirst();
- 					}
- 					if(start==null)
- 						start=t;
- 					long dt=t.getTime()-start.getTime();
- 					String name=getFileName(dt);
- 					log.println(name+"\t"+dt);
- 					ImageIO.write(i,fmt,new FileOutputStream(dir+name));
- 					imgBufs.addLast(i);
- 					count++;
- 				}
- 				if(stopping)
- 					break;
- 				sleep(1000/25);
- 			}
- 		} catch(Exception ex) {}
- 		log.close();
- 		if(but!=null && tmp!=null) {
- 			but.setEnabled(true);
- 			if(but.getText().compareTo("Writing...")==0)
- 				but.setText(tmp);
- 		}
- 	}
- 
- 	protected String getFileName(long dt) {
- 		String ans=pre;
- 		long c=count;
- 		int digits=dig;
- 		if(digits==0) {
- 			c=dt;
- 			digits=6;
- 		}
- 		for(int s=(int)Math.pow(10,digits-1); s>=1; s/=10) {
- 			ans+=c/s;
- 			c-=(c/s)*s;
- 		}
- 		ans+=post+"."+fmt;
- 		return ans;
- 	}
- }
--- 0 ----
Index: AiboPup/tools/mon/Joints.java
diff -c AiboPup/tools/mon/Joints.java:1.1 AiboPup/tools/mon/Joints.java:removed
*** AiboPup/tools/mon/Joints.java:1.1	Thu Feb 20 14:51:16 2003
--- AiboPup/tools/mon/Joints.java	Fri Oct 10 14:37:54 2003
***************
*** 1,14 ****
- public class Joints {
-   public float[] positions;
-   public float[] duties;
-   public float[] sensors;
-   public float[] buttons;
-   int timestamp;
- 
-   Joints() {
-     positions=new float[18];
-     duties=new float[18];
-     sensors=new float[6];
-     buttons=new float[8];
-   } 
- }
--- 0 ----
Index: AiboPup/tools/mon/Listener.java
diff -c AiboPup/tools/mon/Listener.java:1.7 AiboPup/tools/mon/Listener.java:removed
*** AiboPup/tools/mon/Listener.java:1.7	Thu Jun 26 04:47:33 2003
--- AiboPup/tools/mon/Listener.java	Fri Oct 10 14:37:54 2003
***************
*** 1,162 ****
- import java.net.ServerSocket;
- import java.net.Socket;
- import java.io.InputStream;
- import java.io.OutputStream;
- import java.io.IOException;
- 
- public abstract class Listener implements Runnable {
- 	public Listener() { _port=-1; _isConnected=false; }
- 	public Listener(int port) { this(); setPort(port); }
- 	public Listener(String host, int port) { this(); setHostPort(host, port); }
- 
- 	public void setPort(int port) {
- 		_isServer=true;
- 		_port=port;
- 		startThread();
- 	}
- 
- 	public void setHostPort(String host, int port) {
- 		_isServer=false;
- 		_host=host;
- 		_port=port;
- 		startThread();
- 	}
- 	
- 	public void startThread() {
- 		destroy=false;
- 		_listenerThread=new Thread(this);
- 		_listenerThread.start();
- 	}
- 
- 	public void run() {
- 		if (_port >= 0) {
- 			if (_isServer)
- 				runServer();
- 			else
- 				runConnect();
- 		} else {
- 			System.out.println("can't start Listener without [host],port");
- 		}
- 	}
- 
- 	public void kill() {
- 		destroy=true;
- 		_isConnected=false;
- 		if(_listenerThread!=null)
- 			_listenerThread.interrupt();
- 		close();
- 	}
- 
- 	void frameTimer() {
- 		_frametimer_numframes++;
- 		if (System.currentTimeMillis()-_frametimer_timer>1000) {
- 			System.out.println("updated at "+_frametimer_numframes+"hz");
- 			_frametimer_numframes=0;
- 			_frametimer_timer=System.currentTimeMillis();
- 		}
- 	}
- 
- 	double readDouble(InputStream in) throws IOException {
- 		return Double.longBitsToDouble(readLong(in));
- 	}
- 
- 	void writeDouble(OutputStream out, double x) throws IOException {
- 		writeLong(out,Double.doubleToLongBits(x));
- 	}
- 
- 	long readLong(InputStream in) throws IOException {
- 		int read=0;
- 		int last=0;
- 		byte[] buf=new byte[8];
- 		while (read<8 && last>=0) { last=in.read(buf,read,8-read); read+=last; }
- 		if(last<0)
- 			_isConnected=false;
- 		return (b2l(buf[7])<<56) | (b2l(buf[6])<<48) |
- 					 (b2l(buf[5])<<40) | (b2l(buf[4])<<32) |
- 					 (b2l(buf[3])<<24) | (b2l(buf[2])<<16) |
- 					 (b2l(buf[1])<< 8) | b2l(buf[0]);
- 	}
- 
- 	void writeLong(OutputStream out, long x) throws IOException {
- 		int bytelen=8;
- 		byte[] buf=new byte[bytelen];
- 		for(int i=0; i<bytelen; i++)
- 			buf[i]=(new Long((x>>(8*i)) & 0xff)).byteValue();
- 		out.write(buf,0,bytelen);
- 	}
- 
- 	float readFloat(InputStream in) throws IOException {
- 		return Float.intBitsToFloat(readInt(in));
- 	}
- 	
- 	void writeFloat(OutputStream out, float x) throws IOException {
- 		writeInt(out,Float.floatToIntBits(x));
- 	}
- 
- 	int readInt(InputStream in) throws IOException {
- 		int read=0;
- 		int last=0;
- 		byte[] buf=new byte[4];
- 		while (read<4 && last>=0) { last=in.read(buf,read,4-read); read+=last; }
- 		if(last<0)
- 			_isConnected=false;
- 		return (b2i(buf[3])<<24) | (b2i(buf[2])<<16) |
- 					 (b2i(buf[1])<< 8) | b2i(buf[0]);
- 	}
- 	
- 	void writeInt(OutputStream out, int x) throws IOException {
- 		int bytelen=4;
- 		byte[] buf=new byte[bytelen];
- 		for(int i=0; i<bytelen; i++)
- 			buf[i]=(new Integer((x>>(8*i)) & 0xff)).byteValue();
- 		out.write(buf,0,bytelen);
- 	}
- 
- 	void readBytes(byte[] buf, InputStream in, int bytes) throws IOException {
- 		int read=0;
- 		int last=0;
- 		while (read<bytes && last>=0) {
- 			last=in.read(buf, read, bytes-read);
- 			read+=last;
- 		}
- 		if(last<0)
- 			_isConnected=false;
- 	}
- 
- 	String readLine(InputStream in) throws java.io.IOException{
- 		StringBuffer sbuf=new StringBuffer();
- 		int x=in.read();
- 		if(x==-1) {
- 			_isConnected=false;
- 			return sbuf.toString();
- 		}
- 		char c=(char)x;
- 		while(c!='\n') {
- 			sbuf.append(c);
- 			x=in.read();
- 			if(x==-1) {
- 				_isConnected=false;
- 				return sbuf.toString();
- 			}
- 			c=(char)x;
- 		}
- 		return sbuf.toString();
- 	}
- 	
- 	int b2i(byte b) { return (b>=0)?(int)b:((int)b)+256; }
- 	long b2l(byte b) { return (b>=0)?(long)b:((long)b)+256; }
- 
- 	abstract void runServer();
- 	abstract void runConnect();
- 	abstract public void close();
- 
- 	boolean _isServer;
- 	int _port;
- 	String _host;
- 	boolean _isConnected;
- 	volatile Thread _listenerThread;
- 	volatile boolean destroy=false;
- 
- 	int _frametimer_numframes=0;
- 	long _frametimer_timer=System.currentTimeMillis();
- }
--- 0 ----
Index: AiboPup/tools/mon/Makefile
diff -c AiboPup/tools/mon/Makefile:1.7 AiboPup/tools/mon/Makefile:1.18
*** AiboPup/tools/mon/Makefile:1.7	Tue Jul  1 05:00:18 2003
--- AiboPup/tools/mon/Makefile	Thu Oct  2 00:54:17 2003
***************
*** 1,3 ****
--- 1,7 ----
+ ifneq ($(MAKECMDGOALS),clean)
+ AIBO3D:=$(shell javac org/tekkotsu/aibo3d/Java3DTest.java > /dev/null 2>&1; echo $$? )
+ endif
+ 
  SRCS:=$(shell find . -name "*.java")
  
  OBJS:=${SRCS:.java=.class}
***************
*** 7,28 ****
  
  # SEP is to use ';' on windows and ':' on unix because windows is mentally deficient
  SEP:=$(shell if [ "`uname`" = "CYGWIN" -o "`uname`" \> "CYGWIN" -a "`uname`" \< "CYGWIO" ] ; then echo ";" ; else echo ":" ; fi )
! CXXFLAGS=-deprecation -classpath ".$(SEP)./ftp.jar$(SEP)../aibo3d"
  
! .PHONY: all clean msg
  
! all: msg $(OBJS)
  
! msg:
! 	@echo " **     These tools require the JDK 1.4 or higher.  These files         **"
! 	@echo " **     are _not_ necessary for development.  If errors occur, you      **"
! 	@echo " **     can remove the tools/mon/Makefile and continue without it.      **"
  
  %.class: %.java
! 	$(if $(shell which $(CXX)), \
! 		@echo "Compiling $< into $@..."; $(CXX) $(CXXFLAGS) $<, \
! 		@printf "  ***** WARNING: You don't have java... skipping TekkotsuMon *****\n" \
! 	)
  
  clean:
! 	rm -f $(OBJS) *~ 
--- 11,58 ----
  
  # SEP is to use ';' on windows and ':' on unix because windows is mentally deficient
  SEP:=$(shell if [ "`uname`" = "CYGWIN" -o "`uname`" \> "CYGWIN" -a "`uname`" \< "CYGWIO" ] ; then echo ";" ; else echo ":" ; fi )
! CXXFLAGS=-deprecation -classpath ".$(SEP)./ftp.jar$(SEP)./jargs.jar"
  
! .PHONY: all clean build clearbuildlist
  
! all: clearbuildlist build
  
! org/tekkotsu/aibo3d/%.class: org/tekkotsu/aibo3d/%.java
! 	@if [ $(AIBO3D) -eq 0 ] ; then \
! 		printf " $<" >> tmp_buildList.txt; \
! 	fi;
  
  %.class: %.java
! 	@printf " $<" >> tmp_buildList.txt;
! 
! clearbuildlist:
! 	@rm -f tmp_buildList.txt;
! 
! tmp_buildList.txt: ${OBJS}
! #	@echo "Build list constructed...";
! 
! build: tmp_buildList.txt
! 	@if [ -r tmp_buildList.txt ] ; then \
! 		cat README; \
! 		if [ $(AIBO3D) -ne 0 ] ; then \
! 			echo " *************************************************************************"; \
! 			echo " **     Java3D package not found.  Skipping Aibo3D...                   **"; \
! 			echo " **     More information: http://java.sun.com/products/java-media/3D/   **"; \
! 		fi;	\
! 		$(if $(shell which $(CXX)), \
! 			if [ `cat tmp_buildList.txt | wc -c` -gt 400 ] ; then \
! 				list=' [...]'; \
! 			else \
! 				list="`cat tmp_buildList.txt`"; \
! 			fi; \
! 			echo "Compiling$$list ..."; $(CXX) $(CXXFLAGS) `cat tmp_buildList.txt`; , \
! 			printf "  ***** WARNING: You don't have java... skipping TekkotsuMon *****\n"; \
! 		) \
! 	else \
! 		echo "TekkotsuMon: Nothing to be done."; \
! 	fi;
  
  clean:
! 	rm -f tmp_buildList.txt;
! 	find . -name "*.class" -exec rm \{\} \;
! 	find . -name "*~" -exec rm \{\} \;
Index: AiboPup/tools/mon/MechaController.java
diff -c AiboPup/tools/mon/MechaController.java:1.4 AiboPup/tools/mon/MechaController.java:removed
*** AiboPup/tools/mon/MechaController.java:1.4	Sun Jul  6 21:00:10 2003
--- AiboPup/tools/mon/MechaController.java	Fri Oct 10 14:37:54 2003
***************
*** 1,118 ****
- // Sends "Mecha" command data from TekkotsuMon to the AIBO.
- import java.lang.Integer;
- import java.lang.String;
- import java.lang.System;
- import java.io.OutputStream;
- import java.io.InputStream;
- import java.net.Socket;
- import javax.swing.Timer;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.util.Vector;
- import java.net.SocketException;
- 
- // The class itself. Brilliant that even though it does the talking,
- // it extends TCP*Listener*.
- public class MechaController extends TCPListener implements ActionListener {
-   // The command output stream
-   OutputStream out;
-   Socket mysock;
- 	Timer t=new Timer(1000,this);
- 	double forward=0;
- 	double strafe=0;
- 	double rotate=0;
- 	Vector listeners=new Vector();
- 	
- 	public interface MechaUpdatedListener {
- 		public void mechaUpdated(MechaController mc);
- 	}
- 
- 	void addMechaUpdatedListener(MechaUpdatedListener mcl) { listeners.add(mcl); }
- 	void removeMechaUpdatedListener(MechaUpdatedListener mcl) { listeners.remove(mcl); }
- 	void fireMechaUpdated() {
- 		for(int i=0;i<listeners.size();i++)
- 			((MechaUpdatedListener)listeners.get(i)).mechaUpdated(this);
- 	}
- 
-   // Connect to control socket
-   void connected(Socket socket) {
-     mysock = socket;
- 		t.start();
- 		fireMechaUpdated();
-     try {
-       out = mysock.getOutputStream();
- 			InputStream sin=socket.getInputStream();
- 			while (true) { //not that we expect input, but will block until the socket is closed
- 				String msgtype=readLine(sin);
- 				if(!_isConnected) break;
- 			}
-     } catch(Exception e) {if((SocketException)e==null) e.printStackTrace();}
- 
- 		try { socket.close(); } catch (Exception ex) { }
- 
- 		_isConnected=false;
- 		fireMechaUpdated();
- 		//The sleep is to get around the socket still listening after being closed thing
- 		if(!destroy)
- 			System.out.println("WalkGUI - connection closed... reconnect after 5 seconds");
- 		try { Thread.sleep(5000); } catch (Exception ex) {}
-   }
- 
-   // Disconnect from control socket
-   public void close() {
- 		//    try { mysock.close(); } catch(Exception e) {}
-     //_isConnected = false;
- 		t.stop();
-     super.close();
- 		//we'll fire an event to the listeners when the readLine in connected finally fails
-   }
- 
- 	public void actionPerformed(ActionEvent e) {
- 		if(_isConnected) {
- 			sendCommand("f",forward);
- 			sendCommand("s",strafe);
- 			sendCommand("r",rotate);
- 		}
- 	}
- 
-   // Send a mecha command
-   public void sendCommand(String command, double param) {
- 		t.restart();
- 		
-     // Extract command byte
-     byte cmdbytes[] = command.getBytes();
- 		if(cmdbytes[0]=='f')
- 			forward=param;
- 		else if(cmdbytes[0]=='s')
- 			strafe=param;
- 		else if(cmdbytes[0]=='r')
- 			rotate=param;
- 
-     // Construct the command sequence
-     byte sequence[] = new byte[5];
-     // The commmand byte is the first byte in cmdbytes. The remaining
-     // four bytes belong to the parameter. We have to convert the parameter
-     // (which we send as a float, not a double) to MIPS byte order thanks to
-     // (ahem) prior design decisions.
-     sequence[0] = cmdbytes[0];
-     int pbits = Float.floatToIntBits((float) param);
-     Integer i;
-     i = new Integer((pbits >> 24) & 0xff); sequence[4] = i.byteValue();
-     i = new Integer((pbits >> 16) & 0xff); sequence[3] = i.byteValue();
-     i = new Integer((pbits >>  8) & 0xff); sequence[2] = i.byteValue();
-     i = new Integer(pbits & 0xff);	   sequence[1] = i.byteValue();
-     // Now write the whole command.
-     try {
-       out.write(sequence, 0, 5);
-     } catch(Exception e) { close(); return; }
-   }
- 
-   // Some state inquiry functions
-   public boolean hasData() { return false; }
-   public boolean isConnected() { return _isConnected; }
- 
-   // Constructors
-   public MechaController() { super(); }
-   public MechaController(int port) { super(port); }
-   public MechaController(String host, int port) { super(host, port); }
- }
--- 0 ----
Index: AiboPup/tools/mon/PIDs.java
diff -c AiboPup/tools/mon/PIDs.java:1.1 AiboPup/tools/mon/PIDs.java:removed
*** AiboPup/tools/mon/PIDs.java:1.1	Thu Feb 20 14:51:16 2003
--- AiboPup/tools/mon/PIDs.java	Fri Oct 10 14:37:54 2003
***************
*** 1,12 ****
- public class PIDs {
-   public int timestamp;
-   public float[] P;
-   public float[] I;
-   public float[] D;
- 
-   PIDs() {
-     P=new float[18];
-     I=new float[18];
-     D=new float[18];
-   } 
- }
--- 0 ----
Index: AiboPup/tools/mon/PointPick.java
diff -c AiboPup/tools/mon/PointPick.java:1.2 AiboPup/tools/mon/PointPick.java:removed
*** AiboPup/tools/mon/PointPick.java:1.2	Sat Jun 21 21:30:05 2003
--- AiboPup/tools/mon/PointPick.java	Fri Oct 10 14:37:54 2003
***************
*** 1,257 ****
- import javax.swing.*;
- import java.awt.*;
- import java.awt.geom.*;
- import java.awt.event.*;
- import java.util.Vector;
- 
- public class PointPick extends JComponent {
- 	static public void main(String s[]) {
- 		JFrame frame=new JFrame("Point Pick Test");
- 		frame.setSize(new Dimension(300, 300)); 
- 		PointPick pp=new PointPick(true);
- 		frame.getContentPane().setLayout(new BorderLayout());
- 		frame.getContentPane().add(pp,BorderLayout.CENTER);
- 		frame.addWindowListener(new WindowAdapter() {
- 			public void windowClosing(WindowEvent e) { System.exit(0); }
- 		});
- 		frame.show();
- 	}
- 	
- 	float x=0;
- 	float y=0;
- 	float dotsize=8;
- 	float tracksize=14;
- 	PPTic mdot;
- 	PPTic track;
- 	Vector listeners=new Vector();
- 	Vector tics=new Vector();
- 	boolean isCirc=true;
- 	
- 	public interface PointPickedListener {
- 		public void pointPicked(Point2D.Float p, MouseEvent e, PointPick pp);
- 	}
- 	public void addPointPickedListener(PointPickedListener ppl) {
- 		listeners.add(ppl);
- 	}
- 	public void removePointPickedListener(PointPickedListener ppl) {
- 		listeners.remove(ppl);
- 	}
- 	public void firePointPicked(Point2D.Float p, MouseEvent e) {
- 		for(int i=0; i<listeners.size(); i++)
- 			((PointPickedListener)listeners.get(i)).pointPicked(p,e,this);
- 	}
- 	
- 	public class PPTic extends JComponent {
- 		float xp=1.0f;
- 		float yp=1.0f;
- 		BasicStroke s=new BasicStroke(1);
- 		Color line=Color.BLACK;
- 		Color fill=null;
- 		boolean isCirc=true;
- 		public PPTic() {}
- 		public PPTic(float percent, BasicStroke s) {
- 			xp=yp=percent;
- 			this.s=s;
- 		}
- 		public PPTic(float percent, BasicStroke s, Color line, Color fill) {
- 			xp=yp=percent;
- 			this.s=s;
- 			this.line=line;
- 			this.fill=fill;
- 		}
- 		public void paint(Graphics graphics) {
- 			Graphics2D g=(Graphics2D)graphics;
- 			g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
- 			float sw=s.getLineWidth();
- 			float w=getWidth();
- 			float h=getHeight();
- 			float l=w*(1-xp)/2;
- 			float r=l+w*xp;
- 			float t=h*(1-yp)/2;
- 			float b=t+h*yp;
- 			l+=sw/2-.5;
- 			r-=sw/2+.5;
- 			t+=sw/2-.5;
- 			b-=sw/2+.5;
- 			if(fill!=null) {
- 				g.setPaint(fill);
- 				if(isCirc)
- 					g.fill(new Ellipse2D.Float(l,t,r-l,b-t));
- 				else
- 					g.fill(new Rectangle2D.Float(l,t,r-l,b-t));
- 			}
- 			if(line!=null) {
- 				g.setPaint(line);
- 				g.setStroke(s);
- 				if(isCirc)
- 					g.draw(new Ellipse2D.Float(l,t,r-l,b-t));
- 				else
- 					g.draw(new Rectangle2D.Float(l,t,r-l,b-t));
- 			}
- 			super.paint(graphics);
- 		}
- 		public void setCircular(boolean circ) {
- 			isCirc=circ;
- 		}
- 	}
- 	
- 	public PointPick(boolean circ) {
- 		BasicStroke s=new BasicStroke(1);
- 
- 		track=new PPTic(1,new BasicStroke(2),Color.RED,null);
- 		track.reshape((int)((getWidth()*(1+x)-tracksize)/2),(int)((getHeight()*(1+y)-tracksize)/2),(int)tracksize,(int)tracksize);
- 		track.setVisible(false);
- 		add(track);
- 
- 		mdot=new PPTic(1,s,null,isEnabled()?new Color(.7f,.0f,.0f):new Color(.4f,.4f,.4f));
- 		mdot.reshape((int)((getWidth()*(1+x)-dotsize)/2),(int)((getHeight()*(1-y)-dotsize)/2),(int)dotsize,(int)dotsize);
- 		add(mdot);
- 
- 		PPTic tmp,tmp2;
- 		tmp=new PPTic(1.0f,new BasicStroke(2),isEnabled()?Color.BLACK:Color.GRAY,Color.WHITE);
- 		tmp.reshape(0,0,getWidth(),getHeight());
- 		tmp.setLayout(new BorderLayout());
- 		add(tmp);
- 		tics.add(tmp);
- 		for(float f=.75f; f>0; f-=.25f) {
- 			tmp2=new PPTic(f,s,Color.LIGHT_GRAY,null);
- 			tmp2.setLayout(new BorderLayout());
- 			tmp.add(tmp2,BorderLayout.CENTER);
- 			tics.add(tmp2);
- 			tmp=tmp2;
- 		}
- 		tmp2=new PPTic(.0175f,s,null,Color.LIGHT_GRAY);
- 		tmp2.setLayout(new BorderLayout());
- 		tmp.add(tmp2,BorderLayout.CENTER);
- 		tics.add(tmp2);
- 		tmp=tmp2;
- 		
- 		enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK+AWTEvent.MOUSE_EVENT_MASK);
- 		
- 		setCircular(circ);
- 	}
- 	
- 	public void setCircular(boolean circ) {
- 		if(isCirc!=circ) {
- 			for(int i=0; i<tics.size(); i++) {
- 				((PPTic)tics.get(i)).setCircular(circ);
- 			}
- 			setOpaque(!circ);
- 			isCirc=circ;
- 			repaint();
- 		}
- 	}
- 
- 	public void paint(Graphics graphics) {
- 		super.paint(graphics);
- 		int w=getWidth()-1;
- 		int h=getHeight()-1;
- //		Rectangle r=graphics.getClipBounds();
- //		graphics.setColor(Color.WHITE);
- //		graphics.fillRect(r.x,r.y,r.width,r.height);
- 		graphics.setColor(isEnabled()?Color.BLACK:Color.GRAY);
- 		graphics.drawLine(0,w/2,h,w/2);
- 		graphics.drawLine(h/2,0,h/2,w);
- //		graphics.setColor(isEnabled()?Color.DARK_GRAY:Color.LIGHT_GRAY);
- //		graphics.fillOval((int)((getWidth()-dotsize+2)/2),(int)((getHeight()-dotsize+2)/2),(int)dotsize-2,(int)dotsize-2);
- 	}
- 
- 	public void setEnabled(boolean b) {
- 		((PPTic)tics.get(0)).line=b?Color.BLACK:Color.GRAY;
- 		mdot.fill=b?new Color(.7f,.0f,.0f):new Color(.4f,.4f,.4f);
- 		super.setEnabled(b);
- 	}
- 	
- 	public void setBounds(int x, int y, int w, int h) {
- 		if(w>h)
- 			w=h;
- 		if(h>w)
- 			h=w;
- 		((PPTic)tics.get(0)).setBounds(0,0,w,h);
- 		mdot.setBounds((int)((w*(1+this.x)-dotsize)/2),(int)((h*(1-this.y)-dotsize)/2),(int)dotsize,(int)dotsize);
- 		super.setBounds(x,y,w,h);
- 	}
- 	
- 	public void processMouseEvent(MouseEvent e) {
- 		if(isEnabled()) {
- 			if(e.getID()==MouseEvent.MOUSE_PRESSED) {
- 				Point2D.Float mp=screenToModel(e.getPoint());
- 				Point sp=modelToScreen(mp);
- 				sp.translate((int)(-tracksize/2),(int)(-tracksize/2));
- 				track.setLocation(sp);
- 				track.setVisible(true);
- 				doSetPoint(mp);
- 				firePointPicked(mp,e);
- 			} else if(e.getID()==MouseEvent.MOUSE_RELEASED) {
- 				if((e.getModifiersEx()&(MouseEvent.BUTTON1_DOWN_MASK|MouseEvent.BUTTON2_DOWN_MASK|MouseEvent.BUTTON3_DOWN_MASK))==0)
- 					track.setVisible(false);
- 			}
- 		}
- 		super.processMouseEvent(e);
- 	}
- 
- 	public void processMouseMotionEvent(MouseEvent e) {
- 		if(isEnabled()) {
- 			if(e.getID()==MouseEvent.MOUSE_DRAGGED) {
- 				Point2D.Float mp=screenToModel(e.getPoint());
- 				Point sp=modelToScreen(mp);
- 				sp.translate((int)(-tracksize/2),(int)(-tracksize/2));
- 				track.setLocation(sp);
- 				doSetPoint(mp);
- 				firePointPicked(mp,e);
- 			}
- 		}
- 		super.processMouseMotionEvent(e);
- 	}
- 	
- 	public Point2D.Float getPoint() { return new Point2D.Float(x,y); }
- 	public float getXValue() { return x; }
- 	public float getYValue() { return y; }
- 
- 	public void setPoint(float x, float y) {
- 		doSetPoint(x,y);
- 		firePointPicked(new Point2D.Float(x,y),null);
- 	}
- 	
- 	protected Point2D.Float screenToModel(Point p) {
- 		return screenToModel(p.x,p.y);
- 	}
- 	protected Point2D.Float screenToModel(int x, int y) {
- 		float fx=x/(float)getWidth()*2-1;
- 		float fy=1-y/(float)getHeight()*2;
- 		if(isCirc) {
- 			if(fx*fx+fy*fy>1) {
- 				double a=Math.atan2(fy,fx);
- 				fx=(float)Math.cos(a);
- 				fy=(float)Math.sin(a);
- 			}
- 		} else {
- 			if(fx>1)
- 				fx=1;
- 			if(fx<-1)
- 				fx=-1;
- 			if(fy>1)
- 				fy=1;
- 			if(fy<-1)
- 				fy=-1;
- 		}
- 		return new Point2D.Float(fx,fy);
- 	}
- 	protected Point modelToScreen(Point2D.Float p) {
- 		return modelToScreen(p.x,p.y);
- 	}
- 	protected Point modelToScreen(float x, float y) {
- 		return new Point((int)(getWidth()*(1+x)/2),(int)(getHeight()*(1-y)/2));
- 	}
- 	
- 	public void doSetPoint(Point2D.Float p) {
- 		doSetPoint(p.x,p.y);
- 	}
- 	public void doSetPoint(float x, float y) {
- 		this.x=x;
- 		this.y=y;
- 		Point p=modelToScreen(x,y);
- 		p.translate((int)(-dotsize/2),(int)(-dotsize/2));
- 		mdot.setLocation(p);
- 	}
- }
--- 0 ----
Index: AiboPup/tools/mon/README
diff -c /dev/null AiboPup/tools/mon/README:1.1
*** /dev/null	Fri Oct 10 14:37:54 2003
--- AiboPup/tools/mon/README	Fri Jul 25 16:02:48 2003
***************
*** 0 ****
--- 1,3 ----
+  **     These tools require the JDK 1.4 or higher.  These files         **
+  **     are _not_ necessary for development.  If errors occur, you      **
+  **     can remove the tools/mon/Makefile and continue without it.      **
Index: AiboPup/tools/mon/SquareRightLayout.java
diff -c AiboPup/tools/mon/SquareRightLayout.java:1.1 AiboPup/tools/mon/SquareRightLayout.java:removed
*** AiboPup/tools/mon/SquareRightLayout.java:1.1	Sat Jun 21 17:49:55 2003
--- AiboPup/tools/mon/SquareRightLayout.java	Fri Oct 10 14:37:54 2003
***************
*** 1,42 ****
- import java.awt.*;
- 
- public class SquareRightLayout implements LayoutManager {
- 	Component right;
- 	Component square;
- 	static String SQUARE="square";
- 	static String RIGHT="right";
- 	public void addLayoutComponent(String name, Component comp) {
- 		if(name.compareTo(SQUARE)==0)
- 			square=comp;
- 		else if(name.compareTo(RIGHT)==0)
- 			right=comp;
- 	}
- 	public void layoutContainer(Container parent) {
- 		square.setBounds(0,0,parent.getHeight(),parent.getHeight());
- 		right.setBounds(parent.getHeight(),0,parent.getWidth()-parent.getHeight(),parent.getHeight());
- 	}
- 	public Dimension minimumLayoutSize(Container parent) {
- 		Dimension sq=square.getMinimumSize();
- 		Dimension rt=right.getMinimumSize();
- 		int minsq=sq.width>sq.height?sq.width:sq.height;
- 		if(minsq<rt.height)
- 			minsq=rt.height;
- //			int minheight=minsq>rt.height?minsq:rt.height
- 		return new Dimension(minsq+rt.width,minsq);
- 	}
- 	public Dimension preferredLayoutSize(Container parent) {
- 		Dimension sq=square.getPreferredSize();
- 		Dimension rt=right.getPreferredSize();
- 		int prefsq=sq.width>sq.height?sq.width:sq.height;
- 		if(prefsq<rt.height)
- 			prefsq=rt.height;
- //			int prefheight=minsq>rt.height?minsq:rt.height
- 		return new Dimension(prefsq+rt.width,prefsq);
- 	}
- 	public void removeLayoutComponent(Component comp) {
- 		if(square==comp)
- 			square=null;
- 		else if(right==comp)
- 			right=null;
- 	}
- }
--- 0 ----
Index: AiboPup/tools/mon/TCPListener.java
diff -c AiboPup/tools/mon/TCPListener.java:1.10 AiboPup/tools/mon/TCPListener.java:removed
*** AiboPup/tools/mon/TCPListener.java:1.10	Sun Jul  6 21:00:10 2003
--- AiboPup/tools/mon/TCPListener.java	Fri Oct 10 14:37:54 2003
***************
*** 1,69 ****
- import java.net.ServerSocket;
- import java.net.Socket;
- 
- public abstract class TCPListener extends Listener {
- 	abstract void connected(Socket socket);
- 
- 	void runServer() {
- 		Thread me = Thread.currentThread();
- 		try { _serverSocket=new ServerSocket(_port); }
- 		catch (Exception ex) {
- 			System.out.println("port "+_port+": "+ex);
- 			return;
- 		}
- 
- 		while (me == _listenerThread && !destroy) {
- 			try {
- 				_socket=_serverSocket.accept();
- 				connected(_socket);
- 			} catch (Exception ex) { }
- 		}
- 	}
- 
- 	void runConnect() {
- 		int attempts=0;
- 		Thread me = Thread.currentThread();
- 		while (me==_listenerThread && !destroy) {
- 			if(attempts==0) {
- 				//				if(attempts!=0)
- 				//					System.err.println("");
- 				System.err.print("TCPListener port "+_port+" - Connecting..");
- 			}
- 			try {
- 				System.err.print(".");
- 				_socket=new Socket(_host,_port);
- 				System.err.println(" connected.");
- 				attempts=0;
- 				_isConnected=true;
- 			} catch (Exception ex) {}
- 			if(_isConnected) {
- 				connected(_socket);
- 				if(!destroy)
- 					System.err.println("TCPListener port "+_port+" - Disconnected, attempting to reestablish...");
- 			}
- 			attempts++;
- 			if(destroy) {
- 				System.err.println("TCPListener port "+_port+" - Connection closed.");
- 				break;
- 			}
- 			try {
- 				Thread.sleep(500);
- 			} catch (Exception ex) {}
- 		}
- 	}
- 
- 	public void close() {
- 		_listenerThread=null;
- 		_isConnected=false;
- 		try { _socket.close(); } catch (Exception ex) { }
- 		if (_isServer)
- 			try { _serverSocket.close(); } catch (Exception ex) { }
- 	}
- 
- 	public TCPListener() { super(); }
- 	public TCPListener(int port) { super(port); }
- 	public TCPListener(String host, int port) { super(host,port); }
- 
- 	Socket _socket;
- 	ServerSocket _serverSocket;
- }
--- 0 ----
Index: AiboPup/tools/mon/Terminal.java
diff -c AiboPup/tools/mon/Terminal.java:1.2 AiboPup/tools/mon/Terminal.java:removed
*** AiboPup/tools/mon/Terminal.java:1.2	Tue Apr  8 23:37:30 2003
--- AiboPup/tools/mon/Terminal.java	Fri Oct 10 14:37:54 2003
***************
*** 1,134 ****
- import javax.swing.*;
- import java.awt.BorderLayout;
- import java.awt.Dimension;
- import java.awt.Rectangle;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Insets;
- import java.awt.event.KeyListener;
- import java.awt.event.KeyEvent;
- import java.awt.event.ComponentListener;
- import java.awt.event.ComponentEvent;
- 
- /* TODO:
-    JTextPane
-    History, Autocomplete
- */
- public class Terminal implements KeyListener, ComponentListener {
-     static final int MAX_CHARS = 30000;
-     JFrame _term;
-     JTextArea _output;
-     JTextField _input;
-     JScrollPane _scroll;
-     JScrollBar _scroll_bar;
-     int _width, _height;
-     String _title;
-     String _data;
- 
-     public static void main(String[] args) {
- //      Terminal terminal=new Terminal();
-       System.out.println("please instantiate from within Matlab");
-       System.exit(1);
-     }
- 
-     public Terminal() {
-       _height=400;
-       _width=600;
-       _title="AiboMon";
-       _data="";
- 
-       createTerm();
-     }
- 
-     public void close() {
-       _term.setVisible(false);
-     }
- 
-     public boolean wasClosed() {
-       return !_term.isVisible();
-     }
- 
-     void createTerm() {
-       _term=new JFrame("AiboMon");
-       _term.setBackground(Color.darkGray);
-       _term.getContentPane().setLayout(new BorderLayout());
- 
-       _output=new JTextArea();
-       _output.setBackground(Color.black);
-       _output.setForeground(Color.lightGray);
-       _output.setFont(new Font("Monospaced",Font.PLAIN, 12));
-       _output.setLineWrap(true);
-       _output.setEditable(false);
-       _scroll=new JScrollPane(_output,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
-                                       JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
-       _term.getContentPane().add(_scroll, BorderLayout.NORTH);
- 
-       _input=new JTextField();
-       _input.setBackground(Color.black);
-       _input.setForeground(Color.white);
-       _input.setFont(new Font("Monospaced",Font.PLAIN,12));
-       _term.getContentPane().add(_input, BorderLayout.SOUTH);
- 
-       _input.addKeyListener(this);
-       _term.addComponentListener(this);
-       _term.show();
-       _term.setSize(new Dimension(_width, _height));
-       resize();
- 
-       _scroll_bar=_scroll.getVerticalScrollBar();
-     }
-     
-     public void keyPressed(KeyEvent e) {
-       switch(e.getKeyCode()) {
-         case KeyEvent.VK_ENTER:
-           _output.append(_input.getText()+"\n");
-           _data=_data+_input.getText()+"\n";
-           _input.setText("");
-           break;
-         case KeyEvent.VK_UP:
-           break;
-         case KeyEvent.VK_DOWN:
-           break;
-       }
-     }
- 
-     public boolean hasData() {
-       return _data.length()!=0;
-     }
- 
-     public String getData() {
-       String ret;
-       ret=_data;
-       _data="";
-       return ret;
-     }
- 
-     public void write(String s) {
-       _output.append(s);
-       _scroll_bar.setValue(_scroll_bar.getMaximum());
-     }
- 
-     public void clear() {
-       _output.setText("");
-     }
- 
-     void resize() {
-       Dimension dim=_term.getSize();
-       Insets ins=_term.getInsets();
-       int width=dim.width-ins.left-ins.right;
-       int height=dim.height-ins.top-ins.bottom;
-       _scroll.setSize(new Dimension(width, height-25));
-       _input.setSize(new Dimension(width,25));
-     }
- 
-     public void componentResized(ComponentEvent e) {
-       if (e.getID()==ComponentEvent.COMPONENT_RESIZED) resize();
-     }
- 
-     public void keyReleased(KeyEvent e) { }
-     public void keyTyped(KeyEvent e) { }
-     public void componentHidden(ComponentEvent e) { }
-     public void componentMoved(ComponentEvent e) { }
-     public void componentShown(ComponentEvent e) { }
- }
- 
--- 0 ----
Index: AiboPup/tools/mon/TextListener.java
diff -c AiboPup/tools/mon/TextListener.java:1.2 AiboPup/tools/mon/TextListener.java:removed
*** AiboPup/tools/mon/TextListener.java:1.2	Tue Apr  8 23:37:31 2003
--- AiboPup/tools/mon/TextListener.java	Fri Oct 10 14:37:54 2003
***************
*** 1,54 ****
- import java.io.InputStreamReader;
- import java.io.BufferedReader;
- import java.io.PrintStream;
- import java.net.Socket;
- 
- public class TextListener extends TCPListener {
-   String _data="";
-   PrintStream _out;
- 
-   void connected(Socket socket) {
-     _isConnected=true;
-     try {
-       BufferedReader in=new BufferedReader(new InputStreamReader(
-                           socket.getInputStream()));
-       _out=new PrintStream(socket.getOutputStream());
-       while (true) {
-         String read=in.readLine();
-         if (read==null) break;
-         synchronized (_data) { _data=_data+read+"\n"; }
-       }
-     } catch (Exception ex) { }
- 
-     try { socket.close(); } catch (Exception ex) { }
-     _isConnected=false;
-   }
-  
-   public boolean hasData() {
-     return _data.length()!=0;
-   }
- 
-   public String getData() {
-     String ret;
-     synchronized (_data) { 
-       ret=_data;
-       _data="";
-     }
-     return ret;
-   }
- 
-   public void write(String s) {
-     if (_isConnected) {
-       _out.print(s);
-       _out.flush();
-     }
-   }
- 
-   public boolean isConnected() {
-     return _isConnected;
-   }
- 
-   public TextListener() { super(); }
-   public TextListener(int port) { super(port); }
-   public TextListener(String host, int port) { super(host,port); }
- }
--- 0 ----
Index: AiboPup/tools/mon/UDPListener.java
diff -c AiboPup/tools/mon/UDPListener.java:1.1 AiboPup/tools/mon/UDPListener.java:removed
*** AiboPup/tools/mon/UDPListener.java:1.1	Thu Feb 20 14:51:17 2003
--- AiboPup/tools/mon/UDPListener.java	Fri Oct 10 14:37:54 2003
***************
*** 1,30 ****
- import java.net.DatagramSocket;
- 
- public abstract class UDPListener extends Listener {
-   abstract void connected(DatagramSocket socket);
- 
-   void runServer() {
-     try {
-       _socket=new DatagramSocket(_port);
-       connected(_socket);
-     } catch (Exception ex) {
-       System.out.println("port "+_port+": "+ex);
-     }
-   }
- 
-   void runConnect() {
-     try {
-       _socket=new DatagramSocket();
-       connected(_socket);
-     } catch (Exception ex) { }
-   }
- 
-   public void close() {
-   }
- 
-   public UDPListener() { super(); }
-   public UDPListener(int port) { super(port); }
-   public UDPListener(String host, int port) { super(host, port); }
- 
-   DatagramSocket _socket;
- }
--- 0 ----
Index: AiboPup/tools/mon/VisionGUI.java
diff -c AiboPup/tools/mon/VisionGUI.java:1.9 AiboPup/tools/mon/VisionGUI.java:removed
*** AiboPup/tools/mon/VisionGUI.java:1.9	Fri Jun 27 02:03:57 2003
--- AiboPup/tools/mon/VisionGUI.java	Fri Oct 10 14:37:54 2003
***************
*** 1,374 ****
- import java.awt.event.*;
- import javax.swing.*;
- import java.lang.String;
- import java.util.LinkedList;
- import java.awt.*;
- import javax.imageio.ImageIO;
- import java.awt.image.BufferedImage;
- import java.awt.image.IndexColorModel;
- import java.util.Date;
- import java.io.PrintWriter;
- import java.io.FileOutputStream;
- 
- public class VisionGUI extends JFrame implements ActionListener, VisionUpdatedListener {
- 	VisionPanel vision;
- 	JCheckBox aspectBut;
- 	JButton freezeBut;
- 	JButton saveImageBut;
- 	JLabel status;
- 	JButton reconnectBut;
- 	float mspf=0;
- 	float mspfGamma=.9f;
- 	long lastFrameTime=0;
- 	boolean isRaw=false;
- 	boolean isRLE=false;
- 	boolean connected=false;
- 	boolean isFreezeFrame=false;
- 	final static ImageIcon carrows = new ImageIcon("images/chasingarrows.png");
- 	ImageSequenceWriterThread imgWrite=null;
- 	String state="Connecting...";
- 
- 	public class StatusUpdateThread extends Thread {
- 		VisionGUI gui;
- 		public StatusUpdateThread(VisionGUI gui) { super("StatusUpdate"); this.gui=gui; setDaemon(true);}
- 		public void run() {
- 			VisionListener l=gui.vision.getListener();
- 			while(true) {
- 				String status=gui.state;
- 				String recording=recordReport();
- 				String fps=fpsReport();
- 				if(fps.length()>0)
- 					status+=" - "+fps;
- 				if(recording.length()>0)
- 					status+="; "+recording;
- 				gui.status.setText(status);
- 				try {
- 					sleep(100);
- 				} catch(Exception ex) {break;}
- 			}
- 		}
- 		public String recordReport() {
- 			if(gui.imgWrite!=null && (!gui.imgWrite.stopping || gui.imgWrite.isAlive())) {
- 				String ans;
- 				if(!gui.imgWrite.stopping) {
- 					ans="Rec: ";
- 					if(imgWrite.imgBufs.size()!=0)
- 						ans+="Free="+imgWrite.imgBufs.size();
- 				} else
- 					ans="Writing";
- 				ans+=" Queue="+imgWrite.q.size();
- 				return ans;
- 			} else
- 				return "";
- 		}
- 		public String fpsReport() {
- 				if(connected) {
- 					int rnd=(int)(10000/gui.mspf);
- 					return rnd/10.0f+" fps";
- 				} else
- 					return "";
- 		}
- 	}
- 	
- 	public static void main(String s[]) {
- 		int port=-1;
- 		if(s.length<2)
- 			usage();
- 		if(s[1].toUpperCase().compareTo("RLE")==0)
- 			port=VisionRleListener.defPort;
- 		else if(s[1].toUpperCase().compareTo("RAW")==0)
- 			port=VisionRawListener.defPort;
- 		else {
- 			System.err.println("VisionGUI: Unrecognized format: "+s[1]);
- 			usage();
- 		}
- 		if(s.length>2)
- 			port=Integer.parseInt(s[1]);
- 		String[] args=new String[1];
- 		args[0]=s[1];
- 		VisionGUI gui=new VisionGUI(s[0],port,args);
- 		gui.addWindowListener(new WindowAdapter() {
- 				public void windowClosing(WindowEvent e) { System.exit(0); } });
- 		gui.show();
- 	}
- 		
- 	public static void usage() {
- 		System.out.println("Usage: java VisionGUI host (RLE|raw) [port]");
- 		System.out.println("       if port is not specified, it defaults to:");
- 		System.out.println("       "+VisionRawListener.defPort+" for raw");
- 		System.out.println("       "+VisionRleListener.defPort+" for RLE.");
- 		System.exit(2);
- 	}
- 			
- 	public void actionPerformed(ActionEvent e) {
- 		if(e.getActionCommand().compareTo("YUV")==0) {
- 			VisionRaw v=(VisionRaw)vision;
- 			if(v!=null)
- 				v.setConvertRGB(false);
- 		} else if(e.getActionCommand().compareTo("RGB")==0) {
- 			VisionRaw v=(VisionRaw)vision;
- 			if(v!=null)
- 				v.setConvertRGB(true);
- 		} else if(e.getActionCommand().compareTo("freeze")==0) {
- 			isFreezeFrame=!isFreezeFrame;
- 			if(!isFreezeFrame) {
- 				state="Reconnecting...";
- 				vision.open();
- 			} else {
- 				state="Disconnecting...";
- 				vision.close();
- 			}
- 		} else if(e.getActionCommand().compareTo("aspect")==0) {
- 			vision.setLockAspectRatio(((JCheckBox)e.getSource()).isSelected());
- 		} else if(e.getActionCommand().compareTo("seq")==0) {
- 			imgWrite=new ImageSequenceWriterThread(vision.getListener(), saveImageBut);
- 			saveImageBut.setText("Stop Saving Sequence");
- 			saveImageBut.setToolTipText("Click to stop buffering new frames - already captured frames will continue to be written (unless you close the window)");
- 			saveImageBut.setActionCommand("stopseq");
- 			Component cur=this;
- 			while(cur.getParent()!=null) {
- 				cur=cur.getParent();
- 				System.out.println("VisionGUI Weird: "+cur);
- 			}
- 			FileDialog f=new FileDialog((Frame)cur,"Save Image Sequence",FileDialog.SAVE);
- 			f.show();
- 			if(f.getFile()==null || f.getFile().compareTo("")==0) {
- 				saveImageBut.doClick();
- 				return;
- 			}
- 			String base;
- 			String format;
- 			if(f.getFile().lastIndexOf('.')==-1) {
- 				format="png";
- 				base=f.getFile();
- 			} else {
- 				int i=f.getFile().lastIndexOf(".");
- 				format=f.getFile().substring(i+1);
- 				base=f.getFile().substring(0,i);
- 			}
- 			int first=base.indexOf('#');
- 			int last=base.lastIndexOf('#');
- 			boolean appendTime=(first==-1);
- 			imgWrite.setDirectory(f.getDirectory());
- 			f.dispose();
- 			if(first!=-1)
- 				imgWrite.setName(base.substring(0,first),last-first+1,base.substring(last+1),format);
- 			else
- 				imgWrite.setName(base,0,"",format);
- 			imgWrite.start();
- 		} else if(e.getActionCommand().compareTo("stopseq")==0) {
- 			saveImageBut.setText("Save Image Sequence");
- 			saveImageBut.setToolTipText("Saves to a series of files - use .jpg or .png extension to choose format; #'s will be replaced with index, otherwise timecode is appended");
- 			saveImageBut.setActionCommand("seq");
- 			imgWrite.interrupt();
- 		} else if(e.getActionCommand().compareTo("img")==0) {
- 			Component cur=this;
- 			while(cur.getParent()!=null) {
- 				cur=cur.getParent();
- 				System.out.println("VisionGUI Weird: "+cur);
- 			}
- 			FileDialog f=new FileDialog((Frame)cur,"Save Image",FileDialog.SAVE);
- 			f.show();
- 			if(f.getFile()!=null && f.getFile().compareTo("")!=0) {
- 				String format="png";
- 				int i=f.getFile().lastIndexOf(".");
- 				if(i!=-1)
- 					format=f.getFile().substring(i+1);
- 				try {
- 					ImageIO.write(vision.getListener().getImage(),format,new FileOutputStream(f.getDirectory()+f.getFile()));
- 				} catch(Exception ex) {}
- 			}
- 			f.dispose();
- 		} else if(e.getSource()==reconnectBut) {
- 			vision.close();
- 			vision.open();
- 		}
- 	}
- 
- 	class CloseVisionAdapter extends WindowAdapter {
- 		VisionGUI gui;
- 		CloseVisionAdapter(VisionGUI gui) {this.gui=gui;}
- 		public void windowClosing(WindowEvent e) {
- 			gui.vision.close();
- 			if(gui.imgWrite!=null && gui.imgWrite.isAlive()) {
- 				if(!gui.imgWrite.isInterrupted() && !gui.imgWrite.stopping)
- 					gui.imgWrite.interrupt();
- 				while(gui.imgWrite.isInterrupted())
- 					try { Thread.sleep(50); } catch(Exception ex) {}
- 				if(!gui.imgWrite.stopping)
- 					System.out.println("imgWrite refuses to stop");
- 				gui.imgWrite.interrupt(); //this second one should kill it
- 				while(gui.imgWrite.isAlive())
- 					try { Thread.sleep(50); } catch(Exception ex) {}
- 			}
- 		}
- 	}
- 
- 	public void visionUpdated(VisionListener l) {
- 		if(l.isConnected()!=connected) {
- 			connected=l.isConnected();
- 			if(connected) {
- 				freezeBut.setEnabled(true);
- 				freezeBut.setText("Freeze Frame");
- 				freezeBut.setToolTipText("Freezes current frame (disconnects from stream)");
- 				isFreezeFrame=false;
- 				saveImageBut.setEnabled(true);
- 				saveImageBut.setText("Save Image Sequence");
- 				saveImageBut.setToolTipText("Saves to a series of files - use .jpg or .png extension to choose format; #'s will be replaced with index, otherwise timecode is appended");
- 				saveImageBut.setActionCommand("seq");
- 				state="Connected.";
- 			} else {
- 				if(vision._image==null)
- 					saveImageBut.setEnabled(false);
- 				else {
- 					saveImageBut.setText("Save Image");
- 					saveImageBut.setToolTipText("Save current image shown - use .jpg or .png extension to choose format");
- 					saveImageBut.setActionCommand("img");
- 				}
- 				if(isFreezeFrame) {
- 					state="Disconnected.";
- 					freezeBut.setText("Unfreeze");
- 					freezeBut.setToolTipText("Reconnects to stream");
- 				} else {
- 					state="Reconnecting...";
- 					freezeBut.setEnabled(false);
- 				}
- 			}
- 		}
- 		if(connected) {
- 			if(lastFrameTime==0) {
- 				if(l.getTimeStamp()!=null)
- 					lastFrameTime=l.getTimeStamp().getTime();
- 			} else {
- 				long cur=l.getTimeStamp().getTime();
- 				mspf=mspf*mspfGamma+(cur-lastFrameTime)*(1-mspfGamma);
- 				lastFrameTime=cur;
- 			}
- 		} else {
- 			lastFrameTime=0;
- 		}
- 	}
- 	
- 	public VisionGUI(String host, String[] args) {
- 		super();
- 		int port=-1;
- 		for(int i=0; i<args.length; i++) {
- 			if(args[i].toUpperCase().compareTo("RLE")==0) {
- 				isRLE=true;
- 				isRaw=false;
- 			} else if(args[i].toUpperCase().compareTo("RAW")==0) {
- 				isRaw=true;
- 				isRLE=false;
- 			} else
- 				System.err.println("VisionGUI: Unrecognized argument: "+args[0]);
- 		}
- 		if(isRLE)
- 			port=VisionRleListener.defPort;
- 		else if(isRaw)
- 			port=VisionRawListener.defPort;
- 		init(host,port,args);
- 	}
- 	public VisionGUI(String host, int port, String[] args) {
- 		super();
- 		init(host,port,args);
- 	}
- 	public void init(String host, int port, String[] args) {
- 		int strutsize=10;
- 		int sepsize=5;
- 		getContentPane().setLayout(new BorderLayout());
- 		getContentPane().add(Box.createVerticalStrut(strutsize),BorderLayout.NORTH);
- 		getContentPane().add(Box.createHorizontalStrut(strutsize),BorderLayout.WEST);
- 		getContentPane().add(Box.createHorizontalStrut(strutsize),BorderLayout.EAST);
- 		//always use RLE size for default - we'll assume it's full resolution
- 		vision=null;
- 		for(int i=0; i<args.length; i++) {
- 			if(args[i].toUpperCase().compareTo("RLE")==0) {
- 				setTitle("TekkotsuMon: Vision RLE");
- 				vision=new VisionRle(new VisionRleListener(host,port));
- 				isRLE=true;
- 				isRaw=false;
- 			} else if(args[i].toUpperCase().compareTo("RAW")==0) {
- 				setTitle("TekkotsuMon: Vision Raw");
- 				vision=new VisionRaw(new VisionRawListener(host,port));
- 				isRaw=true;
- 				isRLE=false;
- 			} else
- 				System.err.println("VisionGUI: Unrecognized argument: "+args[i]);
- 		}
- 		if(vision==null) {
- 			System.err.println("VisionGUI: Error: Vision mode not specified");
- 		} else {
- 			vision.setMinimumSize(new Dimension(VisionRleListener.width/2, VisionRleListener.height/2));
- 			vision.setPreferredSize(new Dimension(VisionRleListener.width*2, VisionRleListener.height*2));
- 			vision.setLockAspectRatio(true);
- 			getContentPane().add(vision,BorderLayout.CENTER);
- 		}
- 		{
- 			Box tmp2=Box.createHorizontalBox();
- 			tmp2.add(Box.createHorizontalStrut(strutsize));
- 			{
- 				Box tmp3=Box.createVerticalBox();
- 				if(isRaw) {
- 					Box tmp4=Box.createHorizontalBox();
- 					ButtonGroup group=new ButtonGroup();
- 					JRadioButton tmpRad;
- 					tmpRad=new JRadioButton("RGB");
- 					tmpRad.setSelected(true);
- 					tmpRad.addActionListener(this);
- 					tmpRad.setToolTipText("Shows RGB colorspace");
- 					group.add(tmpRad);
- 					tmp4.add(tmpRad);
- 					tmpRad=new JRadioButton("YUV");
- 					tmpRad.addActionListener(this);
- 					tmpRad.setToolTipText("Shows YUV colorspace");
- 					group.add(tmpRad);
- 					tmp4.add(tmpRad);
- 					tmp3.add(tmp4);
- 				}
- 				aspectBut=new JCheckBox("Lock 11:9 aspect");
- 				aspectBut.setAlignmentX(0.5f);
- 				aspectBut.addActionListener(this);
- 				aspectBut.setActionCommand("aspect");
- 				aspectBut.setSelected(true);
- 				aspectBut.setToolTipText("Forces displayed image to hold transmitted image's aspect ratio");
- 				tmp3.add(aspectBut);
- 				freezeBut=new JButton("Freeze Frame");
- 				freezeBut.setAlignmentX(0.5f);
- 				freezeBut.addActionListener(this);
- 				freezeBut.setActionCommand("freeze");
- 				freezeBut.setEnabled(false);
- 				freezeBut.setToolTipText("Freezes current frame (disconnects from stream)");
- 				tmp3.add(freezeBut);
- 				saveImageBut=new JButton("Save Image Sequence");
- 				saveImageBut.setAlignmentX(0.5f);
- 				saveImageBut.addActionListener(this);
- 				saveImageBut.setActionCommand("seq");
- 				saveImageBut.setEnabled(false);
- 				saveImageBut.setToolTipText("Saves to a series of files - use .jpg or .png extension to choose format; #'s will be replaced with index, otherwise timecode is appended");
- 				tmp3.add(saveImageBut);
- 				tmp3.add(Box.createVerticalStrut(strutsize));
- 				tmp3.add(new JSeparator());
- 				tmp3.add(Box.createVerticalStrut(strutsize-sepsize));
- 				{
- 					Box tmp4=Box.createHorizontalBox();
- 					tmp4.add(status=new JLabel(state));
- 					tmp4.add(Box.createHorizontalGlue());
- 					reconnectBut=new JButton(carrows);
- 					reconnectBut.setPreferredSize(new Dimension(carrows.getIconWidth(),carrows.getIconHeight()));
- 					reconnectBut.addActionListener(this);
- 					reconnectBut.setToolTipText("Drop current connection and try again.");
- 					tmp4.add(reconnectBut);
- 					tmp3.add(tmp4);
- 				}
- 				tmp3.add(Box.createVerticalStrut(strutsize));
- 				tmp2.add(tmp3);
- 			}
- 			tmp2.add(Box.createHorizontalStrut(strutsize));
- 			getContentPane().add(tmp2,BorderLayout.SOUTH);
- 		}
- 		pack();
- 		addWindowListener(new CloseVisionAdapter(this));
- 		vision.getListener().addListener(this);
- 		(new StatusUpdateThread(this)).start();
- 	}
- }
--- 0 ----
Index: AiboPup/tools/mon/VisionListener.java
diff -c AiboPup/tools/mon/VisionListener.java:1.5 AiboPup/tools/mon/VisionListener.java:removed
*** AiboPup/tools/mon/VisionListener.java:1.5	Thu Jun 26 18:45:57 2003
--- AiboPup/tools/mon/VisionListener.java	Fri Oct 10 14:37:54 2003
***************
*** 1,32 ****
- import java.awt.image.BufferedImage;
- import java.util.Vector;
- import java.util.Date;
- 
- public abstract class VisionListener extends TCPListener {
- 	boolean updatedFlag;
- 	Date timestamp;
- 
- 	Vector listeners = new Vector();
- 	void addListener(VisionUpdatedListener l) { listeners.add(l); }
- 	void removeListener(VisionUpdatedListener l) { listeners.remove(l); }
- 	void fireVisionUpdate() {
- 		updatedFlag=true;
- 		for(int i=0; i<listeners.size(); i++)
- 			((VisionUpdatedListener)listeners.get(i)).visionUpdated(this);
- 	}
- 
- 	public abstract BufferedImage getImage();
- 	public Date getTimeStamp() { return timestamp; }
- 
- 	public boolean hasData() {
- 		return updatedFlag;
- 	}
-  
- 	public boolean isConnected() {
- 		return _isConnected;
- 	}
- 
- 	public VisionListener() { super(); }
- 	public VisionListener(int port) { super(port); }
- 	public VisionListener(String host, int port) { super(host,port); }
- }
--- 0 ----
Index: AiboPup/tools/mon/VisionPanel.java
diff -c AiboPup/tools/mon/VisionPanel.java:1.1 AiboPup/tools/mon/VisionPanel.java:removed
*** AiboPup/tools/mon/VisionPanel.java:1.1	Thu Jun 26 18:57:41 2003
--- AiboPup/tools/mon/VisionPanel.java	Fri Oct 10 14:37:54 2003
***************
*** 1,97 ****
- import javax.swing.JPanel;
- import java.awt.image.BufferedImage;
- import java.awt.Graphics;
- import java.awt.Color;
- import java.awt.Dimension;
- import java.awt.FontMetrics;
- 
- public class VisionPanel extends JPanel implements VisionUpdatedListener {
- 	BufferedImage _image;
- 	VisionListener _listener;
- 	boolean lockAspect=false;
- 	static float defAspectRatio=176/(float)144;
- 	float tgtAspect=defAspectRatio;
- 
- 	protected VisionPanel(VisionListener listener) {
- 		_listener=listener;
- 		_listener.addListener(this);
- 		setBackground(Color.BLACK);
- 		setForeground(Color.WHITE);
- 		setOpaque(!lockAspect);
- 	}
- 	
- 	public VisionListener getListener() { return _listener; }
- 	
- 	public void close() {
- 		_listener.kill();
- 	}
- 	
- 	public void open() {
- 		_listener.startThread();
- 	}
- 
- 	public void visionUpdated(VisionListener l) {
- 		repaint();
- 	}
- 	
- 	public void setLockAspectRatio(boolean b) {
- 		if(b!=lockAspect) {
- 			lockAspect=b;
- 			setOpaque(!lockAspect);
- 			repaint();
- 		}
- 	}
- 	
- 	public boolean getLockAspectRatio() { return lockAspect; }
- 
- 	public void setAspectRatio(float asp) {
- 		if(asp<=0)
- 			tgtAspect=defAspectRatio;
- 		else
- 			tgtAspect=asp;
- 		if(getLockAspectRatio())
- 			repaint();
- 	}
- 	
- 	public float getAspectRatio() { return tgtAspect; }
- 
- 	public void setLockAspectRatio(boolean b, float asp) {
- 		setLockAspectRatio(b);
- 		setAspectRatio(asp);
- 	}
- 	
- 	public void paint(Graphics graphics) {
- 		_image=_listener.getImage();
- 		super.paint(graphics);
- 		Dimension sz=getSize();
- 		if(getLockAspectRatio()) {
- 			float curasp=sz.width/(float)sz.height;
- 			float tgtasp=getAspectRatio();
- 			if(curasp>tgtasp) {
- 				int width=(int)(sz.height*tgtasp);
- 				drawImage(graphics,_image, (sz.width-width)/2, 0, width, sz.height);
- 			} else if(curasp<tgtasp) {
- 				int height=(int)(sz.width/tgtasp);
- 				drawImage(graphics,_image, 0, (sz.height-height)/2, sz.width, height);
- 			} else {
- 				drawImage(graphics,_image, 0, 0, sz.width, sz.height);
- 			}
- 		} else
- 			drawImage(graphics,_image, 0, 0, sz.width, sz.height);
- 	}
- 	
- 	protected void drawImage(Graphics g, BufferedImage img, int x, int y, int w, int h) {
- 		if(img!=null)
- 			g.drawImage(img,x,y,w,h,null);
- 		else {
- 			g.setColor(getBackground());
- 			g.fillRect(x,y,w,h);
- 			FontMetrics tmp=g.getFontMetrics();
- 			String msg="No image";
- 			int strw=tmp.stringWidth(msg);
- 			int strh=tmp.getHeight();
- 			g.setColor(getForeground());
- 			g.drawString(msg,(getSize().width-strw)/2,(getSize().height-strh)/2+tmp.getAscent());
- 		}
- 	}
- }
\ No newline at end of file
--- 0 ----
Index: AiboPup/tools/mon/VisionRaw.java
diff -c AiboPup/tools/mon/VisionRaw.java:1.7 AiboPup/tools/mon/VisionRaw.java:removed
*** AiboPup/tools/mon/VisionRaw.java:1.7	Thu Jun 26 04:47:33 2003
--- AiboPup/tools/mon/VisionRaw.java	Fri Oct 10 14:37:54 2003
***************
*** 1,37 ****
- import java.awt.image.*;
- import java.awt.*;
- import javax.swing.*;
- import java.awt.event.*;
- 
- public class VisionRaw extends VisionPanel {
- 	VisionRawListener _visionraw;
- 	
- 	public static void main(String s[]) {
- 		int port=VisionRawListener.defPort;
- 		if(s.length<1) {
- 			System.out.println("Usage: java VisionRaw host [port]");
- 			System.out.println("			 if port is not specified, it defaults to "+port);
- 			System.exit(2);
- 		}
- 		if(s.length>1)
- 			port=Integer.parseInt(s[1]);
- 		JFrame frame=new JFrame("TekkotsuMon: Vision Raw");
- 		frame.setBackground(Color.black);
- 		//frame.getContentPane().setLayout(new FlowLayout());
- 		frame.setSize(new Dimension(VisionRawListener.width*2, VisionRawListener.height*2)); 
- 		VisionRaw vision=new VisionRaw(new VisionRawListener(s[0],port));
- 		frame.getContentPane().add(vision);
- 		frame.addWindowListener(new WindowAdapter() {
- 				public void windowClosing(WindowEvent e) { System.exit(0); } });
- 		frame.show();
- 	}
- 
- 	public VisionRaw(VisionRawListener visionraw) {
- 		super(visionraw);
- 		_visionraw=visionraw;
- 	}
- 
- 	public void setConvertRGB(boolean b) { _visionraw.setConvertRGB(b); }
- 	public boolean getConvertRGB(boolean b) { return _visionraw.getConvertRGB(); }
- }
- 
--- 0 ----
Index: AiboPup/tools/mon/VisionRawListener.java
diff -c AiboPup/tools/mon/VisionRawListener.java:1.8 AiboPup/tools/mon/VisionRawListener.java:removed
*** AiboPup/tools/mon/VisionRawListener.java:1.8	Thu Jun 26 18:45:57 2003
--- AiboPup/tools/mon/VisionRawListener.java	Fri Oct 10 14:37:54 2003
***************
*** 1,115 ****
- import java.io.InputStream;
- import java.net.Socket;
- import javax.swing.JFrame;
- import java.awt.Image;
- import java.awt.image.BufferedImage;
- import java.util.Date;
- 
- public class VisionRawListener extends VisionListener {
- 	static int width=88;
- 	static int height=72;
- 	static int channels=3;
- 	int pktSize=width*height*channels;
- 	byte[] _data=new byte[pktSize];
- 	byte[] _outd=new byte[pktSize];
- 	int[] _pixels=new int[width*height];;
- 	BufferedImage img=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
- 	int bytesRead;
- 	boolean convertRGB=true;
- 	static int defPort=10011;
- 
- 	void connected(Socket socket) {
- 		_isConnected=true;
- 		fireVisionUpdate();
- 		try {
- 			InputStream in=socket.getInputStream();
- 			_isConnected=true;
- 			while (true) {
- 				int br;
- 				bytesRead=0;
- 				while(bytesRead<pktSize) {
- 					br=in.read(_data,bytesRead,(pktSize-bytesRead>1024)?1024:(pktSize-bytesRead));
- 					bytesRead=bytesRead+br;
- 				}
- 				synchronized(_outd) {
- 					byte[] temp=_data;
- 					_data=_outd;
- 					_outd=temp;
- 					timestamp=new Date();
- 				}
- 				fireVisionUpdate();
- 			}
- 		} catch (Exception ex) { }
- 		
- 		try { socket.close(); } catch (Exception ex) { }
- 		_isConnected=false;
- 		fireVisionUpdate();
- 	}
- 	
- 	public byte[] getData() {
- //		frameTimer();
- 		synchronized (_outd) {
- 			updatedFlag=false;
- 			return _outd;
- 		}
- 	}
- 
- 	public void setConvertRGB(boolean b) { 
- 		if(b!=convertRGB) {
- 			convertRGB=b;
- 			updatedFlag=true;
- 			for(int i=0; i<listeners.size(); i++)
- 				((VisionUpdatedListener)listeners.get(i)).visionUpdated(this);
- 		}
- 	}
- 	public boolean getConvertRGB() { return convertRGB; }
- 
- 	public int[] getYUVPixels() {
- 		synchronized(_outd) {
- 			byte[] data=getData();
- 			int offset=0;
- 			for (int i=0; i<width*height; i++) {
- 				int y=(int)data[offset++]&0xFF;
- 				int u=(int)data[offset++]&0xFF;
- 				int v=(int)data[offset++]&0xFF;
- 			_pixels[i]=(255<<24) | (y<<16) | (u<<8) | v;
- 			}
- 		}
- 		return _pixels;
- 	}
- 
- 	public int[] getRGBPixels() {
- 		synchronized(_outd) {
- 			byte[] data=getData();
- 			int offset=0;
- 			for (int i=0; i<width*height; i++) {
- 				int y=(int)data[offset++]&0xFF;
- 				int u=(int)data[offset++]&0xFF;
- 				int v=(int)data[offset++]&0xFF;
- 				u=u*2-255;
- 				v=v*2-255;
- 				int r=y+u;
- 				int b=y+v;
- 				u=u>>1;
- 				v=(v>>2)-(v>>4);
- 				int g=y-u-v;
- 				//			r=r&0xFF; g=g&0xFF; b=b&0xFF;
- 				if (r<0) r=0; if (g<0) g=0; if (b<0) b=0;
- 				if (r>255) r=255; if (g>255) g=255; if (b>255) b=255;
- 				
- 				_pixels[i]=(255<<24) | (r<<16) | (g<<8) | b;
- 			}
- 		}
- 		return _pixels;
- 	}
- 
- 	public BufferedImage getImage() {
- 		int[] data=getConvertRGB()?getRGBPixels():getYUVPixels();
- 		img.setRGB(0,0,width,height,data,0,width);
- 		return img;
- 	}
- 	
- 	public VisionRawListener() { super(); }
- 	public VisionRawListener(int port) { super(port); }
- 	public VisionRawListener(String host, int port) { super(host,port); }
- }
--- 0 ----
Index: AiboPup/tools/mon/VisionRle.java
diff -c AiboPup/tools/mon/VisionRle.java:1.7 AiboPup/tools/mon/VisionRle.java:removed
*** AiboPup/tools/mon/VisionRle.java:1.7	Fri Jun 27 02:03:57 2003
--- AiboPup/tools/mon/VisionRle.java	Fri Oct 10 14:37:54 2003
***************
*** 1,35 ****
- import java.awt.image.*;
- import java.awt.*;
- import javax.swing.*;
- import java.awt.event.*;
- 
- public class VisionRle extends VisionPanel {
- 	VisionRleListener _visionrle;
- 
- 	public static void main(String[] s) { 
- 		int port=VisionRleListener.defPort;
- 		if(s.length<1) {
- 			System.out.println("Usage: java VisionRLE host [port]");
- 			System.out.println("			 if port is not specified, it defaults to "+port);
- 			System.exit(2);
- 		}
- 		if(s.length>1)
- 			port=Integer.parseInt(s[1]);
- 		JFrame frame=new JFrame("TekkotsuMon: Vision Segmented");
- 		frame.setBackground(Color.black);
- 		//frame.getContentPane().setLayout(new FlowLayout());
- 		frame.setSize(new Dimension(VisionRleListener.width, VisionRleListener.height)); 
- 		VisionRle vision=new VisionRle(new VisionRleListener(s[0],port));
- 		frame.getContentPane().add(vision);
- 		frame.addWindowListener(new WindowAdapter() {
- 				public void windowClosing(WindowEvent e) { System.exit(0); } });
- 		frame.show();
- 	}
- 
- 	public VisionRle(VisionRleListener visionrle) {
- 		super(visionrle);
- 		_visionrle=visionrle;
- 	}
- 	
- }
- 
--- 0 ----
Index: AiboPup/tools/mon/VisionRleListener.java
diff -c AiboPup/tools/mon/VisionRleListener.java:1.5 AiboPup/tools/mon/VisionRleListener.java:removed
*** AiboPup/tools/mon/VisionRleListener.java:1.5	Thu Jun 26 18:45:57 2003
--- AiboPup/tools/mon/VisionRleListener.java	Fri Oct 10 14:37:54 2003
***************
*** 1,113 ****
- import java.io.InputStream;
- import java.net.Socket;
- import java.awt.Image;
- import java.awt.image.IndexColorModel;
- import java.awt.image.BufferedImage;
- import java.util.Date;
- 
- public class VisionRleListener extends VisionListener {
- 	static int width=176;
- 	static int height=144;
- 	byte[] _data=new byte[22*height*3*2];
- 	byte[] _outd=new byte[width*height];
- 	static int defPort=10012;
- 	static final boolean _debug=false;
- 
- 	//todo: read this from the same file the dog is using
- 	static final byte cmap[]={ (byte)  0, (byte)  0, (byte)  0,
- 	                           (byte)  0, (byte)  0, (byte)  0,
- 	                           (byte)  0, (byte)128, (byte)255,
- 	                           (byte)  0, (byte)128, (byte)  0,
- 	                           (byte)255, (byte)128, (byte)  0,
- 	                           (byte)  0, (byte)255, (byte)  0,
- 	                           (byte)128, (byte)  0, (byte)255,
- 	                           (byte)255, (byte)  0, (byte)  0,
- 	                           (byte)255, (byte)128, (byte)228,
- 	                           (byte)255, (byte)255, (byte)  0,
- 	                           (byte)200, (byte)200, (byte)228,
- 	                           (byte)200, (byte)100, (byte)  0  };
- 	IndexColorModel _cmodel=new IndexColorModel(7, 12, cmap, 0, false);
- 	BufferedImage img=new BufferedImage(width,height,BufferedImage.TYPE_BYTE_INDEXED,_cmodel);
- 
- 
- 	void connected(Socket socket) {
- 		_isConnected=true;
- 		fireVisionUpdate();
- 		try {
- 			InputStream in=socket.getInputStream();
- 			while (true) {
- 				int size=readInt(in);
- 				if(!_isConnected) break;
- 				size=size*3;
- 				readBytes(_data, in, size);
- 				if(!_isConnected) break;
- 				timestamp=new Date();
- 				decodeRLE(size);
- 				fireVisionUpdate();
- 			}
- 		} catch (Exception ex) { }
- 
- 		try { socket.close(); } catch (Exception ex) { }
- 		_isConnected=false;
- 		fireVisionUpdate();
- 	}
- 
- 	void decodeRLE(int pktSize) {
- 		int curx=0, cury=0;
- 		int dlength=pktSize;
- 		int dpos=0;
- 
- 		synchronized (_outd) {
- 			for (; dlength>=3 && cury<height;) {
- 				byte color;
- 				color=_data[dpos++];
- 				color++;
- 				int x=b2i(_data[dpos++]);
- 				int len=b2i(_data[dpos++]);
- 				dlength-=3;
- 				if (x < curx) {
- 					if (_debug) System.out.println("backwards x movement");
- 					break;
- 				}
- 
- 				for (; curx < x; curx++)
- 					_outd[cury*width+curx]=1;
- 
- 				if (curx+len>width) {
- 					if (_debug) System.out.println("run past end");
- 					break;
- 				}
- 
- 				for (; len>0; len--, curx++)
- 					_outd [cury*width+curx]=color;
- 				if (curx==width) {
- 					cury++;
- 					curx=0;
- 				}
- 			}
- 		}
- 		if (cury!=height) {
- 			if (_debug) System.out.println("early end of data\n");
- 		}
- 	}
- 
- 	public byte[] getData() {
- //		frameTimer();
- 		synchronized (_outd) {
- 			updatedFlag=false;
- 			return _outd;
- 		}
- 	}
- 
- 	public BufferedImage getImage() {
- 		synchronized (_outd) {
- 			byte[] data=getData();
- 			img.getRaster().setDataElements(0,0,width,height,data);
- 		}
- 		return img;
- 	}
- 
- 	public VisionRleListener() { super(); }
- 	public VisionRleListener(int port) { super(port); }
- 	public VisionRleListener(String host, int port) { super(host,port); }
- }
--- 0 ----
Index: AiboPup/tools/mon/VisionUpdatedListener.java
diff -c AiboPup/tools/mon/VisionUpdatedListener.java:1.2 AiboPup/tools/mon/VisionUpdatedListener.java:removed
*** AiboPup/tools/mon/VisionUpdatedListener.java:1.2	Fri Jun 20 04:45:38 2003
--- AiboPup/tools/mon/VisionUpdatedListener.java	Fri Oct 10 14:37:54 2003
***************
*** 1,4 ****
- public interface VisionUpdatedListener {
- 	public void visionUpdated(VisionListener comm);
- }
- 
--- 0 ----
Index: AiboPup/tools/mon/WM2DMData.java
diff -c AiboPup/tools/mon/WM2DMData.java:1.1 AiboPup/tools/mon/WM2DMData.java:removed
*** AiboPup/tools/mon/WM2DMData.java:1.1	Thu Mar  6 13:21:15 2003
--- AiboPup/tools/mon/WM2DMData.java	Fri Oct 10 14:37:54 2003
***************
*** 1,13 ****
- // Data container for the WorldModel2 spherical depth map
- 
- public class WM2DMData {
-   public float[] DM_depth;
-   public float[] DM_confidence;
-   public int[] DM_color;
- 
-   WM2DMData() {
-     DM_depth = new float[WorldModel2Conf.DM_CELL_COUNT];
-     DM_confidence = new float[WorldModel2Conf.DM_CELL_COUNT];
-     DM_color = new int[WorldModel2Conf.DM_CELL_COUNT];
-   }
- }
--- 0 ----
Index: AiboPup/tools/mon/WM2DMListener.java
diff -c AiboPup/tools/mon/WM2DMListener.java:1.1 AiboPup/tools/mon/WM2DMListener.java:removed
*** AiboPup/tools/mon/WM2DMListener.java:1.1	Thu Mar  6 13:21:15 2003
--- AiboPup/tools/mon/WM2DMListener.java	Fri Oct 10 14:37:54 2003
***************
*** 1,65 ****
- // A Listener for the WorldModel2 depth map data
- import java.io.InputStream;
- import java.net.Socket;
- 
- // Much of this code has been copied from WorldStateJointsListener.java.
- // I'm not too certain how it works, but I think a fair part of it has to do
- // with synchronization.
- public class WM2DMListener extends TCPListener {
-   boolean _updatedFlag=false;
-   WM2DMData _data;
-   WM2DMData _outd;
- 
-   // Evidently this is the meat of the class
-   void connected(Socket socket) {
-     _isConnected = true;
-     _data = new WM2DMData();
-     _outd = new WM2DMData();
- 
-     try {
-       // CONNECT
-       InputStream in=socket.getInputStream();
-       // READ FOREVER
-       for(;;) {
- 	// read in all WM2 data
- 	for(int i=0; i<WorldModel2Conf.DM_CELL_COUNT; ++i) {
- 	  _data.DM_depth[i] = readFloat(in);
- 	  _data.DM_confidence[i] = readFloat(in);
- 	  _data.DM_color[i] = readInt(in);
- 	}
- 
- 	// this must be some lock thing. I really don't know why it works
- 	// this way.
- 	synchronized(_outd) {
- 	  WM2DMData temp = _data;
- 	  _data = _outd;	// why are we saving the old data?
- 	  _outd = temp;
- 	  _updatedFlag = true;
- 	}
-       }
-     } catch(Exception e) {}
- 
-     // DISCONNECT
-     try { socket.close(); } catch(Exception e) {}
-     _isConnected = false;
-   }
- 
- 
-   // Some state inquiry functions
-   public boolean hasData() { return _updatedFlag; }
-   public boolean isConnected() { return _isConnected; }
- 
- 
-   // Data extraction
-   public WM2DMData getData() {
-     synchronized(_outd) {
-       _updatedFlag = false;
-       return _outd;
-     }
-   }
- 
-   // Constructors
-   public WM2DMListener() { super(); }
-   public WM2DMListener(int port) { super(port); }
-   public WM2DMListener(String host, int port) { super(host, port); }
- }
--- 0 ----
Index: AiboPup/tools/mon/WM2FSData.java
diff -c AiboPup/tools/mon/WM2FSData.java:1.2 AiboPup/tools/mon/WM2FSData.java:removed
*** AiboPup/tools/mon/WM2FSData.java:1.2	Wed May 28 10:55:54 2003
--- AiboPup/tools/mon/WM2FSData.java	Fri Oct 10 14:37:54 2003
***************
*** 1,14 ****
- // Data container for the WorldModel2 FastSLAM subsystem
- 
- public class WM2FSData {
-   public float[][] FS_particlesPos;
-   public float FS_x, FS_y, FS_theta;
-   public float[][] FS_landmarkPos;
-   public float[][] FS_covariance;
- 
-   WM2FSData() {
-     FS_particlesPos = new float[WorldModel2Conf.AFS_NUM_PARTICLES][3];
-     FS_landmarkPos = new float[WorldModel2Conf.AFS_NUM_LANDMARKS][2];
-     FS_covariance = new float[WorldModel2Conf.AFS_NUM_LANDMARKS][4];
-   }
- }
--- 0 ----
Index: AiboPup/tools/mon/WM2FSListener.java
diff -c AiboPup/tools/mon/WM2FSListener.java:1.2 AiboPup/tools/mon/WM2FSListener.java:removed
*** AiboPup/tools/mon/WM2FSListener.java:1.2	Wed May 28 10:55:54 2003
--- AiboPup/tools/mon/WM2FSListener.java	Fri Oct 10 14:37:54 2003
***************
*** 1,80 ****
- // A Listener for the WorldModel2 FastSLAM data
- import java.io.InputStream;
- import java.net.Socket;
- 
- // Much of this code has been copied from WorldStateJointsListener.java.
- // I'm not too certain how it works, but I think a fair part of it has to do
- // with synchronization.
- public class WM2FSListener extends TCPListener {
-   boolean _updatedFlag=false;
-   WM2FSData _data;
-   WM2FSData _outd;
- 
-   // Evidently this is the meat of the class
-   void connected(Socket socket) {
-     _isConnected = true;
-     _data = new WM2FSData();
-     _outd = new WM2FSData();
- 
-     try {
-       // CONNECT
-       InputStream in=socket.getInputStream();
-       // READ FOREVER
-       for(;;) {
- 	// read in all particle positions
- 	for(int i=0; i<WorldModel2Conf.AFS_NUM_PARTICLES; ++i) {
- 	  _data.FS_particlesPos[i][0] = readFloat(in);
- 	  _data.FS_particlesPos[i][1] = readFloat(in);
- 	  _data.FS_particlesPos[i][2] = readFloat(in);
- 	}
- 
- 	// read in robot coordinates
- 	_data.FS_x = readFloat(in);
- 	_data.FS_y = readFloat(in);
- 	_data.FS_theta = readFloat(in);
- 
- 	// read in landmark locations and covariances
- 	for(int i=0; i<WorldModel2Conf.AFS_NUM_LANDMARKS; ++i) {
- 	  _data.FS_landmarkPos[i][0] = readFloat(in);
- 	  _data.FS_landmarkPos[i][1] = readFloat(in);
- 
- 	  _data.FS_covariance[i][0] = readFloat(in);
- 	  _data.FS_covariance[i][1] = _data.FS_covariance[i][2] = readFloat(in);
- 	  _data.FS_covariance[i][3] = readFloat(in);
- 	}
- 
- 	// this must be some lock thing. I really don't know why it works
- 	// this way.
- 	synchronized(_outd) {
- 	  WM2FSData temp = _data;
- 	  _data = _outd;	// why are we saving the old data?
- 	  _outd = temp;
- 	  _updatedFlag = true;
- 	}
-       }
-     } catch(Exception e) {}
- 
-     // DISCONNECT
-     try { socket.close(); } catch(Exception e) {}
-     _isConnected = false;
-   }
- 
- 
-   // Some state inquiry functions
-   public boolean hasData() { return _updatedFlag; }
-   public boolean isConnected() { return _isConnected; }
- 
- 
-   // Data extraction
-   public WM2FSData getData() {
-     synchronized(_outd) {
-       _updatedFlag = false;
-       return _outd;
-     }
-   }
- 
-   // Constructors
-   public WM2FSListener() { super(); }
-   public WM2FSListener(int port) { super(port); }
-   public WM2FSListener(String host, int port) { super(host, port); }
- }
--- 0 ----
Index: AiboPup/tools/mon/WM2HMData.java
diff -c AiboPup/tools/mon/WM2HMData.java:1.1 AiboPup/tools/mon/WM2HMData.java:removed
*** AiboPup/tools/mon/WM2HMData.java:1.1	Thu Mar  6 13:21:16 2003
--- AiboPup/tools/mon/WM2HMData.java	Fri Oct 10 14:37:54 2003
***************
*** 1,16 ****
- // Data container for the WorldModel2 horizontal height map. Also is used
- // for the global height map
- 
- public class WM2HMData {
-   public float[] HM_height;
-   public float[] HM_trav;
-   public float[] HM_confidence;
-   public int[] HM_color;
- 
-   WM2HMData() {
-     HM_height = new float[WorldModel2Conf.HM_CELL_COUNT];
-     HM_trav = new float[WorldModel2Conf.HM_CELL_COUNT];
-     HM_confidence = new float[WorldModel2Conf.HM_CELL_COUNT];
-     HM_color = new int[WorldModel2Conf.HM_CELL_COUNT];
-   }
- }
--- 0 ----
Index: AiboPup/tools/mon/WM2HMListener.java
diff -c AiboPup/tools/mon/WM2HMListener.java:1.1 AiboPup/tools/mon/WM2HMListener.java:removed
*** AiboPup/tools/mon/WM2HMListener.java:1.1	Thu Mar  6 13:21:16 2003
--- AiboPup/tools/mon/WM2HMListener.java	Fri Oct 10 14:37:54 2003
***************
*** 1,66 ****
- // A Listener for the WorldModel2 height map data
- import java.io.InputStream;
- import java.net.Socket;
- 
- // Much of this code has been copied from WorldStateJointsListener.java.
- // I'm not too certain how it works, but I think a fair part of it has to do
- // with synchronization.
- public class WM2HMListener extends TCPListener {
-   boolean _updatedFlag=false;
-   WM2HMData _data;
-   WM2HMData _outd;
- 
-   // Evidently this is the meat of the class
-   void connected(Socket socket) {
-     _isConnected = true;
-     _data = new WM2HMData();
-     _outd = new WM2HMData();
- 
-     try {
-       // CONNECT
-       InputStream in=socket.getInputStream();
-       // READ FOREVER
-       for(;;) {
- 	// read in all WM2 data
- 	for(int i=0; i<WorldModel2Conf.HM_CELL_COUNT; ++i) {
- 	  _data.HM_height[i] = readFloat(in);
- 	  _data.HM_trav[i] = readFloat(in);
- 	  _data.HM_confidence[i] = readFloat(in);
- 	  _data.HM_color[i] = readInt(in);
- 	}
- 
- 	// this must be some lock thing. I really don't know why it works
- 	// this way.
- 	synchronized(_outd) {
- 	  WM2HMData temp = _data;
- 	  _data = _outd;	// why are we saving the old data?
- 	  _outd = temp;
- 	  _updatedFlag = true;
- 	}
-       }
-     } catch(Exception e) {}
- 
-     // DISCONNECT
-     try { socket.close(); } catch(Exception e) {}
-     _isConnected = false;
-   }
- 
- 
-   // Some state inquiry functions
-   public boolean hasData() { return _updatedFlag; }
-   public boolean isConnected() { return _isConnected; }
- 
- 
-   // Data extraction
-   public WM2HMData getData() {
-     synchronized(_outd) {
-       _updatedFlag = false;
-       return _outd;
-     }
-   }
- 
-   // Constructors
-   public WM2HMListener() { super(); }
-   public WM2HMListener(int port) { super(port); }
-   public WM2HMListener(String host, int port) { super(host, port); }
- }
--- 0 ----
Index: AiboPup/tools/mon/WalkGUI.java
diff -c AiboPup/tools/mon/WalkGUI.java:1.5 AiboPup/tools/mon/WalkGUI.java:removed
*** AiboPup/tools/mon/WalkGUI.java:1.5	Sun Jul  6 21:00:10 2003
--- AiboPup/tools/mon/WalkGUI.java	Fri Oct 10 14:37:54 2003
***************
*** 1,336 ****
- import javax.swing.*;
- import java.awt.*;
- import java.awt.geom.*;
- import java.awt.event.*;
- import javax.swing.event.*;
- 
- public class WalkGUI extends JFrame implements PointPick.PointPickedListener, ChangeListener, ActionListener, MouseListener, MechaController.MechaUpdatedListener {
- 	static int defPort=10050;
- 	PointPick pp;
- 	JSlider xslide;
- 	JSlider yslide;
- 	JSlider aslide;
- 	JButton stopBut;
- 	JRadioButton horizRotateBut;
- 	JRadioButton horizStrafeBut;
- 	boolean horizButFake=false;
- 	JCheckBox resetOnRelease;
- 	JLabel status;
- 	JButton reconnectBut;
- 	MechaController comm;
- 	static int slidermax=10000;
- 	final static ImageIcon carrows = new ImageIcon("images/chasingarrows.png");
- 
- 	static public void main(String s[]) {
- 		int port=defPort;
- 		if(s.length<1)
- 			usage();
- 		if(s.length>1)
- 			port=Integer.parseInt(s[1]);
- 		String[] args=new String[s.length-1];
- 		for(int i=0; i<s.length-1; i++)
- 			args[i-1]=s[i];
- 		JFrame frame=new WalkGUI(s[0],port,args);
- 		/*		frame.addWindowListener(new WindowAdapter() {
- 			public void windowClosing(WindowEvent e) { frame.dispose(); }
- 			});*/
- 	}
- 	
- 	public static void usage() {
- 		System.out.println("Usage: java WalkGUI host [port]");
- 		System.out.println("       if port is not specified, it defaults to: "+defPort);
- 		System.exit(2);
- 	}
- 		
- 	public WalkGUI(String host, int port, String args[]) {
- 		super("TekkotsuMon: Walk Remote Control");
- 		pack();
- 		comm=new MechaController(host,port);
- 		comm.addMechaUpdatedListener(this);
- 		show();
- 	}
- 
- 	public void close() {
- 		comm.kill();
- 		dispose();
- 	}
- 	
- 	class CloseWalkAdapter extends WindowAdapter {
- 		WalkGUI gui;
- 		CloseWalkAdapter(WalkGUI gui) {this.gui=gui;}
- 		public void windowClosing(WindowEvent e) {
- 			gui.close();
- 		}
- 	}
- 
- 	public void pointPicked(Point2D.Float p, MouseEvent e, PointPick pp) {
- 		boolean isBut2=(e.getModifiersEx()&MouseEvent.BUTTON3_DOWN_MASK)==MouseEvent.BUTTON3_DOWN_MASK;
- 		if(!horizButFake && isBut2) {
- 			if(horizStrafeBut.isSelected())
- 				horizRotateBut.setSelected(true);
- 			else
- 				horizStrafeBut.setSelected(true);
- 			horizButFake=isBut2;
- 		}
- 		if(horizRotateBut.isSelected())
- 			aslide.setValue((int)(slidermax*p.x));
- 		if(horizStrafeBut.isSelected())
- 			yslide.setValue((int)(slidermax*p.x));
- 		xslide.setValue((int)(slidermax*p.y));
- 	}
- 
- 	public void mechaUpdated(MechaController comm) {
- 		if(status!=null) {
- 			pp.setEnabled(comm._isConnected);
- 			xslide.setEnabled(comm._isConnected);
- 			yslide.setEnabled(comm._isConnected);
- 			aslide.setEnabled(comm._isConnected);
- 			stopBut.setEnabled(comm._isConnected);
- 			if(comm._isConnected)
- 				status.setText("Connected.");
- 			else
- 				status.setText("Reconnecting...");
- 		}
- 	}
- 
- 	public void mouseClicked(MouseEvent e) {}
- 	public void mouseEntered(MouseEvent e) {}
- 	public void mouseExited(MouseEvent e) {}
- 	public void mousePressed(MouseEvent e) {
- 		boolean isBut2=(e.getModifiersEx()&MouseEvent.BUTTON3_DOWN_MASK)==MouseEvent.BUTTON3_DOWN_MASK;
- 		if(!horizButFake && isBut2) {
- 			if(horizStrafeBut.isSelected())
- 				horizRotateBut.setSelected(true);
- 			else
- 				horizStrafeBut.setSelected(true);
- 			horizButFake=isBut2;
- 			updatePP();
- 		}
- 	}
- 	public void mouseReleased(MouseEvent e) {
- 		boolean isBut1=(e.getModifiersEx()&MouseEvent.BUTTON1_DOWN_MASK)==MouseEvent.BUTTON1_DOWN_MASK;
- 		boolean isBut2=(e.getModifiersEx()&MouseEvent.BUTTON3_DOWN_MASK)==MouseEvent.BUTTON3_DOWN_MASK;
- 		if(horizButFake && !isBut2) {
- 			if(horizStrafeBut.isSelected())
- 				horizRotateBut.setSelected(true);
- 			else
- 				horizStrafeBut.setSelected(true);
- 			horizButFake=isBut2;
- 			updatePP();
- 		}
- 		if(!isBut1 && !isBut2) {
- 			if(resetOnRelease.isSelected())
- 				stopBut.doClick();
- 		}
- 	}
- 
- 	public void stateChanged(ChangeEvent e) {
- 		if(e.getSource()==xslide) {
- 			comm.sendCommand("f",xslide.getValue()/(float)slidermax*180.0f);
- 			pp.doSetPoint(pp.getXValue(),xslide.getValue()/(float)slidermax);
- 		} else if(e.getSource()==yslide) {
- 			comm.sendCommand("s",yslide.getValue()/(float)slidermax*-140.0f);
- 			if(horizStrafeBut.isSelected())
- 				pp.doSetPoint(yslide.getValue()/(float)slidermax,pp.getYValue());
- 		} else if(e.getSource()==aslide) {
- 			// Rotation is both fast and sensitive, so we'll exponentiate it to
- 			// drag out the low end without sacrificing the high end
- 			float aval=aslide.getValue()/(float)slidermax;
- 			aval*=(aval<0?-aval:aval);
- 			comm.sendCommand("r",aval*-1.8f);
- 			float tmp=pp.getYValue();
- 			if(horizRotateBut.isSelected())
- 				pp.doSetPoint(aslide.getValue()/(float)slidermax,pp.getYValue());
- 		}
- 	}
- 
- 	public void actionPerformed(ActionEvent e) {
- 		if(e.getSource()==stopBut) {
- 			xslide.setValue(0);
- 			yslide.setValue(0);
- 			aslide.setValue(0);
- 		} else if(e.getSource()==horizRotateBut) {
- 			updatePP();
- 		} else if(e.getSource()==horizStrafeBut) {
- 			updatePP();
- 		} else if(e.getSource()==reconnectBut) {
- 			int port=comm._port;
- 			String addr=comm._host;
- 			comm.kill();
- 			comm.removeMechaUpdatedListener(this);
- 			comm = new MechaController(comm._host,comm._port);
- 			comm.addMechaUpdatedListener(this);
- 		}
- 	}
- 	
- 	public void updatePP() {
- 		float x=0;
- 		if(horizStrafeBut.isSelected())
- 			x=yslide.getValue()/(float)slidermax;
- 		else if(horizRotateBut.isSelected())
- 			x=aslide.getValue()/(float)slidermax;
- 		pp.doSetPoint(x,xslide.getValue()/(float)slidermax);
- 	}
- 
- 	public void frameInit() {
- 		super.frameInit();
- 		
- 		int strutsize=10;
- 		int sepsize=5;
- 		getContentPane().setLayout(new BorderLayout());
- 		getContentPane().add(Box.createHorizontalStrut(strutsize),BorderLayout.EAST);
- 		getContentPane().add(Box.createHorizontalStrut(strutsize),BorderLayout.WEST);
- 		getContentPane().add(Box.createVerticalStrut(strutsize),BorderLayout.NORTH);
- 		JPanel p=new JPanel(new SquareRightLayout());
- 		p.setLayout(new SquareRightLayout());
- 		pp=new PointPick(false);
- 		pp.addPointPickedListener(this);
- 		pp.addMouseListener(this);
- 		p.add(pp,SquareRightLayout.SQUARE);
- 		Box tmp=Box.createHorizontalBox();
- 		tmp.add(Box.createHorizontalStrut(strutsize));
- 		JSeparator sep;
- 		sep=new JSeparator(SwingConstants.VERTICAL);
- 		sep.setMaximumSize(new Dimension(sepsize,slidermax));
- 		tmp.add(sep);
- 		tmp.add(Box.createHorizontalStrut(strutsize));
- 		{
- 			Box tmp2=Box.createVerticalBox();
- 			tmp2.add(Box.createVerticalGlue());
- 			int labwidth=45;
- 			tmp2.add(new JLabel("Forward:"));
- 			{
- 				Box tmp3=Box.createHorizontalBox();
- 				xslide=new JSlider(-slidermax,slidermax,0);
- 				xslide.addChangeListener(this);
- 				JLabel lab;
- 				lab=new JLabel("Aft");
- 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
- 				lab.setHorizontalAlignment(SwingConstants.RIGHT);
- 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
- 				tmp3.add(lab);
- 				tmp3.add(xslide);
- 				lab=new JLabel("Fore");
- 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
- 				lab.setHorizontalAlignment(SwingConstants.LEFT);
- 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
- 				tmp3.add(lab);
- 				//tmp3.add(new JButton("Zero"));
- 				tmp3.setAlignmentX(0);
- 				tmp2.add(tmp3);
- 			}
- 			tmp2.add(Box.createVerticalStrut(strutsize));
- 			tmp2.add(new JLabel("Strafe:"));
- 			{
- 				Box tmp3=Box.createHorizontalBox();
- 				yslide=new JSlider(-slidermax,slidermax,0);
- 				yslide.addChangeListener(this);
- 				JLabel lab;
- 				lab=new JLabel("Left");
- 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
- 				lab.setHorizontalAlignment(SwingConstants.RIGHT);
- 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
- 				tmp3.add(lab);
- 				tmp3.add(yslide);
- 				lab=new JLabel("Right");
- 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
- 				lab.setHorizontalAlignment(SwingConstants.LEFT);
- 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
- 				tmp3.add(lab);
- 				//tmp3.add(new JButton("Zero"));
- 				tmp3.setAlignmentX(0);
- 				tmp2.add(tmp3);
- 			}
- 			tmp2.add(Box.createVerticalStrut(strutsize));
- 			tmp2.add(new JLabel("Rotate:"));
- 			{
- 				Box tmp3=Box.createHorizontalBox();
- 				aslide=new JSlider(-slidermax,slidermax,0);
- 				aslide.addChangeListener(this);
- 				JLabel lab;
- 				lab=new JLabel("Counter");
- 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
- 				lab.setHorizontalAlignment(SwingConstants.RIGHT);
- 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
- 				tmp3.add(lab);
- 				tmp3.add(aslide);
- 				lab=new JLabel("Clock");
- 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
- 				lab.setHorizontalAlignment(SwingConstants.LEFT);
- 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
- 				tmp3.add(lab);
- 				//tmp3.add(new JButton("Zero"));
- 				tmp3.setAlignmentX(0);
- 				tmp2.add(tmp3);
- 			}
- 			tmp2.add(Box.createVerticalStrut(strutsize));
- 			{
- 				Box tmp3=Box.createHorizontalBox();
- 				tmp3.add(Box.createHorizontalGlue());
- 				stopBut=new JButton("Stop!");
- 				stopBut.addActionListener(this);
- 				rootPane.setDefaultButton(stopBut);
- 				tmp3.add(stopBut);
- 				tmp3.add(Box.createHorizontalGlue());
- 				tmp3.setAlignmentX(0);
- 				tmp2.add(tmp3);
- 			}
- 			tmp2.add(Box.createVerticalStrut(strutsize));
- 			ButtonGroup bg = new ButtonGroup();
- 			horizRotateBut=new JRadioButton("Horizontal is Rotate");
- 			horizRotateBut.addActionListener(this);
- 			horizRotateBut.setSelected(true);
- 			bg.add(horizRotateBut);
- 			tmp2.add(horizRotateBut);
- 			horizStrafeBut=new JRadioButton("Horizontal is Strafe");
- 			horizStrafeBut.addActionListener(this);
- 			bg.add(horizStrafeBut);
- 			tmp2.add(horizStrafeBut);
- 			tmp2.add(Box.createVerticalStrut(strutsize));
- 			tmp2.add(resetOnRelease=new JCheckBox("Reset on release")); 
- 			resetOnRelease.setSelected(true);
- 			tmp2.add(Box.createVerticalGlue());
- 			tmp.add(tmp2);
- //			Dimension d=tmp2.getMinimumSize();
- //			System.out.println(d);
- //			pp.setSize(d);
- //			pp.setMinimumSize(d);
- //			pp.setPreferredSize(d);
- //			pp.setMaximumSize(d);
- 		}
- 		p.add(tmp,SquareRightLayout.RIGHT);
- 		getContentPane().add(p,BorderLayout.CENTER);
- 		{
- 			Box tmp2=Box.createHorizontalBox();
- 			tmp2.add(Box.createHorizontalStrut(strutsize));
- 			{
- 				Box tmp3=Box.createVerticalBox();
- 				tmp3.add(Box.createVerticalStrut(strutsize));
- 				tmp3.add(new JSeparator());
- 				tmp3.add(Box.createVerticalStrut(strutsize-sepsize));
- 				{
- 					Box tmp4=Box.createHorizontalBox();
- 					tmp4.add(status=new JLabel("Connecting..."));
- 					tmp4.add(Box.createHorizontalGlue());
- 					reconnectBut=new JButton(carrows);
- 					reconnectBut.setPreferredSize(new Dimension(carrows.getIconWidth(),carrows.getIconHeight()));
- 					reconnectBut.addActionListener(this);
- 					reconnectBut.setToolTipText("Drop current connection and try again.");
- 					tmp4.add(reconnectBut);
- 					tmp3.add(tmp4);
- 				}
- 				tmp3.add(Box.createVerticalStrut(strutsize));
- 				tmp2.add(tmp3);
- 			}
- 			tmp2.add(Box.createHorizontalStrut(strutsize));
- 			getContentPane().add(tmp2,BorderLayout.SOUTH);
- 		}
- 
- 		pp.setEnabled(false);
- 		xslide.setEnabled(false);
- 		yslide.setEnabled(false);
- 		aslide.setEnabled(false);
- 		stopBut.setEnabled(false);
- 		addWindowListener(new CloseWalkAdapter(this));
- 	}
- }
--- 0 ----
Index: AiboPup/tools/mon/WorldModel2Conf.java
diff -c AiboPup/tools/mon/WorldModel2Conf.java:1.2 AiboPup/tools/mon/WorldModel2Conf.java:removed
*** AiboPup/tools/mon/WorldModel2Conf.java:1.2	Wed May 28 10:55:54 2003
--- AiboPup/tools/mon/WorldModel2Conf.java	Fri Oct 10 14:37:54 2003
***************
*** 1,43 ****
- // Constants regarding the configuration of WorldModel2
- //
- // YOU MUST CHANGE THE CONSTANTS TO MATCH THOSE IN THE WorldModel2
- // CONFIGURATION FILES--otherwise, the amounts of data read and written won't
- // match up.
- 
- import java.lang.Math;
- 
- public class WorldModel2Conf {
-   // Array dimensions in pixels
-     // from WorldModel2/Maps/Configuration.h
-   public static final int ALM_DM_V_SIZE = 51;
-   public static final int ALM_DM_H_SIZE = 89;
-   public static final int ALM_HM_SIZE = 20; // don't forget that this value
- 					    // is the *radius* of the height
- 					    // map in pixels, hence one half
- 					    // of the edge length
-   public static final int AGM_V_SIZE = 100;
-   public static final int AGM_H_SIZE = 100;
-     // from WorldModel2/FastSLAM/Configuration.h
-   public static final int AFS_NUM_LANDMARKS = 12;
-   public static final int AFS_NUM_PARTICLES = 400;
- 
-   // Array dimensions in measurement units
-     // from WorldModel2/Maps/Configuration.h
-   public static final double ALM_DM_TOP = R(25.0);
-   public static final double ALM_DM_BOTTOM = R(-75.0);
-   public static final double ALM_DM_LEFT = R(85.0);
-   public static final double ALM_DM_RIGHT = R(-85.0);
-   public static final double ALM_HM_RADIUS = 400;
-   public static final double AGM_TOP = 2000;
-   public static final double AGM_BOTTOM = -2000;
-   public static final double AGM_LEFT = -2000;
-   public static final double AGM_RIGHT = 2000;
- 
-   // These computed constants should not need to change.
-   public static final int HM_CELL_COUNT = 4*ALM_HM_SIZE*ALM_HM_SIZE;
-   public static final int DM_CELL_COUNT = ALM_DM_V_SIZE*ALM_DM_H_SIZE;
-   public static final int GM_CELL_COUNT = AGM_V_SIZE*AGM_H_SIZE;
- 
-   // Convenience degree to radian function
-   public static final double R(double D) { return D*Math.PI/180.0; }
- }
--- 0 ----
Index: AiboPup/tools/mon/WorldStateJointsListener.java
diff -c AiboPup/tools/mon/WorldStateJointsListener.java:1.1 AiboPup/tools/mon/WorldStateJointsListener.java:removed
*** AiboPup/tools/mon/WorldStateJointsListener.java:1.1	Thu Feb 20 14:51:18 2003
--- AiboPup/tools/mon/WorldStateJointsListener.java	Fri Oct 10 14:37:54 2003
***************
*** 1,57 ****
- import java.io.InputStream;
- import java.net.Socket;
- 
- public class WorldStateJointsListener extends TCPListener {
-   boolean _updatedFlag=false;
-   Joints _data;
-   Joints _outd;
- 
-   void connected(Socket socket) {
-     _isConnected=true;
-     _data=new Joints();
-     _outd=new Joints();
-     try {
-       InputStream in=socket.getInputStream();
-       while (true) {
-         _data.timestamp=readInt(in);
-         for (int i=0; i<18; i++)
-           _data.positions[i]=readFloat(in);
-         for (int i=0; i<6; i++)
-           _data.sensors[i]=readFloat(in);
-         for (int i=0; i<8; i++)
-           _data.buttons[i]=readFloat(in);
-         for (int i=0; i<18; i++)
-           _data.duties[i]=readFloat(in);
- 
-         synchronized(_outd) {
-           Joints temp=_data;
-           _data=_outd;
-           _outd=temp;
-           _updatedFlag=true;
-         }
-       }
-     } catch (Exception ex) { }
- 
-     try { socket.close(); } catch (Exception ex) { }
-     _isConnected=false;
-   }
-  
-   public boolean hasData() {
-     return _updatedFlag;
-   }
- 
-   public Joints getData() {
-     synchronized (_outd) {
-       _updatedFlag=false;
-       return _outd;
-     }
-   }
- 
-   public boolean isConnected() {
-     return _isConnected;
-   }
- 
-   public WorldStateJointsListener() { super(); }
-   public WorldStateJointsListener(int port) { super(port); }
-   public WorldStateJointsListener(String host, int port) { super(host,port); }
- }
--- 0 ----
Index: AiboPup/tools/mon/WorldStatePIDsListener.java
diff -c AiboPup/tools/mon/WorldStatePIDsListener.java:1.1 AiboPup/tools/mon/WorldStatePIDsListener.java:removed
*** AiboPup/tools/mon/WorldStatePIDsListener.java:1.1	Thu Feb 20 14:51:18 2003
--- AiboPup/tools/mon/WorldStatePIDsListener.java	Fri Oct 10 14:37:54 2003
***************
*** 1,55 ****
- import java.io.InputStream;
- import java.net.Socket;
- 
- public class WorldStatePIDsListener extends TCPListener {
-   boolean _updatedFlag=false;
-   PIDs _data;
-   PIDs _outd;
- 
-   void connected(Socket socket) {
-     _isConnected=true;
-     _data=new PIDs();
-     _outd=new PIDs();
-     try {
-       InputStream in=socket.getInputStream();
-       while (true) {
-         _data.timestamp=readInt(in);
-         for (int i=0; i<18; i++)
-           _data.P[i]=readFloat(in);
-         for (int i=0; i<18; i++)
-           _data.I[i]=readFloat(in);
-         for (int i=0; i<18; i++)
-           _data.D[i]=readFloat(in);
- 
-         synchronized(_outd) {
-           PIDs temp=_data;
-           _data=_outd;
-           _outd=temp;
-           _updatedFlag=true;
-         }
-       }
-     } catch (Exception ex) { }
- 
-     try { socket.close(); } catch (Exception ex) { }
-     _isConnected=false;
-   }
-  
-   public boolean hasData() {
-     return _updatedFlag;
-   }
- 
-   public PIDs getData() {
-     synchronized (_outd) {
-       _updatedFlag=false;
-       return _outd;
-     }
-   }
- 
-   public boolean isConnected() {
-     return _isConnected;
-   }
- 
-   public WorldStatePIDsListener() { super(); }
-   public WorldStatePIDsListener(int port) { super(port); }
-   public WorldStatePIDsListener(String host, int port) { super(host,port); }
- }
--- 0 ----
Index: AiboPup/tools/mon/aibo3d.lws
diff -c /dev/null AiboPup/tools/mon/aibo3d.lws:1.1
*** /dev/null	Fri Oct 10 14:37:54 2003
--- AiboPup/tools/mon/aibo3d.lws	Tue Aug 26 22:52:02 2003
***************
*** 0 ****
--- 1,386 ----
+ LWSC
+ 1
+ 
+ FirstFrame 1
+ LastFrame 60
+ FrameStep 1
+ PreviewFirstFrame 1
+ PreviewLastFrame 60
+ PreviewFrameStep 1
+ FramesPerSecond 30.000000
+ 
+ LoadObject objects/body2.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0 0.177 0.014 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ ShadowOptions 7
+ 
+ LoadObject objects/tail2.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0 0.05715 0.08279999 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ ParentObject 1
+ ShadowOptions 7
+ 
+ LoadObject objects/neck.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0 0.0627 -0.10004999 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ ParentObject 1
+ ShadowOptions 7
+ 
+ LoadObject objects/head.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0 0.02689999 -0.0004500076 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ ParentObject 3
+ ShadowOptions 7
+ 
+ LoadObject objects/jaw.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0 -0.00475 -0.02945 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ ParentObject 4
+ ShadowOptions 7
+ 
+ LoadObject objects/ear-l.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0.02704999 0.06610002 0.006099998 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ LockedChannels 6
+ ParentObject 4
+ ShadowOptions 7
+ 
+ LoadObject objects/ear-r.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   -0.02705 0.06610002 0.006149998 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ LockedChannels 7
+ ParentObject 4
+ ShadowOptions 7
+ 
+ LoadObject objects/leg-b-up-l.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0.07045 0.0033 0.06394999 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ LockedChannels 6
+ ParentObject 1
+ ShadowOptions 7
+ 
+ LoadObject objects/leg-b-low-l.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   -0.001850001 -0.09015001 0.0225 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ LockedChannels 6
+ ParentObject 8
+ ShadowOptions 7
+ 
+ LoadObject objects/foot-b-l.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0 -0.07345001 0.02495 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ LockedChannels 1
+ ParentObject 9
+ ShadowOptions 7
+ 
+ LoadObject objects/leg-b-up-r.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   -0.07064998 0.003349999 0.06394999 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ LockedChannels 6
+ ParentObject 1
+ ShadowOptions 7
+ 
+ LoadObject objects/leg-b-low-r.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0.00205 -0.09019998 0.0225 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ LockedChannels 6
+ ParentObject 11
+ ShadowOptions 7
+ 
+ LoadObject objects/foot-b-r.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0 -0.0735 0.025 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ LockedChannels 1
+ ParentObject 12
+ ShadowOptions 7
+ 
+ LoadObject objects/leg-f-up-l.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0.07045001 -0.0007499999 -0.07510001 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ LockedChannels 6
+ ParentObject 1
+ ShadowOptions 7
+ 
+ LoadObject objects/leg-f-low-l.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   -0.00165 -0.09469999 -0.01165 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ LockedChannels 6
+ ParentObject 14
+ ShadowOptions 7
+ 
+ LoadObject objects/foot-f-l.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0 -0.06485 -0.02929999 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ LockedChannels 1
+ ParentObject 15
+ ShadowOptions 7
+ 
+ LoadObject objects/leg-f-up-r.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   -0.07044999 -0.0006499998 -0.07515001 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ LockedChannels 6
+ ParentObject 1
+ ShadowOptions 7
+ 
+ LoadObject objects/leg-f-low-r.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0.00105 -0.0948 -0.0116 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ LockedChannels 6
+ ParentObject 17
+ ShadowOptions 7
+ 
+ LoadObject objects/foot-f-r.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0 -0.0649 -0.0293 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ LockedChannels 1
+ ParentObject 18
+ ShadowOptions 7
+ 
+ LoadObject objects/LED_g01.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0 0 0 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ ParentObject 4
+ ShadowOptions 7
+ 
+ LoadObject objects/LED_g02.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0 0 0 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ ParentObject 4
+ ShadowOptions 7
+ 
+ LoadObject objects/LED_g03.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0 0 0 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ ParentObject 4
+ ShadowOptions 7
+ 
+ LoadObject objects/LED_r01.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0 0 0 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ ParentObject 4
+ ShadowOptions 7
+ 
+ LoadObject objects/LED_r02.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0 0 0 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ ParentObject 4
+ ShadowOptions 7
+ 
+ LoadObject objects/LED_r03.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0 0 0 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ ParentObject 4
+ ShadowOptions 7
+ 
+ LoadObject objects/LED_r04.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0 0 0 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ ParentObject 4
+ ShadowOptions 7
+ 
+ LoadObject objects/LED_tail.lwo
+ ShowObject 8 7
+ ObjectMotion (unnamed)
+   9
+   1
+   0 0 0 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ ParentObject 2
+ ShadowOptions 7
+ 
+ AmbientColor 255 255 255
+ AmbIntensity 0.50000
+ 
+ AddLight
+ LightName Light
+ ShowLight 1 7
+ LightMotion (unnamed)
+   9
+   1
+   -2 2 -2 45 35 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ LightColor 255 255 255
+ LgtIntensity 0.700000
+ LightType 0
+ ShadowType 1
+ 
+ ShowCamera 1 7
+ CameraMotion (unnamed)
+   9
+   1
+   -0.6381658 0.5205013 -0.6771318 0 0 0 1 1 1
+   0 0 0 0 0
+ EndBehavior 1
+ TargetObject 1
+ ZoomFactor 3.200000
+ Resolution 1
+ PixelAspectRatio 2
+ SegmentMemory 2200000
+ Antialiasing 0
+ AdaptiveSampling 1
+ AdaptiveThreshold 16
+ FilmSize 2
+ FieldRendering 0
+ MotionBlur 0
+ DepthOfField 0
+ 
+ SolidBackdrop 1
+ BackdropColor 80 80 180 
+ ZenithColor 0 40 80
+ SkyColor 120 180 240
+ GroundColor 50 40 30
+ NadirColor 100 80 60
+ FogType 0
+ DitherIntensity 1
+ AnimatedDither 0
+ 
+ RenderMode 2
+ RayTraceEffects 0
+ ClipRayColors 0
+ DataOverlayLabel  
+ FullSceneParamEval 0
+ 
+ ViewMode 5
+ ViewAimpoint -0.006362 0.165064 -0.119767
+ ViewDirection 0.300197 -0.314159 0.000000
+ ViewZoomFactor 0.526749
+ GridNumber 40
+ GridSize 0.010000
+ ShowMotionPath 1
+ ShowBGImage 0
+ ShowFogRadius 0
+ ShowRedraw 0
+ ShowSafeAreas 0
+ ShowFieldChart 0
Index: AiboPup/tools/mon/config.m
diff -c AiboPup/tools/mon/config.m:1.11 AiboPup/tools/mon/config.m:1.12
*** AiboPup/tools/mon/config.m:1.11	Fri Jun  6 18:39:48 2003
--- AiboPup/tools/mon/config.m	Sun Aug  3 17:56:06 2003
***************
*** 3,9 ****
  
  %eventually parse single config file
  
! conf.ip='192.168.0.6'; % Aibo's IP address
  
  conf.port_stdout=10001;
  conf.port_stderr=10002;
--- 3,9 ----
  
  %eventually parse single config file
  
! conf.ip='192.168.0.7'; % Aibo's IP address
  
  conf.port_stdout=10001;
  conf.port_stderr=10002;
Index: AiboPup/tools/mon/default.col
diff -c /dev/null AiboPup/tools/mon/default.col:1.6
*** /dev/null	Fri Oct 10 14:37:54 2003
--- AiboPup/tools/mon/default.col	Thu Oct  9 20:46:15 2003
***************
*** 0 ****
--- 1,10 ----
+ 0 (128 128 128) "unclassified" 8 1.00
+ 1 (24 43 93) "blue" 8 0.75
+ 2 (255 255 255) "white" 8 0.75
+ 3 (237 131 54) "orange" 8 0.75
+ 4 (43 150 180) "azure" 8 0.75
+ 5 (36 67 23) "green" 8 0.75
+ 6 (209 60 97) "red" 8 0.75
+ 7 (200 189 123) "yellow" 8 0.75
+ 8 (0 0 0) "black" 8 0.75
+ 9 (113 80 34) "brown" 8 0.75
Index: AiboPup/tools/mon/jargs.jar
Index: AiboPup/tools/mon/images/chasingarrows.gif
Index: AiboPup/tools/mon/images/disconnect.gif
Index: AiboPup/tools/mon/images/disconnect.png
Index: AiboPup/tools/mon/images/go.gif
Index: AiboPup/tools/mon/images/go.png
Index: AiboPup/tools/mon/images/larrow.gif
Index: AiboPup/tools/mon/images/offline.gif
Index: AiboPup/tools/mon/images/online.gif
Index: AiboPup/tools/mon/images/rarrow.gif
Index: AiboPup/tools/mon/images/stop.gif
Index: AiboPup/tools/mon/images/stop.png
Index: AiboPup/tools/mon/objects/LED_g01.lwo
Index: AiboPup/tools/mon/objects/LED_g02.lwo
Index: AiboPup/tools/mon/objects/LED_g03.lwo
Index: AiboPup/tools/mon/objects/LED_r01.lwo
Index: AiboPup/tools/mon/objects/LED_r02.lwo
Index: AiboPup/tools/mon/objects/LED_r03.lwo
Index: AiboPup/tools/mon/objects/LED_r04.lwo
Index: AiboPup/tools/mon/objects/LED_tail.lwo
Index: AiboPup/tools/mon/objects/body2.lwo
Index: AiboPup/tools/mon/objects/ear-l.lwo
Index: AiboPup/tools/mon/objects/ear-r.lwo
Index: AiboPup/tools/mon/objects/foot-b-l.lwo
Index: AiboPup/tools/mon/objects/foot-b-r.lwo
Index: AiboPup/tools/mon/objects/foot-f-l.lwo
Index: AiboPup/tools/mon/objects/foot-f-r.lwo
Index: AiboPup/tools/mon/objects/head.lwo
Index: AiboPup/tools/mon/objects/jaw.lwo
Index: AiboPup/tools/mon/objects/leg-b-low-l.lwo
Index: AiboPup/tools/mon/objects/leg-b-low-r.lwo
Index: AiboPup/tools/mon/objects/leg-b-up-l.lwo
Index: AiboPup/tools/mon/objects/leg-b-up-r.lwo
Index: AiboPup/tools/mon/objects/leg-f-low-l.lwo
Index: AiboPup/tools/mon/objects/leg-f-low-r.lwo
Index: AiboPup/tools/mon/objects/leg-f-up-l.lwo
Index: AiboPup/tools/mon/objects/leg-f-up-r.lwo
Index: AiboPup/tools/mon/objects/neck.lwo
Index: AiboPup/tools/mon/objects/tail2.lwo
Index: AiboPup/tools/mon/org/tekkotsu/aibo3d/Aibo3D.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/aibo3d/Aibo3D.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/aibo3d/Aibo3D.java	Thu Oct  9 15:11:26 2003
***************
*** 0 ****
--- 1,171 ----
+ package org.tekkotsu.aibo3d;
+ 
+ import java.awt.*;
+ import java.awt.event.*;
+ import javax.media.j3d.*;
+ import java.io.*;
+ import javax.vecmath.*;
+ import java.util.*;
+ import java.lang.*;
+ import java.util.prefs.Preferences;
+ 
+ import com.sun.j3d.loaders.lw3d.Lw3dLoader;
+ import com.sun.j3d.loaders.Loader;
+ import com.sun.j3d.loaders.Scene;
+ import com.sun.j3d.utils.applet.MainFrame;
+ import com.sun.j3d.utils.universe.SimpleUniverse;
+ import com.sun.j3d.utils.behaviors.mouse.*;
+ import com.sun.j3d.utils.picking.behaviors.*;
+ import com.sun.j3d.utils.picking.*;
+ 
+ import org.tekkotsu.mon.Joints;
+ import org.tekkotsu.mon.WorldStateJointsListener;
+ 
+ public class Aibo3D extends Frame {
+   static Preferences prefs = Preferences.userNodeForPackage(Aibo3D.class);
+   Scene scene;
+   Canvas3D canvas3d;
+   Aibo3DForward forward;
+   WorldStateJointsListener wsj;
+ 
+   public static void main(String args[]) {
+ 		if(args.length<1) {
+ 			System.out.println("Usage: java Aibo3D host [port]");
+ 			System.out.println("       if port is not specified, it defaults to 10031");
+ 			System.exit(2);
+ 		}
+ 		int port=10031;
+ 		if(args.length>1)
+ 			port=Integer.parseInt(args[1]);
+     new Aibo3D(args[0],port,null);
+   }
+ 
+   public Aibo3D(String host, int port, String args[]) {
+     super("Aibo 3D");
+     setSize(500,500);
+     setLocation(prefs.getInt("Aibo3D.location.x",50), prefs.getInt("Aibo3D.location.y",50));
+ 
+     setup3DCanvas();
+     loadLW3D("aibo3d.lws");
+     forward=new Aibo3DForward(scene);
+     showScene();
+   
+     wsj=new WorldStateJointsListener(host,port);
+     while (true) {
+       if (wsj.isConnected()) {
+         if (wsj.hasData()) {
+           Joints j=wsj.getData();
+           float[] p=j.positions;
+           forward.knee_fl.setX(-p[2]);
+           forward.thigh_fl.set(-p[0],0.0f,p[1]);
+           forward.knee_fr.setX(-p[5]);
+           forward.thigh_fr.set(-p[3],0.0f,-p[4]);
+           forward.knee_bl.setX(p[8]);
+           forward.thigh_bl.set(p[6],0.0f,p[7]);
+           forward.knee_br.setX(p[11]);
+           forward.thigh_br.set(p[9],0.0f,-p[10]);
+           forward.neck.setX(-p[12]);
+           forward.head.set(0.0f,p[13],p[14]);
+           forward.tail.set(p[15],p[16],0.0f);
+           forward.jaw.setX(-p[17]);
+         }
+       }
+       sleep(10);
+     }
+   
+ //    testLimits(forward.thigh_bl,50);
+   }
+ 
+ 	void close() {
+     prefs.putInt("Aibo3D.location.x",getLocation().x+getInsets().left);
+     prefs.putInt("Aibo3D.location.y",getLocation().y+getInsets().top);
+ 		dispose();
+ 	}
+ 
+   void testLimits(AiboJoint j) {
+     float step;
+     step=(j.maxX-j.minX)/100;
+     for (float x=j.minX; x<j.maxX; x+=step) { j.setX(x); sleep(10); }
+     for (float x=j.maxX; x>j.minX; x-=step) { j.setX(x); sleep(10); }
+     j.setX(0.0f);
+     step=(j.maxY-j.minY)/100;
+     for (float y=j.minY; y<j.maxY; y+=step) { j.setY(y); sleep(10); }
+     for (float y=j.maxY; y>j.minY; y-=step) { j.setY(y); sleep(10); }
+     j.setY(0.0f);
+     step=(j.maxZ-j.minZ)/100;
+     for (float z=j.minZ; z<j.maxZ; z+=step) { j.setZ(z); sleep(10); }
+     for (float z=j.maxZ; z>j.minZ; z-=step) { j.setZ(z); sleep(10); }
+     j.setZ(0.0f);
+   }
+ 
+   void testLimits(AiboJoint j, int n) {
+     for (int i=0; i<n; i++) {
+       testLimits(j);
+     }
+   }
+ 
+   void sleep(long ms) {
+     try { Thread.sleep(ms); } catch (Exception e) {}
+   }
+ 
+   void loadLW3D(String filename) {
+     Loader loader=new Lw3dLoader(Loader.LOAD_ALL);
+     try {
+       scene=loader.load(filename);
+     } catch (Exception ex) {
+       System.out.println("error loading "+filename);
+       System.exit(1);
+     }
+   }
+ 
+   void setup3DCanvas() {
+     canvas3d=new Canvas3D(SimpleUniverse.getPreferredConfiguration());
+     add("Center",canvas3d);
+     setVisible(true);
+     addWindowListener(new WindowAdapter()         // cleans up properly
+       { public void windowClosing(WindowEvent e)
+           { dispose(); System.exit(0); } });
+   }
+ 
+ 
+   void showScene() {
+     GraphicsConfiguration config =
+       SimpleUniverse.getPreferredConfiguration();
+ 
+ 
+     SimpleUniverse universe = new SimpleUniverse(canvas3d);
+     universe.getViewingPlatform().setNominalViewingTransform();
+ 
+     BranchGroup bg = createSceneGraph(scene);
+     universe.addBranchGraph(bg);
+   }
+ 
+   BranchGroup createSceneGraph(Scene scene) {
+     BranchGroup root = new BranchGroup();
+ 
+     TransformGroup trans = new TransformGroup();
+     trans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
+     trans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
+ 
+     BoundingSphere bounds = new BoundingSphere(new Point3d(), 100.0);
+ 
+     MouseRotate rotator = new MouseRotate(trans);
+     rotator.setSchedulingBounds(bounds);
+     root.addChild(rotator);
+ 
+     MouseTranslate translator = new MouseTranslate(trans);
+     translator.setSchedulingBounds(bounds);
+     root.addChild(translator);
+ 
+     MouseZoom zoomer = new MouseZoom(trans);
+     zoomer.setSchedulingBounds(bounds);
+     root.addChild(zoomer); 
+ 
+     if (scene.getSceneGroup() != null) {
+       trans.addChild(scene.getSceneGroup());
+       root.addChild(trans);
+     }
+ 
+     return root;
+   }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/aibo3d/Aibo3DForward.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/aibo3d/Aibo3DForward.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/aibo3d/Aibo3DForward.java	Fri Sep 26 00:36:17 2003
***************
*** 0 ****
--- 1,140 ----
+ package org.tekkotsu.aibo3d;
+ 
+ import javax.media.j3d.*;
+ import javax.vecmath.*;
+ import java.util.*;
+ import java.lang.*;
+ 
+ import com.sun.j3d.loaders.Scene;
+ 
+ public class Aibo3DForward {
+   Scene _scene;
+   Hashtable _namedObjects;
+   boolean lock;
+ 
+   AiboJoint head;
+   AiboJoint neck;
+   AiboJoint jaw;
+   AiboJoint tail;
+   AiboJoint thigh_fl;
+   AiboJoint knee_fl;
+   AiboJoint thigh_fr;
+   AiboJoint knee_fr;
+   AiboJoint thigh_bl;
+   AiboJoint knee_bl;
+   AiboJoint thigh_br;
+   AiboJoint knee_br;
+   List aiboJoints;
+   
+   public Aibo3DForward(Scene scene) {
+     _scene=scene;
+     _namedObjects=scene.getNamedObjects();
+     lock=false;
+ 
+     makeSceneTransformable();
+     initERS210();
+   }
+ 
+   public List getAiboJoints() {
+     return aiboJoints;    
+   }
+ 
+   void makeSceneTransformable() {
+     for (Enumeration e=_namedObjects.keys(); e.hasMoreElements();)
+       makeObjectTransformable(e.nextElement());
+   }
+ 
+   void makeObjectTransformable(Object key) {
+     TransformGroup objtg=getTG(key);
+     objtg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
+     objtg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
+   }
+ 
+   void printNamedObjects() {
+     for (Enumeration e=_namedObjects.keys(); e.hasMoreElements();)
+       System.out.println(e.nextElement());
+   }
+ 
+   void printNamedObjectTransformationMatrices() {
+     for (Enumeration e=_namedObjects.keys(); e.hasMoreElements();) {
+       System.out.println(e.nextElement()+": ");
+       printNamedObjectTransformationMatrix(e.nextElement());
+     }
+   }
+ 
+   void printNamedObjectTransformationMatrix(Object key) {
+     TransformGroup objtg=getTG(key);
+     Transform3D t3d=new Transform3D();
+     objtg.getTransform(t3d);
+     System.out.println(t3d);
+   }
+ 
+   public TransformGroup getTG(Object key) {
+     return (TransformGroup)_namedObjects.get(key);
+   }
+ 
+   void initERS210 () {
+     neck=new AiboJoint(getTG("objects/neck.lwo"), "neck",
+                        -46.0f,   85.0f,
+                        0.0f,     0.0f,
+                        0.0f,     0.0f);
+     head=new AiboJoint(getTG("objects/head.lwo"), "head",
+                        0.0f,     0.0f,
+                        -92.6f,   92.6f,
+                        -32.0f,   32.0f);
+     jaw=new AiboJoint(getTG("objects/jaw.lwo"), "jaw",
+                        0.0f,     50.0f,
+                        0.0f,     0.0f,
+                        0.0f,     0.0f);
+     tail=new AiboJoint(getTG("objects/tail2.lwo"), "tail",
+                        -25.0f,   25.0f,
+                        -25.0f,   25.0f,
+                        0.0f,     0.0f);
+     thigh_fl=new AiboJoint(getTG("objects/leg-f-up-l.lwo"), "thigh_fl",
+                        -120.0f,  120.0f,
+                        0.0f,     0.0f,
+                        -15.0f,   92.0f);
+     thigh_fr=new AiboJoint(getTG("objects/leg-f-up-r.lwo"), "thigh_fr",
+                        -120.0f,  120.0f,
+                        0.0f,     0.0f,
+                        -92.0f,   15.0f);
+     thigh_bl=new AiboJoint(getTG("objects/leg-b-up-l.lwo"), "thigh_bl",
+                        -120.0f,  120.0f,
+                        0.0f,     0.0f,
+                        -15.0f,   92.0f);
+     thigh_br=new AiboJoint(getTG("objects/leg-b-up-r.lwo"), "thigh_br",
+                        -120.0f,  120.0f,
+                        0.0f,     0.0f,
+                        -92.0f,   15.0f);
+     knee_fl=new AiboJoint(getTG("objects/leg-f-low-l.lwo"), "knee_fl",
+                        -115.0f,  65.0f,
+                        0.0f,     0.0f,
+                        0.0f,     0.0f);
+     knee_fr=new AiboJoint(getTG("objects/leg-f-low-r.lwo"), "knee_fr",
+                        -115.0f,  65.0f,
+                        0.0f,     0.0f,
+                        0.0f,     0.0f);
+     knee_bl=new AiboJoint(getTG("objects/leg-b-low-l.lwo"), "knee_bl",
+                        -65.0f,   115.0f,
+                        0.0f,     0.0f,
+                        0.0f,     0.0f);
+     knee_br=new AiboJoint(getTG("objects/leg-b-low-r.lwo"), "knee_br",
+                        -65.0f,   115.0f,
+                        0.0f,     0.0f,
+                        0.0f,     0.0f);
+     aiboJoints=new ArrayList(20);
+ 
+     aiboJoints.add(head);
+     aiboJoints.add(neck);
+     aiboJoints.add(jaw);
+     aiboJoints.add(tail);
+     aiboJoints.add(thigh_fl);
+     aiboJoints.add(knee_fl);
+     aiboJoints.add(thigh_fr);
+     aiboJoints.add(knee_fr);
+     aiboJoints.add(thigh_bl);
+     aiboJoints.add(knee_bl);
+     aiboJoints.add(thigh_br);
+     aiboJoints.add(knee_br);
+   }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/aibo3d/Aibo3DPick.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/aibo3d/Aibo3DPick.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/aibo3d/Aibo3DPick.java	Wed Oct  1 22:07:33 2003
***************
*** 0 ****
--- 1,335 ----
+ package org.tekkotsu.aibo3d;
+ 
+ import java.awt.*;
+ import java.awt.event.*;
+ import javax.media.j3d.*;
+ import java.io.*;
+ import javax.vecmath.*;
+ import java.util.*;
+ import java.lang.*;
+ import java.util.prefs.Preferences;
+ 
+ import com.sun.j3d.loaders.lw3d.Lw3dLoader;
+ import com.sun.j3d.loaders.Loader;
+ import com.sun.j3d.loaders.Scene;
+ import com.sun.j3d.utils.applet.MainFrame;
+ import com.sun.j3d.utils.universe.SimpleUniverse;
+ import com.sun.j3d.utils.behaviors.mouse.*;
+ import com.sun.j3d.utils.picking.behaviors.*;
+ import com.sun.j3d.utils.picking.*;
+ 
+ import javax.swing.JFrame;
+ import org.tekkotsu.mon.WorldStateJointsListener;
+ import org.tekkotsu.mon.Joints;
+ 
+ public class Aibo3DPick extends Frame {
+   Canvas3D canvas3d;
+   Scene scene;
+   Aibo3DForward forward;
+   PickMoveBehavior picker;
+   BranchGroup branchGroup;
+   SimpleUniverse universe;
+   BranchGroup root;
+   static Preferences prefs = Preferences.userNodeForPackage(Aibo3DPick.class);
+ 	Thread mirror;
+ 	WorldStateJointsListener wsjl;
+ 	WorldStateJointsWriter wsjw;
+   
+   public static void main(String args[]) {
+ 		if(args.length<1) {
+ 			System.out.println("Usage: java Aibo3DPick host [port]");
+ 			System.out.println("       if port is not specified, it defaults to 10051");
+ 			System.exit(2);
+ 		}
+ 		int port=10051;
+ 		if(args.length>1)
+ 			port=Integer.parseInt(args[1]);
+     new Aibo3DPick(args[0],port,null);
+   }
+ 
+   public Aibo3DPick(String host, int port, String args[]) {
+     super("Aibo 3D");
+     setSize(600,400);
+     setLocation(prefs.getInt("Aibo3DPick.location.x",50),prefs.getInt("Aibo3DPick.location.y",50));
+ 
+     setup3DCanvas();
+     loadLW3D("aibo3d.lws");
+     forward=new Aibo3DForward(scene);
+     showScene();
+ 
+     picker.createPicker();
+     wsjl=new WorldStateJointsListener(host, 10031);
+ 		wsjw=new WorldStateJointsWriter(host, port);
+ 
+ 		mirror=new mirrorThread(this);
+ 		mirror.start();
+     addWindowListener(new CloseAdapter(this));
+   }
+ 
+ 	class mirrorThread extends Thread {
+ 		Aibo3DPick gui;
+ 		mirrorThread(Aibo3DPick gui) { this.gui=gui; }
+ 		public void run() { 
+ 			//wait for connection so we know what the current positions are
+ 			while(!gui.wsjl.hasData()) {
+ 				try { Thread.sleep(100); } catch (Exception e) {break;}
+ 			}
+ 			gui.mirrorListener(wsjl);
+ 			while (true) {
+ 				if (gui.forward.lock) gui.mirrorWriter(wsjw);
+ 				else gui.mirrorListener(wsjl);
+ 				try { Thread.sleep(27); } catch (Exception e) {break;}
+ 			}
+ 		}
+ 	}
+ 
+ 	class CloseAdapter extends WindowAdapter {
+ 		Aibo3DPick gui;
+ 		CloseAdapter(Aibo3DPick gui) {this.gui=gui;}
+ 		public void windowClosing(WindowEvent e) {
+ 			gui.close();
+ 		}
+ 	}
+ 
+ 	public void close() {
+     prefs.putInt("Aibo3DPick.location.x",getLocation().x+getInsets().left);
+     prefs.putInt("Aibo3DPick.location.y",getLocation().y+getInsets().top);
+ 		wsjl.kill();
+ 		if(wsjw!=null)
+ 			wsjw.kill();
+ 		mirror.interrupt();
+ 		dispose();
+ 	}
+ 
+   void mirrorListener (WorldStateJointsListener wsj) {
+     if (wsj.isConnected()) {
+       if (wsj.hasData()) {
+         Joints j=wsj.getData();
+         float[] p=j.positions;
+         forward.knee_fl.setX(-p[2]);
+         forward.thigh_fl.set(-p[0],0.0f,p[1]);
+         forward.knee_fr.setX(-p[5]);
+         forward.thigh_fr.set(-p[3],0.0f,-p[4]);
+         forward.knee_bl.setX(p[8]);
+         forward.thigh_bl.set(p[6],0.0f,p[7]);
+         forward.knee_br.setX(p[11]);
+         forward.thigh_br.set(p[9],0.0f,-p[10]);
+         forward.neck.setX(-p[12]);
+         forward.head.set(0.0f,p[13],p[14]);
+         forward.tail.set(p[15],p[16],0.0f);
+         forward.jaw.setX(-p[17]);
+       }
+     }
+   }
+ 
+   void mirrorWriter(WorldStateJointsWriter wsj) {
+     if (wsj.isConnected()) {
+       float[] p=new float[18];
+       p[0]=-forward.thigh_fl.x;
+       p[1]=forward.thigh_fl.z;
+       p[2]=-forward.knee_fl.x;
+       p[3]=-forward.thigh_fr.x;
+       p[4]=-forward.thigh_fr.z;
+       p[5]=-forward.knee_fr.x;
+       p[6]=forward.thigh_bl.x;
+       p[7]=forward.thigh_bl.z;
+       p[8]=forward.knee_bl.x;
+       p[9]=forward.thigh_br.x;
+       p[10]=-forward.thigh_br.z;
+       p[11]=forward.knee_br.x;
+       p[12]=-forward.neck.x;
+       p[13]=forward.head.y;
+       p[14]=forward.head.z;
+       p[15]=forward.tail.x;
+       p[16]=forward.tail.y;
+       p[17]=-forward.jaw.x;
+       wsj.write(p);
+     }
+   }
+ 
+   void testLimits(AiboJoint j) {
+     float step;
+     step=(j.maxX-j.minX)/100;
+     for (float x=j.minX; x<j.maxX; x+=step) { j.setX(x); sleep(10); }
+     for (float x=j.maxX; x>j.minX; x-=step) { j.setX(x); sleep(10); }
+     j.setX(0.0f);
+     step=(j.maxY-j.minY)/100;
+     for (float y=j.minY; y<j.maxY; y+=step) { j.setY(y); sleep(10); }
+     for (float y=j.maxY; y>j.minY; y-=step) { j.setY(y); sleep(10); }
+     j.setY(0.0f);
+     step=(j.maxZ-j.minZ)/100;
+     for (float z=j.minZ; z<j.maxZ; z+=step) { j.setZ(z); sleep(10); }
+     for (float z=j.maxZ; z>j.minZ; z-=step) { j.setZ(z); sleep(10); }
+     j.setZ(0.0f);
+   }
+ 
+   void testLimits(AiboJoint j, int n) {
+     for (int i=0; i<n; i++) {
+       testLimits(j);
+     }
+   }
+ 
+   void sleep(long ms) {
+     try { Thread.sleep(ms); } catch (Exception e) {}
+   }
+ 
+   void loadLW3D(String filename) {
+     Loader loader=new Lw3dLoader(Loader.LOAD_ALL);
+     try {
+       scene=loader.load(filename);
+     } catch (Exception ex) {
+       System.out.println("error loading "+filename);
+       System.exit(1);
+     }
+   }
+ 
+   void setup3DCanvas() {
+     canvas3d=new Canvas3D(SimpleUniverse.getPreferredConfiguration());
+     add("Center",canvas3d);
+     setVisible(true);
+   }
+ 
+   void showScene() {
+     GraphicsConfiguration config =
+       SimpleUniverse.getPreferredConfiguration();
+ 
+     universe = new SimpleUniverse(canvas3d);
+     universe.getViewingPlatform().setNominalViewingTransform();
+ 
+     branchGroup = createSceneGraph(scene);
+     universe.addBranchGraph(branchGroup);
+   }
+ 
+   BranchGroup createSceneGraph(Scene scene) {
+     root = new BranchGroup();
+     TransformGroup transformGroup;
+ 
+     transformGroup = new TransformGroup();
+     transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
+     transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
+ 
+     Hashtable namedObjects = scene.getNamedObjects( );
+ 
+     // recursively set the user data here
+     // so we can find our objects when they are picked
+     
+     java.util.Enumeration enumValues = namedObjects.elements( );
+     java.util.Enumeration enumKeys = namedObjects.keys( );
+     if( enumValues != null )
+     {
+       while( enumValues.hasMoreElements( ) != false )
+       {
+         Object value = enumValues.nextElement( );
+         Object key = enumKeys.nextElement( );
+ 
+         recursiveSetUserData( value, key );
+       }
+     }
+ 
+ 
+     Bounds bounds=new BoundingSphere(new Point3d(0.0,0.0,0.0), 1.0);
+ /*
+     MouseRotate rotator = new MouseRotate(transformGroup);
+     rotator.setSchedulingBounds(bounds);
+     root.addChild(rotator);
+ 
+     MouseTranslate translator = new MouseTranslate(transformGroup);
+     translator.setSchedulingBounds(bounds);
+     root.addChild(translator);
+ */
+     MouseZoom zoomer = new MouseZoom(transformGroup);
+     zoomer.setSchedulingBounds(bounds);
+     root.addChild(zoomer); 
+ 
+     picker=new PickMoveBehavior (canvas3d, scene.getSceneGroup(), scene,
+                                  forward, transformGroup);
+     picker.setSchedulingBounds(bounds);
+     root.addChild(picker);
+ 
+     if (scene.getSceneGroup() != null) {
+       transformGroup.addChild(scene.getSceneGroup());
+       root.addChild(transformGroup);
+     }
+ 
+     moveLights(scene.getSceneGroup(), root);
+ //    recursivePrintGroup(root);
+ 
+     return root;
+   }
+ 
+   void moveLights(Group from, Group to) {
+     from.setCapability(Group.ALLOW_CHILDREN_READ);
+ 
+     java.util.Enumeration enumKids = from.getAllChildren();
+     while( enumKids.hasMoreElements( ) != false ) {
+       Object o = enumKids.nextElement();
+       if (o instanceof Group) {
+         moveLights((Group)o, to);
+       } else if (o instanceof DirectionalLight || o instanceof PointLight) {
+         from.setCapability(Group.ALLOW_CHILDREN_WRITE);
+         to.setCapability(Group.ALLOW_CHILDREN_READ);
+         to.setCapability(Group.ALLOW_CHILDREN_WRITE);
+         from.removeChild((Node)o);
+         to.addChild((Node)o);
+       }
+     }
+ 
+   }
+ 
+   void recursivePrintGroup(Object sgo) {
+     recursivePrintGroup(sgo,"");
+   }
+ 
+   void recursivePrintGroup(Object sgo, String indent) {
+     if( sgo instanceof SceneGraphObject != false )
+     {
+       SceneGraphObject sg = (SceneGraphObject) sgo;
+                                                                                 
+       // recursively process group
+       if( sg instanceof Group )
+       {
+         Group g = (Group) sg;
+         g.setCapability(Group.ALLOW_CHILDREN_READ);
+                                                                                 
+         // recurse on child nodes
+         java.util.Enumeration enumKids = g.getAllChildren( );
+                                                                                 
+         while( enumKids.hasMoreElements( ) != false )
+           recursivePrintGroup( enumKids.nextElement( ), indent+"  ");
+       }
+       else if ( sg instanceof Node || sg instanceof NodeComponent)
+       {
+         System.out.println(indent+sg);
+       }
+     }
+   
+   }
+ 
+   void recursiveSetUserData( Object value, Object key )
+   {
+     if( value instanceof SceneGraphObject != false )
+     {
+       // set the user data for the item
+       SceneGraphObject sg = (SceneGraphObject) value;
+       sg.setUserData( key );
+                                                                                 
+       // recursively process group
+       if( sg instanceof Group )
+       {
+         Group g = (Group) sg;
+         g.setCapability(Group.ALLOW_CHILDREN_READ);
+                                                                                 
+         // recurse on child nodes
+         java.util.Enumeration enumKids = g.getAllChildren( );
+                                                                                 
+         while( enumKids.hasMoreElements( ) != false )
+           recursiveSetUserData( enumKids.nextElement( ), key );
+       }
+       else if ( sg instanceof Shape3D || sg instanceof Morph )
+       {
+         PickTool.setCapabilities( (Node) sg, PickTool.INTERSECT_FULL );
+       }
+     }
+   }
+ 
+ }
Index: AiboPup/tools/mon/org/tekkotsu/aibo3d/AiboJoint.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/aibo3d/AiboJoint.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/aibo3d/AiboJoint.java	Fri Sep 26 00:36:17 2003
***************
*** 0 ****
--- 1,131 ----
+ package org.tekkotsu.aibo3d;
+ 
+ import javax.media.j3d.*;
+ import javax.vecmath.*;
+ import java.util.*;
+ import java.lang.*;
+ 
+ public class AiboJoint {
+   public static final int RADIANS=0;
+   public static final int DEGREES=1;
+ 
+   public String name;
+   public TransformGroup obj;
+   public float minX;
+   public float maxX;
+   public float minY;
+   public float maxY;
+   public float minZ;
+   public float maxZ;
+   public float x;
+   public float y;
+   public float z;
+ 
+   float bound(float n, float l, float h) {
+     return Math.max(Math.min(h, n),l);
+   }
+ 
+   public void setX(float X) {
+     x=bound(X, minX, maxX);
+     setJoints();
+   }
+ 
+   public void setY(float Y) {
+     y=bound(Y, minY, maxY);
+     setJoints();
+   }
+ 
+   public void setZ(float Z) {
+     z=bound(Z, minZ, maxZ);
+     setJoints();
+   }
+ 
+   public void setX(double X) {
+     setX((float)X);
+   }
+ 
+   public void setY(double Y) {
+     setY((float)Y);
+   }
+ 
+   public void setZ(double Z) {
+     setZ((float)Z);
+   }
+ 
+   public void setXDiff(int X) {
+     setX(x+((float)X*0.03f));
+   }
+ 
+   public void setYDiff(int Y) {
+     setY(y+((float)Y*0.03f));
+   }
+   
+   public void setZDiff(int Z) {
+     setZ(z+((float)Z*0.03f));
+   }
+ 
+   public void set(float X, float Y, float Z) {
+     x=bound(X, minX, maxX);
+     y=bound(Y, minY, maxY);
+     z=bound(Z, minZ, maxZ);
+     setJoints();
+   }
+ 
+   // TODO: Lots of crazy speedups possible
+   void setJoints() {
+     Transform3D t3d=new Transform3D();
+     Matrix3f accum=new Matrix3f();
+     Matrix3f rot=new Matrix3f();
+     obj.getTransform(t3d);
+     accum.setIdentity();
+     rot.rotX(x);
+     accum.mul(rot);
+     rot.rotY(y);
+     accum.mul(rot);
+     rot.rotZ(z);
+     accum.mul(rot);
+     t3d.setRotation(accum);
+     obj.setTransform(t3d);
+   }
+ 
+   public AiboJoint (TransformGroup tg, String n, float minx, float maxx,
+                     float miny, float maxy, float minz, float maxz) {
+     this(tg, n, minx, maxx, miny, maxy, minz, maxz, DEGREES);
+   }
+  
+   public AiboJoint (TransformGroup tg, String n, float minx, float maxx,
+                     float miny, float maxy, float minz, float maxz, int units) {
+     if (units==RADIANS) {
+       obj=tg;
+       minX=minx;
+       maxX=maxx;
+       minY=miny;
+       maxY=maxy;
+       minZ=minz;
+       maxZ=maxz;
+     } else if (units==DEGREES) {
+       obj=tg;
+       minX=deg2rad(minx);
+       maxX=deg2rad(maxx);
+       minY=deg2rad(miny);
+       maxY=deg2rad(maxy);
+       minZ=deg2rad(minz);
+       maxZ=deg2rad(maxz);
+     } else {
+       System.out.println("error: unknown units");
+       System.exit(1);
+     }
+     x=0.0f;
+     y=0.0f;
+     z=0.0f;
+     name=n;
+   }
+ 
+   public float deg2rad (float deg) {
+     return (deg*(float)Math.PI)/180.0f;
+   }
+ 
+   public String toString () {
+     return name;
+   }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/aibo3d/AiboPicker.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/aibo3d/AiboPicker.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/aibo3d/AiboPicker.java	Fri Sep 26 00:36:17 2003
***************
*** 0 ****
--- 1,90 ----
+ package org.tekkotsu.aibo3d;
+ 
+ import java.util.*;
+ import java.lang.*;
+ import javax.media.j3d.*;
+ 
+ import com.sun.j3d.loaders.Scene;
+ 
+ public class AiboPicker {
+   Hashtable _namedObjects;
+   Hashtable _shapeToTG;
+ 
+   public static final String head="head";
+   public static final String tail="tail";
+   public static final String body="body";
+   public static final String foot_fl="foot_fl";
+   public static final String foot_fr="foot_fr";
+   public static final String foot_bl="foot_bl";
+   public static final String foot_br="foot_br";
+   public static final String leg_fl="leg_fl";
+   public static final String leg_fr="leg_fr";
+   public static final String leg_bl="leg_bl";
+   public static final String leg_br="leg_br";
+   public static final String knee_fl="knee_fl";
+   public static final String knee_fr="knee_fr";
+   public static final String knee_bl="knee_bl";
+   public static final String knee_br="knee_br";
+   public static final String jaw="jaw";
+ 
+   public AiboPicker (Scene scene) {
+     _namedObjects=scene.getNamedObjects();
+     _shapeToTG=new Hashtable();
+     initERS210();
+   }
+ 
+   public String pick(Object shape) {
+     return (String)_shapeToTG.get(shape);
+   }
+ 
+   public TransformGroup getTG(Object key) {
+     return (TransformGroup)_namedObjects.get(key);
+   }
+ 
+   void addShapesFor(TransformGroup key, String name) {
+     Enumeration shapes = key.getAllChildren();
+     while (shapes.hasMoreElements()) {
+       Object s=shapes.nextElement();
+       if (s instanceof Shape3D) {
+         _shapeToTG.put(s, name);
+       }
+     }
+   }
+ 
+   void initERS210() {
+     addShapesFor(getTG("objects/neck.lwo"), head);
+     addShapesFor(getTG("objects/head.lwo"), head);
+     addShapesFor(getTG("objects/LED_g01.lwo"), head);
+     addShapesFor(getTG("objects/LED_g02.lwo"), head);
+     addShapesFor(getTG("objects/LED_g03.lwo"), head);
+     addShapesFor(getTG("objects/LED_r01.lwo"), head);
+     addShapesFor(getTG("objects/LED_r02.lwo"), head);
+     addShapesFor(getTG("objects/LED_r03.lwo"), head);
+     addShapesFor(getTG("objects/ear-l.lwo"), head);
+     addShapesFor(getTG("objects/ear-r.lwo"), head);
+ 
+     addShapesFor(getTG("objects/jaw.lwo"), jaw);
+     addShapesFor(getTG("objects/body2.lwo"), body);
+     addShapesFor(getTG("objects/tail2.lwo"), tail);
+    
+     addShapesFor(getTG("objects/foot-b-r.lwo"), foot_br);
+     addShapesFor(getTG("objects/leg-b-low-r.lwo"), knee_br);
+     addShapesFor(getTG("objects/leg-b-up-r.lwo"), leg_br);
+ 
+     addShapesFor(getTG("objects/foot-b-l.lwo"), foot_bl);
+     addShapesFor(getTG("objects/leg-b-low-l.lwo"), knee_bl);
+     addShapesFor(getTG("objects/leg-b-up-l.lwo"), leg_bl);
+ 
+     addShapesFor(getTG("objects/foot-f-r.lwo"), foot_fr);
+     addShapesFor(getTG("objects/leg-f-low-r.lwo"), knee_fr);
+     addShapesFor(getTG("objects/leg-f-up-r.lwo"), leg_fr);
+ 
+     addShapesFor(getTG("objects/foot-f-l.lwo"), foot_fl);
+     addShapesFor(getTG("objects/leg-f-low-l.lwo"), knee_fl);
+     addShapesFor(getTG("objects/leg-f-up-l.lwo"), leg_fl);
+     for (Enumeration e=_shapeToTG.keys(); e.hasMoreElements();) {
+       Object o=e.nextElement();
+       // System.out.println(o + "->" + _shapeToTG.get(o));
+     }
+   }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/aibo3d/InverseKinematics.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/aibo3d/InverseKinematics.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/aibo3d/InverseKinematics.java	Fri Sep 26 00:36:17 2003
***************
*** 0 ****
--- 1,6 ----
+ package org.tekkotsu.aibo3d;
+ 
+ public class InverseKinematics {
+   public InverseKinematics () {
+   }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/aibo3d/Java3DTest.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/aibo3d/Java3DTest.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/aibo3d/Java3DTest.java	Wed Oct  1 19:45:16 2003
***************
*** 0 ****
--- 1,10 ----
+ package org.tekkotsu.aibo3d;
+ 
+ import javax.media.j3d.*;
+ import javax.vecmath.*;
+ 
+ //The only role of this file is to cause an error during compile
+ //if Java3D isn't installed.  This way we can test compilation of
+ //this file and skip the whole package if this one file fails.
+ 
+ class Java3DTest {}
Index: AiboPup/tools/mon/org/tekkotsu/aibo3d/Kinematics.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/aibo3d/Kinematics.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/aibo3d/Kinematics.java	Fri Sep 26 00:36:17 2003
***************
*** 0 ****
--- 1,162 ----
+ package org.tekkotsu.aibo3d;
+ 
+ import javax.vecmath.*;
+ 
+ public class Kinematics {
+   public static final int FRONT_LEFT=0;
+   public static final int FRONT_RIGHT=1;
+   public static final int BACK_LEFT=2;
+   public static final int BACK_RIGHT=3;
+  
+   static final Vector3d f_body_to_shoulder=
+                                    new Vector3d( 59.50, 59.20,   0.00); 
+   static final Vector3d f_leg_shoulder_to_knee=
+                                    new Vector3d( 12.80,  0.50, -64.00);
+   static final Vector3d f_leg_knee_to_ball=
+                                    new Vector3d(-18.00,  0.00, -67.23);
+   static final Vector3d h_body_to_shoulder=
+                                    new Vector3d(-59.50, 59.20,   0.00); 
+   static final Vector3d h_leg_shoulder_to_knee=
+                                    new Vector3d(-12.80,  0.50, -64.00);
+   static final Vector3d h_leg_knee_to_ball=
+                                    new Vector3d( 18.00,  0.00, -74.87);
+   static final Vector3d f_upper=f_leg_shoulder_to_knee;
+   static final Vector3d f_lower=f_leg_knee_to_ball;
+   static final Vector3d h_upper=h_leg_shoulder_to_knee;
+   static final Vector3d h_lower=h_leg_knee_to_ball;
+ 
+   static final double rotator_min  = RAD(-117.0);
+   static final double rotator_max  = RAD( 117.0);
+   static final double shoulder_min = RAD( -11.0);
+   static final double shoulder_max = RAD(  97.0);
+   static final double knee_max     = RAD( 147.0);
+   static final double knee_min     = RAD( -27.0);
+ 
+   static final double rotator_kmin  = RAD(-90.0);
+   static final double rotator_kmax  = RAD( 90.0);
+   static final double shoulder_kmin = shoulder_min;
+   static final double shoulder_kmax = RAD( 90.0);
+   static final double knee_kmax     = knee_max;
+   static final double f_knee_kmin   = 0.2616;
+   static final double h_knee_kmin   = 0.2316;
+ 
+   public Kinematics () {
+   }
+ 
+   public static void main(String args[]) {
+     Vector3d target=getForward(0, new LegConfiguration(0.0,0.0,0.0));
+     System.out.println(target);
+     target.y=target.y+20.0;
+     LegConfiguration angles=getInverse(0, target);
+     System.out.println(angles);
+     System.out.println(getForward(0, angles));
+   }
+ 
+   final static double RAD(double deg) {
+     return (deg*Math.PI)/180.0;
+   }
+ 
+   public static LegConfiguration getInverse(int leg, Vector3d target) {
+     Vector3d pos=new Vector3d();
+     Vector3d targ=new Vector3d(target);
+     Matrix3d rot=new Matrix3d();
+     double rotator=0.0, shoulder=0.0, knee=0.0;
+     double a, b, d, dist;
+ 
+     if (leg%2!=0) targ.y = -targ.y;
+ 
+     if (leg<2) {
+       targ.sub(f_body_to_shoulder);
+       dist=targ.lengthSquared();
+ 
+       a=-2*(f_upper.x*f_lower.z - f_upper.z*f_lower.x);
+       b= 2*(f_upper.x*f_lower.x + f_upper.z*f_lower.z);
+       d=(dist-f_upper.lengthSquared()-f_lower.lengthSquared()
+          -2*f_upper.y*f_lower.y);
+       knee=GetTrigAngle(a,b,d,f_knee_kmin,knee_kmax,true);
+ 
+       rot.rotY(-knee);
+       rot.transform(f_leg_knee_to_ball, pos);
+       pos.add(f_leg_shoulder_to_knee);
+       shoulder=GetTrigAngle(-pos.z,pos.y,targ.y,shoulder_kmin,
+                             shoulder_kmax,false);
+ 
+       pos.z=Math.sin(shoulder)*pos.y + Math.cos(shoulder)*pos.z;
+       rotator=GetTrigAngle(-pos.z, pos.x, targ.x, rotator_min, rotator_max,
+                            targ.z>0.0);
+     } else {
+       targ.sub(h_body_to_shoulder);
+       dist=targ.lengthSquared();
+ 
+       a= 2*(h_upper.x*h_lower.z - h_upper.z*h_lower.x);
+       b= 2*(h_upper.x*h_lower.x + h_upper.z*h_lower.z);
+       d=(dist-h_upper.lengthSquared()-h_lower.lengthSquared()
+          -2*h_upper.y*h_lower.y);
+       knee=GetTrigAngle(a,b,d,h_knee_kmin,knee_kmax,true);
+ 
+       rot.rotY(knee);
+       rot.transform(h_leg_knee_to_ball, pos);
+       pos.add(h_leg_shoulder_to_knee);
+       shoulder=GetTrigAngle(-pos.z,pos.y,targ.y,shoulder_kmin,
+                             shoulder_kmax,false);
+ 
+       pos.z=Math.sin(shoulder)*pos.y + Math.cos(shoulder)*pos.z;
+       rotator=GetTrigAngle(-pos.z, -pos.x, -targ.x, rotator_min, rotator_max,
+                            targ.z>0.0);
+ 
+     }
+     
+     return new LegConfiguration (rotator, shoulder, knee);
+   }
+ 
+   static double GetTrigAngle(double a, double b, double d, double min, double max,
+                      boolean add) {
+     double theta;
+     double t, f, c;
+ 
+     f=d/Math.sqrt(a*a + b*b);
+     if (Math.abs(f) > 1.0) f=(f > 0.0) ? 1.0 : -1.0;
+ 
+     t=Math.atan2(a,b);
+     c=Math.acos(f);
+ 
+     theta=add?(t+c):(t-c);
+     if (theta<min) return min;
+     if (theta>max) return max;
+     return theta;
+   }
+  
+   public static Vector3d getForward(int leg, LegConfiguration angles) {
+     Vector3d pos=new Vector3d();
+     Matrix3d rot1=new Matrix3d();
+     Matrix3d rot2=new Matrix3d();
+ 
+     if (leg < 2) {
+       rot1.rotY(-angles.knee);
+       rot1.transform(f_leg_knee_to_ball,pos);
+ 
+       pos.add(f_leg_shoulder_to_knee);
+       rot1.rotX(angles.shoulder);
+       rot2.rotY(-angles.rotator);
+       rot1.mul(rot2);
+       rot1.transform(pos);
+ 
+       pos.add(f_body_to_shoulder);
+     } else {
+       rot1.rotY(angles.knee);
+       rot1.transform(h_leg_knee_to_ball,pos);
+ 
+       pos.add(h_leg_shoulder_to_knee);
+       rot1.rotX(angles.shoulder);
+       rot2.rotY(angles.rotator);
+       rot1.mul(rot2);
+       rot1.transform(pos);
+ 
+       pos.add(h_body_to_shoulder);
+     }
+     if (leg%2!=0) {
+       pos.y=-pos.y;  
+     }
+     return pos; 
+   }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/aibo3d/LegConfiguration.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/aibo3d/LegConfiguration.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/aibo3d/LegConfiguration.java	Fri Sep 26 00:36:17 2003
***************
*** 0 ****
--- 1,19 ----
+ package org.tekkotsu.aibo3d;
+ 
+ public class LegConfiguration {
+   public double rotator;
+   public double shoulder;
+   public double knee;
+ 
+   public LegConfiguration (double rotator, double shoulder, double knee) {
+     this.rotator=rotator;
+     this.shoulder=shoulder;
+     this.knee=knee;
+   }
+ 
+   public String toString() {
+     return "rotator = " + String.valueOf(rotator) + ", " +
+            "shoulder = " + String.valueOf(shoulder) + ", " +
+            "knee = " + String.valueOf(knee);
+   }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/aibo3d/PickMoveBehavior.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/aibo3d/PickMoveBehavior.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/aibo3d/PickMoveBehavior.java	Fri Sep 26 00:36:17 2003
***************
*** 0 ****
--- 1,285 ----
+ package org.tekkotsu.aibo3d;
+ 
+ import java.awt.*;
+ import java.awt.event.*;
+ import java.util.*;
+ import javax.media.j3d.*;
+ import javax.vecmath.*;
+ import javax.media.j3d.*;
+ import com.sun.j3d.utils.picking.*;
+ import com.sun.j3d.loaders.Scene;
+ 
+ public class PickMoveBehavior extends Behavior {
+   Canvas3D canvas3d;
+   BranchGroup branchGroup;
+   Scene scene;
+   AiboPicker picker;
+   PickCanvas pickCanvas;
+   WakeupCriterion[] mouseEvents;
+   WakeupOr mouseCriterion;
+   String currentLink;
+   int currentDragButton;
+   Vector3d currentPos;
+   Aibo3DForward forward;
+ 
+   TransformGroup viewTransformGroup;
+   Transform3D viewTransformX;
+   Transform3D viewTransformY;
+   Transform3D currTransform;
+   Vector3d viewTranslation;
+ 
+   int x, y, dx, dy, x_last, y_last;
+   
+   public PickMoveBehavior (Canvas3D canvas3d, BranchGroup branchGroup,
+       Scene scene, Aibo3DForward forward, TransformGroup viewTransformGroup) {
+     this.canvas3d=canvas3d;
+     this.branchGroup=branchGroup;
+     this.scene=scene;
+     this.forward=forward;
+     this.viewTransformGroup=viewTransformGroup;
+     viewTransformX=new Transform3D();
+     viewTransformY=new Transform3D();
+     currTransform=new Transform3D();
+     viewTranslation=new Vector3d();
+   }
+ 
+   public void initialize() {
+     pickCanvas = new PickCanvas (canvas3d, branchGroup);
+     pickCanvas.setMode(PickTool.GEOMETRY_INTERSECT_INFO);
+     pickCanvas.setTolerance(0.0f); // extra bit of speed
+ 
+     mouseEvents = new WakeupCriterion[3];
+     mouseEvents[0] = new WakeupOnAWTEvent(MouseEvent.MOUSE_DRAGGED);
+     mouseEvents[1] = new WakeupOnAWTEvent(MouseEvent.MOUSE_PRESSED);
+     mouseEvents[2] = new WakeupOnAWTEvent(MouseEvent.MOUSE_RELEASED);
+     mouseCriterion = new WakeupOr(mouseEvents);
+     wakeupOn(mouseCriterion);
+   }
+ 
+   public void createPicker() {
+     picker=new AiboPicker(scene);
+   }
+ 
+   void selectLink(MouseEvent event) {
+     if (currentLink!=null) return;
+     if (picker==null) return;
+     forward.lock=true;
+ 
+     pickCanvas.setShapeLocation (event);
+     PickResult result = pickCanvas.pickClosest();
+     if (result!=null) {
+       currentLink=picker.pick(result.getObject());
+       x = x_last = event.getX();
+       y = y_last = event.getY();
+       currentDragButton = event.getButton();
+ 
+       if (currentLink==AiboPicker.leg_fl ||
+           currentLink==AiboPicker.foot_fl ||
+           currentLink==AiboPicker.knee_fl) {
+         currentPos=Kinematics.getForward(Kinematics.FRONT_LEFT,
+           new LegConfiguration(-forward.thigh_fl.x,
+                                 forward.thigh_fl.z,
+                                -forward.knee_fl.x));
+       } else if (currentLink==AiboPicker.leg_fr ||
+           currentLink==AiboPicker.foot_fr ||
+           currentLink==AiboPicker.knee_fr) {
+         currentPos=Kinematics.getForward(Kinematics.FRONT_RIGHT,
+           new LegConfiguration(-forward.thigh_fr.x,
+                                -forward.thigh_fr.z,
+                                -forward.knee_fr.x));
+ 
+       } else if (currentLink==AiboPicker.leg_bl ||
+           currentLink==AiboPicker.foot_bl ||
+           currentLink==AiboPicker.knee_bl) {
+               currentPos=Kinematics.getForward(Kinematics.BACK_LEFT,
+           new LegConfiguration( forward.thigh_bl.x,
+                                 forward.thigh_bl.z,
+                                 forward.knee_bl.x));
+ 
+       } else if (currentLink==AiboPicker.leg_br ||
+           currentLink==AiboPicker.foot_br ||
+           currentLink==AiboPicker.knee_br) {
+         currentPos=Kinematics.getForward(Kinematics.BACK_RIGHT,
+           new LegConfiguration( forward.thigh_br.x,
+                                -forward.thigh_br.z,
+                                 forward.knee_br.x));
+ 
+       }
+     }
+   }
+ 
+   void rotateViewTransform() {
+     double x_angle, y_angle;
+     double x_factor = 0.03, y_factor = 0.03;
+     x_angle = dy * y_factor;
+     y_angle = dx * x_factor;
+ 
+     viewTransformX.rotX(x_angle);
+     viewTransformY.rotY(y_angle);
+     
+     viewTransformGroup.getTransform(currTransform);
+ 
+     Matrix4d mat = new Matrix4d();
+     currTransform.get(mat);
+ 
+     currTransform.setTranslation(new Vector3d(0.0,0.0,0.0));
+     currTransform.mul(viewTransformX, currTransform);
+     currTransform.mul(viewTransformY, currTransform);
+ 
+     Vector3d translation = new Vector3d(mat.m03, mat.m13, mat.m23);
+     currTransform.setTranslation(translation);
+ 
+     viewTransformGroup.setTransform(currTransform);
+   }
+ 
+   void translateViewTransform() {
+     double x_factor = 0.01, y_factor = 0.01;
+ 
+     viewTransformGroup.getTransform(currTransform);
+     viewTranslation.x = dx*x_factor;
+     viewTranslation.y = -dy*y_factor;
+ 
+     viewTransformX.set(viewTranslation);
+     currTransform.mul(viewTransformX, currTransform);
+     viewTransformGroup.setTransform(currTransform);
+   }
+ 
+   void dragLink(MouseEvent event) {
+     if (currentLink==null) return;
+ 
+     x = event.getX();
+     y = event.getY();
+ 
+     dx = x - x_last;
+     dy = y - y_last;
+ 
+     if (currentLink==AiboPicker.body) {
+       if (currentDragButton==MouseEvent.BUTTON1) {
+         rotateViewTransform();
+       } else if (currentDragButton==MouseEvent.BUTTON3) {
+         translateViewTransform();
+       }
+     } else if (currentLink==AiboPicker.head) {
+       if (currentDragButton==MouseEvent.BUTTON1) { 
+         forward.head.setYDiff(dx);
+         forward.neck.setXDiff(dy);
+       } else if (currentDragButton==MouseEvent.BUTTON3) {
+         forward.head.setZDiff(-dx);
+       }
+     } else if (currentLink==AiboPicker.jaw) {
+       forward.jaw.setXDiff(dy);
+     } else if (currentLink==AiboPicker.tail) {
+       forward.tail.setXDiff(-dy);
+       forward.tail.setYDiff(dx);
+     } else if (currentLink==AiboPicker.leg_fl) {
+       if (currentDragButton==MouseEvent.BUTTON1)
+         forward.thigh_fl.setXDiff(dy);
+       else if (currentDragButton==MouseEvent.BUTTON3)
+         forward.thigh_fl.setZDiff(dx);
+     } else if (currentLink==AiboPicker.knee_fl) {
+       forward.knee_fl.setXDiff(dy);
+     } else if (currentLink==AiboPicker.leg_fr) {
+       if (currentDragButton==MouseEvent.BUTTON1)
+         forward.thigh_fr.setXDiff(dy);
+       else if (currentDragButton==MouseEvent.BUTTON3)
+         forward.thigh_fr.setZDiff(dx);
+     } else if (currentLink==AiboPicker.knee_fr) {
+       forward.knee_fr.setXDiff(dy);
+     } else if (currentLink==AiboPicker.leg_bl) {
+       if (currentDragButton==MouseEvent.BUTTON1)
+         forward.thigh_bl.setXDiff(dy);
+       else if (currentDragButton==MouseEvent.BUTTON3)
+         forward.thigh_bl.setZDiff(dx);
+     } else if (currentLink==AiboPicker.knee_bl) {
+       forward.knee_bl.setXDiff(dy);
+     } else if (currentLink==AiboPicker.leg_br) {
+       if (currentDragButton==MouseEvent.BUTTON1)
+         forward.thigh_br.setXDiff(dy);
+       else if (currentDragButton==MouseEvent.BUTTON3)
+         forward.thigh_br.setZDiff(dx);
+     } else if (currentLink==AiboPicker.knee_br) {
+       forward.knee_br.setXDiff(dy);
+     } else if (currentLink==AiboPicker.foot_fl) {
+       if (currentDragButton==MouseEvent.BUTTON1) {
+         currentPos.x=currentPos.x-dx*0.3;
+         currentPos.z=currentPos.z-dy*0.3;
+       } else if (currentDragButton==MouseEvent.BUTTON3) {
+         currentPos.y=currentPos.y+dx*0.3;
+       }
+       LegConfiguration l=Kinematics.getInverse(Kinematics.FRONT_LEFT,
+                                                currentPos);
+       forward.thigh_fl.setX(-l.rotator);
+       forward.thigh_fl.setZ(l.shoulder);
+       forward.knee_fl.setX(-l.knee);
+     } else if (currentLink==AiboPicker.foot_fr) {
+       if (currentDragButton==MouseEvent.BUTTON1) {
+         currentPos.x=currentPos.x-dx*0.3;
+         currentPos.z=currentPos.z-dy*0.3;
+       } else if (currentDragButton==MouseEvent.BUTTON3) {
+         currentPos.y=currentPos.y+dx*0.3;
+       }
+       LegConfiguration l=Kinematics.getInverse(Kinematics.FRONT_RIGHT,
+                                                currentPos);
+       forward.thigh_fr.setX(-l.rotator);
+       forward.thigh_fr.setZ(-l.shoulder);
+       forward.knee_fr.setX(-l.knee);
+     } else if (currentLink==AiboPicker.foot_bl) {
+       if (currentDragButton==MouseEvent.BUTTON1) {
+         currentPos.x=currentPos.x-dx*0.3;
+         currentPos.z=currentPos.z-dy*0.3;
+       } else if (currentDragButton==MouseEvent.BUTTON3) {
+         currentPos.y=currentPos.y+dx*0.3;
+       }
+       LegConfiguration l=Kinematics.getInverse(Kinematics.BACK_LEFT,
+                                                currentPos);
+       forward.thigh_bl.setX(l.rotator);
+       forward.thigh_bl.setZ(l.shoulder);
+       forward.knee_bl.setX(l.knee);
+     } else if (currentLink==AiboPicker.foot_br) {
+       if (currentDragButton==MouseEvent.BUTTON1) {
+         currentPos.x=currentPos.x-dx*0.3;
+         currentPos.z=currentPos.z-dy*0.3;
+       } else if (currentDragButton==MouseEvent.BUTTON3) {
+         currentPos.y=currentPos.y+dx*0.3;
+       }
+       LegConfiguration l=Kinematics.getInverse(Kinematics.BACK_RIGHT,
+                                                currentPos);
+       forward.thigh_br.setX(l.rotator);
+       forward.thigh_br.setZ(-l.shoulder);
+       forward.knee_br.setX(l.knee);
+     }
+ 
+     x_last = x;
+     y_last = y;
+   }
+ 
+   void unselectLink() {
+     currentLink=null;
+     forward.lock=false;
+   }
+ 
+   public void processStimulus (Enumeration criteria) {
+     WakeupCriterion wakeup;
+     AWTEvent[] event;
+     int id;
+ 
+     while (criteria.hasMoreElements()) {
+       wakeup=(WakeupCriterion) criteria.nextElement();
+       if (wakeup instanceof WakeupOnAWTEvent) {
+         event=((WakeupOnAWTEvent)wakeup).getAWTEvent();
+         for (int i=0; i<event.length; i++) {
+           id=event[i].getID();
+           if (id == MouseEvent.MOUSE_DRAGGED) {
+             dragLink((MouseEvent)event[i]);
+           } else if (id == MouseEvent.MOUSE_PRESSED) {
+             selectLink((MouseEvent)event[i]);
+           } else if (id == MouseEvent.MOUSE_RELEASED) {
+             unselectLink();
+           }
+         }
+       }
+     }
+     wakeupOn(mouseCriterion);
+   }
+ 
+ }
Index: AiboPup/tools/mon/org/tekkotsu/aibo3d/WorldStateJointsWriter.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/aibo3d/WorldStateJointsWriter.java:1.3
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/aibo3d/WorldStateJointsWriter.java	Thu Oct  9 15:12:03 2003
***************
*** 0 ****
--- 1,56 ----
+ package org.tekkotsu.aibo3d;
+ 
+ import java.io.InputStream;
+ import java.io.OutputStream;
+ import java.net.Socket;
+ import org.tekkotsu.mon.TCPListener;
+ import org.tekkotsu.mon.Joints;
+ import java.net.SocketException;
+ 
+ public class WorldStateJointsWriter extends TCPListener {
+   OutputStream _out;
+ 
+   public void connected(Socket socket) {
+     try {
+       _out=socket.getOutputStream();
+ 			
+ 			//never actually receives anything...
+ 			InputStream sin=socket.getInputStream();
+ 			while (true) {
+ 				String msgtype=readLine(sin);
+ 			}
+     } catch(Exception e) {if((SocketException)e==null) e.printStackTrace();}
+ 
+ 		try { socket.close(); } catch (Exception ex) { }
+ 
+ 		_isConnected=false;
+   }
+ 
+   public boolean hasData() {
+     return false;
+   }
+ 
+   public Joints getData() {
+     return null;
+   }
+ 
+   public void close() {
+     _isConnected=false;
+     super.close();
+   }
+ 
+   public void write(float[] f) {
+     try {
+       for (int i=0; i<f.length; i++)
+         writeFloat(_out, f[i]);
+     } catch (Exception ex) { close(); }
+   }
+ 
+   public boolean isConnected() {
+     return _isConnected;
+   }
+ 
+   public WorldStateJointsWriter() { super(); }
+   public WorldStateJointsWriter(int port) { super(port); }
+   public WorldStateJointsWriter(String host, int port) { super(host,port); }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/AiboComm.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/AiboComm.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/AiboComm.java	Fri Sep 26 00:36:18 2003
***************
*** 0 ****
--- 1,31 ----
+ package org.tekkotsu.mon;
+ 
+ import java.io.*;
+ import java.net.*;
+ 
+ public class AiboComm {
+   public TCPListener stderr;
+   public TCPListener stdio;
+   public TCPListener visionRLE;
+   public TCPListener visionRaw;
+   public TCPListener visionObjs;
+   public TCPListener worldGrid;
+   public TCPListener localizer;
+ 
+   public AiboComm() {
+ //    stdio=new TextListener(10001);
+   }
+ 
+   public void close() {
+     stdio.close();
+   }
+ 
+   public static void sleep(long millis) {
+     try { Thread.sleep(millis); } catch (Exception ex) { }
+   }
+   
+   public static void main(String[] args) {
+     System.out.println("please instantiate from within Matlab");
+     System.exit(1);
+   }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/ClassPathModifier.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/ClassPathModifier.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/ClassPathModifier.java	Fri Sep 26 00:36:18 2003
***************
*** 0 ****
--- 1,34 ----
+ package org.tekkotsu.mon;
+ 
+ import java.lang.*;
+ import java.net.*;
+ import java.io.*;
+ import java.lang.reflect.*;
+ 
+ public class ClassPathModifier {
+   private static final Class[] parameters = new Class[]{URL.class};
+ 
+   public static void addFile(String s) throws IOException {
+     File f = new File(s);
+     addFile(f);
+   }
+ 
+   public static void addFile(File f) throws IOException {
+     addURL(f.toURL());
+   }
+ 
+   public static void addURL(URL u) throws IOException {
+     URLClassLoader sysloader =
+       (URLClassLoader)ClassLoader.getSystemClassLoader();
+ 
+ 		Class sysclass = URLClassLoader.class;
+ 
+     try {
+       Method method = sysclass.getDeclaredMethod("addURL",parameters);
+       method.setAccessible(true);
+       method.invoke(sysloader, new Object[]{ u });
+     } catch (Throwable t) {
+       throw new IOException("could not add "+u+" to classpath");
+ 		}
+   }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/ControllerGUI.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/ControllerGUI.java:1.8
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/ControllerGUI.java	Thu Oct  9 20:46:58 2003
***************
*** 0 ****
--- 1,572 ----
+ package org.tekkotsu.mon;
+ 
+ import java.awt.*;
+ import java.awt.event.*;
+ import javax.swing.*;
+ import javax.swing.event.*;
+ import java.beans.*;
+ import java.util.*;
+ import java.util.prefs.Preferences;
+ import java.io.PrintWriter;
+ import java.io.FileWriter;
+ 
+ //Admittedly a little sloppy, but I don't want to spend forever on this...
+ 
+ public class ControllerGUI extends JFrame implements ActionListener, KeyListener {
+ 	JList menu;
+ 	JScrollPane menuScroll;
+ 	JLabel title;
+ 	JLabel status;
+ 	JList scripts;
+ 	ControllerListener comm;
+ 	JButton backBut;
+ 	JButton refreshBut;
+ 	JButton reconnectBut;
+ 	EStopButton estop;
+ 	JTextField inputField;
+ 	boolean isUpdating=false;
+ 	DefaultListModel scriptsModel=new DefaultListModel();
+   Vector inputFieldHistory;
+   int inputFieldLocation;
+ 	static Preferences prefs = Preferences.userNodeForPackage(ControllerGUI.class);
+ 	final static int MAX_STORE_INPUT_HIST=20;
+ 	
+ 	ControllerGUI(String addr, int port) {
+ 		super();
+ 		comm = new ControllerListener(addr,port);
+ 		comm.listener=this;
+ 		init();
+ 		pack();
+ 		show();
+ 	}
+ 
+ 	// Disables the component if there's nothing selected to apply it to
+ 	public class AutoDisableListener implements PropertyChangeListener, ListSelectionListener {
+ 		JComponent target;
+ 		public AutoDisableListener(JComponent target, JList source) {
+ 			this.target=target;
+ 			source.addPropertyChangeListener(this);
+ 			source.addListSelectionListener(this);
+ 		}
+ 		public void propertyChange(PropertyChangeEvent evt) {
+ 			int min=((JList)evt.getSource()).getMinSelectionIndex();
+ 			int max=((JList)evt.getSource()).getMaxSelectionIndex();
+ 			//target.setEnabled(!((JList)evt.getSource()).isSelectionEmpty());
+ 			target.setEnabled(min!=-1 && max-min==0);
+ 		}
+ 		public void valueChanged(ListSelectionEvent evt) {
+ 			int min=((JList)evt.getSource()).getMinSelectionIndex();
+ 			int max=((JList)evt.getSource()).getMaxSelectionIndex();
+ 			//target.setEnabled(!((JList)evt.getSource()).isSelectionEmpty());
+ 			target.setEnabled(min!=-1 && max-min==0);
+ 		}
+ 	}
+ 	
+ 	final static ImageIcon rarrow = new ImageIcon("images/rarrow.gif");
+ 	final static ImageIcon larrow = new ImageIcon("images/larrow.gif");
+ 	final static ImageIcon carrows = new ImageIcon("images/chasingarrows.gif");
+ 
+ 	public class MyCellRenderer implements ListCellRenderer {
+ 		public Component getListCellRendererComponent(JList list,Object value,int index,boolean isSelected,boolean cellHasFocus) {
+ 			ControllerListener.MenuEntry me=(ControllerListener.MenuEntry)value;
+ 			/*			if(me.hasSubmenu) {
+ 						setIcon(rarrow);
+ 						setHorizontalTextPosition(SwingConstants.RIGHT);
+ 						setIconTextGap(5);
+ 						} else
+ 						setIconTextGap(5+rarrow.getIconWidth());
+ 			*/			
+ 			//System.out.println(this.getText()+" "+me.selected+" "+isSelected);
+ 			int numpre=(int)(Math.log(list.getModel().getSize()-1)/Math.log(10))-(index==0?0:(int)(Math.log(index)/Math.log(10)));
+ 			StringBuffer pre=new StringBuffer();
+ 			for(int i=0;i<numpre;i++)
+ 				pre.append(" ");
+ 			JLabel title=new JLabel(pre.toString()+index+". "+me.title);
+ 			title.setBackground(me.selected?list.getSelectionBackground():list.getBackground());
+ 			title.setForeground(me.selected?list.getSelectionForeground():list.getForeground());
+ 			title.setEnabled(list.isEnabled());
+ 			title.setFont(list.getFont());
+ 			title.setOpaque(true);
+ 			title.setPreferredSize(new Dimension(list.getSize().width,title.getPreferredSize().height));
+ 			//Vector tmp2=new Vector();
+ 			//for(int i=0;i<1000000;i++) {tmp2.add(new Integer(0));tmp2.remove(tmp2.size()-1);}
+ 			if(cellHasFocus)
+ 				title.setBorder(BorderFactory.createLineBorder(Color.GRAY,1));
+ 			else
+ 				title.setBorder(BorderFactory.createEmptyBorder(1,1,1,1));
+ 			if(me.hasSubmenu) {
+ 				Box tmp=Box.createHorizontalBox();
+ 				tmp.add(title);
+ 				//				tmp.add(Box.createHorizontalGlue());
+ 				JLabel arr=new JLabel(rarrow);
+ 				arr.setEnabled(list.isEnabled());
+ 				tmp.add(arr);
+ 				if(me.description.length()!=0)
+ 					tmp.setToolTipText(me.description);
+ 				return tmp;
+ 			} else {
+ 				Box tmp=Box.createHorizontalBox();
+ 				tmp.add(title);
+ 				tmp.add(Box.createHorizontalStrut(rarrow.getIconWidth()));
+ 				if(me.description.length()!=0)
+ 					tmp.setToolTipText(me.description);
+ 				return tmp;
+ 			}
+ 		}
+ 	} 
+ 	 
+ 	public class JListDoubleClick extends MouseAdapter {
+ 		ControllerGUI gui;
+ 		JListDoubleClick(ControllerGUI gui) { this.gui=gui; }
+ 		public void mouseClicked(MouseEvent e) {
+ 			if (e.getClickCount() == 2) {
+ 				int index = ((JList)e.getSource()).locationToIndex(e.getPoint());
+ 				gui.doubleClicked((JList)e.getSource(),index);
+ 			}
+ 		}
+ 	}
+ 
+ 	public class MySelectionListener implements ListSelectionListener {
+ 		ControllerGUI gui;
+ 		MySelectionListener(ControllerGUI gui) { this.gui=gui; }
+ 		public void valueChanged(ListSelectionEvent e) {
+ 			if(!gui.isUpdating && !e.getValueIsAdjusting())
+ 				gui.comm.sendSelection(((JList)e.getSource()).getSelectedIndices());
+ 		}
+ 	}
+  	
+ 	public class EscFilter extends KeyAdapter {
+ 		JButton trigger;
+ 		EscFilter(JButton trigger) { this.trigger=trigger; }
+ 		public void keyReleased(KeyEvent evt) {
+ 			if(evt.getKeyCode()==KeyEvent.VK_ESCAPE)
+ 				trigger.doClick();
+ 		}
+ 	}
+ 	public class DelFilter extends KeyAdapter {
+ 		ControllerGUI gui;
+ 		DelFilter(ControllerGUI gui) { this.gui=gui; }
+ 		public void keyReleased(KeyEvent evt) {
+ 			if(evt.getKeyCode()==KeyEvent.VK_BACK_SPACE || evt.getKeyCode()==KeyEvent.VK_DELETE)
+ 				gui.actionPerformed(new ActionEvent(evt.getSource(),0,"delbookmark"));
+ 		}
+ 	}
+ 	public class ReturnFilter extends KeyAdapter {
+ 		ControllerGUI gui;
+ 		ReturnFilter(ControllerGUI gui) { this.gui=gui; }
+ 		public void keyReleased(KeyEvent evt) {
+ 			if(evt.getKeyCode()==KeyEvent.VK_ENTER)
+ 				gui.doubleClicked((JList)evt.getSource(),0);
+ 		}
+ 	}
+  	
+ 	public class ReenableOnClose extends WindowAdapter {
+ 		JButton but;
+ 		public ReenableOnClose(JButton b) { but=b; }
+ 		public void windowClosing(WindowEvent e) {
+ 			e.getWindow().dispose();
+ 			but.setEnabled(true);
+ 		}
+ 	}
+ 
+ 	void lostConnection() {
+ 		updated();
+ 	}
+ 
+ 	void updated() {
+ 			//		System.out.println("updated");
+ 		isUpdating=true;
+ 		Point p=menuScroll.getViewport().getViewPosition();  
+ 
+ 		//scripts.setEnabled(comm._isConnected);
+ 		backBut.setEnabled(comm._isConnected);
+ 		refreshBut.setEnabled(comm._isConnected);
+ 		inputField.setEnabled(comm._isConnected);
+ 		if(!comm._isConnected) {
+ 			title.setText("-");
+ 			menu.setListData(new Vector());
+ 			status.setText("Reconnecting...");
+ 		} else {
+ 			if(comm._connectCount>0) {
+ 				if(comm._connectCount==1)
+ 					for(int i=0; i<scriptsModel.getSize(); i++)
+ 						if(scriptsModel.get(i).toString().equals("STARTUP"))
+ 							comm.sendInput(((ScriptEntry)scriptsModel.get(i)).cmd);
+ 				for(int i=0; i<scriptsModel.getSize(); i++)
+ 					if(scriptsModel.get(i).toString().equals("CONNECT"))
+ 						comm.sendInput(((ScriptEntry)scriptsModel.get(i)).cmd);
+ 				comm._connectCount=-1; //so we don't get it again
+ 			}
+ 			synchronized(comm._menus) {
+ 				title.setText((String)comm._titles.lastElement());
+ 				Vector menuitems=(Vector)comm._menus.lastElement();
+ 				menu.setValueIsAdjusting(true);
+ 				menu.setListData((Vector)menuitems.clone());
+ 				Vector sels=new Vector();
+ 				for(int i=0; i<menuitems.size(); i++)
+ 					if(((ControllerListener.MenuEntry)menuitems.get(i)).selected)
+ 						sels.add(new Integer(i));
+ 				int[] selsArr=new int[sels.size()];
+ 				for(int i=0; i<selsArr.length; i++)
+ 					selsArr[i]=((Integer)sels.get(i)).intValue();
+ 				menu.setSelectedIndices(selsArr);
+ 				menu.setValueIsAdjusting(false);
+ 			}
+ 			status.setText(comm._status.length()>0?comm._status:"Connected.");
+ 		}
+ 		menuScroll.getViewport().setViewPosition(p);
+ 		isUpdating=false;
+ 		comm._updatedFlag=false;
+ 	}
+ 
+ 	public void paint(Graphics g) {
+ 		if(comm!=null && comm._updatedFlag)
+ 			updated();
+ 		super.paint(g);
+ 	}
+ 	
+ 	public void actionPerformed(ActionEvent evt) {
+ 		if(evt.getSource()==backBut) {
+ 			//System.out.println("back button clicked");
+ 			comm.sendReturn();
+ 		} else if(evt.getSource()==refreshBut) {
+ 			//System.out.println("refresh button clicked");
+ 			comm.sendRefresh();
+ 		} else if(evt.getSource()==inputField) {
+ 			//System.out.println("input: "+inputField.getText());
+ 			int[] sel=menu.getSelectedIndices();
+       if (inputField.getText().length()==0) {
+ 			} else if(sel.length==0 || inputField.getText().charAt(0)=='!')
+ 				comm.sendInput(inputField.getText());
+ 			else
+ 				comm.sendInput("!input "+inputField.getText());
+ 			/*else if(sel.length==1) {
+ 				comm.sendSelectionPath(comm.buildSelectionPath(sel[0]));
+ 				comm.sendInput(inputField.getText());
+ 			} else
+ 				for(int i=0; i<sel.length; i++)
+ 					comm.sendInput(inputField.getText(),comm.buildSelectionPath(sel[i]));
+ 			*/
+       inputFieldHistory.add(inputField.getText());
+       inputFieldLocation=inputFieldHistory.size();
+ 			inputField.setText("");
+ 		} else if(evt.getSource()==reconnectBut) {
+ 			int port=comm._port;
+ 			String addr=comm._host;
+ 			comm.kill();
+ 			comm = new ControllerListener(addr,port);
+ 			comm.listener=this;
+ 			estop.close();
+ 			estop.open();
+ 		} else if(evt.getActionCommand().equals("raw") || evt.getActionCommand().equals("rle")) {
+ 			String[] tmp=new String[1];
+ 			tmp[0]=evt.getActionCommand();
+ 		 	VisionGUI vis=new VisionGUI(comm._host,tmp);
+ 			((JButton)evt.getSource()).setEnabled(false);
+ 			vis.addWindowListener(new ReenableOnClose((JButton)evt.getSource()));
+ 			vis.show();
+ 			vis.toFront();
+ 		} else if(evt.getActionCommand().equals("addbookmark")) {
+ 			int sel=comm.firstSelected();
+ 			if(sel==-1 || !comm._isConnected) {
+ 				scriptsModel.addElement(new ScriptEntry("",""));
+ 			} else {
+ 				String title=((ControllerListener.MenuEntry)((Vector)comm._menus.lastElement()).get(menu.getMinSelectionIndex())).title;
+ 				String command="!root";
+ 				Vector path=comm.buildSelectionPath(sel);
+ 				for(int i=1; i<path.size(); i++)
+ 					command+=" \""+path.get(i)+"\"";
+ 				scriptsModel.addElement(new ScriptEntry(title,command));
+ 			}
+ 			new EditScriptGUI(scriptsModel,scriptsModel.getSize()-1,true);
+ 		} else if(evt.getActionCommand().equals("editbookmark")) {
+ 			for(int i=0; i<scriptsModel.getSize(); i++)
+ 				if(scripts.isSelectedIndex(i))
+ 					new EditScriptGUI(scriptsModel,i,false);
+ 		} else if(evt.getActionCommand().equals("delbookmark")) {
+ 			for(int i=0; i<scriptsModel.getSize(); i++)
+ 				if(scripts.isSelectedIndex(i))
+ 					scriptsModel.remove(i--);
+ 		}
+ 	}
+ 	
+ 	public void doubleClicked(JList list, int index) {
+ 		if(list==menu) {
+ 			//Vector items=(Vector)comm._menus.lastElement();
+ 			//System.out.println(items.get(index)+" selected");
+ 			comm.sendSelect();
+ 			/*			int[] sel=menu.getSelectedIndices();
+ 						if(sel.length==1) {
+ 						comm.sendSelectionPath(comm.buildSelectionPath(sel[0]));
+ 						} else if(sel.length>1) {
+ 						Vector selectionPaths=new Vector();
+ 						for(int i=0; i<sel.length; i++)
+ 						selectionPaths.add(comm.buildSelectionPath(sel[i]));
+ 						for(int i=0; i<selectionPaths.size(); i++)
+ 						comm.sendSelectionPath((Vector)selectionPaths.get(i));
+ 						}
+ 			*/
+ 			inputField.setText("");
+ 		} else if(list==scripts) {
+ 			for(int i=0; i<scriptsModel.getSize(); i++)
+ 				if(scripts.isSelectedIndex(i))
+ 					comm.sendInput(((ScriptEntry)scriptsModel.get(i)).cmd);
+ 		} else {
+ 			System.out.println("Unknown list double-clicked");
+ 		}
+ 	}
+ 	
+ 	public class ConstSizeJButton extends JButton {
+ 		Dimension dim;
+ 		ConstSizeJButton(String s, ImageIcon i, Dimension d) { super(s,i); dim=d; }
+ 		public Dimension getPreferredSize() { return dim; }
+ 		public Dimension getMinimumSize() { return dim; }
+ 		public Dimension getMaximumSize() { return dim; }
+ 		public Dimension getSize() { return dim; }
+ 	}
+ 
+ 	protected void init() {
+ 		int spacer_size=10;
+ 	
+ 		
+ 		setTitle("TekkotsuMon: Controller Menus");
+ 		getContentPane().setLayout(new BorderLayout());
+ 		getContentPane().add(Box.createHorizontalStrut(spacer_size),BorderLayout.WEST);
+ 		getContentPane().add(Box.createHorizontalStrut(spacer_size),BorderLayout.EAST);
+ 		getContentPane().add(Box.createVerticalStrut(spacer_size),BorderLayout.NORTH);
+ 		getContentPane().add(Box.createVerticalStrut(spacer_size),BorderLayout.SOUTH);
+ 		
+ 		menu=new JList();
+ 		menu.setCellRenderer(new MyCellRenderer());
+ 		menu.setFixedCellWidth(165);
+ 		menu.addMouseListener(new JListDoubleClick(this)); 
+ 		menu.addListSelectionListener(new MySelectionListener(this));
+ 		menu.addKeyListener(new ReturnFilter(this));
+ 		
+ 		JPanel content=new JPanel(new BorderLayout());
+ 		Box titleBox=Box.createVerticalBox();
+ 		title=new JLabel("-");
+ 		title.setFont(new Font(title.getFont().getFontName(),Font.BOLD,title.getFont().getSize()));
+ 		title.setAlignmentX(0);
+ 		titleBox.add(title);
+ 		titleBox.add(Box.createVerticalStrut(spacer_size));
+ 		content.add(titleBox,BorderLayout.NORTH);
+ 		
+ 		Box menuBox=Box.createVerticalBox();
+ 		menuScroll=new JScrollPane(menu);
+ 		menuScroll.setAlignmentX(0.5f);
+ 		menuBox.add(menuScroll);
+ 		{
+ 			Box tmp=Box.createHorizontalBox();
+ 			backBut=new JButton("Back");
+ 			Dimension dim=new Dimension(backBut.getPreferredSize().width+larrow.getIconWidth()+backBut.getIconTextGap(),backBut.getPreferredSize().height);
+ 			tmp.add(backBut=new ConstSizeJButton("Back",larrow,dim));
+ 			backBut.setEnabled(false);
+ 			backBut.addActionListener(this);
+ 			backBut.setToolTipText("Returns to previous control");
+ 			tmp.add(refreshBut=new JButton("Refresh"));
+ 			refreshBut.setEnabled(false);
+ 			refreshBut.addActionListener(this);
+ 			refreshBut.setToolTipText("Requests a menu refresh (handy if item names are dynamic)");
+ 			tmp.setAlignmentX(0.5f);
+ 			menuBox.add(tmp);
+ 		}
+ 		content.add(menuBox,BorderLayout.CENTER);
+ 
+ 		Box statusbox=Box.createVerticalBox();
+ 		statusbox.add(Box.createVerticalStrut(spacer_size));
+ 		{
+ 			JSeparator sep=new JSeparator(SwingConstants.HORIZONTAL);
+ 			statusbox.add(sep);
+ 		}
+ 		statusbox.add(Box.createVerticalStrut(spacer_size-2));
+ 		{
+ 			JPanel tmp=new JPanel(new BorderLayout());
+ 			status=new JLabel("Connecting...");
+ 			tmp.add(status,BorderLayout.CENTER);
+ 			{
+ 				Box tmp2=Box.createHorizontalBox();
+ 				estop=new EStopButton(new EStopListener(comm._host,EStopListener.defPort));
+ 				estop.setMyDim(new Dimension(65,27));
+ 				estop.setMargin(new Insets(0,0,0,0));
+ 				tmp2.add(estop);
+ 				tmp2.add(Box.createHorizontalStrut(spacer_size));
+ 				reconnectBut=new JButton(carrows);
+ 				reconnectBut.setPreferredSize(new Dimension(carrows.getIconWidth(),carrows.getIconHeight()));
+ 				reconnectBut.addActionListener(this);
+ 				reconnectBut.setToolTipText("Drop current connection and try again.");
+ 				tmp2.add(reconnectBut);
+ 				tmp.add(tmp2,BorderLayout.EAST);
+ 			}
+ 			statusbox.add(tmp);
+ 		}
+ 		content.add(statusbox, BorderLayout.SOUTH);
+ 		
+ 		Box p=Box.createVerticalBox();
+ 		p.add(new JLabel("Send Input:"));
+     inputFieldHistory=new Vector();
+ 		for(int i=0; i<MAX_STORE_INPUT_HIST; i++)
+ 			inputFieldHistory.add(prefs.get("inputFieldHistory"+i,""));
+     inputFieldLocation=inputFieldHistory.size();
+ 		p.add(inputField=new JTextField());
+ 		inputField.setEnabled(false);
+ 		inputField.addActionListener(this);
+     inputField.addKeyListener(this);
+ 		inputField.setMaximumSize(new Dimension(inputField.getMaximumSize().width,inputField.getPreferredSize().height));
+ 		inputField.setToolTipText("Text from here is passed to selected controls, or the current control if no selection");
+ 
+ 		p.add(Box.createVerticalStrut(spacer_size));
+ 		{
+ 			JSeparator sep=new JSeparator(SwingConstants.HORIZONTAL);
+ 			sep.setMaximumSize(new Dimension(sep.getMaximumSize().width,spacer_size));
+ 			p.add(sep);
+ 		}
+ 		p.add(Box.createVerticalStrut(spacer_size-2));
+ 		
+ 		{
+ 			Box tmp=Box.createHorizontalBox();
+ 			JButton but;
+ 		 	but=new JButton("Raw Cam");
+ 			but.setToolTipText("Raw vision");
+ 			but.addActionListener(this);
+ 			but.setActionCommand("raw");
+ 			tmp.add(but);
+ 			but=new JButton("Seg. Cam");
+ 			but.setToolTipText("Segmented vision");
+ 			but.addActionListener(this);
+ 			but.setActionCommand("rle");
+ 			tmp.add(but);
+ 			tmp.setAlignmentX(0.0f);
+ 			p.add(tmp);
+ 		}
+ 		
+ 		p.add(Box.createVerticalStrut(spacer_size));
+ 		{
+ 			JSeparator sep=new JSeparator(SwingConstants.HORIZONTAL);
+ 			sep.setMaximumSize(new Dimension(sep.getMaximumSize().width,spacer_size));
+ 			p.add(sep);
+ 		}
+ 		p.add(Box.createVerticalStrut(spacer_size-2));
+ 		
+ 		p.add(new JLabel("Scripts:"));
+ 		scripts=new JList();
+ 		scripts.setFixedCellWidth(165);
+ 		scripts.addMouseListener(new JListDoubleClick(this));
+ 		scripts.addKeyListener(new ReturnFilter(this));
+ 		scripts.addKeyListener(new DelFilter(this));
+ 		scripts.setModel(scriptsModel);
+ 		{
+ 			JScrollPane tmp=new JScrollPane(scripts);
+ 			tmp.setAlignmentX(0);
+ 			p.add(tmp);
+ 		}
+ 
+ 		{
+ 			Box bbox=Box.createHorizontalBox();
+ 			bbox.setAlignmentX(0);
+ 			bbox.add(Box.createHorizontalGlue());
+ 			JButton tmp;
+ 			bbox.add(tmp=new JButton("Add"));
+ 			tmp.setActionCommand("addbookmark");
+ 			tmp.addActionListener(this);
+ 			tmp.setToolTipText("Adds a shortcut to the current item; saved when window closed");
+ 			bbox.add(tmp=new JButton("Edit"));
+ 			new AutoDisableListener(tmp,scripts);
+ 			tmp.setActionCommand("editbookmark");
+ 			tmp.addActionListener(this);
+ 			tmp.setToolTipText("Allows you to edit a script");
+ 			bbox.add(Box.createHorizontalGlue());
+ 			p.add(bbox);
+ 		}
+ 
+ 		{
+ 			JPanel p2=new JPanel(new BorderLayout());
+ 			p2.add(p,BorderLayout.EAST);
+ 			p2.add(Box.createHorizontalStrut(spacer_size),BorderLayout.WEST);
+ 			content.add(p2, BorderLayout.EAST);
+ 		}
+ 		
+ 		getContentPane().add(content,BorderLayout.CENTER);
+ 		EscFilter esc=new EscFilter(backBut);
+ 		addKeyListener(esc);
+ 		inputField.addKeyListener(esc);
+ 		menu.addKeyListener(esc);
+ 		
+ 		addWindowListener(new CloseVisionAdapter(this));
+ 
+ 		setLocation(prefs.getInt("ControllerGUI.location.x",50),prefs.getInt("ControllerGUI.location.y",50));
+ 		int numScripts=prefs.getInt("ControllerGUI.numScripts",0);
+ 		for(int i=0; i<numScripts; i++)
+ 			scriptsModel.addElement(new ScriptEntry(prefs.get("ControllerGUI.script"+i+".title","unknown"),prefs.get("ControllerGUI.script"+i+".cmd","")));
+ 	}
+ 	
+ 	class CloseVisionAdapter extends WindowAdapter {
+ 		ControllerGUI gui;
+ 		CloseVisionAdapter(ControllerGUI gui) {this.gui=gui;}
+ 		public void windowClosing(WindowEvent e) {
+ 			prefs.putInt("ControllerGUI.location.x",getLocation().x+getInsets().left);
+ 			prefs.putInt("ControllerGUI.location.y",getLocation().y+getInsets().top);
+ 			prefs.putInt("ControllerGUI.numScripts",scriptsModel.getSize());
+ 			for(int i=0; i<scriptsModel.getSize(); i++) {
+ 				prefs.put("ControllerGUI.script"+i+".title",((ScriptEntry)scriptsModel.get(i)).title);
+ 				prefs.put("ControllerGUI.script"+i+".cmd",((ScriptEntry)scriptsModel.get(i)).cmd);
+ 			}
+ 			for(int i=0; i<MAX_STORE_INPUT_HIST; i++)
+ 				prefs.put("inputFieldHistory"+i,(String)inputFieldHistory.get(inputFieldHistory.size()-MAX_STORE_INPUT_HIST+i));
+ 			gui.comm.kill();
+ 			estop.close();
+ 			while(gui.comm.isConnected())
+ 				try { Thread.sleep(50); System.out.print("."); } catch(Exception ex) {}
+ 		}
+ 	}
+ 
+ 	public void show() {
+ 		super.show();
+ 		menu.requestFocus();
+ 	}
+ 	
+ 	public static void main(String s[]) throws java.lang.InterruptedException {
+     if (s.length>1) {
+       System.out.println("usage: java ControllerGUI [host]");
+       System.exit(1);
+     }
+ 
+     try {
+       DogConfig dogConfig=new DogConfig (s);
+       ControllerGUI controllerGUI=new ControllerGUI(dogConfig.getIP(),
+           Integer.parseInt(dogConfig.getValue("Controller", "gui_port")));
+ 
+       controllerGUI.addWindowListener(new WindowAdapter() {
+           public void windowClosing(WindowEvent e) { System.exit(0);} });
+ 			try{
+ 				DogConfigFTP dog_ftp=new DogConfigFTP(dogConfig.getIP(), 21, "config", "config");
+ 				String col=dogConfig.getValue("Vision","colors");
+ 				col=col.substring(col.lastIndexOf('/')+1);
+ 				PrintWriter out=new PrintWriter(new FileWriter("default.col"));
+ 				String tmp=dog_ftp.getFile(col);
+ 				out.print(tmp);
+ 				out.close();
+ 			} catch(Exception ex) { ex.printStackTrace(); }
+     } catch (IllegalArgumentException ex) {System.exit(0);}
+ 	}
+ 
+   public void keyPressed(KeyEvent e) {
+     if (e.getComponent()==inputField) {
+       int key=e.getKeyCode();
+       if (key==KeyEvent.VK_UP || key==KeyEvent.VK_KP_UP) {
+         inputFieldLocation--;
+         if (inputFieldLocation < 0)
+           inputFieldLocation+=inputFieldHistory.size();
+         inputField.setText((String)inputFieldHistory.get(inputFieldLocation));
+       } else if (key==KeyEvent.VK_DOWN || key==KeyEvent.VK_KP_DOWN) {
+         inputFieldLocation++;
+         if (inputFieldLocation >= inputFieldHistory.size())
+           inputFieldLocation-=inputFieldHistory.size();
+         inputField.setText((String)inputFieldHistory.get(inputFieldLocation));
+       }
+     }
+   }
+   public void keyReleased(KeyEvent e) { }
+   public void keyTyped(KeyEvent e) { }
+ }
+ 
Index: AiboPup/tools/mon/org/tekkotsu/mon/ControllerListener.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/ControllerListener.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/ControllerListener.java	Wed Oct  1 22:08:08 2003
***************
*** 0 ****
--- 1,349 ----
+ package org.tekkotsu.mon;
+ 
+ import java.io.*;
+ import java.net.Socket;
+ import java.util.Vector;
+ import java.util.Iterator;
+ import java.lang.Integer;
+ import java.util.HashMap;
+ import java.lang.Class;
+ import java.lang.reflect.Method;
+ import java.lang.reflect.Constructor;
+ import java.net.SocketException;
+ 
+ public class ControllerListener extends TCPListener {
+ 	boolean _updatedFlag=true;
+ 	Vector _titles;
+ 	Vector _menus;
+ 	String _status;
+ 	PrintStream _out;
+ 	ControllerGUI listener;
+ 	HashMap dynObjs=new HashMap();
+ 	InputStream sin;
+ 	int _connectCount=0;
+ 	
+ 	public class MenuEntry {
+ 		boolean hasSubmenu;
+ 		boolean selected;
+ 		String title;
+ 		String description;
+ 		MenuEntry(boolean hasSubmenu, boolean selected, String title, String description) {
+ 			this.hasSubmenu=hasSubmenu;
+ 			this.selected=selected;
+ 			this.title=title;
+ 			this.description=description;
+ 		}
+ 		public String toString() { return title; }
+ 	}
+ 	
+ 	static String escapize(Vector path) {
+ 		System.out.println("Escapize:"+path);
+ 		StringBuffer p=new StringBuffer();
+ 		System.out.println("Escapized1:"+p);
+ 		for(int i=0; i<path.size(); i++) {
+ 			p.append("/");
+ 			System.out.println("Escapized2:"+p);
+ 			p.append(((String)path.get(i)).replaceAll("\\\\","\\\\\\\\").replaceAll("/","\\\\/"));
+ 			System.out.println("Escapized3:"+p);
+ 		}
+ 		System.out.println("Escapized:"+p);
+ 		return p.toString();
+ 	}
+ 
+ 	public int firstSelected() {
+ 		Vector menu=(Vector)_menus.lastElement();
+ 		for(int i=0; i<menu.size(); i++)
+ 			if(((MenuEntry)menu.get(i)).selected)
+ 				return i;
+ 		return -1;
+ 	}
+ 
+ 	public Vector buildSelectionPath(int index) {
+ 		Vector ans=buildSelectionPath();
+ 		ans.add(((Vector)_menus.lastElement()).get(index).toString());
+ 		return ans;
+ 	}
+ 		
+ 	public Vector buildSelectionPath() {
+ 		Vector ans=new Vector();
+ 		for(int i=0; i<_titles.size(); i++)
+ 			ans.add(_titles.get(i));
+ 		//ans.add(((Vector)_menus.get(i)).get(((Integer)_selections.get(0)).intValue()).toString());
+ 		return ans;
+ 	}
+ 		
+ 	void sendSelectionPath(Vector path) {
+ 		try {
+ 			_out.println("!select");
+ 		} catch (Exception ex) { }
+ 	}
+ 	
+ 	void sendSelect() {
+ 		try {
+ 			_out.println("!select");
+ 		} catch (Exception ex) { }
+ 	}
+ 	
+ 	void sendReturn() {
+ 		try {
+ 			_out.println("!cancel");
+ 		} catch (Exception ex) { }
+ 	}
+ 	
+ 	void sendRefresh() {
+ 		try {
+ 			_out.println("!refresh");
+ 		} catch (Exception ex) { }
+ 	}
+ 	
+ 	void sendInput(String s,Vector path) {
+ 		try {
+ 			Vector cur=buildSelectionPath();
+ 			sendSelectionPath(path);
+ 			_out.println(s);
+ 			sendSelectionPath(cur);
+ 		} catch (Exception ex) { }
+ 	}
+ 	
+ 	void sendInput(String s) {
+ 		try {
+ 			_out.println(s);
+ 		} catch (Exception ex) { }
+ 	}
+ 	
+ 	void sendSelection(int sel[]) {
+ 		try {
+ 			String msg="!hilight";
+ 			for(int i=0; i<sel.length; i++) {
+ 				msg+=" ";
+ 				msg+=sel[i];
+ 			}
+ 			_out.println(msg);
+ 		} catch (Exception ex) { }
+ 	}
+ 
+ 	public void connected(Socket socket) {
+ 		_isConnected=true;
+ 		_connectCount=0;
+ 		_menus=new Vector();
+ 		_menus.add(new Vector());
+ 		_titles=new Vector();
+ 		_titles.add("Loading...");
+ //		System.out.println("connection opened");
+ 		try {
+ 			sin=socket.getInputStream();
+ 			_out=new PrintStream(socket.getOutputStream());
+ 			_out.println("!hello");
+ 			_out.println("!refresh");
+ 			while (true) {
+ 				String msgtype=readLine(sin);
+ 				if(!_isConnected) break;
+ 				//				System.out.println("Received: "+msgtype);
+ 				synchronized(_menus) {
+ 					if(msgtype.equals("push")) {
+ 						_menus.add(new Vector());
+ 						_titles.add("Loading...");
+ 					} else if(msgtype.equals("refresh")) {
+ 						String last=readLine(sin);
+ 						if(!_isConnected) break;
+ 						_titles.set(_titles.size()-1,last);
+ 						int len=Integer.parseInt(readLine(sin));
+ 						if(!_isConnected) break;
+ 						Vector menu=(Vector)_menus.lastElement();
+ 						menu.clear();
+ 						for(;len>0;len--) {
+ 							int x=Integer.parseInt(readLine(sin));
+ 							if(x==-1) {
+ 								_isConnected=false;
+ 								break;
+ 							}
+ 							int sel=Integer.parseInt(readLine(sin));
+ 							if(x==-1) {
+ 								_isConnected=false;
+ 								break;
+ 							}
+ 							last=readLine(sin);
+ 							if(!_isConnected) break;
+ 							String descript=readLine(sin);
+ 							if(!_isConnected) break;
+ 							menu.add(new MenuEntry((x>0),(sel>0),last,descript));
+ 						}
+ 						_status="";
+ 						if(!_isConnected) break;
+ 					} else if(msgtype.equals("pop")) {
+ 						if(_menus.size()>1) {
+ 							_menus.remove(_menus.size()-1);
+ 							_titles.remove(_titles.size()-1);
+ 						}
+ 					} else if(msgtype.equals("hello")) {
+ 						_connectCount=Integer.parseInt(readLine(sin));
+ 						if(!_isConnected) break;
+ 						continue;
+ 					} else if(msgtype.equals("reset")) {
+ 						_menus.clear();
+ 						_menus.add(new Vector());
+ 						_titles.clear();
+ 					} else if(msgtype.equals("status")) {
+ 						_status=readLine(sin);
+ 						if(!_isConnected) break;
+ 					} else if(msgtype.equals("load")) {
+ 						String type=readLine(sin);
+ 						if(!_isConnected) break;
+ 						String name=readLine(sin);
+ 						if(!_isConnected) break;
+ 						int port=Integer.parseInt(readLine(sin));
+ 						if(!_isConnected) break;
+ 						String args=readLine(sin);
+ 						if(!_isConnected) break;
+ 						String[] argArr=parseArgs(args);
+ 						if(!_isConnected) break;
+ 						Class objClass=null;
+ 						try {
+ 							objClass=Class.forName(type);
+ 						} catch(Exception ex) { System.out.println("Could not load "+type+": "+ex); }
+ 						if(objClass!=null) {
+ 							Class[] consArgClasses=new Class[3];
+ 							Object[] consArgs=new Object[3];
+ 							consArgs[0]=_host;
+ 							consArgs[1]=new Integer(port);
+ 							consArgs[2]=argArr;
+ 							for(int i=0;i<consArgs.length;i++)
+ 								consArgClasses[i]=consArgs[i].getClass();
+ 							consArgClasses[1]=Integer.TYPE;
+ 							Constructor objCons=objClass.getConstructor(consArgClasses);
+ 							Object obj=objCons.newInstance(consArgs);
+ 							dynObjs.put(name,obj);
+ 						}
+ 					} else if(msgtype.equals("close")) {
+ 						String name=readLine(sin);
+ 						if(!_isConnected) break;
+ 						Object obj=dynObjs.get(name);
+ 						if(obj==null) {
+ 							System.out.println("ControllerGUI: error - could not close "+name+" - not loaded");
+ 						} else {
+ 							try { 
+ 								Method m=obj.getClass().getMethod("close",null);
+ 								m.invoke(obj,null);
+ 							} catch (Exception e) {}
+ 						}
+ 						dynObjs.remove(name);
+ 					} else {
+ 						System.err.println("ControllerListener - Invalid message type:"+msgtype);
+ 					}
+ 					_updatedFlag=true;
+ 					if(listener!=null)
+ 						listener.repaint();
+ 					else
+ 						System.out.println("null listener");
+ 				}
+ 			}
+ 		} catch (Exception e) {if((SocketException)e==null) e.printStackTrace(); }
+ 		
+ 		try { socket.close(); } catch (Exception ex) { }
+ 
+ 		//		while(_updatedFlag)
+ 		//				try { Thread.sleep(100); } catch (Exception ex) {}
+ 
+ 		_isConnected=false;
+ 		_updatedFlag=true;
+ 		_status="Reconnecting.";
+ 		if(listener!=null) {
+ 			listener.lostConnection();
+ 			listener.repaint();
+ 		}
+ 		//The sleep is to get around the socket still listening after being closed thing
+ 		if(!destroy)
+ 			System.out.println("ControllerGUI - connection closed... reconnect after 5 seconds");
+ 		try { Thread.sleep(5000); } catch (Exception ex) {}
+ 	}
+ 
+ 	public void kill() {
+ 		Iterator it=dynObjs.values().iterator();
+ 		while(it.hasNext()) {
+ 			Object obj=it.next();
+ 			try {
+ 				Method m=obj.getClass().getMethod("close",null);
+ 				m.invoke(obj,null);
+ 			} catch(Exception ex) {}
+ 		}
+ 		dynObjs.clear();
+ 		super.kill();
+ 	}
+  
+ 	public boolean hasData() {
+ 		return _updatedFlag;
+ 	}
+ 
+ 	public boolean isConnected() {
+ 		return _isConnected;
+ 	}
+ 
+ 	public String[] parseArgs(String args) throws java.io.IOException {
+ 		Vector v=new Vector();
+ 		StringBuffer cur=new StringBuffer();
+ 		boolean isDoubleQuote=false;
+ 		boolean isSingleQuote=false;
+ 		do {
+ 			for(int i=0; i<args.length(); i++) {
+ 				char c=args.charAt(i);
+ 				switch(c) {
+ 				case ' ':
+ 				case '\n':
+ 				case '\r':
+ 				case '\t':
+ 				case '\f':
+ 					if(isSingleQuote || isDoubleQuote)
+ 						cur.append(c);
+ 					else if(cur.length()>0) {
+ 						v.add(cur.toString());
+ 						cur.setLength(0);
+ 					}
+ 					break;
+ 				case '\\':
+ 					if(i==args.length()-1) { //escaped line break
+ 						args=readLine(sin);  //get next line and continue
+ 						if(!isConnected()) {
+ 							if(cur.length()>0)
+ 								v.add(cur.toString());
+ 							return makeArray(v);
+ 						}
+ 						if(isSingleQuote || isDoubleQuote)
+ 							cur.append('\n');
+ 						i=-1;
+ 					} else
+ 						cur.append(args.charAt(++i));
+ 					break;
+ 				case '"':
+ 					if(isSingleQuote)
+ 						cur.append(c);
+ 					else
+ 						isDoubleQuote=!isDoubleQuote;
+ 					break;
+ 				case '\'':
+ 					if(isDoubleQuote)
+ 						cur.append(c);
+ 					else
+ 						isSingleQuote=!isSingleQuote;
+ 					break;
+ 				default:
+ 					cur.append(c);
+ 					break;
+ 				}
+ 			} 
+ 		} while(isDoubleQuote || isSingleQuote);
+ 		if(cur.length()>0)
+ 			v.add(cur.toString());
+ 		return makeArray(v);
+ 	}
+ 
+ 	protected String[] makeArray(Vector v) {
+ 		String[] ans=new String[v.size()];
+ 		for(int i=0; i<v.size(); i++)
+ 			ans[i]=(String)v.get(i);
+ 		return ans;
+ 	}
+ 
+ 	public ControllerListener() { super(); }
+ 	public ControllerListener(int port) { super(port); }
+ 	public ControllerListener(String host, int port) { super(host,port); }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/ControllerMsg.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/ControllerMsg.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/ControllerMsg.java	Fri Sep 26 00:36:18 2003
***************
*** 0 ****
--- 1,16 ----
+ package org.tekkotsu.mon;
+ 
+ import javax.swing.JOptionPane;
+ 
+ public class ControllerMsg {
+ 
+ 	public static void main(String args[]) {
+ 		new ControllerMsg("",0,args);
+ 	}
+ 
+ 	public ControllerMsg(String host, int port, String args[]) {
+ 		for(int i=0; i<args.length; i++)
+ 			System.out.println("<"+args[i]+">");
+ 		JOptionPane.showMessageDialog(null,args[1],args[0],JOptionPane.INFORMATION_MESSAGE);
+ 	}
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/DogConfig.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/DogConfig.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/DogConfig.java	Fri Sep 26 00:36:18 2003
***************
*** 0 ****
--- 1,187 ----
+ package org.tekkotsu.mon;
+ 
+ import java.util.*;
+ import java.io.*;
+ import java.lang.*;
+ 
+ public class DogConfig {
+   List IPs;
+   String IP;
+   Hashtable config;
+ 
+   public static void main(String args[]) {
+     try {
+       DogConfig config=new DogConfig(args);
+     } catch (IllegalArgumentException ex) { }
+   }
+ 
+   void usage() {
+     System.out.println("java DogConfig Internet_Address");
+   }
+ 
+   public DogConfig(String args[]) {
+     try { ClassPathModifier.addFile("ftp.jar"); }
+     catch (Exception ex) { System.out.println(ex); System.exit(1); }
+ 
+     for (int i=0; i<args.length; i++) {
+       if (args[i].charAt(0)=='-') {
+         System.out.println(args[i] + "is not a valid internet address");
+         throw new IllegalArgumentException();
+       }
+     }
+ 
+     readConfig();
+     for (int i=0; i<args.length; i++) {
+       if (tryIP(args[i])) {
+         IP=args[i];
+         break;
+       }
+     }
+ 
+     if (IP!=null) {
+       int insertpos=0;
+       boolean ipbegun=false;
+ 
+       for (ListIterator iter = IPs.listIterator(); iter.hasNext(); ) {
+         String cline=(String)iter.next();
+         int clength=cline.length();
+ 
+         if (clength!=0 && cline.charAt(0)!='#') ipbegun=true;
+         else if (!ipbegun) insertpos++;
+ 
+         if (cline.compareToIgnoreCase(IP)==0) {
+           insertpos=-1;
+           break;
+         }
+       }
+       
+       if (insertpos>=0) {
+         IPs.add(insertpos,IP); 
+         writeConfig();
+       }
+     } else if (args.length==0) {
+       for (ListIterator iter = IPs.listIterator(); iter.hasNext(); ) {
+         String cline=(String)iter.next();
+         int clength=cline.length();
+         if (clength!=0 && cline.charAt(0)!='#') {
+           if (tryIP(cline)) {
+             IP=cline;
+             break;
+           }
+         }
+       }
+     }
+   
+     if (IP==null) {
+       System.out.println("Dog not found; please switch on dog or specify" +
+                          " correct IP address");
+       throw new IllegalArgumentException();
+       // pop up dialog box asking for IP address?
+     }
+   }
+ 
+   boolean tryIP(String ip) {
+     DogConfigFTP dog_ftp=new DogConfigFTP(ip, 21, "config", "config");
+     System.out.print("Trying "+ip+" ... ");
+     System.out.flush();
+     if (dog_ftp.test()) {
+       System.out.println("found");
+       try {
+         readAiboConfig(dog_ftp.getFile("tekkotsu.cfg"));
+         return true;
+       } catch (Exception ex) {
+         System.out.println("ftp error: "+ ex);
+       }
+     } else {
+       System.out.println("not found");
+     }
+     return false;
+   }
+ 
+   public DogConfig() {
+     this(new String[]{});
+   }
+ 
+   public DogConfig(String s) {
+     this(new String[]{s});
+   }
+ 
+   public String getIP() {
+     return IP;
+   }
+ 
+   void readAiboConfig(String conf) {
+     String[] lines=conf.split("[\r\n]");
+     config=new Hashtable();
+     Hashtable current=config;
+ 
+     for (int i=0; i<lines.length; i++) {
+       String cline=lines[i];
+       int clength=cline.length();
+       if (clength!=0 && cline.charAt(0)!='#') {
+         if (cline.charAt(0)=='[' && cline.charAt(clength-1)==']') {
+           String category=cline.substring(1,clength-1);
+           current=new Hashtable();
+           config.put(category, current);
+         } else {
+           int ind=cline.indexOf('=');
+           if (ind<0) {
+             System.out.println("warning: line "+(i+1)+" ignored");
+             System.out.println("       > "+cline);
+           } else {
+             String key=cline.substring(0,ind);
+             String value=cline.substring(ind+1,clength);
+             current.put(key, value);
+           }
+         }
+       }
+     }
+   }
+ 
+   public String getValue(String section, String key) {
+     Hashtable sectionhash=(Hashtable)config.get(section);
+     if (sectionhash!=null)
+       return (String)sectionhash.get(key);
+     return null;
+   }
+ 
+   File configFile() {
+     String homedir="";
+     try { homedir=System.getProperty("user.home"); } catch (Exception ex) {}
+     return new File(homedir, ".aibo_ip");
+   }
+ 
+   void readConfig() {
+     IPs=new ArrayList(10);
+     try {
+       BufferedReader in = new BufferedReader
+         ( new FileReader (configFile()) );
+       String curLine=in.readLine();
+       while (curLine!=null) {
+         IPs.add(curLine);
+         curLine=in.readLine();
+       }
+       in.close();
+     } catch (FileNotFoundException ex) {
+       // we just start off with 0 IPs
+       // also creating a new file, so add an intro comment
+       IPs.add("# Ordered list of IPs to be used by Tekkotsu tools\n");
+     } catch (IOException ex) {
+       // we read what we could
+     }
+     // no real need for parsing and verifying correctness of IPs
+   }
+ 
+   void writeConfig() {
+     try {
+       PrintWriter out = new PrintWriter ( new BufferedWriter (
+             new FileWriter (configFile())));
+       for (ListIterator iter = IPs.listIterator(); iter.hasNext(); ) {
+         out.println(iter.next());
+       }
+       out.close();
+     } catch (IOException ex) {
+       // can't do much about it
+     }
+   }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/DogConfigFTP.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/DogConfigFTP.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/DogConfigFTP.java	Fri Sep 26 00:36:18 2003
***************
*** 0 ****
--- 1,69 ----
+ package org.tekkotsu.mon;
+ 
+ import com.enterprisedt.net.ftp.*;
+ import java.util.*;
+ import java.net.*;
+ import java.io.*;
+ 
+ public class DogConfigFTP {
+   String _ip;
+   int _port;
+   String _user;
+   String _pass;
+ 
+   public DogConfigFTP(String ip) {
+     this(ip, 21);
+   }
+ 
+   public DogConfigFTP(String ip, int port) {
+     _ip=ip;
+     _port=port;
+     _user="anonymous";
+     _pass="DogConfigFTP@tekkotsu.org";
+   }
+ 
+   public DogConfigFTP(String ip, int port, String user, String pass) {
+     this(ip, port);
+     _user=user;
+     _pass=pass;
+   }
+   
+   public boolean test() {
+     return test(500);
+   }
+ 
+   public boolean test(int millis) {
+     Socket _ftpSocket=new Socket();
+     try {
+       _ftpSocket.connect(new InetSocketAddress(_ip, _port), millis);
+     } catch (Exception ex) { }
+     if (_ftpSocket.isConnected()) {
+       try { _ftpSocket.close(); } catch (Exception ex) { }
+       return true;
+     } else {
+       return false;
+     }
+   }
+ 
+   public String getFile(String remotename) throws FTPException, IOException {
+     FTPClient ftp=new FTPClient(_ip, _port);
+     ftp.login(_user, _pass);
+     ftp.setConnectMode(FTPConnectMode.ACTIVE);
+     ftp.setType(FTPTransferType.ASCII);
+     String ret=new String(ftp.get(remotename));
+     ftp.quit();
+     return ret;
+   }
+ 
+   public String getFile(String user, String pass, String remotename)
+       throws FTPException, IOException {
+     _user=user;
+     _pass=pass;
+     return getFile(remotename);
+   }
+ 
+   public static void main(String args[]) {
+     System.out.println("This is an internal class - run DogConfig instead");
+     System.exit(0);
+   }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/EStopButton.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/EStopButton.java:1.6
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/EStopButton.java	Wed Oct  8 15:11:21 2003
***************
*** 0 ****
--- 1,125 ----
+ package org.tekkotsu.mon;
+ 
+ import javax.swing.JButton;
+ import javax.swing.JFrame;
+ import javax.swing.ImageIcon;
+ import java.awt.event.WindowAdapter;
+ import java.awt.event.WindowEvent;
+ import java.awt.*;
+ import java.awt.event.MouseEvent;
+ import java.awt.event.InputEvent;
+ 
+ public class EStopButton extends JButton implements EStopListener.UpdatedListener {
+ 	EStopListener comm;
+ 	int mode;
+ 	static final int STOPPED_MODE=0;
+ 	static final int NOTSTOPPED_MODE=1;
+ 	static final int DISABLED_MODE=2;
+ 	static final int MAX_MODE=3;
+ 	final static ImageIcon goIcon = new ImageIcon("images/go.gif");
+ 	final static ImageIcon stopIcon = new ImageIcon("images/stop.gif");
+ 	final static ImageIcon disIcon = new ImageIcon("images/offline.gif");
+ 	Dimension dim;
+ 
+ 	static public void main(String s[]) {
+ 		int port=EStopListener.defPort;
+ 		if(s.length<1)
+ 			usage();
+ 		if(s.length>1)
+ 			port=Integer.parseInt(s[1]);
+ 		String[] args=new String[s.length-1];
+ 		for(int i=0; i<s.length-1; i++)
+ 			args[i-1]=s[i];
+ 		JFrame frame=new JFrame("TekkotsuMon: EStop");
+ 		frame.setSize(new Dimension(200, 200)); 
+ 		EStopButton estop=new EStopButton(new EStopListener(s[0],port));
+ 		frame.getContentPane().add(estop);
+ 		frame.addWindowListener(new WindowAdapter() {
+ 				public void windowClosing(WindowEvent e) { System.exit(0); } });
+ 		frame.show();
+ 	}
+ 
+ 	public static void usage() {
+ 		System.out.println("Usage: java EStopButton host [port]");
+ 		System.out.println("       if port is not specified, it defaults to "+EStopListener.defPort);
+ 		System.exit(2);
+ 	}
+ 
+ 	public EStopButton(EStopListener comm) {
+ 		super();
+ 		
+ 		this.comm=comm;
+ 		mode=comm.isConnected()?(comm.getEStop()?STOPPED_MODE:NOTSTOPPED_MODE):DISABLED_MODE;
+ 		setEnabled(mode!=DISABLED_MODE);
+ 		comm.addUpdatedListener(this);
+ 		
+ 		setToolTipText("Toggle Emergency Stop; alt-click to open new window");
+ 		enableEvents(AWTEvent.MOUSE_EVENT_MASK);
+ 
+ 		updateStatus();
+ 	}
+ 
+ 	public void close() {
+ 		comm.kill();
+ 		remove();
+ 	}
+ 	
+ 	public void remove() {
+ 		comm.removeUpdatedListener(this);
+ 	}
+ 	
+ 	public void open() {
+ 		comm.addUpdatedListener(this);
+ 		comm.startThread();
+ 	}
+ 
+ 	public void setMyDim(Dimension d) { dim=d; }
+ 	public Dimension getMyDim() { return dim; }
+ 
+ 	public Dimension getPreferredSize() { return dim; }
+ 	public Dimension getMinimumSize() { return dim; }
+ 	public Dimension getMaximumSize() { return dim; }
+ 	
+ 	public void estopUpdated(EStopListener l) {
+ 		if(l.isConnected()) {
+ 			if(l.getEStop())
+ 				mode=STOPPED_MODE;
+ 			else
+ 				mode=NOTSTOPPED_MODE;
+ 		} else
+ 			mode=DISABLED_MODE;
+ 		updateStatus();
+ 		setEnabled(l.isConnected());
+ 	}
+ 
+ 	public void updateStatus() {
+ 		if(mode==STOPPED_MODE) {
+ 			setText("Go");
+ 			setIcon(goIcon);
+ 		}
+ 		if(mode==NOTSTOPPED_MODE) {
+ 			setText("Stop");
+ 			setIcon(stopIcon);
+ 		}
+ 		if(mode==DISABLED_MODE) {
+ 			setText("");
+ 			setIcon(disIcon);
+ 		}
+ 	}
+ 	
+ 	public void processMouseEvent(MouseEvent e) {
+ 		if(e.getID()==MouseEvent.MOUSE_RELEASED) {
+ 			if((e.getModifiersEx()&InputEvent.ALT_DOWN_MASK)!=0) {
+ 				EStopGUI es=new EStopGUI(comm);
+ 			} else {
+ 				if(isEnabled()) {
+ 					comm.toggleEStop();
+ 				} else {
+ 					close();
+ 					open();
+ 				}
+ 			}
+ 		}
+ 		super.processMouseEvent(e);
+ 	}
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/EStopGUI.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/EStopGUI.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/EStopGUI.java	Fri Sep 26 00:36:19 2003
***************
*** 0 ****
--- 1,125 ----
+ package org.tekkotsu.mon;
+ 
+ import javax.swing.*;
+ import java.awt.*;
+ import java.awt.event.WindowAdapter;
+ import java.awt.event.WindowEvent;
+ import java.awt.event.ActionListener;
+ import java.awt.event.ActionEvent;
+ import java.util.prefs.Preferences;
+ 
+ 
+ public class EStopGUI extends JFrame implements ActionListener, EStopListener.UpdatedListener {
+ 	static int defPort=10053;
+ 	JLabel status;
+ 	JButton reconnectBut;
+ 	EStopPanel estop;
+ 	final static ImageIcon carrows = new ImageIcon("images/chasingarrows.png");
+ 	static Preferences prefs = Preferences.userNodeForPackage(EStopGUI.class);
+ 
+ 	static public void main(String s[]) {
+ 		int port=defPort;
+ 		if(s.length<1)
+ 			usage();
+ 		if(s.length>1)
+ 			port=Integer.parseInt(s[1]);
+ 		String[] args=new String[s.length-1];
+ 		for(int i=0; i<s.length-1; i++)
+ 			args[i-1]=s[i];
+ 		JFrame frame=new EStopGUI(s[0],port,args);
+ 		frame.addWindowListener(new WindowAdapter() {
+ 			public void windowClosing(WindowEvent e) { System.exit(0); }
+ 			});
+ 	}
+ 
+ 	public static void usage() {
+ 		System.out.println("Usage: java EStopGUI host [port]");
+ 		System.out.println("			 if port is not specified, it defaults to "+EStopListener.defPort);
+ 		System.exit(2);
+ 	}
+ 
+ 	public EStopGUI(String host, int port, String args[]) {
+ 		super("TekkotsuMon: EStop Controller");
+ 		init(new EStopListener(host,port));
+ 	}
+ 
+ 	public EStopGUI(EStopListener comm) {
+ 		super();
+ 		init(comm);
+ 	}
+ 
+ 	protected void init(EStopListener comm) {
+ 		int spacer_size=10;
+ 		Container root = getContentPane();
+ 		root.setLayout(new BorderLayout());
+ 		root.add(estop=new EStopPanel(comm),BorderLayout.CENTER);
+ 		root.add(Box.createVerticalStrut(spacer_size),BorderLayout.NORTH);
+ 		root.add(Box.createHorizontalStrut(spacer_size),BorderLayout.EAST);
+ 		root.add(Box.createHorizontalStrut(spacer_size),BorderLayout.WEST);
+ 		
+ 		{
+ 			Box statusbox=Box.createVerticalBox();
+ 			statusbox.add(Box.createVerticalStrut(spacer_size));
+ 			{
+ 				JSeparator sep=new JSeparator(SwingConstants.HORIZONTAL);
+ 				statusbox.add(sep);
+ 			}
+ 			statusbox.add(Box.createVerticalStrut(spacer_size-2));
+ 			{
+ 				JPanel tmp=new JPanel(new BorderLayout());
+ 				status=new JLabel("Connecting...");
+ 				estopUpdated(comm);
+ 				tmp.add(Box.createHorizontalStrut(spacer_size),BorderLayout.WEST);
+ 				tmp.add(status,BorderLayout.CENTER);
+ 				{
+ 					Box tmp2=Box.createHorizontalBox();
+ 					reconnectBut=new JButton(carrows);
+ 					reconnectBut.setPreferredSize(new Dimension(carrows.getIconWidth(),carrows.getIconHeight()));
+ 					reconnectBut.addActionListener(this);
+ 					reconnectBut.setToolTipText("Drop current connection and try again.");
+ 					tmp2.add(reconnectBut);
+ 					tmp2.add(Box.createHorizontalStrut(spacer_size));
+ 					tmp.add(tmp2,BorderLayout.EAST);
+ 				}
+ 				statusbox.add(tmp);
+ 			}
+ 			statusbox.add(Box.createVerticalStrut(spacer_size));
+ 			root.add(statusbox, BorderLayout.SOUTH);
+ 		}
+ 		addWindowListener(new CloseEStopAdapter(this));
+ 		estop.setPreferredSize(new Dimension(150,150));
+ 		pack();
+ 		estop.setPreferredSize(null);
+ 		estop.comm.addUpdatedListener(this);
+ 		setLocation(prefs.getInt("EStopGUI.location.x",50),prefs.getInt("EStopGUI.location.y",50));
+ 		show();
+ 	}
+ 
+ 	public void actionPerformed(ActionEvent evt) {
+ 		if(evt.getSource()==reconnectBut) {
+ 			estop.close();
+ 			estop.open();
+ 		}
+ 	}
+ 	class CloseEStopAdapter extends WindowAdapter {
+ 		EStopGUI gui;
+ 		CloseEStopAdapter(EStopGUI gui) {this.gui=gui;}
+ 		public void windowClosing(WindowEvent e) {
+ 			gui.close();
+ 		}
+ 	}
+ 	public void close() {
+ 		prefs.putInt("EStopGUI.location.x",getLocation().x+getInsets().left);
+ 		prefs.putInt("EStopGUI.location.y",getLocation().y+getInsets().top);
+ 		estop.remove();
+ 		estop.comm.removeUpdatedListener(this);
+ 		dispose();
+ 	}
+ 	public void estopUpdated(EStopListener l) {
+ 		if(l.isConnected()) {
+ 			status.setText("Connected.");
+ 		} else {
+ 			status.setText("Reconnecting...");
+ 		}
+ 	}
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/EStopListener.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/EStopListener.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/EStopListener.java	Wed Oct  1 22:08:08 2003
***************
*** 0 ****
--- 1,103 ----
+ package org.tekkotsu.mon;
+ 
+ import java.lang.Integer;
+ import java.lang.String;
+ import java.io.PrintStream;
+ import java.io.InputStream;
+ import java.net.Socket;
+ import java.util.Vector;
+ import java.net.SocketException;
+ 
+ public class EStopListener extends TCPListener {
+   // The command output stream
+ 	static int defPort=10053;
+   PrintStream out;
+ 	boolean stopped=true;
+ 	boolean data=false;
+   Socket mysock;
+ 	Vector listeners=new Vector();
+ 	
+ 	public interface UpdatedListener {
+ 		public void estopUpdated(EStopListener mc);
+ 	}
+ 
+ 	void addUpdatedListener(UpdatedListener mcl) { listeners.add(mcl); }
+ 	void removeUpdatedListener(UpdatedListener mcl) {
+ 		listeners.remove(mcl);
+ 		if(listeners.size()==0)
+ 			kill();
+ 	}
+ 	void fireUpdated() {
+ 		data=true;
+ 		for(int i=0;i<listeners.size();i++)
+ 			((UpdatedListener)listeners.get(i)).estopUpdated(this);
+ 	}
+ 
+   // Connect to control socket
+   public void connected(Socket socket) {
+     mysock = socket;
+ 		fireUpdated();
+     try {
+       out = new PrintStream(mysock.getOutputStream());
+ 			out.print("refresh\n");
+ 			InputStream sin=socket.getInputStream();
+ 			while (true) {
+ 				String msgtype=readLine(sin);
+ 				if(!_isConnected) break;
+ 				if(msgtype.equals("on")) {
+ 					if(!stopped) {
+ 						stopped=true;
+ 						fireUpdated();
+ 					}
+ 				} else if(msgtype.equals("off")) {
+ 					if(stopped) {
+ 						stopped=false;
+ 						fireUpdated();
+ 					}
+ 				} else {
+ 					System.out.println("Estop Unknown message: "+msgtype);
+ 				}
+ 			}
+     } catch(Exception e) {if((SocketException)e==null) e.printStackTrace();}
+ 
+ 		try { socket.close(); } catch (Exception ex) { }
+ 
+ 		_isConnected=false;
+ 		fireUpdated();
+ 		//The sleep is to get around the socket still listening after being closed thing
+ 		if(!destroy)
+ 			System.out.println("EStopGUI - connection closed... reconnect after 5 seconds");
+ 		try { Thread.sleep(5000); } catch (Exception ex) {}
+   }
+ 
+   // Disconnect from control socket
+   public void close() {
+ 		//    try { mysock.close(); } catch(Exception e) {}
+     //_isConnected = false;
+     super.close();
+ 		//we'll fire an event to the listeners when the readLine in connected finally fails
+   }
+ 
+ 	public void setEStop(boolean b) {
+ 		if(b!=stopped) {
+ 			out.print(b?"stop\n":"start\n");
+ 		}
+ 	}
+ 
+ 	public boolean getEStop() {
+ 		return stopped;
+ 	}
+ 
+ 	public void toggleEStop() {
+ 		setEStop(!stopped);
+ 	}
+ 
+   // Some state inquiry functions
+   public boolean hasData() { return data; }
+   public boolean isConnected() { return _isConnected; }
+ 
+   // Constructors
+   public EStopListener() { super(); }
+   public EStopListener(int port) { super(port); }
+   public EStopListener(String host, int port) { super(host, port); }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/EStopPanel.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/EStopPanel.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/EStopPanel.java	Fri Sep 26 00:36:19 2003
***************
*** 0 ****
--- 1,192 ----
+ package org.tekkotsu.mon;
+ 
+ import javax.swing.JPanel;
+ import javax.swing.JFrame;
+ import java.awt.event.WindowAdapter;
+ import java.awt.event.WindowEvent;
+ import java.awt.geom.Ellipse2D;
+ import java.awt.geom.Rectangle2D;
+ import java.awt.*;
+ import java.awt.event.MouseEvent;
+ import java.awt.event.InputEvent;
+ 
+ public class EStopPanel extends JPanel implements EStopListener.UpdatedListener {
+ 	EStopListener comm;
+ 	int mode;
+ 	static final int STOPPED_MODE=0;
+ 	static final int NOTSTOPPED_MODE=1;
+ 	static final int DISABLED_MODE=2;
+ 	static final int MAX_MODE=3;
+ 	Shape shape[] = new Shape[MAX_MODE];
+ 	BasicStroke stroke[] = new BasicStroke[MAX_MODE];
+ 	Paint fill[] = new Color[MAX_MODE];
+ 	Paint line[] = new Color[MAX_MODE];
+ 	Paint textFill[] = new Color[MAX_MODE];
+ 	String text[] = new String[MAX_MODE];
+ 	float textSize[] = new float[MAX_MODE];
+ 	static final int res=1000;
+ 	
+ 	static public void main(String s[]) {
+ 		int port=EStopListener.defPort;
+ 		if(s.length<1)
+ 			usage();
+ 		if(s.length>1)
+ 			port=Integer.parseInt(s[1]);
+ 		String[] args=new String[s.length-1];
+ 		for(int i=0; i<s.length-1; i++)
+ 			args[i-1]=s[i];
+ 		JFrame frame=new JFrame("TekkotsuMon: EStop");
+ 		frame.setSize(new Dimension(200, 200)); 
+ 		EStopPanel estop=new EStopPanel(new EStopListener(s[0],port));
+ 		frame.getContentPane().add(estop);
+ 		frame.addWindowListener(new WindowAdapter() {
+ 				public void windowClosing(WindowEvent e) { System.exit(0); } });
+ 		frame.show();
+ 	}
+ 
+ 	public static void usage() {
+ 		System.out.println("Usage: java EStopPanel host [port]");
+ 		System.out.println("			 if port is not specified, it defaults to "+EStopListener.defPort);
+ 		System.exit(2);
+ 	}
+ 
+ 	public EStopPanel(EStopListener comm) {
+ 		super();
+ 		
+ 		this.comm=comm;
+ 		mode=comm.isConnected()?(comm.getEStop()?STOPPED_MODE:NOTSTOPPED_MODE):DISABLED_MODE;
+ 		setEnabled(mode!=DISABLED_MODE);
+ 		comm.addUpdatedListener(this);
+ 		
+ 		shape[NOTSTOPPED_MODE]=makeStopSign();
+ 		stroke[NOTSTOPPED_MODE]=new BasicStroke(res/30);
+ 		fill[NOTSTOPPED_MODE]=Color.RED;
+ 		line[NOTSTOPPED_MODE]=Color.BLACK;
+ 		text[NOTSTOPPED_MODE]="STOP";
+ 		textFill[NOTSTOPPED_MODE]=Color.WHITE;
+ 		textSize[NOTSTOPPED_MODE]=3.125f;
+ 
+ 		shape[STOPPED_MODE]=new Ellipse2D.Float(0,0,res,res);
+ 		stroke[STOPPED_MODE]=new BasicStroke(res/30);
+ 		fill[STOPPED_MODE]=Color.GREEN;
+ 		line[STOPPED_MODE]=Color.BLACK;
+ 		text[STOPPED_MODE]="GO";
+ 		textFill[STOPPED_MODE]=Color.BLACK;
+ 		textSize[STOPPED_MODE]=2.5f;
+ 
+ 		shape[DISABLED_MODE]=new Rectangle2D.Float(res/8,res/8,res*3/4,res*3/4);
+ 		stroke[DISABLED_MODE]=new BasicStroke(0);
+ 		fill[DISABLED_MODE]=null;
+ 		line[DISABLED_MODE]=null;
+ 		text[DISABLED_MODE]="><";
+ 		textFill[DISABLED_MODE]=Color.BLACK;
+ 		textSize[DISABLED_MODE]=1.5f;
+ 		
+ 		setToolTipText("Toggle Emergency Stop; alt-click to open new window");
+ 		enableEvents(AWTEvent.MOUSE_EVENT_MASK);
+ 	}
+ 
+ 	protected Shape makeStopSign() {
+ 		int x[] = new int[10];
+ 		int y[] = new int[10];
+ 		double l=res*Math.tan(22.5/180.0*Math.PI);
+ 		x[0]=res/2;
+ 		y[0]=0;
+ 		x[1]=(int)((res-l)/2+l);
+ 		y[1]=0;
+ 		x[2]=res;
+ 		y[2]=(int)((res-l)/2);
+ 		x[3]=res;
+ 		y[3]=x[1];
+ 		x[4]=x[1];
+ 		y[4]=res;
+ 		x[5]=y[2];
+ 		y[5]=res;
+ 		x[6]=0;
+ 		y[6]=y[3];
+ 		x[7]=0;
+ 		y[7]=y[2];
+ 		x[8]=y[2];
+ 		y[8]=y[0];
+ 		x[9]=x[0];
+ 		y[9]=y[0];
+ 		return new Polygon(x,y,10);
+ 	}
+ 	
+ 	public void close() {
+ 		comm.kill();
+ 		remove();
+ 	}
+ 	
+ 	public void remove() {
+ 		comm.removeUpdatedListener(this);
+ 	}
+ 	
+ 	public void open() {
+ 		comm.addUpdatedListener(this);
+ 		comm.startThread();
+ 	}
+ 
+ 	public void estopUpdated(EStopListener l) {
+ 		if(l.isConnected()) {
+ 			if(l.getEStop())
+ 				mode=STOPPED_MODE;
+ 			else
+ 				mode=NOTSTOPPED_MODE;
+ 		} else
+ 			mode=DISABLED_MODE;
+ 		setEnabled(l.isConnected());
+ 		repaint();
+ 	}
+ 	
+ 	public void processMouseEvent(MouseEvent e) {
+ 		if(e.getID()==MouseEvent.MOUSE_RELEASED) {
+ 			if((e.getModifiersEx()&InputEvent.ALT_DOWN_MASK)!=0) {
+ 				EStopGUI es=new EStopGUI(comm);
+ 			} else {
+ 				if(isEnabled()) {
+ 					comm.toggleEStop();
+ 				} else {
+ 					close();
+ 					open();
+ 				}
+ 			}
+ 		}
+ 		super.processMouseEvent(e);
+ 	}
+ 
+ 	public void paint(Graphics graphics) {
+ 		super.paint(graphics);
+ 		Graphics2D g=(Graphics2D)graphics;
+ 		g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
+ 		int w=getWidth();
+ 		int h=getHeight();
+ 		int cons=w>h?h:w;
+ 		int ex=(w>h?w:h)-cons;
+ 		double scale=cons/(double)(res+stroke[mode].getLineWidth());
+ 		if(w>h)
+ 			g.translate(ex/2.0,0);
+ 		else
+ 			g.translate(0,ex/2.0);
+ 		g.translate(stroke[mode].getLineWidth()/2*scale,stroke[mode].getLineWidth()/2*scale);
+ 		g.scale(scale,scale);
+ 		if(fill[mode]!=null) {
+ 			g.setPaint(fill[mode]);
+ 			g.fill(shape[mode]);
+ 		}
+ 		if(line[mode]!=null) {
+ 			g.setPaint(line[mode]);
+ 			g.setStroke(stroke[mode]);
+ 			g.draw(shape[mode]);
+ 		}
+ 		if(textFill[mode]!=null && cons/textSize[mode]>7) {
+ 			g.setPaint(textFill[mode]);
+ 			g.setFont(new Font("Arial",Font.BOLD,(int)(res/textSize[mode])));
+ 			FontMetrics fm=g.getFontMetrics();
+ 			float fw=(float)fm.getStringBounds(text[mode],g).getWidth();
+ 			float fa=fm.getLineMetrics(text[mode],g).getAscent();
+ 			float fd=fm.getLineMetrics(text[mode],g).getDescent();
+ 			g.drawString(text[mode],(res-fw)/2.0f,(res-fd+fa)/2.0f);
+ 		}
+ 	}
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/EditScriptGUI.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/EditScriptGUI.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/EditScriptGUI.java	Fri Sep 26 00:36:19 2003
***************
*** 0 ****
--- 1,182 ----
+ package org.tekkotsu.mon;
+ 
+ import java.awt.*;
+ import java.awt.event.*;
+ import javax.swing.*;
+ import javax.swing.event.*;
+ import java.beans.*;
+ import java.util.*;
+ import java.util.prefs.Preferences;
+ 
+ //Admittedly a little sloppy, but I don't want to spend forever on this...
+ 
+ public class EditScriptGUI extends JFrame implements ActionListener, ListDataListener /*ComponentListener*/ {
+ 	DefaultListModel list;
+ 	int scriptIndex;
+ 	ScriptEntry script;
+ 	static Preferences prefs = Preferences.userNodeForPackage(WalkGUI.class);
+ 	int height=0;
+ 	JTextField title;
+ 	JTextArea command;
+ 	JButton upBut;
+ 	JButton downBut;
+ 	boolean deleteOnCancel;
+ 
+ 	public EditScriptGUI(DefaultListModel list, int scriptIndex, boolean deleteOnCancel) {
+ 		super("TekkotsuMon: Edit Script");
+ 		this.scriptIndex=scriptIndex;
+ 		this.list=list;
+ 		this.deleteOnCancel=deleteOnCancel;
+ 		list.addListDataListener(this);
+ 		script=(ScriptEntry)list.get(scriptIndex);
+ 		title.setText(script.title);
+ 		command.setText(script.cmd);
+ 		checkMoveButtons();
+ 		pack();
+ 		setLocation(prefs.getInt("EditScriptGUI.location.x",50),prefs.getInt("EditScriptGUI.location.y",50));
+ 		show();
+ 		height=getBounds().height;
+ 		title.setMaximumSize(new Dimension(Integer.MAX_VALUE,title.getSize().height));
+ //		titleLabel.setMaximumSize(new Dimension(Integer.MAX_VALUE,titleLabel.getSize().height));
+ 	}
+ 	
+ 	public void checkMoveButtons() {
+ 		scriptIndex=list.indexOf(script);
+ 		upBut.setEnabled((scriptIndex!=0));
+ 		downBut.setEnabled((scriptIndex!=list.getSize()-1));
+ 	}
+ 
+ 	public void frameInit() {
+ 		super.frameInit();
+ 
+ 		int strutsize=10;
+ 		int sepsize=5;
+ 		getContentPane().setLayout(new BorderLayout());
+ 		getContentPane().add(Box.createHorizontalStrut(strutsize),BorderLayout.EAST);
+ 		getContentPane().add(Box.createHorizontalStrut(strutsize),BorderLayout.WEST);
+ 		getContentPane().add(Box.createVerticalStrut(strutsize),BorderLayout.NORTH);
+ 		getContentPane().add(Box.createVerticalStrut(strutsize),BorderLayout.SOUTH);
+ 		
+ 		{
+ 			Box tmp = Box.createVerticalBox();
+ 			{
+ 				Box tmp2=Box.createHorizontalBox();
+ 				JLabel titleLabel=new JLabel("Title: ");
+ 				tmp2.add(titleLabel);
+ 				tmp2.add(title=new JTextField());
+ 				tmp.add(tmp2);
+ 			}
+ 			tmp.add(Box.createVerticalStrut(strutsize));
+ 			{
+ 				Box tmp2=Box.createHorizontalBox();
+ 				JLabel cmdLabel=new JLabel("Commands: ");
+ 				tmp2.add(cmdLabel);
+ 				command=new JTextArea();
+ 				command.setLineWrap(true);
+ 				command.setWrapStyleWord(true); 
+ 				command.setColumns(30);
+ 				command.setRows(6);
+ 				{
+ 					JScrollPane tmp3=new JScrollPane(command);
+ 					tmp2.add(tmp3);
+ 				}
+ 				tmp.add(tmp2);
+ 			}
+ 			tmp.add(Box.createVerticalStrut(strutsize));
+ 			{
+ 				Box tmp2=Box.createHorizontalBox();
+ 				JButton but;
+ 				tmp2.add(but=upBut=new JButton("Move Up"));
+ 				but.setActionCommand("up");
+ 				but.addActionListener(this);
+ 				tmp2.add(Box.createHorizontalStrut(strutsize));
+ 				tmp2.add(but=downBut=new JButton("Move Down"));
+ 				but.setActionCommand("down");
+ 				but.addActionListener(this);
+ 				tmp2.add(Box.createHorizontalStrut(strutsize));
+ 				tmp2.add(Box.createHorizontalGlue());
+ 				tmp2.add(but=new JButton("Cancel"));
+ 				but.setActionCommand("cancel");
+ 				but.addActionListener(this);
+ 				tmp2.add(Box.createHorizontalStrut(strutsize));
+ 				tmp2.add(but=new JButton("OK"));
+ 				but.setActionCommand("ok");
+ 				but.addActionListener(this);
+ 				tmp.add(tmp2);
+ 			}
+ 			getContentPane().add(tmp,BorderLayout.CENTER);
+ 		}
+ 		setResizable(false);
+ 		
+ //		addComponentListener(this);
+ 		addWindowListener(new CloseEditScriptGUIAdapter(this));
+ 	}
+ 
+ 	public void actionPerformed(ActionEvent e) {
+ 		if(e.getActionCommand().equals("ok")) {
+ 			if(title.getText().equals("")) {
+ 				int result=JOptionPane.showConfirmDialog(this,"An empty title will delete the script.  Continue?","Warning: Really Delete?",JOptionPane.OK_CANCEL_OPTION,JOptionPane.WARNING_MESSAGE);
+ 				if(result==JOptionPane.CANCEL_OPTION)
+ 					return;
+ 				list.remove(scriptIndex);
+ 			} else {
+ 				script.title=title.getText();
+ 				script.cmd=command.getText();
+ 				list.add(scriptIndex,list.remove(scriptIndex));
+ 			}
+ 			close();
+ 		} else if(e.getActionCommand().equals("cancel")) {
+ 			if(deleteOnCancel)
+ 				list.remove(scriptIndex);
+ 			close();
+ 		} else if(e.getActionCommand().equals("up")) {
+ 			list.add(scriptIndex,list.remove(scriptIndex-1));
+ 		} else if(e.getActionCommand().equals("down")) {
+ 			list.add(scriptIndex,list.remove(scriptIndex+1));
+ 		} else {
+ 			System.out.println("EditScriptGUI: Unknown action event");
+ 		}
+ 	}
+ 
+ 	public void close() {
+ 		prefs.putInt("EditScriptGUI.location.x",getLocation().x+getInsets().left);
+ 		prefs.putInt("EditScriptGUI.location.y",getLocation().y+getInsets().top);
+ 		dispose();
+ 	}
+ 
+ /*	public void componentResized(ComponentEvent e) {
+ 		if (e.getID()==ComponentEvent.COMPONENT_RESIZED) {
+ //			if(height!=0)
+ //				setBounds(getBounds().x,getBounds().y,getBounds().width,height);
+ 			System.out.println(getInsets());
+ 			System.out.println(getBounds());
+ 		}
+ 	}
+ 	public void componentHidden(ComponentEvent e) { }
+ 	public void componentMoved(ComponentEvent e) { }
+ 	public void componentShown(ComponentEvent e) { }
+ */	
+ 	
+ 	public void contentsChanged(ListDataEvent e) {checkMoveButtons(); }
+ 	public void intervalAdded(ListDataEvent e) {checkMoveButtons(); }
+ 	public void intervalRemoved(ListDataEvent e) {checkMoveButtons(); }
+ 
+ 	class CloseEditScriptGUIAdapter extends WindowAdapter {
+ 		EditScriptGUI gui;
+ 		CloseEditScriptGUIAdapter(EditScriptGUI gui) {this.gui=gui;}
+ 		public void windowClosing(WindowEvent e) {
+ 			gui.close();
+ 		}
+ 	}
+ 
+ 	static public void main(String s[]) {
+ 		DefaultListModel list=new DefaultListModel();
+ 		list.addElement(new ScriptEntry("test","blah blah blah"));
+ 		list.addElement(new ScriptEntry("test2","blah blah blah"));
+ 		list.addElement(new ScriptEntry("test3","blah blah blah"));
+ 		list.addElement(new ScriptEntry("test4","blah blah blah"));
+ 		EditScriptGUI gui=new EditScriptGUI(list,0,true);
+ 		gui.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } 	});
+ 	}
+ }
+ 
Index: AiboPup/tools/mon/org/tekkotsu/mon/GraphCanvas.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/GraphCanvas.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/GraphCanvas.java	Fri Sep 26 00:36:19 2003
***************
*** 0 ****
--- 1,52 ----
+ package org.tekkotsu.mon;
+ 
+ import java.awt.*;
+ import java.awt.event.*;
+ import java.util.*;
+ import java.lang.*;
+ 
+ public class GraphCanvas extends Canvas {
+   float ymin, ymax, yrange;
+   int lastval;
+   LinkedList valQueue=new LinkedList();
+ 
+   public GraphCanvas (float ymin, float ymax) {
+     super();
+ 
+     this.ymin=ymin;
+     this.ymax=ymax;
+     this.yrange=ymax-ymin;
+     lastval=0;
+ 
+     setBackground(Color.black);
+   }
+ 
+   public void registerValue(float yval) {
+     valQueue.add(new Float(yval));
+     repaint();
+   }
+ 
+   public void paint(Graphics g) {
+     update(g);
+   }
+ 
+   public void update(Graphics g) {
+     if (valQueue.isEmpty()) return;
+     Dimension d=getSize();
+ 
+     g.setColor(Color.red);
+     int numadded=valQueue.size();
+     int xstart=d.width-numadded;
+     g.copyArea(numadded,0,xstart,d.height,-numadded,0);
+     g.clearRect(xstart,0,numadded,d.height);
+     for (int i=0; i<numadded; i++) {
+       float val=((Float)valQueue.removeFirst()).floatValue();
+       val=val-ymin;
+       val=val/yrange;
+       if (val<0.0f || val>1.0f) continue;
+       int pos=(int)(d.height*val); 
+       g.drawLine(xstart+i, lastval, xstart+i+1, pos);
+       lastval=pos;
+     }
+   }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/HeadPointGUI.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/HeadPointGUI.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/HeadPointGUI.java	Fri Sep 26 00:36:19 2003
***************
*** 0 ****
--- 1,342 ----
+ package org.tekkotsu.mon;
+ 
+ import javax.swing.*;
+ import java.awt.*;
+ import java.awt.geom.*;
+ import java.awt.event.*;
+ import javax.swing.event.*;
+ import java.util.prefs.Preferences;
+ 
+ public class HeadPointGUI extends JFrame implements PointPick.PointPickedListener, ChangeListener, ActionListener, MouseListener, HeadPointListener.HeadPointUpdatedListener {
+ 	static int defPort=10052;
+ 	PointPick pp;
+ 	JSlider tslide;
+ 	JSlider pslide;
+ 	JSlider rslide;
+ 	JButton stopBut;
+ 	JRadioButton horizRollBut;
+ 	JRadioButton horizPanBut;
+ 	boolean horizButFake=false;
+ 	JCheckBox resetOnRelease;
+ 	JLabel status;
+ 	JButton reconnectBut;
+ 	HeadPointListener comm;
+ 	static int slidermax=10000;
+ 	final static ImageIcon carrows = new ImageIcon("images/chasingarrows.png");
+ 	static Preferences prefs = Preferences.userNodeForPackage(HeadPointGUI.class);
+ 
+ 	static public void main(String s[]) {
+ 		int port=defPort;
+ 		if(s.length<1)
+ 			usage();
+ 		if(s.length>1)
+ 			port=Integer.parseInt(s[1]);
+ 		String[] args=new String[s.length-1];
+ 		for(int i=0; i<s.length-1; i++)
+ 			args[i-1]=s[i];
+ 		JFrame frame=new HeadPointGUI(s[0],port,args);
+ 		/*		frame.addWindowListener(new WindowAdapter() {
+ 			public void windowClosing(WindowEvent e) { System.exit(0); }
+ 			});*/
+ 	}
+ 	
+ 	public static void usage() {
+ 		System.out.println("Usage: java HeadPointGUI host [port]");
+ 		System.out.println("       if port is not specified, it defaults to: "+defPort);
+ 		System.exit(2);
+ 	}
+ 		
+ 	public HeadPointGUI(String host, int port, String args[]) {
+ 		super("TekkotsuMon: Head Pointer Control");
+ 		pack();
+ 		comm=new HeadPointListener(host,port);
+ 		comm.addHeadPointUpdatedListener(this);
+ 		int offx=getGraphicsConfiguration().getBounds().x;
+ 		int offy=getGraphicsConfiguration().getBounds().y;
+ 		setLocation(prefs.getInt("HeadPointGUI.location.x",50),prefs.getInt("HeadPointGUI.location.y",50));
+ 		show();
+ 	}
+ 
+ 	public void close() {
+ 		prefs.putInt("HeadPointGUI.location.x",getLocation().x+getInsets().left);
+ 		prefs.putInt("HeadPointGUI.location.y",getLocation().y+getInsets().top);
+ 		comm.kill();
+ 		dispose();
+ 	}
+ 	
+ 	class CloseHeadPointAdapter extends WindowAdapter {
+ 		HeadPointGUI gui;
+ 		CloseHeadPointAdapter(HeadPointGUI gui) {this.gui=gui;}
+ 		public void windowClosing(WindowEvent e) {
+ 			gui.close();
+ 		}
+ 	}
+ 
+ 	public void pointPicked(Point2D.Float p, MouseEvent e, PointPick pp) {
+ 		boolean isBut2=(e.getModifiersEx()&MouseEvent.BUTTON3_DOWN_MASK)==MouseEvent.BUTTON3_DOWN_MASK;
+ 		if(!horizButFake && isBut2) {
+ 			if(horizPanBut.isSelected())
+ 				horizRollBut.setSelected(true);
+ 			else
+ 				horizPanBut.setSelected(true);
+ 			horizButFake=isBut2;
+ 		}
+ 		if(horizRollBut.isSelected())
+ 			rslide.setValue((int)(slidermax*p.x));
+ 		if(horizPanBut.isSelected())
+ 			pslide.setValue((int)(slidermax*p.x));
+ 		tslide.setValue((int)(slidermax*p.y));
+ 	}
+ 
+ 	public void headPointUpdated(HeadPointListener comm) {
+ 		if(status!=null) {
+ 			pp.setEnabled(comm._isConnected);
+ 			tslide.setEnabled(comm._isConnected);
+ 			pslide.setEnabled(comm._isConnected);
+ 			rslide.setEnabled(comm._isConnected);
+ 			stopBut.setEnabled(comm._isConnected);
+ 			if(comm._isConnected)
+ 				status.setText("Connected.");
+ 			else
+ 				status.setText("Reconnecting...");
+ 		}
+ 	}
+ 
+ 	public void mouseClicked(MouseEvent e) {}
+ 	public void mouseEntered(MouseEvent e) {}
+ 	public void mouseExited(MouseEvent e) {}
+ 	public void mousePressed(MouseEvent e) {
+ 		boolean isBut2=(e.getModifiersEx()&MouseEvent.BUTTON3_DOWN_MASK)==MouseEvent.BUTTON3_DOWN_MASK;
+ 		if(!horizButFake && isBut2) {
+ 			if(horizPanBut.isSelected())
+ 				horizRollBut.setSelected(true);
+ 			else
+ 				horizPanBut.setSelected(true);
+ 			horizButFake=isBut2;
+ 			updatePP();
+ 		}
+ 	}
+ 	public void mouseReleased(MouseEvent e) {
+ 		boolean isBut1=(e.getModifiersEx()&MouseEvent.BUTTON1_DOWN_MASK)==MouseEvent.BUTTON1_DOWN_MASK;
+ 		boolean isBut2=(e.getModifiersEx()&MouseEvent.BUTTON3_DOWN_MASK)==MouseEvent.BUTTON3_DOWN_MASK;
+ 		if(horizButFake && !isBut2) {
+ 			if(horizPanBut.isSelected())
+ 				horizRollBut.setSelected(true);
+ 			else
+ 				horizPanBut.setSelected(true);
+ 			horizButFake=isBut2;
+ 			updatePP();
+ 		}
+ 		if(!isBut1 && !isBut2) {
+ 			if(resetOnRelease.isSelected())
+ 				stopBut.doClick();
+ 		}
+ 	}
+ 
+ 	public void stateChanged(ChangeEvent e) {
+ 		if(e.getSource()==tslide) {
+ 			comm.sendCommand("t",tslide.getValue()/(float)slidermax);
+ 			pp.doSetPoint(pp.getXValue(),tslide.getValue()/(float)slidermax);
+ 		} else if(e.getSource()==pslide) {
+ 			comm.sendCommand("p",-pslide.getValue()/(float)slidermax);
+ 			if(horizPanBut.isSelected())
+ 				pp.doSetPoint(pslide.getValue()/(float)slidermax,pp.getYValue());
+ 		} else if(e.getSource()==rslide) {
+ 			// Rotation is both fast and sensitive, so we'll exponentiate it to
+ 			// drag out the low end without sacrificing the high end
+ 			comm.sendCommand("r",rslide.getValue()/(float)slidermax);
+ 			float tmp=pp.getYValue();
+ 			if(horizRollBut.isSelected())
+ 				pp.doSetPoint(rslide.getValue()/(float)slidermax,pp.getYValue());
+ 		}
+ 	}
+ 
+ 	public void actionPerformed(ActionEvent e) {
+ 		if(e.getSource()==stopBut) {
+ 			tslide.setValue(0);
+ 			pslide.setValue(0);
+ 			rslide.setValue(0);
+ 		} else if(e.getSource()==horizRollBut) {
+ 			updatePP();
+ 		} else if(e.getSource()==horizPanBut) {
+ 			updatePP();
+ 		} else if(e.getSource()==reconnectBut) {
+ 			int port=comm._port;
+ 			String addr=comm._host;
+ 			comm.kill();
+ 			comm.removeHeadPointUpdatedListener(this);
+ 			comm = new HeadPointListener(comm._host,comm._port);
+ 			comm.addHeadPointUpdatedListener(this);
+ 		}
+ 	}
+ 	
+ 	public void updatePP() {
+ 		float x=0;
+ 		if(horizPanBut.isSelected())
+ 			x=pslide.getValue()/(float)slidermax;
+ 		else if(horizRollBut.isSelected())
+ 			x=rslide.getValue()/(float)slidermax;
+ 		pp.doSetPoint(x,tslide.getValue()/(float)slidermax);
+ 	}
+ 
+ 	public void frameInit() {
+ 		super.frameInit();
+ 		
+ 		int strutsize=10;
+ 		int sepsize=5;
+ 		getContentPane().setLayout(new BorderLayout());
+ 		getContentPane().add(Box.createHorizontalStrut(strutsize),BorderLayout.EAST);
+ 		getContentPane().add(Box.createHorizontalStrut(strutsize),BorderLayout.WEST);
+ 		getContentPane().add(Box.createVerticalStrut(strutsize),BorderLayout.NORTH);
+ 		JPanel p=new JPanel(new SquareRightLayout());
+ 		p.setLayout(new SquareRightLayout());
+ 		pp=new PointPick(false);
+ 		pp.addPointPickedListener(this);
+ 		pp.addMouseListener(this);
+ 		p.add(pp,SquareRightLayout.SQUARE);
+ 		Box tmp=Box.createHorizontalBox();
+ 		tmp.add(Box.createHorizontalStrut(strutsize));
+ 		JSeparator sep;
+ 		sep=new JSeparator(SwingConstants.VERTICAL);
+ 		sep.setMaximumSize(new Dimension(sepsize,slidermax));
+ 		tmp.add(sep);
+ 		tmp.add(Box.createHorizontalStrut(strutsize));
+ 		{
+ 			Box tmp2=Box.createVerticalBox();
+ 			tmp2.add(Box.createVerticalGlue());
+ 			int labwidth=45;
+ 			tmp2.add(new JLabel("Tilt:"));
+ 			{
+ 				Box tmp3=Box.createHorizontalBox();
+ 				tslide=new JSlider(-slidermax,slidermax,0);
+ 				tslide.addChangeListener(this);
+ 				JLabel lab;
+ 				lab=new JLabel("Down");
+ 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
+ 				lab.setHorizontalAlignment(SwingConstants.RIGHT);
+ 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
+ 				tmp3.add(lab);
+ 				tmp3.add(tslide);
+ 				lab=new JLabel("Up");
+ 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
+ 				lab.setHorizontalAlignment(SwingConstants.LEFT);
+ 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
+ 				tmp3.add(lab);
+ 				//tmp3.add(new JButton("Zero"));
+ 				tmp3.setAlignmentX(0);
+ 				tmp2.add(tmp3);
+ 			}
+ 			tmp2.add(Box.createVerticalStrut(strutsize));
+ 			tmp2.add(new JLabel("Pan:"));
+ 			{
+ 				Box tmp3=Box.createHorizontalBox();
+ 				pslide=new JSlider(-slidermax,slidermax,0);
+ 				pslide.addChangeListener(this);
+ 				JLabel lab;
+ 				lab=new JLabel("Left");
+ 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
+ 				lab.setHorizontalAlignment(SwingConstants.RIGHT);
+ 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
+ 				tmp3.add(lab);
+ 				tmp3.add(pslide);
+ 				lab=new JLabel("Right");
+ 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
+ 				lab.setHorizontalAlignment(SwingConstants.LEFT);
+ 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
+ 				tmp3.add(lab);
+ 				//tmp3.add(new JButton("Zero"));
+ 				tmp3.setAlignmentX(0);
+ 				tmp2.add(tmp3);
+ 			}
+ 			tmp2.add(Box.createVerticalStrut(strutsize));
+ 			tmp2.add(new JLabel("Roll:"));
+ 			{
+ 				Box tmp3=Box.createHorizontalBox();
+ 				rslide=new JSlider(-slidermax,slidermax,0);
+ 				rslide.addChangeListener(this);
+ 				JLabel lab;
+ 				lab=new JLabel("Counter");
+ 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
+ 				lab.setHorizontalAlignment(SwingConstants.RIGHT);
+ 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
+ 				tmp3.add(lab);
+ 				tmp3.add(rslide);
+ 				lab=new JLabel("Clock");
+ 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
+ 				lab.setHorizontalAlignment(SwingConstants.LEFT);
+ 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
+ 				tmp3.add(lab);
+ 				//tmp3.add(new JButton("Zero"));
+ 				tmp3.setAlignmentX(0);
+ 				tmp2.add(tmp3);
+ 			}
+ 			tmp2.add(Box.createVerticalStrut(strutsize));
+ 			{
+ 				Box tmp3=Box.createHorizontalBox();
+ 				tmp3.add(Box.createHorizontalGlue());
+ 				stopBut=new JButton("Center");
+ 				stopBut.addActionListener(this);
+ 				rootPane.setDefaultButton(stopBut);
+ 				tmp3.add(stopBut);
+ 				tmp3.add(Box.createHorizontalGlue());
+ 				tmp3.setAlignmentX(0);
+ 				tmp2.add(tmp3);
+ 			}
+ 			tmp2.add(Box.createVerticalStrut(strutsize));
+ 			ButtonGroup bg = new ButtonGroup();
+ 			horizPanBut=new JRadioButton("Horizontal is Pan");
+ 			horizPanBut.addActionListener(this);
+ 			horizPanBut.setSelected(true);
+ 			bg.add(horizPanBut);
+ 			tmp2.add(horizPanBut);
+ 			horizRollBut=new JRadioButton("Horizontal is Roll");
+ 			horizRollBut.addActionListener(this);
+ 			bg.add(horizRollBut);
+ 			tmp2.add(horizRollBut);
+ 			tmp2.add(Box.createVerticalStrut(strutsize));
+ 			tmp2.add(resetOnRelease=new JCheckBox("Center on release")); 
+ 			tmp2.add(Box.createVerticalGlue());
+ 			tmp.add(tmp2);
+ //			Dimension d=tmp2.getMinimumSize();
+ //			System.out.println(d);
+ //			pp.setSize(d);
+ //			pp.setMinimumSize(d);
+ //			pp.setPreferredSize(d);
+ //			pp.setMaximumSize(d);
+ 		}
+ 		p.add(tmp,SquareRightLayout.RIGHT);
+ 		getContentPane().add(p,BorderLayout.CENTER);
+ 		{
+ 			Box tmp2=Box.createHorizontalBox();
+ 			tmp2.add(Box.createHorizontalStrut(strutsize));
+ 			{
+ 				Box tmp3=Box.createVerticalBox();
+ 				tmp3.add(Box.createVerticalStrut(strutsize));
+ 				tmp3.add(new JSeparator());
+ 				tmp3.add(Box.createVerticalStrut(strutsize-sepsize));
+ 				{
+ 					Box tmp4=Box.createHorizontalBox();
+ 					tmp4.add(status=new JLabel("Connecting..."));
+ 					tmp4.add(Box.createHorizontalGlue());
+ 					reconnectBut=new JButton(carrows);
+ 					reconnectBut.setPreferredSize(new Dimension(carrows.getIconWidth(),carrows.getIconHeight()));
+ 					reconnectBut.addActionListener(this);
+ 					reconnectBut.setToolTipText("Drop current connection and try again.");
+ 					tmp4.add(reconnectBut);
+ 					tmp3.add(tmp4);
+ 				}
+ 				tmp3.add(Box.createVerticalStrut(strutsize));
+ 				tmp2.add(tmp3);
+ 			}
+ 			tmp2.add(Box.createHorizontalStrut(strutsize));
+ 			getContentPane().add(tmp2,BorderLayout.SOUTH);
+ 		}
+ 
+ 		pp.setEnabled(false);
+ 		tslide.setEnabled(false);
+ 		pslide.setEnabled(false);
+ 		rslide.setEnabled(false);
+ 		stopBut.setEnabled(false);
+ 		addWindowListener(new CloseHeadPointAdapter(this));
+ 	}
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/HeadPointListener.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/HeadPointListener.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/HeadPointListener.java	Wed Oct  1 22:08:08 2003
***************
*** 0 ****
--- 1,116 ----
+ package org.tekkotsu.mon;
+ 
+ // Sends "HeadPoint" command data from TekkotsuMon to the AIBO.
+ import java.lang.Integer;
+ import java.lang.String;
+ import java.lang.System;
+ import java.io.OutputStream;
+ import java.io.InputStream;
+ import java.net.Socket;
+ import javax.swing.Timer;
+ import java.awt.event.ActionEvent;
+ import java.awt.event.ActionListener;
+ import java.util.Vector;
+ import java.net.SocketException;
+ 
+ // The class itself. Brilliant that even though it does the talking,
+ // it extends TCP*Listener*.
+ public class HeadPointListener extends TCPListener implements ActionListener {
+   // The command output stream
+   OutputStream out;
+   Socket mysock;
+ 	double tilt=0;
+ 	double pan=0;
+ 	double roll=0;
+ 	Vector listeners=new Vector();
+ 	
+ 	public interface HeadPointUpdatedListener {
+ 		public void headPointUpdated(HeadPointListener mc);
+ 	}
+ 
+ 	void addHeadPointUpdatedListener(HeadPointUpdatedListener mcl) { listeners.add(mcl); }
+ 	void removeHeadPointUpdatedListener(HeadPointUpdatedListener mcl) { listeners.remove(mcl); }
+ 	void fireHeadPointUpdated() {
+ 		for(int i=0;i<listeners.size();i++)
+ 			((HeadPointUpdatedListener)listeners.get(i)).headPointUpdated(this);
+ 	}
+ 
+   // Connect to control socket
+   public void connected(Socket socket) {
+     mysock = socket;
+ 		fireHeadPointUpdated();
+     try {
+       out = mysock.getOutputStream();
+ 			InputStream sin=socket.getInputStream();
+ 			while (true) { //not that we expect input, but will block until the socket is closed
+ 				String msgtype=readLine(sin);
+ 				if(!_isConnected) break;
+ 			}
+     } catch(Exception e) {if((SocketException)e==null) e.printStackTrace();}
+ 
+ 		try { socket.close(); } catch (Exception ex) { }
+ 
+ 		_isConnected=false;
+ 		fireHeadPointUpdated();
+ 		//The sleep is to get around the socket still listening after being closed thing
+ 		if(!destroy)
+ 			System.out.println("HeadPoint - connection closed... reconnect after 5 seconds");
+ 		try { Thread.sleep(5000); } catch (Exception ex) {}
+   }
+ 
+   // Disconnect from control socket
+   public void close() {
+ 		//    try { mysock.close(); } catch(Exception e) {}
+     //_isConnected = false;
+     super.close();
+ 		//we'll fire an event to the listeners when the readLine in connected finally fails
+   }
+ 
+ 	public void actionPerformed(ActionEvent e) {
+ 		if(_isConnected) {
+ 			sendCommand("t",tilt);
+ 			sendCommand("p",pan);
+ 			sendCommand("r",roll);
+ 		}
+ 	}
+ 
+   // Send a headPoint command
+   public void sendCommand(String command, double param) {
+ 		
+     // Extract command byte
+     byte cmdbytes[] = command.getBytes();
+ 		if(cmdbytes[0]=='t')
+ 			tilt=param;
+ 		else if(cmdbytes[0]=='p')
+ 			pan=param;
+ 		else if(cmdbytes[0]=='r')
+ 			roll=param;
+ 
+     // Construct the command sequence
+     byte sequence[] = new byte[5];
+     // The commmand byte is the first byte in cmdbytes. The remaining
+     // four bytes belong to the parameter. We have to convert the parameter
+     // (which we send as a float, not a double) to MIPS byte order thanks to
+     // (ahem) prior design decisions.
+     sequence[0] = cmdbytes[0];
+     int pbits = Float.floatToIntBits((float) param);
+     Integer i;
+     i = new Integer((pbits >> 24) & 0xff); sequence[4] = i.byteValue();
+     i = new Integer((pbits >> 16) & 0xff); sequence[3] = i.byteValue();
+     i = new Integer((pbits >>  8) & 0xff); sequence[2] = i.byteValue();
+     i = new Integer(pbits & 0xff);	   sequence[1] = i.byteValue();
+     // Now write the whole command.
+     try {
+       out.write(sequence, 0, 5);
+     } catch(Exception e) { close(); return; }
+   }
+ 
+   // Some state inquiry functions
+   public boolean hasData() { return false; }
+   public boolean isConnected() { return _isConnected; }
+ 
+   // Constructors
+   public HeadPointListener() { super(); }
+   public HeadPointListener(int port) { super(port); }
+   public HeadPointListener(String host, int port) { super(host, port); }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/ImageSequenceWriterThread.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/ImageSequenceWriterThread.java:1.3
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/ImageSequenceWriterThread.java	Wed Oct  8 14:26:40 2003
***************
*** 0 ****
--- 1,153 ----
+ package org.tekkotsu.mon;
+ 
+ import java.awt.event.*;
+ import javax.swing.*;
+ import java.lang.String;
+ import java.util.LinkedList;
+ import java.awt.*;
+ import javax.imageio.ImageIO;
+ import java.awt.image.BufferedImage;
+ import java.awt.image.IndexColorModel;
+ import java.awt.image.DataBuffer;
+ import java.util.Date;
+ import java.io.PrintWriter;
+ import java.io.FileOutputStream;
+ 
+ public class ImageSequenceWriterThread extends Thread implements VisionUpdatedListener {
+ 	String dir;
+ 	String pre;
+ 	String post;
+ 	String fmt;
+ 	LinkedList imgBufs=new LinkedList();
+ 	int dig;
+ 	LinkedList q=new LinkedList();
+ 	int count=0;
+ 	VisionListener listen;
+ 	boolean stopping=false;
+ 	JButton but;
+ 
+ 	public ImageSequenceWriterThread(VisionListener l, JButton reenableBut) {
+ 		super("ImageSequenceWriter");
+ 		int initbufsize=250;
+ 		but=reenableBut;
+ 		listen=l;
+ 		l.addListener(this);
+ 		BufferedImage i=l.getImage();
+ 		if(i.getColorModel().getTransferType()!=DataBuffer.TYPE_BYTE)
+ 			for(int j=0;j<initbufsize;j++)
+ 				imgBufs.add(new BufferedImage(i.getWidth(),i.getHeight(),i.getType()));
+ 		else {
+ 			for(int j=0;j<initbufsize;j++)
+ 				imgBufs.add(new BufferedImage(i.getWidth(),i.getHeight(),i.getType(),(IndexColorModel)i.getColorModel()));
+ 		}
+ 	}
+ 
+ 	public void setDirectory(String directory) {
+ 		dir=directory;
+ 		if(dir.charAt(dir.length()-1)!='/')
+ 			dir+='/';
+ 	}
+ 
+ 	public void setName(String prepend, int digits, String append, String format) {
+ 		pre=prepend;
+ 		post=append;
+ 		fmt=format;
+ 		dig=digits;
+ 	}
+ 
+ 	public void visionUpdated(VisionListener l) {
+ 		push(l.getImage(),l.getTimeStamp());
+ 	}
+ 
+ 	public void push(BufferedImage i, Date t) {
+ 		BufferedImage i2;
+ 		if(imgBufs.size()>0)
+ 			i2=(BufferedImage)imgBufs.removeFirst();
+ 		else {
+ 			if(i.getColorModel().getTransferType()!=BufferedImage.TYPE_BYTE_INDEXED)
+ 				i2=new BufferedImage(i.getWidth(),i.getHeight(),i.getType());
+ 			else
+ 				i2=new BufferedImage(i.getWidth(),i.getHeight(),i.getType(),(IndexColorModel)i.getColorModel());
+ 		}
+ 		i.copyData(i2.getRaster());
+ 		synchronized(q) {
+ 			q.addLast(i2);
+ 			q.addLast(t);
+ 		}
+ 	}
+ 
+ 	public void run() {
+ 		String tmp=null;
+ 		PrintWriter log=null;
+ 		if(dig>0) {
+ 			try {
+ 				log=new PrintWriter(new FileOutputStream(dir+pre+post+".txt"));
+ 			} catch(Exception ex) { ex.printStackTrace(); return; }
+ 		}
+ 		Date start=null;
+ 		try {
+ 			while(true) {
+ 				while(q.size()>0) {
+ 					if(interrupted()) {
+ 						if(!stopping) {
+ 							stopping=true;
+ 							if(but!=null) {
+ 								but.setEnabled(false);
+ 								tmp=but.getText();
+ 								but.setText("Writing...");
+ 							}
+ 							listen.removeListener(this);
+ 						} else { //second interrupt... die!
+ 							break;
+ 						}
+ 					}
+ 					BufferedImage i;
+ 					Date t;
+ 					synchronized(q) {
+ 						i=(BufferedImage)q.removeFirst();
+ 						t=(Date)q.removeFirst();
+ 					}
+ 					if(start==null)
+ 						start=t;
+ 					long dt=t.getTime()-start.getTime();
+ 					String name=getFileName(dt);
+ 					if(log!=null)
+ 						log.println(name+"\t"+dt);
+ 					ImageIO.write(i,fmt,new FileOutputStream(dir+name));
+ 					imgBufs.addLast(i);
+ 					count++;
+ 				}
+ 				if(stopping)
+ 					break;
+ 				sleep(1000/25);
+ 			}
+ 		} catch(Exception ex) {
+ 			listen.removeListener(this);
+ 			if((InterruptedException)ex==null)
+ 				ex.printStackTrace();
+ 		}
+ 		if(log!=null)
+ 			log.close();
+ 		if(but!=null && tmp!=null) {
+ 			but.setEnabled(true);
+ 			if(but.getText().compareTo("Writing...")==0)
+ 				but.setText(tmp);
+ 		}
+ 	}
+ 
+ 	protected String getFileName(long dt) {
+ 		String ans=pre;
+ 		long c=count;
+ 		int digits=dig;
+ 		if(digits==0) {
+ 			c=dt;
+ 			digits=6;
+ 		}
+ 		for(int s=(int)Math.pow(10,digits-1); s>=1; s/=10) {
+ 			ans+=c/s;
+ 			c-=(c/s)*s;
+ 		}
+ 		ans+=post+"."+fmt;
+ 		return ans;
+ 	}
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/Joints.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/Joints.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/Joints.java	Fri Sep 26 00:36:19 2003
***************
*** 0 ****
--- 1,45 ----
+ package org.tekkotsu.mon;
+ 
+ public class Joints {
+   public float[] positions;
+   public float[] duties;
+   public float[] sensors;
+   public float[] buttons;
+   int timestamp;
+ 
+   Joints() {
+     positions=new float[18];
+     duties=new float[18];
+     sensors=new float[6];
+     buttons=new float[8];
+   } 
+ 
+   public String toString() {
+     return positionsString()+dutiesString()+sensorsString()+buttonsString();
+   }
+ 
+   public String positionsString() {
+     String ret="";
+     for (int i=0; i<18; i++) ret+=positions[i]+" ";
+     return ret+"\n";
+   }
+ 
+   public String dutiesString() {
+     String ret="";
+     for (int i=0; i<18; i++) ret+=duties[i]+" ";
+     return ret+"\n";
+   }
+ 
+   public String sensorsString() {
+     String ret="";
+     for (int i=0; i<6; i++) ret+=sensors[i]+" ";
+     return ret+"\n";
+   }
+ 
+   public String buttonsString() {
+     String ret="";
+     for (int i=0; i<8; i++) ret+=buttons[i]+" ";
+     return ret+"\n";
+   }
+ 
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/Listener.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/Listener.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/Listener.java	Wed Oct  1 22:08:08 2003
***************
*** 0 ****
--- 1,180 ----
+ package org.tekkotsu.mon;
+ 
+ import java.net.ServerSocket;
+ import java.net.Socket;
+ import java.io.InputStream;
+ import java.io.OutputStream;
+ import java.io.IOException;
+ 
+ public abstract class Listener implements Runnable {
+ 	public Listener() { _port=-1; _isConnected=false; }
+ 	public Listener(int port) { this(); setPort(port); }
+ 	public Listener(String host, int port) { this(); setHostPort(host, port); }
+ 
+ 	public void setPort(int port) {
+ 		_isServer=true;
+ 		_port=port;
+ 		startThread();
+ 	}
+ 
+ 	public void setHostPort(String host, int port) {
+ 		_isServer=false;
+ 		_host=host;
+ 		_port=port;
+ 		startThread();
+ 	}
+ 
+ 	public void startThread() {
+ 		destroy=false;
+ 		_listenerThread=new Thread(this);
+ 		_listenerThread.start();
+ 	}
+ 
+ 	public void run() {
+ 		if (_port >= 0) {
+ 			if (_isServer)
+ 				runServer();
+ 			else
+ 				runConnect();
+ 		} else {
+ 			System.out.println("can't start Listener without [host],port");
+ 		}
+ 	}
+ 
+ 	public void kill() {
+ 		destroy=true;
+ 		_isConnected=false;
+ 		if(_listenerThread!=null)
+ 			_listenerThread.interrupt();
+ 		close();
+ 	}
+ 
+ 	public void frameTimer() {
+ 		_frametimer_numframes++;
+ 		if (System.currentTimeMillis()-_frametimer_timer>1000) {
+ 			System.out.println("updated at "+_frametimer_numframes+"hz");
+ 			_frametimer_numframes=0;
+ 			_frametimer_timer=System.currentTimeMillis();
+ 		}
+ 	}
+ 
+ 	public double readDouble(InputStream in) throws IOException {
+ 		return Double.longBitsToDouble(readLong(in));
+ 	}
+ 
+ 	public void writeDouble(OutputStream out, double x) throws IOException {
+ 		writeLong(out,Double.doubleToLongBits(x));
+ 	}
+ 
+ 	public long readLong(InputStream in) throws IOException {
+ 		int read=0;
+ 		int last=0;
+ 		byte[] buf=new byte[8];
+ 		while (read<8 && last>=0) { last=in.read(buf,read,8-read); read+=last; }
+ 		if(last<0)
+ 			_isConnected=false;
+ 		return (b2l(buf[7])<<56) | (b2l(buf[6])<<48) |
+ 					 (b2l(buf[5])<<40) | (b2l(buf[4])<<32) |
+ 					 (b2l(buf[3])<<24) | (b2l(buf[2])<<16) |
+ 					 (b2l(buf[1])<< 8) | b2l(buf[0]);
+ 	}
+ 
+ 	public void writeLong(OutputStream out, long x) throws IOException {
+ 		int bytelen=8;
+ 		byte[] buf=new byte[bytelen];
+ 		for(int i=0; i<bytelen; i++)
+ 			buf[i]=(new Long((x>>(8*i)) & 0xff)).byteValue();
+ 		out.write(buf,0,bytelen);
+ 	}
+ 
+ 	public float readFloat(InputStream in) throws IOException {
+ 		return Float.intBitsToFloat(readInt(in));
+ 	}
+ 	
+ 	public void writeFloat(OutputStream out, float x) throws IOException {
+ 		writeInt(out,Float.floatToIntBits(x));
+ 	}
+ 
+ 	public int readInt(InputStream in) throws IOException {
+ 		int read=0;
+ 		int last=0;
+ 		byte[] buf=new byte[4];
+ 		while (read<4 && last>=0) { last=in.read(buf,read,4-read); read+=last; }
+ 		if(last<0)
+ 			_isConnected=false;
+ 		return (b2i(buf[3])<<24) | (b2i(buf[2])<<16) |
+ 					 (b2i(buf[1])<< 8) | b2i(buf[0]);
+ 	}
+ 	
+ 	public void writeInt(OutputStream out, int x) throws IOException {
+ 		int bytelen=4;
+ 		byte[] buf=new byte[bytelen];
+ 		for(int i=0; i<bytelen; i++)
+ 			buf[i]=(new Integer((x>>(8*i)) & 0xff)).byteValue();
+ 		out.write(buf,0,bytelen);
+ 	}
+ 
+   public byte[] readBytes(InputStream in, int bytes) throws IOException {
+     byte[] ret=new byte[bytes];
+     readBytes(ret, in, bytes);
+     return ret;
+   }
+ 
+ 	public void readBytes(byte[] buf, InputStream in, int bytes) throws IOException {
+ 		int read=0;
+ 		int last=0;
+ 		while (read<bytes && last>=0) {
+ 			last=in.read(buf, read, bytes-read);
+ 			read+=last;
+ 		}
+ 		if(last<0)
+ 			_isConnected=false;
+ 	}
+ 
+ 	public String readLine(InputStream in) throws java.io.IOException{
+ 		StringBuffer sbuf=new StringBuffer();
+ 		int x=in.read();
+ 		if(x==-1) {
+ 			_isConnected=false;
+ 			return sbuf.toString();
+ 		}
+ 		char c=(char)x;
+ 		while(c!='\n') {
+ 			sbuf.append(c);
+ 			x=in.read();
+ 			if(x==-1) {
+ 				_isConnected=false;
+ 				return sbuf.toString();
+ 			}
+ 			c=(char)x;
+ 		}
+ 		return sbuf.toString();
+ 	}
+ 	
+ 	public int b2i(byte b) { return (b>=0)?(int)b:((int)b)+256; }
+ 	public long b2l(byte b) { return (b>=0)?(long)b:((long)b)+256; }
+ 
+ 	public abstract void runServer();
+ 	public abstract void runConnect();
+ 	public abstract void close();
+ 
+ 	public boolean _isServer;
+ 	public int _port;
+ 	public String _host;
+ 	public boolean _isConnected;
+ 	public volatile Thread _listenerThread;
+ 	public volatile boolean destroy=false;
+ 
+ 	public int _frametimer_numframes=0;
+ 	public long _frametimer_timer=System.currentTimeMillis();
+ 
+   public static final int PACKET_TEXT=0;
+   public static final int PACKET_VISIONRAW_HALF=1;
+   public static final int PACKET_VISIONRAW_FULL=2;
+   public static final int PACKET_VISIONRAW_YFULL_UVHALF=3;
+   public static final int PACKET_VISIONRLE_FULL=4;
+   public static final int PACKET_WORLDSTATEJOINTS=5;
+   public static final int PACKET_WORLDSTATEPIDS=6;
+   public static final int PACKET_WORLDSTATEBUTTONS=7;
+   public static final int PACKET_WMCLASS=8;
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/MechaController.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/MechaController.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/MechaController.java	Wed Oct  1 22:08:08 2003
***************
*** 0 ****
--- 1,120 ----
+ package org.tekkotsu.mon;
+ 
+ // Sends "Mecha" command data from TekkotsuMon to the AIBO.
+ import java.lang.Integer;
+ import java.lang.String;
+ import java.lang.System;
+ import java.io.OutputStream;
+ import java.io.InputStream;
+ import java.net.Socket;
+ import javax.swing.Timer;
+ import java.awt.event.ActionEvent;
+ import java.awt.event.ActionListener;
+ import java.util.Vector;
+ import java.net.SocketException;
+ 
+ // The class itself. Brilliant that even though it does the talking,
+ // it extends TCP*Listener*.
+ public class MechaController extends TCPListener implements ActionListener {
+   // The command output stream
+   OutputStream out;
+   Socket mysock;
+ 	Timer t=new Timer(1000,this);
+ 	double forward=0;
+ 	double strafe=0;
+ 	double rotate=0;
+ 	Vector listeners=new Vector();
+ 	
+ 	public interface MechaUpdatedListener {
+ 		public void mechaUpdated(MechaController mc);
+ 	}
+ 
+ 	void addMechaUpdatedListener(MechaUpdatedListener mcl) { listeners.add(mcl); }
+ 	void removeMechaUpdatedListener(MechaUpdatedListener mcl) { listeners.remove(mcl); }
+ 	void fireMechaUpdated() {
+ 		for(int i=0;i<listeners.size();i++)
+ 			((MechaUpdatedListener)listeners.get(i)).mechaUpdated(this);
+ 	}
+ 
+   // Connect to control socket
+   public void connected(Socket socket) {
+     mysock = socket;
+ 		t.start();
+ 		fireMechaUpdated();
+     try {
+       out = mysock.getOutputStream();
+ 			InputStream sin=socket.getInputStream();
+ 			while (true) { //not that we expect input, but will block until the socket is closed
+ 				String msgtype=readLine(sin);
+ 				if(!_isConnected) break;
+ 			}
+     } catch(Exception e) {if((SocketException)e==null) e.printStackTrace();}
+ 
+ 		try { socket.close(); } catch (Exception ex) { }
+ 
+ 		_isConnected=false;
+ 		fireMechaUpdated();
+ 		//The sleep is to get around the socket still listening after being closed thing
+ 		if(!destroy)
+ 			System.out.println("WalkGUI - connection closed... reconnect after 5 seconds");
+ 		try { Thread.sleep(5000); } catch (Exception ex) {}
+   }
+ 
+   // Disconnect from control socket
+   public void close() {
+ 		//    try { mysock.close(); } catch(Exception e) {}
+     //_isConnected = false;
+ 		t.stop();
+     super.close();
+ 		//we'll fire an event to the listeners when the readLine in connected finally fails
+   }
+ 
+ 	public void actionPerformed(ActionEvent e) {
+ 		if(_isConnected) {
+ 			sendCommand("f",forward);
+ 			sendCommand("s",strafe);
+ 			sendCommand("r",rotate);
+ 		}
+ 	}
+ 
+   // Send a mecha command
+   public void sendCommand(String command, double param) {
+ 		t.restart();
+ 		
+     // Extract command byte
+     byte cmdbytes[] = command.getBytes();
+ 		if(cmdbytes[0]=='f')
+ 			forward=param;
+ 		else if(cmdbytes[0]=='s')
+ 			strafe=param;
+ 		else if(cmdbytes[0]=='r')
+ 			rotate=param;
+ 
+     // Construct the command sequence
+     byte sequence[] = new byte[5];
+     // The commmand byte is the first byte in cmdbytes. The remaining
+     // four bytes belong to the parameter. We have to convert the parameter
+     // (which we send as a float, not a double) to MIPS byte order thanks to
+     // (ahem) prior design decisions.
+     sequence[0] = cmdbytes[0];
+     int pbits = Float.floatToIntBits((float) param);
+     Integer i;
+     i = new Integer((pbits >> 24) & 0xff); sequence[4] = i.byteValue();
+     i = new Integer((pbits >> 16) & 0xff); sequence[3] = i.byteValue();
+     i = new Integer((pbits >>  8) & 0xff); sequence[2] = i.byteValue();
+     i = new Integer(pbits & 0xff);	   sequence[1] = i.byteValue();
+     // Now write the whole command.
+     try {
+       out.write(sequence, 0, 5);
+     } catch(Exception e) { close(); return; }
+   }
+ 
+   // Some state inquiry functions
+   public boolean hasData() { return false; }
+   public boolean isConnected() { return _isConnected; }
+ 
+   // Constructors
+   public MechaController() { super(); }
+   public MechaController(int port) { super(port); }
+   public MechaController(String host, int port) { super(host, port); }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/NetDebug.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/NetDebug.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/NetDebug.java	Fri Sep 26 00:36:20 2003
***************
*** 0 ****
--- 1,44 ----
+ package org.tekkotsu.mon;
+ 
+ import java.net.*;
+ import java.io.*;
+ 
+ 
+ public class NetDebug {
+   public static void main(String args[]) {
+     if (args.length<1) {
+       System.out.println("usage: java NetDebug ip_addr");
+       System.exit(1);
+     }
+     NetDebug netdebug=new NetDebug(args[0]);
+   }
+ 
+   public NetDebug(String ip) {
+     try {
+       Socket s = new Socket(ip, 10011);
+       InputStream in = s.getInputStream();
+       int i=0;
+       while (true) {
+         i++;
+         if (readInt(in)==2) {
+           System.out.println(i);
+         }
+       }
+     } catch (Exception ex) {
+       System.out.println(ex);
+     }
+   }
+ 
+   int readInt(InputStream in) throws IOException {
+     int read=0;
+     int last=0;
+     byte[] buf=new byte[4];
+     while (read<4 && last>=0) { last=in.read(buf,read,4-read); read+=last; }
+     if(last<0)
+       throw new IOException("my exception");
+     return (b2i(buf[3])<<24) | (b2i(buf[2])<<16) |
+            (b2i(buf[1])<< 8) | b2i(buf[0]);
+   }
+ 
+   int b2i(byte b) { return (b>=0)?(int)b:((int)b)+256; }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/PIDs.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/PIDs.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/PIDs.java	Fri Sep 26 00:36:20 2003
***************
*** 0 ****
--- 1,14 ----
+ package org.tekkotsu.mon;
+ 
+ public class PIDs {
+   public int timestamp;
+   public float[] P;
+   public float[] I;
+   public float[] D;
+ 
+   PIDs() {
+     P=new float[18];
+     I=new float[18];
+     D=new float[18];
+   } 
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/PointPick.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/PointPick.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/PointPick.java	Fri Sep 26 00:36:20 2003
***************
*** 0 ****
--- 1,259 ----
+ package org.tekkotsu.mon;
+ 
+ import javax.swing.*;
+ import java.awt.*;
+ import java.awt.geom.*;
+ import java.awt.event.*;
+ import java.util.Vector;
+ 
+ public class PointPick extends JComponent {
+ 	static public void main(String s[]) {
+ 		JFrame frame=new JFrame("Point Pick Test");
+ 		frame.setSize(new Dimension(300, 300)); 
+ 		PointPick pp=new PointPick(true);
+ 		frame.getContentPane().setLayout(new BorderLayout());
+ 		frame.getContentPane().add(pp,BorderLayout.CENTER);
+ 		frame.addWindowListener(new WindowAdapter() {
+ 			public void windowClosing(WindowEvent e) { System.exit(0); }
+ 		});
+ 		frame.show();
+ 	}
+ 	
+ 	float x=0;
+ 	float y=0;
+ 	float dotsize=8;
+ 	float tracksize=14;
+ 	PPTic mdot;
+ 	PPTic track;
+ 	Vector listeners=new Vector();
+ 	Vector tics=new Vector();
+ 	boolean isCirc=true;
+ 	
+ 	public interface PointPickedListener {
+ 		public void pointPicked(Point2D.Float p, MouseEvent e, PointPick pp);
+ 	}
+ 	public void addPointPickedListener(PointPickedListener ppl) {
+ 		listeners.add(ppl);
+ 	}
+ 	public void removePointPickedListener(PointPickedListener ppl) {
+ 		listeners.remove(ppl);
+ 	}
+ 	public void firePointPicked(Point2D.Float p, MouseEvent e) {
+ 		for(int i=0; i<listeners.size(); i++)
+ 			((PointPickedListener)listeners.get(i)).pointPicked(p,e,this);
+ 	}
+ 	
+ 	public class PPTic extends JComponent {
+ 		float xp=1.0f;
+ 		float yp=1.0f;
+ 		BasicStroke s=new BasicStroke(1);
+ 		Color line=Color.BLACK;
+ 		Color fill=null;
+ 		boolean isCirc=true;
+ 		public PPTic() {}
+ 		public PPTic(float percent, BasicStroke s) {
+ 			xp=yp=percent;
+ 			this.s=s;
+ 		}
+ 		public PPTic(float percent, BasicStroke s, Color line, Color fill) {
+ 			xp=yp=percent;
+ 			this.s=s;
+ 			this.line=line;
+ 			this.fill=fill;
+ 		}
+ 		public void paint(Graphics graphics) {
+ 			Graphics2D g=(Graphics2D)graphics;
+ 			g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
+ 			float sw=s.getLineWidth();
+ 			float w=getWidth();
+ 			float h=getHeight();
+ 			float l=w*(1-xp)/2;
+ 			float r=l+w*xp;
+ 			float t=h*(1-yp)/2;
+ 			float b=t+h*yp;
+ 			l+=sw/2-.5;
+ 			r-=sw/2+.5;
+ 			t+=sw/2-.5;
+ 			b-=sw/2+.5;
+ 			if(fill!=null) {
+ 				g.setPaint(fill);
+ 				if(isCirc)
+ 					g.fill(new Ellipse2D.Float(l,t,r-l,b-t));
+ 				else
+ 					g.fill(new Rectangle2D.Float(l,t,r-l,b-t));
+ 			}
+ 			if(line!=null) {
+ 				g.setPaint(line);
+ 				g.setStroke(s);
+ 				if(isCirc)
+ 					g.draw(new Ellipse2D.Float(l,t,r-l,b-t));
+ 				else
+ 					g.draw(new Rectangle2D.Float(l,t,r-l,b-t));
+ 			}
+ 			super.paint(graphics);
+ 		}
+ 		public void setCircular(boolean circ) {
+ 			isCirc=circ;
+ 		}
+ 	}
+ 	
+ 	public PointPick(boolean circ) {
+ 		BasicStroke s=new BasicStroke(1);
+ 
+ 		track=new PPTic(1,new BasicStroke(2),Color.RED,null);
+ 		track.reshape((int)((getWidth()*(1+x)-tracksize)/2),(int)((getHeight()*(1+y)-tracksize)/2),(int)tracksize,(int)tracksize);
+ 		track.setVisible(false);
+ 		add(track);
+ 
+ 		mdot=new PPTic(1,s,null,isEnabled()?new Color(.7f,.0f,.0f):new Color(.4f,.4f,.4f));
+ 		mdot.reshape((int)((getWidth()*(1+x)-dotsize)/2),(int)((getHeight()*(1-y)-dotsize)/2),(int)dotsize,(int)dotsize);
+ 		add(mdot);
+ 
+ 		PPTic tmp,tmp2;
+ 		tmp=new PPTic(1.0f,new BasicStroke(2),isEnabled()?Color.BLACK:Color.GRAY,Color.WHITE);
+ 		tmp.reshape(0,0,getWidth(),getHeight());
+ 		tmp.setLayout(new BorderLayout());
+ 		add(tmp);
+ 		tics.add(tmp);
+ 		for(float f=.75f; f>0; f-=.25f) {
+ 			tmp2=new PPTic(f,s,Color.LIGHT_GRAY,null);
+ 			tmp2.setLayout(new BorderLayout());
+ 			tmp.add(tmp2,BorderLayout.CENTER);
+ 			tics.add(tmp2);
+ 			tmp=tmp2;
+ 		}
+ 		tmp2=new PPTic(.0175f,s,null,Color.LIGHT_GRAY);
+ 		tmp2.setLayout(new BorderLayout());
+ 		tmp.add(tmp2,BorderLayout.CENTER);
+ 		tics.add(tmp2);
+ 		tmp=tmp2;
+ 		
+ 		enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK+AWTEvent.MOUSE_EVENT_MASK);
+ 		
+ 		setCircular(circ);
+ 	}
+ 	
+ 	public void setCircular(boolean circ) {
+ 		if(isCirc!=circ) {
+ 			for(int i=0; i<tics.size(); i++) {
+ 				((PPTic)tics.get(i)).setCircular(circ);
+ 			}
+ 			setOpaque(!circ);
+ 			isCirc=circ;
+ 			repaint();
+ 		}
+ 	}
+ 
+ 	public void paint(Graphics graphics) {
+ 		super.paint(graphics);
+ 		int w=getWidth()-1;
+ 		int h=getHeight()-1;
+ //		Rectangle r=graphics.getClipBounds();
+ //		graphics.setColor(Color.WHITE);
+ //		graphics.fillRect(r.x,r.y,r.width,r.height);
+ 		graphics.setColor(isEnabled()?Color.BLACK:Color.GRAY);
+ 		graphics.drawLine(0,w/2,h,w/2);
+ 		graphics.drawLine(h/2,0,h/2,w);
+ //		graphics.setColor(isEnabled()?Color.DARK_GRAY:Color.LIGHT_GRAY);
+ //		graphics.fillOval((int)((getWidth()-dotsize+2)/2),(int)((getHeight()-dotsize+2)/2),(int)dotsize-2,(int)dotsize-2);
+ 	}
+ 
+ 	public void setEnabled(boolean b) {
+ 		((PPTic)tics.get(0)).line=b?Color.BLACK:Color.GRAY;
+ 		mdot.fill=b?new Color(.7f,.0f,.0f):new Color(.4f,.4f,.4f);
+ 		super.setEnabled(b);
+ 	}
+ 	
+ 	public void setBounds(int x, int y, int w, int h) {
+ 		if(w>h)
+ 			w=h;
+ 		if(h>w)
+ 			h=w;
+ 		((PPTic)tics.get(0)).setBounds(0,0,w,h);
+ 		mdot.setBounds((int)((w*(1+this.x)-dotsize)/2),(int)((h*(1-this.y)-dotsize)/2),(int)dotsize,(int)dotsize);
+ 		super.setBounds(x,y,w,h);
+ 	}
+ 	
+ 	public void processMouseEvent(MouseEvent e) {
+ 		if(isEnabled()) {
+ 			if(e.getID()==MouseEvent.MOUSE_PRESSED) {
+ 				Point2D.Float mp=screenToModel(e.getPoint());
+ 				Point sp=modelToScreen(mp);
+ 				sp.translate((int)(-tracksize/2),(int)(-tracksize/2));
+ 				track.setLocation(sp);
+ 				track.setVisible(true);
+ 				doSetPoint(mp);
+ 				firePointPicked(mp,e);
+ 			} else if(e.getID()==MouseEvent.MOUSE_RELEASED) {
+ 				if((e.getModifiersEx()&(MouseEvent.BUTTON1_DOWN_MASK|MouseEvent.BUTTON2_DOWN_MASK|MouseEvent.BUTTON3_DOWN_MASK))==0)
+ 					track.setVisible(false);
+ 			}
+ 		}
+ 		super.processMouseEvent(e);
+ 	}
+ 
+ 	public void processMouseMotionEvent(MouseEvent e) {
+ 		if(isEnabled()) {
+ 			if(e.getID()==MouseEvent.MOUSE_DRAGGED) {
+ 				Point2D.Float mp=screenToModel(e.getPoint());
+ 				Point sp=modelToScreen(mp);
+ 				sp.translate((int)(-tracksize/2),(int)(-tracksize/2));
+ 				track.setLocation(sp);
+ 				doSetPoint(mp);
+ 				firePointPicked(mp,e);
+ 			}
+ 		}
+ 		super.processMouseMotionEvent(e);
+ 	}
+ 	
+ 	public Point2D.Float getPoint() { return new Point2D.Float(x,y); }
+ 	public float getXValue() { return x; }
+ 	public float getYValue() { return y; }
+ 
+ 	public void setPoint(float x, float y) {
+ 		doSetPoint(x,y);
+ 		firePointPicked(new Point2D.Float(x,y),null);
+ 	}
+ 	
+ 	protected Point2D.Float screenToModel(Point p) {
+ 		return screenToModel(p.x,p.y);
+ 	}
+ 	protected Point2D.Float screenToModel(int x, int y) {
+ 		float fx=x/(float)getWidth()*2-1;
+ 		float fy=1-y/(float)getHeight()*2;
+ 		if(isCirc) {
+ 			if(fx*fx+fy*fy>1) {
+ 				double a=Math.atan2(fy,fx);
+ 				fx=(float)Math.cos(a);
+ 				fy=(float)Math.sin(a);
+ 			}
+ 		} else {
+ 			if(fx>1)
+ 				fx=1;
+ 			if(fx<-1)
+ 				fx=-1;
+ 			if(fy>1)
+ 				fy=1;
+ 			if(fy<-1)
+ 				fy=-1;
+ 		}
+ 		return new Point2D.Float(fx,fy);
+ 	}
+ 	protected Point modelToScreen(Point2D.Float p) {
+ 		return modelToScreen(p.x,p.y);
+ 	}
+ 	protected Point modelToScreen(float x, float y) {
+ 		return new Point((int)(getWidth()*(1+x)/2),(int)(getHeight()*(1-y)/2));
+ 	}
+ 	
+ 	public void doSetPoint(Point2D.Float p) {
+ 		doSetPoint(p.x,p.y);
+ 	}
+ 	public void doSetPoint(float x, float y) {
+ 		this.x=x;
+ 		this.y=y;
+ 		Point p=modelToScreen(x,y);
+ 		p.translate((int)(-dotsize/2),(int)(-dotsize/2));
+ 		mdot.setLocation(p);
+ 	}
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/PrintDuties.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/PrintDuties.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/PrintDuties.java	Fri Sep 26 00:36:20 2003
***************
*** 0 ****
--- 1,22 ----
+ package org.tekkotsu.mon;
+ 
+ import java.net.*;
+ import java.io.*;
+ 
+ 
+ public class PrintDuties {
+   public static void main(String args[]) {
+     if (args.length<1) {
+       System.out.println("usage: java PrintDuties ip_addr");
+       System.exit(1);
+     }
+     WorldStateJointsListener wsjl=new WorldStateJointsListener(args[0],10031);
+     while (true) {
+       if (wsjl.isConnected() && wsjl.hasData()) {
+         System.out.print(wsjl.getData().dutiesString());
+       } else {
+         try { Thread.sleep(10); } catch (Exception ex) { }
+       }
+     }
+   }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/ScriptEntry.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/ScriptEntry.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/ScriptEntry.java	Fri Sep 26 00:36:20 2003
***************
*** 0 ****
--- 1,9 ----
+ package org.tekkotsu.mon;
+ 
+ public class ScriptEntry {
+ 	String title;
+ 	String cmd;
+ 	public ScriptEntry(String title, String cmd) { this.title=title; this.cmd=cmd; }
+ 	public String toString() { return title; }
+ }
+ 	
Index: AiboPup/tools/mon/org/tekkotsu/mon/SquareRightLayout.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/SquareRightLayout.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/SquareRightLayout.java	Fri Sep 26 00:36:20 2003
***************
*** 0 ****
--- 1,44 ----
+ package org.tekkotsu.mon;
+ 
+ import java.awt.*;
+ 
+ public class SquareRightLayout implements LayoutManager {
+ 	Component right;
+ 	Component square;
+ 	static String SQUARE="square";
+ 	static String RIGHT="right";
+ 	public void addLayoutComponent(String name, Component comp) {
+ 		if(name.compareTo(SQUARE)==0)
+ 			square=comp;
+ 		else if(name.compareTo(RIGHT)==0)
+ 			right=comp;
+ 	}
+ 	public void layoutContainer(Container parent) {
+ 		square.setBounds(0,0,parent.getHeight(),parent.getHeight());
+ 		right.setBounds(parent.getHeight(),0,parent.getWidth()-parent.getHeight(),parent.getHeight());
+ 	}
+ 	public Dimension minimumLayoutSize(Container parent) {
+ 		Dimension sq=square.getMinimumSize();
+ 		Dimension rt=right.getMinimumSize();
+ 		int minsq=sq.width>sq.height?sq.width:sq.height;
+ 		if(minsq<rt.height)
+ 			minsq=rt.height;
+ //			int minheight=minsq>rt.height?minsq:rt.height
+ 		return new Dimension(minsq+rt.width,minsq);
+ 	}
+ 	public Dimension preferredLayoutSize(Container parent) {
+ 		Dimension sq=square.getPreferredSize();
+ 		Dimension rt=right.getPreferredSize();
+ 		int prefsq=sq.width>sq.height?sq.width:sq.height;
+ 		if(prefsq<rt.height)
+ 			prefsq=rt.height;
+ //			int prefheight=minsq>rt.height?minsq:rt.height
+ 		return new Dimension(prefsq+rt.width,prefsq);
+ 	}
+ 	public void removeLayoutComponent(Component comp) {
+ 		if(square==comp)
+ 			square=null;
+ 		else if(right==comp)
+ 			right=null;
+ 	}
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/TCPListener.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/TCPListener.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/TCPListener.java	Wed Oct  1 22:08:08 2003
***************
*** 0 ****
--- 1,69 ----
+ package org.tekkotsu.mon;
+ 
+ import java.net.ServerSocket;
+ import java.net.Socket;
+ 
+ public abstract class TCPListener extends Listener {
+ 	public abstract void connected(Socket socket);
+ 
+ 	public void runServer() {
+ 		Thread me = Thread.currentThread();
+ 		try { _serverSocket=new ServerSocket(_port); }
+ 		catch (Exception ex) {
+ 			System.out.println("port "+_port+": "+ex);
+ 			return;
+ 		}
+ 
+ 		while (me == _listenerThread && !destroy) {
+ 			try {
+ 				_socket=_serverSocket.accept();
+ 				connected(_socket);
+ 			} catch (Exception ex) { }
+ 		}
+ 	}
+ 
+ 	public void runConnect() {
+ 		int attempts=0;
+ 		Thread me = Thread.currentThread();
+ 		while (me==_listenerThread && !destroy) {
+ 			if(attempts==0) {
+ 				System.out.println("["+_port+"] connecting ...");
+ 			}
+ 			try {
+ 				_socket=new Socket(_host,_port);
+ 				System.out.println("["+_port+"] connected");
+ 				attempts=0;
+ 				_isConnected=true;
+ 			} catch (Exception ex) {}
+ 			if(_isConnected) {
+ 				connected(_socket);
+ 				if(!destroy)
+ 					System.out.println("["+_port+"] disconnected");
+           System.out.println("["+_port+"] attempting to reestablish ..");
+ 			}
+ 			attempts++;
+ 			if(destroy) {
+ 				System.out.println("["+_port+"] connection closed");
+ 				break;
+ 			}
+ 			try {
+ 				Thread.sleep(500);
+ 			} catch (Exception ex) {}
+ 		}
+ 	}
+ 
+ 	public void close() {
+ 		_listenerThread=null;
+ 		_isConnected=false;
+ 		try { _socket.close(); } catch (Exception ex) { }
+ 		if (_isServer)
+ 			try { _serverSocket.close(); } catch (Exception ex) { }
+ 	}
+ 
+ 	public TCPListener() { super(); }
+ 	public TCPListener(int port) { super(port); }
+ 	public TCPListener(String host, int port) { super(host,port); }
+ 
+ 	Socket _socket;
+ 	ServerSocket _serverSocket;
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/TableMap.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/TableMap.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/TableMap.java	Fri Sep 26 00:36:20 2003
***************
*** 0 ****
--- 1,63 ----
+ package org.tekkotsu.mon;
+ 
+ /** 
+  * In a chain of data manipulators some behaviour is common. TableMap
+  * provides most of this behavour and can be subclassed by filters
+  * that only need to override a handful of specific methods. TableMap 
+  * implements TableModel by routing all requests to its model, and
+  * TableModelListener by routing all events to its listeners. Inserting 
+  * a TableMap which has not been subclassed into a chain of table filters 
+  * should have no effect.
+  *
+  * @version 1.4 12/17/97
+  * @author Philip Milne */
+ 
+ import javax.swing.table.*; 
+ import javax.swing.event.TableModelListener; 
+ import javax.swing.event.TableModelEvent; 
+ 
+ public class TableMap extends AbstractTableModel 
+                       implements TableModelListener {
+     protected TableModel model; 
+ 
+     public TableModel getModel() {
+         return model;
+     }
+ 
+     public void setModel(TableModel model) {
+         this.model = model; 
+         model.addTableModelListener(this); 
+     }
+ 
+     public Object getValueAt(int aRow, int aColumn) {
+         return model.getValueAt(aRow, aColumn); 
+     }
+         
+     public void setValueAt(Object aValue, int aRow, int aColumn) {
+         model.setValueAt(aValue, aRow, aColumn); 
+     }
+ 
+     public int getRowCount() {
+         return (model == null) ? 0 : model.getRowCount(); 
+     }
+ 
+     public int getColumnCount() {
+         return (model == null) ? 0 : model.getColumnCount(); 
+     }
+         
+     public String getColumnName(int aColumn) {
+         return model.getColumnName(aColumn); 
+     }
+ 
+     public Class getColumnClass(int aColumn) {
+         return model.getColumnClass(aColumn); 
+     }
+         
+     public boolean isCellEditable(int row, int column) { 
+          return model.isCellEditable(row, column); 
+     }
+ 
+     public void tableChanged(TableModelEvent e) {
+         fireTableChanged(e);
+     }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/TableSorter.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/TableSorter.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/TableSorter.java	Fri Sep 26 00:36:20 2003
***************
*** 0 ****
--- 1,363 ----
+ package org.tekkotsu.mon;
+ 
+ /**
+  * A sorter for TableModels. The sorter has a model (conforming to TableModel)
+  * and itself implements TableModel. TableSorter does not store or copy
+  * the data in the TableModel, instead it maintains an array of
+  * integers which it keeps the same size as the number of rows in its
+  * model. When the model changes it notifies the sorter that something
+  * has changed eg. "rowsAdded" so that its internal array of integers
+  * can be reallocated. As requests are made of the sorter (like
+  * getValueAt(row, col) it redirects them to its model via the mapping
+  * array. That way the TableSorter appears to hold another copy of the table
+  * with the rows in a different order. The sorting algorthm used is stable
+  * which means that it does not move around rows when its comparison
+  * function returns 0 to denote that they are equivalent.
+  *
+  * @version 1.5 12/17/97
+  * @author Philip Milne
+  */
+ 
+ // Alok Ladsariya
+ // (heavily modified)
+ 
+ import java.util.*;
+ import java.lang.*;
+ import javax.swing.table.*;
+ import javax.swing.event.*;
+ import java.awt.event.*;
+ import javax.swing.*;
+ import javax.swing.table.*;
+ 
+ public class TableSorter extends TableMap {
+   int[] forwardIndices;
+   int[] reverseIndices;
+ 
+   public int sortColumn=0;
+   public boolean sortOrder=true;
+ 
+   public TableSorter() {
+     forwardIndices=new int[0];
+     reverseIndices=new int[0];
+   }
+ 
+   public TableSorter(TableModel model) {
+     this();
+     setModel(model);
+   }
+ 
+   public TableSorter(TableModel model, int defColumn) {
+     this(model);
+     sortColumn=defColumn;
+   }
+ 
+   public void setModel(TableModel model) {
+     super.setModel(model);
+     reallocate();
+     sort();
+   }
+ 
+   public void reallocate() {
+     int rowCount=model.getRowCount();
+ 
+     forwardIndices=new int[rowCount];
+     reverseIndices=new int[rowCount];
+     for (int row=0; row<rowCount; row++) {
+       forwardIndices[row]=row;
+       reverseIndices[row]=row;
+     }
+   }
+ 
+   public void deleteRow(int i) {
+     reallocate();
+     sort();
+   }
+ 
+   public void insertRow(int i) {
+     reallocate();
+     sort();
+   }
+ 
+   public void updateRow(int i) {
+     sort();
+   }
+ 
+   public final int compareRowsByColumn(int row1, int row2, int column) {
+     Class type = model.getColumnClass(column);
+     TableModel data = model;
+ 
+     // Check for nulls.
+ 
+     Object o1 = data.getValueAt(row1, column);
+     Object o2 = data.getValueAt(row2, column); 
+ 
+     // If both values are null, return 0.
+     if (o1 == null && o2 == null) {
+       return 0; 
+     } else if (o1 == null) { // Define null less than everything. 
+       return -1; 
+     } else if (o2 == null) { 
+       return 1; 
+     }
+ 
+     /*
+      * We copy all returned values from the getValue call in case
+      * an optimised model is reusing one object to return many
+      * values.  The Number subclasses in the JDK are immutable and
+      * so will not be used in this way but other subclasses of
+      * Number might want to do this to save space and avoid
+      * unnecessary heap allocation.
+      */
+ 
+     if (type.getSuperclass() == java.lang.Number.class) {
+       Number n1 = (Number)data.getValueAt(row1, column);
+       double d1 = n1.doubleValue();
+       Number n2 = (Number)data.getValueAt(row2, column);
+       double d2 = n2.doubleValue();
+ 
+       if (d1 < d2) {
+         return -1;
+       } else if (d1 > d2) {
+         return 1;
+       } else {
+         return 0;
+       }
+     } else if (type == java.util.Date.class) {
+       Date d1 = (Date)data.getValueAt(row1, column);
+       long n1 = d1.getTime();
+       Date d2 = (Date)data.getValueAt(row2, column);
+       long n2 = d2.getTime();
+ 
+       if (n1 < n2) {
+         return -1;
+       } else if (n1 > n2) {
+         return 1;
+       } else {
+         return 0;
+       }
+     } else if (type == String.class) {
+       String s1 = (String)data.getValueAt(row1, column);
+       String s2    = (String)data.getValueAt(row2, column);
+       int result = s1.compareTo(s2);
+ 
+       if (result < 0) {
+         return -1;
+       } else if (result > 0) {
+         return 1;
+       } else {
+         return 0;
+       }
+     } else if (type == Boolean.class) {
+       Boolean bool1 = (Boolean)data.getValueAt(row1, column);
+       boolean b1 = bool1.booleanValue();
+       Boolean bool2 = (Boolean)data.getValueAt(row2, column);
+       boolean b2 = bool2.booleanValue();
+ 
+       if (b1 == b2) {
+         return 0;
+       } else if (b1) { // Define false < true
+         return 1;
+       } else {
+         return -1;
+       }
+     } else {
+       Object v1 = data.getValueAt(row1, column);
+       String s1 = v1.toString();
+       Object v2 = data.getValueAt(row2, column);
+       String s2 = v2.toString();
+       int result = s1.compareTo(s2);
+ 
+       if (result < 0) {
+         return -1;
+       } else if (result > 0) {
+         return 1;
+       } else {
+         return 0;
+       }
+     }
+   }
+ 
+   public final int compare(int row1, int row2) {
+     int result = compareRowsByColumn(row1, row2, sortColumn);
+     if (result != 0) {
+       return sortOrder ? result : -result;
+     }
+     return 0;
+   }
+ 
+   public void tableChanged(TableModelEvent e) {
+     if (e.getType()==TableModelEvent.INSERT) {
+       if (e.getFirstRow()==e.getLastRow())
+         insertRow(e.getFirstRow());
+       else {
+         reallocate();
+         sort();
+         super.tableChanged(new TableModelEvent(this));
+         return;
+       }
+     } else if (e.getType()==TableModelEvent.UPDATE &&
+         e.getColumn()==sortColumn) {
+ /*    Dynamic sorting disabled
+       if (e.getFirstRow()==e.getLastRow())
+         updateRow(e.getFirstRow());
+       else {
+         sort();
+         super.tableChanged(new TableModelEvent(this));
+         return;
+       }*/
+     } else if (e.getType()==TableModelEvent.DELETE) {
+       if (e.getFirstRow()==e.getLastRow())
+         deleteRow(e.getFirstRow());
+       else {
+         reallocate();
+         sort();
+         super.tableChanged(new TableModelEvent(this));
+         return;
+       }
+     }
+ 
+     for (int i=e.getFirstRow(); i<=e.getLastRow(); i++) {
+       super.tableChanged(new TableModelEvent(this,
+                                              reverseIndices[i],
+                                              reverseIndices[i],
+                                              e.getColumn(),
+                                              e.getType()));
+     }
+   }
+ 
+   public void checkModel() {
+     if (forwardIndices.length != model.getRowCount()) {
+       System.err.println("Sorter not informed of a change in model.");
+     }
+   }
+ 
+   public void sort() {
+     checkModel();
+     sort(forwardIndices);
+     for (int i=0; i<forwardIndices.length; i++) {
+       reverseIndices[forwardIndices[i]]=i;
+     }
+   }
+ 
+   // The mapping only affects the contents of the data rows.
+   // Pass all requests to these rows through the mapping array: "indexes".
+ 
+   public Object getValueAt(int aRow, int aColumn) {
+     checkModel();
+     return model.getValueAt(forwardIndices[aRow], aColumn);
+   }
+ 
+   public void setValueAt(Object aValue, int aRow, int aColumn) {
+     checkModel();
+     model.setValueAt(aValue, forwardIndices[aRow], aColumn);
+   }
+ 
+   public int translateRow(int aRow) {
+     return forwardIndices[aRow];
+   }
+ 
+   // There is no-where else to put this. 
+   // Add a mouse listener to the Table to trigger a table sort 
+   // when a column heading is clicked in the JTable. 
+   public void addMouseListenerToHeaderInTable(JTable table) { 
+     final TableSorter sorter = this; 
+     final JTable tableView = table; 
+     tableView.setColumnSelectionAllowed(false); 
+     MouseAdapter listMouseListener = new MouseAdapter() {
+       public void mouseClicked(MouseEvent e) {
+         TableColumnModel columnModel = tableView.getColumnModel();
+         int viewColumn = columnModel.getColumnIndexAtX(e.getX()); 
+         int column = tableView.convertColumnIndexToModel(viewColumn); 
+         if (e.getClickCount() == 1 && column != -1) {
+           if (column==sorter.sortColumn) {
+             sorter.sortOrder=!sorter.sortOrder;
+           } else {
+             sorter.sortColumn=column;
+             sorter.sortOrder=true;
+           }
+           sorter.sort();
+         }
+       }
+     };
+     JTableHeader th = tableView.getTableHeader(); 
+     th.addMouseListener(listMouseListener); 
+   }
+ 
+   /*
+    * Quicksort code from:
+    * QSortAlgorithm.java      1.3   29 Feb 1996 James Gosling
+    *
+    * Copyright (c) 1994-1996 Sun Microsystems, Inc. All Rights Reserved.
+    *
+    * James Gosling
+    * Kevin A. Smith
+    * extended with TriMedian and InsertionSort by Denis Ahrens
+    * with all the tips from Robert Sedgewick (Algorithms in C++).
+    * It uses TriMedian and InsertionSort for lists shorts than 4.
+    * <fuhrmann@cs.tu-berlin.de>
+    */
+ 
+   private void QuickSort(int a[], int l, int r)
+   {
+     int M = 4;
+     int i;
+     int j;
+     int v;
+ 
+     if ((r-l)>M)
+     {
+       i = (r+l)/2;
+       if (compare(a[l],a[i])>0) swap(a,l,i);     // Tri-Median Methode!
+       if (compare(a[l],a[r])>0) swap(a,l,r);
+       if (compare(a[i],a[r])>0) swap(a,i,r);
+ 
+       j = r-1;
+       swap(a,i,j);
+       i = l;
+       v = a[j];
+       for(;;)
+       {
+         while(compare(a[++i],v)<0);
+         while(compare(a[--j],v)>0);
+         if (j<i) break;
+         swap (a,i,j);
+       }
+       swap(a,i,r-1);
+       QuickSort(a,l,j);
+       QuickSort(a,i+1,r);
+     }
+   }
+ 
+   private void swap(int a[], int i, int j)
+   {
+     int T;
+     T = a[i]; 
+     a[i] = a[j];
+     a[j] = T;
+   }
+ 
+   private void InsertionSort(int a[], int lo0, int hi0)
+   {
+     int i;
+     int j;
+     int v;
+ 
+     for (i=lo0+1;i<=hi0;i++)
+     {
+       v = a[i];
+       j=i;
+       while ((j>lo0) && compare(a[j-1],v)>0)
+       {
+         a[j] = a[j-1];
+         j--;
+       }
+       a[j] = v;
+     }
+   }
+ 
+   public void sort(int a[])
+   {
+     QuickSort(a, 0, a.length - 1);
+     InsertionSort(a,0,a.length-1);
+   }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/Terminal.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/Terminal.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/Terminal.java	Fri Sep 26 00:36:20 2003
***************
*** 0 ****
--- 1,136 ----
+ package org.tekkotsu.mon;
+ 
+ import javax.swing.*;
+ import java.awt.BorderLayout;
+ import java.awt.Dimension;
+ import java.awt.Rectangle;
+ import java.awt.Color;
+ import java.awt.Font;
+ import java.awt.Insets;
+ import java.awt.event.KeyListener;
+ import java.awt.event.KeyEvent;
+ import java.awt.event.ComponentListener;
+ import java.awt.event.ComponentEvent;
+ 
+ /* TODO:
+    JTextPane
+    History, Autocomplete
+ */
+ public class Terminal implements KeyListener, ComponentListener {
+     static final int MAX_CHARS = 30000;
+     JFrame _term;
+     JTextArea _output;
+     JTextField _input;
+     JScrollPane _scroll;
+     JScrollBar _scroll_bar;
+     int _width, _height;
+     String _title;
+     String _data;
+ 
+     public static void main(String[] args) {
+ //      Terminal terminal=new Terminal();
+       System.out.println("please instantiate from within Matlab");
+       System.exit(1);
+     }
+ 
+     public Terminal() {
+       _height=400;
+       _width=600;
+       _title="AiboMon";
+       _data="";
+ 
+       createTerm();
+     }
+ 
+     public void close() {
+       _term.setVisible(false);
+     }
+ 
+     public boolean wasClosed() {
+       return !_term.isVisible();
+     }
+ 
+     void createTerm() {
+       _term=new JFrame("AiboMon");
+       _term.setBackground(Color.darkGray);
+       _term.getContentPane().setLayout(new BorderLayout());
+ 
+       _output=new JTextArea();
+       _output.setBackground(Color.black);
+       _output.setForeground(Color.lightGray);
+       _output.setFont(new Font("Monospaced",Font.PLAIN, 12));
+       _output.setLineWrap(true);
+       _output.setEditable(false);
+       _scroll=new JScrollPane(_output,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+                                       JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+       _term.getContentPane().add(_scroll, BorderLayout.NORTH);
+ 
+       _input=new JTextField();
+       _input.setBackground(Color.black);
+       _input.setForeground(Color.white);
+       _input.setFont(new Font("Monospaced",Font.PLAIN,12));
+       _term.getContentPane().add(_input, BorderLayout.SOUTH);
+ 
+       _input.addKeyListener(this);
+       _term.addComponentListener(this);
+       _term.show();
+       _term.setSize(new Dimension(_width, _height));
+       resize();
+ 
+       _scroll_bar=_scroll.getVerticalScrollBar();
+     }
+     
+     public void keyPressed(KeyEvent e) {
+       switch(e.getKeyCode()) {
+         case KeyEvent.VK_ENTER:
+           _output.append(_input.getText()+"\n");
+           _data=_data+_input.getText()+"\n";
+           _input.setText("");
+           break;
+         case KeyEvent.VK_UP:
+           break;
+         case KeyEvent.VK_DOWN:
+           break;
+       }
+     }
+ 
+     public boolean hasData() {
+       return _data.length()!=0;
+     }
+ 
+     public String getData() {
+       String ret;
+       ret=_data;
+       _data="";
+       return ret;
+     }
+ 
+     public void write(String s) {
+       _output.append(s);
+       _scroll_bar.setValue(_scroll_bar.getMaximum());
+     }
+ 
+     public void clear() {
+       _output.setText("");
+     }
+ 
+     void resize() {
+       Dimension dim=_term.getSize();
+       Insets ins=_term.getInsets();
+       int width=dim.width-ins.left-ins.right;
+       int height=dim.height-ins.top-ins.bottom;
+       _scroll.setSize(new Dimension(width, height-25));
+       _input.setSize(new Dimension(width,25));
+     }
+ 
+     public void componentResized(ComponentEvent e) {
+       if (e.getID()==ComponentEvent.COMPONENT_RESIZED) resize();
+     }
+ 
+     public void keyReleased(KeyEvent e) { }
+     public void keyTyped(KeyEvent e) { }
+     public void componentHidden(ComponentEvent e) { }
+     public void componentMoved(ComponentEvent e) { }
+     public void componentShown(ComponentEvent e) { }
+ }
+ 
Index: AiboPup/tools/mon/org/tekkotsu/mon/TestGraph.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/TestGraph.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/TestGraph.java	Fri Sep 26 00:36:20 2003
***************
*** 0 ****
--- 1,16 ----
+ package org.tekkotsu.mon;
+ import javax.swing.*;
+ 
+ public class TestGraph {
+   public static void main(String args[]) {
+     JFrame frame=new JFrame("graph test");
+     GraphCanvas canvas=new GraphCanvas(0.0f, 1.0f);
+     frame.setSize(500,300);
+     frame.show();
+     frame.getContentPane().add(canvas);
+     while (true) {
+       canvas.registerValue((float)Math.random());
+       try { Thread.sleep(10); } catch (InterruptedException ex) {}
+     }
+   }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/TextListener.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/TextListener.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/TextListener.java	Wed Oct  1 22:08:08 2003
***************
*** 0 ****
--- 1,56 ----
+ package org.tekkotsu.mon;
+ 
+ import java.io.InputStreamReader;
+ import java.io.BufferedReader;
+ import java.io.PrintStream;
+ import java.net.Socket;
+ 
+ public class TextListener extends TCPListener {
+   String _data="";
+   PrintStream _out;
+ 
+   public void connected(Socket socket) {
+     _isConnected=true;
+     try {
+       BufferedReader in=new BufferedReader(new InputStreamReader(
+                           socket.getInputStream()));
+       _out=new PrintStream(socket.getOutputStream());
+       while (true) {
+         String read=in.readLine();
+         if (read==null) break;
+         synchronized (_data) { _data=_data+read+"\n"; }
+       }
+     } catch (Exception ex) { }
+ 
+     try { socket.close(); } catch (Exception ex) { }
+     _isConnected=false;
+   }
+  
+   public boolean hasData() {
+     return _data.length()!=0;
+   }
+ 
+   public String getData() {
+     String ret;
+     synchronized (_data) { 
+       ret=_data;
+       _data="";
+     }
+     return ret;
+   }
+ 
+   public void write(String s) {
+     if (_isConnected) {
+       _out.print(s);
+       _out.flush();
+     }
+   }
+ 
+   public boolean isConnected() {
+     return _isConnected;
+   }
+ 
+   public TextListener() { super(); }
+   public TextListener(int port) { super(port); }
+   public TextListener(String host, int port) { super(host,port); }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/TextWatchableMemory.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/TextWatchableMemory.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/TextWatchableMemory.java	Fri Sep 26 00:36:21 2003
***************
*** 0 ****
--- 1,42 ----
+ package org.tekkotsu.mon;
+ 
+ import javax.swing.*;
+ import javax.swing.event.*;
+ import javax.swing.table.*;
+ import java.awt.*;
+ import java.awt.event.*;
+ import java.util.*;
+ 
+ public class TextWatchableMemory {
+   WatchableMemoryListener listener;
+ 
+   public static void main(String args[]) {
+     if (args.length>1) {
+       System.out.println("usage: java TextWatchableMemory [host]");
+       System.exit(1);
+     }
+ 
+     try {
+       DogConfig dogConfig=new DogConfig (args);
+       TextWatchableMemory watchableMemory=new TextWatchableMemory(
+         dogConfig.getIP(),
+         Integer.parseInt(dogConfig.getValue("Main", "wmmonitor_port")));
+     } catch (IllegalArgumentException ex) {}
+   }
+ 
+   public TextWatchableMemory(String ip, int port) {
+     listener=new WatchableMemoryListener(ip, port);
+ 
+     while (true) {
+       if (listener.isConnected() && listener.hasData()) {
+         System.out.println(listener.getData());
+       } else {
+         sleep(1);
+       }
+     }
+   }
+ 
+   void sleep(long ms) {
+     try { Thread.sleep(ms); } catch (Exception e) {}
+   }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/UDPListener.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/UDPListener.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/UDPListener.java	Wed Oct  1 22:08:08 2003
***************
*** 0 ****
--- 1,32 ----
+ package org.tekkotsu.mon;
+ 
+ import java.net.DatagramSocket;
+ 
+ public abstract class UDPListener extends Listener {
+   public abstract void connected(DatagramSocket socket);
+ 
+   public void runServer() {
+     try {
+       _socket=new DatagramSocket(_port);
+       connected(_socket);
+     } catch (Exception ex) {
+       System.out.println("port "+_port+": "+ex);
+     }
+   }
+ 
+   public void runConnect() {
+     try {
+       _socket=new DatagramSocket();
+       connected(_socket);
+     } catch (Exception ex) { }
+   }
+ 
+   public void close() {
+   }
+ 
+   public UDPListener() { super(); }
+   public UDPListener(int port) { super(port); }
+   public UDPListener(String host, int port) { super(host, port); }
+ 
+   DatagramSocket _socket;
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/VisionGUI.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/VisionGUI.java:1.3
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/VisionGUI.java	Wed Oct  8 01:25:57 2003
***************
*** 0 ****
--- 1,388 ----
+ package org.tekkotsu.mon;
+ 
+ import java.awt.event.*;
+ import javax.swing.*;
+ import java.lang.String;
+ import java.util.LinkedList;
+ import java.awt.*;
+ import javax.imageio.ImageIO;
+ import java.awt.image.BufferedImage;
+ import java.awt.image.IndexColorModel;
+ import java.util.Date;
+ import java.io.PrintWriter;
+ import java.io.FileOutputStream;
+ import java.util.prefs.Preferences;
+ import java.io.File;
+ 
+ 
+ public class VisionGUI extends JFrame implements ActionListener, VisionUpdatedListener {
+ 	VisionPanel vision;
+ 	JCheckBox aspectBut;
+ 	JButton freezeBut;
+ 	JButton saveImageBut;
+ 	JLabel status;
+ 	JButton reconnectBut;
+ 	float mspf=0;
+ 	float mspfGamma=.9f;
+ 	long lastFrameTime=0;
+ 	boolean isRaw=false;
+ 	boolean isRLE=false;
+ 	boolean connected=false;
+ 	boolean isFreezeFrame=false;
+ 	final static ImageIcon carrows = new ImageIcon("images/chasingarrows.png");
+ 	ImageSequenceWriterThread imgWrite=null;
+ 	String state="Connecting...";
+ 	static Preferences prefs = Preferences.userNodeForPackage(VisionGUI.class);
+ 
+ 	public class StatusUpdateThread extends Thread {
+ 		VisionGUI gui;
+ 		public StatusUpdateThread(VisionGUI gui) { super("StatusUpdate"); this.gui=gui; setDaemon(true);}
+ 		public void run() {
+ 			VisionListener l=gui.vision.getListener();
+ 			while(true) {
+ 				String status=gui.state;
+ 				String recording=recordReport();
+ 				String fps=fpsReport();
+ 				if(fps.length()>0)
+ 					status+=" - "+fps;
+ 				if(recording.length()>0)
+ 					status+="; "+recording;
+ 				gui.status.setText(status);
+ 				try {
+ 					sleep(100);
+ 				} catch(Exception ex) {break;}
+ 			}
+ 		}
+ 		public String recordReport() {
+ 			if(gui.imgWrite!=null && !gui.imgWrite.isAlive())
+ 				gui.imgWrite=null;
+ 			if(gui.imgWrite!=null && !gui.imgWrite.stopping) {
+ 				String ans;
+ 				if(!gui.imgWrite.stopping) {
+ 					ans="Rec: ";
+ 					if(imgWrite.imgBufs.size()!=0)
+ 						ans+="Free="+imgWrite.imgBufs.size();
+ 				} else
+ 					ans="Writing";
+ 				ans+=" Queue="+imgWrite.q.size();
+ 				return ans;
+ 			} else
+ 				return "";
+ 		}
+ 		public String fpsReport() {
+ 				if(connected) {
+ 					int rnd=(int)(10000/gui.mspf);
+ 					return rnd/10.0f+" fps";
+ 				} else
+ 					return "";
+ 		}
+ 	}
+ 	
+ 	public static void main(String s[]) {
+ 		int port=-1;
+ 		if(s.length<2)
+ 			usage();
+ 		if(s[1].toUpperCase().compareTo("RLE")==0)
+ 			port=VisionRleListener.defPort;
+ 		else if(s[1].toUpperCase().compareTo("RAW")==0)
+ 			port=VisionRawListener.defPort;
+ 		else {
+ 			System.err.println("VisionGUI: Unrecognized format: "+s[1]);
+ 			usage();
+ 		}
+ 		if(s.length>2)
+ 			port=Integer.parseInt(s[2]);
+ 		String[] args=new String[1];
+ 		args[0]=s[1];
+ 		VisionGUI gui=new VisionGUI(s[0],port,args);
+ 		gui.addWindowListener(new WindowAdapter() {
+ 				public void windowClosing(WindowEvent e) { System.exit(0); } });
+ 		gui.show();
+ 	}
+ 		
+ 	public static void usage() {
+ 		System.out.println("Usage: java VisionGUI host (RLE|raw) [port]");
+ 		System.out.println("       if port is not specified, it defaults to:");
+ 		System.out.println("       "+VisionRawListener.defPort+" for raw");
+ 		System.out.println("       "+VisionRleListener.defPort+" for RLE.");
+ 		System.exit(2);
+ 	}
+ 			
+ 	public void actionPerformed(ActionEvent e) {
+ 		if(e.getActionCommand().compareTo("YUV")==0) {
+ 			VisionRaw v=(VisionRaw)vision;
+ 			if(v!=null)
+ 				v.setConvertRGB(false);
+ 		} else if(e.getActionCommand().compareTo("RGB")==0) {
+ 			VisionRaw v=(VisionRaw)vision;
+ 			if(v!=null)
+ 				v.setConvertRGB(true);
+ 		} else if(e.getActionCommand().compareTo("freeze")==0) {
+ 			isFreezeFrame=!isFreezeFrame;
+ 			if(!isFreezeFrame) {
+ 				state="Reconnecting...";
+ 				vision.open();
+ 			} else {
+ 				state="Disconnecting...";
+ 				vision.close();
+ 			}
+ 		} else if(e.getActionCommand().compareTo("aspect")==0) {
+ 			vision.setLockAspectRatio(((JCheckBox)e.getSource()).isSelected());
+ 		} else if(e.getActionCommand().compareTo("seq")==0) {
+ 			File cursavepath = new File(prefs.get("cursavepath",""));
+ 			JFileChooser dia=new JFileChooser(cursavepath);
+ 			dia.setDialogTitle("Save Image Sequence...");
+ 			Component cur=this;
+ 			while(cur.getParent()!=null)
+ 				cur=cur.getParent();
+ 			if(dia.showSaveDialog(cur)==JFileChooser.APPROVE_OPTION) {
+ 				prefs.put("cursavepath",dia.getCurrentDirectory().getPath());
+ 				imgWrite=new ImageSequenceWriterThread(vision.getListener(), saveImageBut);
+ 				saveImageBut.setText("Stop Saving Sequence");
+ 				saveImageBut.setToolTipText("Click to stop buffering new frames - already captured frames will continue to be written (unless you close the window)");
+ 				saveImageBut.setActionCommand("stopseq");
+ 				String base=dia.getSelectedFile().getName();
+ 				String format;
+ 				if(base.lastIndexOf('.')==-1) {
+ 					format="png";
+ 				} else {
+ 					int i=base.lastIndexOf(".");
+ 					format=base.substring(i+1);
+ 					base=base.substring(0,i);
+ 				}
+ 				int first=base.indexOf('#');
+ 				int last=base.lastIndexOf('#');
+ 				boolean appendTime=(first==-1);
+ 				imgWrite.setDirectory(dia.getSelectedFile().getParent());
+ 				if(first!=-1)
+ 					imgWrite.setName(base.substring(0,first),last-first+1,base.substring(last+1),format);
+ 				else
+ 					imgWrite.setName(base,0,"",format);
+ 				imgWrite.start();
+ 			}
+ 		} else if(e.getActionCommand().compareTo("stopseq")==0) {
+ 			saveImageBut.setText("Save Image Sequence");
+ 			saveImageBut.setToolTipText("Saves to a series of files - use .jpg or .png extension to choose format; #'s will be replaced with index, otherwise timecode is appended");
+ 			saveImageBut.setActionCommand("seq");
+ 			imgWrite.interrupt();
+ 		} else if(e.getActionCommand().compareTo("img")==0) {
+ 			File cursavepath = new File(prefs.get("cursavepath",""));
+ 			JFileChooser dia=new JFileChooser(cursavepath);
+ 			dia.setDialogTitle("Save Image Sequence...");
+ 			Component cur=this;
+ 			while(cur.getParent()!=null)
+ 				cur=cur.getParent();
+ 			if(dia.showSaveDialog(cur)==JFileChooser.APPROVE_OPTION) {
+ 				prefs.put("cursavepath",dia.getCurrentDirectory().getPath());
+ 				String base=dia.getSelectedFile().getName();
+ 				String format;
+ 				if(base.lastIndexOf('.')==-1) {
+ 					format="png";
+ 				} else {
+ 					int i=base.lastIndexOf(".");
+ 					format=base.substring(i+1);
+ 					base=base.substring(0,i);
+ 				}
+ 				try {
+ 					ImageIO.write(vision.getListener().getImage(),format,new FileOutputStream(dia.getSelectedFile().getParent()+File.separator+base+"."+format));
+ 				} catch(Exception ex) {}
+ 			}
+ 		} else if(e.getSource()==reconnectBut) {
+ 			vision.close();
+ 			vision.open();
+ 		}
+ 	}
+ 
+ 	class CloseVisionAdapter extends WindowAdapter {
+ 		VisionGUI gui;
+ 		CloseVisionAdapter(VisionGUI gui) {this.gui=gui;}
+ 		public void windowClosing(WindowEvent e) {
+ 			String name="VisionGUI"+(isRaw?".raw":"")+(isRLE?".rle":"")+".location";
+ 			prefs.putInt(name+".x",getLocation().x+getInsets().left);
+ 			prefs.putInt(name+".y",getLocation().y+getInsets().top);
+ 			gui.vision.close();
+ 			if(gui.imgWrite!=null && gui.imgWrite.isAlive()) {
+ 				if(!gui.imgWrite.isInterrupted() && !gui.imgWrite.stopping)
+ 					gui.imgWrite.interrupt();
+ 				while(gui.imgWrite.isInterrupted())
+ 					try { Thread.sleep(50); } catch(Exception ex) {}
+ 				if(!gui.imgWrite.stopping)
+ 					System.out.println("imgWrite refuses to stop");
+ 				gui.imgWrite.interrupt(); //this second one should kill it
+ 				while(gui.imgWrite.isAlive())
+ 					try { Thread.sleep(50); } catch(Exception ex) {}
+ 			}
+ 		}
+ 	}
+ 
+ 	public void visionUpdated(VisionListener l) {
+ 		if(l.isConnected()!=connected) {
+ 			connected=l.isConnected();
+ 			if(connected) {
+ 				freezeBut.setEnabled(true);
+ 				freezeBut.setText("Freeze Frame");
+ 				freezeBut.setToolTipText("Freezes current frame (disconnects from stream)");
+ 				isFreezeFrame=false;
+ 				saveImageBut.setEnabled(true);
+ 				saveImageBut.setText("Save Image Sequence");
+ 				saveImageBut.setToolTipText("Saves to a series of files - use .jpg or .png extension to choose format; #'s will be replaced with index, otherwise timecode is appended");
+ 				saveImageBut.setActionCommand("seq");
+ 				state="Connected.";
+ 			} else {
+ 				if(vision._image==null)
+ 					saveImageBut.setEnabled(false);
+ 				else {
+ 					saveImageBut.setText("Save Image");
+ 					saveImageBut.setToolTipText("Save current image shown - use .jpg or .png extension to choose format");
+ 					saveImageBut.setActionCommand("img");
+ 				}
+ 				if(isFreezeFrame) {
+ 					state="Disconnected.";
+ 					freezeBut.setText("Unfreeze");
+ 					freezeBut.setToolTipText("Reconnects to stream");
+ 				} else {
+ 					state="Reconnecting...";
+ 					freezeBut.setEnabled(false);
+ 				}
+ 			}
+ 		}
+ 		if(connected) {
+ 			if(lastFrameTime==0) {
+ 				if(l.getTimeStamp()!=null)
+ 					lastFrameTime=l.getTimeStamp().getTime();
+ 			} else {
+ 				long cur=l.getTimeStamp().getTime();
+ 				mspf=mspf*mspfGamma+(cur-lastFrameTime)*(1-mspfGamma);
+ 				lastFrameTime=cur;
+ 			}
+ 		} else {
+ 			lastFrameTime=0;
+ 		}
+ 	}
+ 	
+ 	public VisionGUI(String host, String[] args) {
+ 		super();
+ 		int port=-1;
+ 		for(int i=0; i<args.length; i++) {
+ 			if(args[i].toUpperCase().compareTo("RLE")==0) {
+ 				isRLE=true;
+ 				isRaw=false;
+ 			} else if(args[i].toUpperCase().compareTo("RAW")==0) {
+ 				isRaw=true;
+ 				isRLE=false;
+ 			} else
+ 				System.err.println("VisionGUI: Unrecognized argument: "+args[0]);
+ 		}
+ 		if(isRLE)
+ 			port=VisionRleListener.defPort;
+ 		else if(isRaw)
+ 			port=VisionRawListener.defPort;
+ 		init(host,port,args);
+ 	}
+ 	public VisionGUI(String host, int port, String[] args) {
+ 		super();
+ 		init(host,port,args);
+ 	}
+ 	public void init(String host, int port, String[] args) {
+ 		int strutsize=10;
+ 		int sepsize=5;
+ 		getContentPane().setLayout(new BorderLayout());
+ 		getContentPane().add(Box.createVerticalStrut(strutsize),BorderLayout.NORTH);
+ 		getContentPane().add(Box.createHorizontalStrut(strutsize),BorderLayout.WEST);
+ 		getContentPane().add(Box.createHorizontalStrut(strutsize),BorderLayout.EAST);
+ 		//always use RLE size for default - we'll assume it's full resolution
+ 		vision=null;
+ 		for(int i=0; i<args.length; i++) {
+ 			if(args[i].toUpperCase().compareTo("RLE")==0) {
+ 				setTitle("TekkotsuMon: Vision RLE");
+ 				vision=new VisionRle(new VisionRleListener(host,port));
+ 				isRLE=true;
+ 				isRaw=false;
+ 			} else if(args[i].toUpperCase().compareTo("RAW")==0) {
+ 				setTitle("TekkotsuMon: Vision Raw");
+ 				vision=new VisionRaw(new VisionRawListener(host,port));
+ 				isRaw=true;
+ 				isRLE=false;
+ 			} else
+ 				System.err.println("VisionGUI: Unrecognized argument: "+args[i]);
+ 		}
+ 		if(vision==null) {
+ 			System.err.println("VisionGUI: Error: Vision mode not specified");
+ 		} else {
+ 			vision.setMinimumSize(new Dimension(VisionRleListener.width/2, VisionRleListener.height/2));
+ 			vision.setPreferredSize(new Dimension(VisionRleListener.width*2, VisionRleListener.height*2));
+ 			vision.setLockAspectRatio(true);
+ 			getContentPane().add(vision,BorderLayout.CENTER);
+ 		}
+ 		{
+ 			Box tmp2=Box.createHorizontalBox();
+ 			tmp2.add(Box.createHorizontalStrut(strutsize));
+ 			{
+ 				Box tmp3=Box.createVerticalBox();
+ 				if(isRaw) {
+ 					Box tmp4=Box.createHorizontalBox();
+ 					ButtonGroup group=new ButtonGroup();
+ 					JRadioButton tmpRad;
+ 					tmpRad=new JRadioButton("RGB");
+ 					tmpRad.setSelected(true);
+ 					tmpRad.addActionListener(this);
+ 					tmpRad.setToolTipText("Shows RGB colorspace");
+ 					group.add(tmpRad);
+ 					tmp4.add(tmpRad);
+ 					tmpRad=new JRadioButton("YUV");
+ 					tmpRad.addActionListener(this);
+ 					tmpRad.setToolTipText("Shows YUV colorspace");
+ 					group.add(tmpRad);
+ 					tmp4.add(tmpRad);
+ 					tmp3.add(tmp4);
+ 				}
+ 				aspectBut=new JCheckBox("Lock 11:9 aspect");
+ 				aspectBut.setAlignmentX(0.5f);
+ 				aspectBut.addActionListener(this);
+ 				aspectBut.setActionCommand("aspect");
+ 				aspectBut.setSelected(true);
+ 				aspectBut.setToolTipText("Forces displayed image to hold transmitted image's aspect ratio");
+ 				tmp3.add(aspectBut);
+ 				freezeBut=new JButton("Freeze Frame");
+ 				freezeBut.setAlignmentX(0.5f);
+ 				freezeBut.addActionListener(this);
+ 				freezeBut.setActionCommand("freeze");
+ 				freezeBut.setEnabled(false);
+ 				freezeBut.setToolTipText("Freezes current frame (disconnects from stream)");
+ 				tmp3.add(freezeBut);
+ 				saveImageBut=new JButton("Save Image Sequence");
+ 				saveImageBut.setAlignmentX(0.5f);
+ 				saveImageBut.addActionListener(this);
+ 				saveImageBut.setActionCommand("seq");
+ 				saveImageBut.setEnabled(false);
+ 				saveImageBut.setToolTipText("Saves to a series of files - use .jpg or .png extension to choose format; #'s will be replaced with index, otherwise timecode is appended");
+ 				tmp3.add(saveImageBut);
+ 				tmp3.add(Box.createVerticalStrut(strutsize));
+ 				tmp3.add(new JSeparator());
+ 				tmp3.add(Box.createVerticalStrut(strutsize-sepsize));
+ 				{
+ 					Box tmp4=Box.createHorizontalBox();
+ 					tmp4.add(status=new JLabel(state));
+ 					tmp4.add(Box.createHorizontalGlue());
+ 					reconnectBut=new JButton(carrows);
+ 					reconnectBut.setPreferredSize(new Dimension(carrows.getIconWidth(),carrows.getIconHeight()));
+ 					reconnectBut.addActionListener(this);
+ 					reconnectBut.setToolTipText("Drop current connection and try again.");
+ 					tmp4.add(reconnectBut);
+ 					tmp3.add(tmp4);
+ 				}
+ 				tmp3.add(Box.createVerticalStrut(strutsize));
+ 				tmp2.add(tmp3);
+ 			}
+ 			tmp2.add(Box.createHorizontalStrut(strutsize));
+ 			getContentPane().add(tmp2,BorderLayout.SOUTH);
+ 		}
+ 		pack();
+ 		addWindowListener(new CloseVisionAdapter(this));
+ 		vision.getListener().addListener(this);
+ 		(new StatusUpdateThread(this)).start();
+ 		
+ 		String name="VisionGUI"+(isRaw?".raw":"")+(isRLE?".rle":"")+".location";
+ 		setLocation(prefs.getInt(name+".x",50),prefs.getInt(name+".y",50));
+ 	}
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/VisionListener.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/VisionListener.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/VisionListener.java	Fri Sep 26 00:36:21 2003
***************
*** 0 ****
--- 1,34 ----
+ package org.tekkotsu.mon;
+ 
+ import java.awt.image.BufferedImage;
+ import java.util.Vector;
+ import java.util.Date;
+ 
+ public abstract class VisionListener extends TCPListener {
+ 	boolean updatedFlag;
+ 	Date timestamp;
+ 
+ 	Vector listeners = new Vector();
+ 	void addListener(VisionUpdatedListener l) { listeners.add(l); }
+ 	void removeListener(VisionUpdatedListener l) { listeners.remove(l); }
+ 	void fireVisionUpdate() {
+ 		updatedFlag=true;
+ 		for(int i=0; i<listeners.size(); i++)
+ 			((VisionUpdatedListener)listeners.get(i)).visionUpdated(this);
+ 	}
+ 
+ 	public abstract BufferedImage getImage();
+ 	public Date getTimeStamp() { return timestamp; }
+ 
+ 	public boolean hasData() {
+ 		return updatedFlag;
+ 	}
+  
+ 	public boolean isConnected() {
+ 		return _isConnected;
+ 	}
+ 
+ 	public VisionListener() { super(); }
+ 	public VisionListener(int port) { super(port); }
+ 	public VisionListener(String host, int port) { super(host,port); }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/VisionPanel.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/VisionPanel.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/VisionPanel.java	Fri Sep 26 00:36:21 2003
***************
*** 0 ****
--- 1,99 ----
+ package org.tekkotsu.mon;
+ 
+ import javax.swing.JPanel;
+ import java.awt.image.BufferedImage;
+ import java.awt.Graphics;
+ import java.awt.Color;
+ import java.awt.Dimension;
+ import java.awt.FontMetrics;
+ 
+ public class VisionPanel extends JPanel implements VisionUpdatedListener {
+ 	BufferedImage _image;
+ 	VisionListener _listener;
+ 	boolean lockAspect=false;
+ 	static float defAspectRatio=176/(float)144;
+ 	float tgtAspect=defAspectRatio;
+ 
+ 	protected VisionPanel(VisionListener listener) {
+ 		_listener=listener;
+ 		_listener.addListener(this);
+ 		setBackground(Color.BLACK);
+ 		setForeground(Color.WHITE);
+ 		setOpaque(!lockAspect);
+ 	}
+ 	
+ 	public VisionListener getListener() { return _listener; }
+ 	
+ 	public void close() {
+ 		_listener.kill();
+ 	}
+ 	
+ 	public void open() {
+ 		_listener.startThread();
+ 	}
+ 
+ 	public void visionUpdated(VisionListener l) {
+ 		repaint();
+ 	}
+ 	
+ 	public void setLockAspectRatio(boolean b) {
+ 		if(b!=lockAspect) {
+ 			lockAspect=b;
+ 			setOpaque(!lockAspect);
+ 			repaint();
+ 		}
+ 	}
+ 	
+ 	public boolean getLockAspectRatio() { return lockAspect; }
+ 
+ 	public void setAspectRatio(float asp) {
+ 		if(asp<=0)
+ 			tgtAspect=defAspectRatio;
+ 		else
+ 			tgtAspect=asp;
+ 		if(getLockAspectRatio())
+ 			repaint();
+ 	}
+ 	
+ 	public float getAspectRatio() { return tgtAspect; }
+ 
+ 	public void setLockAspectRatio(boolean b, float asp) {
+ 		setLockAspectRatio(b);
+ 		setAspectRatio(asp);
+ 	}
+ 	
+ 	public void paint(Graphics graphics) {
+ 		_image=_listener.getImage();
+ 		super.paint(graphics);
+ 		Dimension sz=getSize();
+ 		if(getLockAspectRatio()) {
+ 			float curasp=sz.width/(float)sz.height;
+ 			float tgtasp=getAspectRatio();
+ 			if(curasp>tgtasp) {
+ 				int width=(int)(sz.height*tgtasp);
+ 				drawImage(graphics,_image, (sz.width-width)/2, 0, width, sz.height);
+ 			} else if(curasp<tgtasp) {
+ 				int height=(int)(sz.width/tgtasp);
+ 				drawImage(graphics,_image, 0, (sz.height-height)/2, sz.width, height);
+ 			} else {
+ 				drawImage(graphics,_image, 0, 0, sz.width, sz.height);
+ 			}
+ 		} else
+ 			drawImage(graphics,_image, 0, 0, sz.width, sz.height);
+ 	}
+ 	
+ 	protected void drawImage(Graphics g, BufferedImage img, int x, int y, int w, int h) {
+ 		if(img!=null)
+ 			g.drawImage(img,x,y,w,h,null);
+ 		else {
+ 			g.setColor(getBackground());
+ 			g.fillRect(x,y,w,h);
+ 			FontMetrics tmp=g.getFontMetrics();
+ 			String msg="No image";
+ 			int strw=tmp.stringWidth(msg);
+ 			int strh=tmp.getHeight();
+ 			g.setColor(getForeground());
+ 			g.drawString(msg,(getSize().width-strw)/2,(getSize().height-strh)/2+tmp.getAscent());
+ 		}
+ 	}
+ }
\ No newline at end of file
Index: AiboPup/tools/mon/org/tekkotsu/mon/VisionRaw.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/VisionRaw.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/VisionRaw.java	Fri Sep 26 00:36:21 2003
***************
*** 0 ****
--- 1,39 ----
+ package org.tekkotsu.mon;
+ 
+ import java.awt.image.*;
+ import java.awt.*;
+ import javax.swing.*;
+ import java.awt.event.*;
+ 
+ public class VisionRaw extends VisionPanel {
+ 	VisionRawListener _visionraw;
+ 	
+ 	public static void main(String s[]) {
+ 		int port=VisionRawListener.defPort;
+ 		if(s.length<1) {
+ 			System.out.println("Usage: java VisionRaw host [port]");
+ 			System.out.println("			 if port is not specified, it defaults to "+port);
+ 			System.exit(2);
+ 		}
+ 		if(s.length>1)
+ 			port=Integer.parseInt(s[1]);
+ 		JFrame frame=new JFrame("TekkotsuMon: Vision Raw");
+ 		frame.setBackground(Color.black);
+ 		//frame.getContentPane().setLayout(new FlowLayout());
+ 		frame.setSize(new Dimension(VisionRawListener.width*2, VisionRawListener.height*2)); 
+ 		VisionRaw vision=new VisionRaw(new VisionRawListener(s[0],port));
+ 		frame.getContentPane().add(vision);
+ 		frame.addWindowListener(new WindowAdapter() {
+ 				public void windowClosing(WindowEvent e) { System.exit(0); } });
+ 		frame.show();
+ 	}
+ 
+ 	public VisionRaw(VisionRawListener visionraw) {
+ 		super(visionraw);
+ 		_visionraw=visionraw;
+ 	}
+ 
+ 	public void setConvertRGB(boolean b) { _visionraw.setConvertRGB(b); }
+ 	public boolean getConvertRGB(boolean b) { return _visionraw.getConvertRGB(); }
+ }
+ 
Index: AiboPup/tools/mon/org/tekkotsu/mon/VisionRawListener.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/VisionRawListener.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/VisionRawListener.java	Wed Oct  1 22:08:08 2003
***************
*** 0 ****
--- 1,226 ----
+ package org.tekkotsu.mon;
+ 
+ import java.io.InputStream;
+ import java.net.Socket;
+ import javax.swing.JFrame;
+ import java.awt.Image;
+ import java.awt.image.BufferedImage;
+ import java.util.Date;
+ 
+ public class VisionRawListener extends VisionListener {
+ 	int channels=3;
+ 	static int width=176;
+ 	static int height=144;
+ 	int pktSize=width*height*channels;
+   int oldformat=PACKET_VISIONRAW_FULL;
+   int format;
+ 
+ 	byte[] _data=new byte[pktSize];
+ 	byte[] _outd=new byte[pktSize];
+ 	int[] _pixels=new int[width*height];;
+ 	BufferedImage img=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
+ 	int bytesRead;
+ 	boolean convertRGB=true;
+ 	static int defPort=10011;
+ 
+   Object packetFormatChangeLock=new Object();;
+ 
+ 	public void connected(Socket socket) {
+ 		_isConnected=true;
+ 		fireVisionUpdate();
+ 		try {
+ 			InputStream in=socket.getInputStream();
+ 			_isConnected=true;
+ 			while (true) {
+         format=readInt(in);
+         int timest=readInt(in);
+ 
+         if (format!=oldformat) {
+           synchronized (packetFormatChangeLock) {
+             switch (format) {
+               case PACKET_VISIONRAW_HALF:
+                 width=88;
+                 height=72;
+                 channels=3;
+                 pktSize=88*72*3;
+                 break;
+               case PACKET_VISIONRAW_FULL:
+                 width=176;
+                 height=144;
+                 channels=3;
+                 pktSize=176*144*3;
+                 break;
+               case PACKET_VISIONRAW_YFULL_UVHALF:
+                 width=176;
+                 height=144;
+                 channels=3;
+                 pktSize=(176*144*3)/2;
+                 break;
+               default:
+                 System.err.println("VisionRawListener: unknown packet type");
+                 throw new java.lang.NoSuchFieldException("fake exception");
+             }
+ 
+             _data=new byte[pktSize];
+             _outd=new byte[pktSize];
+             _pixels=new int[width*height];;
+             img=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
+             oldformat=format;
+           }
+         }
+ 
+ 				int br;
+ 				bytesRead=0;
+ 
+ 				while(bytesRead<pktSize) {
+ 					br=in.read(_data,bytesRead,(pktSize-bytesRead>1024)?1024:(pktSize-bytesRead));
+ 					bytesRead=bytesRead+br;
+ 				}
+ 				synchronized(_outd) {
+ 					byte[] temp=_data;
+ 					_data=_outd;
+ 					_outd=temp;
+ 					timestamp=new Date();
+ 				}
+ 				fireVisionUpdate();
+ 			}
+ 		} catch (Exception ex) { }
+ 		
+ 		try { socket.close(); } catch (Exception ex) { }
+ 		_isConnected=false;
+ 		fireVisionUpdate();
+ 	}
+ 	
+ 	public byte[] getData() {
+ //		frameTimer();
+ 		synchronized (_outd) {
+ 			updatedFlag=false;
+ 			return _outd;
+ 		}
+ 	}
+ 
+ 	public void setConvertRGB(boolean b) { 
+ 		if(b!=convertRGB) {
+ 			convertRGB=b;
+ 			updatedFlag=true;
+ 			for(int i=0; i<listeners.size(); i++)
+ 				((VisionUpdatedListener)listeners.get(i)).visionUpdated(this);
+ 		}
+ 	}
+ 	public boolean getConvertRGB() { return convertRGB; }
+ 
+ 	public int[] getYUVPixels() {
+ 		synchronized(packetFormatChangeLock) {
+ 			byte[] data=getData();
+       if (format==PACKET_VISIONRAW_HALF || format==PACKET_VISIONRAW_FULL) {
+         int offset=0;
+         for (int i=0; i<width*height; i++) {
+           int y=(int)data[offset++]&0xFF;
+           int u=(int)data[offset++]&0xFF;
+           int v=(int)data[offset++]&0xFF;
+           _pixels[i]=(255<<24) | (y<<16) | (u<<8) | v;
+         }
+       } else if (format==PACKET_VISIONRAW_YFULL_UVHALF) {
+         int i_offset=0, o_offset=0;
+         for (int y=0; y<height; y+=2) {
+           for (int x=0; x<width; x+=2) {
+             int y1=(int)data[i_offset++]&0xFF;
+             int u=(int)data[i_offset++]&0xFF;
+             int v=(int)data[i_offset++]&0xFF;
+             int y2=(int)data[i_offset++]&0xFF;
+             _pixels[o_offset]=(255<<24) | (y1<<16) | (u<<8) | v;
+             _pixels[o_offset+width]=(255<<24) | (u<<8) | v;
+             o_offset++;
+             _pixels[o_offset]=(255<<24) | (y2<<16) | (u<<8) | v;
+             _pixels[o_offset+width]=(255<<24) | (u<<8) | v;
+             o_offset++;
+           }
+           for (int x=0; x<width; x++) {
+             int y1=(int)data[i_offset++]&0xFF;
+             _pixels[o_offset++]|=y1<<16;
+           }
+         }
+       }
+ 		}
+ 		return _pixels;
+ 	}
+ 
+ 	public int[] getRGBPixels() {
+ 		synchronized(packetFormatChangeLock) {
+ 			byte[] data=getData();
+       if (format==PACKET_VISIONRAW_HALF || format==PACKET_VISIONRAW_FULL) {
+         int offset=0;
+         for (int i=0; i<width*height; i++) {
+           int y=(int)data[offset++]&0xFF;
+           int u=(int)data[offset++]&0xFF;
+           int v=(int)data[offset++]&0xFF;
+           _pixels[i]=pixelYUV2RGB(y, u, v);
+         }
+       } else if (format==PACKET_VISIONRAW_YFULL_UVHALF) {
+         int i_offset=0, o_offset=0;
+         for (int y=0; y<height; y+=2) {
+           for (int x=0; x<width; x+=2) {
+             int y1=(int)data[i_offset++]&0xFF;
+             int u=(int)data[i_offset++]&0xFF;
+             int v=(int)data[i_offset++]&0xFF;
+             int y2=(int)data[i_offset++]&0xFF;
+             _pixels[o_offset]=pixelYUV2RGB(y1, u, v);
+             _pixels[o_offset+width]=(255<<24) | (u<<8) | v;
+             o_offset++;
+             _pixels[o_offset]=pixelYUV2RGB(y1, u, v);
+             _pixels[o_offset+width]=(255<<24) | (u<<8) | v;
+             o_offset++;
+           }
+           for (int x=0; x<width; x++) {
+             int y1=(int)data[i_offset++]&0xFF;
+             _pixels[o_offset]|=y1<<16;
+             _pixels[o_offset]=pixelYUV2RGB(_pixels[o_offset]);
+             o_offset++;
+           }
+         }
+       }
+ 		}
+ 		return _pixels;
+ 	}
+ 
+   static final int pixelYUV2RGB(int y, int u, int v) {
+     u=u*2-255;
+     v=v*2-255;
+     int r=y+u;
+     int b=y+v;
+     u=u>>1;
+     v=(v>>2)-(v>>4);
+     int g=y-u-v;
+     if (r<0) r=0; if (g<0) g=0; if (b<0) b=0;
+     if (r>255) r=255; if (g>255) g=255; if (b>255) b=255;
+ 
+     return (255<<24) | (r<<16) | (g<<8) | b;
+   }
+ 
+   static final int pixelYUV2RGB(int yuv) {
+     int y=(yuv>>16)&0xff;
+     int u=(yuv>>8)&0xff;
+     int v=yuv&0xff;
+     u=u*2-255;
+     v=v*2-255;
+     int r=y+u;
+     int b=y+v;
+     u=u>>1;
+     v=(v>>2)-(v>>4);
+     int g=y-u-v;
+     if (r<0) r=0; if (g<0) g=0; if (b<0) b=0;
+     if (r>255) r=255; if (g>255) g=255; if (b>255) b=255;
+ 
+     return (255<<24) | (r<<16) | (g<<8) | b;
+   }
+ 
+ 	public BufferedImage getImage() {
+ 		int[] data=getConvertRGB()?getRGBPixels():getYUVPixels();
+ 		img.setRGB(0,0,width,height,data,0,width);
+ 		return img;
+ 	}
+ 	
+ 	public VisionRawListener() { super(); }
+ 	public VisionRawListener(int port) { super(port); }
+ 	public VisionRawListener(String host, int port) { super(host,port); }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/VisionRle.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/VisionRle.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/VisionRle.java	Fri Sep 26 00:36:21 2003
***************
*** 0 ****
--- 1,37 ----
+ package org.tekkotsu.mon;
+ 
+ import java.awt.image.*;
+ import java.awt.*;
+ import javax.swing.*;
+ import java.awt.event.*;
+ 
+ public class VisionRle extends VisionPanel {
+ 	VisionRleListener _visionrle;
+ 
+ 	public static void main(String[] s) { 
+ 		int port=VisionRleListener.defPort;
+ 		if(s.length<1) {
+ 			System.out.println("Usage: java VisionRLE host [port]");
+ 			System.out.println("			 if port is not specified, it defaults to "+port);
+ 			System.exit(2);
+ 		}
+ 		if(s.length>1)
+ 			port=Integer.parseInt(s[1]);
+ 		JFrame frame=new JFrame("TekkotsuMon: Vision Segmented");
+ 		frame.setBackground(Color.black);
+ 		//frame.getContentPane().setLayout(new FlowLayout());
+ 		frame.setSize(new Dimension(VisionRleListener.width, VisionRleListener.height)); 
+ 		VisionRle vision=new VisionRle(new VisionRleListener(s[0],port));
+ 		frame.getContentPane().add(vision);
+ 		frame.addWindowListener(new WindowAdapter() {
+ 				public void windowClosing(WindowEvent e) { System.exit(0); } });
+ 		frame.show();
+ 	}
+ 
+ 	public VisionRle(VisionRleListener visionrle) {
+ 		super(visionrle);
+ 		_visionrle=visionrle;
+ 	}
+ 	
+ }
+ 
Index: AiboPup/tools/mon/org/tekkotsu/mon/VisionRleListener.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/VisionRleListener.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/VisionRleListener.java	Wed Oct  1 22:08:08 2003
***************
*** 0 ****
--- 1,158 ----
+ package org.tekkotsu.mon;
+ 
+ import java.io.InputStream;
+ import java.net.Socket;
+ import java.awt.Image;
+ import java.awt.image.IndexColorModel;
+ import java.awt.image.BufferedImage;
+ import java.util.Date;
+ import java.io.*;
+ 
+ public class VisionRleListener extends VisionListener {
+ 	static int width=176;
+ 	static int height=144;
+ 	byte[] _data=new byte[width*height];
+ 	byte[] _outd=new byte[width*height];
+ 	static int defPort=10012;
+ 	static final boolean _debug=false;
+ 
+ 	//todo: read this from the same file the dog is using
+   String colorsFileName="default.col";
+ 	BufferedImage img;
+ 	
+ 	public void connected(Socket socket) {
+ 		_isConnected=true;
+ 		fireVisionUpdate();
+ 		try {
+ 			InputStream in=socket.getInputStream();
+ 			while (true) {
+ 				int size=readInt(in);
+ 				if(!_isConnected) break;
+ 				size=size*3;
+ 				readBytes(_data, in, size);
+ 				if(!_isConnected) break;
+ 				timestamp=new Date();
+ 				decodeRLE(size);
+ 				fireVisionUpdate();
+ 			}
+ 		} catch (Exception ex) { }
+ 
+ 		try { socket.close(); } catch (Exception ex) { }
+ 		_isConnected=false;
+ 		fireVisionUpdate();
+ 	}
+ 
+ 	void decodeRLE(int pktSize) {
+ 		int curx=0, cury=0;
+ 		int dlength=pktSize;
+ 		int dpos=0;
+ 
+ 		synchronized (_outd) {
+ 			for (; dlength>=3 && cury<height;) {
+ 				byte color;
+ 				color=_data[dpos++];
+ 				int x=b2i(_data[dpos++]);
+ 				int len=b2i(_data[dpos++]);
+ 				dlength-=3;
+ 				if (x < curx) {
+ 					if (_debug) System.out.println("backwards x movement");
+ 					break;
+ 				}
+ 
+ 				for (; curx < x; curx++)
+ 					_outd[cury*width+curx]=0;
+ 
+ 				if (curx+len>width) {
+ 					if (_debug) System.out.println("run past end");
+ 					break;
+ 				}
+ 
+ 				for (; len>0; len--, curx++)
+ 					_outd [cury*width+curx]=color;
+ 				if (curx==width) {
+ 					cury++;
+ 					curx=0;
+ 				}
+ 			}
+ 		}
+ 		if (cury!=height) {
+ 			if (_debug) System.out.println("early end of data\n");
+ 		}
+ 	}
+ 
+ 	public byte[] getData() {
+ //		frameTimer();
+ 		synchronized (_outd) {
+ 			updatedFlag=false;
+ 			return _outd;
+ 		}
+ 	}
+ 
+ 	public BufferedImage getImage() {
+ 		synchronized (_outd) {
+ 			byte[] data=getData();
+ 			img.getRaster().setDataElements(0,0,width,height,data);
+ 		}
+ 		return img;
+ 	}
+ 
+   void initCMAP() {
+     IndexColorModel cmodel=readColorModel(colorsFileName);
+     img=new BufferedImage(width,height,BufferedImage.TYPE_BYTE_INDEXED,cmodel);
+   }
+ 
+   IndexColorModel readColorModel(String colorsfile) {
+     int[] cmap=readColorMap(colorsfile);
+     if (cmap==null || cmap.length==0) return null;
+     byte[] byte_cmap=new byte[cmap.length*3];
+ 
+     for (int i=0; i<cmap.length; i++) {
+       byte_cmap[i*3]=(byte) ((cmap[i]>>16) & 0xff);
+       byte_cmap[i*3+1]=(byte) ((cmap[i]>>8) & 0xff);
+       byte_cmap[i*3+2]=(byte) (cmap[i] & 0xff);
+     }
+     IndexColorModel cmodel=new IndexColorModel(7, cmap.length, byte_cmap,
+                                                0, false);
+     return cmodel;
+   }
+ 
+   int[] readColorMap(String colorsfile) {
+     try {
+       BufferedReader reader=new BufferedReader(new FileReader(colorsfile));
+       int[] v=new int[32];
+       int vnum=0;
+       String s=reader.readLine();
+       while(s!=null) {
+         if (s.length()==0 || s.charAt(0)=='#') { s=reader.readLine(); continue;
+ }
+                                                                                 
+         int pos=Integer.parseInt(s.substring(0,s.indexOf(" ")));
+                                                                                 
+         String colorstr=s.substring(s.indexOf("(")+1, s.indexOf(")")).trim();
+         String[] colorarr=colorstr.split("\\s+");
+                                                                                 
+         int color=0;
+         color|=Integer.parseInt(colorarr[0])<<16;
+         color|=Integer.parseInt(colorarr[1])<<8;
+         color|=Integer.parseInt(colorarr[2]);
+                                                                                 
+         v[pos]=color;
+         if (pos>vnum) vnum=pos;
+         s=reader.readLine();
+       }
+       int[] colors=new int[vnum+1];
+       for (int i=0; i<=vnum; i++) {
+         colors[i]=v[i];
+       }
+       return colors;
+     } catch (Exception ex) {
+       System.out.println("Error reading file "+colorsfile+": "+ex);
+       return null;
+     }
+   }
+ 
+ 
+ 	public VisionRleListener() { super(); initCMAP(); }
+ 	public VisionRleListener(int port) { super(port); initCMAP(); }
+ 	public VisionRleListener(String host, int port) { super(host,port); initCMAP(); }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/VisionUpdatedListener.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/VisionUpdatedListener.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/VisionUpdatedListener.java	Fri Sep 26 00:36:21 2003
***************
*** 0 ****
--- 1,6 ----
+ package org.tekkotsu.mon;
+ 
+ public interface VisionUpdatedListener {
+ 	public void visionUpdated(VisionListener comm);
+ }
+ 
Index: AiboPup/tools/mon/org/tekkotsu/mon/WM2DMData.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/WM2DMData.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/WM2DMData.java	Fri Sep 26 00:36:22 2003
***************
*** 0 ****
--- 1,15 ----
+ package org.tekkotsu.mon;
+ 
+ // Data container for the WorldModel2 spherical depth map
+ 
+ public class WM2DMData {
+   public float[] DM_depth;
+   public float[] DM_confidence;
+   public int[] DM_color;
+ 
+   WM2DMData() {
+     DM_depth = new float[WorldModel2Conf.DM_CELL_COUNT];
+     DM_confidence = new float[WorldModel2Conf.DM_CELL_COUNT];
+     DM_color = new int[WorldModel2Conf.DM_CELL_COUNT];
+   }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/WM2DMListener.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/WM2DMListener.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/WM2DMListener.java	Wed Oct  1 22:08:08 2003
***************
*** 0 ****
--- 1,67 ----
+ package org.tekkotsu.mon;
+ 
+ // A Listener for the WorldModel2 depth map data
+ import java.io.InputStream;
+ import java.net.Socket;
+ 
+ // Much of this code has been copied from WorldStateJointsListener.java.
+ // I'm not too certain how it works, but I think a fair part of it has to do
+ // with synchronization.
+ public class WM2DMListener extends TCPListener {
+   boolean _updatedFlag=false;
+   WM2DMData _data;
+   WM2DMData _outd;
+ 
+   // Evidently this is the meat of the class
+   public void connected(Socket socket) {
+     _isConnected = true;
+     _data = new WM2DMData();
+     _outd = new WM2DMData();
+ 
+     try {
+       // CONNECT
+       InputStream in=socket.getInputStream();
+       // READ FOREVER
+       for(;;) {
+ 	// read in all WM2 data
+ 	for(int i=0; i<WorldModel2Conf.DM_CELL_COUNT; ++i) {
+ 	  _data.DM_depth[i] = readFloat(in);
+ 	  _data.DM_confidence[i] = readFloat(in);
+ 	  _data.DM_color[i] = readInt(in);
+ 	}
+ 
+ 	// this must be some lock thing. I really don't know why it works
+ 	// this way.
+ 	synchronized(_outd) {
+ 	  WM2DMData temp = _data;
+ 	  _data = _outd;	// why are we saving the old data?
+ 	  _outd = temp;
+ 	  _updatedFlag = true;
+ 	}
+       }
+     } catch(Exception e) {}
+ 
+     // DISCONNECT
+     try { socket.close(); } catch(Exception e) {}
+     _isConnected = false;
+   }
+ 
+ 
+   // Some state inquiry functions
+   public boolean hasData() { return _updatedFlag; }
+   public boolean isConnected() { return _isConnected; }
+ 
+ 
+   // Data extraction
+   public WM2DMData getData() {
+     synchronized(_outd) {
+       _updatedFlag = false;
+       return _outd;
+     }
+   }
+ 
+   // Constructors
+   public WM2DMListener() { super(); }
+   public WM2DMListener(int port) { super(port); }
+   public WM2DMListener(String host, int port) { super(host, port); }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/WM2FSData.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/WM2FSData.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/WM2FSData.java	Fri Sep 26 00:36:22 2003
***************
*** 0 ****
--- 1,16 ----
+ package org.tekkotsu.mon;
+ 
+ // Data container for the WorldModel2 FastSLAM subsystem
+ 
+ public class WM2FSData {
+   public float[][] FS_particlesPos;
+   public float FS_x, FS_y, FS_theta;
+   public float[][] FS_landmarkPos;
+   public float[][] FS_covariance;
+ 
+   WM2FSData() {
+     FS_particlesPos = new float[WorldModel2Conf.AFS_NUM_PARTICLES][3];
+     FS_landmarkPos = new float[WorldModel2Conf.AFS_NUM_LANDMARKS][2];
+     FS_covariance = new float[WorldModel2Conf.AFS_NUM_LANDMARKS][4];
+   }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/WM2FSListener.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/WM2FSListener.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/WM2FSListener.java	Wed Oct  1 22:08:08 2003
***************
*** 0 ****
--- 1,82 ----
+ package org.tekkotsu.mon;
+ 
+ // A Listener for the WorldModel2 FastSLAM data
+ import java.io.InputStream;
+ import java.net.Socket;
+ 
+ // Much of this code has been copied from WorldStateJointsListener.java.
+ // I'm not too certain how it works, but I think a fair part of it has to do
+ // with synchronization.
+ public class WM2FSListener extends TCPListener {
+   boolean _updatedFlag=false;
+   WM2FSData _data;
+   WM2FSData _outd;
+ 
+   // Evidently this is the meat of the class
+   public void connected(Socket socket) {
+     _isConnected = true;
+     _data = new WM2FSData();
+     _outd = new WM2FSData();
+ 
+     try {
+       // CONNECT
+       InputStream in=socket.getInputStream();
+       // READ FOREVER
+       for(;;) {
+ 	// read in all particle positions
+ 	for(int i=0; i<WorldModel2Conf.AFS_NUM_PARTICLES; ++i) {
+ 	  _data.FS_particlesPos[i][0] = readFloat(in);
+ 	  _data.FS_particlesPos[i][1] = readFloat(in);
+ 	  _data.FS_particlesPos[i][2] = readFloat(in);
+ 	}
+ 
+ 	// read in robot coordinates
+ 	_data.FS_x = readFloat(in);
+ 	_data.FS_y = readFloat(in);
+ 	_data.FS_theta = readFloat(in);
+ 
+ 	// read in landmark locations and covariances
+ 	for(int i=0; i<WorldModel2Conf.AFS_NUM_LANDMARKS; ++i) {
+ 	  _data.FS_landmarkPos[i][0] = readFloat(in);
+ 	  _data.FS_landmarkPos[i][1] = readFloat(in);
+ 
+ 	  _data.FS_covariance[i][0] = readFloat(in);
+ 	  _data.FS_covariance[i][1] = _data.FS_covariance[i][2] = readFloat(in);
+ 	  _data.FS_covariance[i][3] = readFloat(in);
+ 	}
+ 
+ 	// this must be some lock thing. I really don't know why it works
+ 	// this way.
+ 	synchronized(_outd) {
+ 	  WM2FSData temp = _data;
+ 	  _data = _outd;	// why are we saving the old data?
+ 	  _outd = temp;
+ 	  _updatedFlag = true;
+ 	}
+       }
+     } catch(Exception e) {}
+ 
+     // DISCONNECT
+     try { socket.close(); } catch(Exception e) {}
+     _isConnected = false;
+   }
+ 
+ 
+   // Some state inquiry functions
+   public boolean hasData() { return _updatedFlag; }
+   public boolean isConnected() { return _isConnected; }
+ 
+ 
+   // Data extraction
+   public WM2FSData getData() {
+     synchronized(_outd) {
+       _updatedFlag = false;
+       return _outd;
+     }
+   }
+ 
+   // Constructors
+   public WM2FSListener() { super(); }
+   public WM2FSListener(int port) { super(port); }
+   public WM2FSListener(String host, int port) { super(host, port); }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/WM2HMData.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/WM2HMData.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/WM2HMData.java	Fri Sep 26 00:36:22 2003
***************
*** 0 ****
--- 1,18 ----
+ package org.tekkotsu.mon;
+ 
+ // Data container for the WorldModel2 horizontal height map. Also is used
+ // for the global height map
+ 
+ public class WM2HMData {
+   public float[] HM_height;
+   public float[] HM_trav;
+   public float[] HM_confidence;
+   public int[] HM_color;
+ 
+   WM2HMData() {
+     HM_height = new float[WorldModel2Conf.HM_CELL_COUNT];
+     HM_trav = new float[WorldModel2Conf.HM_CELL_COUNT];
+     HM_confidence = new float[WorldModel2Conf.HM_CELL_COUNT];
+     HM_color = new int[WorldModel2Conf.HM_CELL_COUNT];
+   }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/WM2HMListener.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/WM2HMListener.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/WM2HMListener.java	Wed Oct  1 22:08:08 2003
***************
*** 0 ****
--- 1,68 ----
+ package org.tekkotsu.mon;
+ 
+ // A Listener for the WorldModel2 height map data
+ import java.io.InputStream;
+ import java.net.Socket;
+ 
+ // Much of this code has been copied from WorldStateJointsListener.java.
+ // I'm not too certain how it works, but I think a fair part of it has to do
+ // with synchronization.
+ public class WM2HMListener extends TCPListener {
+   boolean _updatedFlag=false;
+   WM2HMData _data;
+   WM2HMData _outd;
+ 
+   // Evidently this is the meat of the class
+   public void connected(Socket socket) {
+     _isConnected = true;
+     _data = new WM2HMData();
+     _outd = new WM2HMData();
+ 
+     try {
+       // CONNECT
+       InputStream in=socket.getInputStream();
+       // READ FOREVER
+       for(;;) {
+ 	// read in all WM2 data
+ 	for(int i=0; i<WorldModel2Conf.HM_CELL_COUNT; ++i) {
+ 	  _data.HM_height[i] = readFloat(in);
+ 	  _data.HM_trav[i] = readFloat(in);
+ 	  _data.HM_confidence[i] = readFloat(in);
+ 	  _data.HM_color[i] = readInt(in);
+ 	}
+ 
+ 	// this must be some lock thing. I really don't know why it works
+ 	// this way.
+ 	synchronized(_outd) {
+ 	  WM2HMData temp = _data;
+ 	  _data = _outd;	// why are we saving the old data?
+ 	  _outd = temp;
+ 	  _updatedFlag = true;
+ 	}
+       }
+     } catch(Exception e) {}
+ 
+     // DISCONNECT
+     try { socket.close(); } catch(Exception e) {}
+     _isConnected = false;
+   }
+ 
+ 
+   // Some state inquiry functions
+   public boolean hasData() { return _updatedFlag; }
+   public boolean isConnected() { return _isConnected; }
+ 
+ 
+   // Data extraction
+   public WM2HMData getData() {
+     synchronized(_outd) {
+       _updatedFlag = false;
+       return _outd;
+     }
+   }
+ 
+   // Constructors
+   public WM2HMListener() { super(); }
+   public WM2HMListener(int port) { super(port); }
+   public WM2HMListener(String host, int port) { super(host, port); }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/WMvar.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/WMvar.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/WMvar.java	Fri Sep 26 00:36:22 2003
***************
*** 0 ****
--- 1,74 ----
+ package org.tekkotsu.mon;
+ 
+ import java.util.regex.*;
+ 
+ public class WMvar {
+   public String type;
+   public String registry;
+   public String name;
+   public boolean watched;
+   public byte[] data;
+   public int timestamp;
+   public String stringData;
+   static final Pattern printable=Pattern.compile("^[\\p{Print}\\p{Space}]*$");
+   static final int MAX_STRINGREPRESENTATION_LENGTH=20;
+ 
+   public WMvar(String type, String name, byte[] data, int timestamp) {
+     this.type=type;
+     setName(name);
+     this.data=data;
+     this.timestamp=timestamp;
+     this.stringData=null;
+     watched=false;
+   }
+ 
+   public void update(WMvar wmvar) {
+     this.data=wmvar.data;
+     this.stringData=wmvar.stringData;
+     stringValueRepresentation();
+   }
+ 
+   void setName(String s) {
+     int loc=s.lastIndexOf('.');
+     if (loc<0) { registry=null; name=s; return; }
+     registry=s.substring(0,loc);
+     name=s.substring(loc+1, s.length());
+   }
+ 
+   public String toString() {
+     return type+" " + getCompleteName() + " = " + stringValueRepresentation();
+   }
+ 
+   public String getName() {
+     return name;
+   }
+   public String getValue() {
+     return stringValueRepresentation();
+   }
+   public String getType() {
+     return type;
+   }
+   public String getRegistry() {
+     return registry;
+   }
+   public String getCompleteName() {
+     if (registry==null) return name;
+     else return registry+"."+name;
+   }
+ 
+   public String stringValueRepresentation() {
+     if (stringData!=null) return stringData;
+     String temp;
+     if (data.length>MAX_STRINGREPRESENTATION_LENGTH)
+       temp=new String(data, 0, MAX_STRINGREPRESENTATION_LENGTH);
+     else
+       temp=new String(data);
+     Matcher m=printable.matcher(temp);
+     if (m.matches()) {
+       stringData=temp;
+     } else {
+       stringData="<binary data>";
+     }
+     return stringData;
+   }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/WalkGUI.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/WalkGUI.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/WalkGUI.java	Fri Sep 26 00:36:22 2003
***************
*** 0 ****
--- 1,343 ----
+ package org.tekkotsu.mon;
+ 
+ import javax.swing.*;
+ import java.awt.*;
+ import java.awt.geom.*;
+ import java.awt.event.*;
+ import javax.swing.event.*;
+ import java.util.prefs.Preferences;
+ 
+ public class WalkGUI extends JFrame implements PointPick.PointPickedListener, ChangeListener, ActionListener, MouseListener, MechaController.MechaUpdatedListener {
+ 	static int defPort=10050;
+ 	PointPick pp;
+ 	JSlider xslide;
+ 	JSlider yslide;
+ 	JSlider aslide;
+ 	JButton stopBut;
+ 	JRadioButton horizRotateBut;
+ 	JRadioButton horizStrafeBut;
+ 	boolean horizButFake=false;
+ 	JCheckBox resetOnRelease;
+ 	JLabel status;
+ 	JButton reconnectBut;
+ 	MechaController comm;
+ 	static int slidermax=10000;
+ 	final static ImageIcon carrows = new ImageIcon("images/chasingarrows.png");
+ 	static Preferences prefs = Preferences.userNodeForPackage(WalkGUI.class);
+ 
+ 	static public void main(String s[]) {
+ 		int port=defPort;
+ 		if(s.length<1)
+ 			usage();
+ 		if(s.length>1)
+ 			port=Integer.parseInt(s[1]);
+ 		String[] args=new String[s.length-1];
+ 		for(int i=0; i<s.length-1; i++)
+ 			args[i-1]=s[i];
+ 		JFrame frame=new WalkGUI(s[0],port,args);
+ 		/*		frame.addWindowListener(new WindowAdapter() {
+ 			public void windowClosing(WindowEvent e) { frame.dispose(); }
+ 			});*/
+ 	}
+ 	
+ 	public static void usage() {
+ 		System.out.println("Usage: java WalkGUI host [port]");
+ 		System.out.println("       if port is not specified, it defaults to: "+defPort);
+ 		System.exit(2);
+ 	}
+ 		
+ 	public WalkGUI(String host, int port, String args[]) {
+ 		super("TekkotsuMon: Walk Remote Control");
+ 		pack();
+ 		comm=new MechaController(host,port);
+ 		comm.addMechaUpdatedListener(this);
+ 		setLocation(prefs.getInt("WalkGUI.location.x",50),prefs.getInt("WalkGUI.location.y",50));
+ 		show();
+ 	}
+ 
+ 	public void close() {
+ 		prefs.putInt("WalkGUI.location.x",getLocation().x+getInsets().left);
+ 		prefs.putInt("WalkGUI.location.y",getLocation().y+getInsets().top);
+ 		comm.kill();
+ 		dispose();
+ 	}
+ 	
+ 	class CloseWalkAdapter extends WindowAdapter {
+ 		WalkGUI gui;
+ 		CloseWalkAdapter(WalkGUI gui) {this.gui=gui;}
+ 		public void windowClosing(WindowEvent e) {
+ 			gui.close();
+ 		}
+ 	}
+ 
+ 	public void pointPicked(Point2D.Float p, MouseEvent e, PointPick pp) {
+ 		boolean isBut2=(e.getModifiersEx()&MouseEvent.BUTTON3_DOWN_MASK)==MouseEvent.BUTTON3_DOWN_MASK;
+ 		if(!horizButFake && isBut2) {
+ 			if(horizStrafeBut.isSelected())
+ 				horizRotateBut.setSelected(true);
+ 			else
+ 				horizStrafeBut.setSelected(true);
+ 			horizButFake=isBut2;
+ 		}
+ 		if(horizRotateBut.isSelected())
+ 			aslide.setValue((int)(slidermax*p.x));
+ 		if(horizStrafeBut.isSelected())
+ 			yslide.setValue((int)(slidermax*p.x));
+ 		xslide.setValue((int)(slidermax*p.y));
+ 	}
+ 
+ 	public void mechaUpdated(MechaController comm) {
+ 		if(status!=null) {
+ 			pp.setEnabled(comm._isConnected);
+ 			xslide.setEnabled(comm._isConnected);
+ 			yslide.setEnabled(comm._isConnected);
+ 			aslide.setEnabled(comm._isConnected);
+ 			stopBut.setEnabled(comm._isConnected);
+ 			if(comm._isConnected)
+ 				status.setText("Connected.");
+ 			else
+ 				status.setText("Reconnecting...");
+ 		}
+ 	}
+ 
+ 	public void mouseClicked(MouseEvent e) {}
+ 	public void mouseEntered(MouseEvent e) {}
+ 	public void mouseExited(MouseEvent e) {}
+ 	public void mousePressed(MouseEvent e) {
+ 		boolean isBut2=(e.getModifiersEx()&MouseEvent.BUTTON3_DOWN_MASK)==MouseEvent.BUTTON3_DOWN_MASK;
+ 		if(!horizButFake && isBut2) {
+ 			if(horizStrafeBut.isSelected())
+ 				horizRotateBut.setSelected(true);
+ 			else
+ 				horizStrafeBut.setSelected(true);
+ 			horizButFake=isBut2;
+ 			updatePP();
+ 		}
+ 	}
+ 	public void mouseReleased(MouseEvent e) {
+ 		boolean isBut1=(e.getModifiersEx()&MouseEvent.BUTTON1_DOWN_MASK)==MouseEvent.BUTTON1_DOWN_MASK;
+ 		boolean isBut2=(e.getModifiersEx()&MouseEvent.BUTTON3_DOWN_MASK)==MouseEvent.BUTTON3_DOWN_MASK;
+ 		if(horizButFake && !isBut2) {
+ 			if(horizStrafeBut.isSelected())
+ 				horizRotateBut.setSelected(true);
+ 			else
+ 				horizStrafeBut.setSelected(true);
+ 			horizButFake=isBut2;
+ 			updatePP();
+ 		}
+ 		if(!isBut1 && !isBut2) {
+ 			if(resetOnRelease.isSelected())
+ 				stopBut.doClick();
+ 		}
+ 	}
+ 
+ 	public void stateChanged(ChangeEvent e) {
+ 		if(e.getSource()==xslide) {
+ 			comm.sendCommand("f",xslide.getValue()/(float)slidermax*180.0f);
+ 			pp.doSetPoint(pp.getXValue(),xslide.getValue()/(float)slidermax);
+ 		} else if(e.getSource()==yslide) {
+ 			comm.sendCommand("s",yslide.getValue()/(float)slidermax*-140.0f);
+ 			if(horizStrafeBut.isSelected())
+ 				pp.doSetPoint(yslide.getValue()/(float)slidermax,pp.getYValue());
+ 		} else if(e.getSource()==aslide) {
+ 			// Rotation is both fast and sensitive, so we'll exponentiate it to
+ 			// drag out the low end without sacrificing the high end
+ 			float aval=aslide.getValue()/(float)slidermax;
+ 			aval*=(aval<0?-aval:aval);
+ 			comm.sendCommand("r",aval*-1.8f);
+ 			float tmp=pp.getYValue();
+ 			if(horizRotateBut.isSelected())
+ 				pp.doSetPoint(aslide.getValue()/(float)slidermax,pp.getYValue());
+ 		}
+ 	}
+ 
+ 	public void actionPerformed(ActionEvent e) {
+ 		if(e.getSource()==stopBut) {
+ 			xslide.setValue(0);
+ 			yslide.setValue(0);
+ 			aslide.setValue(0);
+ 		} else if(e.getSource()==horizRotateBut) {
+ 			updatePP();
+ 		} else if(e.getSource()==horizStrafeBut) {
+ 			updatePP();
+ 		} else if(e.getSource()==reconnectBut) {
+ 			int port=comm._port;
+ 			String addr=comm._host;
+ 			comm.kill();
+ 			comm.removeMechaUpdatedListener(this);
+ 			comm = new MechaController(comm._host,comm._port);
+ 			comm.addMechaUpdatedListener(this);
+ 		}
+ 	}
+ 	
+ 	public void updatePP() {
+ 		float x=0;
+ 		if(horizStrafeBut.isSelected())
+ 			x=yslide.getValue()/(float)slidermax;
+ 		else if(horizRotateBut.isSelected())
+ 			x=aslide.getValue()/(float)slidermax;
+ 		pp.doSetPoint(x,xslide.getValue()/(float)slidermax);
+ 	}
+ 
+ 	public void frameInit() {
+ 		super.frameInit();
+ 		
+ 		int strutsize=10;
+ 		int sepsize=5;
+ 		getContentPane().setLayout(new BorderLayout());
+ 		getContentPane().add(Box.createHorizontalStrut(strutsize),BorderLayout.EAST);
+ 		getContentPane().add(Box.createHorizontalStrut(strutsize),BorderLayout.WEST);
+ 		getContentPane().add(Box.createVerticalStrut(strutsize),BorderLayout.NORTH);
+ 		JPanel p=new JPanel(new SquareRightLayout());
+ 		p.setLayout(new SquareRightLayout());
+ 		pp=new PointPick(false);
+ 		pp.addPointPickedListener(this);
+ 		pp.addMouseListener(this);
+ 		p.add(pp,SquareRightLayout.SQUARE);
+ 		Box tmp=Box.createHorizontalBox();
+ 		tmp.add(Box.createHorizontalStrut(strutsize));
+ 		JSeparator sep;
+ 		sep=new JSeparator(SwingConstants.VERTICAL);
+ 		sep.setMaximumSize(new Dimension(sepsize,slidermax));
+ 		tmp.add(sep);
+ 		tmp.add(Box.createHorizontalStrut(strutsize));
+ 		{
+ 			Box tmp2=Box.createVerticalBox();
+ 			tmp2.add(Box.createVerticalGlue());
+ 			int labwidth=45;
+ 			tmp2.add(new JLabel("Forward:"));
+ 			{
+ 				Box tmp3=Box.createHorizontalBox();
+ 				xslide=new JSlider(-slidermax,slidermax,0);
+ 				xslide.addChangeListener(this);
+ 				JLabel lab;
+ 				lab=new JLabel("Aft");
+ 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
+ 				lab.setHorizontalAlignment(SwingConstants.RIGHT);
+ 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
+ 				tmp3.add(lab);
+ 				tmp3.add(xslide);
+ 				lab=new JLabel("Fore");
+ 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
+ 				lab.setHorizontalAlignment(SwingConstants.LEFT);
+ 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
+ 				tmp3.add(lab);
+ 				//tmp3.add(new JButton("Zero"));
+ 				tmp3.setAlignmentX(0);
+ 				tmp2.add(tmp3);
+ 			}
+ 			tmp2.add(Box.createVerticalStrut(strutsize));
+ 			tmp2.add(new JLabel("Strafe:"));
+ 			{
+ 				Box tmp3=Box.createHorizontalBox();
+ 				yslide=new JSlider(-slidermax,slidermax,0);
+ 				yslide.addChangeListener(this);
+ 				JLabel lab;
+ 				lab=new JLabel("Left");
+ 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
+ 				lab.setHorizontalAlignment(SwingConstants.RIGHT);
+ 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
+ 				tmp3.add(lab);
+ 				tmp3.add(yslide);
+ 				lab=new JLabel("Right");
+ 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
+ 				lab.setHorizontalAlignment(SwingConstants.LEFT);
+ 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
+ 				tmp3.add(lab);
+ 				//tmp3.add(new JButton("Zero"));
+ 				tmp3.setAlignmentX(0);
+ 				tmp2.add(tmp3);
+ 			}
+ 			tmp2.add(Box.createVerticalStrut(strutsize));
+ 			tmp2.add(new JLabel("Rotate:"));
+ 			{
+ 				Box tmp3=Box.createHorizontalBox();
+ 				aslide=new JSlider(-slidermax,slidermax,0);
+ 				aslide.addChangeListener(this);
+ 				JLabel lab;
+ 				lab=new JLabel("Counter");
+ 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
+ 				lab.setHorizontalAlignment(SwingConstants.RIGHT);
+ 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
+ 				tmp3.add(lab);
+ 				tmp3.add(aslide);
+ 				lab=new JLabel("Clock");
+ 				lab.setFont(lab.getFont().deriveFont(lab.getFont().getSize2D()-2));
+ 				lab.setHorizontalAlignment(SwingConstants.LEFT);
+ 				lab.setPreferredSize(new Dimension(labwidth,lab.getFont().getSize()));
+ 				tmp3.add(lab);
+ 				//tmp3.add(new JButton("Zero"));
+ 				tmp3.setAlignmentX(0);
+ 				tmp2.add(tmp3);
+ 			}
+ 			tmp2.add(Box.createVerticalStrut(strutsize));
+ 			{
+ 				Box tmp3=Box.createHorizontalBox();
+ 				tmp3.add(Box.createHorizontalGlue());
+ 				stopBut=new JButton("Stop!");
+ 				stopBut.addActionListener(this);
+ 				rootPane.setDefaultButton(stopBut);
+ 				tmp3.add(stopBut);
+ 				tmp3.add(Box.createHorizontalGlue());
+ 				tmp3.setAlignmentX(0);
+ 				tmp2.add(tmp3);
+ 			}
+ 			tmp2.add(Box.createVerticalStrut(strutsize));
+ 			ButtonGroup bg = new ButtonGroup();
+ 			horizRotateBut=new JRadioButton("Horizontal is Rotate");
+ 			horizRotateBut.addActionListener(this);
+ 			horizRotateBut.setSelected(true);
+ 			bg.add(horizRotateBut);
+ 			tmp2.add(horizRotateBut);
+ 			horizStrafeBut=new JRadioButton("Horizontal is Strafe");
+ 			horizStrafeBut.addActionListener(this);
+ 			bg.add(horizStrafeBut);
+ 			tmp2.add(horizStrafeBut);
+ 			tmp2.add(Box.createVerticalStrut(strutsize));
+ 			tmp2.add(resetOnRelease=new JCheckBox("Reset on release")); 
+ 			resetOnRelease.setSelected(true);
+ 			tmp2.add(Box.createVerticalGlue());
+ 			tmp.add(tmp2);
+ //			Dimension d=tmp2.getMinimumSize();
+ //			System.out.println(d);
+ //			pp.setSize(d);
+ //			pp.setMinimumSize(d);
+ //			pp.setPreferredSize(d);
+ //			pp.setMaximumSize(d);
+ 		}
+ 		p.add(tmp,SquareRightLayout.RIGHT);
+ 		getContentPane().add(p,BorderLayout.CENTER);
+ 		{
+ 			Box tmp2=Box.createHorizontalBox();
+ 			tmp2.add(Box.createHorizontalStrut(strutsize));
+ 			{
+ 				Box tmp3=Box.createVerticalBox();
+ 				tmp3.add(Box.createVerticalStrut(strutsize));
+ 				tmp3.add(new JSeparator());
+ 				tmp3.add(Box.createVerticalStrut(strutsize-sepsize));
+ 				{
+ 					Box tmp4=Box.createHorizontalBox();
+ 					tmp4.add(status=new JLabel("Connecting..."));
+ 					tmp4.add(Box.createHorizontalGlue());
+ 					reconnectBut=new JButton(carrows);
+ 					reconnectBut.setPreferredSize(new Dimension(carrows.getIconWidth(),carrows.getIconHeight()));
+ 					reconnectBut.addActionListener(this);
+ 					reconnectBut.setToolTipText("Drop current connection and try again.");
+ 					tmp4.add(reconnectBut);
+ 					tmp3.add(tmp4);
+ 				}
+ 				tmp3.add(Box.createVerticalStrut(strutsize));
+ 				tmp2.add(tmp3);
+ 			}
+ 			tmp2.add(Box.createHorizontalStrut(strutsize));
+ 			getContentPane().add(tmp2,BorderLayout.SOUTH);
+ 		}
+ 
+ 		pp.setEnabled(false);
+ 		xslide.setEnabled(false);
+ 		yslide.setEnabled(false);
+ 		aslide.setEnabled(false);
+ 		stopBut.setEnabled(false);
+ 		addWindowListener(new CloseWalkAdapter(this));
+ 	}
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/WatchableMemory.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/WatchableMemory.java:1.4
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/WatchableMemory.java	Thu Oct  9 20:46:58 2003
***************
*** 0 ****
--- 1,350 ----
+ package org.tekkotsu.mon;
+ 
+ import javax.swing.*;
+ import javax.swing.event.*;
+ import javax.swing.table.*;
+ import java.awt.*;
+ import java.awt.event.*;
+ import java.util.*;
+ import java.util.prefs.Preferences;
+ 
+ public class WatchableMemory {
+   Hashtable registries;
+   WatchableMemoryListener listener;
+   WMregistry globalWM;
+   WMController wmController;
+ 	listenThread runner;
+ 
+   public static void main(String args[]) {
+     if (args.length>1) {
+       System.out.println("usage: java WatchableMemory [host]");
+       System.exit(1);
+     }
+ 
+     try {
+       DogConfig dogConfig=new DogConfig (args);
+       WatchableMemory watchableMemory=new WatchableMemory(dogConfig.getIP(),
+         Integer.parseInt(dogConfig.getValue("Main", "wmmonitor_port")),
+         true);
+     } catch (IllegalArgumentException ex) {}
+   }
+ 
+   public WatchableMemory(String ip, int port, String[] args) {
+     this(ip, port, false);
+   }
+ 
+   public WatchableMemory(String ip, int port) {
+     this(ip, port, false);
+   }
+ 
+   public WatchableMemory(String ip, int port, boolean appmode) {
+     listener=new WatchableMemoryListener(ip, port);
+     registries=new Hashtable();
+     wmController=new WMController(listener);
+     globalWM=new WMregistry("", wmController, registries);
+ 
+     if (appmode) {
+       globalWM.addWindowListener(new WindowAdapter() {
+         public void windowClosing(WindowEvent e) { System.exit(0); } });
+     }
+ 		runner=new listenThread(this,listener);
+ 		runner.start();
+   }
+ 
+ 
+ 	class listenThread extends Thread {
+ 		WatchableMemory gui;
+ 		WatchableMemoryListener listener;
+ 		listenThread(WatchableMemory gui,WatchableMemoryListener listener) { this.gui=gui; this.listener=listener;}
+ 		public void run() { 
+ 			try {
+ 				while (true) {
+ 					if (listener.isConnected()) {
+ 						if (listener.hasData()) {
+ 							WMvar wmvar=listener.getData();
+ 							String registry=wmvar.getRegistry();
+ 							if (registry==null) {
+ 								gui.globalWM.registerVar(wmvar);
+ 							} else {
+ 								WMregistry wmregistry;
+ 								synchronized (registries) {
+ 									wmregistry=(WMregistry)registries.get(registry);
+ 									if (wmregistry==null) {
+ 										wmregistry=new WMregistry(registry, gui.wmController, registries);
+ 										registries.put(registry, wmregistry);
+ 									}
+ 								}
+ 								wmregistry.registerVar(wmvar);
+ 							}
+ 						} else { sleep(10); }
+ 					} else { sleep(100); }
+ 				}
+ 			} catch(Exception ex) { if((InterruptedException)ex==null) ex.printStackTrace(); }
+ 		} 
+ 	}
+ 
+ 	public void close() {
+ 		globalWM.dispose();
+ 		listener.kill();
+ 		runner.interrupt();
+ 		runner=null;
+ 	}
+ 
+   void sleep(long ms) {
+     try { Thread.sleep(ms); } catch (Exception e) {}
+   }
+ }
+ 
+ class WMController {
+   WatchableMemoryListener listener;
+ 
+   public WMController(WatchableMemoryListener listener) {
+     this.listener=listener;
+   }
+ 
+   public boolean update (WMvar wmvar) {
+     if (wmvar.watched) return watch (wmvar);
+     else return supress (wmvar);
+   }
+ 
+   public boolean watch (WMvar wmvar) {
+     return watch(wmvar.getCompleteName());
+   }
+ 
+   public boolean watch (String s) {
+     if (!listener.isConnected()) return false;
+     listener.write("w "+s+"\n");
+     return true;
+   }
+ 
+   public boolean supress (WMvar wmvar) {
+     return supress(wmvar.getCompleteName());
+   }
+ 
+   public boolean supress (String s) {
+     if (!listener.isConnected()) return false;
+     listener.write("s "+s+"\n");
+     return true;
+   }
+ 
+   public boolean examine (WMvar wmvar) {
+     return examine(wmvar.getCompleteName());
+   }
+ 
+   public boolean examine (String s) {
+     if (!listener.isConnected()) return false;
+     listener.write("x "+s+"\n");
+     return true;
+   }
+ 
+   public boolean dumpRegistry (String s) {
+     if (!listener.isConnected()) return false;
+     listener.write("r "+s+"\n");
+     return true;
+   }
+ }
+ 
+ class RegistryTableModel extends AbstractTableModel {
+   final String[] columnNames = { "watch",
+                                  "name",
+                                  "type",
+                                  "value" };
+   Vector wmvars;
+   WMController wmController;
+ 
+   public RegistryTableModel(Vector wmvars, WMController wmController) {
+     super();
+     this.wmvars=wmvars;
+     this.wmController=wmController;
+   }
+ 
+   public int getColumnCount() {
+     return columnNames.length;
+   }
+ 
+   public int getRowCount() {
+     return wmvars.size();
+   }
+ 
+   public String getColumnName(int col) {
+     return columnNames[col];
+   }
+ 
+   public Object getValueAt(int row, int col) {
+     WMvar wmvar=(WMvar)wmvars.get(row);
+     switch (col) {
+       case 0:
+         return new Boolean(wmvar.watched);
+       case 1:
+         return wmvar.getName();
+       case 2:
+         return wmvar.getType();
+       case 3:
+         return wmvar.getValue();
+       default:
+         return null;
+     }
+   }
+ 
+   public Class getColumnClass(int c) {
+     switch (c) {
+       case 0:
+         return (new Boolean(true)).getClass();
+       default:
+         return (new String()).getClass();
+     }
+   }
+ 
+   public boolean isCellEditable(int row, int col) {
+     if (col==0) return true;
+     return false;
+   }
+ 
+   public void setValueAt(Object value, int row, int col) {
+     WMvar wmvar=(WMvar)wmvars.get(row);
+     boolean val=((Boolean)value).booleanValue();
+     if (val) {
+       if (wmController.watch(wmvar))
+         wmvar.watched=val;
+     } else {
+       if (wmController.supress(wmvar))
+         wmvar.watched=val;
+     }
+   }
+ 
+   public void varUpdated(int i) {
+     fireTableCellUpdated(i, 3);
+   }
+ 
+   public void varAdded(int i) {
+     fireTableRowsInserted(i, i);
+   }
+ }
+ 
+ class WMregistry extends JFrame implements ActionListener, MouseListener {
+   RegistryTableModel dataModel;
+   String name;
+ 
+   Vector wmvars_vec;
+   Hashtable wmvars_hash;
+   WMController wmController;
+   Hashtable registries;
+   
+   JTable table;
+   TableSorter sorter;
+   JScrollPane scrollPane;
+   JButton refresh;
+ 
+ 	static Preferences prefs = Preferences.userNodeForPackage(WatchableMemory.class);
+ 
+   public WMregistry(String s, WMController wmController, Hashtable registries) {
+     super(s);
+     name=s;
+     this.wmController=wmController;
+ 
+     addWindowListener(new WindowAdapter() {
+       public void windowClosing(WindowEvent e) { e.getWindow().hide(); } });
+ 
+     wmvars_vec=new Vector();
+     wmvars_hash=new Hashtable();
+ 
+     this.registries=registries;
+     wmController.dumpRegistry(name);
+     dataModel=new RegistryTableModel(wmvars_vec, wmController);
+ 
+     sorter=new TableSorter(dataModel, 1);
+     table = new JTable(sorter);
+     sorter.addMouseListenerToHeaderInTable(table);
+ 
+     setTableSizes();
+     scrollPane = new JScrollPane(table,
+                                  JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+                                  JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+     table.addMouseListener(this);
+ 
+     refresh=new JButton("refresh");
+     refresh.addActionListener(this);
+ 
+     getContentPane().add(scrollPane, BorderLayout.CENTER);
+     getContentPane().add(refresh, BorderLayout.SOUTH);
+ 
+     setLocation(prefs.getInt("WatchableMemory."+s+".location.x",50),prefs.getInt("WatchableMemory.location.y",50));
+ 		addWindowListener(new CloseAdapter(this));
+ 
+     setVisible(true);
+   }
+ 
+ 	class CloseAdapter extends WindowAdapter {
+ 		WMregistry gui;
+ 		CloseAdapter(WMregistry gui) {this.gui=gui;}
+ 		public void windowClosing(WindowEvent e) {
+ 			gui.prefs.putInt("WatchableMemory."+gui.name+".location.x",gui.getLocation().x+gui.getInsets().left);
+ 			gui.prefs.putInt("WatchableMemory."+gui.name+".location.y",gui.getLocation().y+gui.getInsets().top);
+ 		}
+ 	}
+ 
+   public void setTableSizes() {
+     setSize(new Dimension(500, 530));
+     table.setPreferredScrollableViewportSize(new Dimension(500, 500));
+     TableColumn column;
+     column=table.getColumnModel().getColumn(0);
+     column.setPreferredWidth(30);
+     column=table.getColumnModel().getColumn(1);
+     column.setPreferredWidth(100);
+     column=table.getColumnModel().getColumn(2);
+     column.setPreferredWidth(70);
+     column=table.getColumnModel().getColumn(3);
+     column.setPreferredWidth(200);
+   }
+   
+   public void registerVar(WMvar wmvar) {
+     // use hashtable to make updates faster!
+ 
+     for (int i=0; i<wmvars_vec.size(); i++) {
+       WMvar wmvar_i=(WMvar)wmvars_vec.get(i);
+       int cmp=wmvar_i.getName().compareTo(wmvar.getName());
+       if (cmp==0) {
+         wmvar_i.update(wmvar);
+         dataModel.varUpdated(i);
+         return;
+       }
+     }
+     wmvars_vec.add(wmvar);
+     dataModel.varAdded(wmvars_vec.size()-1);
+   }
+ 
+   public void actionPerformed(ActionEvent e) {
+     if (e.getSource()==refresh)
+       wmController.dumpRegistry(name);
+   }
+ 
+   public void mouseClicked(MouseEvent e) {
+     if (e.getClickCount()==2) {
+       int col=table.getSelectedColumn();
+       if (col==1 || col==2)
+         openItem(sorter.translateRow(table.getSelectedRow()));
+     }
+   }
+ 
+   void openItem(int row) {
+     WMvar wmvar=(WMvar)wmvars_vec.get(row);
+     if (wmvar.getType().equals("WMregistry")) {
+       String registry=wmvar.getCompleteName();
+       synchronized (registries) {
+         WMregistry wmregistry=(WMregistry)registries.get(registry);
+         if (wmregistry==null) {
+           wmregistry=new WMregistry(registry, wmController, registries);
+           registries.put(registry, wmregistry);
+         } else {
+           wmregistry.show();
+         }
+       }
+     } else {
+     }
+   }
+ 
+   public void mouseEntered(MouseEvent e) { }
+   public void mouseExited(MouseEvent e) { }
+   public void mousePressed(MouseEvent e) { }
+   public void mouseReleased(MouseEvent e) { }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/WatchableMemoryListener.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/WatchableMemoryListener.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/WatchableMemoryListener.java	Wed Oct  1 22:08:08 2003
***************
*** 0 ****
--- 1,62 ----
+ package org.tekkotsu.mon;
+ 
+ import java.io.*;
+ import java.net.*;
+ import java.util.*;
+ 
+ public class WatchableMemoryListener extends TCPListener {
+   LinkedList changesList;
+   PrintStream _out;
+ 
+   public void connected(Socket socket) {
+     changesList=new LinkedList();
+     _isConnected=true;
+     try {
+       InputStream in=socket.getInputStream();
+       _out = new PrintStream(socket.getOutputStream());
+       while (true) {
+         int format=readInt(in);
+         if (format!=PACKET_WMCLASS)
+           throw new java.lang.NoSuchFieldException("fake exception");
+         int timestamp=readInt(in);
+ 
+         String var_type=new String(readBytes(in, readInt(in)));
+         String var_name=new String(readBytes(in, readInt(in)));
+         byte[] var_data=readBytes(in, readInt(in));
+         
+         WMvar wmvar=new WMvar(var_type, var_name, var_data, timestamp);
+         synchronized(changesList) { changesList.add(wmvar); }
+       }
+     } catch (Exception ex) { }
+ 
+     try { socket.close(); } catch (Exception ex) { }
+     _isConnected=false;
+   }
+  
+   public boolean hasData() {
+     boolean hasdata;
+     synchronized(changesList) { hasdata=!changesList.isEmpty(); }
+     return hasdata;
+   }
+ 
+   public WMvar getData() {
+     WMvar wmvar;
+     synchronized(changesList) { wmvar=(WMvar)changesList.removeFirst(); }
+     return wmvar;
+   }
+ 
+   public boolean isConnected() {
+     return _isConnected;
+   }
+ 
+   public void write(String s) {
+     if (_isConnected) {
+       _out.print(s);
+       _out.flush();
+     }
+   }
+ 
+   public WatchableMemoryListener() { super(); }
+   public WatchableMemoryListener(int port) { super(port); }
+   public WatchableMemoryListener(String host, int port) { super(host,port); }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/WorldModel2Conf.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/WorldModel2Conf.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/WorldModel2Conf.java	Fri Sep 26 00:36:23 2003
***************
*** 0 ****
--- 1,45 ----
+ package org.tekkotsu.mon;
+ 
+ // Constants regarding the configuration of WorldModel2
+ //
+ // YOU MUST CHANGE THE CONSTANTS TO MATCH THOSE IN THE WorldModel2
+ // CONFIGURATION FILES--otherwise, the amounts of data read and written won't
+ // match up.
+ 
+ import java.lang.Math;
+ 
+ public class WorldModel2Conf {
+   // Array dimensions in pixels
+     // from WorldModel2/Maps/Configuration.h
+   public static final int ALM_DM_V_SIZE = 51;
+   public static final int ALM_DM_H_SIZE = 89;
+   public static final int ALM_HM_SIZE = 20; // don't forget that this value
+ 					    // is the *radius* of the height
+ 					    // map in pixels, hence one half
+ 					    // of the edge length
+   public static final int AGM_V_SIZE = 100;
+   public static final int AGM_H_SIZE = 100;
+     // from WorldModel2/FastSLAM/Configuration.h
+   public static final int AFS_NUM_LANDMARKS = 12;
+   public static final int AFS_NUM_PARTICLES = 400;
+ 
+   // Array dimensions in measurement units
+     // from WorldModel2/Maps/Configuration.h
+   public static final double ALM_DM_TOP = R(25.0);
+   public static final double ALM_DM_BOTTOM = R(-75.0);
+   public static final double ALM_DM_LEFT = R(85.0);
+   public static final double ALM_DM_RIGHT = R(-85.0);
+   public static final double ALM_HM_RADIUS = 400;
+   public static final double AGM_TOP = 2000;
+   public static final double AGM_BOTTOM = -2000;
+   public static final double AGM_LEFT = -2000;
+   public static final double AGM_RIGHT = 2000;
+ 
+   // These computed constants should not need to change.
+   public static final int HM_CELL_COUNT = 4*ALM_HM_SIZE*ALM_HM_SIZE;
+   public static final int DM_CELL_COUNT = ALM_DM_V_SIZE*ALM_DM_H_SIZE;
+   public static final int GM_CELL_COUNT = AGM_V_SIZE*AGM_H_SIZE;
+ 
+   // Convenience degree to radian function
+   public static final double R(double D) { return D*Math.PI/180.0; }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/WorldStateJointsListener.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/WorldStateJointsListener.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/WorldStateJointsListener.java	Wed Oct  1 22:08:08 2003
***************
*** 0 ****
--- 1,59 ----
+ package org.tekkotsu.mon;
+ 
+ import java.io.InputStream;
+ import java.net.Socket;
+ 
+ public class WorldStateJointsListener extends TCPListener {
+   boolean _updatedFlag=false;
+   Joints _data;
+   Joints _outd;
+ 
+   public void connected(Socket socket) {
+     _isConnected=true;
+     _data=new Joints();
+     _outd=new Joints();
+     try {
+       InputStream in=socket.getInputStream();
+       while (true) {
+         _data.timestamp=readInt(in);
+         for (int i=0; i<18; i++)
+           _data.positions[i]=readFloat(in);
+         for (int i=0; i<6; i++)
+           _data.sensors[i]=readFloat(in);
+         for (int i=0; i<8; i++)
+           _data.buttons[i]=readFloat(in);
+         for (int i=0; i<18; i++)
+           _data.duties[i]=readFloat(in);
+ 
+         synchronized(_outd) {
+           Joints temp=_data;
+           _data=_outd;
+           _outd=temp;
+           _updatedFlag=true;
+         }
+       }
+     } catch (Exception ex) { }
+ 
+     try { socket.close(); } catch (Exception ex) { }
+     _isConnected=false;
+   }
+  
+   public boolean hasData() {
+     return _updatedFlag;
+   }
+ 
+   public Joints getData() {
+     synchronized (_outd) {
+       _updatedFlag=false;
+       return _outd;
+     }
+   }
+ 
+   public boolean isConnected() {
+     return _isConnected;
+   }
+ 
+   public WorldStateJointsListener() { super(); }
+   public WorldStateJointsListener(int port) { super(port); }
+   public WorldStateJointsListener(String host, int port) { super(host,port); }
+ }
Index: AiboPup/tools/mon/org/tekkotsu/mon/WorldStatePIDsListener.java
diff -c /dev/null AiboPup/tools/mon/org/tekkotsu/mon/WorldStatePIDsListener.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/mon/org/tekkotsu/mon/WorldStatePIDsListener.java	Wed Oct  1 22:08:08 2003
***************
*** 0 ****
--- 1,57 ----
+ package org.tekkotsu.mon;
+ 
+ import java.io.InputStream;
+ import java.net.Socket;
+ 
+ public class WorldStatePIDsListener extends TCPListener {
+   boolean _updatedFlag=false;
+   PIDs _data;
+   PIDs _outd;
+ 
+   public void connected(Socket socket) {
+     _isConnected=true;
+     _data=new PIDs();
+     _outd=new PIDs();
+     try {
+       InputStream in=socket.getInputStream();
+       while (true) {
+         _data.timestamp=readInt(in);
+         for (int i=0; i<18; i++)
+           _data.P[i]=readFloat(in);
+         for (int i=0; i<18; i++)
+           _data.I[i]=readFloat(in);
+         for (int i=0; i<18; i++)
+           _data.D[i]=readFloat(in);
+ 
+         synchronized(_outd) {
+           PIDs temp=_data;
+           _data=_outd;
+           _outd=temp;
+           _updatedFlag=true;
+         }
+       }
+     } catch (Exception ex) { }
+ 
+     try { socket.close(); } catch (Exception ex) { }
+     _isConnected=false;
+   }
+  
+   public boolean hasData() {
+     return _updatedFlag;
+   }
+ 
+   public PIDs getData() {
+     synchronized (_outd) {
+       _updatedFlag=false;
+       return _outd;
+     }
+   }
+ 
+   public boolean isConnected() {
+     return _isConnected;
+   }
+ 
+   public WorldStatePIDsListener() { super(); }
+   public WorldStatePIDsListener(int port) { super(port); }
+   public WorldStatePIDsListener(String host, int port) { super(host,port); }
+ }
Index: AiboPup/tools/seg/ClassPathModifier.java
diff -c /dev/null AiboPup/tools/seg/ClassPathModifier.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/seg/ClassPathModifier.java	Sat Jul 26 21:55:58 2003
***************
*** 0 ****
--- 1,32 ----
+ import java.lang.*;
+ import java.net.*;
+ import java.io.*;
+ import java.lang.reflect.*;
+ 
+ public class ClassPathModifier {
+   private static final Class[] parameters = new Class[]{URL.class};
+ 
+   public static void addFile(String s) throws IOException {
+     File f = new File(s);
+     addFile(f);
+   }
+ 
+   public static void addFile(File f) throws IOException {
+     addURL(f.toURL());
+   }
+ 
+   public static void addURL(URL u) throws IOException {
+     URLClassLoader sysloader =
+       (URLClassLoader)ClassLoader.getSystemClassLoader();
+ 
+ 		Class sysclass = URLClassLoader.class;
+ 
+     try {
+       Method method = sysclass.getDeclaredMethod("addURL",parameters);
+       method.setAccessible(true);
+       method.invoke(sysloader, new Object[]{ u });
+     } catch (Throwable t) {
+       throw new IOException("could not add "+u+" to classpath");
+ 		}
+   }
+ }
Index: AiboPup/tools/seg/ColorConverter.java
diff -c /dev/null AiboPup/tools/seg/ColorConverter.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/seg/ColorConverter.java	Sat Jul 26 21:55:59 2003
***************
*** 0 ****
--- 1,10 ----
+ public abstract class ColorConverter {
+   ColorConverter() { }
+   public final float[] getColor(int rgb) {
+     int r=(rgb>>16)&0xff;
+     int g=(rgb>>8)&0xff;
+     int b=rgb&0xff;
+     return getColor(r, g, b);
+   }
+   public abstract float[] getColor(int r, int g, int b);
+ }
Index: AiboPup/tools/seg/DogConfig.java
diff -c /dev/null AiboPup/tools/seg/DogConfig.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/seg/DogConfig.java	Sat Jul 26 21:55:59 2003
***************
*** 0 ****
--- 1,185 ----
+ import java.util.*;
+ import java.io.*;
+ import java.lang.*;
+ 
+ public class DogConfig {
+   List IPs;
+   String IP;
+   Hashtable config;
+ 
+   public static void main(String args[]) {
+     try {
+       DogConfig config=new DogConfig(args);
+     } catch (IllegalArgumentException ex) { }
+   }
+ 
+   void usage() {
+     System.out.println("java DogConfig Internet_Address");
+   }
+ 
+   public DogConfig(String args[]) {
+     try { ClassPathModifier.addFile("ftp.jar"); }
+     catch (Exception ex) { System.out.println(ex); System.exit(1); }
+ 
+     for (int i=0; i<args.length; i++) {
+       if (args[i].charAt(0)=='-') {
+         System.out.println(args[i] + "is not a valid internet address");
+         throw new IllegalArgumentException();
+       }
+     }
+ 
+     readConfig();
+     for (int i=0; i<args.length; i++) {
+       if (tryIP(args[i])) {
+         IP=args[i];
+         break;
+       }
+     }
+ 
+     if (IP==null) {
+       for (ListIterator iter = IPs.listIterator(); iter.hasNext(); ) {
+         String cline=(String)iter.next();
+         int clength=cline.length();
+         if (clength!=0 && cline.charAt(0)!='#') {
+           if (tryIP(cline)) {
+             IP=cline;
+             break;
+           }
+         }
+       }
+     } else {
+       int insertpos=0;
+       boolean ipbegun=false;
+ 
+       for (ListIterator iter = IPs.listIterator(); iter.hasNext(); ) {
+         String cline=(String)iter.next();
+         int clength=cline.length();
+ 
+         if (clength!=0 && cline.charAt(0)!='#') ipbegun=true;
+         else if (!ipbegun) insertpos++;
+ 
+         if (cline.compareToIgnoreCase(IP)==0) {
+           insertpos=-1;
+           break;
+         }
+       }
+       
+       if (insertpos>=0) {
+         IPs.add(insertpos,IP); 
+         writeConfig();
+       }
+     }
+   
+     if (IP==null) {
+       System.out.println("Dog not found; please switch on dog or specify" +
+                          " correct IP address");
+       throw new IllegalArgumentException();
+       // pop up dialog box asking for IP address?
+     }
+   }
+ 
+   boolean tryIP(String ip) {
+     DogConfigFTP dog_ftp=new DogConfigFTP(ip, 21, "config", "config");
+     System.out.print("Trying "+ip+" ... ");
+     System.out.flush();
+     if (dog_ftp.test()) {
+       System.out.println("found");
+       try {
+         readAiboConfig(dog_ftp.getFile("tekkotsu.cfg"));
+         return true;
+       } catch (Exception ex) {
+         System.out.println("ftp error: "+ ex);
+       }
+     } else {
+       System.out.println("not found");
+     }
+     return false;
+   }
+ 
+   public DogConfig() {
+     this(new String[]{});
+   }
+ 
+   public DogConfig(String s) {
+     this(new String[]{s});
+   }
+ 
+   public String getIP() {
+     return IP;
+   }
+ 
+   void readAiboConfig(String conf) {
+     String[] lines=conf.split("[\r\n]");
+     config=new Hashtable();
+     Hashtable current=config;
+ 
+     for (int i=0; i<lines.length; i++) {
+       String cline=lines[i];
+       int clength=cline.length();
+       if (clength!=0 && cline.charAt(0)!='#') {
+         if (cline.charAt(0)=='[' && cline.charAt(clength-1)==']') {
+           String category=cline.substring(1,clength-1);
+           current=new Hashtable();
+           config.put(category, current);
+         } else {
+           int ind=cline.indexOf('=');
+           if (ind<0) {
+             System.out.println("warning: line "+(i+1)+" ignored");
+             System.out.println("       > "+cline);
+           } else {
+             String key=cline.substring(0,ind);
+             String value=cline.substring(ind+1,clength);
+             current.put(key, value);
+           }
+         }
+       }
+     }
+   }
+ 
+   public String getValue(String section, String key) {
+     Hashtable sectionhash=(Hashtable)config.get(section);
+     if (sectionhash!=null)
+       return (String)sectionhash.get(key);
+     return null;
+   }
+ 
+   File configFile() {
+     String homedir="";
+     try { homedir=System.getProperty("user.home"); } catch (Exception ex) {}
+     return new File(homedir, ".aibo_ip");
+   }
+ 
+   void readConfig() {
+     IPs=new ArrayList(10);
+     try {
+       BufferedReader in = new BufferedReader
+         ( new FileReader (configFile()) );
+       String curLine=in.readLine();
+       while (curLine!=null) {
+         IPs.add(curLine);
+         curLine=in.readLine();
+       }
+       in.close();
+     } catch (FileNotFoundException ex) {
+       // we just start off with 0 IPs
+       // also creating a new file, so add an intro comment
+       IPs.add("# Ordered list of IPs to be used by Tekkotsu tools\n");
+     } catch (IOException ex) {
+       // we read what we could
+     }
+     // no real need for parsing and verifying correctness of IPs
+   }
+ 
+   void writeConfig() {
+     try {
+       PrintWriter out = new PrintWriter ( new BufferedWriter (
+             new FileWriter (configFile())));
+       for (ListIterator iter = IPs.listIterator(); iter.hasNext(); ) {
+         out.println(iter.next());
+       }
+       out.close();
+     } catch (IOException ex) {
+       // can't do much about it
+     }
+   }
+ }
Index: AiboPup/tools/seg/DogConfigFTP.java
diff -c /dev/null AiboPup/tools/seg/DogConfigFTP.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/seg/DogConfigFTP.java	Thu Oct  9 02:29:39 2003
***************
*** 0 ****
--- 1,78 ----
+ import com.enterprisedt.net.ftp.*;
+ import java.util.*;
+ import java.net.*;
+ import java.io.*;
+ 
+ public class DogConfigFTP {
+   String _ip;
+   int _port;
+   String _user;
+   String _pass;
+ 
+   public DogConfigFTP(String ip) {
+     this(ip, 21);
+   }
+ 
+   public DogConfigFTP(String ip, int port) {
+     _ip=ip;
+     _port=port;
+     _user="anonymous";
+     _pass="blah@tekkotsu.org";
+   }
+ 
+   public DogConfigFTP(String ip, int port, String user, String pass) {
+     this(ip, port);
+     _user=user;
+     _pass=pass;
+   }
+   
+   public boolean test() {
+     return test(500);
+   }
+ 
+   public boolean test(int millis) {
+     Socket _ftpSocket=new Socket();
+     try {
+       _ftpSocket.connect(new InetSocketAddress(_ip, _port), millis);
+     } catch (Exception ex) { }
+     if (_ftpSocket.isConnected()) {
+       try { _ftpSocket.close(); } catch (Exception ex) { }
+       return true;
+     } else {
+       return false;
+     }
+   }
+ 
+   public String getFile(String remotename) throws FTPException, IOException {
+     FTPClient ftp=new FTPClient(_ip, _port);
+     ftp.login(_user, _pass);
+     ftp.setConnectMode(FTPConnectMode.ACTIVE);
+     ftp.setType(FTPTransferType.ASCII);
+     String ret=new String(ftp.get(remotename));
+     ftp.quit();
+     return ret;
+   }
+ 
+ 	public void putFile(String localname) throws FTPException, IOException {
+ 		putFile(localname,localname);
+ 	}
+ 
+   public void putFile(String localname, String remoteName) throws FTPException, IOException {
+     FTPClient ftp=new FTPClient(_ip, _port);
+     ftp.login(_user, _pass);
+     ftp.setConnectMode(FTPConnectMode.ACTIVE);
+     ftp.setType(FTPTransferType.BINARY);
+     ftp.put(localname, remoteName);
+     ftp.quit();
+   }
+ 
+   public void login(String user, String pass) {
+     _user=user;
+     _pass=pass;
+   }
+ 
+   public static void main(String args[]) {
+     System.out.println("This is an internal class - run DogConfig instead");
+     System.exit(0);
+   }
+ }
Index: AiboPup/tools/seg/ImageData.java
diff -c /dev/null AiboPup/tools/seg/ImageData.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/seg/ImageData.java	Sat Jul 26 21:55:59 2003
***************
*** 0 ****
--- 1,184 ----
+ import java.awt.image.*;
+ import java.awt.*;
+ import javax.swing.*;
+ import javax.swing.event.*;
+ import java.awt.event.*;
+ import java.util.*;
+ import java.awt.geom.*;
+ import java.io.*;
+ 
+ public class ImageData extends Frame {
+   Toolkit toolkit;
+   public int[] retdata;
+   public int[] data;
+ 
+   public float[] RG;
+   public float[] HS;
+   public float[] HB;
+   public float[] SB;
+ 
+   public int image_width;
+   public int image_height;
+ 
+   public int[] getRGB() {
+     return retdata;
+   }
+ 
+   public float[] getRG() {
+     if (RG==null) {
+       RG=new float[retdata.length*2];
+       for (int i=0; i<retdata.length; i++) {
+         float r=(float)((retdata[i]>>16)&0xFF);
+         float g=(float)((retdata[i]>>8)&0xFF);
+         float b=(float)(retdata[i]&0xFF);
+         RG[i*2]=r/(r+g+b);
+         RG[i*2+1]=g/(r+g+b);
+       }
+     }
+     return RG;
+   }
+ 
+   public float[] getHS() {
+     if (HS==null) {
+       HS=new float[retdata.length*2];
+       float[] hsb=new float[3];
+       for (int i=0; i<retdata.length; i++) {
+         int r=(retdata[i]>>16)&0xFF;
+         int g=(retdata[i]>>8)&0xFF;
+         int b=retdata[i]&0xFF;
+         Color.RGBtoHSB(r, g, b, hsb);
+         HS[i*2]=hsb[0];
+         HS[i*2+1]=hsb[1];
+       }
+     }
+     return HS;
+   }
+ 
+   public float[] getHB() {
+     if (HB==null) {
+       HB=new float[retdata.length*2];
+       float[] hsb=new float[3];
+       for (int i=0; i<retdata.length; i++) {
+         int r=(retdata[i]>>16)&0xFF;
+         int g=(retdata[i]>>8)&0xFF;
+         int b=retdata[i]&0xFF;
+         Color.RGBtoHSB(r, g, b, hsb);
+         HB[i*2]=hsb[0];
+         HB[i*2+1]=hsb[2];
+       }
+     }
+     return HB;
+   }
+ 
+   public float[] getSB() {
+     if (SB==null) {
+       SB=new float[retdata.length*2];
+       float[] hsb=new float[3];
+       for (int i=0; i<retdata.length; i++) {
+         int r=(retdata[i]>>16)&0xFF;
+         int g=(retdata[i]>>8)&0xFF;
+         int b=retdata[i]&0xFF;
+         Color.RGBtoHSB(r, g, b, hsb);
+         SB[i*2]=hsb[1];
+         SB[i*2+1]=hsb[2];
+       }
+     }
+     return SB;
+   }
+   
+   public ImageData() {
+     toolkit=Toolkit.getDefaultToolkit();
+   }
+ 
+   void loadFile(String filename) {
+     Image image=toolkit.createImage(filename);
+     MediaTracker mediaTracker=new MediaTracker(this);
+     mediaTracker.addImage(image, 0);
+     try {
+       mediaTracker.waitForID(0);
+     } catch (InterruptedException e) {
+       System.out.println(e);
+       System.exit(1);
+     }
+     image_width=image.getWidth(this);
+     image_height=image.getHeight(this);
+ 
+     BufferedImage bi = new BufferedImage(image_width, image_height,
+                                          BufferedImage.TYPE_INT_RGB);
+     Graphics big = bi.createGraphics();
+     big.drawImage(image,0,0,null);
+     data=bi.getRGB(0,0,image_width,image_height,null,0,image_width);
+   }
+ 
+   public void loadYUVFile(String filename) {
+     loadFile(filename);
+     YUV2RGB();
+     retdata=data;
+   }
+ 
+   public void YUV2RGB() {
+     for (int i=0; i<data.length; i++) {
+       int y=(int)((data[i]>>16)&0xFF);
+       int u=(int)((data[i]>>8)&0xFF);
+       int v=(int)(data[i]&0xFF);
+       u=u*2-255;
+       v=v*2-255;
+       int r=y+u;
+       int b=y+v;
+       u=u>>1;
+       v=(v>>2)-(v>>4);
+       int g=y-u-v;
+       if (r<0) r=0; if (g<0) g=0; if (b<0) b=0;
+       if (r>255) r=255; if (g>255) g=255; if (b>255) b=255;
+ 
+       data[i]= (r<<16) | (g<<8) | b;
+     }
+   }
+ 
+   public void loadRGBFile(String filename) {
+     loadFile(filename);
+     retdata=data;
+   }
+ 
+   public void loadRGBFiles(String files[]) {
+     loadFile(files[0]);
+     retdata=data;
+     for (int i=1; i<files.length; i++) {
+       loadFile(files[i]);
+       for (int j=i; j<retdata.length; j+=files.length)
+         retdata[j]=data[j];
+     }
+   }
+ 
+   public void loadYUVFiles(String files[]) {
+     loadFile(files[0]);
+     YUV2RGB();
+     retdata=data;
+     for (int i=1; i<files.length; i++) {
+       loadFile(files[i]);
+       YUV2RGB();
+       for (int j=i; j<retdata.length; j+=files.length)
+         retdata[j]=data[j];
+     }
+   }
+ 
+   public void loadFullRGBFiles(String files[]) {
+     for (int i=0; i<files.length; i++) {
+       loadFile(files[i]);
+       if (i==0) retdata=new int[files.length*data.length];
+       for (int j=0; j<data.length; j++)
+         retdata[j+(i*data.length)]=data[j];
+     }
+   }
+ 
+   public void loadFullYUVFiles(String files[]) {
+     for (int i=0; i<files.length; i++) {
+       loadFile(files[i]);
+       if (i==0) retdata=new int[files.length*data.length];
+       YUV2RGB();
+       int l=0;
+       for (int j=i; j<retdata.length; j+=files.length)
+         retdata[j]=data[l++];
+     }
+   }
+ }
Index: AiboPup/tools/seg/ImageShow.java
diff -c /dev/null AiboPup/tools/seg/ImageShow.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/seg/ImageShow.java	Mon Jul 28 02:31:46 2003
***************
*** 0 ****
--- 1,92 ----
+ import java.awt.image.*;
+ import java.awt.*;
+ import javax.swing.*;
+ import javax.swing.event.*;
+ import java.awt.event.*;
+ import java.io.*;
+ import java.util.*;
+ 
+ public class ImageShow extends JFrame implements KeyListener {
+   BufferedImage _image;
+   String[] imglist;
+   byte[] tmap;
+   ImageData imageData;
+   int curimg;
+ 
+   public static void main(String args[]) {
+     if (args.length<1) {
+       System.out.println("usage: java ImageShow raw_image [raw images]");
+       System.exit(1);
+     }
+     ImageShow imageShow=new ImageShow(args);
+     imageShow.show();
+     imageShow.addWindowListener(new WindowAdapter() {
+         public void windowClosing(WindowEvent e) { System.exit(0); } });
+   }
+ 
+   public ImageShow (String args[]) {
+     imageData=new ImageData();
+     imageData.loadYUVFile(args[0]);
+ 
+     int[] data=imageData.getRGB();
+ 
+     setBackground(Color.black);
+     setSize(imageData.image_width*2, imageData.image_height*2);
+     _image=new BufferedImage(imageData.image_width, imageData.image_height,
+         BufferedImage.TYPE_INT_RGB);
+    
+     showImage(data, tmap, imageData.image_width, imageData.image_height);
+ 
+     imglist=new String[args.length];
+     curimg=0;
+     for (int i=0; i<args.length; i++) {
+       imglist[i]=args[i];
+     }
+ 
+     addKeyListener(this);
+   }
+ 
+   void showImage(int[] data, byte[] tmap, int width, int height) {
+     _image.getRaster().setDataElements(0,0,width,height,data);
+     repaint();
+   }
+ 
+   public void paint(Graphics graphics) {
+     Dimension sz=getSize();
+     if (_image!=null)
+       graphics.drawImage(_image, 0, 0, sz.width, sz.height, null);
+   }
+ 
+   public int getPixel(int x, int y) {
+     Dimension sz=getSize();
+     x=(x*_image.getWidth())/sz.width;
+     y=(y*_image.getHeight())/sz.height;
+     return _image.getRGB(x, y);
+   }
+ 
+   public void keyPressed(KeyEvent e) {
+     if (e.getKeyCode()==KeyEvent.VK_LEFT ||
+         e.getKeyCode()==KeyEvent.VK_UP ||
+         e.getKeyCode()==KeyEvent.VK_PAGE_UP ||
+         e.getKeyCode()==KeyEvent.VK_KP_UP ||
+         e.getKeyCode()==KeyEvent.VK_KP_LEFT) {
+       curimg--;
+       if (curimg<0) curimg+=imglist.length;
+       imageData.loadYUVFile(imglist[curimg]);
+       int[] data=imageData.getRGB();
+       showImage(data, tmap, imageData.image_width, imageData.image_height);
+     } else if (e.getKeyCode()==KeyEvent.VK_RIGHT ||
+         e.getKeyCode()==KeyEvent.VK_DOWN ||
+         e.getKeyCode()==KeyEvent.VK_PAGE_DOWN ||
+         e.getKeyCode()==KeyEvent.VK_KP_DOWN ||
+         e.getKeyCode()==KeyEvent.VK_KP_RIGHT) {
+       curimg++;
+       if (curimg>=imglist.length) curimg-=imglist.length;
+       imageData.loadYUVFile(imglist[curimg]);
+       int[] data=imageData.getRGB();
+       showImage(data, tmap, imageData.image_width, imageData.image_height);
+     }
+   }
+   public void keyReleased(KeyEvent e) { }
+   public void keyTyped(KeyEvent e) { }
+ }
Index: AiboPup/tools/seg/Listener.java
diff -c /dev/null AiboPup/tools/seg/Listener.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/seg/Listener.java	Sat Jul 26 21:55:59 2003
***************
*** 0 ****
--- 1,178 ----
+ import java.net.ServerSocket;
+ import java.net.Socket;
+ import java.io.InputStream;
+ import java.io.OutputStream;
+ import java.io.IOException;
+ 
+ public abstract class Listener implements Runnable {
+ 	public Listener() { _port=-1; _isConnected=false; }
+ 	public Listener(int port) { this(); setPort(port); }
+ 	public Listener(String host, int port) { this(); setHostPort(host, port); }
+ 
+ 	public void setPort(int port) {
+ 		_isServer=true;
+ 		_port=port;
+ 		startThread();
+ 	}
+ 
+ 	public void setHostPort(String host, int port) {
+ 		_isServer=false;
+ 		_host=host;
+ 		_port=port;
+ 		startThread();
+ 	}
+ 
+ 	public void startThread() {
+ 		destroy=false;
+ 		_listenerThread=new Thread(this);
+ 		_listenerThread.start();
+ 	}
+ 
+ 	public void run() {
+ 		if (_port >= 0) {
+ 			if (_isServer)
+ 				runServer();
+ 			else
+ 				runConnect();
+ 		} else {
+ 			System.out.println("can't start Listener without [host],port");
+ 		}
+ 	}
+ 
+ 	public void kill() {
+ 		destroy=true;
+ 		_isConnected=false;
+ 		if(_listenerThread!=null)
+ 			_listenerThread.interrupt();
+ 		close();
+ 	}
+ 
+ 	void frameTimer() {
+ 		_frametimer_numframes++;
+ 		if (System.currentTimeMillis()-_frametimer_timer>1000) {
+ 			System.out.println("updated at "+_frametimer_numframes+"hz");
+ 			_frametimer_numframes=0;
+ 			_frametimer_timer=System.currentTimeMillis();
+ 		}
+ 	}
+ 
+ 	double readDouble(InputStream in) throws IOException {
+ 		return Double.longBitsToDouble(readLong(in));
+ 	}
+ 
+ 	void writeDouble(OutputStream out, double x) throws IOException {
+ 		writeLong(out,Double.doubleToLongBits(x));
+ 	}
+ 
+ 	long readLong(InputStream in) throws IOException {
+ 		int read=0;
+ 		int last=0;
+ 		byte[] buf=new byte[8];
+ 		while (read<8 && last>=0) { last=in.read(buf,read,8-read); read+=last; }
+ 		if(last<0)
+ 			_isConnected=false;
+ 		return (b2l(buf[7])<<56) | (b2l(buf[6])<<48) |
+ 					 (b2l(buf[5])<<40) | (b2l(buf[4])<<32) |
+ 					 (b2l(buf[3])<<24) | (b2l(buf[2])<<16) |
+ 					 (b2l(buf[1])<< 8) | b2l(buf[0]);
+ 	}
+ 
+ 	void writeLong(OutputStream out, long x) throws IOException {
+ 		int bytelen=8;
+ 		byte[] buf=new byte[bytelen];
+ 		for(int i=0; i<bytelen; i++)
+ 			buf[i]=(new Long((x>>(8*i)) & 0xff)).byteValue();
+ 		out.write(buf,0,bytelen);
+ 	}
+ 
+ 	float readFloat(InputStream in) throws IOException {
+ 		return Float.intBitsToFloat(readInt(in));
+ 	}
+ 	
+ 	void writeFloat(OutputStream out, float x) throws IOException {
+ 		writeInt(out,Float.floatToIntBits(x));
+ 	}
+ 
+ 	int readInt(InputStream in) throws IOException {
+ 		int read=0;
+ 		int last=0;
+ 		byte[] buf=new byte[4];
+ 		while (read<4 && last>=0) { last=in.read(buf,read,4-read); read+=last; }
+ 		if(last<0)
+ 			_isConnected=false;
+ 		return (b2i(buf[3])<<24) | (b2i(buf[2])<<16) |
+ 					 (b2i(buf[1])<< 8) | b2i(buf[0]);
+ 	}
+ 	
+ 	void writeInt(OutputStream out, int x) throws IOException {
+ 		int bytelen=4;
+ 		byte[] buf=new byte[bytelen];
+ 		for(int i=0; i<bytelen; i++)
+ 			buf[i]=(new Integer((x>>(8*i)) & 0xff)).byteValue();
+ 		out.write(buf,0,bytelen);
+ 	}
+ 
+   byte[] readBytes(InputStream in, int bytes) throws IOException {
+     byte[] ret=new byte[bytes];
+     readBytes(ret, in, bytes);
+     return ret;
+   }
+ 
+ 	void readBytes(byte[] buf, InputStream in, int bytes) throws IOException {
+ 		int read=0;
+ 		int last=0;
+ 		while (read<bytes && last>=0) {
+ 			last=in.read(buf, read, bytes-read);
+ 			read+=last;
+ 		}
+ 		if(last<0)
+ 			_isConnected=false;
+ 	}
+ 
+ 	String readLine(InputStream in) throws java.io.IOException{
+ 		StringBuffer sbuf=new StringBuffer();
+ 		int x=in.read();
+ 		if(x==-1) {
+ 			_isConnected=false;
+ 			return sbuf.toString();
+ 		}
+ 		char c=(char)x;
+ 		while(c!='\n') {
+ 			sbuf.append(c);
+ 			x=in.read();
+ 			if(x==-1) {
+ 				_isConnected=false;
+ 				return sbuf.toString();
+ 			}
+ 			c=(char)x;
+ 		}
+ 		return sbuf.toString();
+ 	}
+ 	
+ 	int b2i(byte b) { return (b>=0)?(int)b:((int)b)+256; }
+ 	long b2l(byte b) { return (b>=0)?(long)b:((long)b)+256; }
+ 
+ 	abstract void runServer();
+ 	abstract void runConnect();
+ 	abstract public void close();
+ 
+ 	boolean _isServer;
+ 	int _port;
+ 	String _host;
+ 	boolean _isConnected;
+ 	volatile Thread _listenerThread;
+ 	volatile boolean destroy=false;
+ 
+ 	int _frametimer_numframes=0;
+ 	long _frametimer_timer=System.currentTimeMillis();
+ 
+   public static final int PACKET_TEXT=0;
+   public static final int PACKET_VISIONRAW_HALF=1;
+   public static final int PACKET_VISIONRAW_FULL=2;
+   public static final int PACKET_VISIONRAW_YFULL_UVHALF=3;
+   public static final int PACKET_VISIONRLE_FULL=4;
+   public static final int PACKET_WORLDSTATEJOINTS=5;
+   public static final int PACKET_WORLDSTATEPIDS=6;
+   public static final int PACKET_WORLDSTATEBUTTONS=7;
+   public static final int PACKET_WMCLASS=8;
+ }
Index: AiboPup/tools/seg/Makefile
diff -c /dev/null AiboPup/tools/seg/Makefile:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/seg/Makefile	Wed Oct  8 14:26:51 2003
***************
*** 0 ****
--- 1,35 ----
+ SRCS:=$(shell find . -name "*.java")
+ 
+ OBJS:=${SRCS:.java=.class}
+ 
+ CXX=javac
+ CURDIR:=$(shell pwd | sed 's/.*\///')
+ 
+ # SEP is to use ';' on windows and ':' on unix because windows is mentally deficient
+ SEP:=$(shell if [ "`uname`" = "CYGWIN" -o "`uname`" \> "CYGWIN" -a "`uname`" \< "CYGWIO" ] ; then echo ";" ; else echo ":" ; fi )
+ CXXFLAGS=-deprecation -classpath ".$(SEP)../mon/ftp.jar"
+ 
+ .PHONY: all clean msg build clearbuildlist
+ 
+ all: clearbuildlist build
+ 
+ %.class: %.java
+ 	@printf " $<" >> tmp_buildList.txt;
+ 
+ clearbuildlist:
+ 	@rm -f tmp_buildList.txt;
+ 
+ tmp_buildList.txt: ${OBJS}
+ #	@echo "Build list constructed...";
+ 
+ build: tmp_buildList.txt
+ 	@if [ -r tmp_buildList.txt ] ; then \
+ 		cat README; \
+ 		$(if $(shell which $(CXX)), \
+ 			echo "Compiling`cat tmp_buildList.txt`..."; $(CXX) $(CXXFLAGS) `cat tmp_buildList.txt`; , \
+ 			printf "  ***** WARNING: You don't have java... skipping TekkotsuMon *****\n"; \
+ 		) \
+ 	fi;
+ 
+ clean:
+ 	rm -f $(OBJS) *~ 
Index: AiboPup/tools/seg/MoveIndex.java
diff -c /dev/null AiboPup/tools/seg/MoveIndex.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/seg/MoveIndex.java	Thu Oct  9 02:30:08 2003
***************
*** 0 ****
--- 1,63 ----
+ import java.util.*;
+ import java.io.*;
+ 
+ public class MoveIndex {
+ 	public static void main(String[] args) {
+ 		if(args.length<3) {
+ 			System.out.println("Usage: java MoveIndex oldindex newindex infile [outfile]");
+ 			System.out.println("       Pass just the base filename (no extension)");
+ 			System.out.println("       Will read corresponding .tm and .col files and write updated files");
+ 			System.out.println("       If outfile is not provided, results will be written back to infile");
+ 			System.exit(2);
+ 		}
+ 		int oldi=Integer.parseInt(args[0]);
+ 		int newi=Integer.parseInt(args[1]);
+ 		String inf=args[2];
+ 		String outf=args[2];
+ 		if(args.length>3)
+ 			outf=args[3];
+ 		
+     try {
+ 			//Move index found in tm file
+ 			{
+ 				byte[] header=new byte[19];
+ 				byte[] tmdata=new byte[65536];
+ 				
+ 				FileInputStream in=new FileInputStream(inf+".tm");
+ 				in.read(header);
+ 				in.read(tmdata);
+ 					
+ 				for (int j=0; j<tmdata.length; j++)
+ 					if (tmdata[j]==oldi) tmdata[j]=(byte)newi;
+ 					
+ 				in.close();
+ 					
+ 				FileOutputStream out=new FileOutputStream(outf+".tm");
+ 				out.write(header);
+ 				out.write(tmdata);
+ 				out.close();
+ 			}
+ 			
+ 			//Move index found in col file
+ 			{
+ 				Vector coldata=new Vector();
+ 				BufferedReader in=new BufferedReader(new FileReader(inf+".col"));
+ 				while(in.ready())
+ 					coldata.add(in.readLine());
+ 				in.close();
+ 				PrintWriter out=new PrintWriter(new FileWriter(outf+".col"));
+ 				for(int i=0; i<coldata.size(); i++) {
+ 					String[] cur=((String)coldata.get(i)).split("\\s",2);
+ 					int idx=Integer.parseInt(cur[0]);
+ 					if(idx==oldi)
+ 						out.println(newi+" "+cur[1]);
+ 					else
+ 						out.println(cur[0]+" "+cur[1]);
+ 				}
+ 				out.close();
+ 			}
+ 				
+ 		} catch (Exception ex) { ex.printStackTrace(); }
+ 		
+ 	}
+ }
Index: AiboPup/tools/seg/README
diff -c /dev/null AiboPup/tools/seg/README:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/seg/README	Mon Sep 22 05:51:26 2003
***************
*** 0 ****
--- 1,3 ----
+  **     These tools require the JDK 1.4 or higher.  These files         **
+  **     are _not_ necessary for development.  If errors occur, you      **
+  **     can remove the tools/mon/Makefile and continue without it.      **
Index: AiboPup/tools/seg/TCPListener.java
diff -c /dev/null AiboPup/tools/seg/TCPListener.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/seg/TCPListener.java	Sat Jul 26 21:55:59 2003
***************
*** 0 ****
--- 1,67 ----
+ import java.net.ServerSocket;
+ import java.net.Socket;
+ 
+ public abstract class TCPListener extends Listener {
+ 	abstract void connected(Socket socket);
+ 
+ 	void runServer() {
+ 		Thread me = Thread.currentThread();
+ 		try { _serverSocket=new ServerSocket(_port); }
+ 		catch (Exception ex) {
+ 			System.out.println("port "+_port+": "+ex);
+ 			return;
+ 		}
+ 
+ 		while (me == _listenerThread && !destroy) {
+ 			try {
+ 				_socket=_serverSocket.accept();
+ 				connected(_socket);
+ 			} catch (Exception ex) { }
+ 		}
+ 	}
+ 
+ 	void runConnect() {
+ 		int attempts=0;
+ 		Thread me = Thread.currentThread();
+ 		while (me==_listenerThread && !destroy) {
+ 			if(attempts==0) {
+ 				System.out.println("["+_port+"] connecting ...");
+ 			}
+ 			try {
+ 				_socket=new Socket(_host,_port);
+ 				System.out.println("["+_port+"] connected");
+ 				attempts=0;
+ 				_isConnected=true;
+ 			} catch (Exception ex) {}
+ 			if(_isConnected) {
+ 				connected(_socket);
+ 				if(!destroy)
+ 					System.out.println("["+_port+"] disconnected");
+           System.out.println("["+_port+"] attempting to reestablish ..");
+ 			}
+ 			attempts++;
+ 			if(destroy) {
+ 				System.out.println("["+_port+"] connection closed");
+ 				break;
+ 			}
+ 			try {
+ 				Thread.sleep(500);
+ 			} catch (Exception ex) {}
+ 		}
+ 	}
+ 
+ 	public void close() {
+ 		_listenerThread=null;
+ 		_isConnected=false;
+ 		try { _socket.close(); } catch (Exception ex) { }
+ 		if (_isServer)
+ 			try { _serverSocket.close(); } catch (Exception ex) { }
+ 	}
+ 
+ 	public TCPListener() { super(); }
+ 	public TCPListener(int port) { super(port); }
+ 	public TCPListener(String host, int port) { super(host,port); }
+ 
+ 	Socket _socket;
+ 	ServerSocket _serverSocket;
+ }
Index: AiboPup/tools/seg/TextListener.java
diff -c /dev/null AiboPup/tools/seg/TextListener.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/seg/TextListener.java	Sat Jul 26 21:55:59 2003
***************
*** 0 ****
--- 1,54 ----
+ import java.io.InputStreamReader;
+ import java.io.BufferedReader;
+ import java.io.PrintStream;
+ import java.net.Socket;
+ 
+ public class TextListener extends TCPListener {
+   String _data="";
+   PrintStream _out;
+ 
+   void connected(Socket socket) {
+     _isConnected=true;
+     try {
+       BufferedReader in=new BufferedReader(new InputStreamReader(
+                           socket.getInputStream()));
+       _out=new PrintStream(socket.getOutputStream());
+       while (true) {
+         String read=in.readLine();
+         if (read==null) break;
+         synchronized (_data) { _data=_data+read+"\n"; }
+       }
+     } catch (Exception ex) { }
+ 
+     try { socket.close(); } catch (Exception ex) { }
+     _isConnected=false;
+   }
+  
+   public boolean hasData() {
+     return _data.length()!=0;
+   }
+ 
+   public String getData() {
+     String ret;
+     synchronized (_data) { 
+       ret=_data;
+       _data="";
+     }
+     return ret;
+   }
+ 
+   public void write(String s) {
+     if (_isConnected) {
+       _out.print(s);
+       _out.flush();
+     }
+   }
+ 
+   public boolean isConnected() {
+     return _isConnected;
+   }
+ 
+   public TextListener() { super(); }
+   public TextListener(int port) { super(port); }
+   public TextListener(String host, int port) { super(host,port); }
+ }
Index: AiboPup/tools/seg/ThresholdAdd.java
diff -c /dev/null AiboPup/tools/seg/ThresholdAdd.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/seg/ThresholdAdd.java	Thu Oct  9 02:29:39 2003
***************
*** 0 ****
--- 1,58 ----
+ import java.awt.image.*;
+ import java.awt.*;
+ import javax.swing.*;
+ import javax.swing.event.*;
+ import java.awt.event.*;
+ import java.io.*;
+ import java.util.*;
+ 
+ public class ThresholdAdd {
+   public static void main(String args[]) {
+     if (args.length<3) {
+       System.out.println("usage: java ThresholdAdd infile1 [infile2 ...] outfile");
+ 			System.out.println("       Each threshold file is copied in turn into the output");
+ 			System.out.println("       Intersecting regions are set to 0");
+ 			System.out.println("       You will still need to merge the .col files manually");
+       System.exit(2);
+     }
+     ThresholdAdd filter=new ThresholdAdd(args);
+   }
+ 
+   public ThresholdAdd (String files[]) {
+ 
+     try {
+       FileOutputStream out=new FileOutputStream(files[files.length-1]);
+ 
+       byte[] tmdata=new byte[65536];
+       byte[] mergeddata=new byte[65536];
+ 			boolean[] conflicts=new boolean[65536];
+ 
+       for (int i=0; i<mergeddata.length; i++) mergeddata[i]=0;
+       for (int i=0; i<conflicts.length; i++) conflicts[i]=false;
+ 
+       for (int i=0; i<files.length-1; i++) {
+         System.out.println("Adding "+files[i]+ "...");
+         FileInputStream in=new FileInputStream(files[i]);
+         in.read(tmdata, 0, 19);
+         if (i==0) out.write(tmdata, 0, 19);
+         in.read(tmdata);
+ 				
+ 				for (int j=0; j<mergeddata.length; j++)
+ 					if(!conflicts[j]) {
+ 						if(mergeddata[j]==0)
+ 							mergeddata[j]=tmdata[j];
+ 						else if(mergeddata[j]!=tmdata[j]) {
+ 							mergeddata[j]=0;
+ 							conflicts[j]=true;
+ 						}
+ 					}
+         in.close();
+       }
+ 
+       out.write(mergeddata);
+       out.close();
+     } catch (Exception ex) {
+       System.out.println(ex);
+     }
+   }
+ }
Index: AiboPup/tools/seg/ThresholdMerge.java
diff -c /dev/null AiboPup/tools/seg/ThresholdMerge.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/seg/ThresholdMerge.java	Thu Oct  9 02:29:39 2003
***************
*** 0 ****
--- 1,50 ----
+ import java.awt.image.*;
+ import java.awt.*;
+ import javax.swing.*;
+ import javax.swing.event.*;
+ import java.awt.event.*;
+ import java.io.*;
+ import java.util.*;
+ 
+ public class ThresholdMerge {
+   public static void main(String args[]) {
+     if (args.length<3) {
+       System.out.println("Usage: java ThresholdMerge infile1 [infile2 ...] outfile");
+ 			System.out.println("       Each threshold file is copied in turn into the output");
+ 			System.out.println("       Earlier thresholds override later thresholds");
+ 			System.out.println("       You will still need to merge the .col files manually");
+       System.exit(2);
+     }
+     ThresholdMerge filter=new ThresholdMerge(args);
+   }
+ 
+   public ThresholdMerge (String files[]) {
+ 
+     try {
+       FileOutputStream out=new FileOutputStream(files[files.length-1]);
+ 
+       byte[] tmdata=new byte[65536];
+       byte[] mergeddata=new byte[65536];
+ 
+       for (int i=0; i<mergeddata.length; i++) mergeddata[i]=0;
+ 
+       for (int i=0; i<files.length-1; i++) {
+         System.out.println("Adding "+files[i]+ "...");
+         FileInputStream in=new FileInputStream(files[i]);
+         in.read(tmdata, 0, 19);
+         if (i==0) out.write(tmdata, 0, 19);
+         in.read(tmdata);
+ 
+         for (int j=0; j<mergeddata.length; j++)
+           if (mergeddata[j]==0) mergeddata[j]=tmdata[j];
+         
+         in.close();
+       }
+ 
+       out.write(mergeddata);
+       out.close();
+     } catch (Exception ex) {
+       System.out.println(ex);
+     }
+   }
+ }
Index: AiboPup/tools/seg/UseThresh.java
diff -c /dev/null AiboPup/tools/seg/UseThresh.java:1.4
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/seg/UseThresh.java	Thu Oct  9 15:54:36 2003
***************
*** 0 ****
--- 1,56 ----
+ 
+ public class UseThresh {
+   public static void main(String s[]) {
+     if (s.length<2) {
+       System.out.println("usage: java UseThresh threshfile colfile [host]");
+       System.out.println("       will upload as default.tm and default.col");
+       System.out.println("       the host will have to be rebooted to reload vision files");
+       System.exit(1);
+     }
+ 
+ 		String tm=s[0];
+ 		String col=s[1];
+ 		String[] addrs;
+ 		if(s.length>2) {
+ 			addrs=new String[s.length-2];
+ 			for(int i=0; i<s.length-2; i++)
+ 				addrs[i]=s[i+2];
+ 		} else
+ 			addrs=new String[0];
+ 
+     try {
+       DogConfig dogConfig=new DogConfig (addrs);
+       DogConfigFTP dog_ftp=new DogConfigFTP(dogConfig.getIP(), 21,
+                                             "config", "config");
+ 			String dogtm=dogConfig.getValue("Vision","thresh");
+ 			dogtm=col.substring(col.lastIndexOf('/')+1);
+       dog_ftp.putFile(tm,dogtm);
+       sleep(1000);
+       dog_ftp=new DogConfigFTP(dogConfig.getIP(), 21,
+                                             "config", "config");
+ 			String dogcol=dogConfig.getValue("Vision","colors");
+ 			dogcol=col.substring(col.lastIndexOf('/')+1);
+       dog_ftp.putFile(col,dogcol);
+       sleep(1000);
+ 			//Someday.... dynamic reloading...
+       /*
+ 				TextListener listener=new TextListener(dogConfig.getIP(),
+           Integer.parseInt(dogConfig.getValue("Controller", "gui_port")));
+       while (!listener.isConnected()) {
+         sleep(10);
+       }
+ 			listener.write("!set vision.thresh=/ms/config/"+tm+"\n");
+ 			listener.write("!set vision.colors=/ms/config/"+col+"\n");
+       sleep(100);
+       listener.kill();
+ 			*/
+     } catch (IllegalArgumentException ex) {
+     } catch (Exception ex) {
+       ex.printStackTrace();
+     }
+   }
+ 
+   public static final void sleep(int tm) {
+     try { Thread.sleep(tm); } catch (Exception ex) {} 
+   }
+ }
Index: AiboPup/tools/seg/VisionFilter.java
diff -c /dev/null AiboPup/tools/seg/VisionFilter.java:1.2
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/seg/VisionFilter.java	Mon Jul 28 02:31:46 2003
***************
*** 0 ****
--- 1,58 ----
+ import java.awt.image.*;
+ import java.awt.*;
+ import javax.swing.*;
+ import javax.swing.event.*;
+ import java.awt.event.*;
+ import java.io.*;
+ import java.util.*;
+ 
+ public class VisionFilter {
+   static final int size_y=16;
+   static final int size_u=64;
+   static final int size_v=64;
+   
+   public static void main(String args[]) {
+     if (args.length!=2) {
+       System.out.println("usage: java VisionFilter infile outfile");
+       System.exit(0);
+     }
+     VisionFilter filter=new VisionFilter(args[0], args[1]);
+   }
+ 
+   public VisionFilter (String infile, String outfile) {
+     try {
+       FileInputStream in=new FileInputStream(infile);
+       FileOutputStream out=new FileOutputStream(outfile);
+ 
+       byte[] tmdata=new byte[65536];
+       in.read(tmdata,0,19);
+       out.write(tmdata,0,19);
+       in.read(tmdata);
+ 
+       filter(tmdata);
+ 
+       out.write(tmdata);
+       in.close();
+       out.close();
+     } catch (Exception ex) {
+       System.out.println(ex);
+     }
+   }
+ 
+   void filter(byte[] data) {
+     int y, u, v;
+     int cnt=0; 
+     for (y=0; y<16; y++)
+       for (u=0; u<64; u++)
+         for (v=0; v<64; v++)
+           if (data[offset(y, u, v)]==1) {
+             data[offset(y, u, v)]=9;
+             cnt++;
+           }
+     System.out.println(cnt);
+   }
+ 
+   static final int offset(int y, int u, int v) {
+     return (y*size_u+u)*size_v+v;
+   }
+ }
Index: AiboPup/tools/seg/VisionSegment.java
diff -c /dev/null AiboPup/tools/seg/VisionSegment.java:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/seg/VisionSegment.java	Sat Jul 26 21:56:00 2003
***************
*** 0 ****
--- 1,164 ----
+ import java.awt.image.*;
+ import java.awt.*;
+ import javax.swing.*;
+ import javax.swing.event.*;
+ import java.awt.event.*;
+ import java.io.*;
+ import java.util.*;
+ 
+ public class VisionSegment extends JFrame implements KeyListener {
+   BufferedImage _image;
+   String[] imglist;
+   byte[] tmap;
+   ImageData imageData;
+   int curimg;
+ 
+   public static void main(String args[]) {
+     if (args.length<3) {
+       System.out.println("usage: java VisionSegment threshold_file colors_file raw_image [raw images]");
+       System.exit(1);
+     }
+     VisionSegment visionSegment=new VisionSegment(args);
+     visionSegment.addWindowListener(new WindowAdapter() {
+         public void windowClosing(WindowEvent e) { System.exit(0); } });
+   }
+ 
+   public VisionSegment (String args[]) {
+     imageData=new ImageData();
+     imageData.loadRGBFile(args[2]);
+ 
+     int[] data=imageData.getRGB();
+     tmap=readThresholdMap(args[0]);
+     IndexColorModel cmodel=readColorModel(args[1]);
+ 
+     if (tmap==null || cmodel==null) return;
+ 
+     setBackground(Color.black);
+     setSize(imageData.image_width*2, imageData.image_height*2);
+     _image=new BufferedImage(imageData.image_width, imageData.image_height,
+         BufferedImage.TYPE_BYTE_INDEXED,cmodel);
+    
+     segmentImage(data, tmap, imageData.image_width, imageData.image_height);
+ 
+     imglist=new String[args.length-2];
+     curimg=0;
+     for (int i=2; i<args.length; i++) {
+       imglist[i-2]=args[i];
+     }
+ 
+     show();
+     addKeyListener(this);
+   }
+ 
+   void segmentImage(int[] data, byte[] tmap, int width, int height) {
+     int size_y=16, size_u=64, size_v=64;
+     byte[] imgdata=new byte[data.length];
+ 
+     for (int i=0; i<data.length; i++) {
+       int y=(data[i]>>16)&0xff;
+       int u=(data[i]>>8)&0xff;
+       int v=data[i]&0xff;
+       y=y>>4;
+       u=u>>2;
+       v=v>>2;
+       imgdata[i]=tmap[(y*size_u+u)*size_v+v];
+     }
+     _image.getRaster().setDataElements(0,0,width,height,imgdata);
+     repaint();
+   }
+ 
+   IndexColorModel readColorModel(String colorsfile) {
+     int[] cmap=readColorMap(colorsfile);
+     if (cmap==null || cmap.length==0) return null;
+     byte[] byte_cmap=new byte[cmap.length*3];
+ 
+     for (int i=0; i<cmap.length; i++) {
+       byte_cmap[i*3]=(byte) ((cmap[i]>>16) & 0xff);
+       byte_cmap[i*3+1]=(byte) ((cmap[i]>>8) & 0xff);
+       byte_cmap[i*3+2]=(byte) (cmap[i] & 0xff);
+     }
+     IndexColorModel cmodel=new IndexColorModel(7, cmap.length, byte_cmap,
+                                                0, false); 
+     return cmodel;
+   }
+ 
+   byte[] readThresholdMap(String thresholdfile) {
+     try {
+       byte[] tmdata=new byte[65536];
+       FileInputStream file_tm_fis=new FileInputStream(thresholdfile);
+       file_tm_fis.read(tmdata,0,19);
+       file_tm_fis.read(tmdata);
+       file_tm_fis.close();
+       return tmdata;
+     } catch (Exception ex) {
+       System.out.println("Error reading file "+thresholdfile+": "+ex);
+       return null;
+     }
+   }
+ 
+   int[] readColorMap(String colorsfile) {
+     try {
+       BufferedReader reader=new BufferedReader(new FileReader(colorsfile));
+       int[] v=new int[32];
+       int vnum=0;
+       String s=reader.readLine();
+       while(s!=null) {
+         if (s.length()==0 || s.charAt(0)=='#') { s=reader.readLine(); continue; }
+         
+         int pos=Integer.parseInt(s.substring(0,s.indexOf(" ")));
+ 
+         String colorstr=s.substring(s.indexOf("(")+1, s.indexOf(")")).trim();
+         String[] colorarr=colorstr.split("\\s+");
+ 
+         int color=0;
+         color|=Integer.parseInt(colorarr[0])<<16;
+         color|=Integer.parseInt(colorarr[1])<<8;
+         color|=Integer.parseInt(colorarr[2]);
+ 
+         v[pos]=color;
+         if (pos>vnum) vnum=pos;
+         s=reader.readLine();
+       }
+       int[] colors=new int[vnum+1];
+       for (int i=0; i<=vnum; i++) {
+         colors[i]=v[i];
+       }
+       return colors;
+     } catch (Exception ex) {
+       System.out.println("Error reading file "+colorsfile+": "+ex);
+       return null;
+     }
+   }
+ 
+   public void paint(Graphics graphics) {
+     Dimension sz=getSize();
+     if (_image!=null)
+       graphics.drawImage(_image, 0, 0, sz.width, sz.height, null);
+   }
+ 
+   public void keyPressed(KeyEvent e) {
+     if (e.getKeyCode()==KeyEvent.VK_LEFT ||
+         e.getKeyCode()==KeyEvent.VK_UP ||
+         e.getKeyCode()==KeyEvent.VK_PAGE_UP ||
+         e.getKeyCode()==KeyEvent.VK_KP_UP ||
+         e.getKeyCode()==KeyEvent.VK_KP_LEFT) {
+       curimg--;
+       if (curimg<0) curimg+=imglist.length;
+       imageData.loadRGBFile(imglist[curimg]);
+       int[] data=imageData.getRGB();
+       segmentImage(data, tmap, imageData.image_width, imageData.image_height);
+     } else if (e.getKeyCode()==KeyEvent.VK_RIGHT ||
+         e.getKeyCode()==KeyEvent.VK_DOWN ||
+         e.getKeyCode()==KeyEvent.VK_PAGE_DOWN ||
+         e.getKeyCode()==KeyEvent.VK_KP_DOWN ||
+         e.getKeyCode()==KeyEvent.VK_KP_RIGHT) {
+       curimg++;
+       if (curimg>=imglist.length) curimg-=imglist.length;
+       imageData.loadRGBFile(imglist[curimg]);
+       int[] data=imageData.getRGB();
+       segmentImage(data, tmap, imageData.image_width, imageData.image_height);
+     }
+   }
+   public void keyReleased(KeyEvent e) { }
+   public void keyTyped(KeyEvent e) { }
+ }
Index: AiboPup/tools/seg/VisionTrain.java
diff -c /dev/null AiboPup/tools/seg/VisionTrain.java:1.3
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/seg/VisionTrain.java	Tue Jul 29 19:43:40 2003
***************
*** 0 ****
--- 1,518 ----
+ import java.awt.image.*;
+ import java.awt.*;
+ import javax.swing.*;
+ import javax.swing.event.*;
+ import java.awt.event.*;
+ import java.util.*;
+ import java.awt.geom.*;
+ import java.io.*;
+ 
+ public class VisionTrain extends JFrame {
+   int height=700, width=700;
+   public ColorControlPanel controlPanel;
+   public static ColorConverter colorConverter;
+ 
+   public static void main(String args[]) {
+     if (args.length<1) {
+       System.out.println("usage: java VisionTrain [filename [filename ..]]");
+       System.exit(1);
+     }
+     colorConverter=new ColorConverter() {
+       public final float[] getColor(int r, int g, int b) {
+         float[] hsb=new float[3];
+         Color.RGBtoHSB(r, g, b, hsb);
+         float[] res=new float[2];
+         res[0]=hsb[0];
+         res[1]=hsb[1];
+         return res;
+       }
+     };
+     
+     VisionTrain visionTrain=new VisionTrain(args);
+     visionTrain.addWindowListener(new WindowAdapter() {
+         public void windowClosing(WindowEvent e) { System.exit(0); } });
+     visionTrain.controlPanel.addWindowListener(new WindowAdapter() {
+         public void windowClosing(WindowEvent e) { System.exit(0); } });
+   }
+  
+   public VisionTrain(String files[]) {
+     ImageShow imageShow=new ImageShow(files);
+     
+     setBackground(Color.black);
+     setSize(new Dimension(width, height));
+     Container root=this.getContentPane();
+     root.setLayout(new BorderLayout());
+     TrainCanvas trainCanvas=new TrainCanvas();
+     root.add(trainCanvas);
+     addKeyListener(trainCanvas);
+     show();
+ 
+     controlPanel=new ColorControlPanel(trainCanvas, imageShow);
+ 
+     ImageData imageData=new ImageData();
+ 
+     imageData.loadFullYUVFiles(files);
+     trainCanvas.plotImage(imageData.getHS(), imageData.getRGB());
+   }
+ }
+ 
+ class ColorControlPanel extends JFrame implements ActionListener,
+     ListSelectionListener {
+   Container root;
+   JTextField colorname;
+   JList colorlist;
+   DefaultListModel list;
+   JScrollPane colorlistscroll;
+   JButton remove, clear, save, imageview, invert;
+   int curcolor;
+ 
+   TrainCanvas trainCanvas;
+   ImageShow imageShow;
+ 
+   public ColorControlPanel (TrainCanvas trainCanvas, ImageShow imageShow) {
+     this.trainCanvas=trainCanvas;
+     this.imageShow=imageShow;
+     imageShow.addMouseMotionListener(trainCanvas);
+     imageShow.addMouseListener(trainCanvas);
+ 
+     setSize(new Dimension (120,350));
+     setLocation(800,50);
+ 
+     setResizable(false);
+     root=this.getContentPane();
+     root.setLayout(new FlowLayout());
+ 
+     colorname=new JTextField(10);
+     colorname.addActionListener(this);
+     root.add(colorname);
+ 
+     list=new DefaultListModel();
+     colorlist=new JList(list);
+     colorlist.setFixedCellWidth(90);
+     colorlist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+     colorlist.addListSelectionListener(this);
+ 
+     colorlistscroll=new JScrollPane(colorlist,
+                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+                        JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+     root.add(colorlistscroll);
+ 
+     remove=new JButton("remove");
+     remove.addActionListener(this);
+     root.add(remove);
+ 
+     clear=new JButton("clear");
+     clear.addActionListener(this);
+     root.add(clear);
+ 
+     invert=new JButton("invert");
+     invert.addActionListener(this);
+     root.add(invert);
+ 
+     imageview=new JButton("image view");
+     imageview.addActionListener(this);
+     root.add(imageview);
+ 
+     save=new JButton("save");
+     save.addActionListener(this);
+     root.add(save);
+ 
+     setCurColor(-1);
+     show();
+   }
+ 
+   public void actionPerformed(ActionEvent e) {
+     if (e.getSource()==save) {
+       JFileChooser chooser=new JFileChooser();
+       chooser.setSelectedFile(new File("default.tm"));
+       int returnval=chooser.showSaveDialog(save);
+       if (returnval==JFileChooser.APPROVE_OPTION) {
+         trainCanvas.save(chooser.getSelectedFile().getName());   
+       }
+     } else if (e.getSource()==clear) {
+       trainCanvas.clear();
+     } else if (e.getSource()==invert) {
+       trainCanvas.invert();
+     } else if (e.getSource()==remove) {
+       trainCanvas.remove((String)list.get(curcolor));
+       list.remove(curcolor);
+       setCurColor(-1);
+     } else if (e.getSource()==imageview) {
+       imageShow.show();
+     } else if (e.getSource()==colorname) {
+       String s=e.getActionCommand();
+       if (!s.equals("")) {
+         int i=0;
+         while (i<list.getSize() && !list.get(i).equals(s)) {
+           i++;
+         }
+         if (i==list.getSize()) {
+           list.addElement(s);
+           colorname.setText("");
+           colorlist.setSelectedIndex(i);
+         }
+       }
+     }
+   }
+ 
+   public void valueChanged(ListSelectionEvent e) {
+     if (!e.getValueIsAdjusting()) {
+       setCurColor(colorlist.getSelectedIndex());
+     }
+   }
+ 
+   void setCurColor(int index) {
+     curcolor=index;
+ 
+     if (index<0) {
+       remove.setEnabled(false);
+       clear.setEnabled(false);
+       trainCanvas.setCurColor(null);
+     } else {
+       remove.setEnabled(true);
+       clear.setEnabled(true);
+       trainCanvas.setCurColor((String)list.get(curcolor));
+     }
+   }
+ }
+ 
+ class TrainCanvas extends Canvas implements MouseListener,
+     MouseMotionListener, KeyListener {
+   BufferedImage image;
+   BufferedImage cachedplot;
+   BufferedImage inv_cachedplot;
+ 
+   Graphics2D graphics;
+   Polygon curPoly;
+   int lastx, lasty;
+   float f_width, f_height, f_offset;
+ 
+   Area curArea;
+   String curColor;
+   int curSelectModifier;
+   int curSelectModified;
+ 
+   Point imageHint;
+ 
+   Hashtable areasHash;
+ 
+   boolean inverted;
+ 
+   public static final int MODIFIER_NONE=0;
+   public static final int MODIFIER_SHIFT=1;
+   public static final int MODIFIER_CTRL=2;
+ 
+   float[] xy;
+   int[] rgb;
+ 
+   public TrainCanvas() {
+     setBackground(Color.black);
+     addMouseListener(this);
+     addMouseMotionListener(this);
+     curSelectModifier=MODIFIER_NONE;
+     curSelectModified=MODIFIER_NONE;
+     addKeyListener(this);
+     areasHash=new Hashtable();
+     inverted=false;
+     imageHint=null;
+   }
+ 
+   public void plotImage(float[] xy, int[] rgb) {
+     this.xy=xy;
+     this.rgb=rgb;
+     Dimension d=getSize();
+     f_width=(float)d.width-41;
+     f_height=(float)d.height-41;
+     f_offset=20;
+     cachedplot=new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_RGB);
+     inv_cachedplot=
+                new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_RGB);
+ 
+     graphics=(Graphics2D)cachedplot.getGraphics();
+     Graphics2D inv_graphics=(Graphics2D)inv_cachedplot.getGraphics();
+ 
+     inv_graphics.setColor(Color.white);
+     inv_graphics.fillRect(0,0,d.width, d.height);
+ 
+     for (int i=0; i<rgb.length; i++) {
+       //      draws thin
+       //      cachedplot.setRGB((int)(xy[i*2]*f_width),
+       //                        (int)(xy[i*2+1]*f_height), rgb[i]);
+ 
+       // draws thick
+       graphics.setColor(new Color(rgb[i]));
+       graphics.drawRect((int)(xy[i*2]*f_width+f_offset),
+                         (int)(xy[i*2+1]*f_height+f_offset), 1,1);
+ 
+       inv_graphics.setColor(new Color(rgb[i]));
+       inv_graphics.drawRect((int)(xy[i*2]*f_width+f_offset),
+                         (int)(xy[i*2+1]*f_height+f_offset), 1,1);
+     }
+ 
+     image=new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_RGB);
+     graphics=(Graphics2D)image.getGraphics();
+ //    graphics.drawImage(cachedplot,0,0,this);
+     redrawScene();
+     repaint();
+   }
+ 
+   public void mousePressed(MouseEvent e) {
+     if (curArea==null) return;
+     if (e.getButton()!=MouseEvent.BUTTON1) return;
+ 
+     curSelectModified=curSelectModifier;
+ 
+     if (curSelectModified!=MODIFIER_SHIFT
+         && curSelectModified!=MODIFIER_CTRL)
+       curArea.reset();
+ 
+     curPoly=new Polygon();
+     lastx=e.getX();
+     lasty=e.getY();
+     curPoly.addPoint(e.getX(), e.getY());
+     repaint();
+   }
+ 
+   public void mouseDragged(MouseEvent e) {
+     if (curArea==null) return;
+ 
+     int x=e.getX();
+     int y=e.getY();
+     if ((Math.abs(x-lastx)+Math.abs(y-lasty))>2) {
+       curPoly.addPoint(e.getX(), e.getY());
+       lastx=x;
+       lasty=y;
+       repaint();
+     }
+   }
+ 
+   public void mouseReleased(MouseEvent e) {
+     if (curArea==null) return;
+     if (e.getButton()!=MouseEvent.BUTTON1) return;
+ 
+     curPoly.addPoint(e.getX(), e.getY());
+     if (curPoly.npoints>=3) {
+       if (curSelectModified==MODIFIER_CTRL) curArea.subtract(new Area(curPoly));
+       else curArea.add(new Area(curPoly));
+     }
+     curPoly=null;
+     repaint();
+   }
+ 
+   public void mouseMoved(MouseEvent e){
+     Object source=e.getSource();
+     if (source instanceof ImageShow) {
+       ImageShow imageShow=(ImageShow)source;
+       int rgb=imageShow.getPixel(e.getX(), e.getY());
+       float[] xy=VisionTrain.colorConverter.getColor(rgb);
+       int x=(int)(xy[0]*f_width+f_offset);
+       int y=(int)(xy[1]*f_height+f_offset);
+       imageHint=new Point(x, y);
+       repaint();
+     }
+   }
+ 
+   public void mouseClicked(MouseEvent e){}
+   public void mouseExited(MouseEvent e){
+     if (e.getSource() instanceof ImageShow) {
+       imageHint=null;
+       repaint();
+     }
+   }
+   public void mouseEntered(MouseEvent e){}
+   public void updateLocation(MouseEvent e){}
+ 
+   public void paint(Graphics g) {
+     update(g);
+   }
+ 
+   public void update(Graphics g) {
+     Graphics2D g2d=(Graphics2D) g;
+     if (image!=null) g.drawImage(image, 0, 0, this);
+     if (inverted)
+       g2d.setColor(Color.black);
+     else
+       g2d.setColor(Color.white);
+ 
+     if (curArea!=null)
+       g2d.draw(curArea);
+ 
+     if (curPoly!=null)
+       g2d.draw(curPoly);
+ 
+     if (imageHint!=null) {
+       g2d.drawRect(imageHint.x-2, imageHint.y-2, 5, 5);
+     }
+   }
+ 
+   public void setCurColor(String color) {
+     curColor=color;
+     if (color==null) {
+       curArea=null;
+       return;
+     }
+ 
+     curArea=(Area)areasHash.get(color);
+     if (curArea==null) {
+       curArea=new Area();
+       areasHash.put(color, curArea);
+     }
+     redrawScene();
+   }
+ 
+   public void clear () {
+     if (curArea==null) return;
+     curArea.reset();
+     redrawScene();
+   }
+ 
+   public void invert () {
+     inverted=!inverted;
+     redrawScene();
+   }
+ 
+   public void remove(String color) {
+     curColor=null;
+     curArea=null;
+     areasHash.remove(color);
+     redrawScene();
+   }
+ 
+   public void redrawScene() {
+     if (inverted)
+       graphics.drawImage(inv_cachedplot,0,0,this);
+     else 
+       graphics.drawImage(cachedplot,0,0,this);
+     graphics.setColor(Color.gray);
+     Collection values=areasHash.values();
+     for (Iterator i=values.iterator(); i.hasNext(); ) {
+       Area area=(Area)i.next();
+       if (area!=curArea)
+         graphics.draw(area);
+     }
+     repaint();  
+   }
+ 
+   public void keyPressed(KeyEvent e) {
+     if (e.getKeyCode()==KeyEvent.VK_SHIFT) {
+       curSelectModifier=MODIFIER_SHIFT;
+     } else if (e.getKeyCode()==KeyEvent.VK_CONTROL) {
+       curSelectModifier=MODIFIER_CTRL;
+     }
+   }
+ 
+   public void keyReleased(KeyEvent e) {
+     if (e.getKeyCode()==KeyEvent.VK_SHIFT
+         ||e.getKeyCode()==KeyEvent.VK_CONTROL) {
+       curSelectModifier=MODIFIER_NONE;
+     }
+   }
+ 
+   public void keyTyped(KeyEvent e) { }
+ 
+   public void save (String filename) {
+     int dotpos=filename.lastIndexOf('.');
+     if (dotpos>0) filename=filename.substring(0,dotpos);
+     
+     Enumeration colors=areasHash.keys();
+     ArrayList colornames=new ArrayList(20);
+     while (colors.hasMoreElements()) colornames.add(colors.nextElement());
+     Collections.sort(colornames);
+     ArrayList areas=new ArrayList(20);
+ 
+     for (Iterator i=colornames.iterator(); i.hasNext();
+          areas.add(areasHash.get(i.next())));
+     
+     int size_y=16, size_u=64, size_v=64;
+     byte[] tmap=new byte[size_y*size_u*size_v];
+ 
+     float[] hsb=new float[3];
+     int y, u, v, r, g, b, h, s;
+     int iy, iu, iv, i;
+ 
+     for (iy=0; iy<16; iy++) {
+       for (iu=0; iu<64; iu++) {
+         for (iv=0; iv<64; iv++) {
+           y=iy<<4; u=iu<<2; v=iv<<2;
+           u=u*2-255;
+           v=v*2-255;
+           r=y+u;
+           b=y+v;
+           u=u>>1;
+           v=(v>>2)-(v>>4);
+           g=y-u-v;
+           if (r<0) r=0; if (g<0) g=0; if (b<0) b=0;
+           if (r>255) r=255; if (g>255) g=255; if (b>255) b=255;
+           float[] xy=VisionTrain.colorConverter.getColor(r, g, b);
+           h=(int)(xy[0]*f_width+f_offset);
+           s=(int)(xy[1]*f_height+f_offset);
+           Point point=new Point(h, s);
+           for (i=0; i<areas.size(); i++) {
+             Area area = (Area) areas.get(i);
+             if (area.contains(point)) {
+               tmap[(iy*size_u+iu)*size_v+iv]=(byte)(i+1);
+               break;
+             }
+           }
+         }
+       }
+     }
+ 
+     try {
+       FileOutputStream file_tm_fos=new FileOutputStream(filename + ".tm");
+       OutputStreamWriter file_tm_osw=new OutputStreamWriter(file_tm_fos);
+       file_tm_osw.write("TMAP\nYUV8\n" +
+           size_y + " " + size_u + " " + size_v + "\n");
+       file_tm_osw.flush();
+       file_tm_fos.write(tmap);
+       file_tm_osw.close();
+     } catch (Exception ex) {
+       System.out.println("Error saving to "+filename +".tm: " + ex);
+     }
+ 
+     int[][] avgcolors=new int[areas.size()][4]; 
+ 
+     int skip=(rgb.length/10000)+1;
+     for (i=0; i<rgb.length; i+=skip) {
+       for (int a=0; a<areas.size(); a++) {
+         Area area=(Area)areas.get(a);
+         Point p=new Point((int)(xy[i*2]*f_width+f_offset),
+                           (int)(xy[i*2+1]*f_height+f_offset));
+         if (area.contains(p)) {
+           avgcolors[a][0]+=(rgb[i]>>16)&0xff;
+           avgcolors[a][1]+=(rgb[i]>>8)&0xff;
+           avgcolors[a][2]+=rgb[i]&0xff;
+           avgcolors[a][3]++;
+         }
+       }
+     }
+ 
+     for (i=0; i<avgcolors.length; i++) {
+       if (avgcolors[i][3]>0) {
+         avgcolors[i][0]=avgcolors[i][0]/avgcolors[i][3];
+         avgcolors[i][1]=avgcolors[i][1]/avgcolors[i][3];
+         avgcolors[i][2]=avgcolors[i][2]/avgcolors[i][3];
+       } else {
+         avgcolors[i][0]=0;
+         avgcolors[i][1]=0;
+         avgcolors[i][2]=0;
+       }
+     }
+  
+     try {
+       FileWriter file_col_fw=new FileWriter(filename + ".col");
+       file_col_fw.write("0 (128 128 128) \"unclassified\" 8 1.00\n");
+       for (i=0; i<areas.size(); i++) {
+         file_col_fw.write((i+1)+ " (" +
+                           avgcolors[i][0] + " " +
+                           avgcolors[i][1] + " " +
+                           avgcolors[i][2] + ") " +
+                           "\"" + colornames.get(i)+ "\" 8 0.75\n");
+       }
+ 
+       file_col_fw.close();
+     } catch (Exception ex) {
+       System.out.println("Error saving to "+filename + ".col: " + ex);
+     }
+   }
+ }
Index: AiboPup/tools/seg/createyuv.m
diff -c /dev/null AiboPup/tools/seg/createyuv.m:1.1
*** /dev/null	Fri Oct 10 14:37:55 2003
--- AiboPup/tools/seg/createyuv.m	Fri Aug  8 23:49:37 2003
***************
*** 0 ****
--- 1,19 ----
+ size_y=16;
+ size_u=64;
+ size_v=64;
+ tmap=uint8(zeros(size_y*size_u*size_v,1));
+ 
+ 
+ for y=1:16
+   for u=37:57
+     for v=30:47
+       i=((y-1)*size_u+(u-1))*size_v+(v-1);
+       tmap(i)=7;
+     end
+   end
+ end
+ 
+ fp=fopen('out.tmap','w');
+ fprintf(fp,'TMAP\nYUV8\n%d %d %d\n',size_y,size_u,size_v);
+ fwrite(fp,tmap,'uint8');
+ fclose(fp);
