CanDriveHarmonica.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 #ifndef CANDRIVEHARMONICA_INCLUDEDEF_H
19 #define CANDRIVEHARMONICA_INCLUDEDEF_H
20 
21 //-----------------------------------------------
24 
27 //-----------------------------------------------
28 
34 {
35 public:
36  // ------------------------- Types
40  struct ParamType
41  {
44  double dCanTimeout;
45  };
46 
51  {
56  };
57 
62  {
63  int iTxPDO1;
64  int iTxPDO2;
65  int iRxPDO2;
66  int iTxSDO;
67  int iRxSDO;
68  };
69 
70  // ------------------------- Interface
74  void setCanItf(CanItf* pCanItf){ m_pCanCtrl = pCanItf; }
75 
80  bool init();
81 
87  bool isInitialized() { return m_bIsInitialized; }
88 
93  bool start();
94 
99  bool stop();
104  bool reset();
105 
109  bool shutdown();
110 
117  bool disableBrake(bool bDisabled);
118 
122  bool initHoming();
123 
127  bool execHoming();
128 
133  bool endHoming();
134 
138  double getTimeToLastMsg();
139 
144  bool getStatusLimitSwitch();
145 
153  bool startWatchdog(bool bStarted);
154 
160  bool evalReceivedMsg(CanMsg& msg);
161 
166  bool evalReceivedMsg() { return true; }
167 
168 
173  void setGearPosVelRadS(double dPosRad, double dVelRadS);
174 
179  void setGearVelRadS(double dVelEncRadS);
180 
184  bool setTypeMotion(int iType);
185 
189  void getGearPosVelRadS(double* pdAngleGearRad, double* pdVelGearRadS);
190 
195  void getGearDeltaPosVelRadS(double* pdDeltaAngleGearRad, double* pdVelGearRadS);
196 
200  void getGearPosRad(double* pdPosGearRad);
201 
205  void setDriveParam(DriveParam driveParam) { m_DriveParam = driveParam; }
206 
210  bool isError();
211 
215  unsigned int getError() { return 0; }
216 
217  // ------ Dummy implementations for completing the interface
218 
222  void requestPosVel();
223 
228  void requestStatus();
229 
233  void getStatus(int* piStatus, int* piTempCel) { *piStatus = 0; *piTempCel = 0; }
234 
235 
236  // ------------------------- Interface: Harmonica specific
241 
250  void getData(double* pdPosGearRad, double* pdVelGearRadS,
251  int* piTorqueCtrl, int* piStatusCtrl);
252 
261  void setCanOpenParam( int iTxPDO1, int iTxPDO2, int iRxPDO2, int iTxSDO, int iRxSDO);
262 
266  void IntprtSetInt(int iDataLen, char cCmdChar1, char cCmdChar2, int iIndex, int iData);
267 
271  void sendHeartbeat();
272 
273 
274  bool setEMStop() {
275  std::cout << "The function setEMStop() is not implemented!!!" << std::endl;
276  return false;
277  }
278 
279  bool resetEMStop() {
280  std::cout << "The function resetEMStop() is not implemented!!!" << std::endl;
281  return false;
282  }
283 
288  void setMotorTorque(double dTorqueNm);
289 
298  void requestMotorTorque();
299 
304  void getMotorTorque(double* dTorqueNm);
305 
316  int setRecorder(int iFlag, int iParam = 0, std::string sParam = "/home/MyLog_");
317 
318 
319  //--------------------------
320  //CanDriveHarmonica specific functions (not from CanDriveItf)
321  //--------------------------
325  void IntprtSetFloat(int iDataLen, char cCmdChar1, char cCmdChar2, int iIndex, float fData);
326 
330  void sendSDOUpload(int iObjIndex, int iObjSub);
331 
335  void sendSDOAbort(int iObjIndex, int iObjSubIndex, unsigned int iErrorCode);
336 
340  void sendSDODownload(int iObjIndex, int iObjSub, int iData);
341 
345  void evalSDO(CanMsg& CMsg, int* pIndex, int* pSubindex);
346 
350  int getSDODataInt32(CanMsg& CMsg);
351 
352 
353 protected:
354  // ------------------------- Parameters
359 
360  // ------------------------- Variables
363 
365 
369 
376 
380 
383 
384  double m_dOldPos;
385 
386  std::string m_sErrorMessage;
387 
390 
392 
394 
396 
398 
400 
401  double m_dMotorCurr;
402 
404 
406 
407 
408  // ------------------------- Member functions
409  double estimVel(double dPos);
410 
411  bool evalStatusRegister(int iStatus);
412  void evalMotorFailure(int iFailure);
413 
416 
417  bool isBitSet(int iVal, int iNrBit)
418  {
419  if( (iVal & (1 << iNrBit)) == 0)
420  return false;
421  else
422  return true;
423  }
424 
429  void sendSDOUploadSegmentConfirmation(bool toggleBit);
430 
439  int receivedSDODataSegment(CanMsg& msg);
440 
447 
452  void receivedSDOTransferAbort(unsigned int iErrorCode);
453 
461 
462 };
463 //-----------------------------------------------
464 #endif
std::string m_sErrorMessage
void setDriveParam(DriveParam driveParam)
void receivedSDOTransferAbort(unsigned int iErrorCode)
bool evalStatusRegister(int iStatus)
void evalSDO(CanMsg &CMsg, int *pIndex, int *pSubindex)
void getMotorTorque(double *dTorqueNm)
double estimVel(double dPos)
bool isBitSet(int iVal, int iNrBit)
void evalMotorFailure(int iFailure)
ElmoRecorder * ElmoRec
int setRecorder(int iFlag, int iParam=0, std::string sParam="/home/MyLog_")
void getStatus(int *piStatus, int *piTempCel)
bool disableBrake(bool bDisabled)
void sendSDODownload(int iObjIndex, int iObjSub, int iData)
void setGearVelRadS(double dVelEncRadS)
void setCanOpenParam(int iTxPDO1, int iTxPDO2, int iRxPDO2, int iTxSDO, int iRxSDO)
void getGearPosVelRadS(double *pdAngleGearRad, double *pdVelGearRadS)
void setGearPosVelRadS(double dPosRad, double dVelRadS)
void getGearDeltaPosVelRadS(double *pdDeltaAngleGearRad, double *pdVelGearRadS)
void IntprtSetFloat(int iDataLen, char cCmdChar1, char cCmdChar2, int iIndex, float fData)
ParamCanOpenType m_ParamCanOpen
int receivedSDODataSegment(CanMsg &msg)
void sendSDOUploadSegmentConfirmation(bool toggleBit)
void IntprtSetInt(int iDataLen, char cCmdChar1, char cCmdChar2, int iIndex, int iData)
int receivedSDOSegmentedInitiation(CanMsg &msg)
void sendSDOUpload(int iObjIndex, int iObjSub)
void sendSDOAbort(int iObjIndex, int iObjSubIndex, unsigned int iErrorCode)
void getData(double *pdPosGearRad, double *pdVelGearRadS, int *piTorqueCtrl, int *piStatusCtrl)
int getSDODataInt32(CanMsg &CMsg)
void getGearPosRad(double *pdPosGearRad)
TimeStamp m_FailureStartTime
void setCanItf(CanItf *pCanItf)
bool setTypeMotion(int iType)
bool startWatchdog(bool bStarted)
unsigned int getError()
void setMotorTorque(double dTorqueNm)


cob_canopen_motor
Author(s): Christian Connette
autogenerated on Wed Apr 7 2021 02:11:53