Skip to content

Commit

Permalink
Use ERASE_CONSTANT
Browse files Browse the repository at this point in the history
  • Loading branch information
christophfroehlich committed Jun 18, 2024
1 parent cb0e733 commit 597a2b8
Showing 1 changed file with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,12 @@ SegmentTolerances get_segment_tolerances(
RCLCPP_DEBUG(logger, "%s %f", "goal_time", active_tolerances.goal_time_tolerance);

// from
// https://github.com/ros-controls/control_msgs/blob/master/control_msgs/msg/JointTolerance.msg #
// https://github.com/ros-controls/control_msgs/blob/master/control_msgs/msg/JointTolerance.msg
// There are two special values for tolerances:
// * 0 - The tolerance is unspecified and will remain at whatever the default is
// * -1 - The tolerance is "erased". If there was a default, the joint will be allowed to move without restriction.
// * 0 - The tolerance is unspecified and will remain at whatever the default is
// * -1 - The tolerance is "erased".
// If there was a default, the joint will be allowed to move without restriction.
constexpr double ERASE_VALUE = -1.0;

// State and goal state tolerances
for (auto joint_tol : goal.path_tolerance)
Expand All @@ -165,26 +167,26 @@ SegmentTolerances get_segment_tolerances(
{
active_tolerances.state_tolerance[i].position = joint_tol.position;
}
else if (joint_tol.position == -1.0)
{ // -1 means erase
else if (joint_tol.position == ERASE_VALUE)
{
active_tolerances.state_tolerance[i].position = 0.0;
}

if (joint_tol.velocity > 0.0)
{
active_tolerances.state_tolerance[i].velocity = joint_tol.velocity;
}
else if (joint_tol.velocity == -1.0)
{ // -1 means erase
else if (joint_tol.velocity == ERASE_VALUE)
{
active_tolerances.state_tolerance[i].velocity = 0.0;
}

if (joint_tol.acceleration > 0.0)
{
active_tolerances.state_tolerance[i].acceleration = joint_tol.acceleration;
}
else if (joint_tol.acceleration == -1.0)
{ // -1 means erase
else if (joint_tol.acceleration == ERASE_VALUE)
{
active_tolerances.state_tolerance[i].acceleration = 0.0;
}

Expand Down Expand Up @@ -215,26 +217,26 @@ SegmentTolerances get_segment_tolerances(
{
active_tolerances.goal_state_tolerance[i].position = goal_tol.position;
}
else if (goal_tol.position == -1.0)
{ // -1 means erase
else if (goal_tol.position == ERASE_VALUE)
{
active_tolerances.goal_state_tolerance[i].position = 0.0;
}

if (goal_tol.velocity > 0.0)
{
active_tolerances.goal_state_tolerance[i].velocity = goal_tol.velocity;
}
else if (goal_tol.velocity == -1.0)
{ // -1 means erase
else if (goal_tol.velocity == ERASE_VALUE)
{
active_tolerances.goal_state_tolerance[i].velocity = 0.0;
}

if (goal_tol.acceleration > 0.0)
{
active_tolerances.goal_state_tolerance[i].acceleration = goal_tol.acceleration;
}
else if (goal_tol.acceleration == -1.0)
{ // -1 means erase
else if (goal_tol.acceleration == ERASE_VALUE)
{
active_tolerances.goal_state_tolerance[i].acceleration = 0.0;
}

Expand Down

0 comments on commit 597a2b8

Please sign in to comment.