Class MethodBase

Inheritance Relationships

Derived Types

Class Documentation

class MethodBase

Base class for Easy Navigation method plugins.

Provides lifecycle integration and update-rate management for components such as localizers, controllers, or map managers.

Subclassed by easynav::ControllerMethodBase, easynav::LocalizerMethodBase, easynav::MapsManagerBase, easynav::PlannerMethodBase

Public Functions

MethodBase() = default

Default constructor.

virtual ~MethodBase() = default

Virtual destructor.

virtual std::expected<void, std::string> initialize(const std::shared_ptr<rclcpp_lifecycle::LifecycleNode> parent_node, const std::string &plugin_name, const std::string &tf_prefix = "")

Initializes the method with the given node and plugin name.

Also reads update frequencies and sets up internal state.

Parameters:
  • parent_node – Shared pointer to the parent lifecycle node.

  • plugin_name – Name of the plugin (used for parameters and logging).

Returns:

std::expected<void, std::string> indicating success or failure.

inline virtual std::expected<void, std::string> on_initialize()

Hook for custom setup logic in derived classes.

Called from initialize(). Can be overridden to implement extra initialization steps.

Returns:

std::expected<void, std::string> indicating success or failure.

std::shared_ptr<rclcpp_lifecycle::LifecycleNode> get_node() const

Get a shared pointer to the parent lifecycle node.

Returns:

Shared pointer to the lifecycle node.

const std::string &get_plugin_name() const

Get the name assigned to the plugin.

Returns:

Plugin name as a constant reference.

const std::string &get_tf_prefix() const

Get the TF namespace.

Returns:

TF namespace with a trailing “/”.

bool isTime2RunRT()

Check whether it is time to run a real-time update.

Uses the configured real-time frequency to determine whether sufficient time has elapsed.

Returns:

True if update should run, false otherwise.

bool isTime2Run()

Check whether it is time to run a normal (non-RT) update.

Uses the configured frequency to determine whether sufficient time has elapsed.

Returns:

True if update should run, false otherwise.

void setRunRT()

Mark that the real-time update has just run.

Records the current time as the last RT execution timestamp. Call this right after completing a successful RT iteration.

Post:

get_last_rt_execution_ts() reflects the time of this call.

void setRun()

Mark that the normal (non-RT) update has just run.

Records the current time as the last non-RT execution timestamp. Call this right after completing a successful non-RT iteration.

Post:

get_last_execution_ts() reflects the time of this call.

inline const rclcpp::Time &get_last_rt_execution_ts() const

Get the timestamp of the last real-time execution.

Note

If no RT run has been recorded yet, this value may be zero-initialized.

Returns:

Reference to the last RT execution time as recorded by setRunRT().

inline const rclcpp::Time &get_last_execution_ts() const

Get the timestamp of the last non-RT execution.

Note

If no non-RT run has been recorded yet, this value may be zero-initialized.

Returns:

Reference to the last non-RT execution time as recorded by setRun().