diff --git a/api/zi_motor.hpp b/api/zi_motor.hpp index 49c6da5..3bc7f7f 100644 --- a/api/zi_motor.hpp +++ b/api/zi_motor.hpp @@ -11,6 +11,7 @@ class ZIMotor { public: virtual ~ZIMotor() {} virtual int32_t motor_enable(int32_t enable) { return err::koperation_not_support; } + virtual int32_t motor_rotate(int32_t direction, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } virtual int32_t motor_move_by(int32_t distance, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } virtual int32_t motor_move_to(int32_t position, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } @@ -33,6 +34,11 @@ class ZIMotor { virtual int32_t motor_read_pos(int32_t* pos) { return err::koperation_not_support; } virtual int32_t motor_set_current_pos_by_change_shift(int32_t pos) { return err::koperation_not_support; } // 一般用于舵机 + virtual int32_t motor_easy_rotate(int32_t direction) { return err::koperation_not_support; }; + virtual int32_t motor_easy_move_by(int32_t distance) { return err::koperation_not_support; }; + virtual int32_t motor_easy_move_to(int32_t position) { return err::koperation_not_support; }; + virtual int32_t motor_easy_move_to_zero(int32_t direction) { return err::koperation_not_support; }; + // virtual int32_t motor_set_shaft(); // s32 pos, s32 speed, s32 torque, diff --git a/cmdid.hpp b/cmdid.hpp index 319cfe2..ef79313 100644 --- a/cmdid.hpp +++ b/cmdid.hpp @@ -56,6 +56,12 @@ typedef enum { virtual int32_t motor_read_pos(int32_t* pos) { return err::koperation_not_support; } virtual int32_t motor_set_current_pos_by_change_shift(int32_t pos) { return err::koperation_not_support; } // 一般用于舵机 + + virtual int32_t motor_easy_rotate(int32_t direction) { return err::koperation_not_support; }; + virtual int32_t motor_easy_move_by(int32_t distance) { return err::koperation_not_support; }; + virtual int32_t motor_easy_move_to(int32_t position) { return err::koperation_not_support; }; + virtual int32_t motor_easy_move_to_zero(int32_t direction) { return err::koperation_not_support; }; + #endif kmotor_enable = CMDID(2, 1), // para:{1}, ack:{} @@ -75,6 +81,11 @@ typedef enum { kmotor_move_to_torque = CMDID(2, 15), // para:{4,4,4}, ack:{} kmotor_calculated_pos_by_move_to_zero = CMDID(2, 16), // para:{}, ack:{} + kmotor_easy_rotate = CMDID(2, 17), // para:{4}, ack:{} + kmotor_easy_move_by = CMDID(2, 18), // para:{4}, ack:{} + kmotor_easy_move_to = CMDID(2, 19), // para:{4}, ack:{} + kmotor_easy_move_to_zero = CMDID(2, 20), // para:{1}, ack:{} + #if 0 virtual ~ZIXYMotor() {} virtual int32_t xymotor_enable(int32_t enable) { return err::koperation_not_support; } diff --git a/protocol_parser.cpp b/protocol_parser.cpp index 324ed72..d48812e 100644 --- a/protocol_parser.cpp +++ b/protocol_parser.cpp @@ -204,6 +204,11 @@ void ZIProtocolParser::onRceivePacket(zcr_cmd_header_t* rxcmd, uint8_t* data, in virtual int32_t motor_calculated_pos_by_move_to_zero() { return err::koperation_not_support; } + virtual int32_t motor_easy_rotate(int32_t direction) { return err::koperation_not_support; }; + virtual int32_t motor_easy_move_by(int32_t distance) { return err::koperation_not_support; }; + virtual int32_t motor_easy_move_to(int32_t position) { return err::koperation_not_support; }; + virtual int32_t motor_easy_move_to_zero(int32_t direction) { return err::koperation_not_support; }; + #endif PROCESS_PACKET_10(kmotor_enable, ZIMotor, motor_enable); PROCESS_PACKET_30(kmotor_rotate, ZIMotor, motor_rotate); @@ -221,6 +226,10 @@ void ZIProtocolParser::onRceivePacket(zcr_cmd_header_t* rxcmd, uint8_t* data, in PROCESS_PACKET_40(kmotor_motor_move_to_zero_backward_and_calculated_shift, ZIMotor, motor_move_to_zero_backward_and_calculated_shift); PROCESS_PACKET_30(kmotor_move_to_torque, ZIMotor, motor_move_to_torque); PROCESS_PACKET_00(kmotor_calculated_pos_by_move_to_zero, ZIMotor, motor_calculated_pos_by_move_to_zero); + PROCESS_PACKET_10(kmotor_easy_rotate, ZIMotor, motor_easy_rotate); + PROCESS_PACKET_10(kmotor_easy_move_by, ZIMotor, motor_easy_move_by); + PROCESS_PACKET_10(kmotor_easy_move_to, ZIMotor, motor_easy_move_to); + PROCESS_PACKET_10(kmotor_easy_move_to_zero, ZIMotor, motor_easy_move_to_zero); /******************************************************************************* * xymotor * diff --git a/protocol_proxy.cpp b/protocol_proxy.cpp index af14f9e..802f876 100644 --- a/protocol_proxy.cpp +++ b/protocol_proxy.cpp @@ -133,6 +133,10 @@ int32_t ZIProtocolProxy::module_enable(int32_t para0) { PROXY_IMPL_10(kmodule_en virtual int32_t motor_set_current_pos_by_change_shift(int32_t pos) { return err::koperation_not_support; } // 一般用于舵机 virtual int32_t motor_calculated_pos_by_move_to_zero() { return err::koperation_not_support; } + virtual int32_t motor_easy_rotate(int32_t direction) { return err::koperation_not_support; }; + virtual int32_t motor_easy_move_by(int32_t distance) { return err::koperation_not_support; }; + virtual int32_t motor_easy_move_to(int32_t position) { return err::koperation_not_support; }; + virtual int32_t motor_easy_move_to_zero(int32_t direction) { return err::koperation_not_support; }; #endif int32_t ZIProtocolProxy::motor_enable(int32_t para0) { PROXY_IMPL_10(kmotor_enable, 30); } @@ -157,6 +161,11 @@ int32_t ZIProtocolProxy::motor_move_to_zero_backward_and_calculated_shift(int32_ int32_t ZIProtocolProxy::motor_move_to_torque(int32_t para0, int32_t para1, int32_t para2) { PROXY_IMPL_30(kmotor_move_to_torque, 30); } int32_t ZIProtocolProxy::motor_calculated_pos_by_move_to_zero() { PROXY_IMPL_00(kmotor_calculated_pos_by_move_to_zero, 30); } +int32_t ZIProtocolProxy::motor_easy_rotate(int32_t para0) { PROXY_IMPL_10(kmotor_easy_rotate, 30); } +int32_t ZIProtocolProxy::motor_easy_move_by(int32_t para0) { PROXY_IMPL_10(kmotor_easy_move_by, 30); } +int32_t ZIProtocolProxy::motor_easy_move_to(int32_t para0) { PROXY_IMPL_10(kmotor_easy_move_to, 30); } +int32_t ZIProtocolProxy::motor_easy_move_to_zero(int32_t para0) { PROXY_IMPL_10(kmotor_easy_move_to_zero, 30); } + /******************************************************************************* * ZIXYMotor * *******************************************************************************/ diff --git a/protocol_proxy.hpp b/protocol_proxy.hpp index 55d6e22..cbbd6a5 100644 --- a/protocol_proxy.hpp +++ b/protocol_proxy.hpp @@ -87,6 +87,11 @@ class ZIProtocolProxy : public ZIMotor, // virtual int32_t motor_set_current_pos_by_change_shift(int32_t pos) { return err::koperation_not_support; } // 一锟斤拷锟斤拷锟节讹拷锟? virtual int32_t motor_calculated_pos_by_move_to_zero() { return err::koperation_not_support; } + virtual int32_t motor_easy_rotate(int32_t direction) { return err::koperation_not_support; }; + virtual int32_t motor_easy_move_by(int32_t distance) { return err::koperation_not_support; }; + virtual int32_t motor_easy_move_to(int32_t position) { return err::koperation_not_support; }; + virtual int32_t motor_easy_move_to_zero(int32_t direction) { return err::koperation_not_support; }; + #endif virtual int32_t motor_enable(int32_t enable) override; @@ -111,6 +116,11 @@ class ZIProtocolProxy : public ZIMotor, // virtual int32_t motor_move_to_torque(int32_t pos, int32_t torque, int32_t overtime) override; virtual int32_t motor_calculated_pos_by_move_to_zero() override; + virtual int32_t motor_easy_rotate(int32_t direction) override; + virtual int32_t motor_easy_move_by(int32_t distance) override; + virtual int32_t motor_easy_move_to(int32_t position) override; + virtual int32_t motor_easy_move_to_zero(int32_t direction) override; + /******************************************************************************* * ZIXYMotor * *******************************************************************************/ diff --git a/zmodule_device_manager.cpp b/zmodule_device_manager.cpp index 50404af..4ff43e5 100644 --- a/zmodule_device_manager.cpp +++ b/zmodule_device_manager.cpp @@ -89,6 +89,11 @@ int32_t ZModuleDeviceManager::module_start(uint16_t id) { PROXY_IMPL(ZIModule, m virtual int32_t motor_set_current_pos_by_change_shift(int32_t pos) { return err::koperation_not_support; } // 一锟斤拷锟斤拷锟节讹拷锟? virtual int32_t motor_calculated_pos_by_move_to_zero() { return err::koperation_not_support; } + virtual int32_t motor_easy_rotate(uint16_t id, int32_t direction); + virtual int32_t motor_easy_move_by(uint16_t id, int32_t distance); + virtual int32_t motor_easy_move_to(uint16_t id, int32_t position); + virtual int32_t motor_easy_move_to_zero(uint16_t id, int32_t direction); + #endif int32_t ZModuleDeviceManager::motor_enable(uint16_t id, int32_t enable) { PROXY_IMPL(ZIMotor, motor_enable, enable); } int32_t ZModuleDeviceManager::motor_rotate(uint16_t id, int32_t direction, int32_t motor_velocity, int32_t acc) { PROXY_IMPL(ZIMotor, motor_rotate, direction, motor_velocity, acc); } @@ -106,6 +111,10 @@ int32_t ZModuleDeviceManager::motor_move_to_zero_forward_and_calculated_shift(ui int32_t ZModuleDeviceManager::motor_move_to_zero_backward_and_calculated_shift(uint16_t id, int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { PROXY_IMPL(ZIMotor, motor_move_to_zero_backward_and_calculated_shift, findzerospeed, findzeroedge_speed, acc, overtime); } int32_t ZModuleDeviceManager::motor_move_to_torque(uint16_t id, int32_t pos, int32_t torque, int32_t overtime) { PROXY_IMPL(ZIMotor, motor_move_to_torque, pos, torque, overtime); } int32_t ZModuleDeviceManager::motor_calculated_pos_by_move_to_zero(uint16_t id) { PROXY_IMPL(ZIMotor, motor_calculated_pos_by_move_to_zero); } +int32_t ZModuleDeviceManager::motor_easy_rotate(uint16_t id, int32_t direction) { PROXY_IMPL(ZIMotor, motor_easy_rotate, direction); } +int32_t ZModuleDeviceManager::motor_easy_move_by(uint16_t id, int32_t distance) { PROXY_IMPL(ZIMotor, motor_easy_move_by, distance); } +int32_t ZModuleDeviceManager::motor_easy_move_to(uint16_t id, int32_t position) { PROXY_IMPL(ZIMotor, motor_easy_move_to, position); } +int32_t ZModuleDeviceManager::motor_easy_move_to_zero(uint16_t id, int32_t direction) { PROXY_IMPL(ZIMotor, motor_easy_move_to_zero, direction); } /******************************************************************************* * ZIXYMotor * *******************************************************************************/ diff --git a/zmodule_device_manager.hpp b/zmodule_device_manager.hpp index c4c99b1..a2044e4 100644 --- a/zmodule_device_manager.hpp +++ b/zmodule_device_manager.hpp @@ -131,6 +131,11 @@ class ZModuleDeviceManager { virtual int32_t motor_set_current_pos_by_change_shift(int32_t pos) { return err::koperation_not_support; } // 一锟斤拷锟斤拷锟节讹拷锟? virtual int32_t motor_calculated_pos_by_move_to_zero() { return err::koperation_not_support; } + virtual int32_t motor_easy_rotate(int32_t direction) { return err::koperation_not_support; }; + virtual int32_t motor_easy_move_by(int32_t distance) { return err::koperation_not_support; }; + virtual int32_t motor_easy_move_to(int32_t position) { return err::koperation_not_support; }; + virtual int32_t motor_easy_move_to_zero(int32_t direction) { return err::koperation_not_support; }; + #endif virtual int32_t motor_enable(uint16_t id, int32_t enable); virtual int32_t motor_rotate(uint16_t id, int32_t direction, int32_t motor_velocity, int32_t acc); @@ -148,6 +153,11 @@ class ZModuleDeviceManager { virtual int32_t motor_move_to_zero_backward_and_calculated_shift(uint16_t id, int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime); virtual int32_t motor_move_to_torque(uint16_t id, int32_t pos, int32_t torque, int32_t overtime); virtual int32_t motor_calculated_pos_by_move_to_zero(uint16_t id); + + virtual int32_t motor_easy_rotate(uint16_t id, int32_t direction); + virtual int32_t motor_easy_move_by(uint16_t id, int32_t distance); + virtual int32_t motor_easy_move_to(uint16_t id, int32_t position); + virtual int32_t motor_easy_move_to_zero(uint16_t id, int32_t direction); /******************************************************************************* * ZIXYMotor * diff --git a/zmodule_device_script_cmder_paser.cpp b/zmodule_device_script_cmder_paser.cpp index 5f43fea..b56211f 100644 --- a/zmodule_device_script_cmder_paser.cpp +++ b/zmodule_device_script_cmder_paser.cpp @@ -99,6 +99,7 @@ void ZModuleDeviceScriptCmderPaser::regfn() { virtual int32_t motor_move_to_zero_forward_and_calculated_shift(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) override; virtual int32_t motor_move_to_zero_backward_and_calculated_shift(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) override; virtual int32_t module_enable(uint16_t id, int32_t enable); + #endif PROCESS_PACKET_10(module_ping, "(mid)"); PROCESS_PACKET_10(module_stop, "(mid)"); @@ -128,7 +129,6 @@ void ZModuleDeviceScriptCmderPaser::regfn() { ack->acktype = ICmdParserACK::kAckType_buf; }); PROCESS_PACKET_20(module_enable, "(mid, enable)"); - #if 0 virtual int32_t motor_enable(int32_t enable) { return err::koperation_not_support; } virtual int32_t motor_rotate(int32_t direction, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } @@ -151,6 +151,11 @@ void ZModuleDeviceScriptCmderPaser::regfn() { virtual int32_t motor_read_pos(int32_t* pos) { return err::koperation_not_support; } virtual int32_t motor_set_current_pos_by_change_shift(int32_t pos) { return err::koperation_not_support; } // 一般用于舵机 virtual int32_t motor_calculated_pos_by_move_to_zero() { return err::koperation_not_support; } + + virtual int32_t motor_easy_rotate(uint16_t id, int32_t direction); + virtual int32_t motor_easy_move_by(uint16_t id, int32_t distance); + virtual int32_t motor_easy_move_to(uint16_t id, int32_t position); + virtual int32_t motor_easy_move_to_zero(uint16_t id, int32_t direction); #endif PROCESS_PACKET_20(motor_enable, "(mid, enable)"); @@ -175,6 +180,11 @@ void ZModuleDeviceScriptCmderPaser::regfn() { PROCESS_PACKET_50(motor_move_to_zero_backward_and_calculated_shift, "(mid, findzerospeed, findzeroedge_speed, acc, overtime)"); PROCESS_PACKET_10(motor_calculated_pos_by_move_to_zero, "(mid)"); + PROCESS_PACKET_20(motor_easy_rotate, "(mid, direction)"); + PROCESS_PACKET_20(motor_easy_move_by, "(mid, distance)"); + PROCESS_PACKET_20(motor_easy_move_to, "(mid, position)"); + PROCESS_PACKET_20(motor_easy_move_to_zero, "(mid, direction)"); + #if 0 virtual ~ZIXYMotor() {} virtual int32_t xymotor_enable(int32_t enable) { return err::koperation_not_support; }