bash
https://github.com/YHRG-Robotics/S1_SDK_V2
bash
(base) lmj@lmj:~$ conda activate lerobot
(lerobot) lmj@lmj:~$ sudo chmod 777 /dev/ttyUSB0
[sudo] lmj 的密码:
chmod: 无法访问 '/dev/ttyUSB0': 没有那个文件或目录
(lerobot) lmj@lmj:~$ cd S1_SDK_V2
(lerobot) lmj@lmj:~/S1_SDK_V2$ sudo chmod 777 /dev/ttyUSB0
(lerobot) lmj@lmj:~/S1_SDK_V2$ ./install.sh
Obtaining file:///home/lmj/S1_SDK_V2
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build editable ... done
Installing backend dependencies ... done
Preparing editable metadata (pyproject.toml) ... done
Requirement already satisfied: numpy in /home/lmj/miniconda3/envs/lerobot/lib/python3.10/site-packages (from S1_SDK==0.1.0) (2.2.6)
Requirement already satisfied: mujoco==3.4.0 in /home/lmj/miniconda3/envs/lerobot/lib/python3.10/site-packages (from S1_SDK==0.1.0) (3.4.0)
Requirement already satisfied: pynput in /home/lmj/miniconda3/envs/lerobot/lib/python3.10/site-packages (from S1_SDK==0.1.0) (1.8.2)
Requirement already satisfied: pybind11>=3.0.4 in /home/lmj/miniconda3/envs/lerobot/lib/python3.10/site-packages (from S1_SDK==0.1.0) (3.1.0)
Requirement already satisfied: absl-py in /home/lmj/miniconda3/envs/lerobot/lib/python3.10/site-packages (from mujoco==3.4.0->S1_SDK==0.1.0) (2.5.0)
Requirement already satisfied: etils[epath] in /home/lmj/miniconda3/envs/lerobot/lib/python3.10/site-packages (from mujoco==3.4.0->S1_SDK==0.1.0) (1.13.0)
Requirement already satisfied: glfw in /home/lmj/miniconda3/envs/lerobot/lib/python3.10/site-packages (from mujoco==3.4.0->S1_SDK==0.1.0) (2.10.2)
Requirement already satisfied: pyopengl in /home/lmj/miniconda3/envs/lerobot/lib/python3.10/site-packages (from mujoco==3.4.0->S1_SDK==0.1.0) (3.1.10)
Requirement already satisfied: fsspec in /home/lmj/miniconda3/envs/lerobot/lib/python3.10/site-packages (from etils[epath]->mujoco==3.4.0->S1_SDK==0.1.0) (2026.9.0)
Requirement already satisfied: importlib_resources in /home/lmj/miniconda3/envs/lerobot/lib/python3.10/site-packages (from etils[epath]->mujoco==3.4.0->S1_SDK==0.1.0) (7.1.0)
Requirement already satisfied: typing_extensions in /home/lmj/miniconda3/envs/lerobot/lib/python3.10/site-packages (from etils[epath]->mujoco==3.4.0->S1_SDK==0.1.0) (4.16.0)
Requirement already satisfied: zipp in /home/lmj/miniconda3/envs/lerobot/lib/python3.10/site-packages (from etils[epath]->mujoco==3.4.0->S1_SDK==0.1.0) (4.1.0)
Requirement already satisfied: six in /home/lmj/miniconda3/envs/lerobot/lib/python3.10/site-packages (from pynput->S1_SDK==0.1.0) (1.17.0)
Requirement already satisfied: evdev>=1.3 in /home/lmj/miniconda3/envs/lerobot/lib/python3.10/site-packages (from pynput->S1_SDK==0.1.0) (1.9.3)
Requirement already satisfied: python-xlib>=0.17 in /home/lmj/miniconda3/envs/lerobot/lib/python3.10/site-packages (from pynput->S1_SDK==0.1.0) (0.33)
Building wheels for collected packages: S1_SDK
Building editable for S1_SDK (pyproject.toml) ... done
Created wheel for S1_SDK: filename=s1_sdk-0.1.0-cp310-cp310-linux_x86_64.whl size=16299 sha256=30dd26930f769e9c0beb89b69ef7df0cadbe605942648f927783d2dbf7429282
Stored in directory: /tmp/pip-ephem-wheel-cache-ce45vm5_/wheels/d5/52/98/3c441dcfdec3d076ddc9d7d0dec0e9975c2399112479f2521e
Successfully built S1_SDK
Installing collected packages: S1_SDK
Attempting uninstall: S1_SDK
Found existing installation: S1_SDK 0.1.0
Uninstalling S1_SDK-0.1.0:
Successfully uninstalled S1_SDK-0.1.0
Successfully installed S1_SDK-0.1.0
------------------------------------------
Architecture: x86_64
Python: /home/lmj/miniconda3/envs/lerobot/bin/python3
------------------------------------------
-- The C compiler identification is GNU 13.3.0
-- The CXX compiler identification is GNU 13.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
CMake Warning (dev) at /home/lmj/miniconda3/envs/lerobot/lib/python3.10/site-packages/pybind11/share/cmake/pybind11/FindPythonLibsNew.cmake:101 (message):
Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
are removed. Run "cmake --help-policy CMP0148" for policy details. Use
the cmake_policy command to set the policy and suppress this warning, or
preferably upgrade to using FindPython, either by calling it explicitly
before pybind11, or by setting PYBIND11_FINDPYTHON ON before pybind11.
Call Stack (most recent call first):
/home/lmj/miniconda3/envs/lerobot/lib/python3.10/site-packages/pybind11/share/cmake/pybind11/pybind11Tools.cmake:44 (find_package)
/home/lmj/miniconda3/envs/lerobot/lib/python3.10/site-packages/pybind11/share/cmake/pybind11/pybind11Common.cmake:243 (include)
/home/lmj/miniconda3/envs/lerobot/lib/python3.10/site-packages/pybind11/share/cmake/pybind11/pybind11Config.cmake:257 (include)
CMakeLists.txt:50 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Found PythonInterp: /home/lmj/miniconda3/envs/lerobot/bin/python (found suitable version "3.10.21", minimum required is "3.9")
-- Found PythonLibs: /home/lmj/miniconda3/envs/lerobot/lib/libpython3.10.so
-- Performing Test HAS_FLTO_AUTO
-- Performing Test HAS_FLTO_AUTO - Success
-- Found pybind11: /home/lmj/miniconda3/envs/lerobot/lib/python3.10/site-packages/pybind11/include (found version "3.1.0")
-- Configuring done (0.3s)
-- Generating done (0.0s)
-- Build files have been written to: /home/lmj/S1_SDK_V2/build
[ 31%] Building CXX object CMakeFiles/control_pos_vel.dir/src/S1_SDK_C++/control_pos_vel.cpp.o
[ 31%] Building CXX object CMakeFiles/enable.dir/src/S1_SDK_C++/enable.cpp.o
[ 31%] Building CXX object CMakeFiles/motor_interface.dir/src/S1_interface.cpp.o
[ 31%] Building CXX object CMakeFiles/disable.dir/src/S1_SDK_C++/disable.cpp.o
[ 31%] Building CXX object CMakeFiles/set_end_zero_pos.dir/src/S1_SDK_C++/set_end_zero_pos.cpp.o
[ 37%] Building CXX object CMakeFiles/read_pos.dir/src/S1_SDK_C++/read_pos.cpp.o
[ 43%] Building CXX object CMakeFiles/set_zero_pos.dir/src/S1_SDK_C++/set_zero_pos.cpp.o
[ 50%] Building CXX object CMakeFiles/gravity.dir/src/S1_SDK_C++/gravity.cpp.o
[ 56%] Linking CXX executable /home/lmj/S1_SDK_V2/examples/C++/enable
[ 62%] Linking CXX executable /home/lmj/S1_SDK_V2/examples/C++/set_zero_pos
[ 68%] Linking CXX executable /home/lmj/S1_SDK_V2/examples/C++/set_end_zero_pos
[ 75%] Linking CXX executable /home/lmj/S1_SDK_V2/examples/C++/disable
[ 81%] Linking CXX executable /home/lmj/S1_SDK_V2/examples/C++/read_pos
[ 87%] Linking CXX executable /home/lmj/S1_SDK_V2/examples/C++/gravity
[ 93%] Linking CXX executable /home/lmj/S1_SDK_V2/examples/C++/control_pos_vel
[ 93%] Built target set_end_zero_pos
[ 93%] Built target set_zero_pos
[ 93%] Built target enable
[ 93%] Built target read_pos
[ 93%] Built target disable
[ 93%] Built target gravity
[ 93%] Built target control_pos_vel
[100%] Linking CXX shared module /home/lmj/S1_SDK_V2/src/S1_SDK/hardware/motor_interface.cpython-310-x86_64-linux-gnu.so
[100%] Built target motor_interface
(lerobot) lmj@lmj:~/S1_SDK_V2$ sudo chmod 777 /dev/ttyUSB0
(lerobot) lmj@lmj:~/S1_SDK_V2$ cd examples/python
(lerobot) lmj@lmj:~/S1_SDK_V2/examples/python$ python check_arm.py
arm found
/dev/ttyUSB0 (机械臂)
(lerobot) lmj@lmj:~/S1_SDK_V2/examples/python$ python keyboard_joint.py --dev /dev/ttyUSB0 --mode only_real --end None
按下了: 6
6按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了: 1
1按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了: 2
2按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[A按下了特殊键: Key.up
^[[AS1 motor 6 timeout
S1 motor 5 timeout
S1 motor 4 timeout
S1 motor 3 timeout
S1 motor 2 timeout
S1 motor 1 timeout
S1 motor 6 timeout
S1 motor 5 timeout
S1 motor 4 timeout
S1 motor 3 timeout
S1 motor 2 timeout
S1 motor 1 timeout
S1 motor 6 timeout
S1 motor 5 timeout
S1 motor 4 timeout
S1 motor 3 timeout
S1 motor 2 timeout
S1 motor 1 timeout
S1 motor 6 timeout
S1 motor 5 timeout
S1 motor 4 timeout
S1 motor 3 timeout
S1 motor 2 timeout
S1 motor 1 timeout
S1 motor 6 timeout
S1 motor 5 timeout
S1 motor 4 timeout
S1 motor 3 timeout
S1 motor 2 timeout
S1 motor 1 timeout
S1 motor 6 timeout
S1 motor 5 timeout
S1 motor 4 timeout
S1 motor 3 timeout
S1 motor 2 timeout
S1 motor 1 timeout
S1 motor 6 timeout
S1 motor 5 timeout
S1 motor 4 timeout
S1 motor 3 timeout
S1 motor 2 timeout
S1 motor 1 timeout
S1 motor 2 timeout
控制部分代码
bash
src/S1_SDK_C++/control_pos_vel.cpp
bash
#include "S1_SDK.hpp"
#include <memory>
#include <iostream>
#include <vector>
#include <thread>
#include <csignal> // for signal handling
#include <atomic> // for std::atomic<bool>
#include "common.hpp"
static std::atomic<bool> g_should_exit{false};
std::vector<float> make_pos();
void signal_handler(int signal);
int main(int argc, char *argv[])
{
std::signal(SIGINT, signal_handler);
std::signal(SIGTERM, signal_handler);
std::shared_ptr<S1::S1ARM> arm;//创建指针
if((arm = param_parse(argc,argv)) == nullptr)
{
return 0;
}
arm->enable(); //使能
std::vector<float> vel = {10,10,10,10,10,10};
std::cout << "Control loop started. Press Ctrl+C to stop.\n";
while(!g_should_exit)
{
std::vector<float> pos = arm->Get_Position();//获取当前位置
// std::cout << "pos: " ;
// for(auto p:pos)
// {
// std::cout << p << " ";
// }
// std::cout << std::endl;
std::vector<float> tar_pos = make_pos();//生成目标位置
arm->Control_Pos_Vel(tar_pos,vel);//控制位置和速度
std::this_thread::sleep_for(std::chrono::milliseconds(2));
}
arm->disable();
}
std::vector<float> make_pos(){
static float local_tick = 0;
static float direction = 1;
if(local_tick > 0.75)
{
direction = -1;
}
else if(local_tick <= 0)
{
direction = 1;
}
local_tick += 0.0001 * direction;
std::vector<float> joint_pos = {0,local_tick,local_tick,0,0,0};
return joint_pos;
}
void signal_handler(int signal) {
if (signal == SIGINT || signal == SIGTERM) {
std::cout << "\n\nReceived signal " << signal
<< ". Shutting down\n";
g_should_exit = true;
}
}
获取当前位置
Get_Position 类似于封装的库函数,获取关节当前位置而不是偏移角度
bash
(lerobot) lmj@lmj:~/S1_SDK_V2$ grep -R "Get_Position" .
grep: ./S1_SDK_V2/lib/macos/arm64/libmotor_core.a: 匹配到二进制文件
`grep: ./S1_SDK_V2/lib/linux/x86_64/libmotor_core.a:` 匹配到二进制文件
grep: ./S1_SDK_V2/lib/linux/aarch64/libmotor_core.a: 匹配到二进制文件
grep: ./S1_SDK_V2/lib/windows/lib/motor_core.lib: 匹配到二进制文件
./S1_SDK_V2/lib/windows/include/S1_SDK.hpp: std::vector<float> Get_Position();
./S1_SDK_V2/src/S1_SDK_C++/control_pos_vel.cpp: std::vector<float> pos = arm->Get_Position();//获取当前位置
./S1_SDK_V2/src/S1_SDK_C++/gravity.cpp: std::vector<float> pos = arm->Get_Position();
./S1_SDK_V2/src/S1_SDK_C++/read_pos.cpp: std::vector<float> pos = arm->Get_Position();
grep: ./S1_SDK_V2/src/S1_SDK/hardware/motor_interface.cpython-310-x86_64-linux-gnu.so: 匹配到二进制文件
./S1_SDK_V2/src/S1_interface.cpp: .def("get_position", &S1::S1ARM::Get_Position)
./S1_SDK_V2/readme.md:std::vector<float> pos = arm.Get_Position();
./S1_SDK_V2/include/S1_SDK.hpp: std::vector<float> Get_Position();
./S1_SDK_V2/include/S1_SDK_back.hpp: std::vector<float> Get_Position();
grep: ./lib/macos/arm64/libmotor_core.a: 匹配到二进制文件
grep: ./lib/linux/x86_64/libmotor_core.a: 匹配到二进制文件
grep: ./lib/linux/aarch64/libmotor_core.a: 匹配到二进制文件
grep: ./lib/windows/lib/motor_core.lib: 匹配到二进制文件
./lib/windows/include/S1_SDK.hpp: std::vector<float> Get_Position();
./src/S1_SDK_C++/control_pos_vel.cpp: std::vector<float> pos = arm->Get_Position();//获取当前位置
./src/S1_SDK_C++/gravity.cpp: std::vector<float> pos = arm->Get_Position();
./src/S1_SDK_C++/read_pos.cpp: std::vector<float> pos = arm->Get_Position();
grep: ./src/S1_SDK/hardware/motor_interface.cpython-310-x86_64-linux-gnu.so: 匹配到二进制文件
./src/S1_interface.cpp: .def("get_position", &S1::S1ARM::Get_Position)
grep: ./examples/C++/gravity: 匹配到二进制文件
grep: ./examples/C++/enable: 匹配到二进制文件
grep: ./examples/C++/control_pos_vel: 匹配到二进制文件
grep: ./examples/C++/set_zero_pos: 匹配到二进制文件
grep: ./examples/C++/read_pos: 匹配到二进制文件
grep: ./examples/C++/disable: 匹配到二进制文件
grep: ./examples/C++/set_end_zero_pos: 匹配到二进制文件
./readme.md:std::vector<float> pos = arm.Get_Position();
./include/S1_SDK.hpp: std::vector<float> Get_Position();
./include/S1_SDK_back.hpp: std::vector<float> Get_Position();
grep: ./build/CMakeFiles/control_pos_vel.dir/src/S1_SDK_C++/control_pos_vel.cpp.o: 匹配到二进制文件
grep: ./build/CMakeFiles/motor_interface.dir/src/S1_interface.cpp.o: 匹配到二进制文件
grep: ./build/CMakeFiles/read_pos.dir/src/S1_SDK_C++/read_pos.cpp.o: 匹配到二进制文件
grep: ./build/CMakeFiles/gravity.dir/src/S1_SDK_C++/gravity.cpp.o: 匹配到二进制文件
(lerobot) lmj@lmj:~/S1_SDK_V2$
bash
src/S1_SDK_C++/read_pos.cpp
bash
#include "S1_SDK.hpp"
#include <memory>
#include <iostream>
#include <vector>
#include <thread>
#include "common.hpp"
int main(int argc, char *argv[])
{
std::shared_ptr<S1::S1ARM> arm;//创建指针
if((arm = param_parse(argc,argv)) == nullptr)
{
return 0;
}
while(true)
{
std::vector<float> pos = arm->Get_Position();
std::cout << "pos: " ;
for(auto p:pos)
{
std::cout << p << " ";
}
std::cout << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
命令行测试角度偏移
bash
(lerobot) lmj@lmj:~/S1_SDK_V2/examples/python$ python read_pos.py --dev /dev/ttyUSB0 --mode only_real --end None
pos: [' 0.000', ' 0.000', ' 0.000', ' 0.000', ' 0.000', ' 0.000']
pos: [' 0.000', ' 0.000', ' 0.000', ' 0.000', ' 0.000', ' 0.000']
pos: [' 0.000', ' 0.000', ' 0.000', ' 0.000', ' 0.000', ' -0.072']
pos: [' 0.000', ' 0.000', ' 0.000', ' 0.000', ' 0.000', ' -0.072']
pos: [' 0.000', ' 0.000', ' 1.118', ' 0.000', ' -1.113', ' -0.072']
pos: [' 0.000', ' 0.000', ' 1.118', ' 0.000', ' -1.113', ' -0.072']
pos: [' 0.000', ' 0.000', ' 1.118', ' 0.000', ' -1.113', ' -0.072']
pos: [' 0.000', ' 0.000', ' 1.118', ' 0.000', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
pos: [' 0.236', ' 0.620', ' 1.118', ' 0.163', ' -1.113', ' -0.072']
bash
pos: [' 0.063', ' -0.013', ' 0.002', ' 0.000', ' -0.035', ' -0.117']
pos: [' 0.063', ' -0.013', ' 0.002', ' 0.000', ' -0.035', ' -0.117']
pos: [' 0.063', ' -0.013', ' 0.002', ' 0.000', ' -0.035', ' -0.117']
pos: [' 0.063', ' -0.013', ' 0.002', ' 0.000', ' -0.035', ' -0.117']
pos: [' 0.063', ' -0.013', ' 0.002', ' 0.000', ' -0.035', ' -0.117']
pos: [' 0.063', ' -0.013', ' 0.002', ' 0.000', ' -0.035', ' -0.117']
pos: [' 0.063', ' -0.013', ' 0.002', ' 0.000', ' -0.035', ' -0.117']
pos: [' 0.063', ' -0.013', ' 0.002', ' 0.000', ' -0.035', ' -0.117']
pos: [' 0.063', ' -0.013', ' 0.002', ' 0.000', ' -0.035', ' -0.117']
pos: [' 0.063', ' -0.013', ' 0.002', ' 0.000', ' -0.035', ' -0.117']
pos: [' 0.063', ' -0.013', ' 0.002', ' 0.000', ' -0.035', ' -0.117']
pos: [' 0.063', ' -0.013', ' 0.002', ' 0.000', ' -0.035', ' -0.117']
pos: [' 0.063', ' -0.013', ' 0.002', ' 0.000', ' -0.035', ' -0.117']
pos: [' 0.063', ' -0.013', ' 0.002', ' 0.000', ' -0.035', ' -0.117']
pos: [' 0.063', ' -0.013', ' 0.002', ' 0.000', ' -0.035', ' -0.117']



