File tree 2 files changed +5
-0
lines changed 2 files changed +5
-0
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,9 @@ class ServoNode
133
133
// Threads used by ServoNode
134
134
std::thread servo_loop_thread_;
135
135
136
+ // Locks for threads safety
137
+ std::mutex lock_;
138
+
136
139
// rolling window of joint commands
137
140
std::deque<KinematicState> joint_cmd_rolling_window_;
138
141
};
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
151
151
}
152
152
else
153
153
{
154
+ std::lock_guard<std::mutex> lock_guard (lock_);
154
155
// Reset the smoothing plugin with the robot's current state in case the robot moved between pausing and unpausing.
155
156
last_commanded_state_ = servo_->getCurrentRobotState (true /* block for current robot state */ );
156
157
servo_->resetSmoothing (last_commanded_state_);
@@ -320,6 +321,7 @@ void ServoNode::servoLoop()
320
321
continue ;
321
322
}
322
323
324
+ std::lock_guard<std::mutex> lock_guard (lock_);
323
325
const bool use_trajectory = servo_params_.command_out_type == " trajectory_msgs/JointTrajectory" ;
324
326
const auto cur_time = node_->now ();
325
327
You can’t perform that action at this time.
0 commit comments