49 CallbackReturn on_init(
50 const hardware_interface::HardwareComponentInterfaceParams & params)
override;
52 std::vector<hardware_interface::StateInterface::ConstSharedPtr> on_export_state_interfaces()
54 std::vector<hardware_interface::CommandInterface::SharedPtr> on_export_command_interfaces()
57 CallbackReturn on_activate(
const rclcpp_lifecycle::State & previous_state)
override;
58 CallbackReturn on_deactivate(
const rclcpp_lifecycle::State & previous_state)
override;
60 hardware_interface::return_type
read(
61 const rclcpp::Time & time,
const rclcpp::Duration & period)
override;
62 hardware_interface::return_type
write(
63 const rclcpp::Time & time,
const rclcpp::Duration & period)
override;
66 void topic_callback(
const sensor_msgs::msg::JointState::SharedPtr msg);
68 std::string state_topic_{
"/zenbedded/inverted_pendulum/state"};
69 std::string command_topic_{
"/zenbedded/inverted_pendulum/cmd"};
71 std::vector<hardware_interface::StateInterface::SharedPtr> state_interfaces_;
72 std::vector<hardware_interface::CommandInterface::SharedPtr> command_interfaces_;
77 double last_accel_cmd_{0.0};
79 std::mutex state_mutex_;
80 double latest_q1_{0.0};
81 double latest_q1_dot_{0.0};
82 double latest_q2_{0.0};
83 double latest_q2_dot_{0.0};
84 std::atomic<bool> has_received_state_{
false};
86 rclcpp::Node::SharedPtr node_;
87 rclcpp::executors::SingleThreadedExecutor::SharedPtr executor_;
88 std::thread spin_thread_;
90 rclcpp::Subscription<sensor_msgs::msg::JointState>::SharedPtr state_sub_;
91 rclcpp::Publisher<control_msgs::msg::JointCommand>::SharedPtr cmd_pub_;
hardware_interface::return_type read(const rclcpp::Time &time, const rclcpp::Duration &period) override
Read the current state values from the actuator.
Definition inverted_pendulum_tier1_hardware.cpp:200
hardware_interface::return_type write(const rclcpp::Time &time, const rclcpp::Duration &period) override
Write the current command values to the actuator.
Definition inverted_pendulum_tier1_hardware.cpp:217