|
|
|
$nodeclass MyUselessClass : StateNode {
} |
class MyUselessClass : public StateNode {
public:
MyUselessClass(const std::string &nodename = "MyUselessClass") : StateNode(nodename) {}
}; |
$nodeclass SayHello : SpeechNode($,"Hello there!") {
} |
$shortnodeclass WriteNodeName : StateNode {
virtual void doStart() {
cout << "This is node " << getName() << endl;
}
} |
$nodeclass GreenLEDOn : LEDNode : constructor {
getMC()->set(RobotInfo::GreenLEDMask, 1.0);
}
|
$nodeclass WaitForPress : StateNode {
virtual void doStart() {
erouter->addListener(this, EventBase::buttonEGID, RobotInfo::GreenButOffset, EventBase::activateETID);
}
virtual void doEvent() {
cout << "Green button pressed: " << event->getDescription() << endl;
postStateCompletion();
}
} |
$nodeclass WaitFor3Presses : StateNode : count() {
int count;
virtual void doStart() {
count = 0;
erouter->addListener(this, EventBase::buttonEGID,
RobotInfo::GreenButOffset, EventBase::activateETID);
}
virtual void doEvent() {
if ( ++count == 3 )
postStateCompletion();
}
} |
$nodeclass GoForward(float distance) : WalkNode($, distance, 0, 0, 1) {
virtual void 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
But we could, if we wish, specify a default value for the distance in the usual way:fwd: GoForward($,100) =C=> SayHello
$nodeclass GoForward(float distance=100) : WalkNode($,_distance,0,0,1) {
virtual void doStart() {
cout << "Going forward by " << distance << " mm." << endl;
}
} |
#include "Behaviors/StateMachine.h"
|
Tekkotsu/tools/sbin/stateparser MyCode.cc.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-fsm.cc.
|
|
|