An application object that ties together various I/O and other modules and runs the main thread. More...
#include <Robots/LoBot/LoApp.H>
Classes | |
struct | signal_pred |
Helper classes for above condition variable. | |
struct | wait_pred |
Public Types | |
typedef Compositor< PixelType > | ImageCompositor |
typedef std::vector < VideoStream * > | VideoStreams |
typedef std::vector < VideoRecorder * > | VideoRecorders |
typedef std::vector < LocustModel * > | LocustModels |
typedef std::vector< Behavior * > | Behaviours |
Public Member Functions | |
void | parse_command_line () |
Parse the command line arguments. | |
void | run () |
~App () | |
Clean-up. | |
Static Public Member Functions | |
static App & | create (int argc, const char *argv[]) |
static void | wait_for_init () |
static int | argc () |
static const char ** | argv () |
static LaserRangeFinder * | lrf () |
static Robot * | robot () |
static Map * | map () |
static const LocustModels & | locusts () |
static const Behaviours & | behaviours () |
static LaserViz * | laser_viz () |
static LaserVizFlat * | laser_viz_flat () |
Friends | |
class | singleton< App > |
struct | signal_pred |
struct | wait_pred |
An application object that ties together various I/O and other modules and runs the main thread.
This class is responsible for instantiating the various objects used to interface with the robot's sensors, motors, etc. It also creates the different behaviours that make up Robolocust's behaviour-based controller and runs the main thread's update loop that takes care of continously retrieving the latest sensor measurements, performing the necessary low-level state computations, etc.
The application object is implemented as a singleton. This allows other modules/behaviours to easily retrieve references to I/O and other objects. Thus, the application object serves as a central repository that holds together the various low-level shared objects required by the different behaviours.
Definition at line 104 of file LoApp.H.
One of the main responsibilities of the application object is to hold a bunch of low-level things together in one place so that they may be accessed by other modules and threads as required. To ease the interface between these low-level objects and high-level behaviours that need them, we use these typedefs.
lobot::App::~App | ( | ) |
Clean-up.
Definition at line 506 of file LoApp.C.
References ModelComponent::started(), and ModelComponent::stop().
static int lobot::App::argc | ( | ) | [inline, static] |
App & lobot::App::create | ( | int | argc, | |
const char * | argv[] | |||
) | [static] |
void lobot::App::parse_command_line | ( | ) |
Parse the command line arguments.
Definition at line 366 of file LoApp.C.
References ModelManager::parseCommandLine(), and ModelManager::setOptionValString().
void lobot::App::run | ( | ) |
The application object has two main responsibilities. First, it must instantiate all the different I/O modules, create the different behaviours, etc. Second, it must run the Robolocust application's main loop. This method implements the afore-mentioned loop.
The main loop runs the update cycle, which takes care of retrieving the latest measurements from the sensors, computing any low-level state based on these measurements, etc. The loop exits when the lobot::Shutdown object is signaled. Before exiting, the main thread waits for all the other threads to wind-up.
Definition at line 381 of file LoApp.C.
References lobot::Pause::clear(), lobot::Pause::is_clear(), lobot::Configuration::load(), lobot::Robot::off(), lobot::MainWindow::push_back(), lobot::Pause::set(), lobot::Configuration::set_internal(), lobot::Shutdown::signaled(), ModelComponent::start(), lobot::Robot::update(), lobot::DangerZone::update(), lobot::LocustModel::update(), lobot::Compositor< pixel_type >::update(), lobot::VideoStream::update(), lobot::LaserRangeFinder::update(), and lobot::VideoRecorder::update().
static void lobot::App::wait_for_init | ( | ) | [inline, static] |
External API for other threads to wait until the application object is fully initialized.
Definition at line 228 of file LoApp.H.
Referenced by lobot::Arbiter::run(), and lobot::Behavior::run().