Robobot new behaviour plan: Difference between revisions

From Rsewiki
(Created page with "Back to Robobot Back to Robobot software description == Create a new behaviour plan == The easy way is to copy an existing plan, e.g.: $ cd ~/svn/robo...")
 
Line 4: Line 4:


== Create a new behaviour plan ==
== Create a new behaviour plan ==
==== Copy from existing plan ====


The easy way is to copy an existing plan, e.g.:
The easy way is to copy an existing plan, e.g.:
Line 12: Line 14:
   
   
Then add the new plan to the repository (if a repository is used)
Then add the new plan to the repository (if a repository is used)
==== Rename class name ====
A number of variables and types need to be renamed.
===== Header file =====
* Search and replace 'BPlan20' to 'BPlan100'  (three places)
* rename 'plan20' (last line) to 'plan100'
The bplan100.h should be changes to look like:
class BPlan100
{
public:
    ~BPlan100();
  void setup();
  void run();
  ...
};
extern BPlan100 plan100;
===== Cpp file =====
* Change the includefile "bplan20.h" to "bplan100.h"
* Rename 'BPlan20' to 'BPlan100'
* Change all "plan20" to "plan100" to make a new section in the configuration file.
* Change all "plan20" to "plan100" - used in logfile name and other places
* Change all "Plan20" to "Plan100" - used in comments and debug print.
Parts of the old file looks like:
#include "bplan20.h"
BPlan20 plan20;
void BPlan20::setup()
{ // ensure there is default values in ini-file
  if (not ini["plan20"].has("log"))
  { // no data yet, so generate some default values
    ini["plan20"]["log"] = "true";
    ini["plan20"]["run"] = "false";
==== Add to CMakeLists.txt ====


(hertil)
(hertil)

Revision as of 11:52, 1 January 2024

Back to Robobot

Back to Robobot software description

Create a new behaviour plan

Copy from existing plan

The easy way is to copy an existing plan, e.g.:

$ cd ~/svn/robobot/raubase/src
$ cp bplan20.cpp bplan100.cpp
$ cp bplan20.h bplan100.h

Then add the new plan to the repository (if a repository is used)

Rename class name

A number of variables and types need to be renamed.

Header file
  • Search and replace 'BPlan20' to 'BPlan100' (three places)
  • rename 'plan20' (last line) to 'plan100'

The bplan100.h should be changes to look like:

class BPlan100
{
public:
    ~BPlan100();
  void setup();
  void run();
  ...
};
extern BPlan100 plan100;
Cpp file
  • Change the includefile "bplan20.h" to "bplan100.h"
  • Rename 'BPlan20' to 'BPlan100'
  • Change all "plan20" to "plan100" to make a new section in the configuration file.
  • Change all "plan20" to "plan100" - used in logfile name and other places
  • Change all "Plan20" to "Plan100" - used in comments and debug print.

Parts of the old file looks like:

#include "bplan20.h"
BPlan20 plan20;

void BPlan20::setup()
{ // ensure there is default values in ini-file
  if (not ini["plan20"].has("log"))
  { // no data yet, so generate some default values
    ini["plan20"]["log"] = "true";
    ini["plan20"]["run"] = "false";

Add to CMakeLists.txt

(hertil)