Skip to content

Commit cb724a9

Browse files
authored
Merge pull request #14 from drawal001/dev
代码重构,添加第二个相机模块
2 parents 153939b + f8e96c8 commit cb724a9

File tree

437 files changed

+4041
-2178
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

437 files changed

+4041
-2178
lines changed

CMakeLists.txt

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,45 @@ project(D5RC VERSION 0.2)
88
set(CMAKE_CXX_STANDARD 20)
99
set(CMAKE_CXX_STANDARD_REQUIRED True)
1010

11+
# 设置 OpenCV 的搜索路径
12+
set(OpenCV_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib/Galaxy/lib/OpenCV_4_10") # 若使用 Mingw,则需要正确设置 OpenCV_DIR, 并将库地址添加到环境变量中
13+
14+
add_compile_definitions(ROOT_DIR="${CMAKE_CURRENT_SOURCE_DIR}") # 定义项目根目录
15+
1116
add_subdirectory(lib/RMD)
1217
add_subdirectory(lib/Nator)
1318
add_subdirectory(lib/Galaxy)
1419

20+
# 五自由度机器人类
1521
add_library(D5Robot src/D5Robot.cpp)
16-
target_include_directories(D5Robot PUBLIC "${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/include" "${PROJECT_SOURCE_DIR}/lib/RMD" "${PROJECT_SOURCE_DIR}/lib/Nator" "${PROJECT_SOURCE_DIR}/lib/Galaxy")
22+
target_include_directories(D5Robot PUBLIC
23+
"${PROJECT_SOURCE_DIR}"
24+
"${PROJECT_SOURCE_DIR}/include"
25+
"${PROJECT_SOURCE_DIR}/lib/RMD"
26+
"${PROJECT_SOURCE_DIR}/lib/Nator"
27+
"${PROJECT_SOURCE_DIR}/lib/Galaxy"
28+
29+
# "${PROJECT_SOURCE_DIR}/lib/Galaxy/include"
30+
"${CMAKE_SOURCE_DIR}/global")
1731
target_link_libraries(D5Robot PUBLIC RMDMotor)
1832
target_link_libraries(D5Robot PUBLIC NatorMotor)
1933
target_link_libraries(D5Robot PUBLIC Camera)
2034

35+
# 导出 DllAPI
2136
add_library(D5RbotApi SHARED src/DllApi.cpp)
2237
target_include_directories(D5RbotApi PUBLIC "${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/include")
2338
target_link_libraries(D5RbotApi D5Robot)
2439
target_compile_definitions(D5RbotApi PUBLIC "D5R_EXPORTS")
2540

41+
# 测试程序
2642
add_executable(test test.cpp)
2743
target_link_libraries(test D5Robot)
2844
target_link_libraries(test D5RbotApi)
2945

3046
add_executable(TestKineHelper "test/TestKineHelper.cpp")
3147
target_include_directories(TestKineHelper PUBLIC "${PROJECT_SOURCE_DIR}/include")
32-
target_link_libraries(TestKineHelper D5Robot)
48+
target_link_libraries(TestKineHelper D5Robot)
49+
50+
add_executable(Match "test/Match.cpp")
51+
target_include_directories(Match PUBLIC "${PROJECT_SOURCE_DIR}/include")
52+
target_link_libraries(Match D5Robot)

README.md

Lines changed: 34 additions & 7 deletions

include/ErrorCode.h renamed to global/ErrorCode.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,20 @@ enum ErrorCode {
1616
SerialClearBufferError,
1717
NatorError = 300,
1818
NatorInitError = 301,
19+
NatorSetError,
20+
NatorGetError,
21+
NatorMoveError,
1922
RMDError = 400,
2023
RMDInitError = 401,
2124
RMDGetPIError = 402,
2225
RMDFormatError,
2326
RMDChecksumError,
27+
RMDMoveError,
2428
D5RError = 500,
2529
D5RMoveError,
30+
D5RNatorNotInitialized,
31+
D5RRMDMotorNotInitialized,
32+
D5RCameraNotInitialized,
2633
CameraError = 600,
2734
CameraInitError,
2835
CameraReadError
File renamed without changes.

global/RobotException.hpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#pragma once
2+
3+
#include "ErrorCode.h"
4+
#include "LogUtil.h"
5+
#include <exception>
6+
#include <string>
7+
8+
namespace D5R {
9+
10+
class RobotException : public std::exception {
11+
public:
12+
ErrorCode code;
13+
std::string msg;
14+
RobotException() noexcept {};
15+
RobotException(ErrorCode code) noexcept { this->code = code; }
16+
RobotException(ErrorCode code, std::string msg) noexcept {
17+
this->code = code;
18+
this->msg = msg;
19+
}
20+
RobotException(const RobotException &other) noexcept : code(other.code) {}
21+
RobotException &operator=(const RobotException &other) noexcept {
22+
this->code = other.code;
23+
return *this;
24+
}
25+
26+
const char *what() const noexcept {
27+
std::string whatInfo;
28+
if (!this->msg.empty()) {
29+
whatInfo = (this->msg + " Errorcode: " + std::to_string(this->code));
30+
} else {
31+
whatInfo = ("The Error code: " + std::to_string(this->code)); // 注意这里的字符串不能以 e/E 开头,否则可能会乱码,原因不明
32+
}
33+
34+
return whatInfo.c_str();
35+
}
36+
};
37+
38+
} // namespace D5R

image/11_19/jaw_10.png

237 KB

image/11_22/jaw0.png

2.46 MB

image/11_22/jaw_model.png

151 KB

image/11_22/res_match_123141.png

1.77 MB

image/11_22/res_match_knn_0452.png

1.8 MB

0 commit comments

Comments
 (0)