ARGoS 3
A parallel, multi-engine simulator for swarm robotics
main.cpp
Go to the documentation of this file.
1
7#include <argos3/core/simulator/simulator.h>
8#include <argos3/core/utility/plugins/dynamic_loading.h>
9#include <argos3/core/simulator/query_plugins.h>
10#include <argos3/core/simulator/argos_command_line_arg_parser.h>
11
12using namespace argos;
13
25int main(int n_argc, char** ppch_argv) {
26 try {
27 /* Create a new instance of the simulator */
28 CSimulator& cSimulator = CSimulator::GetInstance();
29 /* Configure the command line options */
31 /* Parse command line */
32 cACLAP.Parse(n_argc, ppch_argv);
33 switch(cACLAP.GetAction()) {
37 cSimulator.LoadExperiment();
38 cSimulator.Execute();
39 break;
42 QueryPlugins(cACLAP.GetQuery());
43 break;
45 cACLAP.PrintUsage(LOG);
46 break;
48 cACLAP.PrintVersion();
49 break;
51 /* Should never get here */
52 break;
53 }
54 /* Done, destroy stuff */
55 cSimulator.Destroy();
56 }
57 catch(std::exception& ex) {
58 /* A fatal error occurred: dispose of data, print error and exit */
59 LOGERR << ex.what() << std::endl;
60#ifdef ARGOS_THREADSAFE_LOG
61 LOG.Flush();
62 LOGERR.Flush();
63#endif
64 return 1;
65 }
66 /* Everything's ok, exit */
67 return 0;
68}
int main(int n_argc, char **ppch_argv)
The standard main() function to run the ARGoS simulator.
Definition main.cpp:25
The namespace containing all the ARGoS related code.
Definition ci_actuator.h:12
CARGoSLog LOGERR(std::cerr, SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_RED))
Definition argos_log.h:180
void QueryPlugins(const std::string &str_query)
CARGoSLog LOG(std::cout, SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_GREEN))
Definition argos_log.h:179
The command line argument parser used by the main ARGoS executable.
virtual void Parse(SInt32 n_argc, char **ppch_argv)
Parses the command line.
EAction GetAction()
Returns the action parsed by Parse().
virtual void PrintVersion()
Prints the current ARGoS version and release.
const std::string & GetExperimentConfigFile()
Returns the experiment configuration file as parsed by Parse().
virtual void PrintUsage(CARGoSLog &c_log)
Prints usage information to the wanted log.
const std::string & GetQuery()
Returns the query on the plugins as parsed by Parse().
The core class of ARGOS.
Definition simulator.h:62
void Destroy()
Undoes whatever was done by Init().
void SetExperimentFileName(const std::string &str_file_name)
Sets the name of the XML configuration file parsed by Load().
Definition simulator.h:228
static CSimulator & GetInstance()
Returns the instance to the CSimulator class.
Definition simulator.cpp:78
void Execute()
Executes the simulation loop.
void LoadExperiment()
Loads the XML configuration file.
static void LoadAllLibraries()
Loads all the dynamic libraries in the current ARGOS_PLUGIN_PATH.