#ifndef INCLUDED_DstBehavior_h_
#define INCLUDED_DstBehavior_h_
#include "Behaviors/StateNode.h"
#include "Behaviors/Nodes/SoundNode.h"
#include "Behaviors/Nodes/LedNode.h"
#include "Behaviors/Transitions/CompletionTrans.h"
#include "Behaviors/Transitions/EventTrans.h"
#include "Behaviors/Transitions/NullTrans.h"
#include "Behaviors/Transitions/TimeOutTrans.h"
#include "Events/EventRouter.h"
class DstBehavior : public StateNode {
public:
DstBehavior() : StateNode("DstBehavior") {}
virtual void setup() {
StateNode::setup();
std::cout << getName() << " is setting up the state machine." << std::endl;
StateNode *launcher = new StateNode("launcher");
LedNode *noblink = new LedNode("noblink");
SoundNode *bark_node = new SoundNode("bark","barkmed.wav");
SoundNode *howl_node = new SoundNode("howl","howl.wav");
LedNode *blink_node = new LedNode("blink");
StateNode *wait_node = new StateNode("wait");
addNode(launcher); addNode(noblink);
addNode(bark_node); addNode(howl_node); addNode(blink_node); addNode(wait_node);
NullTrans *ntrans = new NullTrans(bark_node);
ntrans->addDestination(noblink);
launcher->addTransition(ntrans);
noblink->getMC()->set(RobotInfo::FaceLEDMask,0.0);
noblink->setPriority(MotionManager::kBackgroundPriority);
EventTrans *btrans = new EventTrans(wait_node,
EventBase::buttonEGID,
RobotInfo::HeadFrButOffset,
EventBase::activateETID);
btrans->setSound("ping.wav");
bark_node->addTransition(btrans);
blink_node->getMC()->cycle(RobotInfo::FaceLEDMask,1500,1.0);
TimeOutTrans *htrans = new TimeOutTrans(howl_node,5000);
htrans->addDestination(blink_node);
bark_node->addTransition(htrans);
CompletionTrans *ctrans = new CompletionTrans(wait_node,1);
howl_node->addTransition(ctrans);
blink_node->addTransition(ctrans);
wait_node->addTransition(new TimeOutTrans(bark_node,15000));
startnode = launcher;
}
virtual void DoStart() {
std::cout << getName() << " is starting up." << std::endl;
StateNode::DoStart();
}
virtual void DoStop() {
std::cout << getName() << " is shutting down." << std::endl;
StateNode::DoStop();
}
protected: // Dummy functions to satisfy the compiler
DstBehavior(const DstBehavior&);
DstBehavior& operator=(const DstBehavior&);
};
#endif
|