diff --git a/README.md b/README.md index 1cbef45..651f69f 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ B站演示地址:https://space.bilibili.com/25336365 修改的地方挺多的不罗列了,代码增加了很多备注。 +servo 文件夹是用于写入舵机初始化程序 + 2025-08-11增加开机自平衡站立,简化控制,通过 esp32 遥控器直接控制,无需配网。 2025-08-16对几种运动中倒地的极限状态进行优化,实现自平衡起身。 diff --git a/servo/.gitignore b/servo/.gitignore new file mode 100644 index 0000000..89cc49c --- /dev/null +++ b/servo/.gitignore @@ -0,0 +1,5 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch diff --git a/servo/.vscode/extensions.json b/servo/.vscode/extensions.json new file mode 100644 index 0000000..080e70d --- /dev/null +++ b/servo/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/servo/.vscode/settings.json b/servo/.vscode/settings.json new file mode 100644 index 0000000..930ff05 --- /dev/null +++ b/servo/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "*.tcc": "cpp" + } +} \ No newline at end of file diff --git a/servo/include/README b/servo/include/README new file mode 100644 index 0000000..49819c0 --- /dev/null +++ b/servo/include/README @@ -0,0 +1,37 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the convention is to give header files names that end with `.h'. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/servo/lib/README b/servo/lib/README new file mode 100644 index 0000000..9379397 --- /dev/null +++ b/servo/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into the executable file. + +The source code of each library should be placed in a separate directory +("lib/your_library_name/[Code]"). + +For example, see the structure of the following example libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +Example contents of `src/main.c` using Foo and Bar: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +The PlatformIO Library Dependency Finder will find automatically dependent +libraries by scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/servo/platformio.ini b/servo/platformio.ini new file mode 100644 index 0000000..4b30716 --- /dev/null +++ b/servo/platformio.ini @@ -0,0 +1,14 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:esp32dev] +platform = espressif32 +board = esp32dev +framework = arduino diff --git a/servo/src/main.cpp b/servo/src/main.cpp new file mode 100644 index 0000000..38709f2 --- /dev/null +++ b/servo/src/main.cpp @@ -0,0 +1,38 @@ +#include + +void onReceiveFunction(void) { + while (Serial.available() > 0) { + char data = Serial.read(); + Serial2.write(data); // 将数据发送到舵机 + } +} +void onReceiveFunction2(void) { + while (Serial2.available() > 0) { + char data = Serial2.read(); + Serial.write(data); // 将数据发送到串口 + } +} +//Serial、Serial1、Serial2 分别对应了 UART0、UART1 和 UART2。 +void setup() { + //串口0初始化 + Serial.begin(1000000); //usb串口 + Serial2.begin(1000000); //舵机串口 + Serial.onReceive(onReceiveFunction); //为串口设置回调函数 + Serial2.onReceive(onReceiveFunction2); //为串口设置回调函数 +} +void loop() { + // 从串口读取数据 + if (Serial.available()) + { + char data = Serial.read(); + // 将数据发送到 舵机 + Serial2.write(data); + } + // 从舵机读取输入数据 + if (Serial2.available()) + { + char data = Serial2.read(); + // 将数据发送到 UART0 + Serial.write(data); + } +} diff --git a/优化模型stl/开源地址和QQ群.pptx b/优化模型stl/开源地址和QQ群.pptx new file mode 100644 index 0000000..a842f2d Binary files /dev/null and b/优化模型stl/开源地址和QQ群.pptx differ