(self, pwm, true_motor_velocity)
return actual_torque, observed_torque
Convert the pwm signal to torque.

    Args:
      pwm: The pulse width modulation.
      true_motor_velocity: The true motor velocity at the current moment. It is
        used to compute the back EMF voltage and the viscous damping.

    Returns:
      actual_torque: The torque that needs to be applied to the motor.
      observed_torque: The torque observed by the sensor.
Convert the pwm signal to torque.
Convert the pwm signal to torque .
def _convert_to_torque_from_pwm(self, pwm, true_motor_velocity):
    """Convert the pwm signal to torque.

    Args:
      pwm: The pulse width modulation.
      true_motor_velocity: The true motor velocity at the current moment. It is
        used to compute the back EMF voltage and the viscous damping.

    Returns:
      actual_torque: The torque that needs to be applied to the motor.
      observed_torque: The torque observed by the sensor.
    """
    observed_torque = np.clip(
        self._torque_constant *
        (np.asarray(pwm) * self._voltage / self._resistance),
        -OBSERVED_TORQUE_LIMIT, OBSERVED_TORQUE_LIMIT)
    if self._torque_limits is not None:
      observed_torque = np.clip(observed_torque, -1.0 * self._torque_limits,
                                self._torque_limits)

    # Net voltage is clipped at 50V by diodes on the motor controller.
    voltage_net = np.clip(
        np.asarray(pwm) * self._voltage -
        (self._torque_constant + self._viscous_damping) *
        np.asarray(true_motor_velocity), -VOLTAGE_CLIPPING, VOLTAGE_CLIPPING)
    current = voltage_net / self._resistance
    current_sign = np.sign(current)
    current_magnitude = np.absolute(current)
    # Saturate torque based on empirical current relation.
    actual_torque = np.interp(current_magnitude, self._current_table,
                              self._torque_table)
    actual_torque = np.multiply(current_sign, actual_torque)
    actual_torque = np.multiply(self._strength_ratios, actual_torque)
    if self._torque_limits is not None:
      actual_torque = np.clip(actual_torque, -1.0 * self._torque_limits,
                              self._torque_limits)
    return actual_torque, observed_torque
def _convert_to_torque_from_pwm ( self , pwm , true_motor_velocity ) : observed_torque = np . clip ( self . _torque_constant * ( np . asarray ( pwm ) * self . _voltage / self . _resistance ) , - OBSERVED_TORQUE_LIMIT , OBSERVED_TORQUE_LIMIT ) if self . _torque_limits is not None : observed_torque = np . clip ( observed_torque , - 1.0 * self . _torque_limits , self . _torque_limits ) # Net voltage is clipped at 50V by diodes on the motor controller. voltage_net = np . clip ( np . asarray ( pwm ) * self . _voltage - ( self . _torque_constant + self . _viscous_damping ) * np . asarray ( true_motor_velocity ) , - VOLTAGE_CLIPPING , VOLTAGE_CLIPPING ) current = voltage_net / self . _resistance current_sign = np . sign ( current ) current_magnitude = np . absolute ( current ) # Saturate torque based on empirical current relation. actual_torque = np . interp ( current_magnitude , self . _current_table , self . _torque_table ) actual_torque = np . multiply ( current_sign , actual_torque ) actual_torque = np . multiply ( self . _strength_ratios , actual_torque ) if self . _torque_limits is not None : actual_torque = np . clip ( actual_torque , - 1.0 * self . _torque_limits , self . _torque_limits ) return actual_torque , observed_torque