Class PendulumController

Class Documentation

class PendulumController

Provides a simple PID controller for the inverted pendulum.

Public Functions

inline PendulumController(std::chrono::nanoseconds period, PIDProperties pid)

Default constructor.

Parameters:
  • period[in] The update period of the controller.

  • pid[in] The properties of the controller.

inline void on_sensor_message(pendulum_msgs::msg::JointState::ConstSharedPtr msg)

Calculate new command based on new sensor state and PID controller properties.

inline void on_pendulum_setpoint(pendulum_msgs::msg::JointCommand::ConstSharedPtr msg)

Callback when a pendulum JointCommand message is received.

inline const pendulum_msgs::msg::JointCommand &get_next_command_message() const

Retrieve the command calculated from the last sensor message.

inline bool next_message_ready() const

True if the command message has been initialized.

inline std::chrono::nanoseconds get_publish_period() const

Get the update period of the controller.

inline void set_pid_properties(const PIDProperties &properties)

Set the properties of the PID controller (gains and desired output).

inline const PIDProperties &get_pid_properties() const

Get the properties of the controller.

inline void set_command(double command)

Set the commanded position of the controller.

inline double get_command() const

Get the commanded position of the controller.

Public Members

size_t messages_received = 0

Count the number of messages received (number of times the callback fired).