|
|
|
#nodeclass MyUselessClass : StateNode #endnodeclass |
#shortnodeclass MyUselessClass : StateNode // (the blank line above terminated the shortnodeclass definition) |
class MyUselessClass : public StateNode {
public:
MyUselessClass(const std::string &nodename = "MyUselessClass") : StateNode(nodename) {}
};
|
#shortnodeclass SayHello : SpeechNode($,"Hello") |
#shortnodeclass WriteNodeName : StateNode : DoStart cout << "This is node " << getName() << endl; |
#shortnodeclass GreenLEDOn : LEDNode : constructor getMC()->set(RobotInfo::GreenLEDMask, 1.0); |
const EventBase &event
argument to those methods that accept one, or a null argument to those
that don't.
#shortnodeclass WaitForPress : StateNode : DoStart
erouter->addListener(this, EventBase::buttonEGID, RobotInfo::GreenButOffset, EventBase::activateETID);
#shortnodemethod processEvent
cout << "Green button pressed: " << event.getDescription() << endl;
postStateCompletion();
|
#nodeclass WaitFor3Presses : StateNode : count()
int count;
#shortnodemethod DoStart
count = 0;
erouter->addListener(this, EventBase::buttonEGID,
RobotInfo::GreenButOffset, EventBase::activateETID);
#shortnodemethod processEvent
if ( ++count == 3 )
postStateCompletion();
#endnodeclass
|
#shortnodeclass GoForward(float distance) : WalkNode($,_distance,0,0,1) : DoStart
cout << "Going forward by " << distance << " mm." << endl;
|
class GoForward : public WalkNode {
public:
float distance; // cache the constructor's parameter
GoForward(const std::string &nodename, float _distance) : WalkNode(nodename,_distance,0,0,1), distance(_distance) {}
virtual void DoStart() {
cout << "Going forward by " << distance << " mm." << endl;
}
};
|
Instead we must write something like:fwd: GoForward =C=> SayHello
We could, if we wish, specify a default value for the distance in the usual way:fwd: GoForward($,100) =C=> SayHello
#shortnodeclass GoForward(float distance=100) : WalkNode($,_distance,0,0,1) : DoStart
cout << "Going forward by " << distance << " mm." << endl;
|
#ifndef _MySampleBehavior_h_ #define _MySampleBehavior_h_ #include "Behaviors/StateMachine.h"
|
Tekkotsu/tools/stataparser mycode.h.fsm -The dash as second argument indicates that the output should be written to the console instead of to a file. If you omit the second argument, the output will be written to the file mycode.h.
|
|
|