BipedalLocomotion::JointLevelControllers::PositionToCurrentController class

Position-to-Current Controller with Friction Compensation and TN-Curve Limiting.

The PositionToCurrentController implements a position control strategy that directly computes motor current commands from position errors. This approach is particularly useful for robots where direct current control provides better performance than traditional position control cascades, especially in applications requiring precise force/torque control or friction compensation.

The controller implements a proportional position control law with Coulomb friction feedforward compensation and dynamic current limiting based on motor torque-speed (TN) characteristics:

\[ I = \text{clamp}\left(\frac{K_p \cdot (q_{ref} - q_{fb}) + \tau_{coulomb}}{\text{gearRatio} \cdot k_{\tau}}, I_{limit}(\omega)\right) \]

where:

  • $ I $ is the output current [A]
  • $ K_p $ is the proportional gain [Nm/rad]
  • $ q_{ref} $ is the reference position [rad]
  • $ q_{fb} $ is the feedback position [rad]
  • $ \tau_{coulomb} = k_{coulomb} \cdot \text{sign}(\dot{q}_{fb}) $ is the Coulomb friction compensation [Nm]
  • $ \dot{q}_{fb} $ is the feedback velocity [rad/s]
  • $ \text{gearRatio} $ is the gear reduction ratio (motor-to-joint)
  • $ k_{\tau} $ is the motor torque constant [Nm/A]
  • $ I_{limit}(\omega) $ is the velocity-dependent current limit [A]

Friction Compensation

The controller includes feedforward Coulomb friction compensation that adds a torque in the direction of motion to counteract coulomb friction effects:

\[ \tau_{coulomb} = k_{coulomb} \cdot \text{tanh}(\dot{q}_{fb} / v_{activation}) \]

where:

  • $ k_{coulomb} $ is the Coulomb friction constant [Nm]
  • $ v_{activation} $ is the velocity threshold for friction activation [rad/s]

This helps improve tracking accuracy, especially at low velocities where friction effects are dominant.

Dynamic Current Limiting (TN-Curve)

The controller implements velocity-dependent current limiting based on motor torque-speed characteristics to prevent motor overheating and ensure safe operation:

  • Constant Region ( $ |\omega| \leq \omega_{rated} $ ): $ I_{limit} = I_{max} $
  • Linear Falloff ( $ \omega_{rated} < |\omega| < \omega_{0} $ ): $ I_{limit} = m \cdot |\omega| + b $
  • No-Load Speed ( $ |\omega| \geq \omega_{0} $ ): $ I_{limit} = 0 $

where:

  • $ \omega_{rated} $ is the rated speed at which current limiting begins [rad/s]
  • $ \omega_{0} $ is the no-load speed where current becomes zero [rad/s]
  • $ m = -I_{max} / (\omega_{0} - \omega_{rated}) $ is the slope of the linear region
  • $ b = I_{max} - m \cdot \omega_{rated} $ is the intercept

Base classes

template<class _Input, class _Output>
class BipedalLocomotion::System::Advanceable<PositionToCurrentControllerInput, Eigen::VectorXd>
Basic class that represents a discrete system.

Constructors, destructors, conversion operators

PositionToCurrentController()
Default constructor.
~PositionToCurrentController() virtual
Default destructor.

Public functions

auto advance() -> bool override
Advance the controller.
auto initialize(std::weak_ptr<const ParametersHandler::IParametersHandler> handler) -> bool override
Initialize the advanceable.
auto setInput(const PositionToCurrentControllerInput& input) -> bool override
Set the input of the port.
auto getOutput() const -> Eigen::VectorXd& override
Get the output of the controller.
auto isOutputValid() const -> bool override
Check if the output is valid.

Function documentation

bool BipedalLocomotion::JointLevelControllers::PositionToCurrentController::advance() override

Advance the controller.

Returns The output of the controller

bool BipedalLocomotion::JointLevelControllers::PositionToCurrentController::initialize(std::weak_ptr<const ParametersHandler::IParametersHandler> handler) override

Initialize the advanceable.

Parameters
handler A weak pointer to the parameters handler
Returns True if the initialization is successful.

Furthermore, the following optional parameters are supported:

Group NameDescriptionMandatory
current_limitAn element for each joint contained in the joints_list parameter. Current limit for each joint [A]No
coulomb_frictionAn element for each joint contained in the joints_list parameter. Coulomb friction for each joint [Nm]No
activation_velocityAn element for each joint contained in the joints_list parameter. Friction activation velocity [rad/s]No
rated_speedAn element for each joint contained in the joints_list parameter. Rated speed for each joint [rad/s]No
no_load_speedAn element for each joint contained in the joints_list parameter. No-load speed for each joint [rad/s]No

bool BipedalLocomotion::JointLevelControllers::PositionToCurrentController::setInput(const PositionToCurrentControllerInput& input) override

Set the input of the port.

Parameters
input the input of the controller
Returns True in case of success and false otherwise

Eigen::VectorXd& BipedalLocomotion::JointLevelControllers::PositionToCurrentController::getOutput() const override

Get the output of the controller.

Returns The output of the controller

bool BipedalLocomotion::JointLevelControllers::PositionToCurrentController::isOutputValid() const override

Check if the output is valid.

Returns True if the output is valid, false otherwise