class EventLoop

Overview

Manages simulation loop. Runs physics and brain interface, and synchronizes them via Transfer Functions. More…

#include <event_loop.h>

class EventLoop {
public:
    // construction

    EventLoop();

    EventLoop(
        const nlohmann::json& graph_config,
        std::chrono::milliseconds timestep,
        std::chrono::milliseconds timestepThres,
        ComputationalGraph::ExecMode execMode = ComputationalGraph::ExecMode::ALL_NODES,
        bool ownGIL = true,
        bool spinROS = false
    );

    // methods

    void runLoopOnce(const std::chrono::time_point<std::chrono::steady_clock>& startTime);
    void runLoop(std::chrono::milliseconds timeout);
    void runLoopAsync(std::chrono::milliseconds timeout = std::chrono::milliseconds(0));
    void stopLoop();
    void shutdown();
    bool isRunning();
    void waitForLoopEnd();
};

Detailed Documentation

Manages simulation loop. Runs physics and brain interface, and synchronizes them via Transfer Functions.

Construction

EventLoop(
    const nlohmann::json& graph_config,
    std::chrono::milliseconds timestep,
    std::chrono::milliseconds timestepThres,
    ComputationalGraph::ExecMode execMode = ComputationalGraph::ExecMode::ALL_NODES,
    bool ownGIL = true,
    bool spinROS = false
)

Constructor.

Methods

void runLoopOnce(const std::chrono::time_point<std::chrono::steady_clock>& startTime)

Run a single loop.

void runLoop(std::chrono::milliseconds timeout)

Run loop.

void runLoopAsync(std::chrono::milliseconds timeout = std::chrono::milliseconds(0))

Run loop in a thread.

void stopLoop()

Stop loop.

void shutdown()

Shutdown loop.

bool isRunning()

Returns true if the event loop is currently running, false otherwise.

void waitForLoopEnd()

Blocks execution until the loop reaches timeout.