Skip to content

Commit 8f8880e

Browse files
mergify[bot]christophfroehlichsaikishor
authored
Add new AntiWindup parameters to JTC (backport #1759) (#1762)
Co-authored-by: Christoph Fröhlich <[email protected]> Co-authored-by: Sai Kishor Kothakota <[email protected]>
1 parent 621e896 commit 8f8880e

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed

doc/release_notes.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ joint_trajectory_controller
5454
* Add the boolean parameter ``set_last_command_interface_value_as_state_on_activation``. When set to ``true``, the last command interface value is used as both the current state and the last commanded state upon activation. When set to ``false``, the current state is used for both (`#1231 <https://github.com/ros-controls/ros2_controllers/pull/1231>`_).
5555
* Feed-forward effort trajectories are supported now (`#1200 <https://github.com/ros-controls/ros2_controllers/pull/1200>`_).
5656
* Parameter ``open_loop_control`` is replaced by ``interpolate_from_desired_state`` and setting the feedback gains to zero (`#1525 <https://github.com/ros-controls/ros2_controllers/pull/1525>`_).
57+
* The controller now supports the new anti-windup strategy of the PID class, which allows for more flexible control of the anti-windup behavior. (`#1759 <https://github.com/ros-controls/ros2_controllers/pull/1759>`__).
58+
5759

5860
mecanum_drive_controller
5961
************************
@@ -83,4 +85,4 @@ gpio_controllers
8385

8486
force_torque_sensor_broadcaster
8587
*******************************
86-
* Multiplier support was added. Users can now specify per–axis scaling factors for both force and torque readings, applied after the existing offset logic. (`#1647 <https://github.com/ros-controls/ros2_controllers/pull/1647/files>`__.
88+
* Multiplier support was added. Users can now specify per–axis scaling factors for both force and torque readings, applied after the existing offset logic. (`#1647 <https://github.com/ros-controls/ros2_controllers/pull/1647/files>`__).

joint_trajectory_controller/src/joint_trajectory_controller.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,16 +1673,23 @@ void JointTrajectoryController::update_pids()
16731673
for (size_t i = 0; i < num_cmd_joints_; ++i)
16741674
{
16751675
const auto & gains = params_.gains.joints_map.at(params_.joints.at(map_cmd_to_joints_[i]));
1676+
control_toolbox::AntiWindupStrategy antiwindup_strat;
1677+
antiwindup_strat.set_type(gains.antiwindup_strategy);
1678+
antiwindup_strat.i_max = gains.i_clamp;
1679+
antiwindup_strat.i_min = -gains.i_clamp;
1680+
antiwindup_strat.error_deadband = gains.error_deadband;
1681+
antiwindup_strat.tracking_time_constant = gains.tracking_time_constant;
16761682
if (pids_[i])
16771683
{
16781684
// update PIDs with gains from ROS parameters
1679-
pids_[i]->set_gains(gains.p, gains.i, gains.d, gains.i_clamp, -gains.i_clamp);
1685+
pids_[i]->set_gains(
1686+
gains.p, gains.i, gains.d, gains.u_clamp_max, gains.u_clamp_min, antiwindup_strat);
16801687
}
16811688
else
16821689
{
16831690
// Init PIDs with gains from ROS parameters
16841691
pids_[i] = std::make_shared<control_toolbox::Pid>(
1685-
gains.p, gains.i, gains.d, gains.i_clamp, -gains.i_clamp);
1692+
gains.p, gains.i, gains.d, gains.u_clamp_max, gains.u_clamp_min, antiwindup_strat);
16861693
}
16871694
ff_velocity_scale_[i] = gains.ff_velocity_scale;
16881695
}

joint_trajectory_controller/src/joint_trajectory_controller_parameters.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,53 @@ joint_trajectory_controller:
140140
default_value: 0.0,
141141
description: "Feed-forward scaling :math:`k_{ff}` of velocity"
142142
}
143+
u_clamp_max: {
144+
type: double,
145+
default_value: .inf,
146+
description: "Upper output clamp."
147+
}
148+
u_clamp_min: {
149+
type: double,
150+
default_value: -.inf,
151+
description: "Lower output clamp."
152+
}
153+
i_clamp_max: {
154+
type: double,
155+
default_value: 0.0,
156+
description: "[Deprecated, see antiwindup_strategy] Upper integral clamp."
157+
}
158+
i_clamp_min: {
159+
type: double,
160+
default_value: 0.0,
161+
description: "[Deprecated, see antiwindup_strategy] Lower integral clamp."
162+
}
163+
antiwindup_strategy: {
164+
type: string,
165+
default_value: "legacy",
166+
read_only: true,
167+
description: "Specifies the anti-windup strategy. Options: 'back_calculation',
168+
'conditional_integration', 'legacy' or 'none'. Note that the 'back_calculation' strategy use the
169+
tracking_time_constant parameter to tune the anti-windup behavior.",
170+
validation: {
171+
one_of<>: [[
172+
"back_calculation",
173+
"conditional_integration",
174+
"legacy",
175+
"none"
176+
]]
177+
}
178+
}
179+
tracking_time_constant: {
180+
type: double,
181+
default_value: 0.0,
182+
description: "Specifies the tracking time constant for the 'back_calculation' strategy. If
183+
set to 0.0 when this strategy is selected, a recommended default value will be applied."
184+
}
185+
error_deadband: {
186+
type: double,
187+
default_value: 0.0,
188+
description: "Is used to stop integration when the error is within the given range."
189+
}
143190
constraints:
144191
stopped_velocity_tolerance: {
145192
type: double,

0 commit comments

Comments
 (0)