32 #include <yarp/os/Bottle.h>
34 #include <yarp/os/Bottle.h>
35 #include <yarp/dev/ControlBoardPid.h>
36 #include <yarp/dev/ControlBoardHelper.h>
38 #include <yarp/dev/PidEnums.h>
39 #include <yarp/dev/ControlBoardInterfacesImpl.h>
41 #include "EoMotionControl.h"
42 #include <yarp/os/LogStream.h>
93 double _resolution_pga;
94 double _resolution_tdb;
96 double _half_bridge_resistor_coeff;
97 double _first_res_coeff;
98 double _second_res_coeff;
109 _ptc_gradient = 0.3851;
112 _resolution_pga = 2.048;
113 _resolution_tdb = 32767;
117 _half_bridge_resistor_coeff = (double)_r_3 / (
double)(_r_2 + _r_3);
118 _first_res_coeff = _r_1*_r_2 + _r_1*_r_3 + _ptc_offset*_r_2 + _ptc_offset*_r_3;
119 _second_res_coeff = _r_3*_r_1 - _r_2*_ptc_offset;
133 double tmp = (( (_ptc_offset + _ptc_gradient * temperature) / ((
double)_r_1 + (_ptc_offset + _ptc_gradient * temperature))) - _half_bridge_resistor_coeff) * (double)_vcc;
134 res = (_resolution_tdb + 1) * ((_pga_gain *
tmp) / _resolution_pga);
136 yDebug(
"Converted temperature limit to raw value:%f", res);
144 double tmp = temperature * ((_resolution_pga) / (_pga_gain * _vcc * (_resolution_tdb + 1)));
145 double den = _ptc_gradient * (_r_2 - _r_2*
tmp - _r_3*
tmp);
147 res = (
tmp * (_first_res_coeff) / den) + ((_second_res_coeff) / den);
167 double _ptc_gradient;
171 double _resolution_pga;
172 double _resolution_tdb;
176 double _half_bridge_resistor_coeff;
177 double _first_res_coeff;
178 double _second_res_coeff;
189 _ptc_gradient = 3.851;
192 _resolution_pga = 2.048;
193 _resolution_tdb = 32767;
195 _half_bridge_resistor_coeff = (double)_r_3 / (
double)(_r_2 + _r_3);
197 _first_res_coeff = _r_1*_r_2 + _r_1*_r_3 + _ptc_offset*_r_2 + _ptc_offset*_r_3;
198 _second_res_coeff = _r_3*_r_1 - _r_2*_ptc_offset;
212 double tmp = (( (_ptc_offset + _ptc_gradient * temperature) / ((
double)_r_1 + (_ptc_offset + _ptc_gradient * temperature))) - _half_bridge_resistor_coeff) * (double)_vcc;
213 res = (_resolution_tdb + 1) * ((_pga_gain *
tmp) / _resolution_pga);
215 yDebug(
"Converted temperature limit to raw value:%f", res);
223 double tmp = temperature * ((_resolution_pga) / (_pga_gain * _vcc * (_resolution_tdb + 1)));
224 double den = _ptc_gradient * (_r_2 - _r_2*
tmp - _r_3*
tmp);
226 res = (
tmp * (_first_res_coeff) / den) + ((_second_res_coeff) / den);
243 yInfo(
"Private varibales NOT DEFINED for class TemperatureSensorNONE");
250 yInfo(
"convertTempCelsiusToRaw METHOD, NOT IMPLEMENTED for class TemperatureSensorNONE");
277 void setUnits(yarp::dev::PidFeedbackUnitsEnum fu, yarp::dev::PidOutputUnitsEnum ou)
283 virtual yarp::dev::Pid
getPID(
int joint) = 0;
296 pid =
new yarp::dev::Pid[nj];
304 yarp::dev::Pid
getPID(
int joint)
override
383 fbk_PidUnits = yarp::dev::PidFeedbackUnitsEnum::RAW_MACHINE_UNITS;
384 out_PidUnits = yarp::dev::PidOutputUnitsEnum::RAW_MACHINE_UNITS;
427 eOmc_jointset_configuration_t
cfg;
433 cfg.candotorquecontrol=0;
434 cfg.usespeedfeedbackfrommotors=0;
435 cfg.pidoutputtype=eomc_pidoutputtype_unknown;
437 cfg.constraints.type=eomc_jsetconstraint_unknown;
438 cfg.constraints.param1=0;
439 cfg.constraints.param2=0;
516 std::array<float32_t, 3>
x0;
517 std::array<float32_t, 3>
Q;
536 std::string _boardname;
539 std::map<std::string, Pid_Algorithm*> minjerkAlgoMap;
541 std::map<std::string, Pid_Algorithm*> torqueAlgoMap;
546 std::vector<std::string> _positionControlLaw;
547 std::vector<std::string> _velocityControlLaw;
548 std::vector<std::string> _mixedControlLaw;
551 std::vector<std::string> _torqueControlLaw;
552 std::vector<std::string> _currentControlLaw;
553 std::vector<std::string> _speedControlLaw;
562 double *_velocityThres;
569 bool parseControlsGroup(yarp::os::Searchable &config);
571 bool parseSelectedPositionControl(yarp::os::Searchable &config);
572 bool parseSelectedVelocityControl(yarp::os::Searchable &config);
573 bool parseSelectedMixedControl(yarp::os::Searchable &config);
576 bool parseSelectedTorqueControl(yarp::os::Searchable &config);
578 bool parseSelectedCurrentPid(yarp::os::Searchable &config,
bool pidisMandatory,
PidInfo *pids);
579 bool parseSelectedSpeedPid(yarp::os::Searchable &config,
bool pidisMandatory,
PidInfo *pids);
581 bool parsePid_minJerk_outPwm(yarp::os::Bottle &b_pid, std::string controlLaw);
582 bool parsePid_minJerk_outCur(yarp::os::Bottle &b_pid, std::string controlLaw);
583 bool parsePid_minJerk_outVel(yarp::os::Bottle &b_pid, std::string controlLaw);
589 bool parsePid_torque_outPwm(yarp::os::Bottle &b_pid, std::string controlLaw);
590 bool parsePid_torque_outCur(yarp::os::Bottle &b_pid, std::string controlLaw);
591 bool parsePid_torque_outVel(yarp::os::Bottle &b_pid, std::string controlLaw);
593 bool parsePidsGroup2FOC(yarp::os::Bottle& pidsGroup, Pid myPid[]);
594 bool parsePidsGroupSimple(yarp::os::Bottle& pidsGroup, Pid myPid[]);
595 bool parsePidsGroupExtended(yarp::os::Bottle& pidsGroup, Pid myPid[]);
596 bool parsePidsGroupDeluxe(yarp::os::Bottle& pidsGroup, Pid myPid[]);
598 bool parsePidsGroup(yarp::os::Bottle& pidsGroup, yarp::dev::Pid myPid[], std::string prefix);
600 bool parsePidUnitsType(yarp::os::Bottle &bPid, yarp::dev::PidFeedbackUnitsEnum &fbk_pidunits, yarp::dev::PidOutputUnitsEnum& out_pidunits);
602 bool checkJointTypes(
PidInfo *pids,
const std::string &pid_type);
603 bool checkSinglePid(
PidInfo &firstPid,
PidInfo ¤tPid,
const int &firstjoint,
const int ¤tjoint,
const std::string &pid_type);
605 bool convert(std::string
const &fromstring, eOmc_jsetconstraint_t &jsetconstraint,
bool& formaterror);
606 bool convert(yarp::os::Bottle &bottle, std::vector<double> &matrix,
bool &formaterror,
int targetsize);
609 bool extractGroup(yarp::os::Bottle &input, yarp::os::Bottle &
out,
const std::string &key1,
const std::string &txt,
int size,
bool mandatory=
true);
611 bool checkAndSetVectorSize(std::vector<T> &vec,
int size,
const std::string &funcName)
613 if(size > (
int)vec.capacity())
615 yError() <<
"embObjMC BOARD " << _boardname <<
" in " << funcName.c_str() <<
": try to insert " << size <<
"element in vector with " << vec.capacity() <<
" elements";
624 void debugUtil_printControlLaws(
void);
628 Parser(
int numofjoints, std::string boardname);
632 bool parseFocGroup(yarp::os::Searchable &config,
focBasedSpecificInfo_t *foc_based_info, std::string groupName, std::vector<std::unique_ptr<eomc::ITemperatureSensor>>& temperatureSensorsVector);
634 bool parseJointsetCfgGroup(yarp::os::Searchable &config, std::vector<JointsSet> &jsets, std::vector<int> &jointtoset);
635 bool parseTimeoutsGroup(yarp::os::Searchable &config, std::vector<timeouts_t> &timeouts,
int defaultVelocityTimeout);
636 bool parseCurrentLimits(yarp::os::Searchable &config, std::vector<motorCurrentLimits_t> &currLimits);
637 bool parseTemperatureLimits(yarp::os::Searchable &config, std::vector<temperatureLimits_t> &temperatureLimits);
638 bool parseJointsLimits(yarp::os::Searchable &config, std::vector<jointLimits_t> &jointsLimits);
639 bool parseRotorsLimits(yarp::os::Searchable &config, std::vector<rotorLimits_t> &rotorsLimits);
642 bool parseBehaviourFalgs(yarp::os::Searchable &config,
bool &useRawEncoderData,
bool &pwmIsLimited );
644 bool parseAxisInfo(yarp::os::Searchable &config,
int axisMap[], std::vector<axisInfo_t> &axisInfo);
648 bool parseGearboxValues(yarp::os::Searchable &config,
double gearbox_M2J[],
double gearbox_E2J[]);
650 bool parseImpedanceGroup(yarp::os::Searchable &config,std::vector<impedanceParameters_t> &impedance);
651 bool parseDeadzoneValue(yarp::os::Searchable &config,
double deadzone[],
bool *found);
652 bool parseKalmanFilterParams(yarp::os::Searchable &config, std::vector<kalmanFilterParams_t> &kalmanFilterParams);
virtual double convertRawToTempCelsius(const double temperature)=0
virtual double convertTempCelsiusToRaw(const double temperature)=0
virtual motor_temperatureSensorTypeEnum_t getType()=0
void setPidOutputType(eOmc_pidoutputtype_t type)
eOmc_jointset_configuration_t cfg
void setUseSpeedFeedbackFromMotors(bool flag)
int getNumberofJoints(void)
std::vector< int > joints
eOmc_jointset_configuration_t * getConfiguration(void)
void setCanDoTorqueControl(bool flag)
bool parseJointsetCfgGroup(yarp::os::Searchable &config, std::vector< JointsSet > &jsets, std::vector< int > &jointtoset)
bool parseJointsLimits(yarp::os::Searchable &config, std::vector< jointLimits_t > &jointsLimits)
bool parseAmpsToSensor(yarp::os::Searchable &config, double ampsToSensor[])
Parser(int numofjoints, std::string boardname)
bool parseMechanicalsFlags(yarp::os::Searchable &config, int useMotorSpeedFbk[])
bool parseMotioncontrolVersion(yarp::os::Searchable &config, int &version)
bool parseAxisInfo(yarp::os::Searchable &config, int axisMap[], std::vector< axisInfo_t > &axisInfo)
bool parseFocGroup(yarp::os::Searchable &config, focBasedSpecificInfo_t *foc_based_info, std::string groupName, std::vector< std::unique_ptr< eomc::ITemperatureSensor >> &temperatureSensorsVector)
bool parseCouplingInfo(yarp::os::Searchable &config, couplingInfo_t &couplingInfo)
bool parsePids(yarp::os::Searchable &config, PidInfo *ppids, TrqPidInfo *tpids, PidInfo *cpids, PidInfo *spids, bool lowLevPidisMandatory)
bool parseTemperatureLimits(yarp::os::Searchable &config, std::vector< temperatureLimits_t > &temperatureLimits)
bool parseDeadzoneValue(yarp::os::Searchable &config, double deadzone[], bool *found)
bool isVerboseEnabled(yarp::os::Searchable &config)
bool parseTimeoutsGroup(yarp::os::Searchable &config, std::vector< timeouts_t > &timeouts, int defaultVelocityTimeout)
bool parseCurrentLimits(yarp::os::Searchable &config, std::vector< motorCurrentLimits_t > &currLimits)
bool parseEncoderFactor(yarp::os::Searchable &config, double encoderFactor[])
bool parsefullscalePWM(yarp::os::Searchable &config, double dutycycleToPWM[])
bool parseRotorsLimits(yarp::os::Searchable &config, std::vector< rotorLimits_t > &rotorsLimits)
bool parseImpedanceGroup(yarp::os::Searchable &config, std::vector< impedanceParameters_t > &impedance)
bool parseKalmanFilterParams(yarp::os::Searchable &config, std::vector< kalmanFilterParams_t > &kalmanFilterParams)
bool parseGearboxValues(yarp::os::Searchable &config, double gearbox_M2J[], double gearbox_E2J[])
bool parseBehaviourFalgs(yarp::os::Searchable &config, bool &useRawEncoderData, bool &pwmIsLimited)
std::string usernamePidSelected
yarp::dev::PidFeedbackUnitsEnum fbk_PidUnits
eOmc_ctrl_out_type_t out_type
yarp::dev::PidOutputUnitsEnum out_PidUnits
yarp::dev::Pid getPID(int joint) override
Pid_Algorithm_simple(int nj, eOmc_ctrl_out_type_t ot)
yarp::dev::PidFeedbackUnitsEnum fbk_PidUnits
eOmc_ctrl_out_type_t getOutputType()
void setUnits(yarp::dev::PidFeedbackUnitsEnum fu, yarp::dev::PidOutputUnitsEnum ou)
eOmc_ctrl_out_type_t out_type
yarp::dev::PidOutputUnitsEnum out_PidUnits
virtual yarp::dev::Pid getPID(int joint)=0
virtual double convertRawToTempCelsius(const double temperature) override
virtual double convertTempCelsiusToRaw(const double temperature) override
~TemperatureSensorNONE()=default
virtual motor_temperatureSensorTypeEnum_t getType() override
TemperatureSensorPT1000()
virtual double convertTempCelsiusToRaw(const double temperature) override
virtual motor_temperatureSensorTypeEnum_t getType() override
TemperatureSensorPT1000 & operator=(const TemperatureSensorPT1000 &other)=default
~TemperatureSensorPT1000()=default
TemperatureSensorPT1000 & operator=(TemperatureSensorPT1000 &&other)=default
virtual double convertRawToTempCelsius(const double temperature) override
TemperatureSensorPT1000(const TemperatureSensorPT1000 &other)=default
TemperatureSensorPT1000(TemperatureSensorPT1000 &&other)=default
virtual double convertRawToTempCelsius(const double temperature) override
TemperatureSensorPT100(TemperatureSensorPT100 &&other)=default
TemperatureSensorPT100 & operator=(TemperatureSensorPT100 &&other)=default
virtual double convertTempCelsiusToRaw(const double temperature) override
TemperatureSensorPT100 & operator=(const TemperatureSensorPT100 &other)=default
TemperatureSensorPT100(const TemperatureSensorPT100 &other)=default
~TemperatureSensorPT100()=default
virtual motor_temperatureSensorTypeEnum_t getType() override
double viscousPos
motor torque constant
double ktau
back-emf compensation parameter
motor_temperatureSensorTypeEnum_t
@ motor_temperature_sensor_pt100
@ motor_temperature_sensor_pt1000
@ motor_temperature_sensor_none
Copyright (C) 2008 RobotCub Consortium.
std::vector< double > matrixM2J
std::vector< double > matrixE2J
std::vector< double > matrixJ2M
bool hasRotorEncoderIndex
double posHwMax
user joint limits, min
double posHwMin
hardaware joint limits, max
double velMax
hardaware joint limits, min
double posMax
user joint limits, max
std::array< float32_t, 3 > x0
std::array< float32_t, 3 > Q
double hardwareTemperatureLimit
double warningTemperatureLimit