Class PendulumMotor

Class Documentation

class PendulumMotor

Represents the physical state of the pendulum, the controlling motor, and the position sensor.

Public Functions

inline PendulumMotor(std::chrono::nanoseconds period, PendulumProperties properties)

Default constructor.

Parameters:
  • period[in] Time between sending messages.

  • properties[in] Physical properties of the pendulum.

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

Update the position of motor based on the command.

inline const pendulum_msgs::msg::JointState &get_next_sensor_message() const

Return the next sensor message calculated by the physics engine.

inline bool next_message_ready() const

Get the status of the next message.

inline void set_done(bool done)

Set the boolean to signal that the physics engine should finish.

inline bool done() const

Get the status of the physics engine.

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

Get the update rate of the publisher.

inline double get_position() const

Get the current position of the pendulum.

inline PendulumState get_state() const

Get the current state of the pendulum.

inline void set_state(const PendulumState &state)

Set the state of the pendulum.

inline const PendulumProperties &get_properties() const

Get the physical properties of the pendulum.

inline void set_properties(const PendulumProperties &properties)

Set the properties of the pendulum.

Public Members

size_t messages_received = 0

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