PilotDemo class

From Tekkotsu Wiki

Jump to: navigation, search

The PilotDemo class is both a demo in its own right and a framework for building your own navigation demos. PilotDemo implements a simple command listener so that you can issue requests to the Pilot by sending text messages from the Tekkotsu console.

You can run PilotDemo directly by going to Root Control > Framework Demos > Navigation Demos > PilotDemo.

PilotDemo Commands

f / bforward/backward 100 mm
F / Bforward/backward 500 mm
fwd distforward dist mm (use negative numbers to go backwards)
l / rturn left/right by 10 degrees
L / Rturn left/right by 90 degrees
turn deg turn left by deg degrees (negative numbers turn right)
loclocalize using landmarks and the world map
clearclear the world map
buildfind landmarks (AprilTags) in current view and add to world map
disp ndisplay best n particles in the world map
randrandomize the particles
setx valset agent's x coordinate
sety valset agent's y coordinate
setq valset agent's theta coordinate
sethomeset agent's x,y,theta to 0 (make current position be home)
rundemo    start the user's state machine

Making Your Own Demo

You can make your own demo by creating a state machine whose parent node inherits from PilotDemo. This is useful if you want to create your own world map and navigation application; you can use PilotDemo to provide a convenient command interface.

To build your own world map, override the buildMap() method.

PilotDemo takes over the state machine's startnode, so in order for your own code to run, your initial node should be called startdemo or rundemo. If it's called startdemo then it will be started automatically when the demo runs. If it's called rundemo then a rumdemo command will be included in the PilotDemo menu, and you can start the behavior manually by typing msg rundemo.

#include "Behaviors/Demos/Navigation/PilotDemo.h"

$nodeclass MyDemo : PilotDemo {

  virtual void buildMap() {
    // code to create the landmarks and (optional) worldBounds polygon for your world map
    // ...

    startdemo: SpeechNode($,"This is my demo") =C=> ...


Adding Your Own Commands

PilotDemo provides an addCommand() method that allows you to add your own commands to the menu. Each command must be implemented as a node in your state machine. See the source code in PilotDemo.h.fsm for examples.