File tree Expand file tree Collapse file tree 2 files changed +5
-0
lines changed
Expand file tree Collapse file tree 2 files changed +5
-0
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,9 @@ class ServoNode
133133 // Threads used by ServoNode
134134 std::thread servo_loop_thread_;
135135
136+ // Locks for threads safety
137+ std::mutex lock_;
138+
136139 // rolling window of joint commands
137140 std::deque<KinematicState> joint_cmd_rolling_window_;
138141};
Original file line number Diff line number Diff line change @@ -151,6 +151,7 @@ void ServoNode::pauseServo(const std::shared_ptr<std_srvs::srv::SetBool::Request
151151 }
152152 else
153153 {
154+ std::lock_guard<std::mutex> lock_guard (lock_);
154155 // Reset the smoothing plugin with the robot's current state in case the robot moved between pausing and unpausing.
155156 last_commanded_state_ = servo_->getCurrentRobotState (true /* block for current robot state */ );
156157 servo_->resetSmoothing (last_commanded_state_);
@@ -320,6 +321,7 @@ void ServoNode::servoLoop()
320321 continue ;
321322 }
322323
324+ std::lock_guard<std::mutex> lock_guard (lock_);
323325 const bool use_trajectory = servo_params_.command_out_type == " trajectory_msgs/JointTrajectory" ;
324326 const auto cur_time = node_->now ();
325327
You can’t perform that action at this time.
0 commit comments