ros2_control - rolling
Loading...
Searching...
No Matches
cartesian_trajectory_controller.hpp
1// Copyright (c) 2026 ros2_control Development Team
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 CARTESIAN_TRAJECTORY_CONTROLLER__CARTESIAN_TRAJECTORY_CONTROLLER_HPP_
16#define CARTESIAN_TRAJECTORY_CONTROLLER__CARTESIAN_TRAJECTORY_CONTROLLER_HPP_
17
18#include <memory>
19#include <vector>
20
21#include "Eigen/Geometry"
22#include "controller_interface/controller_interface.hpp"
23#include "joint_trajectory_controller/joint_trajectory_controller.hpp"
24#include "kinematics_interface/kinematics_interface.hpp"
25#include "pluginlib/class_loader.hpp"
26#include "rclcpp_lifecycle/state.hpp"
27#include "trajectory_msgs/msg/joint_trajectory.hpp"
28#include "trajectory_msgs/msg/multi_dof_joint_trajectory.hpp"
29
30// auto-generated by generate_parameter_library (top-level key: cartesian_trajectory_controller)
31#include "cartesian_trajectory_controller/cartesian_trajectory_controller_parameters.hpp"
32
33namespace cartesian_trajectory_controller
34{
35
37
50class CartesianTrajectoryController : public joint_trajectory_controller::JointTrajectoryController
51{
52public:
53 CartesianTrajectoryController() = default;
54
55 controller_interface::CallbackReturn on_init() override;
56
57 controller_interface::CallbackReturn on_configure(
58 const rclcpp_lifecycle::State & previous_state) override;
59
60protected:
62 void reference_callback(std::shared_ptr<trajectory_msgs::msg::MultiDOFJointTrajectory> msg);
63
66 const trajectory_msgs::msg::MultiDOFJointTrajectory & msg,
67 trajectory_msgs::msg::JointTrajectory & joint_traj);
68
69private:
72 bool build_cartesian_waypoints(
73 const trajectory_msgs::msg::MultiDOFJointTrajectory & msg,
74 const Eigen::Isometry3d & current_pose, std::vector<double> & times,
75 std::vector<Eigen::Vector3d> & positions, std::vector<Eigen::Quaterniond> & orientations) const;
76
79 bool solve_ik_along_path(
80 const CartesianTrajectory & path, Eigen::VectorXd q,
81 trajectory_msgs::msg::JointTrajectory & joint_traj);
82
83 std::shared_ptr<ParamListener> ctc_param_listener_;
84 Params ctc_params_;
85
86 std::shared_ptr<pluginlib::ClassLoader<kinematics_interface::KinematicsInterface>>
87 kinematics_loader_;
88 std::unique_ptr<kinematics_interface::KinematicsInterface> kinematics_;
89
90 rclcpp::Subscription<trajectory_msgs::msg::MultiDOFJointTrajectory>::SharedPtr ref_subscriber_;
91};
92
93} // namespace cartesian_trajectory_controller
94
95#endif // CARTESIAN_TRAJECTORY_CONTROLLER__CARTESIAN_TRAJECTORY_CONTROLLER_HPP_
bool build_joint_trajectory(const trajectory_msgs::msg::MultiDOFJointTrajectory &msg, trajectory_msgs::msg::JointTrajectory &joint_traj)
Build the joint trajectory for a Cartesian message; false drops the message.
Definition cartesian_trajectory_controller.cpp:193
void reference_callback(std::shared_ptr< trajectory_msgs::msg::MultiDOFJointTrajectory > msg)
Convert an incoming Cartesian chunk into a joint trajectory and install it into JTC.
Definition cartesian_trajectory_controller.cpp:175
controller_interface::CallbackReturn on_init() override
Extending interface with initialization method which is individual for each controller.
Definition cartesian_trajectory_controller.cpp:75
Definition cartesian_trajectory.hpp:38
Definition joint_trajectory_controller.hpp:56