|
@ -2,9 +2,9 @@ |
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
#include "sdk\components\zprotocols\zcancmder\zcancmder_protocol.hpp"
|
|
|
|
|
|
|
|
|
// #include "sdk\components\zprotocols\zcancmder\zcancmder_protocol.hpp"
|
|
|
using namespace iflytop; |
|
|
using namespace iflytop; |
|
|
#define TAG "StepMotorCtrlScriptCmderModule"
|
|
|
|
|
|
|
|
|
#define TAG "CMD"
|
|
|
|
|
|
|
|
|
#define CHECK_ARGC(n) \
|
|
|
#define CHECK_ARGC(n) \
|
|
|
if (argc != (n + 1)) { \ |
|
|
if (argc != (n + 1)) { \ |
|
@ -50,64 +50,6 @@ void StepMotorCtrlScriptCmderModule::regmodule(int id, I_StepMotorCtrlModule* ro |
|
|
void StepMotorCtrlScriptCmderModule::regcmd() { //
|
|
|
void StepMotorCtrlScriptCmderModule::regcmd() { //
|
|
|
ZASSERT(m_cmdScheduler != nullptr); |
|
|
ZASSERT(m_cmdScheduler != nullptr); |
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
virtual bool isbusy() = 0; |
|
|
|
|
|
virtual int32_t get_last_exec_status() = 0; |
|
|
|
|
|
|
|
|
|
|
|
virtual int32_t move_to(int32_t x, action_cb_status_t status_cb) = 0; |
|
|
|
|
|
virtual int32_t move_by(int32_t dx, action_cb_status_t status_cb) = 0; |
|
|
|
|
|
virtual int32_t move_to(int32_t velocity, int32_t x, action_cb_status_t status_cb) = 0; |
|
|
|
|
|
virtual int32_t move_by(int32_t velocity, int32_t dx, action_cb_status_t status_cb) = 0; |
|
|
|
|
|
|
|
|
|
|
|
virtual int32_t move_to_zero(action_cb_status_t status_cb) = 0; |
|
|
|
|
|
virtual int32_t move_to_zero_with_calibrate(int32_t x, action_cb_status_t status_cb) = 0; |
|
|
|
|
|
virtual int32_t rotate(int32_t speed, int32_t lastforms, action_cb_status_t status_cb) = 0; |
|
|
|
|
|
virtual int32_t enable(bool venable) = 0; |
|
|
|
|
|
virtual int32_t stop(uint8_t stopType) = 0; |
|
|
|
|
|
virtual int32_t force_change_current_pos(int32_t x) = 0; |
|
|
|
|
|
|
|
|
|
|
|
virtual int32_t move_to_logic_point(int32_t logic_point_num, action_cb_status_t status_cb) = 0; |
|
|
|
|
|
virtual int32_t set_logic_point(int logic_point_num, int32_t x, int32_t vel, s32 acc, s32 dec) = 0; |
|
|
|
|
|
virtual int32_t get_logic_point(int logic_point_num, logic_point_t& logic_point) = 0; |
|
|
|
|
|
|
|
|
|
|
|
virtual int32_t flush() = 0; |
|
|
|
|
|
virtual int32_t factory_reset() = 0; |
|
|
|
|
|
|
|
|
|
|
|
virtual int32_t move_to_block(int32_t tox, int overtime) = 0; |
|
|
|
|
|
virtual int32_t move_by_block(int32_t dx, int overtime) = 0; |
|
|
|
|
|
virtual int32_t move_to_block(int32_t velocity, int32_t tox, int overtime) = 0; |
|
|
|
|
|
virtual int32_t move_by_block(int32_t velocity, int32_t dx, int overtime) = 0; |
|
|
|
|
|
virtual int32_t move_to_zero_block(int overtime) = 0; |
|
|
|
|
|
virtual int32_t move_to_zero_with_calibrate_block(int32_t x, int overtime) = 0; |
|
|
|
|
|
|
|
|
|
|
|
virtual int32_t read_version(version_t& version) = 0; |
|
|
|
|
|
virtual int32_t read_status(status_t& status) = 0; |
|
|
|
|
|
virtual int32_t read_detailed_status(detailed_status_t& debug_info) = 0; |
|
|
|
|
|
|
|
|
|
|
|
virtual int32_t read_pos(int32_t& pos) = 0; |
|
|
|
|
|
virtual int32_t read_pos() = 0; |
|
|
|
|
|
|
|
|
|
|
|
virtual bool read_zero_io_state() = 0; |
|
|
|
|
|
|
|
|
|
|
|
virtual int32_t set_base_param(const base_param_t& param) = 0; |
|
|
|
|
|
virtual int32_t get_base_param(base_param_t& param) = 0; |
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
m_cmdScheduler->registerCmd("xy_robot_ctrl_enable", [this](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { |
|
|
|
|
|
SCRIPT_CMDER_CHECK(argc == 3); |
|
|
|
|
|
|
|
|
|
|
|
int id = atoi(argv[1]); |
|
|
|
|
|
bool enable = atoi(argv[2]); |
|
|
|
|
|
|
|
|
|
|
|
I_XYRobotCtrlModule* module = findXYRobot(id); |
|
|
|
|
|
SCRIPT_CMDER_CHECK(module != nullptr); |
|
|
|
|
|
|
|
|
|
|
|
int32_t ack = module->enable(enable); |
|
|
|
|
|
ZLOGI(TAG, "ack:%d:%s", ack, err::error2str(ack)); |
|
|
|
|
|
}); |
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
m_cmdScheduler->registerCmd("step_motor_ctrl_is_busy", [this](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { |
|
|
m_cmdScheduler->registerCmd("step_motor_ctrl_is_busy", [this](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { |
|
|
CHECK_ARGC(1); |
|
|
CHECK_ARGC(1); |
|
|
|
|
|
|
|
@ -317,7 +259,18 @@ void StepMotorCtrlScriptCmderModule::regcmd() { // |
|
|
int32_t ack = module->flush(); |
|
|
int32_t ack = module->flush(); |
|
|
ZLOGI(TAG, "flush:%s(%d)", err::error2str(ack), ack); |
|
|
ZLOGI(TAG, "flush:%s(%d)", err::error2str(ack), ack); |
|
|
}); |
|
|
}); |
|
|
|
|
|
m_cmdScheduler->registerCmd("step_motor_ctrl_enable", [this](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { |
|
|
|
|
|
CHECK_ARGC(2); |
|
|
|
|
|
|
|
|
|
|
|
int id = atoi(argv[1]); |
|
|
|
|
|
int enable = atoi(argv[2]); |
|
|
|
|
|
|
|
|
|
|
|
I_StepMotorCtrlModule* module = findXYRobot(id); |
|
|
|
|
|
SCRIPT_CMDER_CHECK(module != nullptr); |
|
|
|
|
|
|
|
|
|
|
|
int32_t ack = module->enable(enable); |
|
|
|
|
|
ZLOGI(TAG, "flush:%s(%d)", err::error2str(ack), ack); |
|
|
|
|
|
}); |
|
|
m_cmdScheduler->registerCmd("step_motor_ctrl_factory_reset", [this](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { |
|
|
m_cmdScheduler->registerCmd("step_motor_ctrl_factory_reset", [this](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { |
|
|
CHECK_ARGC(1); |
|
|
CHECK_ARGC(1); |
|
|
|
|
|
|
|
@ -369,6 +322,28 @@ void StepMotorCtrlScriptCmderModule::regcmd() { // |
|
|
ZLOGI(TAG, "status.io_state :%d,%d,%d,%d,%d,%d,%d,%d", GET_BIT(status.io_state, 0), GET_BIT(status.io_state, 1), GET_BIT(status.io_state, 2), GET_BIT(status.io_state, 3), GET_BIT(status.io_state, 4), GET_BIT(status.io_state, 5), GET_BIT(status.io_state, 6), GET_BIT(status.io_state, 7)); |
|
|
ZLOGI(TAG, "status.io_state :%d,%d,%d,%d,%d,%d,%d,%d", GET_BIT(status.io_state, 0), GET_BIT(status.io_state, 1), GET_BIT(status.io_state, 2), GET_BIT(status.io_state, 3), GET_BIT(status.io_state, 4), GET_BIT(status.io_state, 5), GET_BIT(status.io_state, 6), GET_BIT(status.io_state, 7)); |
|
|
ZLOGI(TAG, "status.x :%d", status.x); |
|
|
ZLOGI(TAG, "status.x :%d", status.x); |
|
|
}); |
|
|
}); |
|
|
|
|
|
// virtual int32_t read_detailed_status(detailed_status_t& debug_info) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
m_cmdScheduler->registerCmd("step_motor_ctrl_read_detailed_status", [this](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { |
|
|
|
|
|
CHECK_ARGC(1); |
|
|
|
|
|
|
|
|
|
|
|
int id = atoi(argv[1]); |
|
|
|
|
|
|
|
|
|
|
|
I_StepMotorCtrlModule* module = findXYRobot(id); |
|
|
|
|
|
SCRIPT_CMDER_CHECK(module != nullptr); |
|
|
|
|
|
|
|
|
|
|
|
I_StepMotorCtrlModule::detailed_status_t status; |
|
|
|
|
|
int32_t ack = module->read_detailed_status(status); |
|
|
|
|
|
if (ack != 0) { |
|
|
|
|
|
ZLOGI(TAG, "read status:%s(%d)", err::error2str(ack), ack); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ZLOGI(TAG, "status.status :%d", status.status); |
|
|
|
|
|
ZLOGI(TAG, "status.io_state :%d,%d,%d,%d,%d,%d,%d,%d", GET_BIT(status.io_state, 0), GET_BIT(status.io_state, 1), GET_BIT(status.io_state, 2), GET_BIT(status.io_state, 3), GET_BIT(status.io_state, 4), GET_BIT(status.io_state, 5), GET_BIT(status.io_state, 6), GET_BIT(status.io_state, 7)); |
|
|
|
|
|
ZLOGI(TAG, "status.x :%d", status.x); |
|
|
|
|
|
ZLOGI(TAG, "status.last_exec_status :%d", status.last_exec_status); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
m_cmdScheduler->registerCmd("step_motor_ctrl_set_base_param", [this](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { |
|
|
m_cmdScheduler->registerCmd("step_motor_ctrl_set_base_param", [this](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { |
|
|
CHECK_MIN_ARGC(4); |
|
|
CHECK_MIN_ARGC(4); |
|
|