42 if(m_iNumMotors < 2 || m_iNumMotors > 8) {
111 if(m_iNumMotors >= 1)
120 if(m_iNumMotors >= 2)
130 if(m_iNumMotors >= 3)
139 if(m_iNumMotors >= 4)
149 if(m_iNumMotors >= 5)
158 if(m_iNumMotors >= 6)
168 if(m_iNumMotors >= 7)
177 if(m_iNumMotors == 8)
196 for(
unsigned int i = 0; i <
m_vpMotor.size(); i++)
211 int iMaxMessages = 0;
222 std::string strTypeDrive;
223 std::string strTypeSteer;
248 std::cout <<
"Can configuration of the platform:" << std::endl;
257 std::cout <<
"Uses CAN-Peak-Systems dongle" << std::endl;
259 else if (iTypeCan == 1)
264 std::cout <<
"Uses CAN-Peak-USB" << std::endl;
266 else if (iTypeCan == 2)
271 std::cout <<
"Uses CAN-ESD-card" << std::endl;
680 std::cout <<
"node Wheel1DriveMotor available = 0" << std::endl;
685 std::cout <<
"Wheel1DriveMotor available = type version 2" << std::endl;
691 m_vpMotor[0]->setDriveParam(DriveParamW1DriveMotor);
702 std::cout <<
"node Wheel1SteerMotor available = 0" << std::endl;
707 std::cout <<
"Wheel1SteerMotor available = type version 2" << std::endl;
713 m_vpMotor[1]->setDriveParam(DriveParamW1SteerMotor);
726 std::cout <<
"node Wheel2DriveMotor available = 0" << std::endl;
731 std::cout <<
"Wheel2DriveMotor available = type version 2" << std::endl;
737 m_vpMotor[2]->setDriveParam(DriveParamW2DriveMotor);
748 std::cout <<
"node Wheel2SteerMotor available = 0" << std::endl;
753 std::cout <<
"Wheel2SteerMotor available = type version 2" << std::endl;
759 m_vpMotor[3]->setDriveParam(DriveParamW2SteerMotor);
772 std::cout <<
"node Wheel3DriveMotor available = 0" << std::endl;
777 std::cout <<
"Wheel3DriveMotor available = type version 2" << std::endl;
783 m_vpMotor[4]->setDriveParam(DriveParamW3DriveMotor);
794 std::cout <<
"node Wheel3SteerMotor available = 0" << std::endl;
799 std::cout <<
"Wheel3SteerMotor available = type version 2" << std::endl;
805 m_vpMotor[5]->setDriveParam(DriveParamW3SteerMotor);
818 std::cout <<
"node Wheel4DriveMotor available = 0" << std::endl;
823 std::cout <<
"Wheel4DriveMotor available = type version 2" << std::endl;
829 m_vpMotor[6]->setDriveParam(DriveParamW4DriveMotor);
840 std::cout <<
"node Wheel4SteerMotor available = 0" << std::endl;
845 std::cout <<
"Wheel4SteerMotor available = type version 2" << std::endl;
851 m_vpMotor[7]->setDriveParam(DriveParamW4SteerMotor);
874 for (
unsigned int i = 0; i <
m_vpMotor.size(); i++)
882 std::cout <<
"evalCanBuffer(): Received CAN_Message with unknown identifier " <<
m_CanMsgRec.
m_iID << std::endl;
899 std::vector<bool> vbRetDriveMotor;
900 std::vector<bool> vbRetSteerMotor;
901 std::vector<CanDriveItf*> vpDriveMotor;
902 std::vector<CanDriveItf*> vpSteerMotor;
923 std::vector<double> vdFactorVel;
929 std::cout <<
"StartCanOpen" << std::endl;
936 std::cout <<
"Initialization of Watchdogs" << std::endl;
968 std::cout <<
"Initialization of Watchdogs done" << std::endl;
980 vbRetDriveMotor[i] = vpDriveMotor[i]->init();
981 vbRetSteerMotor[i] = vpSteerMotor[i]->init();
983 vbRetDriveMotor[i] = vbRetDriveMotor[i] && vpDriveMotor[i]->start();
984 vbRetSteerMotor[i] = vbRetSteerMotor[i] && vpSteerMotor[i]->start();
987 if (vbRetDriveMotor[i] && vbRetSteerMotor[i])
988 std::cout <<
"Initialization of Wheel "<< (i+1) <<
" OK" << std::endl;
989 else if (!vbRetDriveMotor[i] && vbRetSteerMotor[i])
990 std::cout <<
"Initialization of Wheel "<< (i+1) <<
" ERROR while initializing DRIVE-Motor" << std::endl;
991 else if (vbRetDriveMotor[i] && !vbRetSteerMotor[i])
992 std::cout <<
"Initialization of Wheel "<< (i+1) <<
" ERROR while initializing STEER-Motor" << std::endl;
994 std::cout <<
"Initialization of Wheel "<< (i+1) <<
" ERROR while initializing STEER- and DRIVE-Motor" << std::endl;
996 vpDriveMotor[i]->setGearVelRadS(0);
997 vpSteerMotor[i]->setGearVelRadS(0);
1006 if((vbRetDriveMotor[i] && vbRetSteerMotor[i]) ==
false)
1012 if(m_iNumDrives >= 1)
1014 if(m_iNumDrives >= 2)
1016 if(m_iNumDrives >= 3)
1018 if(m_iNumDrives == 4)
1023 vpSteerMotor[i]->initHoming();
1039 while(bRet ==
true);
1043 vpSteerMotor[i]->IntprtSetInt(8,
'H',
'M', 1, 1);
1046 bool bAllDone, bTimeOut=
false;
1052 vpSteerMotor[i]->IntprtSetInt(4,
'H',
'M', 1, 0);
1061 if (vpSteerMotor[i]->getStatusLimitSwitch())
1063 vpSteerMotor[i]->setGearVelRadS(0);
1064 vpDriveMotor[i]->setGearVelRadS(0);
1066 bAllDone = bAllDone && vpSteerMotor[i]->getStatusLimitSwitch();
1076 while(!bAllDone && !bTimeOut);
1083 vpSteerMotor[i]->setGearVelRadS(0);
1084 vpDriveMotor[i]->setGearVelRadS(0);
1086 std::cout <<
"Error while Homing: Timeout while waiting for homing signal" << std::endl;
1097 if (bTimeOut ==
false)
1105 double dCurrentPosRad;
1106 vpSteerMotor[i]->getGearPosRad(&dCurrentPosRad);
1108 double dDeltaPhi = 0.0 - dCurrentPosRad;
1110 if (fabs(dDeltaPhi) < 0.03)
1118 double dVelCmd = m_d0 * dDeltaPhi;
1120 vpSteerMotor[i]->setGearVelRadS(dVelCmd);
1121 vpDriveMotor[i]->setGearVelRadS(dVelCmd*vdFactorVel[i]);
1129 std::cout <<
"Wheels homed" << std::endl;
1132 vpSteerMotor[i]->setGearVelRadS(0);
1133 vpDriveMotor[i]->setGearVelRadS(0);
1160 if((vbRetDriveMotor[i] && vbRetSteerMotor[i]) ==
false)
1171 bool bRetMotor =
true;
1174 for(
unsigned int i = 0; i <
m_vpMotor.size(); i++)
1177 if (bRetMotor ==
true)
1183 std::cout <<
"Resetting of Motor " << i <<
" failed" << std::endl;
1195 for(
unsigned int i = 0; i <
m_vpMotor.size(); i++)
1207 bool bErrMotor =
false;
1208 std::vector<bool> vbErrMotor;
1212 for(
unsigned int i = 0; i <
m_vpMotor.size(); i++)
1214 vbErrMotor[i] =
m_vpMotor[i]->isError();
1218 std::cout <<
"Motor " << i <<
" error" << std::endl;
1221 bErrMotor |= vbErrMotor[i];
1225 if(bErrMotor ==
false)
1234 double dWatchTime = 0;
1236 for(
unsigned int i = 0; i <
m_vpMotor.size(); i++)
1238 dWatchTime =
m_vpMotor[i]->getTimeToLastMsg();
1246 std::cout <<
"timeout CAN motor " << i << std::endl;
1261 for(
unsigned int i = 0; i <
m_vpMotor.size(); i++)
1263 bRet =
m_vpMotor[i]->startWatchdog(bStarted);
1276 msg.
set(1,0,0,0,0,0,0,0);
1301 for(
unsigned int i = 0; i <
m_vpMotor.size(); i++)
1306 m_vpMotor[i]->setGearVelRadS(dVelGearRadS);
1320 for(
unsigned int i = 0; i <
m_vpMotor.size(); i++)
1339 for(
unsigned int i = 0; i <
m_vpMotor.size(); i++)
1352 *pdAngleGearRad = 0;
1355 for(
unsigned int i = 0; i <
m_vpMotor.size(); i++)
1360 m_vpMotor[i]->getGearPosVelRadS(pdAngleGearRad, pdVelGearRadS);
1369 double* pdVelGearRadS)
1373 *pdAngleGearRad = 0;
1376 for(
unsigned int i = 0; i <
m_vpMotor.size(); i++)
1381 m_vpMotor[i]->getGearDeltaPosVelRadS(pdAngleGearRad, pdVelGearRadS);
1395 for(
unsigned int i = 0; i <
m_vpMotor.size(); i++)
1400 m_vpMotor[i]->getStatus(piStatus, piTempCel);
1410 for(
unsigned int i = 0; i <
m_vpMotor.size(); i++)
1424 for(
unsigned int i = 0; i <
m_vpMotor.size(); i++)
1429 m_vpMotor[i]->getMotorTorque(pdTorqueNm);
1439 for(
unsigned int i = 0; i <
m_vpMotor.size(); i++)
1444 m_vpMotor[i]->setMotorTorque(dTorqueNm);
1462 for(
unsigned int i = 0; i <
m_vpMotor.size(); i++) {
1468 for(
unsigned int i = 0; i <
m_vpMotor.size(); i++) {
1469 if((tempRet =
m_vpMotor[i]->setRecorder(1, iParam, sString)) > bRet) {
1476 for(
unsigned int i = 0; i <
m_vpMotor.size(); i++) {
1482 for(
unsigned int i = 0; i <
m_vpMotor.size(); i++) {
1483 bRet +=
m_vpMotor[i]->setRecorder(2, 0);
std::string sIniDirectory
GearMotorParamType m_GearMotDrive3
int setVelGearRadS(int iCanIdent, double dVelGearRadS)
void sendNetStartCanOpen()
void setParam(int iDriveIdent, int iEncIncrPerRevMot, double dVelMeasFrqHz, double dBeltRatio, double dGearRatio, int iSign, double dVelMaxEncIncrS, double dAccIncrS2, double dDecIncrS2)
double dWheel3SteerDriveCoupling
GearMotorParamType m_GearMotDrive1
CanOpenIDType m_CanOpenIDParam
void requestMotorTorque()
GearMotorParamType m_GearMotSteer1
int requestMotPosVel(int iCanIdent)
int GetKeyBool(const char *pSect, const char *pKey, bool *pValue, bool bWarnIfNotfound=true)
std::vector< CanDriveItf * > m_vpMotor
int getGearDeltaPosVelRadS(int iCanIdent, double *pdDeltaAngleGearRad, double *pdVelGearRadS)
void getMotorTorque(int iCanIdent, double *pdTorqueNm)
int GetKeyInt(const char *pSect, const char *pKey, int *pValue, bool bWarnIfNotfound=true)
bool startWatchdog(bool bStarted)
GearMotorParamType m_GearMotDrive4
int getGearPosVelRadS(int iCanIdent, double *pdAngleGearRad, double *pdVelGearRadS)
int GetKeyDouble(const char *pSect, const char *pKey, double *pValue, bool bWarnIfNotfound=true)
void getStatus(int iCanIdent, int *piStatus, int *piTempCel)
bool lock(unsigned int uiTimeOut=INFINITE)
double dWheel1SteerDriveCoupling
double dWheel2SteerDriveCoupling
double dWheel4SteerDriveCoupling
GearMotorParamType m_GearMotSteer4
GearMotorParamType m_GearMotSteer3
GearMotorParamType m_GearMotDrive2
CanCtrlPltfCOb3(std::string iniDirectory)
int SetFileName(std::string fileName, std::string strIniFileUsedBy="", bool bCreate=false)
std::vector< int > m_viMotorID
virtual bool receiveMsg(CanMsg *pCMsg)=0
void setMotorTorque(int iCanIdent, double dTorqueNm)
GearMotorParamType m_GearMotSteer2
void set(BYTE Data0=0, BYTE Data1=0, BYTE Data2=0, BYTE Data3=0, BYTE Data4=0, BYTE Data5=0, BYTE Data6=0, BYTE Data7=0)
void requestDriveStatus()
int ElmoRecordings(int iFlag, int iParam, std::string sString)
int iDistSteerAxisToDriveWheelMM
virtual bool transmitMsg(CanMsg CMsg, bool bBlocking=true)=0