CANOpen_driver.h
Go to the documentation of this file.
00001 /****************************************************************
00002  *
00003  * Copyright (c) 2012
00004  *
00005  * Fraunhofer Institute for Manufacturing Engineering   
00006  * and Automation (IPA)
00007  *
00008  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00009  *
00010  * Project name: CIN-Reha
00011  * ROS stack name: cob_drivers
00012  * ROS package name: cob_generic_can
00013  * Description:
00014  *                                                              
00015  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00016  *                      
00017  * Author: 
00018  * Supervised by:
00019  *
00020  * Date of creation: Jan 2012
00021  *
00022  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00023  *
00024  * Redistribution and use in source and binary forms, with or without
00025  * modification, are permitted provided that the following conditions are met:
00026  *
00027  *     * Redistributions of source code must retain the above copyright
00028  *       notice, this list of conditions and the following disclaimer.
00029  *     * Redistributions in binary form must reproduce the above copyright
00030  *       notice, this list of conditions and the following disclaimer in the
00031  *       documentation and/or other materials provided with the distribution.
00032  *     * Neither the name of the Fraunhofer Institute for Manufacturing 
00033  *       Engineering and Automation (IPA) nor the names of its
00034  *       contributors may be used to endorse or promote products derived from
00035  *       this software without specific prior written permission.
00036  *
00037  * This program is free software: you can redistribute it and/or modify
00038  * it under the terms of the GNU Lesser General Public License LGPL as 
00039  * published by the Free Software Foundation, either version 3 of the 
00040  * License, or (at your option) any later version.
00041  * 
00042  * This program is distributed in the hope that it will be useful,
00043  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00044  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00045  * GNU Lesser General Public License LGPL for more details.
00046  * 
00047  * You should have received a copy of the GNU Lesser General Public 
00048  * License LGPL along with this program. 
00049  * If not, see <http://www.gnu.org/licenses/>.
00050  *
00051  ****************************************************************/
00052 
00053 #ifndef CANOPENMaster_INCLUDEDEF_H
00054 #define CANOPENMaster_INCLUDEDEF_H
00055 //-----------------------------------------------
00056 #include <ros/ros.h>
00057 #include <cob_generic_can/CanItf.h>
00058 #include <libpcan/libpcan.h>
00059 #include <cob_utilities/IniFile.h>
00060 #include <cob_generic_can/CanPeakSysUSB.h>
00061 
00062 // Object definitions
00063 #include <CANOpenCiA401_Objects.h>
00064 //-----------------------------------------------
00065 
00066 class CANOpenMaster
00067 {
00068 public:
00069         // --------------- Interface
00070         CANOpenMaster();
00071         ~CANOpenMaster();
00072 
00073         int Init();
00074         int Homing();
00075         int GetNodeState();
00076         void PrintMotorStatus();
00077         int SetSpeed(int); 
00078         int GetSpeed();
00079         int GetDIn();
00080         int Recover(); 
00081         void SendSYNC();
00082         int WritePDO(int ,int);
00083         int WritePDO(CanMsg);
00084 
00085         // --------------- Types
00086 public: 
00087         int m_CanBaseAddress;
00088         
00089         int TxSDO;
00090         int RxSDO;
00091         int TxPDO1;
00092         int RxPDO1;
00093         int TxPDO2;
00094         int RxPDO2;
00095         int TxPDO3;
00096         int RxPDO3;
00097         int TxPDO4;
00098         int RxPDO4;
00099         int SYNC; 
00100         int EMCY; 
00101         int NMT; 
00102         int HEARTBEAT; 
00103         int NodeState;
00104         int ControlerState; 
00105         
00106         // motorcommands
00107         short SWITCH_ON; 
00108         short SHUTDOWN; 
00109         short DISABLE_VOLTAGE; 
00110         short QUICKSTOP;
00111         short DISABLE_OPERATION;
00112         short ENABLE_OPERATION; 
00113         short FAULT_RESET;  
00114         
00115         // motorstates
00116         short Not_Ready_To_Switch_On;
00117         short Switch_On_Disabled;
00118         short Ready_To_Switch_On; 
00119         short Switched_On; 
00120         short Operation_Enable; 
00121         short Fault; 
00122         short Fault_Reaction_Active;
00123         short Quick_Stop_Active;        
00124         
00125         unsigned char CANDownloadHeader;
00126         
00127         // statusvariables for state mashine
00128         bool IS_HOMED;
00129         bool FAULT_WAS_ACTIVE;
00130         
00131 private:
00132         int Lin_Axis_max_speed;
00133 
00134         CanItf* can_itf;
00135         CANOpenCiA401ObjDirectory* CANObj;      
00136         // --------------- Methodes
00137         
00138         // basic CANOpen functions
00139         void SYNCLoop(void*);
00140         bool CANError(CanMsg*);
00141         bool NodeStateError(CanMsg*);
00142         unsigned int ReadObject(CANOpenCiA401ObjDirectory::CANOpenObj*);
00143         int WriteObject(CANOpenCiA401ObjDirectory::CANOpenObj*, int);
00144         void SendNMT(unsigned char, unsigned char);
00145         int WaitForHeartbeat();
00146         int EvaluateControlerState();
00147         
00148 };
00149 //-----------------------------------------------
00150 
00151 #endif
00152 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Defines


CANOpen_driver
Author(s): Tim Fröhlich
autogenerated on Mon Jan 14 2013 16:55:42