MotorTorqueController.h
Go to the documentation of this file.
1 // -*- C++ -*-
10 #ifndef MOTOR_TORQUE_CONTROLLER_H
11 #define MOTOR_TORQUE_CONTROLLER_H
12 
13 #include <string>
14 #include <boost/shared_ptr.hpp>
15 #include "../Stabilizer/TwoDofController.h"
18 
19 // </rtc-template>
20 
22 public:
27  };
28 
30  INACTIVE, // dq = 0
31  STOP, // resume
32  ACTIVE // execute torque control
33  };
34 
37 
38  // for TwoDofController
43  // for TwoDofControllerPDModel
48  // for TwoDofControllerDynamicsModel
53 
54  // for normal/emergency torque contorller
55  bool enable(void); // enable torque controller (normal controller is not activated but emergency toruqe control may be activated)
56  bool disable(void); // disable torque controller (emergency controller is also ignored)
57 
58  // for normal torque controller
59  void setupMotorControllerControlMinMaxDq(double _min_dq, double _max_dq); // set min/max dq for control
60  void setupMotorControllerTransitionMinMaxDq(double _min_transition_dq, double _max_transition_dq); // set min/max dq for transition
61  bool activate(void); // set state of torque controller to ACTIVE
62  bool deactivate(void); // set state of torque controller to STOP -> INACTIVE
63  bool setReferenceTorque(double _tauRef); // set reference torque (does not activate controller)
64 
65  double execute(double _tau, double _tauMax); // determine final state and tauRef, then throw tau, tauRef and state to executeControl
66 
67  // accessor
69  std::string getJointName(void);
71  bool isEnabled(void);
72 
73  // for debug
74  void setErrorPrefix(const std::string& _error_prefix);
75  void printMotorControllerVariables(void); // debug print
76 
77 private:
79  public:
84  double dq; //difference of joint angle from base(qRef) from tdc. it is calcurated by dq = integrate(qd * dt), dq*dt is output of tdc
85  double transition_dq; // for transition. first value is last difference of joint angle from qRef (dq + transition_dq) when state was changed to STOP
86  double recovery_dq; // difference of joint angle in 1 cycle to be recoverd
87  double min_dq; // min total dq when control
88  double max_dq; // max total dq when control
89  double min_transition_dq; // min dq when transition
90  double max_transition_dq; // max dq when transition
91 
92  // for TwoDofController
96  // for TwoDofControllerPDModel
100  // for TwoDofControllerDynamicsModel
104  double getMotorControllerDq(void); // get according dq according to state
105  void setErrorPrefix(const std::string& _error_prefix);
106  private:
107  bool updateParam(double &_param, const double &_new_value); // update param if new_value is acceptable
108  std::string error_prefix;
109  };
110 
111  // internal functions
112  void setupControllerCommon(std::string _jname, double _dt);
113  void resetMotorControllerVariables(MotorController& _mc); // reset internal torque control parameter
114  void prepareStop(MotorController &_mc);
115  void updateController(double _tau, double _tauRef, MotorController& _mc); // execute control and update controller member valiables
116 
117  std::string m_joint_name; // joint name which is controled
118  motor_model_t m_motor_model_type; // motor model type which is used
119  int m_transition_count; // positive value when stopping
120  double m_dt; // control term
121  double m_current_tau; // current tau (mainly for debug message)
122  double m_command_tauRef; // reference tau
123  double m_actual_tauRef; // reference tau which is limited or overwritten by emergency (mainly for debug message)
124  MotorController m_normalController; // substance of two dof controller
125  MotorController m_emergencyController; // overwrite normal controller when emergency
126  std::string m_error_prefix; // assumed to be instance name of rtc
128 };
129 
130 
131 #endif // MOTOR_TORQUE_CONTROLLER_H
bool getTwoDofControllerPDModelParam(TwoDofControllerPDModel::TwoDofControllerPDModelParam &_param)
double execute(double _tau, double _tauMax)
void setupControllerCommon(std::string _jname, double _dt)
void prepareStop(MotorController &_mc)
Feedback and Feedforward Controller which use PDModel as motor model.
bool updateControllerParam(TwoDofController::TwoDofControllerParam &_param)
void updateController(double _tau, double _tauRef, MotorController &_mc)
controller_state_t getMotorControllerState(void)
bool setReferenceTorque(double _tauRef)
bool updateParam(double &_param, const double &_new_value)
void setErrorPrefix(const std::string &_error_prefix)
void setupTwoDofControllerPDModel(TwoDofControllerPDModel::TwoDofControllerPDModelParam &_param)
bool getTwoDofControllerDynamiccsModelParam(TwoDofControllerDynamicsModel::TwoDofControllerDynamicsModelParam &_param)
void setupMotorControllerTransitionMinMaxDq(double _min_transition_dq, double _max_transition_dq)
motor_model_t getMotorModelType(void)
bool updateTwoDofControllerDynamiccsModelParam(TwoDofControllerDynamicsModel::TwoDofControllerDynamicsModelParam &_param)
bool getControllerParam(TwoDofController::TwoDofControllerParam &_param)
void setupMotorControllerControlMinMaxDq(double _min_dq, double _max_dq)
bool updateTwoDofControllerParam(TwoDofController::TwoDofControllerParam &_param)
bool updateTwoDofControllerPDModelParam(TwoDofControllerPDModel::TwoDofControllerPDModelParam &_param)
MotorController m_emergencyController
MotorController m_normalController
void setupTwoDofController(TwoDofController::TwoDofControllerParam &_param)
void setErrorPrefix(const std::string &_error_prefix)
void resetMotorControllerVariables(MotorController &_mc)
Feedback and Feedforward Controller which use PDModel as motor model.
boost::shared_ptr< TwoDofControllerInterface > controller
void setupController(TwoDofController::TwoDofControllerParam &_param)
void setupTwoDofControllerDynamicsModel(TwoDofControllerDynamicsModel::TwoDofControllerDynamicsModelParam &_param)
bool getTwoDofControllerParam(TwoDofController::TwoDofControllerParam &_param)


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Thu May 6 2021 02:41:50