Skip to content

Commit 7e55cc9

Browse files
Merge remote-tracking branch 'origin/master' into jtc/controller_plugin
2 parents 23f55b4 + 210358b commit 7e55cc9

28 files changed

+678
-262
lines changed

diff_drive_controller/src/diff_drive_controller.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,19 @@ controller_interface::return_type DiffDriveController::update_and_write_commands
167167
double right_feedback_mean = 0.0;
168168
for (size_t index = 0; index < static_cast<size_t>(wheels_per_side_); ++index)
169169
{
170-
const double left_feedback = registered_left_wheel_handles_[index].feedback.get().get_value();
171-
const double right_feedback =
172-
registered_right_wheel_handles_[index].feedback.get().get_value();
170+
const auto left_feedback_op =
171+
registered_left_wheel_handles_[index].feedback.get().get_optional();
172+
const auto right_feedback_op =
173+
registered_right_wheel_handles_[index].feedback.get().get_optional();
174+
175+
if (!left_feedback_op.has_value() || !right_feedback_op.has_value())
176+
{
177+
RCLCPP_DEBUG(logger, "Unable to retrieve the data from the left or right wheels feedback!");
178+
return controller_interface::return_type::OK;
179+
}
180+
181+
const double left_feedback = left_feedback_op.value();
182+
const double right_feedback = right_feedback_op.value();
173183

174184
if (std::isnan(left_feedback) || std::isnan(right_feedback))
175185
{
@@ -278,12 +288,18 @@ controller_interface::return_type DiffDriveController::update_and_write_commands
278288
(linear_command + angular_command * wheel_separation / 2.0) / right_wheel_radius;
279289

280290
// Set wheels velocities:
291+
bool set_command_result = true;
281292
for (size_t index = 0; index < static_cast<size_t>(wheels_per_side_); ++index)
282293
{
283-
registered_left_wheel_handles_[index].velocity.get().set_value(velocity_left);
284-
registered_right_wheel_handles_[index].velocity.get().set_value(velocity_right);
294+
set_command_result &=
295+
registered_left_wheel_handles_[index].velocity.get().set_value(velocity_left);
296+
set_command_result &=
297+
registered_right_wheel_handles_[index].velocity.get().set_value(velocity_right);
285298
}
286299

300+
RCLCPP_DEBUG_EXPRESSION(
301+
logger, !set_command_result, "Unable to set the command to one of the command handles!");
302+
287303
return controller_interface::return_type::OK;
288304
}
289305

diff_drive_controller/test/test_diff_drive_controller.cpp

Lines changed: 83 additions & 70 deletions
Large diffs are not rendered by default.

doc/migration.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ joint_trajectory_controller
2020
* Angle wraparound behavior (continuous joints) was added from the current state to the first segment of the incoming trajectory (`#796 <https://github.com/ros-controls/ros2_controllers/pull/796>`_).
2121
* The URDF is now parsed for continuous joints and angle wraparound is automatically activated now (`#949 <https://github.com/ros-controls/ros2_controllers/pull/949>`_). Remove the ``angle_wraparound`` parameter from the configuration and set continuous joint type in the URDF of the respective joint.
2222
* Tolerances sent with the action goal were not used before, but are now processed and used for the upcoming action. (`#716 <https://github.com/ros-controls/ros2_controllers/pull/716>`_). Adaptions to the action goal might be necessary.
23+
* 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>`_).

doc/release_notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ joint_trajectory_controller
5252
allowed to move without restriction.
5353
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>`_).
55+
* Feed-forward effort trajectories are supported now (`#1200 <https://github.com/ros-controls/ros2_controllers/pull/1200>`_).
56+
* 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>`_).
5557

5658
mecanum_drive_controller
5759
************************

effort_controllers/test/test_joint_group_effort_controller.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,13 @@ TEST_F(JointGroupEffortControllerTest, ActivateWithWrongJointsNamesFails)
8585
// activate failed, 'joint4' is not a valid joint name for the hardware
8686
ASSERT_EQ(controller_->on_configure(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);
8787
ASSERT_EQ(controller_->on_activate(rclcpp_lifecycle::State()), CallbackReturn::ERROR);
88+
ASSERT_EQ(controller_->on_cleanup(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);
8889

8990
controller_->get_node()->set_parameter({"joints", std::vector<std::string>{"joint1", "joint2"}});
9091

91-
// activate failed, 'acceleration' is not a registered interface for `joint1`
92+
// activate should succeed now
9293
ASSERT_EQ(controller_->on_configure(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);
93-
ASSERT_EQ(controller_->on_activate(rclcpp_lifecycle::State()), CallbackReturn::ERROR);
94+
ASSERT_EQ(controller_->on_activate(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);
9495
}
9596

9697
TEST_F(JointGroupEffortControllerTest, CommandSuccessTest)

forward_command_controller/src/forward_command_controller.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ controller_interface::CallbackReturn ForwardCommandController::read_parameters()
4545
return controller_interface::CallbackReturn::ERROR;
4646
}
4747

48+
command_interface_types_.clear();
4849
for (const auto & joint : params_.joints)
4950
{
5051
command_interface_types_.push_back(joint + "/" + params_.interface_name);

joint_trajectory_controller/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ if(BUILD_TESTING)
7474
ament_target_dependencies(test_trajectory_controller ros2_control_test_assets)
7575
target_compile_definitions(joint_trajectory_controller PRIVATE _USE_MATH_DEFINES)
7676

77+
add_definitions(-DTEST_FILES_DIRECTORY="${CMAKE_CURRENT_SOURCE_DIR}/test")
7778
ament_add_gmock(test_load_joint_trajectory_controller
7879
test/test_load_joint_trajectory_controller.cpp
7980
)

joint_trajectory_controller/doc/parameters_context.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ constraints:
22
Default values for tolerances if no explicit values are set in the ``JointTrajectory`` message.
33

44
gains: |
5-
Only relevant, if ``open_loop_control`` is not set.
6-
75
If ``velocity`` is the only command interface for all joints or an ``effort`` command interface is configured, PID controllers are used for every joint.
86
This structure contains the controller gains for every joint with the control law
97
@@ -16,3 +14,5 @@ gains: |
1614
i.e., the shortest rotation to the target position is the desired motion.
1715
Otherwise :math:`e = s_d - s` is used, with the desired position :math:`s_d` and the measured
1816
position :math:`s` from the state interface.
17+
18+
If you want to turn off the PIDs (open loop control), set the feedback gains to zero.

joint_trajectory_controller/doc/trajectory.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ The spline interpolator uses the following interpolation strategies depending on
4949

5050
Trajectories with velocity fields only, velocity and acceleration only, or acceleration fields only can be processed and are accepted, if ``allow_integration_in_goal_trajectories`` is true. Position (and velocity) is then integrated from velocity (or acceleration, respectively) by Heun's method.
5151

52+
Effort trajectories are allowed for controllers that claim the ``effort`` command interface and they are treated as feed-forward effort that is added to the position feedback. Effort is handled separately from position, velocity and acceleration. We use linear interpolation for effort when the ``spline`` interpolation method is selected.
53+
5254
Visualized Examples
5355
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5456
To visualize the difference of the different interpolation methods and their inputs, different trajectories defined at a 0.5s grid and are sampled at a rate of 10ms.

joint_trajectory_controller/doc/userdoc.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@ Currently, joints with hardware interface types ``position``, ``velocity``, ``ac
2424
* ``position``, ``velocity``, ``acceleration``
2525
* ``velocity``
2626
* ``effort``
27+
* ``position``, ``effort``
2728

2829
This means that the joints can have one or more command interfaces, where the following control laws are applied at the same time:
2930

3031
* For command interfaces ``position``, the desired positions are simply forwarded to the joints,
3132
* For command interfaces ``acceleration``, desired accelerations are simply forwarded to the joints.
3233
* For ``velocity`` (``effort``) command interfaces, the position+velocity trajectory following error is mapped to ``velocity`` (``effort``) commands through a PID loop if it is configured (:ref:`parameters`).
34+
* For ``effort`` command interface (without ``position`` command interface), if the trajectory contains effort, this will be added to the PID commands as a feed forward effort.
35+
* For ``position, effort`` command interface, if the trajectory contains effort, this will be passed directly to the ``effort`` interface (PID won't be used) while the positions will be passed to the ``position`` interface.
3336

3437
This leads to the following allowed combinations of command and state interfaces:
3538

@@ -38,7 +41,7 @@ This leads to the following allowed combinations of command and state interfaces
3841

3942
* if command interface ``velocity`` is the only one, state interfaces must include ``position, velocity`` .
4043

41-
* With command interface ``effort``, state interfaces must include ``position, velocity``.
44+
* With command interface ``effort`` or ``position, effort``, state interfaces must include ``position, velocity``.
4245

4346
* With command interface ``acceleration``, state interfaces must include ``position, velocity``.
4447

@@ -97,7 +100,7 @@ A yaml file for using it could be:
97100
action_monitor_rate: 20.0
98101
99102
allow_partial_joints_goal: false
100-
open_loop_control: true
103+
interpolate_from_desired_state: true
101104
constraints:
102105
stopped_velocity_tolerance: 0.01
103106
goal_time: 0.0

0 commit comments

Comments
 (0)