Homepage Demos Overview Downloads Tutorials Reference
Credits

PaceTargetsMachine.cc

Go to the documentation of this file.
00001 #include "PaceTargetsMachine.h"
00002 #include "Behaviors/Transition.h"
00003 #include "WalkToTargetMachine.h"
00004 #include "Behaviors/Nodes/WalkNode.h"
00005 #include "ExploreMachine.h"
00006 #include "Behaviors/Transitions/TimeOutTrans.h"
00007 #include "Behaviors/Transitions/VisualTargetTrans.h"
00008 #include "Behaviors/Nodes/OutputNode.h"
00009 #include "Behaviors/Nodes/PlayMotionSequenceNode.h"
00010 #include "Behaviors/Nodes/GroupNode.h"
00011 #include "SoundPlay/SoundManager.h"
00012 
00013 void PaceTargetsMachine::setup() {
00014   StateNode::setup();
00015 
00016   WalkNode * turnAround = new WalkNode(0,0,1,this);
00017   turnAround->setName(getName()+"::TurnAround");
00018   addNode(turnAround);
00019 
00020   GroupNode * explGrp = new GroupNode(getName()+"::ExplGroup",this);
00021   addNode(explGrp);
00022   {
00023     ExploreMachine * explore = new ExploreMachine(explGrp->getName()+"::Explore",explGrp);
00024     explGrp->addNode(explore);
00025     PlayMotionSequenceNode<MotionSequence::SizeSmall> * panhead = new PlayMotionSequenceNode<MotionSequence::SizeSmall>(explGrp->getName()+"::PanHead",explGrp,"/ms/data/motion/pan_head.mot",true);
00026     explGrp->addNode(panhead);
00027   }
00028 
00029   WalkToTargetMachine * chase = new WalkToTargetMachine(ProjectInterface::visPinkBallSID,turnAround,explGrp,this);
00030   chase->setName(getName()+"::Chase");
00031   addNode(chase);
00032 
00033   //starts out exploring
00034   start=explGrp;
00035 
00036   Transition * tmptrans=NULL;
00037 
00038   //if it sees pink, chase it
00039   explGrp->addTransition(tmptrans=new VisualTargetTrans(chase,ProjectInterface::visPinkBallSID));
00040   tmptrans->setSound("cutey.wav");
00041 
00042   //once you've turned around, explore
00043   turnAround->addTransition(tmptrans=new TimeOutTrans(explGrp,3500));
00044   tmptrans->setSound("barkmed.wav");
00045 
00046   //add some more sounds
00047   //!@todo extract these transitions from within chase - i don't like this way of doing things anymore...
00048   chase->setup();
00049   chase->getLostTrans()->setSound("whimper.wav");
00050   chase->getCloseTrans()->setSound("fart.wav");
00051 
00052   //preload the sounds so we don't pause on tranisitions
00053   sndman->LoadFile("cutey.wav");
00054   sndman->LoadFile("barkmed.wav");
00055   sndman->LoadFile("whimper.wav");
00056   sndman->LoadFile("fart.wav");
00057 }
00058 
00059 void PaceTargetsMachine::DoStart() {
00060   StateNode::DoStart();
00061   start->DoStart();
00062 }
00063 
00064 void PaceTargetsMachine::teardown() {
00065   //preload the sounds
00066   sndman->ReleaseFile("cutey.wav");
00067   sndman->ReleaseFile("barkmed.wav");
00068   sndman->ReleaseFile("whimper.wav");
00069   sndman->ReleaseFile("fart.wav");
00070 }
00071 
00072 /*! @file
00073  * @brief Implements PaceTargetsMachine, a StateMachine for walking back and forth between two visual targets
00074  * @author ejt (Creator)
00075  *
00076  * $Author: ejt $
00077  * $Name: tekkotsu-2_0 $
00078  * $Revision: 1.11 $
00079  * $State: Exp $
00080  * $Date: 2003/12/08 00:20:57 $
00081  */
00082 

Tekkotsu v2.0
Generated Wed Jan 21 03:20:29 2004 by Doxygen 1.3.4