Skip to content

Commit 1dd18da

Browse files
Merge pull request #10 from linker-bot/dev
refactor: normalize naming, fix G20 misalignment, and unify conversion
2 parents 98df055 + 8727434 commit 1dd18da

36 files changed

Lines changed: 216 additions & 216 deletions

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,12 @@ cmake --build . -j
235235
### 主要 API 接口
236236

237237
**控制接口**
238-
- `fingerMove()` — 设置关节位置
238+
- `setPosition()` — 设置关节位置
239239
- `setSpeed()` — 设置运动速度
240240
- `setTorque()` — 设置扭矩限制
241241

242242
**状态查询**
243-
- `getState()` — 获取关节状态
243+
- `getPosition()` — 获取关节状态
244244
- `getSpeed()` — 获取当前速度
245245
- `getTorque()` — 获取当前扭矩
246246

@@ -418,3 +418,4 @@ Copyright (c) 2026 灵心巧手(北京)科技有限公司
418418
---
419419

420420
**注意**:使用前请确保设备已正确连接并配置好通信接口。
421+

build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ if [ "$INSTALL" = true ]; then
250250
purge_install_artifacts "$SUDO"
251251

252252
# 通过 CMake 的 install 规则安装。对外公共头白名单、库文件、third_party 运行时
253-
# 依赖、cmake config target 等都由 linkerhand/CMakeLists.txt 统一控制,
253+
# 依赖、cmake config target 等都由 CMakeLists.txt 统一控制,
254254
# 不要在这里再手动 cp 头文件——会绕过白名单把全部内部头释放出去。
255255
print_info "执行 cmake --install (受白名单约束)..."
256256
$SUDO cmake --install . --prefix "$INSTALL_PREFIX"
@@ -288,7 +288,7 @@ if [ "$INSTALL" = true ]; then
288288
echo "使用示例(推荐 find_package):"
289289
echo " find_package(linkerhand-cpp-sdk CONFIG REQUIRED)"
290290
echo " target_link_libraries(<tgt> PRIVATE LinkerHand::linkerhand_cpp_sdk)"
291-
echo " 参考工程: linkerhand/examples/standalone/"
291+
echo " 参考工程: examples/standalone/"
292292
echo ""
293293
INC="$INSTALL_PREFIX/include/linkerhand-cpp-sdk"
294294
echo "或手动指定(头按子目录发布):"

docs/API-Reference.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ LinkerHandApi 类的构造函数,用于初始化 Linker 机械手 API。
4040
4141
### 设置关节位置
4242
```cpp
43-
void fingerMove(const std::vector<uint8_t> &pose);
43+
void setPosition(const std::vector<uint8_t> &pose);
4444
```
4545
**Description**:
4646
设置关节的目标位置,用于控制手指的运动。
@@ -66,7 +66,7 @@ void fingerMove(const std::vector<uint8_t> &pose);
6666

6767
### 设置关节位置
6868
```cpp
69-
void fingerMoveArc(const std::vector<double> &pose);
69+
void setPositionArc(const std::vector<double> &pose);
7070
```
7171
**Description**:
7272
设置关节的目标位置,用于控制手指的运动。
@@ -127,7 +127,7 @@ std::vector<uint8_t> getSpeed();
127127

128128
### 获取当前关节状态
129129
```cpp
130-
std::vector<uint8_t> getState();
130+
std::vector<uint8_t> getPosition();
131131
```
132132
**Description**:
133133
获取当前关节的状态信息。
@@ -138,7 +138,7 @@ std::vector<uint8_t> getState();
138138

139139
### 获取当前关节状态
140140
```cpp
141-
std::vector<double> getStateArc();
141+
std::vector<double> getPositionArc();
142142
```
143143
**Description**:
144144
获取当前关节的状态信息。
@@ -269,13 +269,13 @@ int main() {
269269

270270
std::cout << "执行动作:握拳" << std::endl;
271271
std::vector<uint8_t> fist_pose = {120, 60, 0, 0, 0, 0, 255, 255, 255, 51};
272-
hand.fingerMove(fist_pose);
272+
hand.setPosition(fist_pose);
273273
std::this_thread::sleep_for(std::chrono::seconds(1));
274274
std::cout << "-------------------------------------------" << std::endl;
275275

276276
std::cout << "执行动作:张开" << std::endl;
277277
std::vector<uint8_t> open_pose = {255, 104, 255, 255, 255, 255, 255, 255, 255, 71};
278-
hand.fingerMove(open_pose);
278+
hand.setPosition(open_pose);
279279
std::this_thread::sleep_for(std::chrono::seconds(1));
280280
std::cout << "-------------------------------------------" << std::endl;
281281

@@ -297,3 +297,4 @@ int main() {
297297
- 如果有任何问题或需要进一步支持,请联系 [https://linkerbot.cn/aboutUs](https://linkerbot.cn/aboutUs)
298298

299299
---
300+

docs/FAQ.md

Lines changed: 5 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,16 @@
11
# 常见问题解答
22

3-
本文档面向 `pack.sh` 生成的 `linkerhand-cpp-sdk/` 发布包,以及从 `linkerhand/` 源码构建安装 SDK 的开发者。
4-
5-
## 安装与发布包
6-
7-
### Q1: 发布包和源码仓库是什么关系?
8-
9-
`linkerhand/` 是唯一主开发工作区,`./pack.sh pack` 会基于它生成可直接发布的 `linkerhand-cpp-sdk/`。发布包内包含预编译库、示例、示教器、文档和必要的第三方依赖。
10-
11-
### Q2: 发布包解压后怎么快速验证?
12-
13-
Linux/macOS:
14-
15-
```bash
16-
cd linkerhand-cpp-sdk
17-
mkdir build && cd build
18-
cmake ..
19-
cmake --build . -j$(nproc)
20-
./bin/test_l10_can_0
21-
```
22-
23-
Windows MinGW:
24-
25-
```cmd
26-
cd linkerhand-cpp-sdk
27-
mkdir build
28-
cd build
29-
cmake -G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=mingw32-make ..
30-
mingw32-make -j
31-
build\bin\test_l10_can_0.exe
32-
```
33-
34-
### Q3: 发布包里的头文件为什么比最小 API 入口多?
35-
36-
发布包不仅面向统一 API,也要支持 `examples/``hand_teach_pendant/` 和部分需要直连通信层的客户工程,所以会一起发布 `include/communication/` 下的通信相关头。新项目优先从 `LinkerHandApi.h` 开始接入。
37-
38-
### Q4: 安装后 `find_package` 应该怎么接?
39-
40-
从源码执行 `cmake --install``./build.sh -i` 后,可直接在下游工程里写:
41-
42-
```cmake
43-
find_package(linkerhand-cpp-sdk CONFIG REQUIRED)
44-
target_link_libraries(my_app PRIVATE LinkerHand::linkerhand_cpp_sdk)
45-
```
46-
47-
这条路径适合系统安装后的二次开发;如果只是消费发布包,直接用发布包根目录的 `CMakeLists.txt` 构建 examples 或参考 `README.md` 手动链接即可。
48-
49-
## 构建与运行
50-
51-
### Q5: 发布包里的 `build.sh` / `build.bat` 能做什么?
52-
53-
它们主要服务于持有源码工程的开发者,用于重建、安装或卸载 SDK。客户从发布包消费预编译库时,通常不需要执行 `-b` / `-i`,直接用 `cmake ..` 构建 examples 即可。
54-
55-
### Q6: `--skip-tests` 为什么没有关闭 examples?
56-
57-
当前 `build.sh` 透传的是 `-DBUILD_TESTS=OFF`,这是 examples 子目录内部开关,不影响顶层 `BUILD_EXAMPLES` / `BUILD_PENDANT`。如果只想构建 SDK,请直接使用:
58-
59-
```bash
60-
cmake -S linkerhand -B linkerhand/build -DBUILD_EXAMPLES=OFF -DBUILD_PENDANT=OFF
61-
cmake --build linkerhand/build -j
62-
```
63-
64-
### Q7: 哪些平台是当前主要验证目标?
65-
66-
- Linux `x86_64`
67-
- Linux `aarch64`
68-
- Windows `x64`(MinGW / MSVC 导入库)
69-
70-
其中 O20 的 CAN-FD 示例目前主要面向 Linux `x86_64`
3+
本文档面向 `linkerhand-cpp-sdk/` 发布包,以及从 repository root 源码构建安装 SDK 的开发者。
714

725
## 通信与接口
736

74-
### Q8: CAN、Modbus、EtherCAT 怎么选?
7+
### Q1: CAN、Modbus、EtherCAT 怎么选?
758

769
- 统一 API 层通过 `COMM_TYPE::CAN``COMM_TYPE::MODBUS``COMM_TYPE::ETHERCAT` 选择通信方式。
7710
- 不同手型支持范围不同,具体以 `README.md` 型号表和现有 examples 为准。
7811
- 需要自己管理底层总线时,优先参考 `examples/test_*``hand_teach_pendant/src/HandController.cpp` 的实际用法。
7912

80-
### Q9: Linux 下 CAN 默认怎么配?
13+
### Q2: Linux 下 CAN 默认怎么配?
8114

8215
```bash
8316
sudo modprobe can
@@ -89,18 +22,14 @@ ip link show can0
8922

9023
如果示例使用了 `can1` 或其他设备名,请按现场总线名替换。
9124

92-
### Q10: Windows 下还需要额外 DLL 吗?
25+
### Q3: Windows 下还需要额外 DLL 吗?
9326

9427
需要。发布包已经带上 `third_party/PCAN_Basic/` 和对应导入库;客户工程除了 SDK 自身 DLL 外,还要确保 `PCANBasic.dll` 与可执行文件同目录,或能被系统搜索路径找到。
9528

9629
## 文档与支持
9730

98-
### Q11: 先看哪个文档最合适?
31+
### Q4: 先看哪个文档最合适?
9932

10033
- 想了解总体接入方式:看 `README.md`
10134
- 想确认接口签名:看 `docs/API-Reference.md`
10235
- 遇到构建或运行问题:看 `docs/TROUBLESHOOTING.md`
103-
104-
### Q12: 旧版参考目录还能直接当文档源吗?
105-
106-
不能。旧版目录只适合做历史对照,内容可能与当前命名空间、打包布局、构建开关不一致。对外发布请以 `linkerhand/``pack.sh` 产物为准。

docs/TROUBLESHOOTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ pkg-config --modversion libusb-1.0
1717
如果构建网页示教器,还要确认 `Boost::system` 可用。只想先验证 SDK 本体时,可显式关闭示例和示教器:
1818

1919
```bash
20-
cmake -S linkerhand -B linkerhand/build -DBUILD_EXAMPLES=OFF -DBUILD_PENDANT=OFF
21-
cmake --build linkerhand/build -j
20+
cmake -S . -B build -DBUILD_EXAMPLES=OFF -DBUILD_PENDANT=OFF
21+
cmake --build build -j
2222
```
2323

2424
### 2. 找不到 `LinkerHandApi.h``CommFactory.h`(旧名 `CanBusFactory.h`
@@ -96,7 +96,7 @@ O20 的 CAN-FD 主要面向 Linux `x86_64`。在 ARM + Ubuntu 18 及以下环境
9696
`USE_ETHERCAT` 默认关闭。只有在现场确实需要时再打开:
9797

9898
```bash
99-
cmake -S linkerhand -B linkerhand/build -DUSE_ETHERCAT=ON
99+
cmake -S . -B build -DUSE_ETHERCAT=ON
100100
```
101101

102102
打开后仍失败,先检查系统是否已安装 `libethercat` 和对应 `pkg-config` 信息,而不是直接修改源码。
@@ -123,10 +123,10 @@ cmake -S linkerhand -B linkerhand/build -DUSE_ETHERCAT=ON
123123

124124
### 11. 为什么不再从旧版参考目录复制文档?
125125

126-
旧版目录长期手工维护,很多内容与当前仓库状态不再一致。现在的发布文档都应从 `linkerhand/docs/` 输出,由 `pack.sh` 直接复制,避免一边改代码、一边忘记同步旧目录。
126+
旧版目录长期手工维护,很多内容与当前仓库状态不再一致。现在的发布文档都应从 `docs/` 输出,由 `pack.sh` 直接复制,避免一边改代码、一边忘记同步旧目录。
127127

128128
## 排查原则
129129

130130
- 连续编译或运行失败两次以上,先回看日志和环境,不继续盲试。
131131
- 先检查平台、依赖、设备名、库路径,再怀疑源码逻辑。
132-
- 对外发布只以 `linkerhand/` 当前内容和 `pack.sh` 生成物为准。
132+
- 对外发布只以 repository root 当前内容和 `pack.sh` 生成物为准。

examples/CMakeLists.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ else()
115115
link_directories(${LIBCANBUS_DIR})
116116

117117
# 设置运行时库路径,确保运行时能找到 libcanbus.so 与 SDK .so
118-
set(CMAKE_INSTALL_RPATH "${LIBCANBUS_DIR}")
118+
# $ORIGIN: 让 exe 在自身所在目录(bin/)查找,从而拿到 copy_dependencies 复制过来的 SDK .so
119+
set(CMAKE_INSTALL_RPATH "\$ORIGIN" "${LIBCANBUS_DIR}")
119120
if(LINKERHAND_LIB_DIR)
120121
list(APPEND CMAKE_INSTALL_RPATH "${LINKERHAND_LIB_DIR}")
121122
endif()
@@ -153,6 +154,18 @@ function(copy_dependencies target)
153154
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
154155
COMMENT "Copying linkerhand_cpp_sdk runtime to output directory"
155156
)
157+
# Unix: 复制只拿到 .so.<VERSION>,exe NEEDED 的是 .so.<SOVERSION>(由 SONAME 决定),
158+
# 必须在 bin/ 里同步建出 SONAME 软链,否则 ld.so 找不到。
159+
if(UNIX AND NOT APPLE)
160+
add_custom_command(TARGET ${target} POST_BUILD
161+
COMMAND ${CMAKE_COMMAND} -E remove -f
162+
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<TARGET_SONAME_FILE_NAME:linkerhand_cpp_sdk>"
163+
COMMAND ${CMAKE_COMMAND} -E create_symlink
164+
"$<TARGET_FILE_NAME:linkerhand_cpp_sdk>"
165+
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<TARGET_SONAME_FILE_NAME:linkerhand_cpp_sdk>"
166+
COMMENT "Creating SONAME symlink for linkerhand_cpp_sdk in output directory"
167+
)
168+
endif()
156169
elseif(LINKERHAND_DLL AND EXISTS "${LINKERHAND_DLL}")
157170
add_custom_command(TARGET ${target} POST_BUILD
158171
COMMAND ${CMAKE_COMMAND} -E copy_if_different

examples/L10/action_group_show.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ int main() {
428428

429429
while (running) {
430430
std::vector<uint8_t> action = showLeft();
431-
hand.fingerMove(action);
431+
hand.setPosition(action);
432432
std::this_thread::sleep_for(std::chrono::milliseconds(33));
433433
}
434434

0 commit comments

Comments
 (0)