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 
12 using namespace argos;
13 
25 int 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 }
argos::CARGoSCommandLineArgParser::ACTION_SHOW_HELP
@ ACTION_SHOW_HELP
Definition: argos_command_line_arg_parser.h:34
argos::CSimulator::GetInstance
static CSimulator & GetInstance()
Returns the instance to the CSimulator class.
Definition: simulator.cpp:87
argos::CARGoSCommandLineArgParser::Parse
virtual void Parse(SInt32 n_argc, char **ppch_argv)
Parses the command line.
Definition: argos_command_line_arg_parser.cpp:80
argos::LOG
CARGoSLog LOG(std::cout, SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_GREEN))
Definition: argos_log.h:179
argos
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
argos::CARGoSCommandLineArgParser::ACTION_QUERY
@ ACTION_QUERY
Definition: argos_command_line_arg_parser.h:37
argos::CARGoSCommandLineArgParser::GetExperimentConfigFile
const std::string & GetExperimentConfigFile()
Returns the experiment configuration file as parsed by Parse().
Definition: argos_command_line_arg_parser.h:97
argos::CSimulator::SetExperimentFileName
void SetExperimentFileName(const std::string &str_file_name)
Sets the name of the XML configuration file parsed by Load().
Definition: simulator.h:228
argos::CSimulator
The core class of ARGOS.
Definition: simulator.h:62
argos::LOGERR
CARGoSLog LOGERR(std::cerr, SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_RED))
Definition: argos_log.h:180
argos::CSimulator::LoadExperiment
void LoadExperiment()
Loads the XML configuration file.
Definition: simulator.cpp:115
argos::CARGoSCommandLineArgParser::GetQuery
const std::string & GetQuery()
Returns the query on the plugins as parsed by Parse().
Definition: argos_command_line_arg_parser.h:107
argos::CDynamicLoading::LoadAllLibraries
static void LoadAllLibraries()
Loads all the dynamic libraries in the current ARGOS_PLUGIN_PATH.
Definition: dynamic_loading.cpp:183
argos::CARGoSLog::Flush
void Flush()
Definition: argos_log.h:147
argos::CARGoSCommandLineArgParser::PrintUsage
virtual void PrintUsage(CARGoSLog &c_log)
Prints usage information to the wanted log.
Definition: argos_command_line_arg_parser.cpp:143
argos::QueryPlugins
void QueryPlugins(const std::string &str_query)
Definition: query_plugins.cpp:52
argos::CARGoSCommandLineArgParser::ACTION_RUN_EXPERIMENT
@ ACTION_RUN_EXPERIMENT
Definition: argos_command_line_arg_parser.h:36
main
int main(int n_argc, char **ppch_argv)
The standard main() function to run the ARGoS simulator.
Definition: main.cpp:25
argos::CARGoSCommandLineArgParser
The command line argument parser used by the main ARGoS executable.
Definition: argos_command_line_arg_parser.h:25
argos::CSimulator::Execute
void Execute()
Executes the simulation loop.
Definition: simulator.cpp:269
argos::CARGoSCommandLineArgParser::GetAction
EAction GetAction()
Returns the action parsed by Parse().
Definition: argos_command_line_arg_parser.h:87
argos::CSimulator::Destroy
void Destroy()
Undoes whatever was done by Init().
Definition: simulator.cpp:213
argos::CARGoSCommandLineArgParser::ACTION_SHOW_VERSION
@ ACTION_SHOW_VERSION
Definition: argos_command_line_arg_parser.h:35
argos::CARGoSCommandLineArgParser::ACTION_UNKNOWN
@ ACTION_UNKNOWN
Definition: argos_command_line_arg_parser.h:33
argos::CARGoSCommandLineArgParser::PrintVersion
virtual void PrintVersion()
Prints the current ARGoS version and release.
Definition: argos_command_line_arg_parser.cpp:180