Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

GrasperNode.cc

Go to the documentation of this file.
00001 #include "Shared/RobotInfo.h"
00002 #if (defined(TGT_HAS_ARMS) || !defined(STRICT_TGT_MODEL)) && !defined(TGT_IS_AIBO)
00003 
00004 #include "GrasperNode.h"
00005 #include "Crew/Grasper.h"
00006 #include "Events/GrasperEvent.h"
00007 #include "Shared/MarkScope.h"
00008 
00009 void GrasperNode::preStart() {
00010   StateNode::preStart();
00011   cancelFlag = false;
00012 }
00013 
00014 void GrasperNode::postStart() {
00015   StateNode::postStart();
00016 #ifdef TGT_HAS_ARMS
00017   if ( !cancelFlag ) {
00018     VRmixin::grasper->executeRequest(graspreq,this);
00019     erouter->addListener(this,EventBase::grasperEGID,(size_t)this);
00020   }
00021 #endif
00022 }
00023 
00024 void GrasperNode::doEvent() {
00025   // Normally a =GRASP=> event will trigger on any Grasper event, but
00026   // if the user is testing for explicit error codes using =GRASP(t)=> and
00027   // none of the tests succeeds, we want to provide for a default case by
00028   // posting a failure event that can be picked up by an =F=> transition.
00029   switch ( event->getGeneratorID() ) {
00030   case EventBase::grasperEGID: {
00031     const GrasperEvent *graspEvent = dynamic_cast<const GrasperEvent*>(event);
00032     if ( graspEvent && graspEvent->getErrorType() != GrasperRequest::noError )
00033       erouter->addTimer(this,1,1,false);   // delay so any =GRASP(t)=> transitions can fire first
00034     else
00035       postStateCompletion();
00036     break;
00037   }
00038   case EventBase::timerEGID:  // delay has expired and nothing else fired; post failure
00039     postStateFailure();
00040     break;
00041   default:
00042     break;
00043   }
00044 }
00045 
00046 void GrasperNode::cancelThisRequest() {
00047   cancelFlag = true;
00048   postStateFailure();
00049 }
00050 
00051 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:41 2016 by Doxygen 1.6.3