WaypointWalkNode.h
Go to the documentation of this file.00001
00002 #ifndef INCLUDED_WaypointWalkNode_h_
00003 #define INCLUDED_WaypointWalkNode_h_
00004
00005 #include "MCNode.h"
00006 #include "Motion/MotionManager.h"
00007 #define WALKMC_NO_WARN_NOOP
00008 #include "Motion/WaypointWalkMC.h"
00009 #undef WALKMC_NO_WARN_NOOP
00010 #include "Events/EventRouter.h"
00011 #include "Events/LocomotionEvent.h"
00012
00013
00014
00015 extern const char defWaypointWalkNodeName[];
00016
00017
00018 extern const char defWaypointWalkNodeDesc[];
00019
00020
00021 template<typename W, const char* mcName=defWaypointWalkNodeName, const char* mcDesc=defWaypointWalkNodeDesc>
00022 class WaypointEngineNode : public MCNode<W,mcName,mcDesc> {
00023 public:
00024
00025
00026 WaypointEngineNode() : MCNode<W,mcName,mcDesc>() {}
00027
00028
00029 WaypointEngineNode(const std::string& name) : MCNode<W,mcName,mcDesc>(name) {}
00030
00031
00032 ~WaypointEngineNode() {}
00033
00034 virtual void postStart() {
00035
00036
00037 MCNode<W,mcName,mcDesc>::postStart();
00038 if ( MCNode<W,mcName,mcDesc>::isActive() ) {
00039 erouter->addListener(this, EventBase::locomotionEGID, MCNode<W,mcName,mcDesc>::getMC_ID(), EventBase::statusETID);
00040 MCNode<W,mcName,mcDesc>::getMC()->go();
00041 }
00042 }
00043
00044 virtual void stop() {
00045 { MMAccessor<W> wp_walker = MCNode<W,mcName,mcDesc>::getMC();
00046 wp_walker->pause();
00047 wp_walker->zeroVelocities();
00048 }
00049
00050
00051 MCNode<W,mcName,mcDesc>::stop();
00052 }
00053
00054 protected:
00055
00056 WaypointEngineNode(const std::string& className, const std::string& instanceName) :
00057 MCNode<W,mcName,mcDesc>(className,instanceName) {}
00058
00059 void doEvent() {
00060 if ( static_cast<const LocomotionEvent&>(*this->event).isStop() )
00061 MCNode<W,mcName,mcDesc>::postStateCompletion();
00062 }
00063
00064 };
00065
00066
00067 typedef WaypointEngineNode<WaypointWalkMC> WaypointWalkNode;
00068
00069
00070
00071
00072
00073
00074 #endif