Robobot level 3 details
From Rsewiki
(Difference between revisions)
(Created page with "Back to Robobot_B Back to Robobot architecture == Mission control == The example mission is intended to illustrate how mission (elements) could be programmed. === ...") |
Revision as of 15:28, 17 November 2023
Back to Robobot_B
Back to Robobot architecture
Contents |
Mission control
The example mission is intended to illustrate how mission (elements) could be programmed.
Divide and conqer
Do not make the whole DTU Robocup track in one function; divide the task into smaller parts to make it easy to test, modify, reorder and skip.
Simple plan
An example mission is available in the file bplan1.h and bplan1.cpp
The header file bplan1.h is:
#pragma once using namespace std; class BPlan1 { public: ~BPlan1(); void setup(); void run(); void terminate(); private: void toLog(const char * message); int logCnt = 0; bool toConsole = true; FILE * logfile = nullptr; bool setupDone = false; }; extern BPlan1 plan1;
Explained line by line
Pragma and namespace
#pragma once using namespace std;
The first line ensures that the file is used once only. Other files may include other header files that in turn also includes this file, the #pragma once ensures the definitions are used once only.
The namespace is used to avoid writing 'std::' for all standard functions, e.g. the type 'std::string' can be specified as just 'string'.
Class
class BPlan1 { public: ... private: ... }; extern BPlan1 plan1;