ros2_control - galactic
Loading...
Searching...
No Matches
inverted_pendulum_controller.hpp
1// Copyright 2026 kamal2730
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef INVERTED_PENDULUM_CONTROLLER__INVERTED_PENDULUM_CONTROLLER_HPP_
16#define INVERTED_PENDULUM_CONTROLLER__INVERTED_PENDULUM_CONTROLLER_HPP_
17
18#include <string>
19
20#include "controller_interface/controller_interface.hpp"
21#include "rclcpp/rclcpp.hpp"
22#include "rclcpp_lifecycle/state.hpp"
23
24namespace inverted_pendulum_controller
25{
31{
32public:
34
35 controller_interface::CallbackReturn on_init() override;
36
37 controller_interface::InterfaceConfiguration command_interface_configuration() const override;
38 controller_interface::InterfaceConfiguration state_interface_configuration() const override;
39
40 controller_interface::CallbackReturn on_configure(
41 const rclcpp_lifecycle::State & previous_state) override;
42 controller_interface::CallbackReturn on_activate(
43 const rclcpp_lifecycle::State & previous_state) override;
44 controller_interface::CallbackReturn on_deactivate(
45 const rclcpp_lifecycle::State & previous_state) override;
46
47 controller_interface::return_type update(
48 const rclcpp::Time & time, const rclcpp::Duration & period) override;
49
50protected:
51 // Interface names (read in on_configure)
52 std::string motor_joint_state_name_;
53 std::string motor_joint_vel_name_;
54 std::string pendulum_joint_state_name_;
55 std::string pendulum_joint_vel_name_;
56 std::string motor_joint_command_name_;
57
58 // Control parameters
59 double balance_angle_;
60 double kp_;
61 double kd_;
62 double max_acceleration_;
63};
64
65} // namespace inverted_pendulum_controller
66
67#endif // INVERTED_PENDULUM_CONTROLLER__INVERTED_PENDULUM_CONTROLLER_HPP_
Definition controller_interface.hpp:69
Definition inverted_pendulum_controller.hpp:31
Configuring what command/state interfaces to claim.
Definition controller_interface.hpp:63