catchrobo2022 / Mbed 2 deprecated CatchroboJointController

Dependencies:   mbed FastPWM3

TorqueController/TorqueController.cpp

Committer:
benkatz
Date:
2017-02-14
Revision:
19:bd10a04eedc2
Parent:
8:10ae7bc88d6e

File content as of revision 19:bd10a04eedc2:


//cogging torque and torque ripple compensation can go here later

#include "CurrentRegulator.h"
#include "TorqueController.h"

TorqueController::TorqueController(float Kt, CurrentRegulator *regulator)
    {
    _CurrentRegulator = regulator;
    _Kt = Kt;
    
    }

void TorqueController::SetTorque(float torque)
    {
        SetCurrent(0, torque/_Kt);
    }

void TorqueController::SetCurrent(float Id, float Iq)
    {
        _CurrentRegulator->UpdateRef(Id, Iq);
        _CurrentRegulator->Commutate();
        
    }