Skip to content

ForwardCommandController: It should at least warn when receives messages while not active #1760

Open
@caioaamaral

Description

@caioaamaral

Is your feature request related to a problem? Please describe.
JTC for instance error log when it is not active:

RCLCPP_ERROR(logger, "Can't sample trajectory. Controller is not active.");

I would like something equivalent for ForwardCommandController

Describe the solution you'd like
I've tried some solutions, but not quite sure why this does not work

joints_command_subscriber_ = this->get_node()->create_subscription<
    std_msgs::msg::Float64MultiArray>(
    "commands", rclcpp::SystemDefaultsQoS(),
    [this](const forward_command_controller::CmdType::SharedPtr msg) {
      auto current_state = this->get_node()->get_current_state().id();
      if (current_state != lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE) {
        RCLCPP_WARN(this->get_node()->get_logger(),
          "Received command while controller is not active");
        return;
      }

      rt_command_ptr_.writeFromNonRT(msg);
    });

Describe alternatives you've considered
N/A

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions