3939
4040#include < optional>
4141#include < memory>
42- #include " angles/angles.h "
42+ #include < vector >
4343#include " joint_trajectory_controller/joint_trajectory_controller.hpp"
44- #include " joint_trajectory_controller/trajectory.hpp"
4544#include " rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp"
4645#include " rclcpp/time.hpp"
4746#include " rclcpp/duration.hpp"
@@ -63,26 +62,35 @@ class ScaledJointTrajectoryController : public joint_trajectory_controller::Join
6362
6463 CallbackReturn on_init () override ;
6564
66- protected:
67- struct TimeData
68- {
69- TimeData () : time(0.0 ), period(rclcpp::Duration::from_nanoseconds(0.0 )), uptime(0.0 )
70- {
71- }
72- rclcpp::Time time;
73- rclcpp::Duration period;
74- rclcpp::Time uptime;
75- };
76-
7765private:
78- double scaling_factor_{ 1.0 };
79- realtime_tools::RealtimeBuffer<TimeData> time_data_;
66+ std::atomic<double > scaling_factor_{ 1.0 };
8067
8168 std::optional<std::reference_wrapper<hardware_interface::LoanedStateInterface>> scaling_state_interface_ =
8269 std::nullopt ;
8370
8471 std::shared_ptr<scaled_joint_trajectory_controller::ParamListener> scaled_param_listener_;
8572 scaled_joint_trajectory_controller::Params scaled_params_;
73+
74+ // Private methods copied from Upstream JTC
75+ void update_pids ();
76+
77+ /* *
78+ * @brief Assigns the values from a trajectory point interface to a joint interface.
79+ *
80+ * @tparam T The type of the joint interface.
81+ * @param[out] joint_interface The reference_wrapper to assign the values to
82+ * @param[in] trajectory_point_interface Containing the values to assign.
83+ * @todo: Use auto in parameter declaration with c++20
84+ */
85+ template <typename T>
86+ bool assign_interface_from_point (const T& joint_interface, const std::vector<double >& trajectory_point_interface)
87+ {
88+ bool success = true ;
89+ for (size_t index = 0 ; index < num_cmd_joints_; ++index) {
90+ success &= joint_interface[index].get ().set_value (trajectory_point_interface[map_cmd_to_joints_[index]]);
91+ }
92+ return success;
93+ }
8694};
8795} // namespace ur_controllers
8896
0 commit comments