#include <wg0x.h>
Public Member Functions | |
virtual void | collectDiagnostics (EthercatCom *com) |
void | construct (EtherCAT_SlaveHandler *sh, int &start_address) |
< Construct EtherCAT device More... | |
void | diagnostics (diagnostic_updater::DiagnosticStatusWrapper &d, unsigned char *) |
For EtherCAT device that only publish one EtherCAT Status message. If sub-class implements multiDiagnostics() then diagnostics() is not used. More... | |
virtual int | initialize (pr2_hardware_interface::HardwareInterface *, bool allow_unprogrammed=true) |
void | packCommand (unsigned char *buffer, bool halt, bool reset) |
bool | program (EthercatCom *com, const WG0XActuatorInfo &actutor_info) |
Programs acutator and heating parameters into device EEPROM. More... | |
bool | program (EthercatCom *com, const MotorHeatingModelParametersEepromConfig &heating_config) |
Programs motor heating parameters into device EEPROM. More... | |
bool | publishTrace (const string &reason, unsigned level, unsigned delay) |
Asks device to publish (motor) trace. Only works for devices that support it. More... | |
bool | readActuatorInfoFromEeprom (EthercatCom *com, WG0XActuatorInfo &actuator_info) |
Reads actuator info from eeprom. More... | |
bool | readMotorHeatingModelParametersFromEeprom (EthercatCom *com, MotorHeatingModelParametersEepromConfig &config) |
Reads actuator info from eeprom. More... | |
bool | unpackState (unsigned char *this_buffer, unsigned char *prev_buffer) |
WG0X () | |
virtual | ~WG0X () |
Public Member Functions inherited from EthercatDevice | |
virtual void | construct (ros::NodeHandle &nh) |
EthercatDevice () | |
void | ethercatDiagnostics (diagnostic_updater::DiagnosticStatusWrapper &d, unsigned numPorts) |
Adds diagnostic information for EtherCAT ports. More... | |
virtual void | multiDiagnostics (vector< diagnostic_msgs::DiagnosticStatus > &vec, unsigned char *buffer) |
For EtherCAT devices that publish more than one EtherCAT Status message. If sub-class implements multiDiagnostics() then diagnostics() is not used. More... | |
int | readData (EthercatCom *com, EC_UINT address, void *buffer, EC_UINT length, AddrMode addrMode) |
int | readWriteData (EthercatCom *com, EC_UINT address, void *buffer, EC_UINT length, AddrMode addrMode) |
int | writeData (EthercatCom *com, EC_UINT address, void const *buffer, EC_UINT length, AddrMode addrMode) |
virtual | ~EthercatDevice () |
Static Public Member Functions | |
static double | calcEncoderVelocity (int32_t new_position, uint32_t new_timestamp, int32_t old_position, uint32_t old_timestamp) |
static double | convertRawTemperature (int16_t raw_temp) |
Converts raw 16bit temperature value returned by device into value in degress Celcius. More... | |
static int32_t | positionDiff (int32_t new_position, int32_t old_position) |
static ros::Duration | timediffToDuration (int32_t timediff_usec) |
static int32_t | timestampDiff (uint32_t new_timestamp, uint32_t old_timestamp) |
Static Public Member Functions inherited from EthercatDevice | |
static int | readData (EthercatCom *com, EtherCAT_SlaveHandler *sh, EC_UINT address, void *buffer, EC_UINT length, AddrMode addrMode) |
Read data from device ESC. More... | |
static int | readWriteData (EthercatCom *com, EtherCAT_SlaveHandler *sh, EC_UINT address, void *buffer, EC_UINT length, AddrMode addrMode) |
Read then write data to ESC. More... | |
static int | writeData (EthercatCom *com, EtherCAT_SlaveHandler *sh, EC_UINT address, void const *buffer, EC_UINT length, AddrMode addrMode) |
Write data to device ESC. More... | |
Protected Types | |
enum | { MODE_OFF = 0x00, MODE_ENABLE = (1 << 0), MODE_CURRENT = (1 << 1), MODE_SAFETY_RESET = (1 << 4), MODE_SAFETY_LOCKOUT = (1 << 5), MODE_UNDERVOLTAGE = (1 << 6), MODE_RESET = (1 << 7) } |
enum | { WG05_PRODUCT_CODE = 6805005, WG06_PRODUCT_CODE = 6805006, WG021_PRODUCT_CODE = 6805021 } |
enum | { NO_CALIBRATION =0, CONTROLLER_CALIBRATION =1, SAVED_CALIBRATION =2 } |
enum | { LIMIT_SENSOR_0_STATE = (1 << 0), LIMIT_SENSOR_1_STATE = (1 << 1), LIMIT_ON_TO_OFF = (1 << 2), LIMIT_OFF_TO_ON = (1 << 3) } |
enum | { SAFETY_DISABLED = (1 << 0), SAFETY_UNDERVOLTAGE = (1 << 1), SAFETY_OVER_CURRENT = (1 << 2), SAFETY_BOARD_OVER_TEMP = (1 << 3), SAFETY_HBRIDGE_OVER_TEMP = (1 << 4), SAFETY_OPERATIONAL = (1 << 5), SAFETY_WATCHDOG = (1 << 6) } |
enum | AppRamStatus { APP_RAM_PRESENT =1, APP_RAM_MISSING =2, APP_RAM_NOT_APPLICABLE =3 } |
Different possible states for application ram on device. More... | |
Protected Member Functions | |
void | clearErrorFlags (void) |
bool | initializeMotorHeatingModel (bool allow_unprogrammed) |
bool | initializeMotorModel (pr2_hardware_interface::HardwareInterface *hw, const string &device_description, double max_pwm_ratio, double board_resistance, bool poor_measured_motor_voltage) |
Allocates and initialized motor trace for WG0X devices than use it (WG006, WG005) More... | |
bool | lockWG0XDiagnostics () |
void | publishGeneralDiagnostics (diagnostic_updater::DiagnosticStatusWrapper &d) |
void | publishMailboxDiagnostics (diagnostic_updater::DiagnosticStatusWrapper &d) |
bool | readAppRam (EthercatCom *com, double &zero_offset) |
int | readMailbox (EthercatCom *com, unsigned address, void *data, unsigned length) |
Read data from WG0X local bus using mailbox communication. More... | |
bool | tryLockWG0XDiagnostics () |
void | unlockWG0XDiagnostics () |
bool | verifyChecksum (const void *buffer, unsigned size) |
bool | verifyState (WG0XStatus *this_status, WG0XStatus *prev_status) |
bool | writeAppRam (EthercatCom *com, double zero_offset) |
int | writeMailbox (EthercatCom *com, unsigned address, void const *data, unsigned length) |
Write data to WG0X local bus using mailbox communication. More... | |
Static Protected Member Functions | |
static void | copyActuatorInfo (ethercat_hardware::ActuatorInfo &out, const WG0XActuatorInfo &in) |
Fills in ethercat_hardware::ActuatorInfo from WG0XActuatorInfo. More... | |
static string | modeString (uint8_t mode) |
static string | safetyDisableString (uint8_t status) |
static bool | timestamp_jump (uint32_t timestamp, uint32_t last_timestamp, uint32_t amount) |
Static Protected Attributes | |
static const unsigned | ACTUATOR_INFO_PAGE = 4095 |
static const unsigned | COMMAND_PHY_ADDR = 0x1000 |
static boost::shared_ptr< ethercat_hardware::MotorHeatingModelCommon > | motor_heating_model_common_ |
static const unsigned | PDO_COMMAND_SYNCMAN_NUM = 0 |
static const unsigned | PDO_STATUS_SYNCMAN_NUM = 1 |
static const int | PWM_MAX = 0x4000 |
static const unsigned | STATUS_PHY_ADDR = 0x2000 |
Additional Inherited Members | |
Public Types inherited from EthercatDevice | |
enum | AddrMode { FIXED_ADDR =0, POSITIONAL_ADDR =1 } |
Public Attributes inherited from EthercatDevice | |
enum EthercatDevice::AddrMode | __attribute__ |
unsigned int | command_size_ |
EthercatDeviceDiagnostics | deviceDiagnostics [2] |
diagnostic_updater::DiagnosticStatusWrapper | diagnostic_status_ |
pthread_mutex_t | diagnosticsLock_ |
unsigned | newDiagnosticsIndex_ |
pthread_mutex_t | newDiagnosticsIndexLock_ |
EtherCAT_SlaveHandler * | sh_ |
unsigned int | status_size_ |
bool | use_ros_ |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
static |
|
virtual |
Reimplemented from EthercatDevice.
|
virtual |
|
static |
|
staticprotected |
Fills in ethercat_hardware::ActuatorInfo from WG0XActuatorInfo.
WG0XAcuatorInfo is a packed structure that comes directly from the device EEPROM. ethercat_hardware::ActuatorInfo is a ROS message type that is used by both motor model and motor heating model.
|
virtual |
For EtherCAT device that only publish one EtherCAT Status message. If sub-class implements multiDiagnostics() then diagnostics() is not used.
d | Diagnostics status wrapper. |
buffer | Pointer to slave process data. |
Reimplemented from EthercatDevice.
|
virtual |
|
protected |
|
protected |
|
virtual |
reset | when asserted this will clear diagnostic error conditions device safety disable |
halt | while asserted will disable actuator, usually by disabling H-bridge |
Reimplemented from EthercatDevice.
|
static |
bool WG0X::program | ( | EthercatCom * | com, |
const WG0XActuatorInfo & | actutor_info | ||
) |
Programs acutator and heating parameters into device EEPROM.
WG0X devices store configuaration info in EEPROM. This configuration information contains information such as device name, motor parameters, and encoder parameters.
Originally, devices only stored ActuatorInfo in EEPROM. However, later we discovered that in extreme cases, certain motors may overheat. To prevent motor overheating, a model is used to estimate motor winding temperature and stop motor if temperature gets too high. However, the new motor heating model needs more motor parameters than were originally stored in eeprom.
com | EtherCAT communication class used for communicating with device |
actutor_info | Actuator information to be stored in device EEPROM |
actutor_info | Motor heating motor information to be stored in device EEPROM |
bool WG0X::program | ( | EthercatCom * | com, |
const MotorHeatingModelParametersEepromConfig & | heating_config | ||
) |
Programs motor heating parameters into device EEPROM.
Originally, devices only stored ActuatorInfo in EEPROM. However, later we discovered that in extreme cases, certain motors may overheat. To prevent motor overheating, a model is used to estimate motor winding temperature and stop motor if temperature gets too high. However, the new motor heating model needs more motor parameters than were originally stored in eeprom.
com | EtherCAT communication class used for communicating with device |
heating_config | Motor heating model parameters to be stored in device EEPROM |
|
protected |
|
protected |
|
virtual |
Asks device to publish (motor) trace. Only works for devices that support it.
reason | Message to put in trace as reason. |
level | Level to put in trace (aka ERROR=2, WARN=1, OK=0) |
delay | Publish trace after delay cyles. For 1kHz realtime loop 1cycle = 1ms. |
Reimplemented from EthercatDevice.
bool WG0X::readActuatorInfoFromEeprom | ( | EthercatCom * | com, |
WG0XActuatorInfo & | actuator_info | ||
) |
|
protected |
|
protected |
Read data from WG0X local bus using mailbox communication.
Internally a localbus read is done in two parts. First, a mailbox write of a command header that include local bus address and length. Second, a mailbox read of the result.
com | used to perform communication with device |
address | WG0X (FPGA) local bus address to read from |
data | pointer to buffer where read data can be stored, must be at least length in size |
length | amount of data to read, limited at 511 bytes. |
bool WG0X::readMotorHeatingModelParametersFromEeprom | ( | EthercatCom * | com, |
MotorHeatingModelParametersEepromConfig & | config | ||
) |
|
staticprotected |
|
static |
Convert timestamp difference to ros::Duration. Timestamp is assumed to be in microseconds
It is assumed that each timestamps is exactly 32bit and can wrap around from 0xFFFFFFFF back to 0. In this case 1 - 4294967295 should equal 2 not -4294967294. (Note : 0xFFFFFFFF = 4294967295)
|
staticprotected |
|
static |
Returns (new_timestamp - old_timestamp). Accounts for wrapping of timestamp values.
It is assumed that each timestamps is exactly 32bit and can wrap around from 0xFFFFFFFF back to 0. In this case 1 - 4294967295 should equal 2 not -4294967294. (Note : 0xFFFFFFFF = 4294967295)
|
virtual |
Reimplemented from EthercatDevice.
|
protected |
|
protected |
|
protected |
|
protected |
Write data to WG0X local bus using mailbox communication.
First, this puts a command header that include local bus address and length in write mailbox. Second it waits until device actually empties write mailbox.
com | used to perform communication with device |
address | WG0X (FPGA) local bus address to write data to |
data | pointer to buffer where write data is stored, must be at least length in size |
length | amount of data to write, limited at 507 bytes |
enum { ... } WG0X::__attribute__ |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
protected |
|
protected |
|
staticprotected |
|
staticprotected |
|
protected |
|
protected |
The ros::Duration timestamp measures the time since the ethercat process started. It is generated by accumulating diffs between 32bit device timestamps. Device timestamps are assumed to be in microseconds, so 32bit timestamp will overflow every 72 minutes, ros::Duration (int32_t secs, int32_t nsecs) should overflow will overflow after 68 years
|
staticprotected |
|
protected |
|
protected |