|
|
@ -9,7 +9,7 @@ using namespace iflytop; |
|
|
|
|
|
|
|
#define TAG "Eq20ServoMotor"
|
|
|
|
|
|
|
|
void Eq20ServoMotor::init(ModbusBlockHost *modbusBlockHost, int moduleid, int motorid = 1) { |
|
|
|
void Eq20ServoMotor::init(ModbusBlockHost *modbusBlockHost, int moduleid, int motorid) { |
|
|
|
// this->com = com;
|
|
|
|
m_modbusBlockHost = modbusBlockHost; |
|
|
|
m_deviceId = motorid; |
|
|
@ -230,18 +230,28 @@ int32_t Eq20ServoMotor::module_get_last_exec_status(int32_t *status) { |
|
|
|
*status = 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t Eq20ServoMotor::module_get_status(int32_t *status) {} |
|
|
|
int32_t Eq20ServoMotor::module_get_status(int32_t *status) { |
|
|
|
*status = 0; |
|
|
|
servo_internal_status_t internal_state; |
|
|
|
int32_t ecode = get_servo_internal_state(internal_state); |
|
|
|
if (ecode != 0) { |
|
|
|
return ecode; |
|
|
|
} |
|
|
|
if (!internal_state.data.sbit.is_reach_target) { |
|
|
|
*status = 1; |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t Eq20ServoMotor::module_get_error(int32_t *iserror) { |
|
|
|
*iserror = 0; |
|
|
|
|
|
|
|
// get_servo_internal_state();
|
|
|
|
servo_internal_status_t internal_state; |
|
|
|
int32_t ecode = get_servo_internal_state(internal_state); |
|
|
|
if (ecode != 0) { |
|
|
|
return ecode; |
|
|
|
} |
|
|
|
*status = internal_state.data.sbit.servo_warning | internal_state.data.sbit.servo_warning; |
|
|
|
return 0; |
|
|
|
if (internal_state.data.sbit.servo_warning | internal_state.data.sbit.servo_warning) { |
|
|
|
*iserror = err::kmodule_error; |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t Eq20ServoMotor::module_clear_error() { return err::koperation_not_support; } |
|
|
@ -254,7 +264,15 @@ int32_t Eq20ServoMotor::module_writeio(int32_t io) { return err::koperation_not_ |
|
|
|
int32_t Eq20ServoMotor::module_read_adc(int32_t adcindex, int32_t *adc) { return err::koperation_not_support; } |
|
|
|
|
|
|
|
int32_t Eq20ServoMotor::motor_enable(int32_t varenable) { return enable(varenable); } |
|
|
|
int32_t Eq20ServoMotor::motor_rotate(int32_t direction, int32_t motor_velocity, int32_t acc) { return rotate(direction * motor_velocity, acc); } |
|
|
|
|
|
|
|
int32_t Eq20ServoMotor::motor_rotate(int32_t direction, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } |
|
|
|
int32_t Eq20ServoMotor::motor_move_by(int32_t distance, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } |
|
|
|
int32_t Eq20ServoMotor::motor_move_to(int32_t position, int32_t motor_velocity, int32_t acc) {} |
|
|
|
int32_t Eq20ServoMotor::motor_move_to_with_torque(int32_t pos, int32_t torque) {} |
|
|
|
int32_t Eq20ServoMotor::motor_move_to(int32_t position, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } |
|
|
|
int32_t Eq20ServoMotor::motor_move_to_with_torque(int32_t pos, int32_t torque) { return err::koperation_not_support; } |
|
|
|
|
|
|
|
int32_t Eq20ServoMotor::motor_rotate_acctime(int32_t direction, int32_t motor_velocity, int32_t acctime) { return rotate(direction * motor_velocity, acctime); }; |
|
|
|
int32_t Eq20ServoMotor::motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) { return move_by(distance, motor_velocity, acctime); }; |
|
|
|
int32_t Eq20ServoMotor::motor_move_to_acctime(int32_t position, int32_t motor_velocity, int32_t acctime) { return move_to(position, motor_velocity, acctime); } |
|
|
|
|
|
|
|
int32_t Eq20ServoMotor::motor_move_to_zero_forward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return move_to_zero_forward(findzerospeed, findzeroedge_speed, 30); } |
|
|
|
int32_t Eq20ServoMotor::motor_move_to_zero_backward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return move_to_zero_backward(findzerospeed, findzeroedge_speed, 30); } |