diff -urdN ../Tekkotsu_2.3/Behaviors/BehaviorBase.cc ./Behaviors/BehaviorBase.cc --- ../Tekkotsu_2.3/Behaviors/BehaviorBase.cc Tue Jan 4 14:51:37 2005 +++ ./Behaviors/BehaviorBase.cc Thu Jul 7 18:33:51 2005 @@ -1,15 +1,8 @@ #include "BehaviorBase.h" +#include "Events/EventRouter.h" std::set BehaviorBase::registry; -/*! @deprecated, behavior constructors should take a name argument (which by default should be the name of the type of the class) */ -BehaviorBase::BehaviorBase() - : ReferenceCounter(), EventListener(), started(false), - instanceName("?"), className("BehaviorBase") -{ - registry.insert(this); -} - BehaviorBase::BehaviorBase(const std::string& name) : ReferenceCounter(), EventListener(), started(false), instanceName(name), className(name) @@ -44,8 +37,8 @@ BehaviorBase::~BehaviorBase() { SetAutoDelete(false); if(started) - DoStop(); - //{ if(started) { references++; DoStop(); references--; } } + std::cerr << "Behavior " << getName() << " deleted while running: use 'RemoveReference', not 'delete'" << std::endl; + erouter->removeListener(this); registry.erase(this); } @@ -63,6 +56,8 @@ //std::cout << getName() << " stopped " << this << std::endl; if(started) { started=false; + erouter->removeListener(this); + erouter->removeTimer(this); RemoveReference(); } } @@ -72,9 +67,9 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.6 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.9 $ * $State: Exp $ - * $Date: 2005/01/04 19:51:37 $ + * $Date: 2005/07/07 22:33:51 $ */ diff -urdN ../Tekkotsu_2.3/Behaviors/BehaviorBase.h ./Behaviors/BehaviorBase.h --- ../Tekkotsu_2.3/Behaviors/BehaviorBase.h Tue Jan 4 14:51:37 2005 +++ ./Behaviors/BehaviorBase.h Sat Apr 23 14:32:59 2005 @@ -16,7 +16,7 @@ * rely on the reference counting. * * For an empty behavior boilerplate file to help you get started quickly, try - * Tekkotsu/docs/behavior_header.h: + * project/templates/behavior.h: * * But it would probably still be a good idea to go through the "First Behavior" tutorial to get a better idea of @@ -24,7 +24,7 @@ */ class BehaviorBase : public ReferenceCounter, public EventListener { public: - //! destructor - if is active when deleted, will call DoStop() first + //! destructor - if is active when deleted, will display a warning (don't delete directly - use RemoveReference()) virtual ~BehaviorBase(); //! By default, merely adds to the reference counter (through AddReference()); Note you should still call this from your overriding methods @@ -91,8 +91,6 @@ */ protected: - //! deprecated, behavior constructors should take a name argument (which by default should be the name of the type of the class) - BehaviorBase() __attribute__((deprecated)); //! constructor, @a name is used as both instance name and class name explicit BehaviorBase(const std::string& name); //! constructor, allows different initial values for class name and instance name @@ -113,10 +111,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.18 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.21 $ * $State: Exp $ - * $Date: 2005/01/04 19:51:37 $ + * $Date: 2005/04/23 18:32:59 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/CVS/Entries ./Behaviors/CVS/Entries --- ../Tekkotsu_2.3/Behaviors/CVS/Entries Wed Dec 31 19:00:00 1969 +++ ./Behaviors/CVS/Entries Wed Aug 10 11:03:30 2005 @@ -0,0 +1,14 @@ +/BehaviorBase.cc/1.9/Thu Jul 7 22:33:51 2005//Ttekkotsu-2_4 +/BehaviorBase.h/1.21/Sat Apr 23 18:32:59 2005//Ttekkotsu-2_4 +/Controller.cc/1.45/Wed Jun 1 05:47:44 2005//Ttekkotsu-2_4 +/Controller.h/1.35/Thu Aug 4 04:37:55 2005//Ttekkotsu-2_4 +/README/1.1/Sat Mar 1 20:53:25 2003//Ttekkotsu-2_4 +/StateNode.cc/1.25/Fri Apr 15 21:30:55 2005//Ttekkotsu-2_4 +/StateNode.h/1.20/Sun Aug 7 04:11:02 2005//Ttekkotsu-2_4 +/Transition.cc/1.16/Wed Aug 3 18:47:58 2005//Ttekkotsu-2_4 +/Transition.h/1.12/Sun Aug 7 04:11:02 2005//Ttekkotsu-2_4 +D/Controls//// +D/Demos//// +D/Mon//// +D/Nodes//// +D/Transitions//// diff -urdN ../Tekkotsu_2.3/Behaviors/CVS/Repository ./Behaviors/CVS/Repository --- ../Tekkotsu_2.3/Behaviors/CVS/Repository Wed Dec 31 19:00:00 1969 +++ ./Behaviors/CVS/Repository Wed Aug 10 11:03:18 2005 @@ -0,0 +1 @@ +Tekkotsu/Behaviors diff -urdN ../Tekkotsu_2.3/Behaviors/CVS/Root ./Behaviors/CVS/Root --- ../Tekkotsu_2.3/Behaviors/CVS/Root Wed Dec 31 19:00:00 1969 +++ ./Behaviors/CVS/Root Wed Aug 10 11:03:18 2005 @@ -0,0 +1 @@ +:pserver:anonymous@cvs.tekkotsu.org:/cvs diff -urdN ../Tekkotsu_2.3/Behaviors/CVS/Tag ./Behaviors/CVS/Tag --- ../Tekkotsu_2.3/Behaviors/CVS/Tag Wed Dec 31 19:00:00 1969 +++ ./Behaviors/CVS/Tag Wed Aug 10 11:03:18 2005 @@ -0,0 +1 @@ +Ntekkotsu-2_4 diff -urdN ../Tekkotsu_2.3/Behaviors/Controller.cc ./Behaviors/Controller.cc --- ../Tekkotsu_2.3/Behaviors/Controller.cc Wed Jan 5 15:28:34 2005 +++ ./Behaviors/Controller.cc Wed Jun 1 01:47:44 2005 @@ -2,10 +2,10 @@ #include "Motion/EmergencyStopMC.h" #include "Motion/LedMC.h" #include "Motion/MMAccessor.h" -#include "Shared/SharedObject.h" +#include "IPC/SharedObject.h" #include "Shared/WorldState.h" #include "Shared/get_time.h" -#include "SoundPlay/SoundManager.h" +#include "Sound/SoundManager.h" #include "Events/TextMsgEvent.h" #include "Shared/ERS210Info.h" #include "Shared/ERS220Info.h" @@ -48,11 +48,6 @@ } void Controller::DoStop() { - motman->removeMotion(display); - //these two lines help prevent residual display in case that was the only MotionCommand using LEDs - for(unsigned int i=LEDOffset; isetOutput(NULL,i,0.f); - display=MotionManager::invalid_MC_ID; sndman->ReleaseFile(config->controller.select_snd); sndman->ReleaseFile(config->controller.next_snd); sndman->ReleaseFile(config->controller.prev_snd); @@ -60,6 +55,11 @@ sndman->ReleaseFile(config->controller.cancel_snd); erouter->removeListener(this); reset(); + motman->removeMotion(display); + display=MotionManager::invalid_MC_ID; + //these two lines help prevent residual display in case that was the only MotionCommand using LEDs + for(unsigned int i=LEDOffset; isetOutput(NULL,i,0.f); gui_comm->printf("goodbye\n"); wireless->setDaemon(gui_comm,false); wireless->close(gui_comm); @@ -303,6 +303,28 @@ } } +bool Controller::select(ControlBase* item, const std::string& name) { + // Depth first + const std::vector& slots = item->getSlots(); + for(unsigned int i=0; igetName() == name) { // sensitive to #Name + char in[10]; + snprintf(in, 9, "%d", i); in[9]='\0'; + ControlBase * ret = item->takeInput(in); + if(ret!=NULL) { + setNext(ret); + return true; + } + } else { + if (select(slots[i], name)) + return true; + } + } + } + return false; +} + void Controller::takeLine(const std::string& s) { // cout << "RECEIVED: " << s << endl; if(s.size()==0) @@ -342,13 +364,18 @@ } else if(args[0]=="!cancel") { setNext(cmdstack.top()->doCancel()); } else if(args[0]=="!select") { + if (args.size() == 1) setNext(cmdstack.top()->doSelect()); + else { + select(root, args[1].c_str()); + refresh(); + } } else if(args[0]=="!next") { setNext(cmdstack.top()->doNextItem()); } else if(args[0]=="!prev") { setNext(cmdstack.top()->doPrevItem()); } else if(args[0]=="!dump_stack") { - theOneController->gui_comm->printf("stack_dump\n%d\n",cmdstack.size()); + theOneController->gui_comm->printf("stack_dump\n%lu\n",(unsigned long)cmdstack.size()); //this is rather ugly - can't iterate a stack, have to unstack and restack it. Oh well. std::stack< ControlBase* > tmpstack; while(!cmdstack.empty()) { @@ -465,8 +492,8 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.41 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.45 $ * $State: Exp $ - * $Date: 2005/01/05 20:28:34 $ + * $Date: 2005/06/01 05:47:44 $ */ diff -urdN ../Tekkotsu_2.3/Behaviors/Controller.h ./Behaviors/Controller.h --- ../Tekkotsu_2.3/Behaviors/Controller.h Wed Jan 5 15:28:35 2005 +++ ./Behaviors/Controller.h Thu Aug 4 00:37:55 2005 @@ -21,7 +21,7 @@ * - '!reset' - return to the root control * - '!next' - calls ControlBase::doNextItem() of the current control * - '!prev' - calls ControlBase::doPrevItem() of the current control - * - '!select' - calls ControlBase::doSelect() of the current control + * - '!select [item]' - calls ControlBase::doSelect() of the current control, unless item is specified, in which case it is searched for, starting at the root. * - '!cancel' - calls ControlBase::doCancel() of the current control * - '!dump_stack' - requests a dump of the current stack of submenus (useful if the GUI (re)connects and thus current robot state is unknown) * - '!msg text' - sends text out as a TextMsgEvent; also note that any text entered on the console port while a GUI is also connected will also be sent as a TextMsgEvent, without needing the !input. @@ -103,10 +103,10 @@ Controller() : BehaviorBase("Controller"), EventTrapper(), 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), isControlling(false), gui_comm(NULL) {init();} //!< Constructor Controller(ControlBase* r) : BehaviorBase("Controller"), EventTrapper(), 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), isControlling(false), gui_comm(NULL) { init(); } //!< Constructor, sets a default root control virtual ~Controller() { - cout << "~Controller()..." << endl; + std::cout << "~Controller()..." << std::endl; delete root; theOneController=NULL; - cout << "~Controller()-DONE" << endl; + std::cout << "~Controller()-DONE" << std::endl; } //!< Destructor //@{ @@ -152,6 +152,9 @@ //! called with each line that's entered on the tekkotsu console or from the GUI void takeLine(const std::string& s); + //! called with slots (options), a name to lookup; will select the named control + bool Controller::select(ControlBase* item, const std::string& name); + //! sets a config value - some values may require additional processing (done here) to have the new values take effect int setConfig(const char *str); @@ -217,10 +220,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.32 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.35 $ * $State: Exp $ - * $Date: 2005/01/05 20:28:35 $ + * $Date: 2005/08/04 04:37:55 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/BatteryCheckControl.h ./Behaviors/Controls/BatteryCheckControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/BatteryCheckControl.h Tue Jan 25 15:06:39 2005 +++ ./Behaviors/Controls/BatteryCheckControl.h Tue Jan 25 15:06:39 2005 @@ -111,7 +111,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.10 $ * $State: Exp $ * $Date: 2005/01/25 20:06:39 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/BehaviorActivatorControl.h ./Behaviors/Controls/BehaviorActivatorControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/BehaviorActivatorControl.h Thu Sep 25 11:26:10 2003 +++ ./Behaviors/Controls/BehaviorActivatorControl.h Thu Sep 25 11:26:10 2003 @@ -62,7 +62,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.8 $ * $State: Rel $ * $Date: 2003/09/25 15:26:10 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/BehaviorReportControl.h ./Behaviors/Controls/BehaviorReportControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/BehaviorReportControl.h Tue Jan 25 15:06:39 2005 +++ ./Behaviors/Controls/BehaviorReportControl.h Sat Feb 5 02:27:26 2005 @@ -37,14 +37,14 @@ snprintf(format,100," %%-%ds %%s\n",maxlen); sout->printf("** Currently Instantiated Behavior Report **\n"); - sout->printf("%d active, %d inactive, %d total\n\n",active.size(),inactive.size(),reg.size()); - sout->printf("Active Behaviors (%d):\n",active.size()); + sout->printf("%lu active, %lu inactive, %lu total\n\n",(unsigned long)active.size(),(unsigned long)inactive.size(),(unsigned long)reg.size()); + sout->printf("Active Behaviors:\n"); sout->printf(format,"Class Name","Instance Name"); sout->printf(format,"------------","---------------"); for(behlist_t::const_iterator it=active.begin(); it!=active.end(); it++) sout->printf(format,(*it)->getClassName().c_str(),(*it)->getName().c_str()); sout->printf("\n"); - sout->printf("Inactive Behaviors (%d):\n",inactive.size()); + sout->printf("Inactive Behaviors:\n"); sout->printf(format,"Class Name","Instance Name"); sout->printf(format,"------------","---------------"); for(behlist_t::const_iterator it=inactive.begin(); it!=inactive.end(); it++) @@ -58,10 +58,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.4 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.6 $ * $State: Exp $ - * $Date: 2005/01/25 20:06:39 $ + * $Date: 2005/02/05 07:27:26 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/BehaviorSwitchActivatorControl.h ./Behaviors/Controls/BehaviorSwitchActivatorControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/BehaviorSwitchActivatorControl.h Thu Sep 25 11:26:10 2003 +++ ./Behaviors/Controls/BehaviorSwitchActivatorControl.h Thu Sep 25 11:26:10 2003 @@ -54,7 +54,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.3 $ * $State: Rel $ * $Date: 2003/09/25 15:26:10 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/BehaviorSwitchControl.h ./Behaviors/Controls/BehaviorSwitchControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/BehaviorSwitchControl.h Thu Nov 11 19:05:03 2004 +++ ./Behaviors/Controls/BehaviorSwitchControl.h Wed Jun 29 18:02:58 2005 @@ -223,13 +223,15 @@ virtual void startmine() { if(!retained) { - mybeh=Al::construct(); + Al allocator; + mybeh=allocator.construct(); mybeh->setName(getName()); if(behgrp!=NULL) behgrp->curBehavior=mybeh; } else { if(mybeh==NULL) { - mybeh=Al::construct(); + Al allocator; + mybeh=allocator.construct(); mybeh->setName(getName()); mybeh->AddReference(); } @@ -265,10 +267,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.14 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.15 $ * $State: Exp $ - * $Date: 2004/11/12 00:05:03 $ + * $Date: 2005/06/29 22:02:58 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/CVS/Entries ./Behaviors/Controls/CVS/Entries --- ../Tekkotsu_2.3/Behaviors/Controls/CVS/Entries Wed Dec 31 19:00:00 1969 +++ ./Behaviors/Controls/CVS/Entries Wed Aug 10 11:03:18 2005 @@ -0,0 +1,47 @@ +/BatteryCheckControl.h/1.10/Tue Jan 25 20:06:39 2005//Ttekkotsu-2_4 +/BehaviorActivatorControl.h/1.8/Thu Sep 25 15:26:10 2003//Ttekkotsu-2_4 +/BehaviorReportControl.h/1.6/Sat Feb 5 07:27:26 2005//Ttekkotsu-2_4 +/BehaviorSwitchActivatorControl.h/1.3/Thu Sep 25 15:26:10 2003//Ttekkotsu-2_4 +/BehaviorSwitchControl.h/1.15/Wed Jun 29 22:02:58 2005//Ttekkotsu-2_4 +/ControlBase.cc/1.13/Wed Jun 1 05:47:44 2005//Ttekkotsu-2_4 +/ControlBase.h/1.22/Thu Nov 4 03:01:31 2004//Ttekkotsu-2_4 +/DumpFileControl.h/1.2/Thu Sep 25 15:26:10 2003//Ttekkotsu-2_4 +/EventLogger.cc/1.18/Sun Aug 7 04:11:03 2005//Ttekkotsu-2_4 +/EventLogger.h/1.7/Wed Jun 1 05:47:44 2005//Ttekkotsu-2_4 +/FileBrowserControl.cc/1.10/Wed Feb 2 18:20:27 2005//Ttekkotsu-2_4 +/FileBrowserControl.h/1.10/Wed Jan 14 20:43:44 2004//Ttekkotsu-2_4 +/FileInputControl.h/1.2/Tue Mar 23 00:55:01 2004//Ttekkotsu-2_4 +/FreeMemReportControl.cc/1.6/Sat Feb 5 07:27:26 2005//Ttekkotsu-2_4 +/FreeMemReportControl.h/1.8/Thu Nov 11 01:45:35 2004//Ttekkotsu-2_4 +/HelpControl.cc/1.10/Wed Jun 1 05:47:44 2005//Ttekkotsu-2_4 +/HelpControl.h/1.5/Mon Jan 19 22:03:58 2004//Ttekkotsu-2_4 +/LoadCalibration.h/1.5/Mon Jun 6 23:05:51 2005//Ttekkotsu-2_4 +/LoadPostureControl.h/1.16/Mon Jun 6 23:05:51 2005//Ttekkotsu-2_4 +/LoadWalkControl.h/1.9/Mon Jun 6 23:05:51 2005//Ttekkotsu-2_4 +/MCValueEditControl.h/1.3/Thu Sep 25 15:26:11 2003//Ttekkotsu-2_4 +/NetworkStatusControl.h/1.3/Sun Aug 7 04:11:03 2005//Ttekkotsu-2_4 +/NullControl.h/1.2/Thu Sep 25 15:26:11 2003//Ttekkotsu-2_4 +/PlaySoundControl.h/1.8/Mon Jun 6 23:05:51 2005//Ttekkotsu-2_4 +/PostureEditor.cc/1.18/Tue Aug 2 22:24:20 2005//Ttekkotsu-2_4 +/PostureEditor.h/1.8/Sun Aug 7 04:11:03 2005//Ttekkotsu-2_4 +/ProfilerCheckControl.h/1.6/Thu Nov 11 20:34:59 2004//Ttekkotsu-2_4 +/RebootControl.cc/1.4/Wed Feb 2 18:20:27 2005//Ttekkotsu-2_4 +/RebootControl.h/1.2/Thu Sep 25 15:26:11 2003//Ttekkotsu-2_4 +/RunSequenceControl.h/1.17/Mon Jun 6 23:05:51 2005//Ttekkotsu-2_4 +/SavePostureControl.h/1.12/Wed Jun 1 05:47:45 2005//Ttekkotsu-2_4 +/SaveWalkControl.h/1.10/Wed Jun 1 05:47:45 2005//Ttekkotsu-2_4 +/SensorObserverControl.cc/1.5/Wed Jun 1 05:47:45 2005//Ttekkotsu-2_4 +/SensorObserverControl.h/1.5/Sun Aug 7 04:11:03 2005//Ttekkotsu-2_4 +/ShutdownControl.cc/1.4/Wed Feb 2 18:20:27 2005//Ttekkotsu-2_4 +/ShutdownControl.h/1.3/Thu Sep 25 15:26:11 2003//Ttekkotsu-2_4 +/SimulatorAdvanceFrameControl.h/1.1/Thu Jun 23 22:37:28 2005//Ttekkotsu-2_4 +/StringInputControl.cc/1.5/Mon Jul 28 05:54:32 2003//Ttekkotsu-2_4 +/StringInputControl.h/1.5/Tue Mar 23 00:55:01 2004//Ttekkotsu-2_4 +/ToggleControl.h/1.4/Tue Mar 23 00:55:01 2004//Ttekkotsu-2_4 +/ValueEditControl.h/1.15/Sun Aug 7 04:11:03 2005//Ttekkotsu-2_4 +/ValueSetControl.h/1.3/Sun Jan 18 10:16:56 2004//Ttekkotsu-2_4 +/WalkCalibration.cc/1.11/Wed Jun 1 05:47:45 2005//Ttekkotsu-2_4 +/WalkCalibration.h/1.7/Wed Feb 2 18:47:23 2005//Ttekkotsu-2_4 +/WaypointWalkControl.cc/1.15/Mon Jun 6 23:05:51 2005//Ttekkotsu-2_4 +/WaypointWalkControl.h/1.6/Sun Aug 7 04:11:03 2005//Ttekkotsu-2_4 +D diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/CVS/Repository ./Behaviors/Controls/CVS/Repository --- ../Tekkotsu_2.3/Behaviors/Controls/CVS/Repository Wed Dec 31 19:00:00 1969 +++ ./Behaviors/Controls/CVS/Repository Wed Aug 10 11:03:18 2005 @@ -0,0 +1 @@ +Tekkotsu/Behaviors/Controls diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/CVS/Root ./Behaviors/Controls/CVS/Root --- ../Tekkotsu_2.3/Behaviors/Controls/CVS/Root Wed Dec 31 19:00:00 1969 +++ ./Behaviors/Controls/CVS/Root Wed Aug 10 11:03:18 2005 @@ -0,0 +1 @@ +:pserver:anonymous@cvs.tekkotsu.org:/cvs diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/CVS/Tag ./Behaviors/Controls/CVS/Tag --- ../Tekkotsu_2.3/Behaviors/Controls/CVS/Tag Wed Dec 31 19:00:00 1969 +++ ./Behaviors/Controls/CVS/Tag Wed Aug 10 11:03:18 2005 @@ -0,0 +1 @@ +Ntekkotsu-2_4 diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/ControlBase.cc ./Behaviors/Controls/ControlBase.cc --- ../Tekkotsu_2.3/Behaviors/Controls/ControlBase.cc Wed Nov 3 22:01:31 2004 +++ ./Behaviors/Controls/ControlBase.cc Wed Jun 1 01:47:44 2005 @@ -2,7 +2,7 @@ #include "Motion/MMAccessor.h" #include "Motion/LedMC.h" #include "Shared/string_util.h" -#include "SoundPlay/SoundManager.h" +#include "Sound/SoundManager.h" #include "Wireless/Wireless.h" #include #include @@ -331,6 +331,7 @@ refresh(); return this; }*/ + return this; //should never get here, but gcc 4 thinks we can } bool ControlBase::validInput(const std::string& str) { @@ -391,7 +392,7 @@ void ControlBase::clearMenu() { if(config->main.use_VT100) { - sout->printf("\r\33[%dA",(options.size()+1)); //moves cursor up to beginning of menu + sout->printf("\r\33[%luA",(unsigned long)(options.size()+1)); //moves cursor up to beginning of menu sout->printf("\33[J"); //clears to end of screen } } @@ -411,9 +412,9 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.9 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.13 $ * $State: Exp $ - * $Date: 2004/11/04 03:01:31 $ + * $Date: 2005/06/01 05:47:44 $ */ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/ControlBase.h ./Behaviors/Controls/ControlBase.h --- ../Tekkotsu_2.3/Behaviors/Controls/ControlBase.h Wed Nov 3 22:01:31 2004 +++ ./Behaviors/Controls/ControlBase.h Wed Nov 3 22:01:31 2004 @@ -167,7 +167,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.22 $ * $State: Exp $ * $Date: 2004/11/04 03:01:31 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/DumpFileControl.h ./Behaviors/Controls/DumpFileControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/DumpFileControl.h Thu Sep 25 11:26:10 2003 +++ ./Behaviors/Controls/DumpFileControl.h Thu Sep 25 11:26:10 2003 @@ -40,7 +40,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.2 $ * $State: Rel $ * $Date: 2003/09/25 15:26:10 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/EventLogger.cc ./Behaviors/Controls/EventLogger.cc --- ../Tekkotsu_2.3/Behaviors/Controls/EventLogger.cc Wed Dec 22 18:53:34 2004 +++ ./Behaviors/Controls/EventLogger.cc Sun Aug 7 00:11:03 2005 @@ -6,10 +6,16 @@ #include "StringInputControl.h" #include "NullControl.h" #include -#include "Events/LocomotionEvent.h" -#include "Events/TextMsgEvent.h" -#include "Events/VisionObjectEvent.h" -#include "SoundPlay/SoundManager.h" +#include "Sound/SoundManager.h" +#include "Vision/FilterBankGenerator.h" +#include "Shared/Base64.h" + +#include +#include + +Socket* EventLogger::logSocket=NULL; +unsigned int EventLogger::logSocketRefCount=0; +int EventLogger::port=10080; EventLogger::EventLogger() : ControlBase("Event Logger","Allows you to see/log all of the un-trapped events as they are generated"), logfilePath(), logfile(), verbosity(0) { for(unsigned int i=0; i("Verbosity","Controls verbosity level: 0=(gen,source,type); 1=0+gen_id,source_id,type_id; 2=1+duration,timestamp; 3=2+magnitude; additional columns may be added for subclass info","Please enter a new verbosity level: 0=(gen,source,type); 1=0+gen_id,source_id,type_id; 2=1+duration,timestamp; 3=2+magnitude; additional columns may be added for subclass info",&verbosity)); pushSlot(new ControlBase("[X] Console Output","If selected, outputs events to the console")); pushSlot(new StringInputControl("[ ] File Output","Please enter the filename to log to (in /ms/...)")); + if(logSocket==NULL) { + ASSERT(logSocketRefCount==0,"logSocket is NULL, ref count is non-zero"); + logSocket=wireless->socket(SocketNS::SOCK_STREAM,1024,1<<15); + wireless->setDaemon(logSocket); + wireless->listen(logSocket,port); + } + logSocketRefCount++; +} + +EventLogger::~EventLogger() { + clearSlots(); + if(--logSocketRefCount==0) { + wireless->setDaemon(logSocket,false); + wireless->close(logSocket); + logSocket=NULL; + } } ControlBase* EventLogger::doSelect() { @@ -67,11 +89,115 @@ std::string logdata = event.getDescription(true,verbosity); if(options[EventBase::numEGIDs+2]->getName()[1]=='X') sout->printf("EVENT: %s\n",logdata.c_str()); + if(logSocket!=NULL && wireless->isConnected(logSocket->sock)) { + xmlDoc * doc = xmlNewDoc((const xmlChar*)"1.0"); + xmlNode * cur = xmlNewNode(NULL,(const xmlChar*)""); + xmlSetProp(cur,(const xmlChar*)"type",(const xmlChar*)"log"); + xmlNode * desc = xmlNewNode(NULL,(const xmlChar*)"param"); + event.SaveXML(cur); + xmlAddChild(cur,desc); + xmlSetProp(desc,(const xmlChar*)"name",(const xmlChar*)"description"); + xmlSetProp(desc,(const xmlChar*)"value",(const xmlChar*)event.getDescription(true,3).c_str()); + xmlBuffer* buf=xmlBufferCreate(); + int n=xmlNodeDump(buf,doc,cur,0,1); + xmlFreeDoc(doc); + byte * nbuf = logSocket->getWriteBuffer(n+1); + if(nbuf!=NULL) { + memcpy(nbuf,xmlBufferContent(buf),n); + nbuf[n]='\n'; + logSocket->write(n+1); + } + xmlBufferFree(buf); + } checkLogFile(); if(logfile) logfile << logdata << endl; } +void EventLogger::logImage(FilterBankGenerator& fbg, unsigned int layer, unsigned int channel, const BehaviorBase* source/*=NULL*/) { + if(logSocket!=NULL && wireless->isConnected(logSocket->sock)) { + fbg.selectSaveImage(layer,channel); + unsigned int len=fbg.getBinSize(); + char * binbuf=new char[len]; + fbg.SaveBuffer(binbuf,len); + string b64buf=base64::encode(binbuf,len); + + xmlDoc * doc = xmlNewDoc((const xmlChar*)"1.0"); + xmlNode * cur = xmlNewNode(NULL,(const xmlChar*)"event"); + xmlSetProp(cur,(const xmlChar*)"type",(const xmlChar*)"image"); + if(source!=NULL) + xmlSetProp(cur,(const xmlChar*)"sid",(const xmlChar*)source->getName().c_str()); + snprintf(binbuf,len,"%d",get_time()); + xmlSetProp(cur,(const xmlChar*)"time",(const xmlChar*)binbuf); + delete [] binbuf; + xmlNodeSetContent(cur,(const xmlChar*)b64buf.c_str()); + xmlBuffer* buf=xmlBufferCreate(); + int n=xmlNodeDump(buf,doc,cur,0,1); + xmlFreeDoc(doc); + byte * nbuf = logSocket->getWriteBuffer(n+1); + if(nbuf!=NULL) { + memcpy(nbuf,xmlBufferContent(buf),n); + nbuf[n]='\n'; + logSocket->write(n+1); + } + xmlBufferFree(buf); + } +} + +void EventLogger::logMessage(std::string msg, const BehaviorBase* source/*=NULL*/, const char* icon/*=NULL*/, unsigned int placement/*=0*/) { + if(logSocket!=NULL && wireless->isConnected(logSocket->sock)) { + xmlDoc * doc = xmlNewDoc((const xmlChar*)"1.0"); + xmlNode * cur = xmlNewNode(NULL,(const xmlChar*)"event"); + xmlSetProp(cur,(const xmlChar*)"type",(const xmlChar*)"userlog"); + if(source!=NULL) + xmlSetProp(cur,(const xmlChar*)"sid",(const xmlChar*)source->getName().c_str()); + if(icon!=NULL) + xmlSetProp(cur,(const xmlChar*)"icon",(const xmlChar*)icon); + const unsigned int len=20; + char sbuf[len]; + snprintf(sbuf,len,"%d",placement); + xmlSetProp(cur,(const xmlChar*)"voff",(const xmlChar*)sbuf); + snprintf(sbuf,len,"%d",get_time()); + xmlSetProp(cur,(const xmlChar*)"time",(const xmlChar*)sbuf); + xmlNodeSetContent(cur,(const xmlChar*)msg.c_str()); + xmlBuffer* buf=xmlBufferCreate(); + int n=xmlNodeDump(buf,doc,cur,0,1); + xmlFreeDoc(doc); + byte * nbuf = logSocket->getWriteBuffer(n+1); + if(nbuf!=NULL) { + memcpy(nbuf,xmlBufferContent(buf),n); + nbuf[n]='\n'; + logSocket->write(n+1); + } + xmlBufferFree(buf); + } +} + +void EventLogger::logWebcam(const BehaviorBase* source/*=NULL*/) { + if(logSocket!=NULL && wireless->isConnected(logSocket->sock)) { + xmlDoc * doc = xmlNewDoc((const xmlChar*)"1.0"); + xmlNode * cur = xmlNewNode(NULL,(const xmlChar*)"event"); + xmlSetProp(cur,(const xmlChar*)"type",(const xmlChar*)"webcam"); + if(source!=NULL) + xmlSetProp(cur,(const xmlChar*)"sid",(const xmlChar*)source->getName().c_str()); + const unsigned int len=20; + char sbuf[len]; + snprintf(sbuf,len,"%d",get_time()); + xmlSetProp(cur,(const xmlChar*)"time",(const xmlChar*)sbuf); + xmlNodeSetContent(cur,(const xmlChar*)" "); + xmlBuffer* buf=xmlBufferCreate(); + int n=xmlNodeDump(buf,doc,cur,0,1); + xmlFreeDoc(doc); + byte * nbuf = logSocket->getWriteBuffer(n+1); + if(nbuf!=NULL) { + memcpy(nbuf,xmlBufferContent(buf),n); + nbuf[n]='\n'; + logSocket->write(n+1); + } + xmlBufferFree(buf); + } +} + void EventLogger::clearSlots() { erouter->removeListener(this); ControlBase::clearSlots(); @@ -92,13 +218,13 @@ logfilePath=strin->getLastInput(); logfile.clear(); if(logfilePath.size()!=0) { - sout->printf("Opening `/ms/%s'\n",logfilePath.c_str()); - logfile.open(("/ms/"+logfilePath).c_str()); + sout->printf("Opening `%s'\n",(config->portPath(logfilePath)).c_str()); + logfile.open((config->portPath(logfilePath)).c_str()); if(!logfile.fail()) { setStatus(cur,'X'); strin->setName(strin->getName()+": "+logfilePath); } else { - serr->printf("Opening `/ms/%s' failed\n",logfilePath.c_str()); + serr->printf("Opening `%s' failed\n",(config->portPath(logfilePath)).c_str()); } } } @@ -109,8 +235,8 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.16 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.18 $ * $State: Exp $ - * $Date: 2004/12/22 23:53:34 $ + * $Date: 2005/08/07 04:11:03 $ */ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/EventLogger.h ./Behaviors/Controls/EventLogger.h --- ../Tekkotsu_2.3/Behaviors/Controls/EventLogger.h Thu Oct 7 18:15:20 2004 +++ ./Behaviors/Controls/EventLogger.h Wed Jun 1 01:47:44 2005 @@ -6,12 +6,15 @@ #include "Events/EventListener.h" #include +class FilterBankGenerator; +class BehaviorBase; + //! allows logging of events to the console or a file class EventLogger : public ControlBase, public EventListener { public: //!constructor EventLogger(); - virtual ~EventLogger() { clearSlots(); } + virtual ~EventLogger(); //!opens a custom (embedded) menu to toggle individual EGIDs virtual ControlBase* doSelect(); @@ -21,6 +24,24 @@ //!sends all events received to stdout and/or logfile virtual void processEvent(const EventBase& event); + //!returns #logSocket + static class Socket* getLogSocket() { return logSocket; } + + //! returns #port + static int getLogSocketPort() { return port; } + + //! sets #port + static void setLogSocketPort(int p) { port=p; } + + //! send the current camera image over the log socket + static void logImage(FilterBankGenerator& fbg, unsigned int layer, unsigned int channel, const BehaviorBase* source=NULL); + + //! send a string over the log socket + static void logMessage(std::string msg, const BehaviorBase* source=NULL, const char* icon=NULL, unsigned int placement=0); + + //! request that the desktop side take a picture with the webcam (if available) + static void logWebcam(const BehaviorBase* source=NULL); + protected: virtual void clearSlots(); @@ -35,7 +56,16 @@ //!if a filename is given, events are logged to here std::ofstream logfile; - + + //! events which are logged will be sent over this port in an xml format. See eventlog.dtd in the docs directory + static class Socket* logSocket; + + //! port number #logSocket will listen on + static int port; + + //! reference count for #logSocket -- when this hits 0, close the socket + static unsigned int logSocketRefCount; + //!controls the level of verbosity - currently 0 through 2 unsigned int verbosity; }; @@ -45,10 +75,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.6 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.7 $ * $State: Exp $ - * $Date: 2004/10/07 22:15:20 $ + * $Date: 2005/06/01 05:47:44 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/FileBrowserControl.cc ./Behaviors/Controls/FileBrowserControl.cc --- ../Tekkotsu_2.3/Behaviors/Controls/FileBrowserControl.cc Wed Jan 14 15:43:43 2004 +++ ./Behaviors/Controls/FileBrowserControl.cc Wed Feb 2 13:20:27 2005 @@ -4,6 +4,8 @@ #include #include +using namespace std; + ControlBase * FileBrowserControl::activate(MotionManager::MC_ID display, Socket * gui) { rebuildmenu(); return ControlBase::activate(display,gui); @@ -158,9 +160,9 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.9 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.10 $ * $State: Exp $ - * $Date: 2004/01/14 20:43:43 $ + * $Date: 2005/02/02 18:20:27 $ */ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/FileBrowserControl.h ./Behaviors/Controls/FileBrowserControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/FileBrowserControl.h Wed Jan 14 15:43:44 2004 +++ ./Behaviors/Controls/FileBrowserControl.h Wed Jan 14 15:43:44 2004 @@ -72,7 +72,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.10 $ * $State: Exp $ * $Date: 2004/01/14 20:43:44 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/FileInputControl.h ./Behaviors/Controls/FileInputControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/FileInputControl.h Mon Mar 22 19:55:01 2004 +++ ./Behaviors/Controls/FileInputControl.h Mon Mar 22 19:55:01 2004 @@ -48,7 +48,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.2 $ * $State: Exp $ * $Date: 2004/03/23 00:55:01 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/FreeMemReportControl.cc ./Behaviors/Controls/FreeMemReportControl.cc --- ../Tekkotsu_2.3/Behaviors/Controls/FreeMemReportControl.cc Thu Sep 25 11:26:11 2003 +++ ./Behaviors/Controls/FreeMemReportControl.cc Sat Feb 5 02:27:26 2005 @@ -1,6 +1,8 @@ #include "FreeMemReportControl.h" -#include -#include +#ifdef PLATFORM_APERIOS +# include +# include +#endif void FreeMemReportControl::processEvent(const EventBase& e) { ASSERTRET(e.getGeneratorID()==EventBase::timerEGID,"Unexpected event"); @@ -11,7 +13,7 @@ if(freememprintf("WARNING: Low memory: %d\n",freemem); + serr->printf("WARNING: Low memory: %lu\n",(unsigned long)freemem); } } else { if(isWarning) { @@ -25,7 +27,7 @@ void FreeMemReportControl::refresh() { char tmp[256]; - sprintf(tmp,"Free Mem: %d",freeMem()); + sprintf(tmp,"Free Mem: %lu",(unsigned long)freeMem()); options[1]->setName(tmp); ControlBase::refresh(); report(); @@ -35,18 +37,22 @@ //! reports size of free memory - if this is below low_mem, also generates a warning void FreeMemReportControl::report() { size_t freemem=freeMem(); - sout->printf("%d bytes free\n",freemem); + sout->printf("%lu bytes free\n",(unsigned long)freemem); if(freememprintf("WARNING: Low memory: %d\n",freemem); + serr->printf("WARNING: Low memory: %lu\n",(unsigned long)freemem); resetTimerFreq(); } //! returns the size of the free memory size_t FreeMemReportControl::freeMem() { size_t freemem; +#ifdef PLATFORM_APERIOS if (AnalyzerGetSizeOfFreeMemory(&freemem)!=azrSUCCESS) sout->printf("Aperios error: getsizeoffreememory failed\n"); +#else + freemem=-1U; +#endif return freemem; } @@ -63,9 +69,9 @@ * @author ejt (object), alokl (core function) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.4 $ - * $State: Rel $ - * $Date: 2003/09/25 15:26:11 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.6 $ + * $State: Exp $ + * $Date: 2005/02/05 07:27:26 $ */ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/FreeMemReportControl.h ./Behaviors/Controls/FreeMemReportControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/FreeMemReportControl.h Wed Nov 10 20:45:35 2004 +++ ./Behaviors/Controls/FreeMemReportControl.h Wed Nov 10 20:45:35 2004 @@ -66,7 +66,7 @@ * @author ejt (object), alokl (core function) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.8 $ * $State: Exp $ * $Date: 2004/11/11 01:45:35 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/HelpControl.cc ./Behaviors/Controls/HelpControl.cc --- ../Tekkotsu_2.3/Behaviors/Controls/HelpControl.cc Wed Jan 5 15:35:41 2005 +++ ./Behaviors/Controls/HelpControl.cc Wed Jun 1 01:47:44 2005 @@ -37,7 +37,7 @@ const std::string pre=" "+prefix; unsigned int numlen=1; if(slots.size()>1) - numlen=(int)(log(slots.size()-1)/log(10))+1; + numlen=(int)(log(slots.size()-1.0)/log(10.0))+1; #ifdef HelpControl_HTML_ unsigned int ngoodslots=0; for(unsigned int i=0; iportPath(config->motion.root)), cp(calp) { setFilter("*.txt"); } //!Constructor LoadCalibration(const std::string& n,WalkMC::CalibrationParam* calp) - : FileBrowserControl(n,"","/ms/data/motion/"), cp(calp) + : FileBrowserControl(n,"",config->portPath(config->motion.root)), cp(calp) { setFilter("*.txt"); } //!Constructor LoadCalibration(const std::string& n, const std::string& d,WalkMC::CalibrationParam* calp) - : FileBrowserControl(n,d,"/ms/data/motion/"), cp(calp) + : FileBrowserControl(n,d,config->portPath(config->motion.root)), cp(calp) { setFilter("*.txt"); } protected: @@ -31,7 +31,7 @@ //!calls readData() for each of the matrices virtual ControlBase* selectedFile(const std::string& f) { - FILE * file=fopen(f.c_str(),"r"); + FILE * file=fopen(config->portPath(f).c_str(),"r"); if(readMaxs(file)) if(readData(file,cp->f_calibration)) readData(file,cp->b_calibration); @@ -86,10 +86,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.3 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.5 $ * $State: Exp $ - * $Date: 2004/02/26 01:02:25 $ + * $Date: 2005/06/06 23:05:51 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/LoadPostureControl.h ./Behaviors/Controls/LoadPostureControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/LoadPostureControl.h Fri Jan 7 14:34:22 2005 +++ ./Behaviors/Controls/LoadPostureControl.h Mon Jun 6 19:05:51 2005 @@ -8,7 +8,7 @@ #include "Motion/EmergencyStopMC.h" #include "Events/EventRouter.h" #include "Motion/LedMC.h" -#include "SoundPlay/SoundManager.h" +#include "Sound/SoundManager.h" #include //! Upon activation, loads a position from a file name read from cin (stored in ms/data/motion...) @@ -17,7 +17,7 @@ public: //! Constructor LoadPostureControl(const std::string& n, MotionManager::MC_ID estop_id) - : FileBrowserControl(n,"Loads a posture from user-selected file",config->motion.root), + : FileBrowserControl(n,"Loads a posture from user-selected file",config->portPath(config->motion.root)), estopid(estop_id), ledid(MotionManager::invalid_MC_ID), file() { setFilter("*.pos"); @@ -74,10 +74,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.14 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.16 $ * $State: Exp $ - * $Date: 2005/01/07 19:34:22 $ + * $Date: 2005/06/06 23:05:51 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/LoadWalkControl.h ./Behaviors/Controls/LoadWalkControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/LoadWalkControl.h Sat Jan 10 15:10:27 2004 +++ ./Behaviors/Controls/LoadWalkControl.h Mon Jun 6 19:05:51 2005 @@ -12,14 +12,14 @@ 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) + : FileBrowserControl(n,"Loads a set of walk parameters from a file specified by user",config->portPath(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) + : FileBrowserControl(n,"Loads a set of walk parameters from a file specified by user",config->portPath(config->motion.root)), walk_id(MotionManager::invalid_MC_ID), thewalk(awalk) { setFilter("*.prm"); } @@ -56,10 +56,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.8 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.9 $ * $State: Exp $ - * $Date: 2004/01/10 20:10:27 $ + * $Date: 2005/06/06 23:05:51 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/MCValueEditControl.h ./Behaviors/Controls/MCValueEditControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/MCValueEditControl.h Thu Sep 25 11:26:11 2003 +++ ./Behaviors/Controls/MCValueEditControl.h Thu Sep 25 11:26:11 2003 @@ -29,7 +29,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.3 $ * $State: Rel $ * $Date: 2003/09/25 15:26:11 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/NetworkStatusControl.h ./Behaviors/Controls/NetworkStatusControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/NetworkStatusControl.h Wed Jan 12 17:37:26 2005 +++ ./Behaviors/Controls/NetworkStatusControl.h Sun Aug 7 00:11:03 2005 @@ -8,7 +8,10 @@ #include "NullControl.h" #include "Events/EventRouter.h" #include "Wireless/Wireless.h" -#include + +#ifdef PLATFORM_APERIOS +# include +#endif //! will display current network status such as wireless signal strength class NetworkStatusControl : public ControlBase, public EventListener { @@ -27,6 +30,7 @@ //! calls report() virtual void refresh() { erouter->addTimer(this,0,1000,true); +#ifdef PLATFORM_APERIOS EtherDriverGetWLANStatisticsMsg msg; EtherStatus status = ERA201D1_GetWLANStatistics(&msg); clearSlots(); @@ -52,14 +56,14 @@ pushSlot(new NullControl("Error Accessing wireless statistics",tmp)); serr->printf("%s",tmp); } - +#endif ControlBase::refresh(); } - //! stops listening for power events and sets display to invalid virtual void deactivate() { erouter->removeListener(this); ControlBase::deactivate(); } + //! refresh the control whenever an event is received virtual void processEvent(const EventBase& /*event*/) { refresh(); } @@ -73,10 +77,10 @@ * @author ejt (UI repackaging) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.1 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.3 $ * $State: Exp $ - * $Date: 2005/01/12 22:37:26 $ + * $Date: 2005/08/07 04:11:03 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/NullControl.h ./Behaviors/Controls/NullControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/NullControl.h Thu Sep 25 11:26:11 2003 +++ ./Behaviors/Controls/NullControl.h Thu Sep 25 11:26:11 2003 @@ -32,7 +32,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.2 $ * $State: Rel $ * $Date: 2003/09/25 15:26:11 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/PlaySoundControl.h ./Behaviors/Controls/PlaySoundControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/PlaySoundControl.h Thu Sep 25 11:26:11 2003 +++ ./Behaviors/Controls/PlaySoundControl.h Mon Jun 6 19:05:51 2005 @@ -3,14 +3,14 @@ #define INCLUDED_PlaySoundControl_h_ #include "FileBrowserControl.h" -#include "SoundPlay/SoundManager.h" +#include "Sound/SoundManager.h" //! Upon activation, loads a position from a file name read from cin (stored in ms/data/motion...) class PlaySoundControl : public FileBrowserControl { public: //! Constructor PlaySoundControl(const std::string& n) - : FileBrowserControl(n,"Plays a sound from a user specified sound file",config->sound.root) + : FileBrowserControl(n,"Plays a sound from a user specified sound file",config->portPath(config->sound.root)) { setFilter("*.wav"); } @@ -32,10 +32,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.6 $ - * $State: Rel $ - * $Date: 2003/09/25 15:26:11 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.8 $ + * $State: Exp $ + * $Date: 2005/06/06 23:05:51 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/PostureEditor.cc ./Behaviors/Controls/PostureEditor.cc --- ../Tekkotsu_2.3/Behaviors/Controls/PostureEditor.cc Tue Jan 11 13:40:00 2005 +++ ./Behaviors/Controls/PostureEditor.cc Tue Aug 2 18:24:20 2005 @@ -3,7 +3,7 @@ #include "Motion/EmergencyStopMC.h" #include "Motion/MotionSequenceMC.h" #include "Motion/LedMC.h" -#include "SoundPlay/SoundManager.h" +#include "Sound/SoundManager.h" #include "Events/EventRouter.h" #include "ValueEditControl.h" #include "NullControl.h" @@ -16,7 +16,7 @@ estopID(estop_ID), loadPose(NULL), disabledLoadPose(NULL), savePose(NULL), pauseCalled(false) { // add load and save menus - pushSlot(loadPose=new FileInputControl("Load Posture","Select a posture to open",config->motion.root)); + pushSlot(loadPose=new FileInputControl("Load Posture","Select a posture to open",config->portPath(config->motion.root))); loadPose->setFilter("*.pos"); disabledLoadPose=new NullControl("[Load disabled by EStop]","Cannot load new postures while EStop is active"); pushSlot(savePose=new StringInputControl("Save Posture","Please enter the filename to save to (in "+config->motion.root+")")); @@ -43,6 +43,8 @@ ControlBase * PostureEditor::activate(MotionManager::MC_ID disp_id, Socket * gui) { //cout << "activate" << endl; + if(reachID!=MotionManager::invalid_MC_ID) // was already activated + return ControlBase::activate(disp_id,gui); // happens when estop is turned on, causing "reactivation" // start off with current pose pose.takeSnapshot(); pose.setWeights(1); @@ -90,24 +92,28 @@ //cout << "pause" << endl; refresh(); //one last time, in case this pause is due to un-estop putting Controller into low-profile mode pauseCalled=true; - erouter->removeListener(this,EventBase::timerEGID); + erouter->removeTimer(this); + ControlBase::pause(); } void PostureEditor::deactivate() { //cout << "deactivate" << endl; + //cout << "removeMotion(" << reachID << ")" << endl; motman->removeMotion(reachID); reachID=MotionManager::invalid_MC_ID; erouter->removeListener(this); + erouter->removeTimer(this); ControlBase::deactivate(); } void PostureEditor::processEvent(const EventBase& e) { + //cout << "processEvent(" << e.getName() << ")" << endl; if(e.getGeneratorID()==EventBase::estopEGID) { if(e.getTypeID()==EventBase::deactivateETID) { MMAccessor(reachID)->play(); - erouter->removeListener(this,EventBase::timerEGID); + erouter->removeTimer(this); if(!pauseCalled) refresh(); } else { @@ -138,6 +144,10 @@ //cout << "updatePose" << endl; bool paused=isEStopped(); MMAccessor reach_acc(reachID); + if(paused) { + reach_acc->clear(); + return; + } PostureEngine curpose; reach_acc->getPose(curpose); reach_acc->clear(); @@ -149,11 +159,7 @@ //now move to desired posture reach_acc->setTime(delay); reach_acc->setPose(pose); - //run now or later? - if(paused) - reach_acc->pause(); - else - reach_acc->play(); + reach_acc->play(); } @@ -162,8 +168,8 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.14 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.18 $ * $State: Exp $ - * $Date: 2005/01/11 18:40:00 $ + * $Date: 2005/08/02 22:24:20 $ */ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/PostureEditor.h ./Behaviors/Controls/PostureEditor.h --- ../Tekkotsu_2.3/Behaviors/Controls/PostureEditor.h Thu Dec 2 13:48:56 2004 +++ ./Behaviors/Controls/PostureEditor.h Sun Aug 7 00:11:03 2005 @@ -3,7 +3,7 @@ #define INCLUDED_PostureEditor_h_ #include "ControlBase.h" -#include "Shared/SharedObject.h" +#include "IPC/SharedObject.h" #include "Motion/PostureEngine.h" #include "Motion/MotionManager.h" #include "Events/EventListener.h" @@ -38,7 +38,7 @@ static const unsigned int moveTime=1500; //!< number of milliseconds to take to load a posture - individual joint changes will be done in half the time bool isEStopped(); //!< called to check status of estop - void updatePose(unsigned int delay); //!< called anytime pose is modified; uses #reachID to move to #pose if estop is off, setting up #ledID otherwise + void updatePose(unsigned int delay); //!< called anytime pose is modified; uses #reachID to move to #pose if estop is off private: PostureEditor(const PostureEditor& ); //!< don't call @@ -50,10 +50,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.6 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.8 $ * $State: Exp $ - * $Date: 2004/12/02 18:48:56 $ + * $Date: 2005/08/07 04:11:03 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/ProfilerCheckControl.h ./Behaviors/Controls/ProfilerCheckControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/ProfilerCheckControl.h Thu Nov 11 15:34:59 2004 +++ ./Behaviors/Controls/ProfilerCheckControl.h Thu Nov 11 15:34:59 2004 @@ -24,7 +24,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.6 $ * $State: Exp $ * $Date: 2004/11/11 20:34:59 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/RebootControl.cc ./Behaviors/Controls/RebootControl.cc --- ../Tekkotsu_2.3/Behaviors/Controls/RebootControl.cc Thu Sep 25 11:26:11 2003 +++ ./Behaviors/Controls/RebootControl.cc Wed Feb 2 13:20:27 2005 @@ -1,9 +1,13 @@ #include "RebootControl.h" -#include +#ifdef PLATFORM_APERIOS +# include +#endif ControlBase * RebootControl::doSelect() { +#ifdef PLATFORM_APERIOS OBootCondition bc(obcbBOOT_TIMER, 0, obcbttRELATIVE); OPENR::Shutdown(bc); +#endif return NULL; } @@ -12,9 +16,9 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.3 $ - * $State: Rel $ - * $Date: 2003/09/25 15:26:11 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.4 $ + * $State: Exp $ + * $Date: 2005/02/02 18:20:27 $ */ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/RebootControl.h ./Behaviors/Controls/RebootControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/RebootControl.h Thu Sep 25 11:26:11 2003 +++ ./Behaviors/Controls/RebootControl.h Thu Sep 25 11:26:11 2003 @@ -23,7 +23,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.2 $ * $State: Rel $ * $Date: 2003/09/25 15:26:11 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/RunSequenceControl.h ./Behaviors/Controls/RunSequenceControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/RunSequenceControl.h Fri Jan 7 14:34:51 2005 +++ ./Behaviors/Controls/RunSequenceControl.h Mon Jun 6 19:05:51 2005 @@ -6,7 +6,7 @@ #include "Motion/MotionSequenceMC.h" #include "Motion/EmergencyStopMC.h" #include "Motion/LedMC.h" -#include "SoundPlay/SoundManager.h" +#include "Sound/SoundManager.h" #include "Motion/MMAccessor.h" #include "Shared/TimeET.h" #include "Shared/Config.h" @@ -28,7 +28,7 @@ public: //! Constructor, sets filter to *.mot RunSequenceControl(const std::string& n, MotionManager::MC_ID estop_id) - : FileBrowserControl(n,"Runs a motion sequence from a user-specified file",config->motion.root), + : FileBrowserControl(n,"Runs a motion sequence from a user-specified file",config->portPath(config->motion.root)), estopid(estop_id), ledid(MotionManager::invalid_MC_ID), waitingFile() { setFilter("*.mot"); @@ -84,10 +84,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.15 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.17 $ * $State: Exp $ - * $Date: 2005/01/07 19:34:51 $ + * $Date: 2005/06/06 23:05:51 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/SavePostureControl.h ./Behaviors/Controls/SavePostureControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/SavePostureControl.h Fri Jan 7 18:16:58 2005 +++ ./Behaviors/Controls/SavePostureControl.h Wed Jun 1 01:47:45 2005 @@ -9,9 +9,9 @@ class SavePostureControl : public StringInputControl { public: //! Constructor - SavePostureControl() : StringInputControl("Save Posture","Saves current posture to filename read from user","Please enter name for posture file (in /ms/data/motion)...") {} + SavePostureControl() : StringInputControl("Save Posture","Saves current posture to filename read from user","Please enter name for posture file (in data/motion)...") {} //! Constructor - 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)...") {} + SavePostureControl(const std::string& n) : StringInputControl(n,"Saves current posture to filename read from user","Please enter name for posture file (in data/motion)...") {} virtual ControlBase * takeInput(const std::string& msg) { if(msg.size()>0) { @@ -33,10 +33,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.11 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.12 $ * $State: Exp $ - * $Date: 2005/01/07 23:16:58 $ + * $Date: 2005/06/01 05:47:45 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/SaveWalkControl.h ./Behaviors/Controls/SaveWalkControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/SaveWalkControl.h Thu Dec 2 16:29:45 2004 +++ ./Behaviors/Controls/SaveWalkControl.h Wed Jun 1 01:47:45 2005 @@ -10,9 +10,9 @@ 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) {} + 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 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) {} + SaveWalkControl(const std::string& n, WalkMC * awalk) : StringInputControl(n,"Saves Walk parameters to filename read from user","Please enter name for posture file (in data/motion)..."), walk_id(MotionManager::invalid_MC_ID), thewalk(awalk) {} //! destructor virtual ~SaveWalkControl() {} @@ -49,9 +49,9 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.9 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.10 $ * $State: Exp $ - * $Date: 2004/12/02 21:29:45 $ + * $Date: 2005/06/01 05:47:45 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/SensorObserverControl.cc ./Behaviors/Controls/SensorObserverControl.cc --- ../Tekkotsu_2.3/Behaviors/Controls/SensorObserverControl.cc Tue Jan 11 18:49:04 2005 +++ ./Behaviors/Controls/SensorObserverControl.cc Wed Jun 1 01:47:45 2005 @@ -7,7 +7,7 @@ #include "Events/TextMsgEvent.h" #include "Events/VisionObjectEvent.h" #include "Shared/WorldState.h" -#include "SoundPlay/SoundManager.h" +#include "Sound/SoundManager.h" SensorObserverControl::SensorObserverControl() : ControlBase("Sensor Observer","Allows you to see/log the sensor data"), logfilePath(), logfile(), helpCtl(NULL), sensorCtl(NULL), buttonCtl(NULL), outputCtl(NULL), dutyCtl(NULL), consoleCtl(NULL), fileCtl(NULL), rtCtl(NULL), rtFreqCtl(NULL), numListeners(0) @@ -122,14 +122,14 @@ logfilePath=fileCtl->getLastInput(); logfile.clear(); if(logfilePath.size()!=0) { - sout->printf("Opening `/ms/%s'\n",logfilePath.c_str()); - logfile.open(("/ms/"+logfilePath).c_str()); + sout->printf("Opening `%s'\n",config->portPath(logfilePath).c_str()); + logfile.open(config->portPath(logfilePath).c_str()); if(!logfile.fail()) { std::string tmp=fileCtl->getName(); tmp[1]='X'; fileCtl->setName(tmp+": "+logfilePath); } else { - serr->printf("Opening `/ms/%s' failed\n",logfilePath.c_str()); + serr->printf("Opening `%s' failed\n",config->portPath(logfilePath).c_str()); } } } @@ -209,8 +209,8 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.4 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.5 $ * $State: Exp $ - * $Date: 2005/01/11 23:49:04 $ + * $Date: 2005/06/01 05:47:45 $ */ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/SensorObserverControl.h ./Behaviors/Controls/SensorObserverControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/SensorObserverControl.h Tue Jan 11 18:49:04 2005 +++ ./Behaviors/Controls/SensorObserverControl.h Sun Aug 7 00:11:03 2005 @@ -30,11 +30,11 @@ void updateRT(); //! The real time view for SensorObserverControl is split into a separate class for more straightfoward handling of refreshes - friend class RTViewControl : public ControlBase, public EventListener { + class RTViewControl : public ControlBase, public EventListener { public: - //constructor, pass pointer to SensorObserverControl which contains it + //!constructor, pass pointer to SensorObserverControl which contains it RTViewControl(SensorObserverControl* p) : ControlBase("Real-time View"), EventListener(), parent(p), period(500) {} - virtual void processEvent(const EventBase& /*event*/) { refresh(); } + virtual void processEvent(const EventBase& /*event*/) { refresh(); } //!< causes control to refresh whenever an event (i.e. timer) is received virtual void refresh(); virtual void pause(); virtual void deactivate(); @@ -46,6 +46,7 @@ RTViewControl(const RTViewControl& ); //!< don't call RTViewControl& operator=(const RTViewControl& ); //!< don't call }; + friend class RTViewControl; //!address of the logfile, if any (empty string is no logfile) std::string logfilePath; @@ -76,10 +77,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.3 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.5 $ * $State: Exp $ - * $Date: 2005/01/11 23:49:04 $ + * $Date: 2005/08/07 04:11:03 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/ShutdownControl.cc ./Behaviors/Controls/ShutdownControl.cc --- ../Tekkotsu_2.3/Behaviors/Controls/ShutdownControl.cc Thu Sep 25 11:26:11 2003 +++ ./Behaviors/Controls/ShutdownControl.cc Wed Feb 2 13:20:27 2005 @@ -1,9 +1,13 @@ #include "ShutdownControl.h" -#include +#ifdef PLATFORM_APERIOS +# include +#endif ControlBase * ShutdownControl::doSelect() { +#ifdef PLATFORM_APERIOS OBootCondition bc(0); OPENR::Shutdown(bc); +#endif return NULL; } @@ -12,9 +16,9 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.3 $ - * $State: Rel $ - * $Date: 2003/09/25 15:26:11 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.4 $ + * $State: Exp $ + * $Date: 2005/02/02 18:20:27 $ */ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/ShutdownControl.h ./Behaviors/Controls/ShutdownControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/ShutdownControl.h Thu Sep 25 11:26:11 2003 +++ ./Behaviors/Controls/ShutdownControl.h Thu Sep 25 11:26:11 2003 @@ -23,7 +23,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.3 $ * $State: Rel $ * $Date: 2003/09/25 15:26:11 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/SimulatorAdvanceFrameControl.h ./Behaviors/Controls/SimulatorAdvanceFrameControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/SimulatorAdvanceFrameControl.h Wed Dec 31 19:00:00 1969 +++ ./Behaviors/Controls/SimulatorAdvanceFrameControl.h Thu Jun 23 18:37:28 2005 @@ -0,0 +1,66 @@ +//-*-c++-*- +#ifndef INCLUDED_SimulatorAdvanceFrameControl_h +#define INCLUDED_SimulatorAdvanceFrameControl_h + +#include "Behaviors/Controls/NullControl.h" +#ifdef PLATFORM_APERIOS +# warning SimulatorAdvanceFrameControl is only useful when running in simulation! +#else +# include "local/sim/Main.h" +#endif + +//! Requests the next camera frame and sensor data, for use when running in simulation +/*! There are a number of options regarding control of input data and + * flow of time. This is only applicable when using a non-realtime + * source (such as loading logged data from disk) and the simulator's + * AdvanceOnAccess is 'false' (this is "advance on request" -- the + * same data may be accessed multiple times until you manually + * request the next frame) */ +class SimulatorAdvanceFrameControl : public NullControl { + +public: + //! default constructor + SimulatorAdvanceFrameControl() + : NullControl("SimulatorAdvanceFrameControl","Requests the next camera frame and sensor data, for use when running in simulation") + {} + //! constructor which allows a custom name + SimulatorAdvanceFrameControl(const std::string& n) + : NullControl(n,"Requests the next camera frame and sensor data, for use when running in simulation") + {} + + //can't do anything if we're running on aperios +#ifndef PLATFORM_APERIOS + + virtual ControlBase * activate(MotionManager::MC_ID disp_id, Socket * gui) { + Main::advanceVision(); + Main::advanceSensor(); + return NullControl::activate(disp_id,gui); + } + + virtual std::string getName() const { + if(Main::canManuallyAdvance()) + return NullControl::getName(); + return "[Auto-Advancing]"; + } + + virtual std::string getDescription() const { + if(Main::canManuallyAdvance()) + return NullControl::getDescription(); + return "Cannot manually advance when in realtime mode, or when AdvanceOnAccess is enabled"; + } + +#endif + +}; + +/*! @file + * @brief Defines SimulatorAdvanceFrameControl, which requests the next camera frame and sensor data, for use when running in simulation + * @author ejt (Creator) + * + * $Author: ejt $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.1 $ + * $State: Exp $ + * $Date: 2005/06/23 22:37:28 $ + */ +#endif diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/StringInputControl.cc ./Behaviors/Controls/StringInputControl.cc --- ../Tekkotsu_2.3/Behaviors/Controls/StringInputControl.cc Mon Jul 28 01:54:32 2003 +++ ./Behaviors/Controls/StringInputControl.cc Mon Jul 28 01:54:32 2003 @@ -42,7 +42,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.5 $ * $State: Rel $ * $Date: 2003/07/28 05:54:32 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/StringInputControl.h ./Behaviors/Controls/StringInputControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/StringInputControl.h Mon Mar 22 19:55:01 2004 +++ ./Behaviors/Controls/StringInputControl.h Mon Mar 22 19:55:01 2004 @@ -44,7 +44,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.5 $ * $State: Exp $ * $Date: 2004/03/23 00:55:01 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/ToggleControl.h ./Behaviors/Controls/ToggleControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/ToggleControl.h Mon Mar 22 19:55:01 2004 +++ ./Behaviors/Controls/ToggleControl.h Mon Mar 22 19:55:01 2004 @@ -141,7 +141,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.4 $ * $State: Exp $ * $Date: 2004/03/23 00:55:01 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/ValueEditControl.h ./Behaviors/Controls/ValueEditControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/ValueEditControl.h Wed Dec 15 23:50:48 2004 +++ ./Behaviors/Controls/ValueEditControl.h Sun Aug 7 00:11:03 2005 @@ -146,7 +146,7 @@ /*!@name Copies * accessors for the copies vector, so you can assign the same value to several places if you need to */ virtual std::vector& getCopies() { return copies; } //!< returns a reference to the vector #copies - virtual ValueEditControl& addCopy(T* t) { copies.push_back(t); return *this; } //!< #copies.push_back(t) + virtual ValueEditControl& addCopy(T* t) { copies.push_back(t); return *this; } //!< copies.push_back(t) //@} //! shows current value @@ -167,10 +167,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.14 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.15 $ * $State: Exp $ - * $Date: 2004/12/16 04:50:48 $ + * $Date: 2005/08/07 04:11:03 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/ValueSetControl.h ./Behaviors/Controls/ValueSetControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/ValueSetControl.h Sun Jan 18 05:16:56 2004 +++ ./Behaviors/Controls/ValueSetControl.h Sun Jan 18 05:16:56 2004 @@ -50,7 +50,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.3 $ * $State: Exp $ * $Date: 2004/01/18 10:16:56 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/WalkCalibration.cc ./Behaviors/Controls/WalkCalibration.cc --- ../Tekkotsu_2.3/Behaviors/Controls/WalkCalibration.cc Wed Nov 3 22:01:32 2004 +++ ./Behaviors/Controls/WalkCalibration.cc Wed Jun 1 01:47:45 2005 @@ -6,8 +6,11 @@ #include "Behaviors/Controller.h" #include "Shared/WorldState.h" #include "Shared/string_util.h" -#include "SoundPlay/SoundManager.h" +#include "Sound/SoundManager.h" #include +#include + +using namespace std; char * WalkCalibration::datanames[WalkCalibration::NUM_SRC] = { "fs","fr","sr","br","bs","rr" }; @@ -160,8 +163,8 @@ help->pushSlot(new NullControl("next reboot.")); - load=new FileInputControl("Load Data Set","Load data files - select any file from the set, all will be loaded","/ms"); - save=new StringInputControl("Save Data Set","Saves current data (/ms)","Enter the base name (up to 6 char)"); + load=new FileInputControl("Load Data Set","Load data files - select any file from the set, all will be loaded","/"); + save=new StringInputControl("Save Data Set","Saves current data","Enter the base name (up to 6 char)"); measure=new NullControl("Take Measurements","Begins the data gathering process"); measure->pushSlot(new NullControl()); clear=new NullControl("Clear Data","Clear the current data and start over"); @@ -384,7 +387,7 @@ } void WalkCalibration::saveData(const std::string& n, const std::vector& dat) { - std::string p=( n.substr(0,3)=="/ms/" ? n : "/ms/"+n ); + std::string p=config->portPath(n); sout->printf("Saving data to '%s'...\n",p.c_str()); std::ofstream out(p.c_str()); if(!out) { @@ -874,24 +877,6 @@ return; } - -void WalkCalibration::addSample(std::vector& dat, unsigned int row, float sol) { - float * d=new float[13]; - dat.push_back(d); - for(unsigned int i=0; i<12; i++) - d[i]=0; - - d[row*4+0]=old_x; - d[row*4+1]=old_y; - d[row*4+2]=old_a; - d[row*4+3]=1; - d[12]=sol/(stopTime-startTime); - - for(unsigned int i=0; i<13; i++) - cout << d[i] << ' '; - cout << endl; -} - void WalkCalibration::addSample(std::vector& dat, float x, float y, float a) { float * d=new float[6]; dat.push_back(d); @@ -913,9 +898,9 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.9 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.11 $ * $State: Exp $ - * $Date: 2004/11/04 03:01:32 $ + * $Date: 2005/06/01 05:47:45 $ */ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/WalkCalibration.h ./Behaviors/Controls/WalkCalibration.h --- ../Tekkotsu_2.3/Behaviors/Controls/WalkCalibration.h Thu Oct 7 15:07:04 2004 +++ ./Behaviors/Controls/WalkCalibration.h Wed Feb 2 13:47:23 2005 @@ -85,7 +85,6 @@ float arclen(float d, float a, float sign); //!< calculates arc distance corresponding to a displacement and angle, negated if necessary to match @a sign void addSample(); //!< adds data point corresponding to measurements stored in #firstIn and #secondIn - void addSample(std::vector& dat, unsigned int row, float sol); //!< adds data point to @a dat at row with solution (deprecated) void addSample(std::vector& dat, float x, float y, float a); //!< adds data point to @a dat for a given x,y,a (and #old_x, #old_y, #old_a) static void report(unsigned int row, float cmd, float actual); //!< reports data as they are being taken static void err(const std::string& str); //!< pops up an error message on the controller and also displays it on the console @@ -124,10 +123,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.6 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.7 $ * $State: Exp $ - * $Date: 2004/10/07 19:07:04 $ + * $Date: 2005/02/02 18:47:23 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/WaypointWalkControl.cc ./Behaviors/Controls/WaypointWalkControl.cc --- ../Tekkotsu_2.3/Behaviors/Controls/WaypointWalkControl.cc Thu Dec 2 16:29:45 2004 +++ ./Behaviors/Controls/WaypointWalkControl.cc Mon Jun 6 19:05:51 2005 @@ -8,7 +8,7 @@ #include "Motion/WaypointWalkMC.h" #include "Motion/WalkMC.h" #include "Motion/MMAccessor.h" -#include "SoundPlay/SoundManager.h" +#include "Sound/SoundManager.h" WaypointWalkControl::WaypointWalkControl() : ControlBase("WaypointWalkControl","Allows interactive control and execution of a set of waypoints"), @@ -21,7 +21,7 @@ pushSlot(addEgoWPCtl=new NullControl("Add Egocentric Waypoint","Appends a new egocentric waypoint (heading and location relative) at the end of the list")); pushSlot(addOffWPCtl=new NullControl("Add Offset Waypoint","Appends a new offset waypoint (location relative) at the end of the list")); pushSlot(addAbsWPCtl=new NullControl("Add Absolute Waypoint","Appends a new absolute waypoint at the end of the list")); - pushSlot(loadCtl=new FileInputControl("Load Waypoints","Reads a path from a file",config->motion.root)); + pushSlot(loadCtl=new FileInputControl("Load Waypoints","Reads a path from a file",config->portPath(config->motion.root))); loadCtl->setFilter("*.wyp"); pushSlot(saveCtl=new StringInputControl("Save Waypoints","Writes the current path to a file")); pushSlot(localizationCtl=new StringInputControl("Drift Error Correction","Enter 3 numbers 'x y a' reprenting current error")); @@ -247,9 +247,9 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.13 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.15 $ * $State: Exp $ - * $Date: 2004/12/02 21:29:45 $ + * $Date: 2005/06/06 23:05:51 $ */ diff -urdN ../Tekkotsu_2.3/Behaviors/Controls/WaypointWalkControl.h ./Behaviors/Controls/WaypointWalkControl.h --- ../Tekkotsu_2.3/Behaviors/Controls/WaypointWalkControl.h Tue Jul 27 10:33:28 2004 +++ ./Behaviors/Controls/WaypointWalkControl.h Sun Aug 7 00:11:03 2005 @@ -3,7 +3,7 @@ #define INCLUDED_WaypointWalkControl_h_ #include "ControlBase.h" -#include "Shared/SharedObject.h" +#include "IPC/SharedObject.h" class NullControl; class ToggleControl; @@ -16,13 +16,13 @@ //!constructor WaypointWalkControl(); - //! add #walk to ::motman + //! add #walk_id to ::motman virtual ControlBase * activate(MotionManager::MC_ID disp_id, Socket * gui); //!will be called after each waypoint is reached so we can update the menu virtual void refresh(); - //! remove the #walk from ::motman + //! remove the #walk_id from ::motman virtual void deactivate(); //!handles selection of menu items @@ -51,7 +51,7 @@ }; protected: - bool isRunning; //!< true if #walk is currently running + bool isRunning; //!< true if #walk_id is currently running NullControl * startstopCtl; //!< start and stop waypoint running ToggleControl * loopCtl; //!< repeat waypoints NullControl * addEgoWPCtl; //!< start and stop waypoint running @@ -75,10 +75,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.4 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.6 $ * $State: Exp $ - * $Date: 2004/07/27 14:33:28 $ + * $Date: 2005/08/07 04:11:03 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/ASCIIVisionBehavior.cc ./Behaviors/Demos/ASCIIVisionBehavior.cc --- ../Tekkotsu_2.3/Behaviors/Demos/ASCIIVisionBehavior.cc Tue Jan 4 14:51:41 2005 +++ ./Behaviors/Demos/ASCIIVisionBehavior.cc Wed Jun 1 01:47:45 2005 @@ -3,24 +3,22 @@ #include "Vision/RawCameraGenerator.h" #include "Wireless/Socket.h" -const char ASCIIVisionBehavior::charMap[ASCIIVisionBehavior::charMapSize] = { - ' ','.',',','\'','~','-','"','^',':',';','!','i','l','I','>','+','?',')', - '1',']','|','/','t','f','j','r','n','u','v','c','z','x','Y','U','J','C','L','Q', - '0','O','Z','X','m','w','q','p','d','b','k','h','a','o','*','#','M','W','&','8', - '%','B','$','@' -}; +const char ASCIIVisionBehavior::charMap[ASCIIVisionBehavior::charMapSize+1] = +" .,-+=ioxwfkHN8M#@"; void ASCIIVisionBehavior::processEvent(const EventBase& e) { const FilterBankEvent& fbkevt=dynamic_cast(e); - unsigned int layer = 1; + unsigned int layer = 2; char charimg[(fbkevt.getWidth(layer)+1)*fbkevt.getHeight(layer)+1]; char * curchar=charimg; unsigned char * image = fbkevt.getImage(layer, RawCameraGenerator::CHAN_Y); - for (unsigned int y = 0; y < fbkevt.getHeight(layer); y++) { + for (unsigned int y = 0; y < fbkevt.getHeight(layer); y+=2) { + //notice 'y+=2' above -- skip every other row, makes "image" look more square (letters are taller than wide) + //normally, if you want to process every pixel, use y++ instead ;) unsigned char * row = image + (y * fbkevt.getStride(layer)); for (unsigned int x = 0; x < fbkevt.getWidth(layer); x++) { unsigned char * pixel = row + (x * fbkevt.getIncrement(layer)); @@ -38,8 +36,8 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.3 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.4 $ * $State: Exp $ - * $Date: 2005/01/04 19:51:41 $ + * $Date: 2005/06/01 05:47:45 $ */ diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/ASCIIVisionBehavior.h ./Behaviors/Demos/ASCIIVisionBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/ASCIIVisionBehavior.h Tue Jan 4 14:51:41 2005 +++ ./Behaviors/Demos/ASCIIVisionBehavior.h Wed Jun 1 01:47:45 2005 @@ -15,8 +15,8 @@ //! constructor ASCIIVisionBehavior() : BehaviorBase("ASCIIVisionBehavior") {} - static const unsigned int charMapSize=62; //!< the number of available characters for levels of "gray" - static const char charMap[charMapSize]; //!< the included characters sorted in order of darkness - could be improved... (less is more sometimes) + static const unsigned int charMapSize=18; //!< the number of available characters for levels of "gray" + static const char charMap[charMapSize+1]; //!< the included characters sorted in order of darkness - could be improved... (less is more sometimes) virtual void DoStart() { BehaviorBase::DoStart(); // do this first @@ -42,10 +42,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.6 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.7 $ * $State: Exp $ - * $Date: 2005/01/04 19:51:41 $ + * $Date: 2005/06/01 05:47:45 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/AlanBehavior.h ./Behaviors/Demos/AlanBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/AlanBehavior.h Wed Nov 10 20:45:35 2004 +++ ./Behaviors/Demos/AlanBehavior.h Wed Jun 1 01:47:45 2005 @@ -5,7 +5,7 @@ #include "Behaviors/BehaviorBase.h" #include "Motion/MotionManager.h" #include "Motion/MMAccessor.h" -#include "Shared/SharedObject.h" +#include "IPC/SharedObject.h" #include "Shared/WorldState.h" #include "Events/EventRouter.h" #include "Motion/PostureMC.h" @@ -115,10 +115,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.12 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.13 $ * $State: Exp $ - * $Date: 2004/11/11 01:45:35 $ + * $Date: 2005/06/01 05:47:45 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/AutoGetupBehavior.h ./Behaviors/Demos/AutoGetupBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/AutoGetupBehavior.h Tue Dec 21 15:29:07 2004 +++ ./Behaviors/Demos/AutoGetupBehavior.h Wed Jun 1 01:47:45 2005 @@ -5,11 +5,11 @@ #include "Behaviors/BehaviorBase.h" #include "Shared/WorldState.h" #include "Events/EventRouter.h" -#include "Shared/SharedObject.h" +#include "IPC/SharedObject.h" #include "Motion/MotionManager.h" #include "Motion/MotionSequenceMC.h" #include "Shared/Config.h" -#include "SoundPlay/SoundManager.h" +#include "Sound/SoundManager.h" //! a little background behavior to keep the robot on its feet class AutoGetupBehavior : public BehaviorBase { @@ -74,10 +74,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.14 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.15 $ * $State: Exp $ - * $Date: 2004/12/21 20:29:07 $ + * $Date: 2005/06/01 05:47:45 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/BanditMachine.h ./Behaviors/Demos/BanditMachine.h --- ../Tekkotsu_2.3/Behaviors/Demos/BanditMachine.h Tue Dec 21 16:49:50 2004 +++ ./Behaviors/Demos/BanditMachine.h Wed Jun 1 01:47:45 2005 @@ -4,14 +4,14 @@ #include "Behaviors/StateNode.h" #include "Behaviors/Demos/StareAtBallBehavior.h" -#include "Shared/SharedObject.h" +#include "IPC/SharedObject.h" #include "Motion/PostureMC.h" #include "Motion/MotionSequenceMC.h" #include "Motion/LedMC.h" #include "Behaviors/Transitions/TimeOutTrans.h" #include "Behaviors/Transitions/SmoothCompareTrans.h" #include "Behaviors/Nodes/OutputNode.h" -#include "SoundPlay/SoundManager.h" +#include "Sound/SoundManager.h" #include "Shared/ProjectInterface.h" #include "Behaviors/Demos/karmedbandit.h" @@ -61,7 +61,7 @@ StateNode::DoStart(); stare->DoStart(); start->DoStart(); - SharedObject lie("/ms/data/motion/liedown.pos"); + SharedObject lie("liedown.pos"); lie->setOutputCmd(LFrLegOffset+RotatorOffset,.77); lie->setOutputCmd(RFrLegOffset+RotatorOffset,.73); lie->setOutputCmd(LFrLegOffset+KneeOffset,.6); @@ -214,10 +214,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.24 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.25 $ * $State: Exp $ - * $Date: 2004/12/21 21:49:50 $ + * $Date: 2005/06/01 05:47:45 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/BatteryMonitorBehavior.h ./Behaviors/Demos/BatteryMonitorBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/BatteryMonitorBehavior.h Wed Nov 10 20:45:35 2004 +++ ./Behaviors/Demos/BatteryMonitorBehavior.h Wed Jun 1 01:47:45 2005 @@ -6,7 +6,7 @@ #include "Shared/debuget.h" #include "Shared/WorldState.h" #include "Events/EventRouter.h" -#include "Shared/SharedObject.h" +#include "IPC/SharedObject.h" #include "Motion/MotionManager.h" #include "Motion/PostureMC.h" #include "Motion/LedMC.h" @@ -156,10 +156,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.20 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.21 $ * $State: Exp $ - * $Date: 2004/11/11 01:45:35 $ + * $Date: 2005/06/01 05:47:45 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/CVS/Entries ./Behaviors/Demos/CVS/Entries --- ../Tekkotsu_2.3/Behaviors/Demos/CVS/Entries Wed Dec 31 19:00:00 1969 +++ ./Behaviors/Demos/CVS/Entries Wed Aug 10 11:03:18 2005 @@ -0,0 +1,46 @@ +/ASCIIVisionBehavior.cc/1.4/Wed Jun 1 05:47:45 2005//Ttekkotsu-2_4 +/ASCIIVisionBehavior.h/1.7/Wed Jun 1 05:47:45 2005//Ttekkotsu-2_4 +/AlanBehavior.h/1.13/Wed Jun 1 05:47:45 2005//Ttekkotsu-2_4 +/AutoGetupBehavior.h/1.15/Wed Jun 1 05:47:45 2005//Ttekkotsu-2_4 +/BanditMachine.h/1.25/Wed Jun 1 05:47:45 2005//Ttekkotsu-2_4 +/BatteryMonitorBehavior.h/1.21/Wed Jun 1 05:47:45 2005//Ttekkotsu-2_4 +/CameraBehavior.cc/1.10/Fri Aug 5 21:55:43 2005//Ttekkotsu-2_4 +/CameraBehavior.h/1.8/Thu Nov 11 01:45:35 2004//Ttekkotsu-2_4 +/ChaseBallBehavior.cc/1.11/Sun Oct 17 01:16:10 2004//Ttekkotsu-2_4 +/ChaseBallBehavior.h/1.5/Thu Nov 11 01:45:35 2004//Ttekkotsu-2_4 +/CrashTestBehavior.h/1.3/Thu Nov 11 01:45:35 2004//Ttekkotsu-2_4 +/DrawSkeletonBehavior.h/1.3/Sun Aug 7 04:11:03 2005//Ttekkotsu-2_4 +/DrawVisObjBoundBehavior.h/1.4/Thu Aug 4 21:09:26 2005//Ttekkotsu-2_4 +/DriveMeBehavior.cc/1.11/Wed Jun 1 05:47:45 2005//Ttekkotsu-2_4 +/DriveMeBehavior.h/1.8/Wed Jun 1 05:47:45 2005//Ttekkotsu-2_4 +/ExploreMachine.cc/1.1/Sat Dec 4 00:10:38 2004//Ttekkotsu-2_4 +/ExploreMachine.h/1.23/Mon Jan 24 22:23:46 2005//Ttekkotsu-2_4 +/FlashIPAddrBehavior.cc/1.3/Wed Jun 1 05:47:45 2005//Ttekkotsu-2_4 +/FlashIPAddrBehavior.h/1.4/Sun Aug 7 04:11:03 2005//Ttekkotsu-2_4 +/FollowHeadBehavior.cc/1.9/Thu Nov 11 01:45:36 2004//Ttekkotsu-2_4 +/FollowHeadBehavior.h/1.5/Thu Nov 11 01:45:36 2004//Ttekkotsu-2_4 +/FreezeTestBehavior.h/1.2/Thu Nov 11 01:45:36 2004//Ttekkotsu-2_4 +/GroundPlaneBehavior.h/1.8/Thu Dec 23 01:47:06 2004//Ttekkotsu-2_4 +/HeadLevelBehavior.h/1.10/Thu Nov 11 01:45:36 2004//Ttekkotsu-2_4 +/HelloWorldBehavior.h/1.5/Thu Nov 11 01:45:36 2004//Ttekkotsu-2_4 +/KinematicSampleBehavior.h/1.10/Wed Jun 1 05:47:45 2005//Ttekkotsu-2_4 +/KinematicSampleBehavior2.h/1.13/Wed Jun 1 05:47:45 2005//Ttekkotsu-2_4 +/LookForSoundBehavior.h/1.8/Thu Dec 23 01:47:06 2004//Ttekkotsu-2_4 +/MCRepeater.h/1.6/Wed Jun 1 05:47:45 2005//Ttekkotsu-2_4 +/MotionStressTestBehavior.h/1.8/Sun Aug 7 04:11:03 2005//Ttekkotsu-2_4 +/PaceTargetsMachine.cc/1.18/Wed Aug 3 19:11:58 2005//Ttekkotsu-2_4 +/PaceTargetsMachine.h/1.9/Mon Jan 24 22:23:46 2005//Ttekkotsu-2_4 +/RelaxBehavior.h/1.7/Wed Jun 1 05:47:45 2005//Ttekkotsu-2_4 +/SimpleChaseBallBehavior.h/1.11/Tue May 3 16:30:29 2005//Ttekkotsu-2_4 +/SoundTestBehavior.h/1.12/Wed Jun 1 05:47:45 2005//Ttekkotsu-2_4 +/StareAtBallBehavior.cc/1.10/Wed Jun 1 05:47:45 2005//Ttekkotsu-2_4 +/StareAtBallBehavior.h/1.6/Fri Nov 12 00:05:03 2004//Ttekkotsu-2_4 +/StareAtPawBehavior2.cc/1.3/Thu Aug 4 21:09:26 2005//Ttekkotsu-2_4 +/StareAtPawBehavior2.h/1.21/Thu Jul 7 20:25:56 2005//Ttekkotsu-2_4 +/StepTest.h/1.3/Sun Aug 7 04:11:03 2005//Ttekkotsu-2_4 +/ToggleHeadLightBehavior.h/1.5/Wed Jun 1 05:47:45 2005//Ttekkotsu-2_4 +/WallTestBehavior.cc/1.12/Wed Jun 1 05:47:45 2005//Ttekkotsu-2_4 +/WallTestBehavior.h/1.4/Tue Nov 16 00:11:46 2004//Ttekkotsu-2_4 +/WorldStateVelDaemon.h/1.5/Wed Jun 29 22:00:03 2005//Ttekkotsu-2_4 +/karmedbandit.h/1.3/Thu Sep 18 22:40:27 2003//Ttekkotsu-2_4 +D diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/CVS/Repository ./Behaviors/Demos/CVS/Repository --- ../Tekkotsu_2.3/Behaviors/Demos/CVS/Repository Wed Dec 31 19:00:00 1969 +++ ./Behaviors/Demos/CVS/Repository Wed Aug 10 11:03:18 2005 @@ -0,0 +1 @@ +Tekkotsu/Behaviors/Demos diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/CVS/Root ./Behaviors/Demos/CVS/Root --- ../Tekkotsu_2.3/Behaviors/Demos/CVS/Root Wed Dec 31 19:00:00 1969 +++ ./Behaviors/Demos/CVS/Root Wed Aug 10 11:03:18 2005 @@ -0,0 +1 @@ +:pserver:anonymous@cvs.tekkotsu.org:/cvs diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/CVS/Tag ./Behaviors/Demos/CVS/Tag --- ../Tekkotsu_2.3/Behaviors/Demos/CVS/Tag Wed Dec 31 19:00:00 1969 +++ ./Behaviors/Demos/CVS/Tag Wed Aug 10 11:03:18 2005 @@ -0,0 +1 @@ +Ntekkotsu-2_4 diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/CameraBehavior.cc ./Behaviors/Demos/CameraBehavior.cc --- ../Tekkotsu_2.3/Behaviors/Demos/CameraBehavior.cc Tue Jan 25 18:50:55 2005 +++ ./Behaviors/Demos/CameraBehavior.cc Fri Aug 5 17:55:43 2005 @@ -1,11 +1,12 @@ #include "CameraBehavior.h" #include "Events/EventRouter.h" +#include "Events/TextMsgEvent.h" #include "Shared/ERS210Info.h" #include "Shared/ERS220Info.h" #include "Shared/ERS7Info.h" #include "Wireless/Socket.h" #include "Shared/WorldState.h" -#include "SoundPlay/SoundManager.h" +#include "Sound/SoundManager.h" #include "Shared/Config.h" #include "Shared/ProjectInterface.h" #include "Motion/LedMC.h" @@ -35,6 +36,7 @@ sndman->LoadFile("camera.wav"); ledID=motman->addPersistentMotion(SharedObject()); erouter->addListener(this,camera_click); + erouter->addListener(this,EventBase::textmsgEGID); } void CameraBehavior::DoStop() { @@ -51,7 +53,11 @@ */ void CameraBehavior::processEvent(const EventBase& e) { - if(e.shorterThan(camera_click)) + if(e.getGeneratorID()==EventBase::textmsgEGID) { + const TextMsgEvent * txt=dynamic_cast(&e); + if(txt==NULL || txt->getText()!="camera") + return; + } else if(e.shorterThan(camera_click)) return; { @@ -156,17 +162,18 @@ std::string CameraBehavior::getNextName(const std::string& ext) { char tmp[100]; - snprintf(tmp,100,"/ms/data/img%05d%s",index++,ext.c_str()); - sout->printf("Saving %s...",tmp); - return tmp; + snprintf(tmp,100,"data/img%05d%s",index++,ext.c_str()); + std::string ans=config->portPath(tmp); + sout->printf("Saving `%s'...",ans.c_str()); + return ans; } void CameraBehavior::initIndex() { - std::string path="/ms/data/"; + std::string path=config->portPath("data/"); DIR* dir=opendir(path.c_str()); if(dir==NULL) { - serr->printf("bad path: %s\n",path.c_str()); + serr->printf("bad path: `%s'\n",path.c_str()); return; } struct dirent * ent=readdir(dir); @@ -196,9 +203,9 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.8 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.10 $ * $State: Exp $ - * $Date: 2005/01/25 23:50:55 $ + * $Date: 2005/08/05 21:55:43 $ */ diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/CameraBehavior.h ./Behaviors/Demos/CameraBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/CameraBehavior.h Wed Nov 10 20:45:35 2004 +++ ./Behaviors/Demos/CameraBehavior.h Wed Nov 10 20:45:35 2004 @@ -61,7 +61,7 @@ * @author ejt (rewrite for new vision system) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.8 $ * $State: Exp $ * $Date: 2004/11/11 01:45:35 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/ChaseBallBehavior.cc ./Behaviors/Demos/ChaseBallBehavior.cc --- ../Tekkotsu_2.3/Behaviors/Demos/ChaseBallBehavior.cc Sat Oct 16 21:16:10 2004 +++ ./Behaviors/Demos/ChaseBallBehavior.cc Sat Oct 16 21:16:10 2004 @@ -64,7 +64,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.11 $ * $State: Exp $ * $Date: 2004/10/17 01:16:10 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/ChaseBallBehavior.h ./Behaviors/Demos/ChaseBallBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/ChaseBallBehavior.h Wed Nov 10 20:45:35 2004 +++ ./Behaviors/Demos/ChaseBallBehavior.h Wed Nov 10 20:45:35 2004 @@ -37,7 +37,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.5 $ * $State: Exp $ * $Date: 2004/11/11 01:45:35 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/CrashTestBehavior.h ./Behaviors/Demos/CrashTestBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/CrashTestBehavior.h Wed Nov 10 20:45:35 2004 +++ ./Behaviors/Demos/CrashTestBehavior.h Wed Nov 10 20:45:35 2004 @@ -37,7 +37,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.3 $ * $State: Exp $ * $Date: 2004/11/11 01:45:35 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/DrawSkeletonBehavior.h ./Behaviors/Demos/DrawSkeletonBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/DrawSkeletonBehavior.h Wed Dec 31 19:00:00 1969 +++ ./Behaviors/Demos/DrawSkeletonBehavior.h Sun Aug 7 00:11:03 2005 @@ -0,0 +1,123 @@ +//-*-c++-*- +#ifndef INCLUDED_DrawSkeletonBehavior_h_ +#define INCLUDED_DrawSkeletonBehavior_h_ + +#include "Behaviors/BehaviorBase.h" +#include "Events/EventRouter.h" + +#include "Shared/ProjectInterface.h" +#include "Events/VisionObjectEvent.h" +#include "Events/FilterBankEvent.h" +#include "Vision/Graphics.h" +#include "Shared/Config.h" +#include "Vision/RawCameraGenerator.h" +#include "Behaviors/Mon/RawCamBehavior.h" +#include "Motion/Kinematics.h" +#include "Shared/newmat/newmatio.h" + +//! Draws the kinematics "skeleton" on the camera frame +class DrawSkeletonBehavior : public BehaviorBase { +public: + //! constructor + DrawSkeletonBehavior() : BehaviorBase("DrawSkeletonBehavior") {} + + virtual void DoStart() { + BehaviorBase::DoStart(); // do this first (required) + erouter->addListener(this, EventBase::visRawCameraEGID,ProjectInterface::visRawCameraSID,EventBase::statusETID); + } + + virtual void DoStop() { + erouter->removeListener(this); //generally a good idea, unsubscribe all + BehaviorBase::DoStop(); // do this last (required) + } + + virtual void processEvent(const EventBase& e) { + //We're assuming e is a filter bank event and that its source is not null... + //You could add error checking code for that. + const FilterBankEvent& fbe=dynamic_cast(e); + + unsigned int chan=RawCameraGenerator::CHAN_U; + unsigned int layer=RawCamBehavior::getSourceLayer(chan,fbe.getNumLayers()); + unsigned char color=48; + float originBoxSize=.1; + + Graphics g(*fbe.getSource(),layer,chan); + g.setColor(color); + + NEWMAT::ColumnVector p=Kinematics::pack(0,0,0); + for(unsigned int leg=0; leglinkToJoint(jointOffset,CameraFrameOffset); + NEWMAT::ColumnVector o=T*p; //o is now the position of point p on the link, relative to the camera + bool front=o(3)>=0; + config->vision.computePixel(o(1),o(2),o(3),x,y); + //cout << jointOffset << ' ' << o.t() << " -> " << x << ' ' << y << endl; + return front; + } + + +private: + // Providing declarations for these functions will avoid a compiler warning if + // you have any class members which are pointers. However, as it is, an error + // will result if you inadvertantly cause a call to either (which is probably + // a good thing, unless you really intended to copy/assign a behavior, in + // which case simply provide implementations for the functions) + DrawSkeletonBehavior(const DrawSkeletonBehavior&); //!< don't call (copy constructor) + DrawSkeletonBehavior& operator=(const DrawSkeletonBehavior&); //!< don't call (assignment operator) +}; + +/*! @file + * @brief Defines DrawSkeletonBehavior, which draws the kinematics "skeleton" on the camera frame + * @author ejt (Creator) + * + * $Author: ejt $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.3 $ + * $State: Exp $ + * $Date: 2005/08/07 04:11:03 $ + */ + +#endif diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/DrawVisObjBoundBehavior.h ./Behaviors/Demos/DrawVisObjBoundBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/DrawVisObjBoundBehavior.h Wed Dec 31 19:00:00 1969 +++ ./Behaviors/Demos/DrawVisObjBoundBehavior.h Thu Aug 4 17:09:26 2005 @@ -0,0 +1,107 @@ +//-*-c++-*- +#ifndef INCLUDED_DrawVisObjBoundBehavior_h_ +#define INCLUDED_DrawVisObjBoundBehavior_h_ + +#include "Behaviors/BehaviorBase.h" +#include "Events/EventRouter.h" +#include "Shared/ProjectInterface.h" +#include "Events/VisionObjectEvent.h" +#include "Events/FilterBankEvent.h" +#include "Vision/Graphics.h" +#include "Shared/Config.h" +#include "Vision/RawCameraGenerator.h" + +//! Draws a boundary box in camera frame around all detected vision object events +class DrawVisObjBoundBehavior : public BehaviorBase { +public: + //! constructor + DrawVisObjBoundBehavior() : BehaviorBase("DrawVisObjBoundBehavior"), objs(), drawn(0) {} + + virtual void DoStart() { + BehaviorBase::DoStart(); // do this first (required) + erouter->addListener(this, EventBase::visObjEGID); + erouter->addListener(this, EventBase::visRawCameraEGID,ProjectInterface::visRawCameraSID,EventBase::statusETID); + erouter->addListener(this, EventBase::visSegmentEGID,ProjectInterface::visSegmentSID,EventBase::statusETID); + //This part isn't done -- we can't draw into RLE images until RLEGraphics is written + // erouter->addListener(this, EventBase::visRLEEGID,ProjectInterface::visRLESID,EventBase::statusETID); + } + + virtual void DoStop() { + erouter->removeListener(this); //generally a good idea, unsubscribe all + BehaviorBase::DoStop(); // do this last (required) + } + + virtual void processEvent(const EventBase& e) { + if(e.getGeneratorID()==EventBase::visObjEGID) { + if(drawn>=2) { + objs.clear(); + drawn=0; + } + if(e.getTypeID()!=EventBase::deactivateETID) { + const VisionObjectEvent& vis=dynamic_cast(e); + Rect r={vis.getLeft(),vis.getTop(),vis.getWidth(),vis.getHeight()}; + objs.push_back(r); + } + } else { + //cache current layer, channel, and pen color (depends on whether we're handling the seg cam or the raw cam + unsigned int layer, chan; + unsigned char color; + const FilterBankEvent& fbe=dynamic_cast(e); + if(e.getGeneratorID()==EventBase::visRawCameraEGID) { + layer=fbe.getNumLayers()-1-config->vision.rawcam_y_skip; + chan=RawCameraGenerator::CHAN_Y; + color=255; + } else if(e.getGeneratorID()==EventBase::visSegmentEGID) { + layer=fbe.getNumLayers()-1-config->vision.rlecam_skip; + chan=config->vision.rlecam_channel; + color=7; + } + + //do the drawing + Graphics g(*fbe.getSource(),layer,chan); + g.setColor(color); + for(std::vector::const_iterator it=objs.begin(); it!=objs.end(); ++it) + g.drawRect(it->x,it->y,it->w,it->h); + + //this is only needed until RLEGraphics is in place + // in the mean time, we trigger the RLE generator to recompress the modified seg cam image + if(config->vision.rlecam_compression==Config::vision_config::COMPRESS_RLE) + ProjectInterface::defRLEGenerator->invalidateCaches(); + + drawn++; + } + } + + static std::string getClassDescription() { return "Draws a boundary box in camera frame around all detected vision object events"; } + virtual std::string getDescription() const { return getClassDescription(); } + + +protected: + //! a simple structure for storing bounding box info for each detected object + struct Rect { + float x; //!< left edge, in resolution-independent coordinates + float y; //!< top edge, in resolution-independent coordinates + float w; //!< width, in resolution-independent coordinates + float h; //!< height, in resolution-independent coordinates + }; + + std::vector objs; //!< vector of boundary boxes from the current frame + unsigned int drawn; //!< a counter of the number of frames that have been updated, when this hits 2, the next vision object will clear the list + +private: + DrawVisObjBoundBehavior(const DrawVisObjBoundBehavior&); //!< don't call (copy constructor) + DrawVisObjBoundBehavior& operator=(const DrawVisObjBoundBehavior&); //!< don't call (assignment operator) +}; + +/*! @file + * @brief Defines DrawVisObjBoundBehavior, which draws a boundary box in camera frame around all detected vision object events + * @author ejt (Creator) + * + * $Author: ejt $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.4 $ + * $State: Exp $ + * $Date: 2005/08/04 21:09:26 $ + */ + +#endif diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/DriveMeBehavior.cc ./Behaviors/Demos/DriveMeBehavior.cc --- ../Tekkotsu_2.3/Behaviors/Demos/DriveMeBehavior.cc Tue Dec 21 16:49:50 2004 +++ ./Behaviors/Demos/DriveMeBehavior.cc Wed Jun 1 01:47:45 2005 @@ -2,7 +2,7 @@ #include "Motion/WalkMC.h" #include "Motion/MotionSequenceMC.h" #include "Motion/PostureEngine.h" -#include "Shared/SharedObject.h" +#include "IPC/SharedObject.h" #include "Events/EventRouter.h" #include "Events/EventBase.h" @@ -26,7 +26,7 @@ { // Construct the standing up motion that the aibo does after it's done moving stand->setTime(700); // 700 milliseconds to stand up - stand->setPose(PostureEngine("/ms/data/motion/stand.pos")); + stand->setPose(PostureEngine("stand.pos")); } void DriveMeBehavior::DoStart() @@ -109,9 +109,9 @@ * @author tss (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.10 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.11 $ * $State: Exp $ - * $Date: 2004/12/21 21:49:50 $ + * $Date: 2005/06/01 05:47:45 $ */ diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/DriveMeBehavior.h ./Behaviors/Demos/DriveMeBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/DriveMeBehavior.h Tue Dec 21 15:29:07 2004 +++ ./Behaviors/Demos/DriveMeBehavior.h Wed Jun 1 01:47:45 2005 @@ -5,7 +5,7 @@ #include "Behaviors/BehaviorBase.h" #include "Motion/MotionManager.h" #include "Motion/MotionSequenceMC.h" -#include "Shared/SharedObject.h" +#include "IPC/SharedObject.h" //! A very simple behavior that asks the user for WalkMC walking parameters and a walk duration. /*! The AIBO walks accordingly and then stands up, then asks again. And so on and so on.\n @@ -39,10 +39,10 @@ * @author tss (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.7 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.8 $ * $State: Exp $ - * $Date: 2004/12/21 20:29:07 $ + * $Date: 2005/06/01 05:47:45 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/ExploreMachine.cc ./Behaviors/Demos/ExploreMachine.cc --- ../Tekkotsu_2.3/Behaviors/Demos/ExploreMachine.cc Fri Dec 3 19:10:38 2004 +++ ./Behaviors/Demos/ExploreMachine.cc Fri Dec 3 19:10:38 2004 @@ -72,7 +72,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.1 $ * $State: Exp $ * $Date: 2004/12/04 00:10:38 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/ExploreMachine.h ./Behaviors/Demos/ExploreMachine.h --- ../Tekkotsu_2.3/Behaviors/Demos/ExploreMachine.h Mon Jan 24 17:23:46 2005 +++ ./Behaviors/Demos/ExploreMachine.h Mon Jan 24 17:23:46 2005 @@ -47,7 +47,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.23 $ * $State: Exp $ * $Date: 2005/01/24 22:23:46 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/FlashIPAddrBehavior.cc ./Behaviors/Demos/FlashIPAddrBehavior.cc --- ../Tekkotsu_2.3/Behaviors/Demos/FlashIPAddrBehavior.cc Fri Jan 28 19:56:58 2005 +++ ./Behaviors/Demos/FlashIPAddrBehavior.cc Wed Jun 1 01:47:45 2005 @@ -5,7 +5,7 @@ #include "Motion/LedEngine.h" #include "Shared/WorldState.h" #include "Shared/Config.h" -#include "SoundPlay/SoundManager.h" +#include "Sound/SoundManager.h" #include "Wireless/Wireless.h" void FlashIPAddrBehavior::DoStart() { @@ -180,8 +180,8 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.2 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.3 $ * $State: Exp $ - * $Date: 2005/01/29 00:56:58 $ + * $Date: 2005/06/01 05:47:45 $ */ diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/FlashIPAddrBehavior.h ./Behaviors/Demos/FlashIPAddrBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/FlashIPAddrBehavior.h Thu Jan 27 00:39:42 2005 +++ ./Behaviors/Demos/FlashIPAddrBehavior.h Sun Aug 7 00:11:03 2005 @@ -6,7 +6,7 @@ #include "Motion/MotionManager.h" #include "Motion/MotionSequenceMC.h" -//! Displays IP address by flashing a series of numbers on the LED face panel +//! Displays IP address by speaking the digits and flashing a series of numbers on the LED face panel /*! Will only run the display on DoStart() if the flash_on_start * config variable is set. Otherwise you will need to hold down the * buttons specified by #button1 and #button2 to trigger the display. @@ -36,7 +36,7 @@ virtual std::string getDescription() const { return getClassDescription(); } protected: - typedef XLargeMotionSequenceMC MSMC_t; + typedef XLargeMotionSequenceMC MSMC_t; //!< used to flash the LEDs to report the IP address void loadSounds(); //!< loads the numeric sounds into memory void releaseSounds(); //!< releases the numeric sounds @@ -58,10 +58,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.2 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.4 $ * $State: Exp $ - * $Date: 2005/01/27 05:39:42 $ + * $Date: 2005/08/07 04:11:03 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/FollowHeadBehavior.h ./Behaviors/Demos/FollowHeadBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/FollowHeadBehavior.h Wed Nov 10 20:45:36 2004 +++ ./Behaviors/Demos/FollowHeadBehavior.h Wed Nov 10 20:45:36 2004 @@ -54,7 +54,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.5 $ * $State: Exp $ * $Date: 2004/11/11 01:45:36 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/FreezeTestBehavior.h ./Behaviors/Demos/FreezeTestBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/FreezeTestBehavior.h Wed Nov 10 20:45:36 2004 +++ ./Behaviors/Demos/FreezeTestBehavior.h Wed Nov 10 20:45:36 2004 @@ -42,7 +42,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.2 $ * $State: Exp $ * $Date: 2004/11/11 01:45:36 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/GroundPlaneBehavior.h ./Behaviors/Demos/GroundPlaneBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/GroundPlaneBehavior.h Wed Dec 22 20:47:06 2004 +++ ./Behaviors/Demos/GroundPlaneBehavior.h Wed Dec 22 20:47:06 2004 @@ -85,7 +85,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.8 $ * $State: Exp $ * $Date: 2004/12/23 01:47:06 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/HeadLevelBehavior.h ./Behaviors/Demos/HeadLevelBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/HeadLevelBehavior.h Wed Nov 10 20:45:36 2004 +++ ./Behaviors/Demos/HeadLevelBehavior.h Wed Nov 10 20:45:36 2004 @@ -85,7 +85,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.10 $ * $State: Exp $ * $Date: 2004/11/11 01:45:36 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/HelloWorldBehavior.h ./Behaviors/Demos/HelloWorldBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/HelloWorldBehavior.h Wed Nov 10 20:45:36 2004 +++ ./Behaviors/Demos/HelloWorldBehavior.h Wed Nov 10 20:45:36 2004 @@ -50,7 +50,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.5 $ * $State: Exp $ * $Date: 2004/11/11 01:45:36 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/KinematicSampleBehavior.h ./Behaviors/Demos/KinematicSampleBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/KinematicSampleBehavior.h Wed Dec 22 20:47:06 2004 +++ ./Behaviors/Demos/KinematicSampleBehavior.h Wed Jun 1 01:47:45 2005 @@ -6,7 +6,7 @@ #include "Motion/PIDMC.h" #include "Motion/PostureMC.h" #include "Motion/MotionManager.h" -#include "Shared/SharedObject.h" +#include "IPC/SharedObject.h" #include "Motion/roboop/robot.h" #include "Shared/Config.h" #include "Motion/Kinematics.h" @@ -113,10 +113,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.9 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.10 $ * $State: Exp $ - * $Date: 2004/12/23 01:47:06 $ + * $Date: 2005/06/01 05:47:45 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/KinematicSampleBehavior2.h ./Behaviors/Demos/KinematicSampleBehavior2.h --- ../Tekkotsu_2.3/Behaviors/Demos/KinematicSampleBehavior2.h Wed Dec 22 20:47:06 2004 +++ ./Behaviors/Demos/KinematicSampleBehavior2.h Wed Jun 1 01:47:45 2005 @@ -6,7 +6,7 @@ #include "Motion/PIDMC.h" #include "Motion/PostureMC.h" #include "Motion/MotionManager.h" -#include "Shared/SharedObject.h" +#include "IPC/SharedObject.h" #include "Motion/roboop/robot.h" #include "Shared/Config.h" #include "Motion/Kinematics.h" @@ -163,10 +163,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.12 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.13 $ * $State: Exp $ - * $Date: 2004/12/23 01:47:06 $ + * $Date: 2005/06/01 05:47:45 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/LookForSoundBehavior.h ./Behaviors/Demos/LookForSoundBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/LookForSoundBehavior.h Wed Dec 22 20:47:06 2004 +++ ./Behaviors/Demos/LookForSoundBehavior.h Wed Dec 22 20:47:06 2004 @@ -74,7 +74,7 @@ * @author Paris Smaragdis (paris AT media mit edu) (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.8 $ * $State: Exp $ * $Date: 2004/12/23 01:47:06 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/MCRepeater.h ./Behaviors/Demos/MCRepeater.h --- ../Tekkotsu_2.3/Behaviors/Demos/MCRepeater.h Wed Nov 10 20:45:36 2004 +++ ./Behaviors/Demos/MCRepeater.h Wed Jun 1 01:47:45 2005 @@ -3,7 +3,7 @@ #define INCLUDED_MCRepeater_h_ #include "Behaviors/BehaviorBase.h" -#include "Shared/SharedObject.h" +#include "IPC/SharedObject.h" #include "Motion/MotionManager.h" #include "Events/EventRouter.h" @@ -46,10 +46,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.5 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.6 $ * $State: Exp $ - * $Date: 2004/11/11 01:45:36 $ + * $Date: 2005/06/01 05:47:45 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/MotionStressTestBehavior.h ./Behaviors/Demos/MotionStressTestBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/MotionStressTestBehavior.h Wed Dec 22 20:47:07 2004 +++ ./Behaviors/Demos/MotionStressTestBehavior.h Sun Aug 7 00:11:03 2005 @@ -60,6 +60,7 @@ } } + //! creates and adds a new MotionSequenceMC void addMS(LegOrder_t leg,unsigned int delay=0) { unsigned int index=leg*JointsPerLeg+RotatorOffset; SharedObject ms; @@ -87,10 +88,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.7 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.8 $ * $State: Exp $ - * $Date: 2004/12/23 01:47:07 $ + * $Date: 2005/08/07 04:11:03 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/PaceTargetsMachine.cc ./Behaviors/Demos/PaceTargetsMachine.cc --- ../Tekkotsu_2.3/Behaviors/Demos/PaceTargetsMachine.cc Fri Jan 21 17:50:33 2005 +++ ./Behaviors/Demos/PaceTargetsMachine.cc Wed Aug 3 15:11:58 2005 @@ -8,30 +8,38 @@ #include "Behaviors/Nodes/OutputNode.h" #include "Behaviors/Nodes/MotionSequenceNode.h" #include "Behaviors/Nodes/GroupNode.h" -#include "SoundPlay/SoundManager.h" +#include "Sound/SoundManager.h" void PaceTargetsMachine::setup() { StateNode::setup(); - WalkNode * turnAround = new WalkNode(0,0,1); + const float turnAroundSpeed=1; //1 rad/sec + //explore and chase have their own built-in speeds + + //***** NODE SETUP *****// + + //turns in place + WalkNode * turnAround = new WalkNode(0,0,turnAroundSpeed); turnAround->setName(getName()+"::TurnAround"); addNode(turnAround); + //two nodes running together -- explore will wander around, panhead will look around GroupNode * explGrp = new GroupNode(getName()+"::ExplGroup"); addNode(explGrp); { ExploreMachine * explore = new ExploreMachine(explGrp->getName()+"::Explore"); explGrp->addNode(explore); - SmallMotionSequenceNode * panhead = new SmallMotionSequenceNode(explGrp->getName()+"::PanHead","/ms/data/motion/pan_head.mot",true); + SmallMotionSequenceNode * panhead = new SmallMotionSequenceNode(explGrp->getName()+"::PanHead","pan_head.mot",true); explGrp->addNode(panhead); } + //follow the ball WalkToTargetNode * chase = new WalkToTargetNode(ProjectInterface::visPinkBallSID); chase->setName(getName()+"::Chase"); addNode(chase); - //starts out exploring - start=explGrp; + + //***** TRANSITION SETUP *****// Transition * tmptrans=NULL; @@ -48,7 +56,7 @@ tmptrans->setSound("fart.wav"); //once you've turned around, explore - turnAround->addTransition(tmptrans=new TimeOutTrans(explGrp,3500)); + turnAround->addTransition(tmptrans=new TimeOutTrans(explGrp,(unsigned int)(M_PI/turnAroundSpeed*1000))); //turn 180 degrees (aka PI radians) tmptrans->setSound("barkmed.wav"); //preload the sounds so we don't pause on tranisitions @@ -56,6 +64,9 @@ sndman->LoadFile("barkmed.wav"); sndman->LoadFile("whimper.wav"); sndman->LoadFile("fart.wav"); + + //starts out exploring + start=explGrp; } void PaceTargetsMachine::DoStart() { @@ -77,9 +88,9 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.16 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.18 $ * $State: Exp $ - * $Date: 2005/01/21 22:50:33 $ + * $Date: 2005/08/03 19:11:58 $ */ diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/PaceTargetsMachine.h ./Behaviors/Demos/PaceTargetsMachine.h --- ../Tekkotsu_2.3/Behaviors/Demos/PaceTargetsMachine.h Mon Jan 24 17:23:46 2005 +++ ./Behaviors/Demos/PaceTargetsMachine.h Mon Jan 24 17:23:46 2005 @@ -35,7 +35,7 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.9 $ * $State: Exp $ * $Date: 2005/01/24 22:23:46 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/RelaxBehavior.h ./Behaviors/Demos/RelaxBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/RelaxBehavior.h Wed Nov 10 20:45:36 2004 +++ ./Behaviors/Demos/RelaxBehavior.h Wed Jun 1 01:47:45 2005 @@ -5,7 +5,7 @@ #include #include "Behaviors/BehaviorBase.h" #include "Motion/PIDMC.h" -#include "Shared/SharedObject.h" +#include "IPC/SharedObject.h" #include "Motion/MotionManager.h" using namespace std; @@ -50,8 +50,8 @@ * @author ejt (Modifications) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.6 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.7 $ * $State: Exp $ - * $Date: 2004/11/11 01:45:36 $ + * $Date: 2005/06/01 05:47:45 $ */ diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/SimpleChaseBallBehavior.h ./Behaviors/Demos/SimpleChaseBallBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/SimpleChaseBallBehavior.h Wed Nov 10 20:45:36 2004 +++ ./Behaviors/Demos/SimpleChaseBallBehavior.h Tue May 3 12:30:29 2005 @@ -27,7 +27,7 @@ //! adds a headpointer and a walker, and a listens for vision events virtual void DoStart() { BehaviorBase::DoStart(); - walker_id = motman->addPersistentMotion(SharedObject()); //the 'false' prevents autopruning + walker_id = motman->addPersistentMotion(SharedObject()); erouter->addListener(this,EventBase::visObjEGID); } @@ -41,10 +41,17 @@ //! sets the head to point at the object and sets the body to move where the head points virtual void processEvent(const EventBase& event) { if(event.getGeneratorID()==EventBase::visObjEGID && event.getTypeID()==EventBase::statusETID) { - //in case the head isn't pointing straight forward, we'll straife + //x and y are the direction to walk; positive x is forward and positive y is left + //so these calculations walk the direction the head is pointing (at 120 mm/sec) float x=120.0f*cos(state->outputs[HeadOffset+PanOffset]); float y=120.0f*sin(state->outputs[HeadOffset+PanOffset]); + + //z is the amount to turn in radians; conveniently enough, we can use the + //x parameter from the vision event as the speed to turn -- you could + //scale this up or down to make it be more or less sensitive float z=-static_cast(&event)->getCenterX(); + + //now pass these values to the walk motion command: MMAccessor(walker_id)->setTargetVelocity(x,y,z); } } @@ -58,10 +65,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.10 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.11 $ * $State: Exp $ - * $Date: 2004/11/11 01:45:36 $ + * $Date: 2005/05/03 16:30:29 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/SoundTestBehavior.h ./Behaviors/Demos/SoundTestBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/SoundTestBehavior.h Wed Nov 10 20:45:36 2004 +++ ./Behaviors/Demos/SoundTestBehavior.h Wed Jun 1 01:47:45 2005 @@ -3,7 +3,7 @@ #define INCLUDED_SoundTestBehavior_h_ #include "Behaviors/BehaviorBase.h" -#include "SoundPlay/SoundManager.h" +#include "Sound/SoundManager.h" #include "Shared/ERS210Info.h" #include "Shared/ERS220Info.h" #include "Shared/ERS7Info.h" @@ -14,7 +14,7 @@ * up and then played successively once the chin button is released. * * Notice that this doesn't preload all needed sounds:\n - * - @c barkmed.wav is listed in /ms/config/tekkotsu.cfg as a preloaded system sound + * - @c barkmed.wav is listed in ms/config/tekkotsu.cfg as a preloaded system sound * - @c growl.wav will be loaded before being played automatically - notice the * hiccup this can cause. */ @@ -121,10 +121,10 @@ * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.11 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.12 $ * $State: Exp $ - * $Date: 2004/11/11 01:45:36 $ + * $Date: 2005/06/01 05:47:45 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/StareAtBallBehavior.cc ./Behaviors/Demos/StareAtBallBehavior.cc --- ../Tekkotsu_2.3/Behaviors/Demos/StareAtBallBehavior.cc Sat Oct 16 21:16:10 2004 +++ ./Behaviors/Demos/StareAtBallBehavior.cc Wed Jun 1 01:47:45 2005 @@ -37,18 +37,17 @@ //cout << horiz << ' ' << vert << endl; + // Very simple visual servoing control -- move the head in the direction of the target double tilt=state->outputs[HeadOffset+TiltOffset]-vert*M_PI/7; double pan=state->outputs[HeadOffset+PanOffset]-horiz*M_PI/6; - if(tiltDtoR(40)) - tilt=DtoR(40); - if(pan>DtoR(80)) - pan=DtoR(80); - if(pancheckoutMotion(headpointer_id); +#ifdef TGT_ERS7 + //on an ers-7, we want to set the nod joint to look up, since tilt can only look down + headpointer->setJoints(tilt,pan,outputRanges[HeadOffset+NodOffset][MaxRange]); +#else + //on other models (we'll just assume ers-2xx), center the roll joint headpointer->setJoints(tilt,pan,0); +#endif motman->checkinMotion(headpointer_id); } diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/StareAtBallBehavior.h ./Behaviors/Demos/StareAtBallBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/StareAtBallBehavior.h Thu Nov 11 19:05:03 2004 +++ ./Behaviors/Demos/StareAtBallBehavior.h Thu Nov 11 19:05:03 2004 @@ -36,7 +36,7 @@ * @author tss (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ + * $Name: tekkotsu-2_4 $ * $Revision: 1.6 $ * $State: Exp $ * $Date: 2004/11/12 00:05:03 $ diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/StareAtPawBehavior.h ./Behaviors/Demos/StareAtPawBehavior.h --- ../Tekkotsu_2.3/Behaviors/Demos/StareAtPawBehavior.h Wed Dec 22 20:47:07 2004 +++ ./Behaviors/Demos/StareAtPawBehavior.h Wed Dec 31 19:00:00 1969 @@ -1,102 +0,0 @@ -//-*-c++-*- -#ifndef INCLUDED_StareAtPawBehavior_h_ -#define INCLUDED_StareAtPawBehavior_h_ - -#include "Behaviors/BehaviorBase.h" -#include "Motion/OldKinematics.h" -#include "Motion/PIDMC.h" -#include "Motion/HeadPointerMC.h" -#include "Motion/MotionManager.h" -#include "Shared/SharedObject.h" - - -//! Uses CMPack kinematics to track the paw which last received a button press with the camera -/*! This is the "old" way of doing things, using CMPack kinematics... compare to StareAtPawBehavior2 for new-style kinematics */ -class StareAtPawBehavior : public BehaviorBase { -public: - //! constructor - StareAtPawBehavior() - : BehaviorBase("StareAtPawBehavior"), lastLeg(LFrLegOrder), pointID(MotionManager::invalid_MC_ID) - { } - - virtual void DoStart() { - BehaviorBase::DoStart(); // do this first - for(unsigned int i=0; ioutputs[HeadOffset+i]; - pointID=motman->addPersistentMotion(SharedObject()); - erouter->addListener(this,EventBase::sensorEGID); - erouter->addListener(this,EventBase::buttonEGID); - } - - virtual void DoStop() { - motman->removeMotion(pointID); - pointID=MotionManager::invalid_MC_ID; - erouter->removeListener(this); - BehaviorBase::DoStop(); // do this last - } - - virtual void processEvent(const EventBase& e) { - if(e.getGeneratorID()==EventBase::buttonEGID) { - - if(e.getSourceID()==LFrPawOffset) - lastLeg=LFrLegOrder; - else if(e.getSourceID()==RFrPawOffset) - lastLeg=RFrLegOrder; - else - return; - if(e.getTypeID()==EventBase::activateETID) { - unsigned int lastlegoff=LegOffset+lastLeg*JointsPerLeg; - SharedObject relaxLeg(lastlegoff,lastlegoff+JointsPerLeg,0); - motman->addPrunableMotion(relaxLeg); - } else if(e.getTypeID()==EventBase::deactivateETID) { - unsigned int lastlegoff=LegOffset+lastLeg*JointsPerLeg; - SharedObject tightLeg(lastlegoff,lastlegoff+JointsPerLeg,1); - motman->addPrunableMotion(tightLeg); - } - - } else if(e.getGeneratorID()==EventBase::sensorEGID) { - - double leg_angles[JointsPerLeg]; - for(unsigned int i=0; ioutputs[LegOffset+lastLeg*JointsPerLeg+i]; - vector3d paw; - GetLegPosition(paw,leg_angles,lastLeg); - paw-=body_to_neck; //target should be neck-relative - paw.z+=body_to_neck.z; // but body-height relative (#@%&$) - GetHeadAngles(head_angles,paw,0,0); - /*{ - double tmp[JointsPerLeg]; - GetLegAngles(tmp,paw,lastLeg); - sout->printf("Leg: (%g,%g,%g) (%g,%g,%g) (%g,%g,%g)\n",leg_angles[0],leg_angles[1],leg_angles[2],paw.x,paw.y,paw.z,tmp[0],tmp[1],tmp[2]); - vector3d tmp2; - tmp2=RunForwardModel(head_angles,0,0,vector3d(0,0,0)); - sout->printf("Head: (%g,%g,%g) (%g,%g,%g) (%g,%g,%g)\n",tmp2.x,tmp2.y,tmp2.z,head_angles[0],head_angles[1],head_angles[2],state->outputs[HeadOffset+0],state->outputs[HeadOffset+1],state->outputs[HeadOffset+2]); - }*/ - MMAccessor(pointID)->setJoints(head_angles[0],head_angles[1],head_angles[2]); - - } else { - serr->printf("StareAtPawBehavior: Unhandled event %s\n",e.getName().c_str()); - } - } - - static std::string getClassDescription() { return "Uses kinematics to track the paw which last received a button press with the camera"; } - virtual std::string getDescription() const { return getClassDescription(); } - -protected: - LegOrder_t lastLeg; //!< last leg to have it's button pressed, i.e. the one we are looking at - MotionManager::MC_ID pointID; //!< the HeadPointerMC we are using to do the looking - double head_angles[JointsPerLeg]; //!< temporary storage of the head angles we desire -}; - -/*! @file - * @brief Defines StareAtPawBehavior, which uses CMPack kinematics to track the paw which last received a button press with the camera - * @author ejt (Creator) - * - * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.7 $ - * $State: Exp $ - * $Date: 2004/12/23 01:47:07 $ - */ - -#endif diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/StareAtPawBehavior2.cc ./Behaviors/Demos/StareAtPawBehavior2.cc --- ../Tekkotsu_2.3/Behaviors/Demos/StareAtPawBehavior2.cc Wed Dec 31 19:00:00 1969 +++ ./Behaviors/Demos/StareAtPawBehavior2.cc Thu Aug 4 17:09:26 2005 @@ -0,0 +1,137 @@ +#include "StareAtPawBehavior2.h" + +#include "Events/EventRouter.h" +#include "Shared/WorldState.h" +#include "Motion/MMAccessor.h" +#include "Motion/PIDMC.h" +#include "Motion/HeadPointerMC.h" +#include "Motion/PostureMC.h" +#include "IPC/SharedObject.h" +#include "Motion/roboop/robot.h" +#include "Shared/Config.h" +#include "Motion/Kinematics.h" + +// these are for drawing into the camera frame +#include "Shared/ProjectInterface.h" +#include "Vision/Graphics.h" +#include "Events/FilterBankEvent.h" +#include "Vision/RawCameraGenerator.h" +#include "Behaviors/Mon/RawCamBehavior.h" + +//better to put this here instead of the header +using namespace std; + +void StareAtPawBehavior2::DoStart() { + BehaviorBase::DoStart(); // do this first + + pointID=motman->addPersistentMotion(SharedObject()); + + //sensorEGID to update head pointer whenever we get new info about joint positions + erouter->addListener(this,EventBase::sensorEGID); + //buttonEGID to switch the target when the LFr or RFr button is pressed (ignores the others) + erouter->addListener(this,EventBase::buttonEGID); + //visRawCameraEGID to draw a dot on the camera image where we think the toe is + erouter->addListener(this,EventBase::visRawCameraEGID,ProjectInterface::visRawCameraSID,EventBase::statusETID); + + if(state->robotDesign == WorldState::ERS7Mask) + sout->printf("NOTICE: The ERS-7 has a rather \"sticky\" nod joint\n" + "(the upper tilt joint). This can cause it to hesitate\n" + "or altogether fail to precisely center the target position\n" + "vertically in the center of the image...\n"); +} + +void StareAtPawBehavior2::DoStop() { + motman->removeMotion(pointID); + pointID=MotionManager::invalid_MC_ID; + erouter->removeListener(this); + BehaviorBase::DoStop(); // do this last +} + +void StareAtPawBehavior2::processEvent(const EventBase& e) { + if(e.getGeneratorID()==EventBase::buttonEGID) { + //*******************************// + //*** Switch the "active" toe ***// + //*******************************// + + if(e.getSourceID()==LFrPawOffset) { + lastLeg=LFrLegOrder; + } else if(e.getSourceID()==RFrPawOffset) { + lastLeg=RFrLegOrder; + } else + return; + if(e.getTypeID()==EventBase::activateETID) { + unsigned int lastlegoff=LegOffset+lastLeg*JointsPerLeg; + SharedObject relaxLeg(lastlegoff,lastlegoff+JointsPerLeg,0); + motman->addPrunableMotion(relaxLeg); + } else if(e.getTypeID()==EventBase::deactivateETID) { + unsigned int lastlegoff=LegOffset+lastLeg*JointsPerLeg; + SharedObject tightLeg(lastlegoff,lastlegoff+JointsPerLeg,1); + motman->addPrunableMotion(tightLeg); + } + + + } else if(e.getGeneratorID()==EventBase::sensorEGID) { + //***************************************************************************// + //*** Update the position of the head based on new information on the toe ***// + //***************************************************************************// + + //Which paw do we want? + const char * ipname= (lastLeg==LFrLegOrder) ? "ToeLFrPaw" : "ToeRFrPaw"; + + //Ask kinematics for current location of that paw (this is the "objective" aka target) + NEWMAT::ColumnVector Pobj=kine->getJointInterestPoint(BaseFrameOffset,ipname); + + //Now point the head there + MMAccessor(pointID)->lookAtPoint(Pobj(1),Pobj(2),Pobj(3)); //keep head as far away as possible + //Alternative method: + // MMAccessor(pointID)->lookAtPoint(Pobj(1),Pobj(2),Pobj(3),80); //keep head 80mm away + + + } else if(e.getGeneratorID()==EventBase::visRawCameraEGID) { + //**************************************************************// + //*** Draw into the camera frame to put a box around the toe ***// + //**************************************************************// + + //same as above, but get the toe position relative to the camera + const char * ipname= (lastLeg==LFrLegOrder) ? "ToeLFrPaw" : "ToeRFrPaw"; + NEWMAT::ColumnVector Pobj=kine->getJointInterestPoint(CameraFrameOffset,ipname); + float x,y; + config->vision.computePixel(Pobj(1),Pobj(2),Pobj(3),x,y); + y*=config->vision.aspectRatio; + float r=atan2(10.f,sqrt(Pobj.SumSquare()))/CameraHorizFOV/2; + + //draw into the layer which will be sent to the gui + //not doing any error checking on the type of the event or its source... cross your fingers ;) + const FilterBankEvent& fbe=dynamic_cast(e); + unsigned chan=RawCameraGenerator::CHAN_Y; + unsigned int layer=RawCamBehavior::getSourceLayer(chan,fbe.getNumLayers()); + Graphics g(*fbe.getSource(), layer, chan); + g.setColor(255); + g.drawRect(x-r,y-r,r*2,r*2); + + /* + //this method of drawing gets the pixel coordinates without applying + // camera calibration via config->vision.computePixel + g.setColor(192); + r=atan2(5.f,sqrt(Pobj.SumSquare()))/CameraHorizFOV/2; //draws a half-size rectangle + x=Pobj(1)/(Pobj(3)*tan(CameraHorizFOV/2)); + y=Pobj(2)/(Pobj(3)*tan(CameraVertFOV/2)); + y*=config->vision.aspectRatio; + g.drawRect(x-r,y-r,r*2,r*2); + */ + + } else { + serr->printf("StareAtPawBehavior2: Unhandled event %s\n",e.getName().c_str()); + } +} + +/*! @file + * @brief Implements StareAtPawBehavior2, which uses new-style ROBOOP kinematics to track the paw which last received a button press with the camera + * @author ejt (Creator) + * + * $Author: ejt $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.3 $ + * $State: Exp $ + * $Date: 2005/08/04 21:09:26 $ + */ diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/StareAtPawBehavior2.h ./Behaviors/Demos/StareAtPawBehavior2.h --- ../Tekkotsu_2.3/Behaviors/Demos/StareAtPawBehavior2.h Wed Dec 22 20:47:07 2004 +++ ./Behaviors/Demos/StareAtPawBehavior2.h Thu Jul 7 16:25:56 2005 @@ -3,15 +3,7 @@ #define INCLUDED_StareAtPawBehavior2_h_ #include "Behaviors/BehaviorBase.h" -#include "Motion/PIDMC.h" -#include "Motion/HeadPointerMC.h" -#include "Motion/PostureMC.h" #include "Motion/MotionManager.h" -#include "Shared/SharedObject.h" -#include "Motion/roboop/robot.h" -#include "Shared/Config.h" -#include "Motion/Kinematics.h" - //! Uses new-style ROBOOP kinematics to track the paw which last received a button press with the camera class StareAtPawBehavior2 : public BehaviorBase { @@ -21,61 +13,9 @@ : BehaviorBase("StareAtPawBehavior2"), lastLeg(LFrLegOrder), pointID(MotionManager::invalid_MC_ID) { } - virtual void DoStart() { - BehaviorBase::DoStart(); // do this first - pointID=motman->addPersistentMotion(SharedObject()); - erouter->addListener(this,EventBase::sensorEGID); - erouter->addListener(this,EventBase::buttonEGID); - if(state->robotDesign == WorldState::ERS7Mask) - sout->printf("NOTICE: The ERS-7 has a rather \"sticky\" nod joint\n" - "(the upper tilt joint). This can cause it to hesitate\n" - "or altogether fail to precisely center the target position\n" - "vertically in the center of the image...\n"); - } - - virtual void DoStop() { - motman->removeMotion(pointID); - pointID=MotionManager::invalid_MC_ID; - erouter->removeListener(this); - BehaviorBase::DoStop(); // do this last - } - - virtual void processEvent(const EventBase& e) { - if(e.getGeneratorID()==EventBase::buttonEGID) { - - if(e.getSourceID()==LFrPawOffset) { - lastLeg=LFrLegOrder; - } else if(e.getSourceID()==RFrPawOffset) { - lastLeg=RFrLegOrder; - } else - return; - if(e.getTypeID()==EventBase::activateETID) { - unsigned int lastlegoff=LegOffset+lastLeg*JointsPerLeg; - SharedObject relaxLeg(lastlegoff,lastlegoff+JointsPerLeg,0); - motman->addPrunableMotion(relaxLeg); - } else if(e.getTypeID()==EventBase::deactivateETID) { - unsigned int lastlegoff=LegOffset+lastLeg*JointsPerLeg; - SharedObject tightLeg(lastlegoff,lastlegoff+JointsPerLeg,1); - motman->addPrunableMotion(tightLeg); - } - - } else if(e.getGeneratorID()==EventBase::sensorEGID) { - - //Which paw do we want? - const char * ipname= (lastLeg==LFrLegOrder) ? "ToeLFrPaw" : "ToeRFrPaw"; - - //Ask kinematics for current location of that paw (this is the "objective" aka target) - NEWMAT::ColumnVector Pobj=kine->getJointInterestPoint(BaseFrameOffset,ipname); - - //Now point the head there - MMAccessor(pointID)->lookAtPoint(Pobj(1),Pobj(2),Pobj(3)); //keep head as far away as possible - //Alternative method: - // MMAccessor(pointID)->lookAtPoint(Pobj(1),Pobj(2),Pobj(3),80); //keep head 80mm away - - } else { - serr->printf("StareAtPawBehavior2: Unhandled event %s\n",e.getName().c_str()); - } - } + virtual void DoStart(); + virtual void DoStop(); + virtual void processEvent(const EventBase& e); static std::string getClassDescription() { return "Uses kinematics to track the paw which last received a button press with the camera"; } virtual std::string getDescription() const { return getClassDescription(); } @@ -86,14 +26,14 @@ }; /*! @file - * @brief Defines StareAtPawBehavior2, which uses new-style ROBOOP kinematics to track the paw which last received a button press with the camera + * @brief Describes StareAtPawBehavior2, which uses new-style ROBOOP kinematics to track the paw which last received a button press with the camera * @author ejt (Creator) * * $Author: ejt $ - * $Name: tekkotsu-2_3 $ - * $Revision: 1.18 $ + * $Name: tekkotsu-2_4 $ + * $Revision: 1.21 $ * $State: Exp $ - * $Date: 2004/12/23 01:47:07 $ + * $Date: 2005/07/07 20:25:56 $ */ #endif diff -urdN ../Tekkotsu_2.3/Behaviors/Demos/StepTest.h ./Behaviors/Demos/StepTest.h --- ../Tekkotsu_2.3/Behaviors/Demos/StepTest.h Wed Dec 31 19:00:00