|
|
@ -10,9 +10,11 @@ static void limit_input(s32& input, s32 min, s32 max) { |
|
|
|
if (input < min) input = min; |
|
|
|
} |
|
|
|
|
|
|
|
void MiniRobotCtrlModule::initialize(FeiTeServoMotor* bus, uint8_t id) { |
|
|
|
void MiniRobotCtrlModule::initialize(uint16_t module_id, FeiTeServoMotor *bus, uint8_t idinbus) { |
|
|
|
m_bus = bus; |
|
|
|
m_id = id; |
|
|
|
m_id = idinbus; |
|
|
|
m_module_id = module_id; |
|
|
|
|
|
|
|
m_bus->write_u8(m_id, feite::kRegServoRunMode, feite::kServoMode); |
|
|
|
m_thread.init("MiniRobotCtrlModule", 1024, osPriorityNormal); |
|
|
|
} |
|
|
@ -263,3 +265,64 @@ void MiniRobotCtrlModule::call_status_cb(action_cb_status_t cb, int32_t status) |
|
|
|
m_last_exec_status = status; |
|
|
|
if (cb) cb(status); |
|
|
|
} |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* OVERRIDE MODULE * |
|
|
|
*******************************************************************************/ |
|
|
|
|
|
|
|
int32_t MiniRobotCtrlModule::getid(int32_t *id) { |
|
|
|
*id = m_module_id; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t MiniRobotCtrlModule::module_stop() { return stop(0); } |
|
|
|
int32_t MiniRobotCtrlModule::module_break() { return stop(0); } |
|
|
|
int32_t MiniRobotCtrlModule::module_get_last_exec_status(int32_t *status) { |
|
|
|
*status = m_last_exec_status; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t MiniRobotCtrlModule::module_get_status(int32_t *status) { |
|
|
|
*status = m_thread.isworking(); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t MiniRobotCtrlModule::module_get_error(int32_t *iserror) { |
|
|
|
/**
|
|
|
|
* @brief TODO: |
|
|
|
* Ìí¼Ó¹ýÔØ¼ì²â |
|
|
|
*/ |
|
|
|
*iserror = 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t MiniRobotCtrlModule::module_clear_error() { return 0; } |
|
|
|
|
|
|
|
int32_t MiniRobotCtrlModule::module_set_param(int32_t param_id, int32_t param_value) { return err::kmodule_not_find_config_index; } |
|
|
|
int32_t MiniRobotCtrlModule::module_get_param(int32_t param_id, int32_t *param_value) { return err::kmodule_not_find_config_index; } |
|
|
|
int32_t MiniRobotCtrlModule::module_readio(int32_t *io) { |
|
|
|
*io = 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t MiniRobotCtrlModule::module_writeio(int32_t io) { return 0; } |
|
|
|
int32_t MiniRobotCtrlModule::module_read_adc(int32_t adcindex, int32_t *adc) { |
|
|
|
*adc = 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* Motor * |
|
|
|
*******************************************************************************/ |
|
|
|
int32_t MiniRobotCtrlModule::motor_enable(int32_t varenable) { return enable(varenable); } |
|
|
|
int32_t MiniRobotCtrlModule::motor_rotate(int32_t direction, int32_t motor_velocity, int32_t acc) { return rotate(direction, motor_velocity, acc, nullptr); } |
|
|
|
int32_t MiniRobotCtrlModule::motor_move_by(int32_t distance, int32_t motor_velocity, int32_t acc) { return move_by(distance, motor_velocity, acc, nullptr); } |
|
|
|
int32_t MiniRobotCtrlModule::motor_move_to(int32_t position, int32_t motor_velocity, int32_t acc) { return move_to(position, motor_velocity, acc, nullptr); } |
|
|
|
int32_t MiniRobotCtrlModule::motor_move_to_with_torque(int32_t pos, int32_t torque) { return move_to(pos, 0, torque, nullptr); } |
|
|
|
|
|
|
|
int32_t MiniRobotCtrlModule::motor_rotate_acctime(int32_t direction, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } |
|
|
|
int32_t MiniRobotCtrlModule::motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } |
|
|
|
int32_t MiniRobotCtrlModule::motor_move_to_acctime(int32_t position, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } |
|
|
|
|
|
|
|
int32_t MiniRobotCtrlModule::motor_move_to_zero_forward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } |
|
|
|
int32_t MiniRobotCtrlModule::motor_move_to_zero_backward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return move_to(0, findzerospeed, acc, nullptr); } |
|
|
|
|
|
|
|
int32_t MiniRobotCtrlModule::motor_read_pos(int32_t *pos) { |
|
|
|
if (!m_bus->getNowPos(m_id, *pos)) return err::ksubdevice_overtime; |
|
|
|
return 0; |
|
|
|
} |