PowerCubeCtrl.h
Go to the documentation of this file.
00001 
00060 #ifndef __POWER_CUBE_CTRL_H_
00061 #define __POWER_CUBE_CTRL_H_
00062 
00063 // standard includes
00064 #include <iostream>
00065 #include <sstream>
00066 #include <string>
00067 #include <deque>
00068 #include <pthread.h> 
00069 
00070 // own includes
00071 #include <schunk_libm5api/m5apiw32.h>
00072 #include <schunk_powercube_chain/moveCommand.h>
00073 #include <schunk_powercube_chain/PowerCubeCtrlParams.h>
00074 
00075 class PowerCubeCtrl
00076 {
00077 
00078 public:
00079 
00081         PowerCubeCtrl(PowerCubeCtrlParams * params);
00082 
00084         ~PowerCubeCtrl();
00085 
00086         typedef enum
00087         {
00088                 PC_CTRL_OK = 0, PC_CTRL_NOT_HOMED = -1, PC_CTRL_ERR = -2, PC_CTRL_POW_VOLT_ERR = -3
00089         } PC_CTRL_STATUS;
00090 
00092         // Functions for initialization and close: //
00094 
00098         bool Init(PowerCubeCtrlParams * params);
00099 
00103         bool isInitialized() const
00104         {
00105                 return m_Initialized;
00106         }
00107 
00111         std::string getErrorMessage() const
00112         {
00113                 return m_ErrorMessage;
00114         }
00115         
00119         PC_CTRL_STATUS getPC_Status() const
00120         {
00121                 return m_pc_status;
00122         }
00123 
00127         bool Close();
00128 
00130         // Functions for control: //
00132 
00136         bool MoveJointSpaceSync(const std::vector<double>& angles);
00137 
00141         bool MoveVel(const std::vector<double>& velocities);
00142 
00146         bool Stop();
00147 
00151         bool Recover();
00152 
00154         // functions to set parameters: //
00156 
00162         bool setMaxVelocity(double velocity);
00163         bool setMaxVelocity(const std::vector<double>& velocities);
00164 
00170         bool setMaxAcceleration(double acceleration);
00171         bool setMaxAcceleration(const std::vector<double>& accelerations);
00172 
00179         bool setHorizon(double horizon);
00180 
00187         double getHorizon();
00188 
00194         bool setSyncMotion();
00195 
00201         bool setASyncMotion();
00202 
00204         // Functions for getting state and monitoring: //
00206 
00210         bool updateStates();
00211 
00215         bool getStatus(PC_CTRL_STATUS& status, std::vector<std::string>& errorMessages);
00216         
00220         std::vector<unsigned long> getVersion();
00221 
00227         bool statusMoving();
00228 
00232         std::vector<double> getPositions();
00233 
00237         std::vector<double> getVelocities();
00238 
00242         std::vector<double> getAccelerations();
00243 
00249         bool doHoming();
00250 
00251         void updateVelocities(std::vector<double> pos_temp, double delta_t);
00252 
00253 protected:
00254         pthread_mutex_t m_mutex;
00255 
00256         int m_DeviceHandle;
00257         bool m_Initialized;
00258         bool m_CANDeviceOpened;
00259 
00260         PowerCubeCtrlParams* m_params;
00261         PC_CTRL_STATUS m_pc_status;
00262 
00263         std::vector<unsigned long> m_status;
00264         std::vector<std::string> m_ModuleTypes;
00265         std::vector<unsigned long> m_version;
00266         std::vector<unsigned char> m_dios;
00267         std::vector<double> m_positions;
00268         std::deque< std::vector<double> > m_cached_pos;
00269         std::vector<double> m_velocities;
00270         std::vector<double> m_accelerations;
00271 
00272         double m_horizon;
00273 
00274         ros::Time m_last_time_pub;
00275 
00276         std::string m_ErrorMessage;
00277 
00278 };
00279 
00280 #endif


schunk_powercube_chain
Author(s): Florian Weisshardt
autogenerated on Thu Aug 27 2015 15:06:58