Class base_controller
Defined in File base_controller.hpp
Inheritance Relationships
Base Types
public rer::client< base_controller >
public cspatial::metrics::interference_metrics
Derived Types
public cosm::controller::base_controller2D
(Class base_controller2D)public cosm::controller::base_controller3D
(Class base_controller3D)public cosm::controller::base_controllerQ3D
(Class base_controllerQ3D)
Class Documentation
-
class base_controller : public rer::client<base_controller>, public cspatial::metrics::interference_metrics
The implementation of base controller class that the controllers for all robots. It holds all functionality common to both 2D and 3D controllers, as well that some that is stubbed out here, but overridden in derived classes which allows this class to be used as the robot controller handle when rendering QT graphics overlays.
It should never be derived from directly; derive from one of the adaptor controllers in the PAL.
Subclassed by cosm::controller::base_controller2D, cosm::controller::base_controller3D, cosm::controller::base_controllerQ3D
Public Functions
-
base_controller(const base_controller&) = delete
-
base_controller(void)
-
~base_controller(void) override
-
rmath::radians azimuth(void) const
-
virtual void control_step(void) = 0
Run the main controller loop.
-
rmath::vector2z dpos2D(void) const
-
rmath::vector3z dpos3D(void) const
-
inline auto entered_interference(void) const -> decltype(std::declval<decltype(*m_inta_tracker)>().entered_interference()) override
-
virtual rtypes::type_uuid entity_id(void) const = 0
Get the ID of the entity, which is unique among all entities of the same type in simulation. For real robots, it doesn’t have to be unique, but it probably still should be to assist with debugging.
-
inline auto exited_interference(void) const -> decltype(std::declval<decltype(*m_inta_tracker)>().exited_interference()) override
-
inline auto exp_interference(void) const -> decltype(std::declval<decltype(*m_inta_tracker)>().exp_interference()) override
-
virtual void init(ticpp::Element&) = 0
Initialize the controller from XML configuration.
-
inline const cspatial::interference_tracker *inta_tracker(void) const
-
inline auto interference_duration(void) const -> decltype(std::declval<decltype(*m_inta_tracker)>().interference_duration()) override
-
inline auto interference_loc3D(void) const -> decltype(std::declval<decltype(*m_inta_tracker)>().interference_loc3D()) override
-
inline const ckin::metrics_proxy *kin_proxy(void) const
-
virtual void mdc_ts_update(void) const = 0
Convenience function to add timestamp to messages during the control step.
-
inline void ndc_uuid_pop(void) const
-
inline void ndc_uuid_push(void) const
Convenience function to add footbot ID to salient messages during loop function execution (timestep is already there).
-
base_controller &operator=(const base_controller&) = delete
-
virtual void reset(void) = 0
Resut the controller before initialization, after simulation finishes, etc. Should be idempotent, making starting running the controller after calling this function the same as if the controller had just been created.
-
inline rmath::rng *rng(void)
Return a handle to the rmath::rng used for random number generation by this robot.
-
rmath::vector2d rpos2D(void) const
-
rmath::vector3d rpos3D(void) const
-
inline class subsystem::base_saa_subsystem *saa(void)
-
inline const class subsystem::base_saa_subsystem *saa(void) const
-
virtual void sensing_update(const rtypes::timestep &tick) = 0
Update the sensing for the robot.
Set the current clock tick.
Update positioning information.
- Parameters:
tick – The current simulation clock tick.
-
virtual void sensing_update(const rtypes::timestep &tick, const rtypes::discretize_ratio &ratio) = 0
Update the sensing for the robot.
Set the current clock tick.
Update positioning information.
- Parameters:
tick – The current clock tick.
ratio – The ratio that should be used to calculate the robot’s discrete position in the arena (should match the ratio used to create the arena grid).
-
inline cfsm::supervisor_fsm *supervisor(void)
-
inline const cfsm::supervisor_fsm *supervisor(void) const
-
rmath::radians zenith(void) const
Protected Functions
-
void inta_tracker(std::unique_ptr<cspatial::interference_tracker> inta)
-
inline cspatial::interference_tracker *inta_tracker(void)
-
void kin_proxy(std::unique_ptr<ckin::metrics_proxy> prox)
-
virtual fs::path output_init(const cpconfig::output_config *config)
Initialize controller output (i.e. where it will log events of interest).
Sets up the following log files in the output directory:
cosm.controller -> controller.log
cosm.fsm -> fsm.log
cosm.subsystem.saa -> saa.log
- Returns:
Absolute path to the output directory.
-
virtual void rng_init(int seed, const std::string &category)
Initialize random number generation for the controller.
- Parameters:
seed – The seed to use. -1 results in time seeded RNG, otherwise the seed value is used.
category – The category of the RNG so that multiple robots can share RNG (or not), depending on configuration.
-
void saa(std::unique_ptr<subsystem::base_saa_subsystem> saa)
-
void supervisor(std::unique_ptr<cfsm::supervisor_fsm> fsm)
-
base_controller(const base_controller&) = delete