Skip to content

Commit 89d71c5

Browse files
committed
Add safety checks for joint position and velocity limits
Ensure position limits are only applied when configured and re-clamp velocity limits after acceleration and jerk computations to maintain validity. Signed-off-by: Sachin Kumar <sachinkum123567@gmail.com>
1 parent cb7e3f0 commit 89d71c5

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

joint_limits/src/joint_saturation_limiter.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,10 @@ void JointSaturationLimiter<trajectory_msgs::msg::JointTrajectoryPoint>::clamp_j
220220
{
221221
desired_pos_[index] =
222222
current_joint_states.positions[index] + desired_vel_[index] * dt_seconds;
223-
clamp_pos_limit();
223+
if (joint_limits_[index].has_position_limits)
224+
{
225+
clamp_pos_limit();
226+
}
224227
}
225228

226229
desired_acc_[index] = (desired_vel_[index] - current_joint_velocities[index]) / dt_seconds;
@@ -437,6 +440,13 @@ void JointSaturationLimiter<trajectory_msgs::msg::JointTrajectoryPoint>::clamp_j
437440
}
438441
}
439442

443+
// Re-clamp desired velocity after acceleration/jerk may have recomputed it
444+
if (
445+
has_desired_velocity && joint_limits_[index].has_velocity_limits &&
446+
std::fabs(desired_vel_[index]) > joint_limits_[index].max_velocity)
447+
{
448+
clamp_vel_limit();
449+
}
440450
// Re-clamp desired position after acceleration/jerk may have recomputed it
441451
if (has_desired_position && joint_limits_[index].has_position_limits)
442452
{

0 commit comments

Comments
 (0)