Tasks#

At the begin of a simulation, prepare (C++, Python) is called: override it to initialize the task. The base implementation is empty, therefore it is not required to call it.

During the simulation, update (C++, Python) is called before a behavior is executed: override it to with higher-level logic specific to your task, which should possibly interacting with the lower-level navigation controller by

  • checking the agent’s controller (C++, Python) state and possibly triggering some action, or

  • direcly setting the agent’s behavior (C++, Python) target

yet, task are free to interact in any other way. The base implementation is empty, therefore it is not required to call it.

To let the simulation know that it can terminates, you should override done (C++, Python) returning whether the task has finished. The base implementation returns false, resulting in a never-ending task.

When events meaningful for the task happens, they can be logged using log_event (C++, Python), passing a sequence of float as payload. In case you want to log data, you should override get_log_size (:cpp:func:`C++ <navground::sim::Task::get_log_size>`, :py:meth:`Python <navground.sim.Task.get_log_size>`), returning the size of the payload, which should not change between events. The base implementation returns ``0, signalling that it won’t log data.

Warning

In case you log data of a different size, an exception will be raised.

Virtual methods#

C++ method

Python method

override

prepare

prepare

can

update

update

should

done

done

should

get_log_size

get_log_size

should

Class skelethon#

#include "navground/sim/state_estimation.h"

namespace core = navground::core;
namespace sim = navground::sim;

struct MyStateEstimation : public sim::StateEstimation {
  // CAN override
  // executed at the start of the simulation
  // void prepare(sim::Agent * agent, sim::World * world) override;

  // CAN override
  // executed during the the simulation
  // update the environment state according to the agent and world
  void update(sim::Agent *agent, sim::World *world,
              core::EnvironmentState state) ovveride {
    if (auto se = dynamic_cast<SupportedEnvironmentState>) {
      // update the state
    }
  }
};