diff --git a/README.md b/README.md index dbfc76e..744bbfd 100644 --- a/README.md +++ b/README.md @@ -235,12 +235,12 @@ cmake --build . -j ### 主要 API 接口 **控制接口** -- `fingerMove()` — 设置关节位置 +- `setPosition()` — 设置关节位置 - `setSpeed()` — 设置运动速度 - `setTorque()` — 设置扭矩限制 **状态查询** -- `getState()` — 获取关节状态 +- `getPosition()` — 获取关节状态 - `getSpeed()` — 获取当前速度 - `getTorque()` — 获取当前扭矩 @@ -418,3 +418,4 @@ Copyright (c) 2026 灵心巧手(北京)科技有限公司 --- **注意**:使用前请确保设备已正确连接并配置好通信接口。 + diff --git a/build.sh b/build.sh index eb4ea04..2ac4e0d 100755 --- a/build.sh +++ b/build.sh @@ -250,7 +250,7 @@ if [ "$INSTALL" = true ]; then purge_install_artifacts "$SUDO" # 通过 CMake 的 install 规则安装。对外公共头白名单、库文件、third_party 运行时 - # 依赖、cmake config target 等都由 linkerhand/CMakeLists.txt 统一控制, + # 依赖、cmake config target 等都由 CMakeLists.txt 统一控制, # 不要在这里再手动 cp 头文件——会绕过白名单把全部内部头释放出去。 print_info "执行 cmake --install (受白名单约束)..." $SUDO cmake --install . --prefix "$INSTALL_PREFIX" @@ -288,7 +288,7 @@ if [ "$INSTALL" = true ]; then echo "使用示例(推荐 find_package):" echo " find_package(linkerhand-cpp-sdk CONFIG REQUIRED)" echo " target_link_libraries( PRIVATE LinkerHand::linkerhand_cpp_sdk)" - echo " 参考工程: linkerhand/examples/standalone/" + echo " 参考工程: examples/standalone/" echo "" INC="$INSTALL_PREFIX/include/linkerhand-cpp-sdk" echo "或手动指定(头按子目录发布):" diff --git a/docs/API-Reference.md b/docs/API-Reference.md index fea28df..66c2516 100644 --- a/docs/API-Reference.md +++ b/docs/API-Reference.md @@ -40,7 +40,7 @@ LinkerHandApi 类的构造函数,用于初始化 Linker 机械手 API。 ### 设置关节位置 ```cpp -void fingerMove(const std::vector &pose); +void setPosition(const std::vector &pose); ``` **Description**: 设置关节的目标位置,用于控制手指的运动。 @@ -66,7 +66,7 @@ void fingerMove(const std::vector &pose); ### 设置关节位置 ```cpp -void fingerMoveArc(const std::vector &pose); +void setPositionArc(const std::vector &pose); ``` **Description**: 设置关节的目标位置,用于控制手指的运动。 @@ -127,7 +127,7 @@ std::vector getSpeed(); ### 获取当前关节状态 ```cpp -std::vector getState(); +std::vector getPosition(); ``` **Description**: 获取当前关节的状态信息。 @@ -138,7 +138,7 @@ std::vector getState(); ### 获取当前关节状态 ```cpp -std::vector getStateArc(); +std::vector getPositionArc(); ``` **Description**: 获取当前关节的状态信息。 @@ -269,13 +269,13 @@ int main() { std::cout << "执行动作:握拳" << std::endl; std::vector fist_pose = {120, 60, 0, 0, 0, 0, 255, 255, 255, 51}; - hand.fingerMove(fist_pose); + hand.setPosition(fist_pose); std::this_thread::sleep_for(std::chrono::seconds(1)); std::cout << "-------------------------------------------" << std::endl; std::cout << "执行动作:张开" << std::endl; std::vector open_pose = {255, 104, 255, 255, 255, 255, 255, 255, 255, 71}; - hand.fingerMove(open_pose); + hand.setPosition(open_pose); std::this_thread::sleep_for(std::chrono::seconds(1)); std::cout << "-------------------------------------------" << std::endl; @@ -297,3 +297,4 @@ int main() { - 如果有任何问题或需要进一步支持,请联系 [https://linkerbot.cn/aboutUs](https://linkerbot.cn/aboutUs)。 --- + diff --git a/docs/FAQ.md b/docs/FAQ.md index 897e17c..7b6a721 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -1,83 +1,16 @@ # 常见问题解答 -本文档面向 `pack.sh` 生成的 `linkerhand-cpp-sdk/` 发布包,以及从 `linkerhand/` 源码构建安装 SDK 的开发者。 - -## 安装与发布包 - -### Q1: 发布包和源码仓库是什么关系? - -`linkerhand/` 是唯一主开发工作区,`./pack.sh pack` 会基于它生成可直接发布的 `linkerhand-cpp-sdk/`。发布包内包含预编译库、示例、示教器、文档和必要的第三方依赖。 - -### Q2: 发布包解压后怎么快速验证? - -Linux/macOS: - -```bash -cd linkerhand-cpp-sdk -mkdir build && cd build -cmake .. -cmake --build . -j$(nproc) -./bin/test_l10_can_0 -``` - -Windows MinGW: - -```cmd -cd linkerhand-cpp-sdk -mkdir build -cd build -cmake -G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=mingw32-make .. -mingw32-make -j -build\bin\test_l10_can_0.exe -``` - -### Q3: 发布包里的头文件为什么比最小 API 入口多? - -发布包不仅面向统一 API,也要支持 `examples/`、`hand_teach_pendant/` 和部分需要直连通信层的客户工程,所以会一起发布 `include/communication/` 下的通信相关头。新项目优先从 `LinkerHandApi.h` 开始接入。 - -### Q4: 安装后 `find_package` 应该怎么接? - -从源码执行 `cmake --install` 或 `./build.sh -i` 后,可直接在下游工程里写: - -```cmake -find_package(linkerhand-cpp-sdk CONFIG REQUIRED) -target_link_libraries(my_app PRIVATE LinkerHand::linkerhand_cpp_sdk) -``` - -这条路径适合系统安装后的二次开发;如果只是消费发布包,直接用发布包根目录的 `CMakeLists.txt` 构建 examples 或参考 `README.md` 手动链接即可。 - -## 构建与运行 - -### Q5: 发布包里的 `build.sh` / `build.bat` 能做什么? - -它们主要服务于持有源码工程的开发者,用于重建、安装或卸载 SDK。客户从发布包消费预编译库时,通常不需要执行 `-b` / `-i`,直接用 `cmake ..` 构建 examples 即可。 - -### Q6: `--skip-tests` 为什么没有关闭 examples? - -当前 `build.sh` 透传的是 `-DBUILD_TESTS=OFF`,这是 examples 子目录内部开关,不影响顶层 `BUILD_EXAMPLES` / `BUILD_PENDANT`。如果只想构建 SDK,请直接使用: - -```bash -cmake -S linkerhand -B linkerhand/build -DBUILD_EXAMPLES=OFF -DBUILD_PENDANT=OFF -cmake --build linkerhand/build -j -``` - -### Q7: 哪些平台是当前主要验证目标? - -- Linux `x86_64` -- Linux `aarch64` -- Windows `x64`(MinGW / MSVC 导入库) - -其中 O20 的 CAN-FD 示例目前主要面向 Linux `x86_64`。 +本文档面向 `linkerhand-cpp-sdk/` 发布包,以及从 repository root 源码构建安装 SDK 的开发者。 ## 通信与接口 -### Q8: CAN、Modbus、EtherCAT 怎么选? +### Q1: CAN、Modbus、EtherCAT 怎么选? - 统一 API 层通过 `COMM_TYPE::CAN`、`COMM_TYPE::MODBUS`、`COMM_TYPE::ETHERCAT` 选择通信方式。 - 不同手型支持范围不同,具体以 `README.md` 型号表和现有 examples 为准。 - 需要自己管理底层总线时,优先参考 `examples/test_*` 和 `hand_teach_pendant/src/HandController.cpp` 的实际用法。 -### Q9: Linux 下 CAN 默认怎么配? +### Q2: Linux 下 CAN 默认怎么配? ```bash sudo modprobe can @@ -89,18 +22,14 @@ ip link show can0 如果示例使用了 `can1` 或其他设备名,请按现场总线名替换。 -### Q10: Windows 下还需要额外 DLL 吗? +### Q3: Windows 下还需要额外 DLL 吗? 需要。发布包已经带上 `third_party/PCAN_Basic/` 和对应导入库;客户工程除了 SDK 自身 DLL 外,还要确保 `PCANBasic.dll` 与可执行文件同目录,或能被系统搜索路径找到。 ## 文档与支持 -### Q11: 先看哪个文档最合适? +### Q4: 先看哪个文档最合适? - 想了解总体接入方式:看 `README.md` - 想确认接口签名:看 `docs/API-Reference.md` - 遇到构建或运行问题:看 `docs/TROUBLESHOOTING.md` - -### Q12: 旧版参考目录还能直接当文档源吗? - -不能。旧版目录只适合做历史对照,内容可能与当前命名空间、打包布局、构建开关不一致。对外发布请以 `linkerhand/` 和 `pack.sh` 产物为准。 diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md index b453d63..8658ceb 100644 --- a/docs/TROUBLESHOOTING.md +++ b/docs/TROUBLESHOOTING.md @@ -17,8 +17,8 @@ pkg-config --modversion libusb-1.0 如果构建网页示教器,还要确认 `Boost::system` 可用。只想先验证 SDK 本体时,可显式关闭示例和示教器: ```bash -cmake -S linkerhand -B linkerhand/build -DBUILD_EXAMPLES=OFF -DBUILD_PENDANT=OFF -cmake --build linkerhand/build -j +cmake -S . -B build -DBUILD_EXAMPLES=OFF -DBUILD_PENDANT=OFF +cmake --build build -j ``` ### 2. 找不到 `LinkerHandApi.h` 或 `CommFactory.h`(旧名 `CanBusFactory.h`) @@ -96,7 +96,7 @@ O20 的 CAN-FD 主要面向 Linux `x86_64`。在 ARM + Ubuntu 18 及以下环境 `USE_ETHERCAT` 默认关闭。只有在现场确实需要时再打开: ```bash -cmake -S linkerhand -B linkerhand/build -DUSE_ETHERCAT=ON +cmake -S . -B build -DUSE_ETHERCAT=ON ``` 打开后仍失败,先检查系统是否已安装 `libethercat` 和对应 `pkg-config` 信息,而不是直接修改源码。 @@ -123,10 +123,10 @@ cmake -S linkerhand -B linkerhand/build -DUSE_ETHERCAT=ON ### 11. 为什么不再从旧版参考目录复制文档? -旧版目录长期手工维护,很多内容与当前仓库状态不再一致。现在的发布文档都应从 `linkerhand/docs/` 输出,由 `pack.sh` 直接复制,避免一边改代码、一边忘记同步旧目录。 +旧版目录长期手工维护,很多内容与当前仓库状态不再一致。现在的发布文档都应从 `docs/` 输出,由 `pack.sh` 直接复制,避免一边改代码、一边忘记同步旧目录。 ## 排查原则 - 连续编译或运行失败两次以上,先回看日志和环境,不继续盲试。 - 先检查平台、依赖、设备名、库路径,再怀疑源码逻辑。 -- 对外发布只以 `linkerhand/` 当前内容和 `pack.sh` 生成物为准。 +- 对外发布只以 repository root 当前内容和 `pack.sh` 生成物为准。 diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index b1d9777..5ea3403 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -115,7 +115,8 @@ else() link_directories(${LIBCANBUS_DIR}) # 设置运行时库路径,确保运行时能找到 libcanbus.so 与 SDK .so - set(CMAKE_INSTALL_RPATH "${LIBCANBUS_DIR}") + # $ORIGIN: 让 exe 在自身所在目录(bin/)查找,从而拿到 copy_dependencies 复制过来的 SDK .so + set(CMAKE_INSTALL_RPATH "\$ORIGIN" "${LIBCANBUS_DIR}") if(LINKERHAND_LIB_DIR) list(APPEND CMAKE_INSTALL_RPATH "${LINKERHAND_LIB_DIR}") endif() @@ -153,6 +154,18 @@ function(copy_dependencies target) "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COMMENT "Copying linkerhand_cpp_sdk runtime to output directory" ) + # Unix: 复制只拿到 .so.,exe NEEDED 的是 .so.(由 SONAME 决定), + # 必须在 bin/ 里同步建出 SONAME 软链,否则 ld.so 找不到。 + if(UNIX AND NOT APPLE) + add_custom_command(TARGET ${target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E remove -f + "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$" + COMMAND ${CMAKE_COMMAND} -E create_symlink + "$" + "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$" + COMMENT "Creating SONAME symlink for linkerhand_cpp_sdk in output directory" + ) + endif() elseif(LINKERHAND_DLL AND EXISTS "${LINKERHAND_DLL}") add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different diff --git a/examples/L10/action_group_show.cpp b/examples/L10/action_group_show.cpp index f4843ff..fbec178 100644 --- a/examples/L10/action_group_show.cpp +++ b/examples/L10/action_group_show.cpp @@ -428,7 +428,7 @@ int main() { while (running) { std::vector action = showLeft(); - hand.fingerMove(action); + hand.setPosition(action); std::this_thread::sleep_for(std::chrono::milliseconds(33)); } diff --git a/examples/linker_hand_example.cpp b/examples/linker_hand_example.cpp index 2f5ef27..09c371d 100644 --- a/examples/linker_hand_example.cpp +++ b/examples/linker_hand_example.cpp @@ -281,7 +281,7 @@ void interactiveMode(LinkerHandApi &hand) case 8: for (size_t i = 0; i < 10; i++) { - std::cout << bytesToHex(hand.getState()) << std::endl; + std::cout << bytesToHex(hand.getPosition()) << std::endl; std::this_thread::sleep_for(std::chrono::milliseconds(100)); } break; @@ -290,7 +290,7 @@ void interactiveMode(LinkerHandApi &hand) std::cout << "L6 - Execute action" << std::endl; for (size_t i = 0; i < 10; i++) { for (const auto &pose : L6_POSE_1) { - hand.fingerMove(pose); + hand.setPosition(pose); std::this_thread::sleep_for(std::chrono::milliseconds(150)); } std::this_thread::sleep_for(std::chrono::milliseconds(150)); @@ -298,7 +298,7 @@ void interactiveMode(LinkerHandApi &hand) } else if (hand.handJoint_ == LINKER_HAND::O6) { std::cout << "O6 - Execute action" << std::endl; for (const auto &pose : L6_POSE_1) { - hand.fingerMove(pose); + hand.setPosition(pose); std::this_thread::sleep_for(std::chrono::milliseconds(1200)); } } else if (hand.handJoint_ == LINKER_HAND::L7) { @@ -308,12 +308,12 @@ void interactiveMode(LinkerHandApi &hand) std::cout << "L7 - Execute action - Make a fist" << std::endl; for (const auto &pose : L7_POSE_1) { - hand.fingerMove(pose); + hand.setPosition(pose); std::this_thread::sleep_for(std::chrono::seconds(1)); // 等待1秒 } //--------------------------------------------------------- std::cout << "L7 - Execute action - Open hand" << std::endl; - hand.fingerMove(L7_POSE_OPEN); + hand.setPosition(L7_POSE_OPEN); std::this_thread::sleep_for(std::chrono::seconds(1)); //--------------------------------------------------------- } @@ -325,30 +325,30 @@ void interactiveMode(LinkerHandApi &hand) std::cout << "L10 - Execute action - Finger cycle bending" << std::endl; for (const auto &pose : L10_POSE_1) { - hand.fingerMove(pose); + hand.setPosition(pose); std::this_thread::sleep_for(std::chrono::seconds(1)); } //--------------------------------------------------------- std::cout << "L10 - Execute action - Thumb and Circular Fingers" << std::endl; for (const auto &pose : L10_POSE_2) { - hand.fingerMove(pose); + hand.setPosition(pose); std::this_thread::sleep_for(std::chrono::seconds(1)); } //--------------------------------------------------------- std::cout << "L10 - Execute action - Finger side swing" << std::endl; for (const auto &pose : L10_POSE_3) { - hand.fingerMove(pose); + hand.setPosition(pose); std::this_thread::sleep_for(std::chrono::seconds(1)); } //--------------------------------------------------------- std::cout << "L10 - Execute action - Make a fist" << std::endl; - hand.fingerMove(L10_POSE_CLOSE); + hand.setPosition(L10_POSE_CLOSE); std::this_thread::sleep_for(std::chrono::seconds(1)); //--------------------------------------------------------- std::cout << "L10 - Execute action - Open hand" << std::endl; - hand.fingerMove(L10_POSE_OPEN); + hand.setPosition(L10_POSE_OPEN); std::this_thread::sleep_for(std::chrono::seconds(1)); //--------------------------------------------------------- } @@ -358,12 +358,12 @@ void interactiveMode(LinkerHandApi &hand) //--------------------------------------------------------- std::cout << "L20 - Execute action - Make a fist" << std::endl; std::vector L20_POSE_CLOSE = {69, 0, 0, 0, 0, 32, 10, 100, 180, 240, 145, 255, 255, 255, 255, 0, 0, 0, 0, 0}; - hand.fingerMove(L20_POSE_CLOSE); + hand.setPosition(L20_POSE_CLOSE); std::this_thread::sleep_for(std::chrono::seconds(1)); //--------------------------------------------------------- std::cout << "L20 - Execute action - Open hand" << std::endl; std::vector L20_POSE_OPEN = {255, 255, 230, 255, 255, 255, 10, 100, 180, 240, 245, 255, 255, 255, 255, 255, 255, 255, 255, 255}; - hand.fingerMove(L20_POSE_OPEN); + hand.setPosition(L20_POSE_OPEN); std::this_thread::sleep_for(std::chrono::seconds(1)); } else if (hand.handJoint_ == LINKER_HAND::L25 || hand.handJoint_ == LINKER_HAND::L21) @@ -382,18 +382,18 @@ void interactiveMode(LinkerHandApi &hand) std::vector pos2_2 = {230, 0, 0, 15, 5, 42, 55, 80, 210, 202, 85, 0, 0, 0, 0, 90, 0, 40, 35, 5, 120, 0, 5, 0, 0}; std::cout << "L25/L21 - Execute action - Make a fist" << std::endl; - hand.fingerMove(pos2_1); + hand.setPosition(pos2_1); std::this_thread::sleep_for(std::chrono::seconds(1)); - hand.fingerMove(pos2_2); + hand.setPosition(pos2_2); std::this_thread::sleep_for(std::chrono::seconds(1)); std::cout << "L25/L21 - Execute action - Open hand" << std::endl; - hand.fingerMove(pos1_1); + hand.setPosition(pos1_1); std::this_thread::sleep_for(std::chrono::seconds(1)); - // hand.fingerMove(pos1_2); + // hand.setPosition(pos1_2); // std::this_thread::sleep_for(std::chrono::seconds(1)); - hand.fingerMove(pos1_3); + hand.setPosition(pos1_3); std::this_thread::sleep_for(std::chrono::seconds(1)); } else if (hand.handJoint_ == LINKER_HAND::G20) @@ -402,15 +402,15 @@ void interactiveMode(LinkerHandApi &hand) //--------------------------------------------------------- std::cout << "G20 - Execute action - Make a fist" << std::endl; std::vector G20_POSE_CLOSE_1 = {255, 0, 0, 0, 0,255,255,178,84,0,255,255,0,0,0,0}; - hand.fingerMove(G20_POSE_CLOSE_1); + hand.setPosition(G20_POSE_CLOSE_1); std::this_thread::sleep_for(std::chrono::milliseconds(50)); std::vector G20_POSE_CLOSE_2 = {117, 0, 0, 0, 0,47,255,178,84,0,115,104,0,0,0,0}; - hand.fingerMove(G20_POSE_CLOSE_2); + hand.setPosition(G20_POSE_CLOSE_2); std::this_thread::sleep_for(std::chrono::seconds(1)); //--------------------------------------------------------- std::cout << "G20 - Execute action - Open hand" << std::endl; std::vector G20_POSE_OPEN = {255, 255, 255, 255, 255, 255, 255, 172, 74, 0, 255, 255, 255, 255, 255, 255}; - hand.fingerMove(G20_POSE_OPEN); + hand.setPosition(G20_POSE_OPEN); std::this_thread::sleep_for(std::chrono::seconds(1)); } else if (hand.handJoint_ == LINKER_HAND::O20) diff --git a/examples/test.cpp b/examples/test.cpp index 33a9ecf..4f0dae5 100644 --- a/examples/test.cpp +++ b/examples/test.cpp @@ -93,7 +93,7 @@ int main() { } std::cout << std::endl; - std::vector state = hand.getState(); + std::vector state = hand.getPosition(); std::cout << "state size:" << state.size() << std::endl; for (size_t j = 0; j < state.size(); j++) { std::cout << (int)state[j] << " "; diff --git a/examples/test_0.cpp b/examples/test_0.cpp index 47c2b2a..58b38d2 100644 --- a/examples/test_0.cpp +++ b/examples/test_0.cpp @@ -37,13 +37,13 @@ int main() { std::cout << "执行动作:握拳" << std::endl; std::vector fist_pose = {120, 60, 0, 0, 0, 0, 255, 255, 255, 51}; - hand.fingerMove(fist_pose); + hand.setPosition(fist_pose); std::this_thread::sleep_for(std::chrono::seconds(1)); std::cout << "-------------------------------------------" << std::endl; std::cout << "执行动作:张开" << std::endl; std::vector open_pose = {255, 104, 255, 255, 255, 255, 255, 255, 255, 71}; - hand.fingerMove(open_pose); + hand.setPosition(open_pose); std::this_thread::sleep_for(std::chrono::seconds(1)); std::cout << "-------------------------------------------" << std::endl; diff --git a/examples/test_g20_can_0.cpp b/examples/test_g20_can_0.cpp index a736a4c..ffd1589 100644 --- a/examples/test_g20_can_0.cpp +++ b/examples/test_g20_can_0.cpp @@ -55,17 +55,17 @@ int main(int argc, char *argv[]) { // G20 握拳动作 std::cout << "G20 - Execute action - Make a fist" << std::endl; std::vector G20_POSE_CLOSE_1 = {255, 0, 0, 0, 0, 255, 255, 178, 84, 0, 255, 255, 0, 0, 0, 0}; - hand.fingerMove(G20_POSE_CLOSE_1); + hand.setPosition(G20_POSE_CLOSE_1); std::this_thread::sleep_for(std::chrono::milliseconds(50)); std::vector G20_POSE_CLOSE_2 = {117, 0, 0, 0, 0, 47, 255, 178, 84, 0, 115, 104, 0, 0, 0, 0}; - hand.fingerMove(G20_POSE_CLOSE_2); + hand.setPosition(G20_POSE_CLOSE_2); std::this_thread::sleep_for(std::chrono::seconds(1)); // G20 张开动作 std::cout << "G20 - Execute action - Open hand" << std::endl; std::vector G20_POSE_OPEN = {255, 255, 255, 255, 255, 255, 255, 172, 74, 0, 255, 255, 255, 255, 255, 255}; - hand.fingerMove(G20_POSE_OPEN); + hand.setPosition(G20_POSE_OPEN); std::this_thread::sleep_for(std::chrono::seconds(1)); // 循环测试 @@ -74,14 +74,14 @@ int main(int argc, char *argv[]) { // 握拳 std::cout << "Make a fist..." << std::endl; - hand.fingerMove(G20_POSE_CLOSE_1); + hand.setPosition(G20_POSE_CLOSE_1); std::this_thread::sleep_for(std::chrono::milliseconds(50)); - hand.fingerMove(G20_POSE_CLOSE_2); + hand.setPosition(G20_POSE_CLOSE_2); std::this_thread::sleep_for(std::chrono::seconds(1)); // 张开 std::cout << "Open hand..." << std::endl; - hand.fingerMove(G20_POSE_OPEN); + hand.setPosition(G20_POSE_OPEN); std::this_thread::sleep_for(std::chrono::seconds(1)); } diff --git a/examples/test_g20_can_1.cpp b/examples/test_g20_can_1.cpp index d752a5e..077ad2e 100644 --- a/examples/test_g20_can_1.cpp +++ b/examples/test_g20_can_1.cpp @@ -112,7 +112,7 @@ void threadGetParameters(LinkerHandApi& hand, int iteration) { }); auto future_state = std::async(std::launch::async, [&hand]() { - return hand.getState(); + return hand.getPosition(); }); // 等待所有结果 @@ -198,16 +198,16 @@ void threadMotionControl(LinkerHandApi& hand, int iteration) { // G20 握拳动作(两步) std::vector G20_POSE_CLOSE_1 = {255, 0, 0, 0, 0, 255, 255, 178, 84, 0, 255, 255, 0, 0, 0, 0}; - hand.fingerMove(G20_POSE_CLOSE_1); + hand.setPosition(G20_POSE_CLOSE_1); std::this_thread::sleep_for(std::chrono::milliseconds(50)); std::vector G20_POSE_CLOSE_2 = {117, 0, 0, 0, 0, 47, 255, 178, 84, 0, 115, 104, 0, 0, 0, 0}; - hand.fingerMove(G20_POSE_CLOSE_2); + hand.setPosition(G20_POSE_CLOSE_2); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); // G20 张开动作 std::vector G20_POSE_OPEN = {255, 255, 255, 255, 255, 255, 255, 172, 74, 0, 255, 255, 255, 255, 255, 255}; - hand.fingerMove(G20_POSE_OPEN); + hand.setPosition(G20_POSE_OPEN); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); auto end = std::chrono::steady_clock::now(); diff --git a/examples/test_l10.cpp b/examples/test_l10.cpp index 8b2715a..8563a48 100644 --- a/examples/test_l10.cpp +++ b/examples/test_l10.cpp @@ -35,11 +35,11 @@ int main() { // 执行一次握拳动作 std::vector fist_pose = {101, 60, 0, 0, 0, 0, 255, 255, 255, 51}; - hand.fingerMove(fist_pose); + hand.setPosition(fist_pose); std::this_thread::sleep_for(std::chrono::seconds(1)); // 读取并打印当前状态 - std::vector state = hand.getState(); + std::vector state = hand.getPosition(); std::cout << "state size: " << state.size() << std::endl; for (size_t i = 0; i < state.size(); ++i) { std::cout << (int)state[i] << " "; diff --git a/examples/test_l10_can_0.cpp b/examples/test_l10_can_0.cpp index d6d40c8..a2ed230 100644 --- a/examples/test_l10_can_0.cpp +++ b/examples/test_l10_can_0.cpp @@ -99,7 +99,7 @@ int main() { } std::cout << std::endl; - std::vector state = hand.getState(); + std::vector state = hand.getPosition(); std::cout << "state size:" << state.size() << std::endl; for (size_t j = 0; j < state.size(); j++) { std::cout << (int)state[j] << " "; diff --git a/examples/test_l10_can_1.cpp b/examples/test_l10_can_1.cpp index 1f52501..1a3b6e7 100644 --- a/examples/test_l10_can_1.cpp +++ b/examples/test_l10_can_1.cpp @@ -113,7 +113,7 @@ void threadGetParameters(LinkerHandApi& hand, int iteration) { }); auto future_state = std::async(std::launch::async, [&hand]() { - return hand.getState(); + return hand.getPosition(); }); // 等待所有结果 @@ -212,12 +212,12 @@ void threadMotionControl(LinkerHandApi& hand, int iteration) { // 握拳 std::vector fist_pose = {101, 60, 0, 0, 0, 0, 255, 255, 255, 51}; - hand.fingerMove(fist_pose); + hand.setPosition(fist_pose); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); // 张开 std::vector open_pose = {255, 104, 255, 255, 255, 255, 255, 255, 255, 71}; - hand.fingerMove(open_pose); + hand.setPosition(open_pose); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); auto end = std::chrono::steady_clock::now(); diff --git a/examples/test_l10_modbus.cpp b/examples/test_l10_modbus.cpp index ac992a9..dc93df4 100644 --- a/examples/test_l10_modbus.cpp +++ b/examples/test_l10_modbus.cpp @@ -111,7 +111,7 @@ int main(int argc, char* argv[]) { for (size_t i = 0; i < poses.size(); ++i) { std::cout << "动作 " << (i + 1) << "/" << poses.size() << ": "; printVector("位置", poses[i]); - hand.fingerMove(poses[i]); + hand.setPosition(poses[i]); std::this_thread::sleep_for(std::chrono::milliseconds(500)); } std::cout << std::endl; @@ -121,7 +121,7 @@ int main(int argc, char* argv[]) { std::cout << "测试 4: 读取当前状态" << std::endl; std::cout << "----------------------------------------" << std::endl; for (int i = 0; i < 5; ++i) { - std::vector state = hand.getState(); + std::vector state = hand.getPosition(); if (!state.empty()) { printVector("当前关节位置", state); } else { diff --git a/examples/test_l20_can_0.cpp b/examples/test_l20_can_0.cpp index e2a170f..bce3a0a 100644 --- a/examples/test_l20_can_0.cpp +++ b/examples/test_l20_can_0.cpp @@ -28,10 +28,15 @@ std::string getCurrentTime() { return oss.str(); } +double scale_value(double original_value, double a_min, double a_max, double b_min, double b_max) +{ + return (original_value - a_min) * (b_max - b_min) / (a_max - a_min) + b_min; +} + int main() { try { // 初始化灵巧手 - LinkerHandApi hand(LINKER_HAND::L20, HAND_TYPE::LEFT); + LinkerHandApi hand(LINKER_HAND::L20, HAND_TYPE::RIGHT); // 创建 CAN 总线对象 std::shared_ptr bus = Communication::CommFactory::createCanBus("can0", 1000000); @@ -39,6 +44,7 @@ int main() { hand.setCanTxCallback([bus](uint32_t can_id, const uint8_t *data, uintptr_t data_len) -> int32_t { static int tx_count = 0; tx_count++; + /* std::cout << "\033[32m[TX #" << tx_count << "]\033[0m " << getCurrentTime() << " | CAN_ID: 0x" << std::hex << std::setw(8) << std::setfill('0') << can_id @@ -49,7 +55,7 @@ int main() { std::cout << std::hex << std::setw(2) << std::setfill('0') << (int)data[i] << " "; } std::cout << std::dec << std::endl; - +*/ std::vector data_vec(data, data + data_len); bus->send(data_vec, can_id); return 0; @@ -66,68 +72,117 @@ int main() { static int rx_count = 0; rx_count++; + /* std::cout << "\033[34m[RX #" << rx_count << "]\033[0m " << getCurrentTime() << " | CAN_ID: 0x" << std::hex << std::setw(8) << std::setfill('0') << frame.can_id << std::dec << " (" << frame.can_id << ")" << " | DLC: " << (int)frame.can_dlc << " | Data: "; + for (int i = 0; i < frame.can_dlc; i++) { std::cout << std::hex << std::setw(2) << std::setfill('0') << (int)frame.data[i] << " "; } std::cout << std::dec << std::endl; + */ return 0; }); - for (size_t i = 0; i < 1; ++i) { - std::cout << hand.getVersion() << std::endl; - - std::vector torque = hand.getTorque(); - std::cout << "torque size:" << torque.size() << std::endl; - for (size_t j = 0; j < torque.size(); j++) { - std::cout << (int)torque[j] << " "; - } - std::cout << std::endl; + // for (size_t i = 0; i < 1; ++i) { + // std::cout << hand.getVersion() << std::endl; + + // std::vector torque = hand.getTorque(); + // std::cout << "torque size:" << torque.size() << std::endl; + // for (size_t j = 0; j < torque.size(); j++) { + // std::cout << (int)torque[j] << " "; + // } + // std::cout << std::endl; + + // std::vector speed = hand.getSpeed(); + // std::cout << "speed size:" << speed.size() << std::endl; + // for (size_t j = 0; j < speed.size(); j++) { + // std::cout << (int)speed[j] << " "; + // } + // std::cout << std::endl; + + // std::vector state = hand.getPosition(); + // std::cout << "state size:" << state.size() << std::endl; + // for (size_t j = 0; j < state.size(); j++) { + // std::cout << (int)state[j] << " "; + // } + // std::cout << std::endl; + + // std::vector>> touch_mats = hand.getForce(); + // // 手指名称表,顺序对应 touch_mats[0..4] + // const std::array finger_name = { + // "THUMB_TOUCH", "INDEX_TOUCH", "MIDDLE_TOUCH", "RING_TOUCH", "LITTLE_TOUCH" + // }; + // for (size_t n = 0; n < touch_mats.size(); ++n) { + // std::cout << finger_name[n] << ":\n"; + // for (const auto &row : touch_mats[n]) { + // for (uint8_t val : row) + // std::cout << std::setw(2) << static_cast(val) << ' '; + // std::cout << '\n'; + // } + // std::cout << '\n'; + // } + + // // 握拳 + // std::vector fist_pose = {74, 0, 0, 0, 0, 176, 52, 120, 150, 201, 198, 0, 0, 0, 0, 254, 0, 0, 0, 0, 100, 0, 0, 0, 0}; + // hand.setPosition(fist_pose); + // std::this_thread::sleep_for(std::chrono::seconds(1)); + + // // 张开 + // std::vector open_pose = {74, 254, 254, 254, 253, 176, 52, 120, 150, 201, 198, 0, 0, 0, 0, 254, 0, 0, 0, 0, 254, 255, 255, 255, 250}; + // hand.setPosition(open_pose); + // std::this_thread::sleep_for(std::chrono::seconds(1)); + // } + + + std::cout << hand.getVersion() << std::endl; + + // 张开 + std::vector open_pose = {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255}; + hand.setPosition(open_pose); + + // std::vector op_arc = {0.0, 0.0, 0.0, 0.0, 0.0, -0.5, -0.18, 0.03, 0.11, 0.18, 0.15, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + // hand.setPositionArc(op_arc); + std::this_thread::sleep_for(std::chrono::seconds(1)); + + + std::vector state1 = hand.getPosition(); + std::cout << "state1 size:" << state1.size() << std::endl; + for (size_t j = 0; j < state1.size(); j++) { + std::cout << (int)state1[j] << " "; + } + std::cout << std::endl; + + + + + + std::vector state2 = hand.testPositionArc(open_pose); + std::cout << "state1 size:" << state2.size() << std::endl; + for (size_t j = 0; j < state2.size(); j++) { + std::cout << (float)state2[j] << " "; + } + std::cout << std::endl; + + + + std::vector state = hand.getPositionArc(); + std::cout << "state size:" << state.size() << std::endl; + for (size_t j = 0; j < state.size(); j++) { + std::cout << (float)state[j] << " "; + } + std::cout << std::endl; - std::vector speed = hand.getSpeed(); - std::cout << "speed size:" << speed.size() << std::endl; - for (size_t j = 0; j < speed.size(); j++) { - std::cout << (int)speed[j] << " "; - } - std::cout << std::endl; - std::vector state = hand.getState(); - std::cout << "state size:" << state.size() << std::endl; - for (size_t j = 0; j < state.size(); j++) { - std::cout << (int)state[j] << " "; - } - std::cout << std::endl; - - std::vector>> touch_mats = hand.getForce(); - // 手指名称表,顺序对应 touch_mats[0..4] - const std::array finger_name = { - "THUMB_TOUCH", "INDEX_TOUCH", "MIDDLE_TOUCH", "RING_TOUCH", "LITTLE_TOUCH" - }; - for (size_t n = 0; n < touch_mats.size(); ++n) { - std::cout << finger_name[n] << ":\n"; - for (const auto &row : touch_mats[n]) { - for (uint8_t val : row) - std::cout << std::setw(2) << static_cast(val) << ' '; - std::cout << '\n'; - } - std::cout << '\n'; - } + // std::vector fist_pose = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + // hand.setPositionArc(fist_pose); + // std::this_thread::sleep_for(std::chrono::seconds(1)); - // 握拳 - std::vector fist_pose = {74, 0, 0, 0, 0, 176, 52, 120, 150, 201, 198, 0, 0, 0, 0, 254, 0, 0, 0, 0, 100, 0, 0, 0, 0}; - hand.fingerMove(fist_pose); - std::this_thread::sleep_for(std::chrono::seconds(1)); - // 张开 - std::vector open_pose = {74, 254, 254, 254, 253, 176, 52, 120, 150, 201, 198, 0, 0, 0, 0, 254, 0, 0, 0, 0, 254, 255, 255, 255, 250}; - hand.fingerMove(open_pose); - std::this_thread::sleep_for(std::chrono::seconds(1)); - } } catch (const std::exception& e) { std::cerr << "Error: " << e.what() << std::endl; return 1; diff --git a/examples/test_l21_can_0.cpp b/examples/test_l21_can_0.cpp index 8b3bc9a..ce59b98 100644 --- a/examples/test_l21_can_0.cpp +++ b/examples/test_l21_can_0.cpp @@ -96,7 +96,7 @@ int main() { } std::cout << std::endl; - std::vector state = hand.getState(); + std::vector state = hand.getPosition(); std::cout << "state size:" << state.size() << std::endl; for (size_t j = 0; j < state.size(); j++) { std::cout << (int)state[j] << " "; @@ -120,12 +120,12 @@ int main() { // 握拳 std::vector fist_pose = {74, 0, 0, 0, 0, 176, 52, 120, 150, 201, 198, 0, 0, 0, 0, 254, 0, 0, 0, 0, 100, 0, 0, 0, 0}; - hand.fingerMove(fist_pose); + hand.setPosition(fist_pose); std::this_thread::sleep_for(std::chrono::seconds(1)); // 张开 std::vector open_pose = {74, 254, 254, 254, 253, 176, 52, 120, 150, 201, 198, 0, 0, 0, 0, 254, 0, 0, 0, 0, 254, 255, 255, 255, 250}; - hand.fingerMove(open_pose); + hand.setPosition(open_pose); std::this_thread::sleep_for(std::chrono::seconds(1)); } } catch (const std::exception& e) { diff --git a/examples/test_l7_can_0.cpp b/examples/test_l7_can_0.cpp index 8e9aad4..9c2fe4d 100644 --- a/examples/test_l7_can_0.cpp +++ b/examples/test_l7_can_0.cpp @@ -52,7 +52,7 @@ int main() { // 获取当前状态 std::cout << "Getting current status..." << std::endl; - auto currentStatus = hand.getState(); + auto currentStatus = hand.getPosition(); std::cout << "Current status: "; for (auto pos : currentStatus) { std::cout << (int)pos << " "; diff --git a/examples/test_l7_can_1.cpp b/examples/test_l7_can_1.cpp index 6cd5b81..5b9980d 100644 --- a/examples/test_l7_can_1.cpp +++ b/examples/test_l7_can_1.cpp @@ -113,7 +113,7 @@ void threadGetParameters(LinkerHandApi& hand, int iteration) { }); auto future_state = std::async(std::launch::async, [&hand]() { - return hand.getState(); + return hand.getPosition(); }); // 等待所有结果 @@ -212,12 +212,12 @@ void threadMotionControl(LinkerHandApi& hand, int iteration) { // 握拳 std::vector fist_pose = {255, 255, 0, 0, 0, 0, 255}; - hand.fingerMove(fist_pose); + hand.setPosition(fist_pose); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); // 张开 std::vector open_pose = {255, 255, 255, 255, 255, 255, 255}; - hand.fingerMove(open_pose); + hand.setPosition(open_pose); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); auto end = std::chrono::steady_clock::now(); diff --git a/examples/test_l7_modbus_0.cpp b/examples/test_l7_modbus_0.cpp index c3ed341..13fc5ca 100644 --- a/examples/test_l7_modbus_0.cpp +++ b/examples/test_l7_modbus_0.cpp @@ -105,7 +105,7 @@ int main(int argc, char* argv[]) { for (size_t i = 0; i < poses.size(); ++i) { std::cout << "动作 " << (i + 1) << "/" << poses.size() << ": "; printVector("位置", poses[i]); - hand.fingerMove(poses[i]); + hand.setPosition(poses[i]); std::this_thread::sleep_for(std::chrono::milliseconds(500)); } std::cout << std::endl; @@ -115,7 +115,7 @@ int main(int argc, char* argv[]) { std::cout << "测试 4: 读取当前状态" << std::endl; std::cout << "----------------------------------------" << std::endl; for (int i = 0; i < 5; ++i) { - std::vector state = hand.getState(); + std::vector state = hand.getPosition(); if (!state.empty()) { printVector("当前关节位置", state); } else { diff --git a/examples/test_l7_modbus_1.cpp b/examples/test_l7_modbus_1.cpp index f014482..05805aa 100644 --- a/examples/test_l7_modbus_1.cpp +++ b/examples/test_l7_modbus_1.cpp @@ -49,7 +49,7 @@ void handStateMonitorThread(LinkerHandApi& hand) { try { // 读取关节位置 - std::vector state = hand.getState(); + std::vector state = hand.getPosition(); if (!state.empty()) { std::lock_guard console_lock(g_console_mutex); std::cout << "\033[1;36m[状态监控 " << std::setw(4) << iteration << "] "; @@ -198,7 +198,7 @@ void gestureControlThread(LinkerHandApi& hand) { std::cout << "\033[1;34m[手势控制] 执行手势: " << "\033[0m" << std::endl; } - hand.fingerMove(pose); + hand.setPosition(pose); // 下一个手势 gesture_index = (gesture_index + 1) % gestures.size(); @@ -252,7 +252,7 @@ void faultDetectionThread(LinkerHandApi& hand) { if (last_fault_state) { std::cout << "\033[1;33m[故障恢复] 尝试恢复: 发送张开手势\033[0m" << std::endl; std::vector recovery_pose = {255, 255, 255, 255, 255, 255, 255}; - hand.fingerMove(recovery_pose); + hand.setPosition(recovery_pose); } } else if (last_fault_state) { @@ -314,7 +314,7 @@ void performanceTestThread(LinkerHandApi& hand) { { std::lock_guard hand_lock(g_hand_mutex); - hand.fingerMove(position); + hand.setPosition(position); } // 控制频率 @@ -427,7 +427,7 @@ int main(int argc, char* argv[]) { { std::lock_guard hand_lock(g_hand_mutex); std::vector stop_pose = {255, 255, 255, 255, 255, 255, 255}; - hand.fingerMove(stop_pose); + hand.setPosition(stop_pose); safePrint("发送停止手势"); } diff --git a/examples/test_o20_canfd_0.cpp b/examples/test_o20_canfd_0.cpp index 4407ed3..630abae 100644 --- a/examples/test_o20_canfd_0.cpp +++ b/examples/test_o20_canfd_0.cpp @@ -55,8 +55,8 @@ int main() { std::cout << "Version: " << version << std::endl; std::vector pos(34, 0); - std::cout << "Calling fingerMove()..." << std::endl; - api.fingerMove(pos); + std::cout << "Calling setPosition()..." << std::endl; + api.setPosition(pos); std::cout << "Calling getSpeed()..." << std::endl; std::vector speed = api.getSpeed(); diff --git a/examples/test_o20_canfd_1.cpp b/examples/test_o20_canfd_1.cpp index d2fb11d..3b0f165 100644 --- a/examples/test_o20_canfd_1.cpp +++ b/examples/test_o20_canfd_1.cpp @@ -81,7 +81,7 @@ int main() { for (size_t i = 0; i < 17; ++i) { std::vector poses_temp = poses_seq; poses_temp[i] = 255; - api.fingerMove(poses_temp); + api.setPosition(poses_temp); std::this_thread::sleep_for(std::chrono::seconds(1)); } diff --git a/examples/test_o6_can_0.cpp b/examples/test_o6_can_0.cpp index 4de7989..d0088de 100644 --- a/examples/test_o6_can_0.cpp +++ b/examples/test_o6_can_0.cpp @@ -95,12 +95,12 @@ int main() { // 握拳 std::vector fist_pose = {255, 255, 0, 0, 0, 0}; - hand->fingerMove(fist_pose); + hand->setPosition(fist_pose); std::this_thread::sleep_for(std::chrono::seconds(1)); // 张开 std::vector open_pose = {255, 104, 255, 255, 255, 255}; - hand->fingerMove(open_pose); + hand->setPosition(open_pose); std::this_thread::sleep_for(std::chrono::seconds(1)); for (size_t k = 0; k < 3; k++) { @@ -120,8 +120,8 @@ int main() { } std::cout << std::endl; - std::cout << "getState----------------------------------------" << std::endl; - std::vector state = hand->getState(); + std::cout << "getPosition----------------------------------------" << std::endl; + std::vector state = hand->getPosition(); std::cout << "state size:" << state.size() << std::endl; for (size_t j = 0; j < state.size(); j++) { std::cout << (int)state[j] << " "; diff --git a/examples/test_o6_can_1.cpp b/examples/test_o6_can_1.cpp index d1843c8..c662469 100644 --- a/examples/test_o6_can_1.cpp +++ b/examples/test_o6_can_1.cpp @@ -112,7 +112,7 @@ void threadGetParameters(LinkerHandApi& hand, int iteration) { }); auto future_state = std::async(std::launch::async, [&hand]() { - return hand.getState(); + return hand.getPosition(); }); // 等待所有结果 @@ -211,12 +211,12 @@ void threadMotionControl(LinkerHandApi& hand, int iteration) { // 握拳 std::vector fist_pose = {101, 60, 0, 0, 0, 0}; - hand.fingerMove(fist_pose); + hand.setPosition(fist_pose); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); // 张开 std::vector open_pose = {255, 104, 255, 255, 255, 255}; - hand.fingerMove(open_pose); + hand.setPosition(open_pose); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); auto end = std::chrono::steady_clock::now(); diff --git a/examples/test_o6_can_3.cpp b/examples/test_o6_can_3.cpp index 90a5391..dc87d78 100644 --- a/examples/test_o6_can_3.cpp +++ b/examples/test_o6_can_3.cpp @@ -125,7 +125,7 @@ int main(int argc, char* argv[]) { for (size_t j = 0; j < poses.size(); ++j) { std::cout << "动作 " << (j + 1) << "/" << poses.size() << ": "; printVector("位置", poses[j]); - hand.fingerMove(poses[j]); + hand.setPosition(poses[j]); std::this_thread::sleep_for(std::chrono::milliseconds(500)); } std::cout << std::endl; diff --git a/examples/test_o6_modbus_0.cpp b/examples/test_o6_modbus_0.cpp index c671273..32806da 100644 --- a/examples/test_o6_modbus_0.cpp +++ b/examples/test_o6_modbus_0.cpp @@ -117,7 +117,7 @@ int main(int argc, char* argv[]) { for (size_t i = 0; i < poses.size(); ++i) { std::cout << "动作 " << (i + 1) << "/" << poses.size() << ": "; printVector("位置", poses[i]); - hand.fingerMove(poses[i]); + hand.setPosition(poses[i]); std::this_thread::sleep_for(std::chrono::milliseconds(500)); } std::cout << std::endl; @@ -127,7 +127,7 @@ int main(int argc, char* argv[]) { std::cout << "测试 4: 读取当前状态" << std::endl; std::cout << "----------------------------------------" << std::endl; for (int i = 0; i < 5; ++i) { - std::vector state = hand.getState(); + std::vector state = hand.getPosition(); if (!state.empty()) { printVector("当前关节位置", state); } else { diff --git a/examples/test_o6_modbus_1.cpp b/examples/test_o6_modbus_1.cpp index 1ef87b4..5365df6 100644 --- a/examples/test_o6_modbus_1.cpp +++ b/examples/test_o6_modbus_1.cpp @@ -152,7 +152,7 @@ int main(int argc, char* argv[]) { for (size_t i = 0; i < poses.size(); ++i) { std::cout << "动作 " << (i + 1) << "/" << poses.size() << ": "; printVector("位置", poses[i]); - hand.fingerMove(poses[i]); + hand.setPosition(poses[i]); std::this_thread::sleep_for(std::chrono::milliseconds(500)); } std::cout << std::endl; @@ -162,7 +162,7 @@ int main(int argc, char* argv[]) { std::cout << "测试 4: 读取当前状态" << std::endl; std::cout << "----------------------------------------" << std::endl; for (int i = 0; i < 5; ++i) { - std::vector state = hand.getState(); + std::vector state = hand.getPosition(); if (!state.empty()) { printVector("当前关节位置", state); } else { diff --git a/examples/test_o6_modbus_2.cpp b/examples/test_o6_modbus_2.cpp index da4000d..e9e8a1c 100644 --- a/examples/test_o6_modbus_2.cpp +++ b/examples/test_o6_modbus_2.cpp @@ -80,7 +80,7 @@ int main(int argc, char* argv[]) { std::cout << "测试 4: 读取当前状态" << std::endl; std::cout << "----------------------------------------" << std::endl; for (int i = 0; i < 5; ++i) { - std::vector state = hand.getState(); + std::vector state = hand.getPosition(); if (!state.empty()) { printVector("当前关节位置", state); } else { @@ -216,7 +216,7 @@ int main(int argc, char* argv[]) { for (size_t i = 0; i < poses.size(); ++i) { std::cout << "动作 " << (i + 1) << "/" << poses.size() << ": "; printVector("位置", poses[i]); - hand.fingerMove(poses[i]); + hand.setPosition(poses[i]); std::this_thread::sleep_for(std::chrono::milliseconds(500)); } std::cout << std::endl; diff --git a/include/api/LinkerHandApi.h b/include/api/LinkerHandApi.h index 0fafd38..e83be67 100644 --- a/include/api/LinkerHandApi.h +++ b/include/api/LinkerHandApi.h @@ -49,11 +49,12 @@ class LINKERHAND_API LinkerHandApi void setModbusRxCallback(ModbusRxCallback modbus_rx_callback); // 设置关节位置 - void fingerMove(const std::vector &pose); - void fingerMoveArc(const std::vector &pose); + void setPosition(const std::vector &pose); + void setPositionArc(const std::vector &pose); // 获取关节位置 - std::vector getState(); - std::vector getStateArc(); + std::vector getPosition(); + std::vector getPositionArc(); + std::vector testPositionArc(const std::vector &pose); // 设置速度 void setSpeed(const std::vector &speed); diff --git a/lib/linux/arm64/linkerhand_cpp_sdk.so.2.0.0 b/lib/linux/arm64/linkerhand_cpp_sdk.so.2.0.0 index ea664d5..ff2e340 100644 Binary files a/lib/linux/arm64/linkerhand_cpp_sdk.so.2.0.0 and b/lib/linux/arm64/linkerhand_cpp_sdk.so.2.0.0 differ diff --git a/lib/linux/x86_64/linkerhand_cpp_sdk.so.2.0.0 b/lib/linux/x86_64/linkerhand_cpp_sdk.so.2.0.0 index b3f14f2..fbe93e1 100644 Binary files a/lib/linux/x86_64/linkerhand_cpp_sdk.so.2.0.0 and b/lib/linux/x86_64/linkerhand_cpp_sdk.so.2.0.0 differ diff --git a/lib/win64/mingw/linkerhand_cpp_sdk.dll b/lib/win64/mingw/linkerhand_cpp_sdk.dll index f42b08f..5b4af3e 100644 Binary files a/lib/win64/mingw/linkerhand_cpp_sdk.dll and b/lib/win64/mingw/linkerhand_cpp_sdk.dll differ diff --git a/lib/win64/msvc/linkerhand_cpp_sdk.dll b/lib/win64/msvc/linkerhand_cpp_sdk.dll index 397448e..aedcd40 100644 Binary files a/lib/win64/msvc/linkerhand_cpp_sdk.dll and b/lib/win64/msvc/linkerhand_cpp_sdk.dll differ diff --git a/lib/win64/msvc/linkerhand_cpp_sdk.lib b/lib/win64/msvc/linkerhand_cpp_sdk.lib index 68d32b8..f560758 100644 Binary files a/lib/win64/msvc/linkerhand_cpp_sdk.lib and b/lib/win64/msvc/linkerhand_cpp_sdk.lib differ