Easy Navigation
Loading...
Searching...
No Matches
CommandGuard Class Reference

Keeps the velocity command sent to the robot from being stale or invalid. More...

#include <CommandGuard.hpp>

Public Member Functions

bool check_controller_period (double period, const std::string &controller) const
 Checks "cmd_timeout" against the period (s) of controller. Logs if not longer.
double cmd_timeout () const
bool configure (rclcpp_lifecycle::LifecycleNode &node)
 Reads and checks the parameters, and starts over. Logs and returns false if invalid.
void declare_parameters (rclcpp_lifecycle::LifecycleNode &node)
 Declares "cmd_timeout" and "cmd_vel_keepalive_period" in node.
bool discard_non_finite (NavState &nav_state)
 Consumes this cycle's non-finite proposals.
bool is_new (const geometry_msgs::msg::TwistStamped &cmd)
 Whether a controller command is new (stamp or value changed). Remembers it.
bool keepalive_due (const rclcpp::Time &now) const
 Whether the command must be republished at now (keepalive).
double keepalive_period () const
void published (const rclcpp::Time &stamp)
 Records that a command stamped stamp was published.
rclcpp::QoS qos () const
 QoS of the velocity publisher.
void report (NavState &nav_state, bool discarded, bool fresh)
 Updates "diagnostics.cmd_vel" after this cycle's selection.
void reset ()
 Forgets the timeout, keepalive and last command (e.g.
VelocityMux::Selection supervise (const VelocityMux::Selection &selection, const rclcpp::Time &now)
 selection, or zero if its non-zero target is held for longer than the timeout.
bool timed_out () const
 Whether the target was zeroed because no proposal arrived in time.

Detailed Description

Keeps the velocity command sent to the robot from being stale or invalid.

Around ControllerNode's VelocityMux, every RT cycle:

  • only new controller commands (stamp or value changed) are proposed (is_new());
  • non-finite proposals are discarded before the mux selects (discard_non_finite());
  • a non-zero target with no new proposal for "cmd_timeout" s becomes zero (supervise());
  • the command is republished every "cmd_vel_keepalive_period" s (keepalive_due()), and the publisher offers deadline and liveliness QoS of twice that period (qos());
  • problems are reported in NavState as "diagnostics.cmd_vel" (report()).

Member Function Documentation

◆ check_controller_period()

bool check_controller_period ( double period,
const std::string & controller ) const

Checks "cmd_timeout" against the period (s) of controller. Logs if not longer.

◆ cmd_timeout()

double cmd_timeout ( ) const
nodiscard

◆ configure()

bool configure ( rclcpp_lifecycle::LifecycleNode & node)

Reads and checks the parameters, and starts over. Logs and returns false if invalid.

◆ declare_parameters()

void declare_parameters ( rclcpp_lifecycle::LifecycleNode & node)

Declares "cmd_timeout" and "cmd_vel_keepalive_period" in node.

◆ discard_non_finite()

bool discard_non_finite ( NavState & nav_state)

Consumes this cycle's non-finite proposals.

Returns
Whether any was discarded.

◆ is_new()

bool is_new ( const geometry_msgs::msg::TwistStamped & cmd)

Whether a controller command is new (stamp or value changed). Remembers it.

◆ keepalive_due()

bool keepalive_due ( const rclcpp::Time & now) const
nodiscard

Whether the command must be republished at now (keepalive).

◆ keepalive_period()

double keepalive_period ( ) const
nodiscard

◆ published()

void published ( const rclcpp::Time & stamp)

Records that a command stamped stamp was published.

◆ qos()

rclcpp::QoS qos ( ) const
nodiscard

QoS of the velocity publisher.

◆ report()

void report ( NavState & nav_state,
bool discarded,
bool fresh )

Updates "diagnostics.cmd_vel" after this cycle's selection.

◆ reset()

void reset ( )

Forgets the timeout, keepalive and last command (e.g.

once the robot is stopped). The last report is kept: NavState outlives a reconfiguration, its ERROR must be cleared.

◆ supervise()

VelocityMux::Selection supervise ( const VelocityMux::Selection & selection,
const rclcpp::Time & now )

selection, or zero if its non-zero target is held for longer than the timeout.

◆ timed_out()

bool timed_out ( ) const
nodiscard

Whether the target was zeroed because no proposal arrived in time.


The documentation for this class was generated from the following files: