1515#ifndef JOINT_TRAJECTORY_CONTROLLER_PLUGINS__TRAJECTORY_CONTROLLER_BASE_HPP_
1616#define JOINT_TRAJECTORY_CONTROLLER_PLUGINS__TRAJECTORY_CONTROLLER_BASE_HPP_
1717
18+ #include < atomic>
1819#include < memory>
1920#include < string>
2021#include < vector>
@@ -74,9 +75,9 @@ class TrajectoryControllerBase
7475 bool compute_control_law_non_rt (
7576 const std::shared_ptr<trajectory_msgs::msg::JointTrajectory> & trajectory)
7677 {
77- rt_control_law_ready_. writeFromNonRT ( false ) ;
78+ rt_control_law_ready_ = false ;
7879 auto ret = on_compute_control_law_non_rt (trajectory);
79- rt_control_law_ready_. writeFromNonRT ( true ) ;
80+ rt_control_law_ready_ = true ;
8081 return ret;
8182 }
8283
@@ -93,10 +94,9 @@ class TrajectoryControllerBase
9394 bool compute_control_law_rt (
9495 const std::shared_ptr<trajectory_msgs::msg::JointTrajectory> & trajectory)
9596 {
96- // TODO(christophfroehlich): Need a lock-free write here
97- rt_control_law_ready_.writeFromNonRT (false );
97+ rt_control_law_ready_ = false ;
9898 auto ret = on_compute_control_law_rt (trajectory);
99- rt_control_law_ready_. writeFromNonRT ( true ) ;
99+ rt_control_law_ready_ = true ;
100100 return ret;
101101 }
102102
@@ -143,15 +143,13 @@ class TrajectoryControllerBase
143143 /* *
144144 * @return true if the control law is ready (updated with the trajectory)
145145 */
146- bool is_ready () { return rt_control_law_ready_. readFromRT () ; }
146+ bool is_ready () { return rt_control_law_ready_; }
147147
148148protected:
149149 // the node handle for parameter handling
150150 rclcpp_lifecycle::LifecycleNode::SharedPtr node_;
151151 // map from joints in the message to command joints
152152 std::vector<size_t > map_cmd_to_joints_;
153- // Are we computing the control law or is it valid?
154- realtime_tools::RealtimeBuffer<bool > rt_control_law_ready_;
155153
156154 /* *
157155 * @brief Get the logger for this plugin
@@ -200,6 +198,8 @@ class TrajectoryControllerBase
200198private:
201199 // child logger for this plugin
202200 rclcpp::Logger logger_ = rclcpp::get_logger(" joint_trajectory_controller_plugins" );
201+ // Are we computing the control law or is it valid?
202+ std::atomic<bool > rt_control_law_ready_;
203203};
204204
205205} // namespace joint_trajectory_controller_plugins
0 commit comments