ros2_controllers icon indicating copy to clipboard operation
ros2_controllers copied to clipboard

[JTC] Accept larger number of `joints` than `command_joints`

Open christophfroehlich opened this issue 2 years ago • 7 comments

This PR softens the condition that the number of joints and command_joints have to be equal: JTC now supports having less command_joints than joints.

This gives the opportunity to track the state and error of passive joints, especially joints that are not command_joints but a degree-of-freedom of the physical system.

As an example, see the cart-pole example in the following video (a pendulum on a cart). Now it is possible to send a swing-up trajectory of the pendulum including values of the cart and the pendulum joint, JTC will do the trajectory interpolation and publishes the full state including the desired values for the pendulum joint, but it finally only can command the cart-joint.

https://github.com/ros-controls/ros2_controllers/assets/3367244/d9c89a01-9940-442b-83af-fd64a7a83e12

This PR does not directly address passive joints being part of a closed-loop kinematic chain, i.e., joints not being a degree-of-freedom of the system. One could track the trajectory of all joints being part of the closed loop, but the kinematics need to be solved in the hardware interface, e.g., by means of a transmission interface.

A future PR will propose a possibility to implement different control laws than PID, e.g., a state-space controller, which is in fact necessary to control the pendulum from the example above.

More implementation details

  • command_joints must be a subset of joints if they don't have the same size.
  • If they have the same size, a 1:1 mapping is assumed independent of the values of command_joints. (see check_interface_names_with_command_joints test)
  • ~/controller_state topic uses a single joint_names vector for all fields. Hence, entries of the output field being not included in command_joints will be NaN.

This would break rqt_joint_trajectory_controller, I used now the required state interface instead of claimed hardware interfaces from the contoller_manager msg.

christophfroehlich avatar Oct 30 '23 19:10 christophfroehlich

Codecov Report

Attention: Patch coverage is 91.48936% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 72.61%. Comparing base (0b43291) to head (2456246).

:exclamation: Current head 2456246 differs from pull request most recent head f983bcf. Consider uploading reports for the commit f983bcf to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #809      +/-   ##
==========================================
+ Coverage   71.86%   72.61%   +0.75%     
==========================================
  Files          41       41              
  Lines        3650     3652       +2     
  Branches     1794     1780      -14     
==========================================
+ Hits         2623     2652      +29     
+ Misses        707      686      -21     
+ Partials      320      314       -6     
Flag Coverage Δ
unittests 72.61% <91.48%> (+0.75%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...jectory_controller/joint_trajectory_controller.hpp 100.00% <100.00%> (ø)
...include/joint_trajectory_controller/trajectory.hpp 86.66% <ø> (+13.33%) :arrow_up:
...ory_controller/src/joint_trajectory_controller.cpp 81.08% <91.11%> (+1.55%) :arrow_up:

... and 7 files with indirect coverage changes

codecov[bot] avatar Oct 30 '23 19:10 codecov[bot]

This pull request is in conflict. Could you fix it @christophfroehlich?

mergify[bot] avatar Nov 15 '23 11:11 mergify[bot]

This pull request is in conflict. Could you fix it @christophfroehlich?

mergify[bot] avatar Jan 02 '24 15:01 mergify[bot]

This pull request is in conflict. Could you fix it @christophfroehlich?

mergify[bot] avatar Jan 11 '24 14:01 mergify[bot]

This pull request is in conflict. Could you fix it @christophfroehlich?

mergify[bot] avatar Jan 22 '24 23:01 mergify[bot]

This pull request is in conflict. Could you fix it @christophfroehlich?

mergify[bot] avatar Mar 02 '24 19:03 mergify[bot]

This pull request is in conflict. Could you fix it @christophfroehlich?

mergify[bot] avatar Apr 29 '24 12:04 mergify[bot]