From our partners in robotics we often hear that TiViPE is easy to use, but for starters the first steps appear to be the biggest hurdle. Here is a step by step approach how to use TiViPE as an end-user programming environment without any textual programming.
Figure 1: Flow chart of toy scenario.
A toy robot scenario
- From the start we will wait until the user presses the ‘y’ button. As soon as this button is pressed 2 scenarios will start in parallel (items 2 and 3)
- The first scenario “Say: It is a nice day”. Within TiViPE this means that a string is constructed with the following text: “say (It_is_a_nice_day)”, but of course any textual command can be constructed to provide full control over the robot. Since this state activates itself, the command is repeated over and over again. Hence, this scenario might be used as some monitoring scenario that becomes active as soon as the robot needs to stopped to protect users or to protect the robot from being damaged.
- The second scenario running in parallel to the first scenario is an interactive scenario that starts with “Hello”.
- As soon as Hello has been performed “Bye” is activated.
- Next the user can select what action needs to be taken. This state is called “KeySelection” like the first one, but here 2 different keys perform different actions.
- “Yes” is activated when the ‘y’ button is pressed or
- “No” is activated when the ‘n’ button is pressed.
- Both “Yes” and “No” when completed activate another user selection mechanism called “KeySelectionOrTimeOut” this state behaves the same as a “KeySelection” state, but unlike the latter it can also time out. When no appropriate key is pressed, it automatically activates “Hello” after 10 seconds.
- In case ‘y’ was pressed “Positive” is activated and this state in turn activates “Hello”.
- In case ‘n’ was pressed “Negative” is activated, also this state activates “Hello” after it has been completed.
It is clear that the program sketched above is not a meaningful robotics example, but is aimed to make the user familiar with a sequence of robot actions that can be influenced by the user, and this makes a robot partly autonomous, and partly remote controlled.
The detailed textual description is as follows:
======================================================================= Author Tino Lourens Date 17 Oct 2012 Update 24 Mar 2017 Example how to use key interrupts ======================================================================= xx UpdateStatesNscis (first in the row) This module is used for state chart control. It starts and updates modules. Start 1 1 CommandStateSelectByKey Activate [][y][2&10] (when y is pressed activate both 2 and 10; otherwise activate 1) Info * Press 'y' to indicate that you are ready. 2 CommandState2 Command say (It_is_a_nice_day) Activate 2 10 CommandState2 Command say (Hello) Activate 20 20 CommandState2 Command say (Bye) Activate 30 30 CommandStateSelectByKey Activate [][y,n][40,50] (when y is pressed activate 40; when n is pressed activate 50; otherwise activate 30) Info * Press 'y' to say yes; activate state 40.<br> * Press 'n' to say no; activate state 50. (Note that <br> is used for a new line in the showInfo module) 40 CommandState2 Command say (Yes) Activate 60 50 CommandState2 Command say (No) Activate 60 60 CommandStateSelectByKeyOrTimeOut Activate [][y,n][70,80] (when y is pressed activate 70; when n is pressed activate 80; otherwise activate 60) TimeOut 10,000 (10 seconds) TimeOutActivate 10 Info * Press 'y' to say positive; activate state 70.<br> * Press 'n' to say negative; activate state 80. (Note that <br> is used for a new line in the showInfo module) 70 CommandState2 Command say (Positive) Activate 10 80 CommandState2 Command say (Negative) Activate 10 xx CommandStateInterrupActiveStatesSCIS (last in the row) This module is used for state chart control. It sends commands to the robot It might interrupt all commands to the robot. =======================================================================
Toy robot implementation in TiViPE
In the example given above the robot commands are kept short and simple, and thus every robot action state can be implemented by “CommandState2” or “CommandStateTextFile”, latter uses a file where one or more textual commands are given. The 3 keyboard selection mechanisms require the “CommandStateSelectByKey” or “CommandStateSelectByKeyOrTimeOut”. All these blocks are found in the TiViPE environment in Module->TVP->Robotics->SCIS->States, as illustrated in Figure 2.
Figure 2: Getting modules in TiViPE.
Module->TVP->Shared memory,
Module->TVP->Robotics->Generic,
Module->TVP->Robotics->NAO->Actuation.
Figure 3: Nine different modules are selected.
Figure 4: Duplicating modules.
Figure 5: Duplicated modules.
Figure 6: Toy example constructed.
Figure 7: Saving a network.
Figure 8: Editing the parameters of getKeysAndButtons.
Figure 9: Editing the parameters of UpdateStatesNscis.
Figure 10: Editing the parameters of CommandStateInterruptActiveStateSCIS, writeBooleanTime, NaoRobotN, and readBooleanTime.
Figure 11: Editing the parameters of CommandStateSelectByKey (2x) and CommandStateSelectByKeyTimeOut (1x). The Information used is given in the extended text description.
Figure 12: Editing the parameters of CommandState2 (7 modules).
Figure 13: Selecting modules.
Figure 14: Merging a module. Here the position where to place the module (TVP->Test->CommandStateSelectByKeyExample2) is an arbitrary choice.
Figure 15: Compilation of a module.
Figure 16: Unorganized parameters. The result a huge pile of parameters after compounding 13 modules.
The post on merging modules will explain in detail how the module can be optimized.