35 #ifndef ETHERCAT_HARDWARE__WG0X_H 36 #define ETHERCAT_HARDWARE__WG0X_H 45 #include <boost/shared_ptr.hpp> 142 char robot_name_[32];
143 char motor_make_[32];
144 char motor_model_[32];
237 void construct(EtherCAT_SlaveHandler *sh,
int &start_address);
243 void packCommand(
unsigned char *buffer,
bool halt,
bool reset);
244 bool unpackState(
unsigned char *this_buffer,
unsigned char *prev_buffer);
255 bool publishTrace(
const string &reason,
unsigned level,
unsigned delay);
260 uint8_t board_major_;
261 uint8_t board_minor_;
267 ethercat_hardware::ActuatorInfo actuator_info_msg_;
268 static void copyActuatorInfo(ethercat_hardware::ActuatorInfo &out,
const WG0XActuatorInfo &in);
276 MODE_ENABLE = (1 << 0),
277 MODE_CURRENT = (1 << 1),
278 MODE_SAFETY_RESET = (1 << 4),
279 MODE_SAFETY_LOCKOUT = (1 << 5),
280 MODE_UNDERVOLTAGE = (1 << 6),
281 MODE_RESET = (1 << 7)
286 WG05_PRODUCT_CODE = 6805005,
287 WG06_PRODUCT_CODE = 6805006,
288 WG021_PRODUCT_CODE = 6805021
291 static string modeString(uint8_t
mode);
292 static string safetyDisableString(uint8_t
status);
303 void clearErrorFlags(
void);
306 enum {NO_CALIBRATION=0, CONTROLLER_CALIBRATION=1, SAVED_CALIBRATION=2};
323 enum AppRamStatus { APP_RAM_PRESENT=1, APP_RAM_MISSING=2, APP_RAM_NOT_APPLICABLE=3 };
325 bool readAppRam(
EthercatCom *com,
double &zero_offset);
326 bool writeAppRam(
EthercatCom *com,
double zero_offset);
330 int writeMailbox(
EthercatCom *com,
unsigned address,
void const *data,
unsigned length);
331 int readMailbox(
EthercatCom *com,
unsigned address,
void *data,
unsigned length);
337 const string &device_description,
338 double max_pwm_ratio,
339 double board_resistance,
340 bool poor_measured_motor_voltage);
342 bool initializeMotorHeatingModel(
bool allow_unprogrammed);
345 static bool timestamp_jump(uint32_t timestamp, uint32_t last_timestamp, uint32_t amount);
347 static const int PWM_MAX = 0x4000;
356 static const unsigned COMMAND_PHY_ADDR = 0x1000;
357 static const unsigned STATUS_PHY_ADDR = 0x2000;
359 static const unsigned PDO_COMMAND_SYNCMAN_NUM = 0;
360 static const unsigned PDO_STATUS_SYNCMAN_NUM = 1;
364 LIMIT_SENSOR_0_STATE = (1 << 0),
365 LIMIT_SENSOR_1_STATE = (1 << 1),
366 LIMIT_ON_TO_OFF = (1 << 2),
367 LIMIT_OFF_TO_ON = (1 << 3)
372 SAFETY_DISABLED = (1 << 0),
373 SAFETY_UNDERVOLTAGE = (1 << 1),
374 SAFETY_OVER_CURRENT = (1 << 2),
375 SAFETY_BOARD_OVER_TEMP = (1 << 3),
376 SAFETY_HBRIDGE_OVER_TEMP = (1 << 4),
377 SAFETY_OPERATIONAL = (1 << 5),
378 SAFETY_WATCHDOG = (1 << 6)
383 static const unsigned ACTUATOR_INFO_PAGE = 4095;
402 bool lockWG0XDiagnostics();
403 bool tryLockWG0XDiagnostics();
404 void unlockWG0XDiagnostics();
410 static int32_t timestampDiff(uint32_t new_timestamp, uint32_t old_timestamp);
411 static int32_t positionDiff(int32_t new_position, int32_t old_position);
413 static ros::Duration timediffToDuration(int32_t timediff_usec);
415 static double calcEncoderVelocity(int32_t new_position, uint32_t new_timestamp,
416 int32_t old_position, uint32_t old_timestamp);
418 static double convertRawTemperature(int16_t raw_temp);
422 #endif // ETHERCAT_HARDWARE__WG0X_H uint16_t max_bridge_temperature_
uint8_t board_over_temp_count_
uint8_t mbx_command_irq_count_
int16_t programmed_pwm_value_
uint32_t pulses_per_revolution_
WG0XDiagnostics wg0x_publish_diagnostics_
uint8_t firmware_major_revision_
uint32_t bridge_over_temp_total_
static const unsigned SIZE
ROSCONSOLE_DECL void initialize()
uint8_t bridge_over_temp_count_
int max_consecutive_drops_
uint16_t board_temperature_
static boost::shared_ptr< ethercat_hardware::MotorHeatingModelCommon > motor_heating_model_common_
bool verifyChecksum(void) const
MotorModel * motor_model_
uint8_t firmware_minor_revision_
bool too_many_dropped_packets_
uint8_t undervoltage_count_
uint8_t safety_disable_status_
uint8_t safety_disable_status_hold_
uint8_t safety_disable_status_hold_
uint16_t bridge_temperature_
ethercat_hardware::WGEeprom eeprom_
Access to device eeprom.
AppRamStatus
Different possible states for application ram on device.
WG0XDiagnosticsInfo diagnostics_info_
uint8_t safety_disable_status_
int16_t config_offset_current_B_
float nominal_voltage_scale_
bool status_checksum_error_
uint32_t safety_disable_total_
uint8_t safety_disable_count_
int16_t offset_current_B_
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
double motor_torque_constant_
bool fpga_internal_reset_detected_
static const unsigned CONFIG_INFO_BASE_ADDR
double cached_zero_offset_
int32_t last_calibration_falling_edge_
bool timestamp_jump_detected_
double encoder_reduction_
int32_t last_calibration_rising_edge_
uint32_t watchdog_disable_total_
uint32_t operate_disable_total_
uint8_t highside_deadtime_
int16_t config_offset_current_A_
pthread_mutex_t wg0x_diagnostics_lock_
double cached_zero_offset_
ros::Duration sample_timestamp_
uint16_t absolute_current_limit_
uint32_t over_current_total_
uint32_t checksum_errors_
int32_t encoder_index_pos_
int16_t programmed_current_
uint8_t configuration_status_
uint8_t operate_disable_count_
int16_t programmed_current_
ethercat_hardware::MotorTraceSample motor_trace_sample_
uint8_t over_current_count_
bool encoder_errors_detected_
uint8_t pdi_checksum_error_count_
static const unsigned BASE_ADDR
uint16_t supply_current_in_
int16_t offset_current_A_
uint8_t watchdog_disable_count_
uint32_t last_last_timestamp_
pr2_hardware_interface::DigitalOut publish_motor_trace_
uint8_t safety_disable_count_
WG0XSafetyDisableStatus safety_disable_status_
AppRamStatus app_ram_status_
uint32_t device_serial_number_
float nominal_current_scale_
uint8_t pdi_timeout_error_count_
int16_t measured_current_
uint32_t board_over_temp_total_
uint16_t supply_current_out_
boost::shared_ptr< ethercat_hardware::MotorHeatingModel > motor_heating_model_
WG0XSafetyDisableCounters safety_disable_counters_
uint32_t undervoltage_total_
ethercat_hardware::WGMailbox mailbox_
Mailbox access to device.
bool verifyCRC(void) const
uint8_t pdo_command_irq_count_
ethercat_hardware::MotorHeatingModelCommon __attribute__
WG0XDiagnostics wg0x_collect_diagnostics_
uint8_t lowside_deadtime_
bool disable_motor_model_checking_
uint16_t num_encoder_errors_
uint8_t calibration_reading_