|
|
@ -21,6 +21,8 @@ |
|
|
|
#include "sdk\components/xy_robot_ctrl_module/zcan_xy_robot_master_module.hpp"
|
|
|
|
#include "sdk\components\eq_20_asb_motor\script_cmder_eq20_servomotor.hpp"
|
|
|
|
#include "sdk\components\mini_servo_motor\mini_servo_motor_ctrl_module.hpp"
|
|
|
|
#include "sdk\components\mini_servo_motor\scirpt_cmder_mini_servo_motor_ctrl_module.hpp"
|
|
|
|
#include "sdk\components\step_motor_45\script_cmder_step_motor_45.hpp"
|
|
|
|
// #include "sdk\components\scriptcmder_module\xy_robot_script_cmder_module.hpp"
|
|
|
|
// #include "sdk\components\zcancmder_master_module/zcan_master_step_motor_ctrl_module.hpp"
|
|
|
|
// #include "sdk\components\zcancmder_master_module\zcan_xy_robot_master_module.hpp"
|
|
|
@ -152,72 +154,13 @@ I_StepMotorCtrlModule* g_z_step_motor = nullptr; |
|
|
|
/*******************************************************************************
|
|
|
|
* ´®¿ÚÖ¸Áî * |
|
|
|
*******************************************************************************/ |
|
|
|
StepMotorCtrlScriptCmderModule g_step_motor_ctrl_script_cmder_module; |
|
|
|
XYRobotScriptCmderModule g_script_xyrobot; |
|
|
|
ScriptCmderEq20Servomotor g_script_eq20servomotor; |
|
|
|
StepMotorCtrlScriptCmderModule g_step_motor_ctrl_script_cmder_module; |
|
|
|
XYRobotScriptCmderModule g_script_xyrobot; |
|
|
|
ScriptCmderEq20Servomotor g_script_eq20servomotor; |
|
|
|
ScirptCmderMiniServoMotorCtrlModule g_script_mini_servo_motor_ctrl_module; |
|
|
|
ScriptCmderStepMotor45 g_script_step_motor45; |
|
|
|
|
|
|
|
} // namespace iflytop
|
|
|
|
#if 0
|
|
|
|
void regfn() { |
|
|
|
// setzero
|
|
|
|
// set4095
|
|
|
|
// moveto
|
|
|
|
#if 0
|
|
|
|
cmdScheduler.registerCmd("mini_servo_set_zero", [](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { |
|
|
|
CHECK_ARGC(1); |
|
|
|
int id = atoi(argv[1]); |
|
|
|
ZLOGI(TAG, "mini_servo_set_zero %d", id); |
|
|
|
g_feiteservomotor.reCalibration(id, 0); |
|
|
|
ZLOGI(TAG, "mini_servo_set_zero %d done", id); |
|
|
|
}); |
|
|
|
cmdScheduler.registerCmd("mini_servo_set_4095", [](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { |
|
|
|
CHECK_ARGC(1); |
|
|
|
int id = atoi(argv[1]); |
|
|
|
ZLOGI(TAG, "mini_servo_set_4095 %d", id); |
|
|
|
g_feiteservomotor.reCalibration(id, 4095); |
|
|
|
ZLOGI(TAG, "mini_servo_set_4095 %d done", id); |
|
|
|
}); |
|
|
|
cmdScheduler.registerCmd("mini_servo_move_to", [](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { |
|
|
|
CHECK_ARGC(3); |
|
|
|
int id = atoi(argv[1]); |
|
|
|
int pos = atoi(argv[2]); |
|
|
|
int torque = atoi(argv[3]); |
|
|
|
|
|
|
|
ZLOGI(TAG, "mini_servo_move_to %d %d %d %d", id, pos, 2700, torque); |
|
|
|
g_feiteservomotor.moveTo(id, pos, 2700, torque); |
|
|
|
}); |
|
|
|
cmdScheduler.registerCmd("mini_servo_rotate", [](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { |
|
|
|
CHECK_ARGC(2); |
|
|
|
int id = atoi(argv[1]); |
|
|
|
int speed = atoi(argv[2]); |
|
|
|
// int v = atoi(3000);
|
|
|
|
ZLOGI(TAG, "mini_servo_rotate %d %d %d", id, speed, 10, 2700); |
|
|
|
g_feiteservomotor.rotate(id, speed, 10); |
|
|
|
}); |
|
|
|
cmdScheduler.registerCmd("mini_servo_move_with_torque", [](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { |
|
|
|
CHECK_ARGC(2); |
|
|
|
int id = atoi(argv[1]); |
|
|
|
int torque = atoi(argv[2]); |
|
|
|
// int v = atoi(3000);
|
|
|
|
if (torque == 0) { |
|
|
|
g_feiteservomotor.moveWithTorque(id, 1); |
|
|
|
} else { |
|
|
|
g_feiteservomotor.moveWithTorque(id, torque); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
cmdScheduler.registerCmd("sleep_ms", [](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { |
|
|
|
CHECK_ARGC(1); |
|
|
|
osDelay(atoi(argv[1])); |
|
|
|
}); |
|
|
|
|
|
|
|
cmdScheduler.registerCmd("hbot_enable", [](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { |
|
|
|
CHECK_ARGC(0); |
|
|
|
g_xyrobotctrlmodule->enable(false); |
|
|
|
}); |
|
|
|
#endif
|
|
|
|
} |
|
|
|
#endif
|
|
|
|
|
|
|
|
extern "C" { |
|
|
|
extern DMA_HandleTypeDef hdma_usart3_rx; |
|
|
@ -259,7 +202,22 @@ void Main::run() { |
|
|
|
ZASSERT(g_z_step_motor != nullptr); |
|
|
|
|
|
|
|
g_xyrobotctrlmodule = zcancmder_master::create_xyrobot_ctrl_module(&m_zcanCommnaderMaster, 1); |
|
|
|
g_mini_servo[0].initialize(&g_feiteservomotor_bus, 1); |
|
|
|
g_mini_servo[1].initialize(&g_feiteservomotor_bus, 2); |
|
|
|
g_mini_servo[2].initialize(&g_feiteservomotor_bus, 3); |
|
|
|
g_mini_servo[3].initialize(&g_feiteservomotor_bus, 4); |
|
|
|
g_mini_servo[4].initialize(&g_feiteservomotor_bus, 5); |
|
|
|
|
|
|
|
StepMotor45Scheduler step_motor45_scheduler; |
|
|
|
step_motor45_scheduler.initialize(&htim10, 1000); |
|
|
|
|
|
|
|
g_step_motor45[0].initialize(&step_motor45_scheduler, cfg1); |
|
|
|
g_step_motor45[1].initialize(&step_motor45_scheduler, cfg2); |
|
|
|
g_step_motor45[2].initialize(&step_motor45_scheduler, cfg3); |
|
|
|
g_step_motor45[3].initialize(&step_motor45_scheduler, cfg4); |
|
|
|
g_step_motor45[4].initialize(&step_motor45_scheduler, cfg5); |
|
|
|
g_step_motor45[5].initialize(&step_motor45_scheduler, cfg6); |
|
|
|
step_motor45_scheduler.start(); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* CMD * |
|
|
@ -272,56 +230,23 @@ void Main::run() { |
|
|
|
|
|
|
|
g_script_xyrobot.initialize(&g_cmdScheduler); |
|
|
|
g_script_xyrobot.regmodule(1, g_xyrobotctrlmodule); |
|
|
|
#if 0
|
|
|
|
|
|
|
|
g_xyrobotctrlmodule = zcancmder_master::create_xyrobot_ctrl_module(&m_zcanCommnaderMaster, 1); |
|
|
|
// g_xyrobotctrlmodule->enable(false);
|
|
|
|
|
|
|
|
g_stepmotorctrlmodule = zcancmder_master::create_zcan_master_step_motor_ctrl_module(&m_zcanCommnaderMaster, 1); |
|
|
|
// g_stepmotorctrlmodule->rotate(300000, 0, [this](int32_t end) {});
|
|
|
|
|
|
|
|
cmdScheduler |
|
|
|
xyRobotScriptCmderModule.initialize(&cmdScheduler); |
|
|
|
xyRobotScriptCmderModule.regXYRobot(1, g_xyrobotctrlmodule); |
|
|
|
g_script_mini_servo_motor_ctrl_module.initialize(&g_cmdScheduler); |
|
|
|
g_script_mini_servo_motor_ctrl_module.regmodule(1, &g_mini_servo[0]); |
|
|
|
g_script_mini_servo_motor_ctrl_module.regmodule(2, &g_mini_servo[1]); |
|
|
|
g_script_mini_servo_motor_ctrl_module.regmodule(3, &g_mini_servo[2]); |
|
|
|
g_script_mini_servo_motor_ctrl_module.regmodule(4, &g_mini_servo[3]); |
|
|
|
g_script_mini_servo_motor_ctrl_module.regmodule(5, &g_mini_servo[4]); |
|
|
|
|
|
|
|
g_script_step_motor45.initialize(&g_cmdScheduler); |
|
|
|
g_script_step_motor45.regmodule(1, &g_step_motor45[0]); |
|
|
|
g_script_step_motor45.regmodule(2, &g_step_motor45[1]); |
|
|
|
g_script_step_motor45.regmodule(3, &g_step_motor45[2]); |
|
|
|
g_script_step_motor45.regmodule(4, &g_step_motor45[3]); |
|
|
|
g_script_step_motor45.regmodule(5, &g_step_motor45[4]); |
|
|
|
g_script_step_motor45.regmodule(6, &g_step_motor45[5]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
regfn(); |
|
|
|
|
|
|
|
int i = 1; |
|
|
|
g_step_motor[i++].initialize(11, 10000, &m_IflytopCanMaster); |
|
|
|
g_step_motor[i++].initialize(12, 10000, &m_IflytopCanMaster); |
|
|
|
g_step_motor[i++].initialize(13, 10000, &m_IflytopCanMaster); |
|
|
|
g_step_motor[i++].initialize(14, 10000, &m_IflytopCanMaster); |
|
|
|
g_step_motor[i++].initialize(15, 10000, &m_IflytopCanMaster); |
|
|
|
g_step_motor[i++].initialize(16, 10000, &m_IflytopCanMaster); |
|
|
|
|
|
|
|
g_step_motor45[0].initialize(cfg1); |
|
|
|
g_step_motor45[1].initialize(cfg1); |
|
|
|
g_step_motor45[2].initialize(cfg2); |
|
|
|
g_step_motor45[3].initialize(cfg3); |
|
|
|
g_step_motor45[4].initialize(cfg4); |
|
|
|
g_step_motor45[5].initialize(cfg5); |
|
|
|
g_step_motor45[6].initialize(cfg6); |
|
|
|
|
|
|
|
StepMotor45Scheduler step_motor45_scheduler; |
|
|
|
step_motor45_scheduler.initialize(&htim10, 1000); |
|
|
|
step_motor45_scheduler.addMotor(&g_step_motor45[1]); |
|
|
|
step_motor45_scheduler.addMotor(&g_step_motor45[2]); |
|
|
|
step_motor45_scheduler.addMotor(&g_step_motor45[3]); |
|
|
|
step_motor45_scheduler.addMotor(&g_step_motor45[4]); |
|
|
|
step_motor45_scheduler.addMotor(&g_step_motor45[5]); |
|
|
|
step_motor45_scheduler.addMotor(&g_step_motor45[6]); |
|
|
|
// g_step_motor45_1.rotate(true, 1000);
|
|
|
|
|
|
|
|
step_motor45_scheduler.start(); |
|
|
|
|
|
|
|
|
|
|
|
g_modbusblockhost.initialize(&huart2); |
|
|
|
g_eq20servomotor.init(&g_modbusblockhost); |
|
|
|
g_feiteservomotor.initialize(&huart3, &hdma_usart3_rx, &hdma_usart3_tx); |
|
|
|
#endif
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
step_motor_cmd_reg(); |
|
|
|
#endif
|
|
|
|