|
|
@ -7,7 +7,7 @@ |
|
|
|
#include "feite_servo_motor.hpp"
|
|
|
|
#include "sdk/os/zos.hpp"
|
|
|
|
//
|
|
|
|
#include "sdk\components\cmdscheduler\cmd_scheduler.hpp"
|
|
|
|
// #include "sdk\components\cmdscheduler\cmd_scheduler.hpp"
|
|
|
|
#include "sdk\components\eq_20_asb_motor\eq20_servomotor.hpp"
|
|
|
|
#include "sdk\components\iflytop_can_slave_module_master_end\stepmotor.hpp"
|
|
|
|
#include "sdk\components\iflytop_can_slave_v1\iflytop_can_master.hpp"
|
|
|
@ -16,9 +16,8 @@ |
|
|
|
#include "sdk\components\zcancmder\zcanreceiver_master.hpp"
|
|
|
|
//
|
|
|
|
#include "sdk\components/step_motor_ctrl_module/step_motor_ctrl_script_cmder_module.hpp"
|
|
|
|
|
|
|
|
#include "sdk\components/xy_robot_ctrl_module/xy_robot_script_cmder_module.hpp"
|
|
|
|
|
|
|
|
#include "sdk\components\cmdscheduler\cmd_scheduler_v2.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"
|
|
|
@ -27,6 +26,10 @@ |
|
|
|
// #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"
|
|
|
|
|
|
|
|
#include "sdk\components\zprotocol_helper\micro_computer_module_device_script_cmder_paser.hpp"
|
|
|
|
#include "sdk\components\zprotocols\zcancmder_v2\protocol_proxy.hpp"
|
|
|
|
#include "sdk\components\zprotocols\zcancmder_v2\zmodule_device_manager.hpp"
|
|
|
|
#include "sdk\components\zprotocols\zcancmder_v2\zmodule_device_script_cmder_paser.hpp"
|
|
|
|
#define TAG "main"
|
|
|
|
namespace iflytop { |
|
|
|
Main gmain; |
|
|
@ -94,7 +97,7 @@ static StepMotor45::cfg_t cfg3 = { |
|
|
|
.driverPin = {PG6, PG7, PG8, PC6}, |
|
|
|
.driverPinMirror = true, |
|
|
|
}; |
|
|
|
|
|
|
|
#if 0
|
|
|
|
static StepMotor45::cfg_t cfg4 = { |
|
|
|
.max_pos = -1, |
|
|
|
.enable_zero_limit = false, |
|
|
@ -132,36 +135,31 @@ static StepMotor45::cfg_t cfg6 = { |
|
|
|
.driverPin = {PC12, PD3, PD5, PD7}, |
|
|
|
.driverPinMirror = true, |
|
|
|
}; |
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace iflytop { |
|
|
|
/*******************************************************************************
|
|
|
|
* 基础组件 * |
|
|
|
*******************************************************************************/ |
|
|
|
ZCanCommnaderMaster m_zcanCommnaderMaster; |
|
|
|
CmdScheduler g_cmdScheduler; |
|
|
|
ModbusBlockHost g_modbusblockhost; |
|
|
|
FeiTeServoMotor g_feiteservomotor_bus; |
|
|
|
CmdSchedulerV2 g_cmdScheduler; // 串口字符串指令总线
|
|
|
|
ZCanCommnaderMaster m_zcanCommnaderMaster; // can总线
|
|
|
|
ModbusBlockHost g_modbusblockhost; // modbus总线
|
|
|
|
FeiTeServoMotor g_feiteservomotor_bus; // 飞特舵机总线
|
|
|
|
ZModuleDeviceManager g_zmodule_device_manager; // 用于管理所有的设备
|
|
|
|
MicroComputerModuleDeviceScriptCmderPaser g_zmodule_device_script_cmder_paser; // 用于解析所有的设备指令
|
|
|
|
StepMotor45Scheduler step_motor45_scheduler; // 45步进电机调度器
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 本地设备 * |
|
|
|
*******************************************************************************/ |
|
|
|
StepMotor45 g_step_motor45[7]; |
|
|
|
Eq20ServoMotor g_main_servo_motor; |
|
|
|
StepMotor45 g_step_motor45[7]; |
|
|
|
MiniRobotCtrlModule g_mini_servo[6]; |
|
|
|
/*******************************************************************************
|
|
|
|
* CAN设备 * |
|
|
|
*******************************************************************************/ |
|
|
|
I_XYRobotCtrlModule* g_xyrobotctrlmodule = nullptr; |
|
|
|
I_StepMotorCtrlModule* g_z_step_motor = nullptr; |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 串口指令 * |
|
|
|
*******************************************************************************/ |
|
|
|
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; |
|
|
|
ZIProtocolProxy g_xyrobotctrlmodule; |
|
|
|
ZIProtocolProxy g_z_step_motor; |
|
|
|
|
|
|
|
} // namespace iflytop
|
|
|
|
|
|
|
@ -181,75 +179,54 @@ void Main::run() { |
|
|
|
*******************************************************************************/ |
|
|
|
|
|
|
|
chip_init(&chipcfg); |
|
|
|
|
|
|
|
zos_cfg_t zoscfg; |
|
|
|
zos_init(&zoscfg); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 总线初始化 * |
|
|
|
*******************************************************************************/ |
|
|
|
// 指令总线
|
|
|
|
g_cmdScheduler.initialize(&DEBUG_UART, 1000); |
|
|
|
// can总线
|
|
|
|
auto* cfg = m_zcanCommnaderMaster.createCFG(); |
|
|
|
m_zcanCommnaderMaster.init(cfg); |
|
|
|
// 飞特舵机总线
|
|
|
|
g_feiteservomotor_bus.initialize(&huart3, &hdma_usart3_rx, &hdma_usart3_tx); |
|
|
|
// modbus总线
|
|
|
|
g_modbusblockhost.initialize(&huart2, &hdma_usart2_tx, &hdma_usart2_rx); |
|
|
|
g_main_servo_motor.init(&g_modbusblockhost, 1); |
|
|
|
g_cmdScheduler.initialize(&DEBUG_UART, 1000); // 串口字符串指令总线
|
|
|
|
auto* cfg = m_zcanCommnaderMaster.createCFG(); // can总线配置
|
|
|
|
m_zcanCommnaderMaster.init(cfg); // can总线
|
|
|
|
g_modbusblockhost.initialize(&huart2, &hdma_usart2_tx, &hdma_usart2_rx); // modbus总线
|
|
|
|
g_feiteservomotor_bus.initialize(&huart3, &hdma_usart3_rx, &hdma_usart3_tx); // 飞特舵机总线
|
|
|
|
step_motor45_scheduler.initialize(&htim10); |
|
|
|
// 设备管理器初始化
|
|
|
|
g_zmodule_device_manager.initialize(&m_zcanCommnaderMaster); |
|
|
|
// 设备指令解析器初始化
|
|
|
|
g_zmodule_device_script_cmder_paser.initialize(&g_cmdScheduler, &g_zmodule_device_manager); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 设备构造和初始化 * |
|
|
|
*******************************************************************************/ |
|
|
|
// g_z_step_motor = zcancmder_master::create_zcan_master_step_motor_ctrl_module(&m_zcanCommnaderMaster, 1);
|
|
|
|
// ZASSERT(g_z_step_motor != nullptr);
|
|
|
|
|
|
|
|
// g_xyrobotctrlmodule = zcancmder_master::create_xyrobot_ctrl_module(&m_zcanCommnaderMaster, 1);
|
|
|
|
g_mini_servo[0].initialize(1, &g_feiteservomotor_bus, 1); |
|
|
|
g_mini_servo[1].initialize(2, &g_feiteservomotor_bus, 2); |
|
|
|
g_mini_servo[2].initialize(3, &g_feiteservomotor_bus, 3); |
|
|
|
g_mini_servo[3].initialize(4, &g_feiteservomotor_bus, 4); |
|
|
|
g_mini_servo[4].initialize(5, &g_feiteservomotor_bus, 5); |
|
|
|
g_mini_servo[5].initialize(6, &g_feiteservomotor_bus, 6); |
|
|
|
|
|
|
|
StepMotor45Scheduler step_motor45_scheduler; |
|
|
|
step_motor45_scheduler.initialize(&htim10); |
|
|
|
|
|
|
|
g_step_motor45[0].initialize(1, &step_motor45_scheduler, cfg1); |
|
|
|
g_step_motor45[1].initialize(2, &step_motor45_scheduler, cfg2); |
|
|
|
g_step_motor45[2].initialize(3, &step_motor45_scheduler, cfg3); |
|
|
|
g_step_motor45[3].initialize(4, &step_motor45_scheduler, cfg4); |
|
|
|
g_step_motor45[4].initialize(5, &step_motor45_scheduler, cfg5); |
|
|
|
g_step_motor45[5].initialize(6, &step_motor45_scheduler, cfg6); |
|
|
|
g_main_servo_motor.init(2, &g_modbusblockhost, 1); |
|
|
|
g_xyrobotctrlmodule.initialize(3, &m_zcanCommnaderMaster); |
|
|
|
g_z_step_motor.initialize(4, &m_zcanCommnaderMaster); |
|
|
|
|
|
|
|
g_mini_servo[0].initialize(11, &g_feiteservomotor_bus, 1); |
|
|
|
g_mini_servo[1].initialize(12, &g_feiteservomotor_bus, 2); |
|
|
|
g_mini_servo[2].initialize(13, &g_feiteservomotor_bus, 3); |
|
|
|
g_mini_servo[3].initialize(14, &g_feiteservomotor_bus, 4); |
|
|
|
g_mini_servo[4].initialize(15, &g_feiteservomotor_bus, 5); |
|
|
|
g_mini_servo[5].initialize(16, &g_feiteservomotor_bus, 6); |
|
|
|
|
|
|
|
g_step_motor45[0].initialize(21, &step_motor45_scheduler, cfg1); |
|
|
|
g_step_motor45[1].initialize(22, &step_motor45_scheduler, cfg2); |
|
|
|
g_step_motor45[2].initialize(23, &step_motor45_scheduler, cfg3); |
|
|
|
step_motor45_scheduler.start(); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* CMD * |
|
|
|
*******************************************************************************/ |
|
|
|
g_script_eq20servomotor.initialize(&g_cmdScheduler); |
|
|
|
g_script_eq20servomotor.regmodule(1, &g_main_servo_motor); |
|
|
|
|
|
|
|
g_step_motor_ctrl_script_cmder_module.initialize(&g_cmdScheduler); |
|
|
|
g_step_motor_ctrl_script_cmder_module.regmodule(1, g_z_step_motor); |
|
|
|
|
|
|
|
g_script_xyrobot.initialize(&g_cmdScheduler); |
|
|
|
g_script_xyrobot.regmodule(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_mini_servo_motor_ctrl_module.regmodule(6, &g_mini_servo[5]); |
|
|
|
|
|
|
|
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]); |
|
|
|
g_zmodule_device_manager.registerModule(&g_main_servo_motor); |
|
|
|
g_zmodule_device_manager.registerModule(&g_xyrobotctrlmodule); |
|
|
|
g_zmodule_device_manager.registerModule(&g_z_step_motor); |
|
|
|
g_zmodule_device_manager.registerModule(&g_mini_servo[0]); |
|
|
|
g_zmodule_device_manager.registerModule(&g_mini_servo[1]); |
|
|
|
g_zmodule_device_manager.registerModule(&g_mini_servo[2]); |
|
|
|
g_zmodule_device_manager.registerModule(&g_mini_servo[3]); |
|
|
|
g_zmodule_device_manager.registerModule(&g_mini_servo[4]); |
|
|
|
g_zmodule_device_manager.registerModule(&g_mini_servo[5]); |
|
|
|
g_zmodule_device_manager.registerModule(&g_step_motor45[0]); |
|
|
|
g_zmodule_device_manager.registerModule(&g_step_motor45[1]); |
|
|
|
g_zmodule_device_manager.registerModule(&g_step_motor45[2]); |
|
|
|
|
|
|
|
#if 0
|
|
|
|
step_motor_cmd_reg(); |
|
|
|