00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*- 00002 00003 // -- BEGIN LICENSE BLOCK ---------------------------------------------- 00004 // This file is part of the SCHUNK Canopen Driver suite. 00005 // 00006 // This program is free software licensed under the LGPL 00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3). 00008 // You can find a copy of this license in LICENSE folder in the top 00009 // directory of the source code. 00010 // 00011 // © Copyright 2016 SCHUNK GmbH, Lauffen/Neckar Germany 00012 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany 00013 // -- END LICENSE BLOCK ------------------------------------------------ 00014 00015 //---------------------------------------------------------------------- 00023 //---------------------------------------------------------------------- 00024 00025 #ifndef DS402NODE_H 00026 #define DS402NODE_H 00027 00028 #include "DS301Node.h" 00029 00030 #include "ds402.h" 00031 00032 00033 namespace icl_hardware { 00034 namespace canopen_schunk { 00035 00043 class DS402Node : public DS301Node 00044 { 00045 public: 00047 typedef boost::shared_ptr<DS402Node> Ptr; 00049 typedef boost::shared_ptr<const DS402Node> ConstPtr; 00050 00051 enum eDefaultPDOMapping 00052 { 00053 PDO_MAPPING_CONTROLWORD_STATUSWORD, 00054 PDO_MAPPING_INTERPOLATED_POSITION_MODE, 00055 PDO_MAPPING_PROFILE_POSITION_MODE 00056 }; 00057 00058 DS402Node(const uint8_t node_id, const icl_hardware::canopen_schunk::CanDevPtr& can_device, HeartBeatMonitor::Ptr heartbeat_monitor); 00059 00060 virtual void setNMTState (const NMT::eNMT_State state, const NMT::eNMT_SubState sub_state); 00061 00073 virtual bool setTarget ( const float target ); 00074 00080 virtual void startPPMovement (); 00081 00082 00087 virtual void acceptPPTargets (); 00088 00095 virtual double getTargetFeedback(); 00096 00103 virtual void setDefaultPDOMapping (const eDefaultPDOMapping mapping); 00104 00108 virtual void home(); 00109 00118 virtual void initDS402State( const icl_hardware::canopen_schunk::ds402::eState& requested_state ); 00119 00120 00122 ds402::eModeOfOperation getModeOfOperation () const { return m_op_mode; } 00123 00124 00133 virtual bool setModeOfOperation (const ds402::eModeOfOperation op_mode); 00134 00143 virtual bool isModeSupported (const ds402::eModeOfOperation op_mode); 00144 00150 void printSupportedModesOfOperation (); 00151 00155 virtual void printStatus(); 00156 00160 virtual void quickStop(); 00161 00167 virtual void stopNode(); 00168 00173 virtual void initNode(); 00174 00179 virtual void querySupportedDeviceModes(); 00180 00186 virtual void setupProfilePositionMode (const ds402::ProfilePositionModeConfiguration& config); 00187 00188 00195 double getTransmissionFactor () const { return m_transmission_factor; } 00196 00203 void setTransmissionFactor (const double transmission_factor) { m_transmission_factor = transmission_factor; } 00204 00210 virtual void setupHomingMode (const ds402::HomingModeConfiguration& config); 00211 00217 virtual void setupProfileVelocityMode (const ds402::ProfileVelocityModeConfiguration& config); 00218 00224 virtual void setupProfileTorqueMode (const ds402::ProfileTorqueModeConfiguration& config); 00225 00226 00232 virtual bool resetFault (); 00233 00234 00235 size_t getMaximumNumberOfStateTransitions () const { return m_max_number_of_state_transitions; } 00236 void setMaximumNumberOfStateTransitions (const size_t max_number_of_state_transitions) { m_max_number_of_state_transitions = max_number_of_state_transitions; } 00237 00238 00244 virtual void configureInterpolationCycleTime (const uint8_t interpolation_cycle_time_ms = 8); 00245 00249 virtual void configureHomingMethod ( const int8_t homing_method ); 00250 00256 virtual void configureHomingSpeeds (const uint32_t low_speed, const uint32_t high_speed = 0); 00257 00265 virtual void enableNode (const ds402::eModeOfOperation operation_mode = ds402::MOO_RESERVED_0); 00266 00271 virtual void disableNode (); 00272 00277 virtual void openBrakes (); 00278 00283 virtual void closeBrakes (); 00284 00290 virtual bool isTargetReached(); 00291 00292 virtual ds402::Statusword getStatus(); 00293 00294 00295 protected: 00299 void configureMaxAcceleration (const uint32_t acceleration); 00303 void configureMaxDeceleration (const uint32_t deceleration); 00304 00308 void configureProfileVelocity (const uint32_t velocity); 00312 void configureProfileAcceleration (const uint32_t acceleration); 00316 void configureProfileDeceleration (const uint32_t deceleration); 00320 void configureQuickStopDeceleration (const uint32_t deceleration); 00324 void configureMotionProfileType (const int16_t motion_type); 00325 00329 void configureHomingAcceleration (const uint32_t acceleration); 00330 00334 void configureSensorSelectionCode ( const int16_t sensor_selection_code ); 00335 00339 void configureTorqueSlope ( const uint32_t torque_slope ); 00343 void configureTorqueProfileType ( const int16_t torque_profile_type ); 00344 00355 virtual void configureInterpolationData (const uint8_t buffer_organization = 0, 00356 const int16_t interpolation_type = 0, 00357 const uint8_t size_of_data_record = 4); 00358 00366 std::string operationModeSpecificStatus ( const ds402::Statusword& statusword ); 00367 00374 void doDS402StateTransition (const ds402::eStateTransission transition); 00375 00380 virtual void onStatusWordUpdate (); 00381 00383 ds402::SupportedDriveModes m_supported_modes; 00384 00386 ds402::eModeOfOperation m_op_mode; 00387 00388 ds402::eState m_current_ds402_state; 00389 ds402::eState m_expected_ds402_state; 00390 00391 ds402::ProfilePositionModeConfiguration m_ppm_config; 00392 00396 uint8_t m_interpolation_cycle_time_ms; 00397 size_t m_max_number_of_state_transitions; 00398 int8_t m_homing_method; 00399 double m_transmission_factor; 00400 }; 00401 00402 00403 }}// end of NS 00404 #endif // DS402NODE_H