From 28545e965113bbcdeb57e5a90c6e5923a7534ab7 Mon Sep 17 00:00:00 2001 From: lixiao <932184220@qq.com> Date: Thu, 5 Sep 2024 10:35:03 +0800 Subject: [PATCH] cpp --- entry/src/main/cpp/CMakeLists.txt | 10 +- entry/src/main/cpp/sdk/api/include/JudgeSdk.h | 4 +- entry/src/main/cpp/sdk/api/js/JSApiBridge.cpp | 205 +-- entry/src/main/cpp/sdk/api/js/JSApiBridge.h | 61 +- .../cpp/sdk/assistdrive/AutomaticService.cpp | 122 +- .../cpp/sdk/assistdrive/AutomaticService.h | 22 +- .../AutomaticServiceDataManager.cpp | 4 +- .../assistdrive/AutomaticServiceDataManager.h | 9 +- .../sdk/assistdrive/AutomaticServiceDefines.h | 18 +- .../cpp/sdk/assistdrive/IAutomaticService.h | 4 + .../cpp/sdk/assistdrive/data/aiconfig.json | 277 ++++ .../cpp/sdk/assistdrive/data/basepoint.json | 6 + .../main/cpp/sdk/assistdrive/data/car.json | 204 +++ .../cpp/sdk/assistdrive/data/collect.json | 1360 +++++++++++++++++ .../sdk/assistdrive/data/collectParams.json | 99 ++ .../cpp/sdk/assistdrive/data/destLib.json | 50 + .../cpp/sdk/assistdrive/data/naviPath.json | 216 +++ .../ItemModelAbstractClass.cpp} | 45 +- .../ItemModelAbstractClass.h} | 22 +- .../ItemModelCftc.cpp} | 10 +- .../FieldModelCftc.h => item/ItemModelCftc.h} | 14 +- .../ItemModelDcrk.cpp} | 10 +- .../FieldModelDcrk.h => item/ItemModelDcrk.h} | 14 +- .../ItemModelPdqb.cpp} | 8 +- .../FieldModelPdqb.h => item/ItemModelPdqb.h} | 14 +- .../ItemModelQxxs.cpp} | 12 +- .../FieldModelQxxs.h => item/ItemModelQxxs.h} | 14 +- .../ItemModelZjzw.cpp} | 10 +- .../FieldModelZjzw.h => item/ItemModelZjzw.h} | 14 +- .../sdk/assistdrive/track/TrackModeDefines.h | 24 + .../assistdrive/track/TrackModeManager.cpp | 5 +- .../sdk/assistdrive/track/TrackModeManager.h | 3 +- .../track/libTrack/LibModeAbstractClass.h | 4 +- .../track/libTrack/LibModeLateral.h | 2 +- .../track/libTrack/LibModeReverse.cpp | 5 +- .../track/libTrack/LibModeReverse.h | 2 +- .../track/pathTrack/PathTrackAbstractClass.h | 27 + .../track/pathTrack/PathTrackDefines.h | 31 + .../track/pathTrack/PathTrackMethodLQR.h | 26 + .../pathTrack/PathTrackMethodPursuit.cpp | 18 + .../track/pathTrack/PathTrackMethodPursuit.h | 30 + .../track/pathTrack/purp/CtrlParam.h | 17 - .../{purp => pursuitMethod}/PathTracking.cpp | 34 +- .../{purp => pursuitMethod}/PathTracking.h | 4 +- .../pathTrack/{purp => pursuitMethod}/State.h | 0 .../{purp => pursuitMethod}/States.h | 0 .../{purp => pursuitMethod}/TargetCourse.cpp | 4 +- .../{purp => pursuitMethod}/TargetCourse.h | 2 +- .../assistdrive/track/teachTrack/CacuTeach.h | 125 +- .../track/trackMode/TrackModeAbstractClass.h | 3 +- .../track/trackMode/TrackModeLib.h | 2 +- .../track/trackMode/TrackModePath.h | 42 +- .../track/trackMode/TrackModeTeach.cpp | 2 +- .../track/trackMode/TrackModeTeach.h | 2 +- entry/src/main/cpp/sdk/exam/ExamService.h | 9 +- entry/src/main/ets/pages/Index.ets | 14 +- .../ets/utils/wireControl/WireControl.ets | 32 +- 57 files changed, 2892 insertions(+), 435 deletions(-) create mode 100644 entry/src/main/cpp/sdk/assistdrive/data/aiconfig.json create mode 100644 entry/src/main/cpp/sdk/assistdrive/data/basepoint.json create mode 100644 entry/src/main/cpp/sdk/assistdrive/data/car.json create mode 100644 entry/src/main/cpp/sdk/assistdrive/data/collect.json create mode 100644 entry/src/main/cpp/sdk/assistdrive/data/collectParams.json create mode 100644 entry/src/main/cpp/sdk/assistdrive/data/destLib.json create mode 100644 entry/src/main/cpp/sdk/assistdrive/data/naviPath.json rename entry/src/main/cpp/sdk/assistdrive/{field/FieldModelAbstractClass.cpp => item/ItemModelAbstractClass.cpp} (80%) rename entry/src/main/cpp/sdk/assistdrive/{field/FieldModelAbstractClass.h => item/ItemModelAbstractClass.h} (84%) rename entry/src/main/cpp/sdk/assistdrive/{field/FieldModelCftc.cpp => item/ItemModelCftc.cpp} (78%) rename entry/src/main/cpp/sdk/assistdrive/{field/FieldModelCftc.h => item/ItemModelCftc.h} (58%) rename entry/src/main/cpp/sdk/assistdrive/{field/FieldModelDcrk.cpp => item/ItemModelDcrk.cpp} (77%) rename entry/src/main/cpp/sdk/assistdrive/{field/FieldModelDcrk.h => item/ItemModelDcrk.h} (62%) rename entry/src/main/cpp/sdk/assistdrive/{field/FieldModelPdqb.cpp => item/ItemModelPdqb.cpp} (65%) rename entry/src/main/cpp/sdk/assistdrive/{field/FieldModelPdqb.h => item/ItemModelPdqb.h} (62%) rename entry/src/main/cpp/sdk/assistdrive/{field/FieldModelQxxs.cpp => item/ItemModelQxxs.cpp} (78%) rename entry/src/main/cpp/sdk/assistdrive/{field/FieldModelQxxs.h => item/ItemModelQxxs.h} (62%) rename entry/src/main/cpp/sdk/assistdrive/{field/FieldModelZjzw.cpp => item/ItemModelZjzw.cpp} (78%) rename entry/src/main/cpp/sdk/assistdrive/{field/FieldModelZjzw.h => item/ItemModelZjzw.h} (58%) create mode 100644 entry/src/main/cpp/sdk/assistdrive/track/pathTrack/PathTrackAbstractClass.h create mode 100644 entry/src/main/cpp/sdk/assistdrive/track/pathTrack/PathTrackDefines.h create mode 100644 entry/src/main/cpp/sdk/assistdrive/track/pathTrack/PathTrackMethodLQR.h create mode 100644 entry/src/main/cpp/sdk/assistdrive/track/pathTrack/PathTrackMethodPursuit.cpp create mode 100644 entry/src/main/cpp/sdk/assistdrive/track/pathTrack/PathTrackMethodPursuit.h delete mode 100644 entry/src/main/cpp/sdk/assistdrive/track/pathTrack/purp/CtrlParam.h rename entry/src/main/cpp/sdk/assistdrive/track/pathTrack/{purp => pursuitMethod}/PathTracking.cpp (59%) rename entry/src/main/cpp/sdk/assistdrive/track/pathTrack/{purp => pursuitMethod}/PathTracking.h (81%) rename entry/src/main/cpp/sdk/assistdrive/track/pathTrack/{purp => pursuitMethod}/State.h (100%) rename entry/src/main/cpp/sdk/assistdrive/track/pathTrack/{purp => pursuitMethod}/States.h (100%) rename entry/src/main/cpp/sdk/assistdrive/track/pathTrack/{purp => pursuitMethod}/TargetCourse.cpp (93%) rename entry/src/main/cpp/sdk/assistdrive/track/pathTrack/{purp => pursuitMethod}/TargetCourse.h (94%) diff --git a/entry/src/main/cpp/CMakeLists.txt b/entry/src/main/cpp/CMakeLists.txt index c307973..ec45215 100644 --- a/entry/src/main/cpp/CMakeLists.txt +++ b/entry/src/main/cpp/CMakeLists.txt @@ -326,17 +326,14 @@ set(JUDGE_INCLUDE ${CMAKE_SOURCE_DIR}/sdk/judge/sub2 ${CMAKE_SOURCE_DIR}/sdk/judge/sub3 ${CMAKE_SOURCE_DIR}/sdk/assistdrive - ${CMAKE_SOURCE_DIR}/sdk/assistdrive/navigate ${CMAKE_SOURCE_DIR}/sdk/assistdrive/track ${CMAKE_SOURCE_DIR}/sdk/assistdrive/track/libTrack ${CMAKE_SOURCE_DIR}/sdk/assistdrive/track/pathTrack - ${CMAKE_SOURCE_DIR}/sdk/assistdrive/track/pathTrack/purp + ${CMAKE_SOURCE_DIR}/sdk/assistdrive/track/pathTrack/pursuitMethod ${CMAKE_SOURCE_DIR}/sdk/assistdrive/track/teachTrack - ${CMAKE_SOURCE_DIR}/sdk/assistdrive/track/trackInfo ${CMAKE_SOURCE_DIR}/sdk/assistdrive/track/trackMode ${CMAKE_SOURCE_DIR}/sdk/assistdrive/util - ${CMAKE_SOURCE_DIR}/sdk/assistdrive/wirecontrol - ${CMAKE_SOURCE_DIR}/sdk/assistdrive/field + ${CMAKE_SOURCE_DIR}/sdk/assistdrive/item ) #设置全局包含的源文件 @@ -387,8 +384,7 @@ file(GLOB_RECURSE JUDGE_SOURCE ${CMAKE_SOURCE_DIR}/sdk/assistdrive/*.* ${CMAKE_SOURCE_DIR}/sdk/assistdrive/track/*.* ${CMAKE_SOURCE_DIR}/sdk/assistdrive/util/*.* - ${CMAKE_SOURCE_DIR}/sdk/assistdrive/wirecontrol/*.* - ${CMAKE_SOURCE_DIR}/sdk/assistdrive/field/*.* + ${CMAKE_SOURCE_DIR}/sdk/assistdrive/item/*.* ) #设置编译的包含的目标工程 diff --git a/entry/src/main/cpp/sdk/api/include/JudgeSdk.h b/entry/src/main/cpp/sdk/api/include/JudgeSdk.h index ff2437e..34b300a 100644 --- a/entry/src/main/cpp/sdk/api/include/JudgeSdk.h +++ b/entry/src/main/cpp/sdk/api/include/JudgeSdk.h @@ -57,10 +57,10 @@ typedef void(JUDGE_SDK_CALLBACK* autoServerControlCallback)(const char* data, in /** * 说明: 辅助驾驶教学语音回调函数原型 - * 参数: itemIndex: 项目编号; soundIndex: 语音编号 + * 参数: data: 项目语音数据; length: 数据长度 * 返回值: 无 */ -typedef void(JUDGE_SDK_CALLBACK* autoServerSoundCallback)(int itemIndex, int soundIndex); +typedef void(JUDGE_SDK_CALLBACK* autoServerSoundCallback)(const char* data, int length); /** * 说明: 辅助驾驶日志回调函数原型 diff --git a/entry/src/main/cpp/sdk/api/js/JSApiBridge.cpp b/entry/src/main/cpp/sdk/api/js/JSApiBridge.cpp index d38dcf2..a7fc82e 100644 --- a/entry/src/main/cpp/sdk/api/js/JSApiBridge.cpp +++ b/entry/src/main/cpp/sdk/api/js/JSApiBridge.cpp @@ -20,7 +20,7 @@ JSApiBridge::~JSApiBridge() JS_JUDGE_FUN_IMPL(examJudgeVersion) { logdebug("call js_examJudgeVersion"); - const char* version = ExamService::examJudgeVersion(); + const char *version = ExamService::examJudgeVersion(); return createString(env, std::string(nullptr != version ? version : "")); } @@ -49,19 +49,18 @@ JS_JUDGE_FUN_IMPL(examJudgeSetLogCallback) // } bool ok = m_methodLog.setup( - env, ref, [](napi_env nenv, napi_ref nref, JSAsyncContextLog* ctx) -> bool { + env, ref, [](napi_env nenv, napi_ref nref, JSAsyncContextLog *ctx) -> bool { napi_value func = nullptr, result = nullptr; size_t argc = 3; napi_value args[3] = {nullptr}; // napi_get_undefined(ctx->env, &result); // 调用napi - return napi_ok == napi_get_reference_value(nenv, nref, &func) - && napi_ok == napi_create_int32(nenv, ctx->level, &args[0]) - && napi_ok - == napi_create_string_utf8(nenv, ctx->log.c_str(), ctx->log.length(), - &args[1]) - && napi_ok == napi_create_int32(nenv, ctx->log.length(), &args[2]) - && napi_ok == napi_call_function(nenv, nullptr, func, argc, args, &result); + return napi_ok == napi_get_reference_value(nenv, nref, &func) && + napi_ok == napi_create_int32(nenv, ctx->level, &args[0]) && + napi_ok == napi_create_string_utf8(nenv, ctx->log.c_str(), ctx->log.length(), + &args[1]) && + napi_ok == napi_create_int32(nenv, ctx->log.length(), &args[2]) && + napi_ok == napi_call_function(nenv, nullptr, func, argc, args, &result); }); if (!ok) @@ -90,7 +89,7 @@ JS_JUDGE_FUN_IMPL(examJudgeErrorInfo) return createErrorCode(env, errorNapiArgType); } - const char* errinfo = ExamService::examJudgeErrorInfo(errCode); + const char *errinfo = ExamService::examJudgeErrorInfo(errCode); return createString(env, std::string(nullptr != errinfo ? errinfo : "")); } @@ -195,18 +194,17 @@ JS_JUDGE_FUN_IMPL(examJudgeSetRealExamCallback) // } bool ok = m_methodReal.setup( - env, ref, [](napi_env nenv, napi_ref nref, JSAsyncContextReal* ctx) -> bool { + env, ref, [](napi_env nenv, napi_ref nref, JSAsyncContextReal *ctx) -> bool { napi_value func = nullptr, result = nullptr; size_t argc = 2; napi_value args[2] = {nullptr}; // napi_get_undefined(ctx->env, &result); // 调用napi - return napi_ok == napi_get_reference_value(nenv, nref, &func) - && napi_ok - == napi_create_string_utf8(nenv, ctx->data.c_str(), ctx->data.length(), - &args[0]) - && napi_ok == napi_create_int32(nenv, ctx->data.length(), &args[1]) - && napi_ok == napi_call_function(nenv, nullptr, func, argc, args, &result); + return napi_ok == napi_get_reference_value(nenv, nref, &func) && + napi_ok == napi_create_string_utf8(nenv, ctx->data.c_str(), ctx->data.length(), + &args[0]) && + napi_ok == napi_create_int32(nenv, ctx->data.length(), &args[1]) && + napi_ok == napi_call_function(nenv, nullptr, func, argc, args, &result); }); if (!ok) @@ -237,18 +235,17 @@ JS_JUDGE_FUN_IMPL(examJudgeSetPerformCallback) // } bool ok = m_methodPerform.setup( - env, ref, [](napi_env nenv, napi_ref nref, JSAsyncContextPerform* ctx) -> bool { + env, ref, [](napi_env nenv, napi_ref nref, JSAsyncContextPerform *ctx) -> bool { napi_value func = nullptr, result = nullptr; size_t argc = 2; napi_value args[2] = {nullptr}; // napi_get_undefined(ctx->env, &result); // 调用napi - return napi_ok == napi_get_reference_value(nenv, nref, &func) - && napi_ok - == napi_create_string_utf8(nenv, ctx->data.c_str(), ctx->data.length(), - &args[0]) - && napi_ok == napi_create_int32(nenv, ctx->data.length(), &args[1]) - && napi_ok == napi_call_function(nenv, nullptr, func, argc, args, &result); + return napi_ok == napi_get_reference_value(nenv, nref, &func) && + napi_ok == napi_create_string_utf8(nenv, ctx->data.c_str(), ctx->data.length(), + &args[0]) && + napi_ok == napi_create_int32(nenv, ctx->data.length(), &args[1]) && + napi_ok == napi_call_function(nenv, nullptr, func, argc, args, &result); }); if (!ok) @@ -318,8 +315,8 @@ JS_JUDGE_FUN_IMPL(examJudgeSoundEnd) int itemno = 0; std::string code = ""; int type = 0; - if (!getInt(env, args[0], itemno) || !getString(env, args[1], code) - || !getInt(env, args[2], type)) + if (!getInt(env, args[0], itemno) || !getString(env, args[1], code) || + !getInt(env, args[2], type)) { return createErrorCode(env, errorNapiArgType); } @@ -331,7 +328,7 @@ JS_JUDGE_FUN_IMPL(examJudgeSoundEnd) JS_JUDGE_FUN_IMPL(examJudgeTrackFile) { logdebug("call js_examJudgeTrackFile"); - const char* filename = ExamService::examJudgeTrackFile(); + const char *filename = ExamService::examJudgeTrackFile(); return createString(env, std::string(nullptr != filename ? filename : "")); } @@ -402,7 +399,7 @@ JS_JUDGE_FUN_IMPL(examJudgeMapImage) { logdebug("call js_examJudgeMapImage"); // GraphicImage img; - const char* data = ExamService::examJudgeMapImage(); + const char *data = ExamService::examJudgeMapImage(); int size = ExamService::examJudgeMapSize(); return createArrayBuffer(env, data, size, sizeof(char), napi_uint8_clamped_array); } @@ -426,22 +423,21 @@ JS_JUDGE_FUN_IMPL(examJudgeMapImageSetCallback) // } bool ok = m_methodMap.setup( - env, ref, [](napi_env nenv, napi_ref nref, JSAsyncContextMap* ctx) -> bool { + env, ref, [](napi_env nenv, napi_ref nref, JSAsyncContextMap *ctx) -> bool { napi_value func = nullptr, result = nullptr; size_t argc = 2; napi_value args[2] = {nullptr}; // napi_get_undefined(ctx->env, &result); // 调用napi napi_value buf = nullptr; - void* under = nullptr; + void *under = nullptr; napi_create_arraybuffer(nenv, ctx->size * sizeof(char), &under, &buf); memcpy(under, ctx->buf, ctx->size * sizeof(char)); - return napi_ok == napi_get_reference_value(nenv, nref, &func) - && napi_ok - == napi_create_typedarray(nenv, napi_uint8_clamped_array, ctx->size, buf, - 0, &args[0]) - && napi_ok == napi_create_int32(nenv, ctx->size, &args[1]) - && napi_ok == napi_call_function(nenv, nullptr, func, argc, args, &result); + return napi_ok == napi_get_reference_value(nenv, nref, &func) && + napi_ok == napi_create_typedarray(nenv, napi_uint8_clamped_array, ctx->size, buf, + 0, &args[0]) && + napi_ok == napi_create_int32(nenv, ctx->size, &args[1]) && + napi_ok == napi_call_function(nenv, nullptr, func, argc, args, &result); }); if (!ok) @@ -651,8 +647,8 @@ JS_JUDGE_FUN_IMPL(autoServiceTrack) double y = 0.0; double yaw = 0.0; double v = 0.0; - if (!getDouble(env, args[0], x) || !getDouble(env, args[1], y) || !getDouble(env, args[2], yaw) - || !getDouble(env, args[3], v)) + if (!getDouble(env, args[0], x) || !getDouble(env, args[1], y) || + !getDouble(env, args[2], yaw) || !getDouble(env, args[3], v)) { return createErrorCode(env, errorNapiArgType); } @@ -697,20 +693,19 @@ JS_JUDGE_FUN_IMPL(registerMapImageCallback) napi_value ref = args[0]; bool ok = m_methodMap.setup( - env, ref, [](napi_env nenv, napi_ref nref, JSAsyncContextMap* ctx) -> bool { + env, ref, [](napi_env nenv, napi_ref nref, JSAsyncContextMap *ctx) -> bool { napi_value func = nullptr, result = nullptr; size_t argc = 2; napi_value args[2] = {nullptr}; napi_value buf = nullptr; - void* under = nullptr; + void *under = nullptr; napi_create_arraybuffer(nenv, ctx->size * sizeof(char), &under, &buf); memcpy(under, ctx->buf, ctx->size * sizeof(char)); - return napi_ok == napi_get_reference_value(nenv, nref, &func) - && napi_ok - == napi_create_typedarray(nenv, napi_uint8_clamped_array, ctx->size, buf, - 0, &args[0]) - && napi_ok == napi_create_int32(nenv, ctx->size, &args[1]) - && napi_ok == napi_call_function(nenv, nullptr, func, argc, args, &result); + return napi_ok == napi_get_reference_value(nenv, nref, &func) && + napi_ok == napi_create_typedarray(nenv, napi_uint8_clamped_array, ctx->size, buf, + 0, &args[0]) && + napi_ok == napi_create_int32(nenv, ctx->size, &args[1]) && + napi_ok == napi_call_function(nenv, nullptr, func, argc, args, &result); }); if (!ok) @@ -735,21 +730,18 @@ JS_JUDGE_FUN_IMPL(registerAutoServiceControlCallback) napi_value ref = args[0]; - bool ok = m_methodMap.setup( - env, ref, [](napi_env nenv, napi_ref nref, JSAsyncContextMap* ctx) -> bool { + bool ok = m_autoServiceControl.setup( + env, ref, [](napi_env nenv, napi_ref nref, JSAsyncContextString *ctx) -> bool { napi_value func = nullptr, result = nullptr; size_t argc = 2; napi_value args[2] = {nullptr}; - napi_value buf = nullptr; - void* under = nullptr; - napi_create_arraybuffer(nenv, ctx->size * sizeof(char), &under, &buf); - memcpy(under, ctx->buf, ctx->size * sizeof(char)); - return napi_ok == napi_get_reference_value(nenv, nref, &func) - && napi_ok - == napi_create_typedarray(nenv, napi_uint8_clamped_array, ctx->size, buf, - 0, &args[0]) - && napi_ok == napi_create_int32(nenv, ctx->size, &args[1]) - && napi_ok == napi_call_function(nenv, nullptr, func, argc, args, &result); + // napi_get_undefined(ctx->env, &result); + // 调用napi + return napi_ok == napi_get_reference_value(nenv, nref, &func) && + napi_ok == napi_create_string_utf8(nenv, ctx->data.c_str(), ctx->data.length(), + &args[0]) && + napi_ok == napi_create_int32(nenv, ctx->data.length(), &args[1]) && + napi_ok == napi_call_function(nenv, nullptr, func, argc, args, &result); }); if (!ok) @@ -774,21 +766,18 @@ JS_JUDGE_FUN_IMPL(registerAutoServiceSoundCallback) napi_value ref = args[0]; - bool ok = m_methodMap.setup( - env, ref, [](napi_env nenv, napi_ref nref, JSAsyncContextMap* ctx) -> bool { + bool ok = m_autoServiceSound.setup( + env, ref, [](napi_env nenv, napi_ref nref, JSAsyncContextString *ctx) -> bool { napi_value func = nullptr, result = nullptr; size_t argc = 2; napi_value args[2] = {nullptr}; - napi_value buf = nullptr; - void* under = nullptr; - napi_create_arraybuffer(nenv, ctx->size * sizeof(char), &under, &buf); - memcpy(under, ctx->buf, ctx->size * sizeof(char)); - return napi_ok == napi_get_reference_value(nenv, nref, &func) - && napi_ok - == napi_create_typedarray(nenv, napi_uint8_clamped_array, ctx->size, buf, - 0, &args[0]) - && napi_ok == napi_create_int32(nenv, ctx->size, &args[1]) - && napi_ok == napi_call_function(nenv, nullptr, func, argc, args, &result); + // napi_get_undefined(ctx->env, &result); + // 调用napi + return napi_ok == napi_get_reference_value(nenv, nref, &func) && + napi_ok == napi_create_string_utf8(nenv, ctx->data.c_str(), ctx->data.length(), + &args[0]) && + napi_ok == napi_create_int32(nenv, ctx->data.length(), &args[1]) && + napi_ok == napi_call_function(nenv, nullptr, func, argc, args, &result); }); if (!ok) @@ -813,21 +802,18 @@ JS_JUDGE_FUN_IMPL(registerAutoServiceLogCallback) napi_value ref = args[0]; - bool ok = m_methodMap.setup( - env, ref, [](napi_env nenv, napi_ref nref, JSAsyncContextMap* ctx) -> bool { + bool ok = m_autoServiceLog.setup( + env, ref, [](napi_env nenv, napi_ref nref, JSAsyncContextString *ctx) -> bool { napi_value func = nullptr, result = nullptr; size_t argc = 2; napi_value args[2] = {nullptr}; - napi_value buf = nullptr; - void* under = nullptr; - napi_create_arraybuffer(nenv, ctx->size * sizeof(char), &under, &buf); - memcpy(under, ctx->buf, ctx->size * sizeof(char)); - return napi_ok == napi_get_reference_value(nenv, nref, &func) - && napi_ok - == napi_create_typedarray(nenv, napi_uint8_clamped_array, ctx->size, buf, - 0, &args[0]) - && napi_ok == napi_create_int32(nenv, ctx->size, &args[1]) - && napi_ok == napi_call_function(nenv, nullptr, func, argc, args, &result); + // napi_get_undefined(ctx->env, &result); + // 调用napi + return napi_ok == napi_get_reference_value(nenv, nref, &func) && + napi_ok == napi_create_string_utf8(nenv, ctx->data.c_str(), ctx->data.length(), + &args[0]) && + napi_ok == napi_create_int32(nenv, ctx->data.length(), &args[1]) && + napi_ok == napi_call_function(nenv, nullptr, func, argc, args, &result); }); if (!ok) @@ -835,32 +821,32 @@ JS_JUDGE_FUN_IMPL(registerAutoServiceLogCallback) return createErrorCode(env, errorNapiSetCallback); } - int code = AutomaticService::registerAutoServiceLogCallback(nullptr); + int code = AutomaticService::registerAutoServiceControlCallback(nullptr); return createErrorCode(env, code); } -void JSApiBridge::examJudgeCallbackLogToCaller(int level, const char* info, int len) +void JSApiBridge::examJudgeCallbackLogToCaller(int level, const char *info, int len) { if (level < LOG_LV_CLOSE || level > LOG_LV_ALL || nullptr == info || len <= 0) return; m_methodLog.submit(level, std::string(info, len)); } -void JSApiBridge::examJudgeCallbackRealExamToCaller(const char* data, int len) +void JSApiBridge::examJudgeCallbackRealExamToCaller(const char *data, int len) { if (nullptr == data || len <= 0) return; m_methodReal.submit(std::string(data, len)); } -void JSApiBridge::examJudgeCallbackPerformToCaller(const char* data, int len) +void JSApiBridge::examJudgeCallbackPerformToCaller(const char *data, int len) { if (nullptr == data || len <= 0) return; m_methodPerform.submit(std::string(data, len)); } -void JSApiBridge::examJudgeCallbackMapImageToCaller(const char* data, int len) +void JSApiBridge::examJudgeCallbackMapImageToCaller(const char *data, int len) { if (nullptr == data || len <= 0) return; @@ -868,7 +854,30 @@ void JSApiBridge::examJudgeCallbackMapImageToCaller(const char* data, int len) m_methodMap.submit(data, len); } -bool JSApiBridge::getArg(napi_env env, napi_callback_info cbinfo, size_t& count, napi_value* values) +void JSApiBridge::autoServiceCallbackControlToCaller(const char *data, int length) +{ + if (nullptr == data || length <= 0) + return; + m_autoServiceControl.submit(std::string(data, length)); +} + +void JSApiBridge::autoServiceCallbackSoundToCaller(const char *data, int length) +{ + if (nullptr == data || length <= 0) + { + return; + } + m_autoServiceSound.submit(std::string(data, length)); +} + +void JSApiBridge::autoServiceCallbackLogToCaller(const char *data, int length) +{ + if (nullptr == data || length <= 0) + return; + m_autoServiceLog.submit(std::string(data, length)); +} + +bool JSApiBridge::getArg(napi_env env, napi_callback_info cbinfo, size_t &count, napi_value *values) { size_t argc = count; napi_status status = napi_get_cb_info(env, cbinfo, &argc, values, nullptr, nullptr); @@ -886,7 +895,7 @@ bool JSApiBridge::getArg(napi_env env, napi_callback_info cbinfo, size_t& count, return true; } -bool JSApiBridge::getString(napi_env env, napi_value nva, std::string& value) +bool JSApiBridge::getString(napi_env env, napi_value nva, std::string &value) { napi_valuetype type; napi_status status = napi_typeof(env, nva, &type); @@ -919,7 +928,7 @@ bool JSApiBridge::getString(napi_env env, napi_value nva, std::string& value) return true; } -bool JSApiBridge::getInt(napi_env env, napi_value nva, int& value) +bool JSApiBridge::getInt(napi_env env, napi_value nva, int &value) { napi_valuetype type; napi_status status = napi_typeof(env, nva, &type); @@ -944,7 +953,7 @@ bool JSApiBridge::getInt(napi_env env, napi_value nva, int& value) return true; } -bool JSApiBridge::getInt64(napi_env env, napi_value nva, int64& value) +bool JSApiBridge::getInt64(napi_env env, napi_value nva, int64 &value) { napi_valuetype type; napi_status status = napi_typeof(env, nva, &type); @@ -969,7 +978,7 @@ bool JSApiBridge::getInt64(napi_env env, napi_value nva, int64& value) return true; } -bool JSApiBridge::getDouble(napi_env env, napi_value nva, double& value) +bool JSApiBridge::getDouble(napi_env env, napi_value nva, double &value) { napi_valuetype type; napi_status status = napi_typeof(env, nva, &type); @@ -994,7 +1003,7 @@ bool JSApiBridge::getDouble(napi_env env, napi_value nva, double& value) return true; } -bool JSApiBridge::getBool(napi_env env, napi_value nva, bool& value) +bool JSApiBridge::getBool(napi_env env, napi_value nva, bool &value) { napi_valuetype type; napi_status status = napi_typeof(env, nva, &type); @@ -1019,7 +1028,7 @@ bool JSApiBridge::getBool(napi_env env, napi_value nva, bool& value) return true; } -bool JSApiBridge::getRef(napi_env env, napi_value nva, napi_ref& value) +bool JSApiBridge::getRef(napi_env env, napi_value nva, napi_ref &value) { napi_valuetype type = napi_undefined; napi_status status = napi_typeof(env, nva, &type); @@ -1044,7 +1053,7 @@ bool JSApiBridge::getRef(napi_env env, napi_value nva, napi_ref& value) return true; } -napi_value JSApiBridge::createErrorCode(napi_env env, int code, const char* desc, const char* file, +napi_value JSApiBridge::createErrorCode(napi_env env, int code, const char *desc, const char *file, int line) { if (codeSuccess != code) @@ -1077,7 +1086,7 @@ napi_value JSApiBridge::createInt64(napi_env env, int64 value) return result; } -napi_value JSApiBridge::createString(napi_env env, const std::string& value) +napi_value JSApiBridge::createString(napi_env env, const std::string &value) { napi_value result = nullptr; napi_status status = napi_create_string_utf8(env, value.c_str(), value.length(), &result); @@ -1088,13 +1097,13 @@ napi_value JSApiBridge::createString(napi_env env, const std::string& value) return result; } -napi_value JSApiBridge::createArrayBuffer(napi_env env, const void* data, size_t size, size_t chunk, +napi_value JSApiBridge::createArrayBuffer(napi_env env, const void *data, size_t size, size_t chunk, napi_typedarray_type type) { const size_t offset = 0; // 偏移字节数 size_t bytes = size * chunk; // 数据字节数 napi_value buf = nullptr; - void* under = nullptr; + void *under = nullptr; napi_status status = napi_create_arraybuffer(env, bytes, &under, &buf); if (napi_ok != status) { diff --git a/entry/src/main/cpp/sdk/api/js/JSApiBridge.h b/entry/src/main/cpp/sdk/api/js/JSApiBridge.h index f68d58b..40fb479 100644 --- a/entry/src/main/cpp/sdk/api/js/JSApiBridge.h +++ b/entry/src/main/cpp/sdk/api/js/JSApiBridge.h @@ -56,38 +56,49 @@ public: JS_JUDGE_FUN_DECL(registerAutoServiceSoundCallback); JS_JUDGE_FUN_DECL(registerAutoServiceLogCallback); - virtual void examJudgeCallbackLogToCaller(int level, const char* info, int len) override; - virtual void examJudgeCallbackRealExamToCaller(const char* data, int len) override; - virtual void examJudgeCallbackPerformToCaller(const char* data, int len) override; - virtual void examJudgeCallbackMapImageToCaller(const char* data, int len) override; + virtual void examJudgeCallbackLogToCaller(int level, const char *info, int len) override; + virtual void examJudgeCallbackRealExamToCaller(const char *data, int len) override; + virtual void examJudgeCallbackPerformToCaller(const char *data, int len) override; + virtual void examJudgeCallbackMapImageToCaller(const char *data, int len) override; + + virtual void autoServiceCallbackControlToCaller(const char *data, int length) override; + virtual void autoServiceCallbackSoundToCaller(const char *data, int length) override; + virtual void autoServiceCallbackLogToCaller(const char *data, int length) override; private: - //uv_work_t* m_work = nullptr; - JSAsyncMethod m_methodLog; - JSAsyncMethod m_methodReal; - JSAsyncMethod m_methodPerform; - JSAsyncMethod m_methodMap; + // uv_work_t* m_work = nullptr; + JSAsyncMethod m_methodLog; + JSAsyncMethod m_methodReal; + JSAsyncMethod m_methodPerform; + JSAsyncMethod m_methodMap; + + JSAsyncMethod m_autoServiceControl; + JSAsyncMethod m_autoServiceSound; + JSAsyncMethod m_autoServiceLog; + public: - bool getArg (napi_env env, napi_callback_info cbinfo, size_t& count, napi_value* values); - bool getInt (napi_env env, napi_value nva, int& value); - bool getInt64 (napi_env env, napi_value nva, int64& value); - bool getDouble(napi_env env, napi_value nva, double& value); - bool getString(napi_env env, napi_value nva, std::string& value); - bool getBool (napi_env env, napi_value nva, bool& value); - bool getRef (napi_env env, napi_value nva, napi_ref& value); + bool getArg(napi_env env, napi_callback_info cbinfo, size_t &count, napi_value *values); + bool getInt(napi_env env, napi_value nva, int &value); + bool getInt64(napi_env env, napi_value nva, int64 &value); + bool getDouble(napi_env env, napi_value nva, double &value); + bool getString(napi_env env, napi_value nva, std::string &value); + bool getBool(napi_env env, napi_value nva, bool &value); + bool getRef(napi_env env, napi_value nva, napi_ref &value); - napi_value createErrorCode(napi_env env, int code, const char* desc = "", const char* file = __FILE__, int line = __LINE__); - napi_value createInt (napi_env env, int value); - napi_value createInt64 (napi_env env, int64 value); - napi_value createString (napi_env env, const std::string& value); - //size元素数量 chunk每个元素字节大小 - napi_value createArrayBuffer(napi_env env, const void* data, size_t size, size_t chunk=sizeof(char), napi_typedarray_type type = napi_uint8_clamped_array); + napi_value createErrorCode(napi_env env, int code, const char *desc = "", + const char *file = __FILE__, int line = __LINE__); + napi_value createInt(napi_env env, int value); + napi_value createInt64(napi_env env, int64 value); + napi_value createString(napi_env env, const std::string &value); + // size元素数量 chunk每个元素字节大小 + napi_value createArrayBuffer(napi_env env, const void *data, size_t size, + size_t chunk = sizeof(char), + napi_typedarray_type type = napi_uint8_clamped_array); - //获取napi版本号 + // 获取napi版本号 std::string getNapiVersion(napi_env env); - }; -#endif // JUDGE_OS_OHOS +#endif // JUDGE_OS_OHOS #endif // JSAPIBRIDGE_H diff --git a/entry/src/main/cpp/sdk/assistdrive/AutomaticService.cpp b/entry/src/main/cpp/sdk/assistdrive/AutomaticService.cpp index 7b8560c..26bd311 100644 --- a/entry/src/main/cpp/sdk/assistdrive/AutomaticService.cpp +++ b/entry/src/main/cpp/sdk/assistdrive/AutomaticService.cpp @@ -9,20 +9,24 @@ #include "AutomaticServiceDataManager.h" #include "AutomaticServiceLogManager.h" #include "GraphicTools.h" +#include "HFactory.h" using namespace automatic_service; constexpr auto kDefaultRealRange = 50; // 绘图实际边长(单位:米) -AutomaticService::AutomaticService() { pGraphicTool_ = __NEW__(GraphicImage); } +AutomaticService::AutomaticService() +{ + pGraphicTool_ = __NEW__(GraphicImage); +} int AutomaticService::autoServiceInit() { - fieldModelPtrList_.emplace_back(new FieldModelDcrk()); - fieldModelPtrList_.emplace_back(new FieldModelZjzw()); - fieldModelPtrList_.emplace_back(new FieldModelCftc()); - fieldModelPtrList_.emplace_back(new FieldModelPdqb()); - fieldModelPtrList_.emplace_back(new FieldModelQxxs()); + fieldModelPtrList_.emplace_back(new ItemModelDcrk()); + fieldModelPtrList_.emplace_back(new ItemModelZjzw()); + fieldModelPtrList_.emplace_back(new ItemModelCftc()); + fieldModelPtrList_.emplace_back(new ItemModelPdqb()); + fieldModelPtrList_.emplace_back(new ItemModelQxxs()); if (!pTrackInfo_) { @@ -49,8 +53,12 @@ int AutomaticService::autoServiceSetBasePoint(const char *data, int length) { std::string errorInfo = e.what(); AutomaticServiceLogManager::GetInstance()->log(errorInfo); + FactoryAutomaticApi->autoServiceCallbackLogToCaller(errorInfo.c_str(), + errorInfo.size()); } + std::string logText = "[AutomaticService] setBasePoint finish."; + FactoryAutomaticApi->autoServiceCallbackLogToCaller(logText.c_str(), logText.size()); return 0; } @@ -61,8 +69,8 @@ int AutomaticService::autoServiceSetFieldModel(const char *data, int length) std::wstring_convert> convert; std::wstring str = convert.from_bytes(data); nlohmann::json fieldModelListJson = nlohmann::json::parse(str); - AutomaticServiceDataManager::GetInstance()->fieldModelList() = - fieldModelListJson.get(); + AutomaticServiceDataManager::GetInstance()->itemModelList() = + fieldModelListJson.get(); } catch (std::exception &e) { @@ -72,7 +80,7 @@ int AutomaticService::autoServiceSetFieldModel(const char *data, int length) for (size_t i = 0; i < fieldModelPtrList_.size(); i++) { - FieldModelAbstractClass *pCurrModel = fieldModelPtrList_[i]; + ItemModelAbstractClass *pCurrModel = fieldModelPtrList_[i]; pCurrModel->initModelPoint(); } @@ -116,7 +124,7 @@ int AutomaticService::autoServiceSetTeachPointParam(const char *data, int length for (size_t i = 0; i < fieldModelPtrList_.size(); i++) { - FieldModelAbstractClass *pCurrModel = fieldModelPtrList_[i]; + ItemModelAbstractClass *pCurrModel = fieldModelPtrList_[i]; pCurrModel->initTeachPoint(); } @@ -148,7 +156,6 @@ int AutomaticService::autoServiceSetLineInfo(const char *data, int length) std::wstring_convert> convert; std::wstring str = convert.from_bytes(temp.c_str()); nlohmann::json lineInfoJson = nlohmann::json::parse(str); - auto temp1 = lineInfoJson.get(); AutomaticServiceDataManager::GetInstance()->lineInfo() = lineInfoJson.get(); } catch (std::exception &e) @@ -168,7 +175,6 @@ int AutomaticService::autoServiceSetLibInfo(const char *data, int length) std::wstring_convert> convert; std::wstring str = convert.from_bytes(temp.c_str()); nlohmann::json libInfiJson = nlohmann::json::parse(str); - auto temp1 = libInfiJson.get(); AutomaticServiceDataManager::GetInstance()->libInfo() = libInfiJson.get(); } catch (std::exception &e) @@ -197,6 +203,7 @@ int AutomaticService::autoServiceSelectLineAndLib(int lineIndex, int libIndex) int AutomaticService::autoServiceTrack(double x, double y, double yaw, double v) { + // FIXME: 实际使用时,前置机传入经纬度坐标,需要结合基准点计算出相对坐标 double tempX = 0.0; double tempY = 0.0; auto basePoint = AutomaticServiceDataManager::GetInstance()->basePoint(); @@ -228,13 +235,13 @@ int AutomaticService::autoServiceTrack(double x, double y, double yaw, double v) AutoPoint topLeft(x - currCarPosInImage.x / unit_, y - currCarPosInImage.y / unit_); AutoPoint bottomRight(x + currCarPosInImage.x / unit_, y + currCarPosInImage.y / unit_); mapRect_ = AutoRect(topLeft, bottomRight); - std::string logText = "[AutomaticService] topLeft = (" + std::to_string(topLeft.x) + ", " + - std::to_string(topLeft.y) + "); bottomRight = (" + - std::to_string(bottomRight.x) + ", " + std::to_string(bottomRight.y) + - ")"; + std::string logText = "[AutomaticService] topLeft = (" + std::to_string(topLeft.x) + ", " + + std::to_string(topLeft.y) + "); bottomRight = (" + + std::to_string(bottomRight.x) + ", " + std::to_string(bottomRight.y) + + ")"; AutomaticServiceLogManager::GetInstance()->log(logText); - drawFieldModel(x, y); // 绘制场地模型 + drawItemModel(x, y); // 绘制场地模型 // drawCarModel(yaw); // 绘制车模 drawSelectedLine(x, y); // 绘制路径 drawSelectedLib(x, y); // 绘制库位 @@ -250,36 +257,36 @@ int AutomaticService::autoServiceTrack(double x, double y, double yaw, double v) int currTeachPointIndex = -1; for (size_t i = 0; i < fieldModelPtrList_.size(); i++) { - FieldModelAbstractClass *pCurrProject = fieldModelPtrList_[i]; + ItemModelAbstractClass *pCurrProject = fieldModelPtrList_[i]; auto itemStatus = pCurrProject->updateItemStatus(x, y); if (itemStatus == Enter) { - currItem = pCurrProject->getModelName(); + currItem = pCurrProject->getItemName(); currTeachPointIndex = pCurrProject->calculateTeachPoint(x, y); break; } } AutomaticServiceLogManager::GetInstance()->log("[AutomaticService] currItem = " + currItem); - AutomaticServiceLogManager::GetInstance()->log("[AutomaticService] currTeachPointIndex = " + - std::to_string(currTeachPointIndex)); + AutomaticServiceLogManager::GetInstance()->log("[AutomaticService] currTeachPointIndex = " + + std::to_string(currTeachPointIndex)); - if (soundCallback_ && !currItem.empty() && currTeachPointIndex >= 0) - { - soundCallback_(itemIndex2SoundMap[currItem], currTeachPointIndex); - } + // FIXME_zhanke: 封装项目语音回调结构体,并转为json作为回调数据 + // if (soundCallback_ && !currItem.empty() && currTeachPointIndex >= 0) + // { + // soundCallback_(itemIndex2SoundMap[currItem], currTeachPointIndex); + // } // 初始化写入教学配置信息 pTrackInfo_->init(x, y, yaw, v, currItem, currTeachPointIndex); // 开始跟踪算法计算 pTrackModeManager_->init(*pTrackInfo_); - std::string order = pTrackModeManager_->run(*pTrackInfo_); + ControlParam controlParam = pTrackModeManager_->run(*pTrackInfo_); + nlohmann::json orderJson = controlParam; + std::string order = orderJson.dump(); - if (controlCallback_) - { - controlCallback_(order.c_str(), order.size()); - } + autoServiceCallbackControlToCaller(order.c_str(), order.size()); return 0; } @@ -298,7 +305,10 @@ int AutomaticService::autoServiceSetImageSize(int width, int height) return 0; } -TrackInfo AutomaticService::getTrack() { return *pTrackInfo_; } +TrackInfo AutomaticService::getTrack() +{ + return *pTrackInfo_; +} int AutomaticService::registerMapImageCallback(examJudgeCallbackMapImage callback) { @@ -313,45 +323,65 @@ int AutomaticService::registerMapImageCallback(examJudgeCallbackMapImage callbac int AutomaticService::registerAutoServiceControlCallback(autoServerControlCallback callback) { - if (!callback) + if (callback) { - return -1; + controlCallback_ = callback; } - controlCallback_ = callback; return 0; } int AutomaticService::registerAutoServiceSoundCallback(autoServerSoundCallback callback) { - if (!callback) + if (callback) { - return -1; + soundCallback_ = callback; } - soundCallback_ = callback; return 0; } int AutomaticService::registerAutoServiceLogCallback(autoServerLogCallback callback) { - if (!callback) + if (callback) { - return -1; + logCallback_ = callback; } - AutomaticServiceLogManager::GetInstance()->setCallback(callback); - AutomaticServiceLogManager::GetInstance()->log("registerAutoServiceLogCallback success"); return 0; } -void AutomaticService::drawFieldModel(int x, int y) +void AutomaticService::autoServiceCallbackControlToCaller(const char *data, int length) +{ + if (controlCallback_) + { + controlCallback_(data, length); + } +} + +void AutomaticService::autoServiceCallbackSoundToCaller(const char *data, int length) +{ + if (soundCallback_) + { + soundCallback_(data, length); + } +} + +void AutomaticService::autoServiceCallbackLogToCaller(const char *data, int length) +{ + if (logCallback_) + { + logCallback_(data, length); + } +} + +void AutomaticService::drawItemModel(int x, int y) { Pointi currCarPosInImage(imageWidth_ / 2, imageHeight_ / 2); // 绘图画布中心点(单位:像素) Pointi padding(currCarPosInImage.x - x * unit_, currCarPosInImage.y - y * unit_); for (size_t i = 0; i < fieldModelPtrList_.size(); i++) { - FieldModelAbstractClass *pCurrModel = fieldModelPtrList_[i]; + ItemModelAbstractClass *pCurrModel = fieldModelPtrList_[i]; if (pCurrModel->isModelInMapArea(mapRect_)) { // 在框定的视野范围,才绘制模型 @@ -411,7 +441,7 @@ void AutomaticService::drawSelectedLine(int x, int y) AutomaticServiceDataManager::GetInstance()->lineInfo().getFeaturesById(selectedLineIndex_); auto points = selectedLine.geometry.coordinates; std::vector pointList; - FieldModelAbstractClass::transferPoint2ImagePixel(points, padding, unit_, pointList); + ItemModelAbstractClass::transferPoint2ImagePixel(points, padding, unit_, pointList); pGraphicTool_->drawPoint(pointList[0], RGB_GREEN, 2); for (size_t i = 0; i < pointList.size() - 1; i++) { @@ -428,7 +458,7 @@ void AutomaticService::drawSelectedLib(int x, int y) AutomaticServiceDataManager::GetInstance()->libInfo().getFeaturesById(selectedLibIndex_); auto points = selectedLib.geometry.coordinates; std::vector pointList; - FieldModelAbstractClass::transferPoint2ImagePixel(points, padding, unit_, pointList); + ItemModelAbstractClass::transferPoint2ImagePixel(points, padding, unit_, pointList); pGraphicTool_->drawPoint(pointList[0], RGB_GREEN, 2); for (size_t i = 0; i < pointList.size() - 1; i++) { @@ -442,7 +472,7 @@ void AutomaticService::drawCarHistoryPos(int x, int y) Pointi currCarPosInImage(imageWidth_ / 2, imageHeight_ / 2); // 绘图画布中心点(单位:像素) Pointi padding(currCarPosInImage.x - x * unit_, currCarPosInImage.y - y * unit_); std::vector pixelList; - FieldModelAbstractClass::transferPoint2ImagePixel(historyPosList_, padding, unit_, pixelList); + ItemModelAbstractClass::transferPoint2ImagePixel(historyPosList_, padding, unit_, pixelList); pGraphicTool_->drawPoint(pixelList[0], RGB_BLACK, 2); for (size_t i = 1; i < pixelList.size(); i++) { diff --git a/entry/src/main/cpp/sdk/assistdrive/AutomaticService.h b/entry/src/main/cpp/sdk/assistdrive/AutomaticService.h index 662adc6..8c80263 100644 --- a/entry/src/main/cpp/sdk/assistdrive/AutomaticService.h +++ b/entry/src/main/cpp/sdk/assistdrive/AutomaticService.h @@ -10,12 +10,12 @@ #define AUTOMATIC_SERVICE_H_ #include "AutomaticServiceDefines.h" -#include "FieldModelCftc.h" -#include "FieldModelDcrk.h" -#include "FieldModelPdqb.h" -#include "FieldModelQxxs.h" -#include "FieldModelZjzw.h" #include "IAutomaticService.h" +#include "ItemModelCftc.h" +#include "ItemModelDcrk.h" +#include "ItemModelPdqb.h" +#include "ItemModelQxxs.h" +#include "ItemModelZjzw.h" #include "TrackInfo.h" #include "TrackModeManager.h" @@ -38,15 +38,20 @@ public: virtual int autoServiceSelectLineAndLib(int lineIndex, int libIndex) override; virtual int autoServiceTrack(double x, double y, double yaw, double v) override; virtual int autoServiceSetImageSize(int width, int height) override; + virtual int registerMapImageCallback(examJudgeCallbackMapImage callback) override; virtual int registerAutoServiceControlCallback(autoServerControlCallback callback) override; virtual int registerAutoServiceSoundCallback(autoServerSoundCallback callback) override; virtual int registerAutoServiceLogCallback(autoServerLogCallback callback) override; + virtual void autoServiceCallbackControlToCaller(const char *data, int length) override; + virtual void autoServiceCallbackSoundToCaller(const char *data, int length) override; + virtual void autoServiceCallbackLogToCaller(const char *data, int length) override; + TrackInfo getTrack(); private: - void drawFieldModel(int x, int y); + void drawItemModel(int x, int y); void drawCarModel(double yaw); void drawSelectedLine(int x, int y); void drawSelectedLib(int x, int y); @@ -67,9 +72,10 @@ private: examJudgeCallbackMapImage mapImageCallback_ = nullptr; autoServerControlCallback controlCallback_ = nullptr; autoServerSoundCallback soundCallback_ = nullptr; + autoServerLogCallback logCallback_ = nullptr; - std::vector fieldModelPtrList_; // 场地模型指针列表 - std::vector> historyPosList_; // 车辆历史位置 + std::vector fieldModelPtrList_; // 场地模型指针列表 + std::vector> historyPosList_; // 车辆历史位置 }; #endif // !AUTOMATIC_SERVICE_H_ diff --git a/entry/src/main/cpp/sdk/assistdrive/AutomaticServiceDataManager.cpp b/entry/src/main/cpp/sdk/assistdrive/AutomaticServiceDataManager.cpp index 86d1c33..4235fae 100644 --- a/entry/src/main/cpp/sdk/assistdrive/AutomaticServiceDataManager.cpp +++ b/entry/src/main/cpp/sdk/assistdrive/AutomaticServiceDataManager.cpp @@ -7,9 +7,9 @@ BasePoint& AutomaticServiceDataManager::basePoint() return basePoint_; } -FieldModelList& AutomaticServiceDataManager::fieldModelList() +ItemModelList& AutomaticServiceDataManager::itemModelList() { - return fieldModelList_; + return itemModelList_; } TeachItemList& AutomaticServiceDataManager::teachPointInfo() diff --git a/entry/src/main/cpp/sdk/assistdrive/AutomaticServiceDataManager.h b/entry/src/main/cpp/sdk/assistdrive/AutomaticServiceDataManager.h index a4bebbd..fccdec0 100644 --- a/entry/src/main/cpp/sdk/assistdrive/AutomaticServiceDataManager.h +++ b/entry/src/main/cpp/sdk/assistdrive/AutomaticServiceDataManager.h @@ -10,14 +10,13 @@ #define AUTOMATICSERVICEDATAMANAGER_H #include "AutomaticServiceDefines.h" -#include "FieldModelAbstractClass.h" #include "GraphicDefines.h" #include "HSingleton.h" +#include "ItemModelAbstractClass.h" using data::BasePoint; using data::CarModelList; -using data::FieldModel; -using data::FieldModelList; +using data::ItemModelList; using data::TeachItemList; using data::TeachPointList; using data::Track; @@ -29,7 +28,7 @@ class AutomaticServiceDataManager public: BasePoint& basePoint(); - FieldModelList& fieldModelList(); + ItemModelList& itemModelList(); TeachItemList& teachPointInfo(); TeachPointList& teachPointParam(); CarModelList& carModel(); @@ -45,7 +44,7 @@ public: private: BasePoint basePoint_; // 全场基准点 - FieldModelList fieldModelList_; // 场地模型 + ItemModelList itemModelList_; // 项目模型 TeachItemList teachPointInfo_; // 教学点信息 TeachPointList teachPointParam_; // 教学点参数 CarModelList carModel_; // 车辆模型 diff --git a/entry/src/main/cpp/sdk/assistdrive/AutomaticServiceDefines.h b/entry/src/main/cpp/sdk/assistdrive/AutomaticServiceDefines.h index 0c98ed3..e2a34b6 100644 --- a/entry/src/main/cpp/sdk/assistdrive/AutomaticServiceDefines.h +++ b/entry/src/main/cpp/sdk/assistdrive/AutomaticServiceDefines.h @@ -37,7 +37,7 @@ static std::unordered_map itemIndex2SoundMap = { namespace data { -// 场地模型经纬度坐标基准点定义 +// 模型经纬度坐标基准点定义 struct BasePoint { std::string basegpsn; @@ -47,7 +47,7 @@ struct BasePoint }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(BasePoint, basegpsn, basegpse, basegpsnO, basegpseO) -// 场地模型经纬度坐标点定义 +// 模型经纬度坐标点定义 struct ModelPoint { std::string Index; @@ -57,21 +57,21 @@ struct ModelPoint }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ModelPoint, Index, GPSN, GPSE, High) -// 场地模型定义 -struct FieldModel +// 项目模型定义 +struct ItemModel { std::string ModelName; std::string Index; std::vector Points; }; -NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(FieldModel, ModelName, Index, Points) +NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ItemModel, ModelName, Index, Points) -// 场地模型列表 -struct FieldModelList +// 项目模型列表 +struct ItemModelList { - std::vector model; + std::vector model; }; -NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(FieldModelList, model) +NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ItemModelList, model) // 教学点信息定义 struct TeachPointInfo diff --git a/entry/src/main/cpp/sdk/assistdrive/IAutomaticService.h b/entry/src/main/cpp/sdk/assistdrive/IAutomaticService.h index 8f9ca7c..01688ce 100644 --- a/entry/src/main/cpp/sdk/assistdrive/IAutomaticService.h +++ b/entry/src/main/cpp/sdk/assistdrive/IAutomaticService.h @@ -24,6 +24,10 @@ public: virtual int registerAutoServiceControlCallback(autoServerControlCallback callback) = 0; virtual int registerAutoServiceSoundCallback(autoServerSoundCallback callback) = 0; virtual int registerAutoServiceLogCallback(autoServerLogCallback callback) = 0; + + virtual void autoServiceCallbackControlToCaller(const char *data, int length) = 0; + virtual void autoServiceCallbackSoundToCaller(const char *data, int length) = 0; + virtual void autoServiceCallbackLogToCaller(const char *data, int length) = 0; }; #endif // IAUTOMATICSERVICE_H diff --git a/entry/src/main/cpp/sdk/assistdrive/data/aiconfig.json b/entry/src/main/cpp/sdk/assistdrive/data/aiconfig.json new file mode 100644 index 0000000..3a95b02 --- /dev/null +++ b/entry/src/main/cpp/sdk/assistdrive/data/aiconfig.json @@ -0,0 +1,277 @@ +{ + "item": [ + { + "item_code": "20100", + "teach_point": [ + { + "point_index": 1, + "teachName": "进项目-江西蓝天", + "velocity_max": 5.7, + "velocity_std": 3, + "steering_std": 0, + "lamp_std": 0 + }, + { + "point_index": 2, + "teachName": "停车-江西蓝天", + "velocity_max": 7.4, + "velocity_std": 0, + "steering_std": 0, + "lamp_std": 0 + }, + { + "point_index": 3, + "teachName": "右入库第一把右打满-江西蓝天", + "velocity_max": 4.1, + "velocity_std": 0.8, + "steering_std": 540, + "lamp_std": 0 + }, + { + "point_index": 4, + "teachName": "右入库第二把回正-江西蓝天", + "velocity_max": 3.1, + "velocity_std": 0.8, + "steering_std": 0, + "lamp_std": 0 + }, + { + "point_index": 5, + "teachName": "右入库第三把右打满-江西蓝天", + "velocity_max": 2.3, + "velocity_std": 0.8, + "steering_std": 540, + "lamp_std": 0 + }, + { + "point_index": 6, + "teachName": "右入库调整库边距-江西蓝天", + "velocity_max": 2.6, + "velocity_std": 0.8, + "steering_std": 0, + "lamp_std": 0 + }, + { + "point_index": 7, + "teachName": "右入库停车-江西蓝天", + "velocity_max": 3.8, + "velocity_std": 0, + "steering_std": 0, + "lamp_std": 0 + }, + { + "point_index": 8, + "teachName": "左出库-江西蓝天", + "velocity_max": 4.5, + "velocity_std": 0.7, + "steering_std": 540, + "lamp_std": 0 + }, + { + "point_index": 9, + "teachName": "回正方向-江西蓝天", + "velocity_max": 4.3, + "velocity_std": 1.5, + "steering_std": 0, + "lamp_std": 0 + }, + { + "point_index": 10, + "teachName": "左出库停车-江西蓝天", + "velocity_max": 4.9, + "velocity_std": 0, + "steering_std": 0, + "lamp_std": 0 + }, + { + "point_index": 11, + "teachName": "左入库第一把左打满-江西蓝天", + "velocity_max": 3.5, + "velocity_std": 0.8, + "steering_std": 540, + "lamp_std": 0 + }, + { + "point_index": 12, + "teachName": "左入库第二把回正-江西蓝天", + "velocity_max": 3.1, + "velocity_std": 0.8, + "steering_std": 0, + "lamp_std": 0 + }, + { + "point_index": 13, + "teachName": "左入库第三把左打满-江西蓝天", + "velocity_max": 4.1, + "velocity_std": 0.8, + "steering_std": 540, + "lamp_std": 0 + }, + { + "point_index": 14, + "teachName": "左入库调整库边距-江西蓝天", + "velocity_max": 3.3, + "velocity_std": 0.9, + "steering_std": 0, + "lamp_std": 0 + }, + { + "point_index": 15, + "teachName": "左入库停车-江西蓝天", + "velocity_max": 3.5, + "velocity_std": 0, + "steering_std": 0, + "lamp_std": 0 + }, + { + "point_index": 16, + "teachName": "右出库-江西蓝天", + "velocity_max": 4, + "velocity_std": 1.3, + "steering_std": 540, + "lamp_std": 0 + } + ] + }, + { + "item_code": "20700", + "teach_point": [ + { + "point_index": 1, + "teachName": "进项目-江西蓝天-新", + "velocity_max": 7.9, + "velocity_std": 2.2, + "steering_std": 0, + "lamp_std": 1 + }, + { + "point_index": 2, + "teachName": "左转-江西蓝天", + "velocity_max": 7.1, + "velocity_std": 1.7, + "steering_std": 540, + "lamp_std": 1 + } + ] + }, + { + "item_code": "20400", + "teach_point": [ + { + "point_index": 1, + "teachName": "进项目-江西蓝天", + "velocity_max": 8.2, + "velocity_std": 3.3, + "steering_std": 0, + "lamp_std": 0 + }, + { + "point_index": 2, + "teachName": "停车-江西蓝天", + "velocity_max": 7.6, + "velocity_std": 0, + "steering_std": 0, + "lamp_std": 0 + }, + { + "point_index": 3, + "teachName": "入库第一把右打一圈-江西蓝天", + "velocity_max": 5.3, + "velocity_std": 1.2, + "steering_std": 360, + "lamp_std": 0 + }, + { + "point_index": 4, + "teachName": "入库第二把回正方向-江西蓝天", + "velocity_max": 3.4, + "velocity_std": 1.1, + "steering_std": 0, + "lamp_std": 0 + }, + { + "point_index": 5, + "teachName": "入库第三把左打满-江西蓝天", + "velocity_max": 4.8, + "velocity_std": 1.2, + "steering_std": 540, + "lamp_std": 0 + }, + { + "point_index": 6, + "teachName": "入库停车-江西蓝天", + "velocity_max": 3.7, + "velocity_std": 0, + "steering_std": 0, + "lamp_std": 0 + }, + { + "point_index": 8, + "teachName": "出库第二把右打满-江西蓝天", + "velocity_max": 5.7, + "velocity_std": 1.6, + "steering_std": 540, + "lamp_std": -1 + } + ] + }, + { + "item_code": "20300", + "teach_point": [ + { + "point_index": 1, + "teachName": "进项目-江西蓝天", + "velocity_max": 8, + "velocity_std": 4, + "steering_std": 0, + "lamp_std": 0 + }, + { + "point_index": 2, + "teachName": "定点停车-江西蓝天", + "velocity_max": 6, + "velocity_std": 0, + "steering_std": 0, + "lamp_std": 0 + } + ] + }, + { + "item_code": "20600", + "teach_point": [ + { + "point_index": 1, + "teachName": "进项目-蓝天", + "velocity_max": 3.8, + "velocity_std": 1.8, + "steering_std": 0, + "lamp_std": 0 + }, + { + "point_index": 2, + "teachName": "左打一圈-江西蓝天", + "velocity_max": 7.1, + "velocity_std": 2.5, + "steering_std": 360, + "lamp_std": 0 + }, + { + "point_index": 3, + "teachName": "回正方向-江西蓝天", + "velocity_max": 6.3, + "velocity_std": 2, + "steering_std": 0, + "lamp_std": 0 + }, + { + "point_index": 4, + "teachName": "右打一圈-江西蓝天", + "velocity_max": 7.4, + "velocity_std": 2.4, + "steering_std": 360, + "lamp_std": 0 + } + ] + } + ] +} \ No newline at end of file diff --git a/entry/src/main/cpp/sdk/assistdrive/data/basepoint.json b/entry/src/main/cpp/sdk/assistdrive/data/basepoint.json new file mode 100644 index 0000000..fe27c64 --- /dev/null +++ b/entry/src/main/cpp/sdk/assistdrive/data/basepoint.json @@ -0,0 +1,6 @@ +{ + "basegpsn": "31.92780567", + "basegpse": "118.86541574", + "basegpsnO": "31.92780567", + "basegpseO": "118.86541574" +} \ No newline at end of file diff --git a/entry/src/main/cpp/sdk/assistdrive/data/car.json b/entry/src/main/cpp/sdk/assistdrive/data/car.json new file mode 100644 index 0000000..fd6f158 --- /dev/null +++ b/entry/src/main/cpp/sdk/assistdrive/data/car.json @@ -0,0 +1,204 @@ +{ + "Model": [ + { + "Angle": 90, + "BasePointHigh": 26.2752, + "Points": [ + { + "Index": "1", + "High": 26.2752, + "GPSN": 31.717204409, + "GPSE": 117.253089451 + }, + { + "Index": "2", + "High": 26.2752, + "GPSN": 31.717203877, + "GPSE": 117.253084862 + }, + { + "Index": "3", + "High": 26.2752, + "GPSN": 31.717202326, + "GPSE": 117.25308195 + }, + { + "Index": "4", + "High": 26.2752, + "GPSN": 31.717200053, + "GPSE": 117.253080811 + }, + { + "Index": "5", + "High": 26.2752, + "GPSN": 31.717197005, + "GPSE": 117.253080452 + }, + { + "Index": "6", + "High": 26.2752, + "GPSN": 31.717192775, + "GPSE": 117.253080452 + }, + { + "Index": "7", + "High": 26.2752, + "GPSN": 31.717191657, + "GPSE": 117.253080452 + }, + { + "Index": "8", + "High": 26.2752, + "GPSN": 31.717190476, + "GPSE": 117.253080452 + }, + { + "Index": "9", + "High": 26.2752, + "GPSN": 31.717172384, + "GPSE": 117.253080452 + }, + { + "Index": "10", + "High": 26.2752, + "GPSN": 31.71716599, + "GPSE": 117.253081739 + }, + { + "Index": "11", + "High": 26.2752, + "GPSN": 31.717164691, + "GPSE": 117.25308272 + }, + { + "Index": "12", + "High": 26.2752, + "GPSN": 31.717164096, + "GPSE": 117.253084619 + }, + { + "Index": "13", + "High": 26.2752, + "GPSN": 31.717163735, + "GPSE": 117.253089451 + }, + { + "Index": "14", + "High": 26.2752, + "GPSN": 31.717164096, + "GPSE": 117.253094284 + }, + { + "Index": "15", + "High": 26.2752, + "GPSN": 31.717164691, + "GPSE": 117.253096183 + }, + { + "Index": "16", + "High": 26.2752, + "GPSN": 31.71716599, + "GPSE": 117.253097164 + }, + { + "Index": "17", + "High": 26.2752, + "GPSN": 31.717172384, + "GPSE": 117.253098451 + }, + { + "Index": "18", + "High": 26.2752, + "GPSN": 31.717190476, + "GPSE": 117.253098451 + }, + { + "Index": "19", + "High": 26.2752, + "GPSN": 31.717191657, + "GPSE": 117.253098451 + }, + { + "Index": "20", + "High": 26.2752, + "GPSN": 31.717192775, + "GPSE": 117.253098451 + }, + { + "Index": "21", + "High": 26.2752, + "GPSN": 31.717197005, + "GPSE": 117.253098451 + }, + { + "Index": "22", + "High": 26.2752, + "GPSN": 31.717200053, + "GPSE": 117.253098092 + }, + { + "Index": "23", + "High": 26.2752, + "GPSN": 31.717202326, + "GPSE": 117.253096953 + }, + { + "Index": "24", + "High": 26.2752, + "GPSN": 31.717203877, + "GPSE": 117.253094041 + }, + { + "Index": "25", + "High": 26.2752, + "GPSN": 31.717195761, + "GPSE": 117.2530808 + }, + { + "Index": "26", + "High": 26.2752, + "GPSN": 31.717197564, + "GPSE": 117.2530808 + }, + { + "Index": "27", + "High": 26.2752, + "GPSN": 31.717172285, + "GPSE": 117.253080589 + }, + { + "Index": "28", + "High": 26.2752, + "GPSN": 31.717174089, + "GPSE": 117.253080589 + }, + { + "Index": "29", + "High": 26.2752, + "GPSN": 31.717195761, + "GPSE": 117.253098103 + }, + { + "Index": "30", + "High": 26.2752, + "GPSN": 31.717197564, + "GPSE": 117.253098103 + }, + { + "Index": "31", + "High": 26.2752, + "GPSN": 31.717172285, + "GPSE": 117.253098314 + }, + { + "Index": "32", + "High": 26.2752, + "GPSN": 31.717174089, + "GPSE": 117.253098314 + } + ], + "BasePointN": 31.717181863, + "BasePointE": 117.25308444 + } + ] +} diff --git a/entry/src/main/cpp/sdk/assistdrive/data/collect.json b/entry/src/main/cpp/sdk/assistdrive/data/collect.json new file mode 100644 index 0000000..eaa3085 --- /dev/null +++ b/entry/src/main/cpp/sdk/assistdrive/data/collect.json @@ -0,0 +1,1360 @@ +{ + "model": [ + { + "ModelName": "20100", + "Index": "1", + "Points": [ + { + "Index": "1", + "High": 5.652, + "GPSN": 31.927901651, + "GPSE": 118.865305637 + }, + { + "Index": "2", + "High": 5.652, + "GPSN": 31.927842221, + "GPSE": 118.865314541 + }, + { + "Index": "3", + "High": 5.652, + "GPSN": 31.927848137, + "GPSE": 118.865384947 + }, + { + "Index": "4", + "High": 5.652, + "GPSN": 31.927803569, + "GPSE": 118.865391291 + }, + { + "Index": "5", + "High": 5.652, + "GPSN": 31.927805706, + "GPSE": 118.865415677 + }, + { + "Index": "6", + "High": 5.652, + "GPSN": 31.927850806, + "GPSE": 118.865408951 + }, + { + "Index": "7", + "High": 5.652, + "GPSN": 31.927859599, + "GPSE": 118.865478966 + }, + { + "Index": "8", + "High": 5.652, + "GPSN": 31.927919517, + "GPSE": 118.865470305 + } + ] + }, + { + "ModelName": "20700", + "Index": "2", + "Points": [ + { + "Index": "1", + "High": 5.652, + "GPSN": 31.927881793, + "GPSE": 118.865686313 + }, + { + "Index": "2", + "High": 5.652, + "GPSN": 31.927914277, + "GPSE": 118.865681618 + }, + { + "Index": "3", + "High": 5.652, + "GPSN": 31.927917722, + "GPSE": 118.865714991 + }, + { + "Index": "4", + "High": 5.652, + "GPSN": 31.927946445, + "GPSE": 118.865710751 + }, + { + "Index": "5", + "High": 5.652, + "GPSN": 31.927950576, + "GPSE": 118.865748397 + }, + { + "Index": "6", + "High": 5.652, + "GPSN": 31.927889549, + "GPSE": 118.865757671 + } + ] + }, + { + "ModelName": "20400", + "Index": "3", + "Points": [ + { + "Index": "1", + "High": 5.652, + "GPSN": 31.928033327, + "GPSE": 118.865703253 + }, + { + "Index": "2", + "High": 5.652, + "GPSN": 31.928032263, + "GPSE": 118.865739049 + }, + { + "Index": "3", + "High": 5.652, + "GPSN": 31.928042318, + "GPSE": 118.865739461 + }, + { + "Index": "4", + "High": 5.652, + "GPSN": 31.928041741, + "GPSE": 118.86576613 + }, + { + "Index": "5", + "High": 5.652, + "GPSN": 31.928110929, + "GPSE": 118.86576907 + }, + { + "Index": "6", + "High": 5.652, + "GPSN": 31.928111876, + "GPSE": 118.865742306 + }, + { + "Index": "7", + "High": 5.652, + "GPSN": 31.92815667, + "GPSE": 118.865744135 + }, + { + "Index": "8", + "High": 5.652, + "GPSN": 31.928157734, + "GPSE": 118.865708329 + } + ] + }, + { + "ModelName": "20300", + "Index": "4", + "Points": [ + { + "Index": "1", + "High": 5.652, + "GPSN": 31.927865416, + "GPSE": 118.865533203 + }, + { + "Index": "2", + "High": 5.652, + "GPSN": 31.927872189, + "GPSE": 118.865596164 + }, + { + "Index": "3", + "High": 5.652, + "GPSN": 31.927903338, + "GPSE": 118.865591649 + }, + { + "Index": "4", + "High": 5.652, + "GPSN": 31.927903924, + "GPSE": 118.865596873 + }, + { + "Index": "5", + "High": 5.652, + "GPSN": 31.927872784, + "GPSE": 118.865601473 + }, + { + "Index": "6", + "High": 5.652, + "GPSN": 31.927873118, + "GPSE": 118.865604719 + }, + { + "Index": "7", + "High": 5.652, + "GPSN": 31.927904213, + "GPSE": 118.865600087 + }, + { + "Index": "8", + "High": 5.652, + "GPSN": 31.927904916, + "GPSE": 118.865605269 + }, + { + "Index": "9", + "High": 5.652, + "GPSN": 31.927873641, + "GPSE": 118.86560989 + } + ] + }, + { + "ModelName": "20600", + "Index": "5", + "Points": [ + { + "Index": "L1", + "High": 5.652, + "GPSN": 31.928448474, + "GPSE": 118.865759066 + }, + { + "Index": "L2", + "High": 5.652, + "GPSN": 31.928447699, + "GPSE": 118.865755598 + }, + { + "Index": "L3", + "High": 5.652, + "GPSN": 31.928446662, + "GPSE": 118.865752235 + }, + { + "Index": "L4", + "High": 5.652, + "GPSN": 31.92844548, + "GPSE": 118.86574919 + }, + { + "Index": "L5", + "High": 5.652, + "GPSN": 31.928444082, + "GPSE": 118.865746271 + }, + { + "Index": "L6", + "High": 5.652, + "GPSN": 31.928442558, + "GPSE": 118.865743659 + }, + { + "Index": "L7", + "High": 5.652, + "GPSN": 31.92844089, + "GPSE": 118.865741174 + }, + { + "Index": "L8", + "High": 5.652, + "GPSN": 31.928438915, + "GPSE": 118.865738604 + }, + { + "Index": "L9", + "High": 5.652, + "GPSN": 31.928436778, + "GPSE": 118.865736225 + }, + { + "Index": "L10", + "High": 5.652, + "GPSN": 31.928434803, + "GPSE": 118.865734216 + }, + { + "Index": "L11", + "High": 5.652, + "GPSN": 31.928432665, + "GPSE": 118.865732461 + }, + { + "Index": "L12", + "High": 5.652, + "GPSN": 31.928430357, + "GPSE": 118.86573097 + }, + { + "Index": "L13", + "High": 5.652, + "GPSN": 31.92842794, + "GPSE": 118.865729775 + }, + { + "Index": "L14", + "High": 5.652, + "GPSN": 31.928425622, + "GPSE": 118.865728432 + }, + { + "Index": "L15", + "High": 5.652, + "GPSN": 31.928423196, + "GPSE": 118.865727427 + }, + { + "Index": "L16", + "High": 5.652, + "GPSN": 31.928420806, + "GPSE": 118.865726803 + }, + { + "Index": "L17", + "High": 5.652, + "GPSN": 31.92841838, + "GPSE": 118.865726486 + }, + { + "Index": "L18", + "High": 5.652, + "GPSN": 31.928415927, + "GPSE": 118.865726222 + }, + { + "Index": "L19", + "High": 5.652, + "GPSN": 31.928413465, + "GPSE": 118.865726095 + }, + { + "Index": "L20", + "High": 5.652, + "GPSN": 31.928411319, + "GPSE": 118.865726084 + }, + { + "Index": "L21", + "High": 5.652, + "GPSN": 31.928409164, + "GPSE": 118.86572619 + }, + { + "Index": "L22", + "High": 5.652, + "GPSN": 31.928406711, + "GPSE": 118.865726497 + }, + { + "Index": "L23", + "High": 5.652, + "GPSN": 31.928404294, + "GPSE": 118.865727025 + }, + { + "Index": "L24", + "High": 5.652, + "GPSN": 31.928402084, + "GPSE": 118.865727734 + }, + { + "Index": "L25", + "High": 5.652, + "GPSN": 31.928399929, + "GPSE": 118.865728654 + }, + { + "Index": "L26", + "High": 5.652, + "GPSN": 31.92839762, + "GPSE": 118.86572987 + }, + { + "Index": "L27", + "High": 5.652, + "GPSN": 31.928395375, + "GPSE": 118.865731245 + }, + { + "Index": "L28", + "High": 5.652, + "GPSN": 31.928392994, + "GPSE": 118.865732915 + }, + { + "Index": "L29", + "High": 5.652, + "GPSN": 31.928390703, + "GPSE": 118.865734745 + }, + { + "Index": "L30", + "High": 5.652, + "GPSN": 31.928388476, + "GPSE": 118.865736976 + }, + { + "Index": "L31", + "High": 5.652, + "GPSN": 31.928386429, + "GPSE": 118.865739419 + }, + { + "Index": "L32", + "High": 5.652, + "GPSN": 31.928384652, + "GPSE": 118.865741957 + }, + { + "Index": "L33", + "High": 5.652, + "GPSN": 31.928383056, + "GPSE": 118.865744664 + }, + { + "Index": "L34", + "High": 5.652, + "GPSN": 31.928381541, + "GPSE": 118.865747064 + }, + { + "Index": "L35", + "High": 5.652, + "GPSN": 31.928379944, + "GPSE": 118.865749391 + }, + { + "Index": "L36", + "High": 5.652, + "GPSN": 31.928378375, + "GPSE": 118.865751463 + }, + { + "Index": "L37", + "High": 5.652, + "GPSN": 31.928376734, + "GPSE": 118.865753451 + }, + { + "Index": "L38", + "High": 5.652, + "GPSN": 31.928375048, + "GPSE": 118.865755608 + }, + { + "Index": "L39", + "High": 5.652, + "GPSN": 31.928373316, + "GPSE": 118.865757734 + }, + { + "Index": "L40", + "High": 5.652, + "GPSN": 31.928371576, + "GPSE": 118.865759807 + }, + { + "Index": "L41", + "High": 5.652, + "GPSN": 31.928369826, + "GPSE": 118.865761837 + }, + { + "Index": "L42", + "High": 5.652, + "GPSN": 31.928367707, + "GPSE": 118.865763761 + }, + { + "Index": "L43", + "High": 5.652, + "GPSN": 31.928365524, + "GPSE": 118.86576558 + }, + { + "Index": "L44", + "High": 5.652, + "GPSN": 31.928363477, + "GPSE": 118.865767145 + }, + { + "Index": "L45", + "High": 5.652, + "GPSN": 31.928361385, + "GPSE": 118.865768626 + }, + { + "Index": "L46", + "High": 5.652, + "GPSN": 31.928359275, + "GPSE": 118.865770011 + }, + { + "Index": "L47", + "High": 5.652, + "GPSN": 31.928357137, + "GPSE": 118.865771301 + }, + { + "Index": "L48", + "High": 5.652, + "GPSN": 31.928354955, + "GPSE": 118.865772517 + }, + { + "Index": "L49", + "High": 5.652, + "GPSN": 31.928352736, + "GPSE": 118.865773638 + }, + { + "Index": "L50", + "High": 5.652, + "GPSN": 31.928350103, + "GPSE": 118.865774643 + }, + { + "Index": "L51", + "High": 5.652, + "GPSN": 31.928347452, + "GPSE": 118.865775605 + }, + { + "Index": "L52", + "High": 5.652, + "GPSN": 31.928344863, + "GPSE": 118.865776504 + }, + { + "Index": "L53", + "High": 5.652, + "GPSN": 31.928342257, + "GPSE": 118.865777371 + }, + { + "Index": "L54", + "High": 5.652, + "GPSN": 31.928339885, + "GPSE": 118.865778101 + }, + { + "Index": "L55", + "High": 5.652, + "GPSN": 31.928337495, + "GPSE": 118.865778714 + }, + { + "Index": "L56", + "High": 5.652, + "GPSN": 31.92833479, + "GPSE": 118.865779243 + }, + { + "Index": "L57", + "High": 5.652, + "GPSN": 31.928332057, + "GPSE": 118.865779613 + }, + { + "Index": "L58", + "High": 5.652, + "GPSN": 31.928329803, + "GPSE": 118.865779676 + }, + { + "Index": "L59", + "High": 5.652, + "GPSN": 31.928327539, + "GPSE": 118.865779761 + }, + { + "Index": "L60", + "High": 5.652, + "GPSN": 31.928325321, + "GPSE": 118.865779909 + }, + { + "Index": "L61", + "High": 5.652, + "GPSN": 31.928323111, + "GPSE": 118.865780089 + }, + { + "Index": "L62", + "High": 5.652, + "GPSN": 31.928320424, + "GPSE": 118.865779782 + }, + { + "Index": "L63", + "High": 5.652, + "GPSN": 31.928317745, + "GPSE": 118.86577938 + }, + { + "Index": "L64", + "High": 5.652, + "GPSN": 31.928315347, + "GPSE": 118.865778936 + }, + { + "Index": "L65", + "High": 5.652, + "GPSN": 31.928312966, + "GPSE": 118.865778428 + }, + { + "Index": "L66", + "High": 5.652, + "GPSN": 31.928310242, + "GPSE": 118.865777477 + }, + { + "Index": "L67", + "High": 5.652, + "GPSN": 31.928307528, + "GPSE": 118.865776514 + }, + { + "Index": "L68", + "High": 5.652, + "GPSN": 31.928305363, + "GPSE": 118.865775764 + }, + { + "Index": "L69", + "High": 5.652, + "GPSN": 31.928303208, + "GPSE": 118.865775002 + }, + { + "Index": "L70", + "High": 5.652, + "GPSN": 31.928300899, + "GPSE": 118.865773945 + }, + { + "Index": "L71", + "High": 5.652, + "GPSN": 31.928298627, + "GPSE": 118.865772771 + }, + { + "Index": "L72", + "High": 5.652, + "GPSN": 31.928296318, + "GPSE": 118.86577147 + }, + { + "Index": "L73", + "High": 5.652, + "GPSN": 31.928294054, + "GPSE": 118.865770064 + }, + { + "Index": "L74", + "High": 5.652, + "GPSN": 31.928291809, + "GPSE": 118.865768478 + }, + { + "Index": "L75", + "High": 5.652, + "GPSN": 31.928289617, + "GPSE": 118.865766807 + }, + { + "Index": "L76", + "High": 5.652, + "GPSN": 31.928287381, + "GPSE": 118.86576502 + }, + { + "Index": "L77", + "High": 5.652, + "GPSN": 31.92828519, + "GPSE": 118.865763148 + }, + { + "Index": "L78", + "High": 5.652, + "GPSN": 31.928283332, + "GPSE": 118.865761446 + }, + { + "Index": "L79", + "High": 5.652, + "GPSN": 31.928281537, + "GPSE": 118.865759659 + }, + { + "Index": "L80", + "High": 5.652, + "GPSN": 31.928279508, + "GPSE": 118.86575747 + }, + { + "Index": "L81", + "High": 5.652, + "GPSN": 31.928277569, + "GPSE": 118.865755164 + }, + { + "Index": "L82", + "High": 5.652, + "GPSN": 31.92827554, + "GPSE": 118.865752552 + }, + { + "Index": "L83", + "High": 5.652, + "GPSN": 31.928273628, + "GPSE": 118.865749824 + }, + { + "Index": "L84", + "High": 5.652, + "GPSN": 31.928271752, + "GPSE": 118.865746821 + }, + { + "Index": "L85", + "High": 5.652, + "GPSN": 31.928270012, + "GPSE": 118.865743712 + }, + { + "Index": "L86", + "High": 5.652, + "GPSN": 31.928268497, + "GPSE": 118.865740952 + }, + { + "Index": "L87", + "High": 5.652, + "GPSN": 31.92826709, + "GPSE": 118.865738129 + }, + { + "Index": "L88", + "High": 5.652, + "GPSN": 31.928265512, + "GPSE": 118.865734618 + }, + { + "Index": "L89", + "High": 5.652, + "GPSN": 31.928264087, + "GPSE": 118.865731001 + }, + { + "Index": "L90", + "High": 5.652, + "GPSN": 31.928263059, + "GPSE": 118.86572785 + }, + { + "Index": "L91", + "High": 5.652, + "GPSN": 31.928262148, + "GPSE": 118.865724646 + }, + { + "Index": "L92", + "High": 5.652, + "GPSN": 31.928261219, + "GPSE": 118.865720575 + }, + { + "Index": "L93", + "High": 5.652, + "GPSN": 31.928260479, + "GPSE": 118.86571644 + }, + { + "Index": "R1", + "High": 5.652, + "GPSN": 31.928479398, + "GPSE": 118.865752256 + }, + { + "Index": "R2", + "High": 5.652, + "GPSN": 31.928478893, + "GPSE": 118.865749422 + }, + { + "Index": "R3", + "High": 5.652, + "GPSN": 31.928478235, + "GPSE": 118.865746631 + }, + { + "Index": "R4", + "High": 5.652, + "GPSN": 31.928477441, + "GPSE": 118.865743966 + }, + { + "Index": "R5", + "High": 5.652, + "GPSN": 31.928476503, + "GPSE": 118.865741364 + }, + { + "Index": "R6", + "High": 5.652, + "GPSN": 31.928475809, + "GPSE": 118.865738752 + }, + { + "Index": "R7", + "High": 5.652, + "GPSN": 31.928474979, + "GPSE": 118.865736183 + }, + { + "Index": "R8", + "High": 5.652, + "GPSN": 31.928473807, + "GPSE": 118.865733148 + }, + { + "Index": "R9", + "High": 5.652, + "GPSN": 31.928472463, + "GPSE": 118.865730187 + }, + { + "Index": "R10", + "High": 5.652, + "GPSN": 31.928471173, + "GPSE": 118.865727776 + }, + { + "Index": "R11", + "High": 5.652, + "GPSN": 31.928469902, + "GPSE": 118.865725344 + }, + { + "Index": "R12", + "High": 5.652, + "GPSN": 31.928468729, + "GPSE": 118.865723102 + }, + { + "Index": "R13", + "High": 5.652, + "GPSN": 31.928467575, + "GPSE": 118.86572086 + }, + { + "Index": "R14", + "High": 5.652, + "GPSN": 31.928466267, + "GPSE": 118.865718851 + }, + { + "Index": "R15", + "High": 5.652, + "GPSN": 31.928464879, + "GPSE": 118.865716895 + }, + { + "Index": "R16", + "High": 5.652, + "GPSN": 31.928463345, + "GPSE": 118.865714917 + }, + { + "Index": "R17", + "High": 5.652, + "GPSN": 31.928461731, + "GPSE": 118.865713035 + }, + { + "Index": "R18", + "High": 5.652, + "GPSN": 31.928460018, + "GPSE": 118.865710994 + }, + { + "Index": "R19", + "High": 5.652, + "GPSN": 31.928458205, + "GPSE": 118.86570908 + }, + { + "Index": "R20", + "High": 5.652, + "GPSN": 31.928456212, + "GPSE": 118.865707177 + }, + { + "Index": "R21", + "High": 5.652, + "GPSN": 31.928454138, + "GPSE": 118.865705421 + }, + { + "Index": "R22", + "High": 5.652, + "GPSN": 31.928451685, + "GPSE": 118.865703053 + }, + { + "Index": "R23", + "High": 5.652, + "GPSN": 31.928449051, + "GPSE": 118.865700959 + }, + { + "Index": "R24", + "High": 5.652, + "GPSN": 31.928446671, + "GPSE": 118.865699394 + }, + { + "Index": "R25", + "High": 5.652, + "GPSN": 31.9284442, + "GPSE": 118.865698051 + }, + { + "Index": "R26", + "High": 5.652, + "GPSN": 31.928441765, + "GPSE": 118.865696486 + }, + { + "Index": "R27", + "High": 5.652, + "GPSN": 31.928439186, + "GPSE": 118.865695259 + }, + { + "Index": "R28", + "High": 5.652, + "GPSN": 31.928436209, + "GPSE": 118.86569436 + }, + { + "Index": "R29", + "High": 5.652, + "GPSN": 31.928433161, + "GPSE": 118.865693916 + }, + { + "Index": "R30", + "High": 5.652, + "GPSN": 31.928431249, + "GPSE": 118.865692996 + }, + { + "Index": "R31", + "High": 5.652, + "GPSN": 31.928429265, + "GPSE": 118.865692214 + }, + { + "Index": "R32", + "High": 5.652, + "GPSN": 31.928426407, + "GPSE": 118.865691156 + }, + { + "Index": "R33", + "High": 5.652, + "GPSN": 31.92842353, + "GPSE": 118.865690194 + }, + { + "Index": "R34", + "High": 5.652, + "GPSN": 31.928420788, + "GPSE": 118.86568975 + }, + { + "Index": "R35", + "High": 5.652, + "GPSN": 31.928418038, + "GPSE": 118.865689422 + }, + { + "Index": "R36", + "High": 5.652, + "GPSN": 31.928415161, + "GPSE": 118.8656892 + }, + { + "Index": "R37", + "High": 5.652, + "GPSN": 31.928412293, + "GPSE": 118.865689126 + }, + { + "Index": "R38", + "High": 5.652, + "GPSN": 31.928409317, + "GPSE": 118.865689073 + }, + { + "Index": "R39", + "High": 5.652, + "GPSN": 31.92840635, + "GPSE": 118.865689369 + }, + { + "Index": "R40", + "High": 5.652, + "GPSN": 31.928403194, + "GPSE": 118.865690067 + }, + { + "Index": "R41", + "High": 5.652, + "GPSN": 31.928400118, + "GPSE": 118.865691156 + }, + { + "Index": "R42", + "High": 5.652, + "GPSN": 31.928397864, + "GPSE": 118.86569141 + }, + { + "Index": "R43", + "High": 5.652, + "GPSN": 31.928395627, + "GPSE": 118.865691896 + }, + { + "Index": "R44", + "High": 5.652, + "GPSN": 31.928393328, + "GPSE": 118.8656927 + }, + { + "Index": "R45", + "High": 5.652, + "GPSN": 31.928391091, + "GPSE": 118.865693747 + }, + { + "Index": "R46", + "High": 5.652, + "GPSN": 31.928389008, + "GPSE": 118.865694307 + }, + { + "Index": "R47", + "High": 5.652, + "GPSN": 31.928386943, + "GPSE": 118.865694984 + }, + { + "Index": "R48", + "High": 5.652, + "GPSN": 31.928384679, + "GPSE": 118.865695872 + }, + { + "Index": "R49", + "High": 5.652, + "GPSN": 31.928382452, + "GPSE": 118.865696888 + }, + { + "Index": "R50", + "High": 5.652, + "GPSN": 31.928380495, + "GPSE": 118.865698178 + }, + { + "Index": "R51", + "High": 5.652, + "GPSN": 31.928378511, + "GPSE": 118.865699425 + }, + { + "Index": "R52", + "High": 5.652, + "GPSN": 31.928377005, + "GPSE": 118.865700324 + }, + { + "Index": "R53", + "High": 5.652, + "GPSN": 31.92837548, + "GPSE": 118.865701213 + }, + { + "Index": "R54", + "High": 5.652, + "GPSN": 31.928373758, + "GPSE": 118.865702513 + }, + { + "Index": "R55", + "High": 5.652, + "GPSN": 31.928372117, + "GPSE": 118.865703962 + }, + { + "Index": "R56", + "High": 5.652, + "GPSN": 31.928369637, + "GPSE": 118.865706637 + }, + { + "Index": "R57", + "High": 5.652, + "GPSN": 31.928367445, + "GPSE": 118.865709651 + }, + { + "Index": "R58", + "High": 5.652, + "GPSN": 31.928365605, + "GPSE": 118.865711385 + }, + { + "Index": "R59", + "High": 5.652, + "GPSN": 31.92836391, + "GPSE": 118.865713331 + }, + { + "Index": "R60", + "High": 5.652, + "GPSN": 31.928362088, + "GPSE": 118.86571589 + }, + { + "Index": "R61", + "High": 5.652, + "GPSN": 31.928360537, + "GPSE": 118.865718692 + }, + { + "Index": "R62", + "High": 5.652, + "GPSN": 31.92835968, + "GPSE": 118.865720829 + }, + { + "Index": "R63", + "High": 5.652, + "GPSN": 31.928358715, + "GPSE": 118.865722901 + }, + { + "Index": "R64", + "High": 5.652, + "GPSN": 31.928357471, + "GPSE": 118.865725196 + }, + { + "Index": "R65", + "High": 5.652, + "GPSN": 31.928356091, + "GPSE": 118.865727385 + }, + { + "Index": "R66", + "High": 5.652, + "GPSN": 31.928354648, + "GPSE": 118.865729648 + }, + { + "Index": "R67", + "High": 5.652, + "GPSN": 31.92835298, + "GPSE": 118.86573171 + }, + { + "Index": "R68", + "High": 5.652, + "GPSN": 31.928351185, + "GPSE": 118.865733476 + }, + { + "Index": "R69", + "High": 5.652, + "GPSN": 31.928349228, + "GPSE": 118.865734988 + }, + { + "Index": "R70", + "High": 5.652, + "GPSN": 31.928346784, + "GPSE": 118.865737039 + }, + { + "Index": "R71", + "High": 5.652, + "GPSN": 31.928344178, + "GPSE": 118.865738784 + }, + { + "Index": "R72", + "High": 5.652, + "GPSN": 31.928340841, + "GPSE": 118.865740466 + }, + { + "Index": "R73", + "High": 5.652, + "GPSN": 31.928337369, + "GPSE": 118.865741661 + }, + { + "Index": "R74", + "High": 5.652, + "GPSN": 31.928334889, + "GPSE": 118.865742126 + }, + { + "Index": "R75", + "High": 5.652, + "GPSN": 31.928332409, + "GPSE": 118.865742496 + }, + { + "Index": "R76", + "High": 5.652, + "GPSN": 31.928330317, + "GPSE": 118.865742729 + }, + { + "Index": "R77", + "High": 5.652, + "GPSN": 31.928328216, + "GPSE": 118.865742898 + }, + { + "Index": "R78", + "High": 5.652, + "GPSN": 31.92832551, + "GPSE": 118.865743046 + }, + { + "Index": "R79", + "High": 5.652, + "GPSN": 31.928322814, + "GPSE": 118.865742845 + }, + { + "Index": "R80", + "High": 5.652, + "GPSN": 31.928320225, + "GPSE": 118.865742348 + }, + { + "Index": "R81", + "High": 5.652, + "GPSN": 31.928317691, + "GPSE": 118.865741544 + }, + { + "Index": "R82", + "High": 5.652, + "GPSN": 31.928315013, + "GPSE": 118.865740561 + }, + { + "Index": "R83", + "High": 5.652, + "GPSN": 31.928312389, + "GPSE": 118.865739376 + }, + { + "Index": "R84", + "High": 5.652, + "GPSN": 31.928310116, + "GPSE": 118.865738118 + }, + { + "Index": "R85", + "High": 5.652, + "GPSN": 31.928307907, + "GPSE": 118.865736712 + }, + { + "Index": "R86", + "High": 5.652, + "GPSN": 31.928305841, + "GPSE": 118.86573521 + }, + { + "Index": "R87", + "High": 5.652, + "GPSN": 31.928303893, + "GPSE": 118.865733497 + }, + { + "Index": "R88", + "High": 5.652, + "GPSN": 31.9283019, + "GPSE": 118.865731403 + }, + { + "Index": "R89", + "High": 5.652, + "GPSN": 31.928300088, + "GPSE": 118.865729098 + }, + { + "Index": "R90", + "High": 5.652, + "GPSN": 31.928298194, + "GPSE": 118.865726507 + }, + { + "Index": "R91", + "High": 5.652, + "GPSN": 31.928296489, + "GPSE": 118.865723747 + }, + { + "Index": "R92", + "High": 5.652, + "GPSN": 31.928295119, + "GPSE": 118.865721103 + }, + { + "Index": "R93", + "High": 5.652, + "GPSN": 31.928293919, + "GPSE": 118.865718354 + }, + { + "Index": "R94", + "High": 5.652, + "GPSN": 31.92829281, + "GPSE": 118.865715679 + }, + { + "Index": "R95", + "High": 5.652, + "GPSN": 31.928291953, + "GPSE": 118.865712866 + }, + { + "Index": "R96", + "High": 5.652, + "GPSN": 31.928291502, + "GPSE": 118.865710846 + }, + { + "Index": "R97", + "High": 5.652, + "GPSN": 31.928291178, + "GPSE": 118.865708784 + } + ] + } + ] +} \ No newline at end of file diff --git a/entry/src/main/cpp/sdk/assistdrive/data/collectParams.json b/entry/src/main/cpp/sdk/assistdrive/data/collectParams.json new file mode 100644 index 0000000..d07c81b --- /dev/null +++ b/entry/src/main/cpp/sdk/assistdrive/data/collectParams.json @@ -0,0 +1,99 @@ +{ + "item": [ + { + "itemCode": "20100", + "teachPoint": [ + { + "name": "1", + "params": [ + { + "libIndex": "1", + "distance1": 2000, + "distance2": 400 + } + ] + }, + { + "name": "2", + "params": [ + { + "libIndex": "1", + "distance1": 18005, + "distance2": 400 + } + ] + }, + { + "name": "10", + "params": [ + { + "libIndex": "1", + "distance1": 18002, + "distance2": 0 + } + ] + }, + { + "name": "11", + "params": [ + { + "libIndex": "1", + "distance1": 15546, + "distance2": 0 + }, + { + "libIndex": "23", + "distance1": 500, + "distance2": 1500 + }, + { + "libIndex": "24", + "distance1": 500, + "distance2": 1500 + } + ] + } + ] + }, + { + "itemCode": "20400", + "teachPoint": [ + { + "name": "3", + "params": [ + { + "libIndex": "45", + "distance1": 600, + "distance2": 1000 + } + ] + } + ] + }, + { + "itemCode": "20700", + "teachPoint": [ + { + "name": "1", + "params": [ + { + "libIndex": "", + "distance1": 2000, + "distance2": 2000 + } + ] + }, + { + "name": "2", + "params": [ + { + "libIndex": "", + "distance1": 2000, + "distance2": 2000 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/entry/src/main/cpp/sdk/assistdrive/data/destLib.json b/entry/src/main/cpp/sdk/assistdrive/data/destLib.json new file mode 100644 index 0000000..8efc0e7 --- /dev/null +++ b/entry/src/main/cpp/sdk/assistdrive/data/destLib.json @@ -0,0 +1,50 @@ +{ + "type": "FeatureCollection", + "name": "2", + "crs": { + "type": "name", + "properties": { + "name": "urn:ogc:def:crs:OGC:1.3:CRS84" + } + }, + "features": [ + { + "type": "Feature", + "properties": { + "id": 6, + "name": "停车库位6", + "type": 1, + "describe": "停车库位6" + }, + "geometry": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ + -52.87, + 3.109 + ], + [ + -57.281, + -0.124 + ], + [ + -58.704, + 1.762 + ], + [ + -54.3, + 4.986 + ], + [ + -52.87, + 3.109 + ] + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/entry/src/main/cpp/sdk/assistdrive/data/naviPath.json b/entry/src/main/cpp/sdk/assistdrive/data/naviPath.json new file mode 100644 index 0000000..068184b --- /dev/null +++ b/entry/src/main/cpp/sdk/assistdrive/data/naviPath.json @@ -0,0 +1,216 @@ +{ + "type": "FeatureCollection", + "name": "naviPath", + "crs": { + "type": "name", + "properties": { + "name": "urn:ogc:def:crs:OGC:1.3:CRS84" + } + }, + "features": [ + { + "type": "Feature", + "properties": { + "id": 1, + "name": "倒库演示", + "type": 1, + "describe": "倒库演示" + }, + "geometry": { + "type": "MultiLineString", + "coordinates": [ + [ + [ + -19.795226214395715, + 6.600886245100837 + ], + [ + 5.341078932663112, + 9.797209774512604 + ], + [ + 15.407760917957223, + 11.00451675980673 + ], + [ + 26.51672231501605, + 12.272623377453787 + ], + [ + 39.788413491486637, + 13.905527789218493 + ] + ] + ] + } + }, + { + "type": "Feature", + "properties": { + "id": 2, + "name": "导航到洗车点", + "type": 2, + "describe": "导航到洗车点" + }, + "geometry": { + "type": "MultiLineString", + "coordinates": [ + [ + [ + -1.166855954699315, + 0.945972004169775 + ], + [ + -2.353999575511834, + 9.702208639950221 + ], + [ + -0.60275224835574, + 12.867924962117007 + ], + [ + 3.20284290488731, + 13.979293458196835 + ], + [ + 6.739015392414039, + 13.23838112747695 + ], + [ + 11.352878542806055, + 11.823912132466258 + ], + [ + 16.758170773739774, + 10.409443137455565 + ], + [ + 22.163463004673481, + 10.880932802459132 + ], + [ + 28.907449105885135, + 11.049321968531885 + ], + [ + 32.95720854993364, + 11.150355468175452 + ], + [ + 36.316572413084003, + 12.935280628546138 + ], + [ + 37.67210519996928, + 16.067319117498329 + ], + [ + 37.394263075949283, + 19.468780272166953 + ], + [ + 35.440948749505949, + 22.90391926005006 + ], + [ + 28.638026440168815, + 26.67583658007857 + ], + [ + 26.954134779441802, + 35.903562880862609 + ], + [ + 25.337598785143868, + 48.970562168104259 + ], + [ + 26.145866782292856, + 59.747468796757097 + ], + [ + 28.114, + 72.748 + ], + [ + 29.783072769463203, + 80.358302724055733 + ] + ] + ] + } + }, + { + "type": "Feature", + "properties": { + "id": 3, + "name": "公司巡游", + "type": 2, + "describe": "公司巡游" + }, + "geometry": { + "type": "MultiLineString", + "coordinates": [ + [ + [ + -1.166855954699315, + 0.945972004169775 + ], + [ + -1.941446118633742, + 6.267069652067139 + ], + [ + -2.615002782924549, + 11.251388967819098 + ], + [ + -5.747041271876792, + 14.450783123200424 + ], + [ + -11.438595085134098, + 14.248716123913184 + ], + [ + -13.728687743722837, + 10.948288468888236 + ], + [ + -17.137413714395755, + 7.017798009806693 + ], + [ + -27.490722537925166, + 4.029930362747869 + ], + [ + -42.951200479101644, + 2.535996539218456 + ], + [ + -75.29660489086632, + -0.573470372546254 + ], + [ + -106.113332832042772, + -2.727514490193284 + ], + [ + -139.362046067336934, + -5.159499784310952 + ], + [ + -187.167928420278002, + -8.668507137252178 + ], + [ + -241.505428420278008, + -15.617036549016859 + ] + ] + ] + } + } + ] +} \ No newline at end of file diff --git a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelAbstractClass.cpp b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelAbstractClass.cpp similarity index 80% rename from entry/src/main/cpp/sdk/assistdrive/field/FieldModelAbstractClass.cpp rename to entry/src/main/cpp/sdk/assistdrive/item/ItemModelAbstractClass.cpp index 0b098bf..ef442cc 100644 --- a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelAbstractClass.cpp +++ b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelAbstractClass.cpp @@ -1,17 +1,17 @@ -#include "FieldModelAbstractClass.h" +#include "ItemModelAbstractClass.h" #include "AutomaticServiceDataManager.h" #include "GraphicTools.h" -void FieldModelAbstractClass::initModelPoint() +void ItemModelAbstractClass::initModelPoint() { - auto fieldModelList = AutomaticServiceDataManager::GetInstance()->fieldModelList(); - for (size_t i = 0; i < fieldModelList.model.size(); i++) + auto itemModelList = AutomaticServiceDataManager::GetInstance()->itemModelList(); + for (size_t i = 0; i < itemModelList.model.size(); i++) { - if (fieldModelList.model[i].ModelName == modelName_) + if (itemModelList.model[i].ModelName == itemName_) { auto basePoint = AutomaticServiceDataManager::GetInstance()->basePoint(); - auto originPointList = fieldModelList.model[i].Points; + auto originPointList = itemModelList.model[i].Points; pointList_.clear(); leftPointList_.clear(); rightPointList_.clear(); @@ -41,14 +41,14 @@ void FieldModelAbstractClass::initModelPoint() } } -void FieldModelAbstractClass::initTeachPoint() +void ItemModelAbstractClass::initTeachPoint() { // 初始化教学点信息 std::unordered_map indexMap; // teach point index, index in teachPointList_ auto teachPointInfoList = AutomaticServiceDataManager::GetInstance()->teachPointInfo(); for (size_t i = 0; i < teachPointInfoList.item.size(); i++) { - if (teachPointInfoList.item[i].item_code == modelName_) + if (teachPointInfoList.item[i].item_code == itemName_) { for (size_t j = 0; j < teachPointInfoList.item[i].teach_point.size(); j++) { @@ -65,7 +65,7 @@ void FieldModelAbstractClass::initTeachPoint() auto teachPointParamList = AutomaticServiceDataManager::GetInstance()->teachPointParam(); for (size_t i = 0; i < teachPointParamList.item.size(); i++) { - if (teachPointParamList.item[i].itemCode == modelName_) + if (teachPointParamList.item[i].itemCode == itemName_) { for (size_t j = 0; j < teachPointParamList.item[i].teachPoint.size(); j++) { @@ -83,7 +83,7 @@ void FieldModelAbstractClass::initTeachPoint() initTeachPointLines(); } -bool FieldModelAbstractClass::isModelInMapArea(AutoRect mapArea) +bool ItemModelAbstractClass::isModelInMapArea(AutoRect mapArea) { // 遍历所有点,只要有点在就绘制 for (size_t i = 0; i < pointList_.size(); i++) @@ -97,7 +97,7 @@ bool FieldModelAbstractClass::isModelInMapArea(AutoRect mapArea) return false; } -ItemStatus FieldModelAbstractClass::updateItemStatus(double x, double y) +ItemStatus ItemModelAbstractClass::updateItemStatus(double x, double y) { switch (status_) { @@ -141,7 +141,7 @@ ItemStatus FieldModelAbstractClass::updateItemStatus(double x, double y) return status_; } -int FieldModelAbstractClass::calculateTeachPoint(double x, double y) +int ItemModelAbstractClass::calculateTeachPoint(double x, double y) { for (size_t i = 0; i < teachPointList_.size(); i++) { @@ -165,19 +165,14 @@ int FieldModelAbstractClass::calculateTeachPoint(double x, double y) return -1; } -std::string FieldModelAbstractClass::getModelName() +std::string ItemModelAbstractClass::getItemName() { - return modelName_; + return itemName_; } -std::vector &FieldModelAbstractClass::getModelPointList() -{ - return pointList_; -} - -void FieldModelAbstractClass::transferPoint2ImagePixel(const std::vector &inPointList, - const Pointi &padding, double unit, - std::vector &outPointList) +void ItemModelAbstractClass::transferPoint2ImagePixel(const std::vector &inPointList, + const Pointi &padding, double unit, + std::vector &outPointList) { for (size_t i = 0; i < inPointList.size(); i++) { @@ -186,7 +181,7 @@ void FieldModelAbstractClass::transferPoint2ImagePixel(const std::vector> &inPointList, const Pointi &padding, double unit, std::vector &outPointList) { @@ -197,8 +192,8 @@ void FieldModelAbstractClass::transferPoint2ImagePixel( } } -Pointi FieldModelAbstractClass::transferPoint2ImagePixel(const AutoPoint &inPoint, - const Pointi &padding, double unit) +Pointi ItemModelAbstractClass::transferPoint2ImagePixel(const AutoPoint &inPoint, + const Pointi &padding, double unit) { Pointi outPoint(inPoint.x * unit + padding.x, inPoint.y * unit + padding.x); return outPoint; diff --git a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelAbstractClass.h b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelAbstractClass.h similarity index 84% rename from entry/src/main/cpp/sdk/assistdrive/field/FieldModelAbstractClass.h rename to entry/src/main/cpp/sdk/assistdrive/item/ItemModelAbstractClass.h index 77e9f5c..b249c9d 100644 --- a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelAbstractClass.h +++ b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelAbstractClass.h @@ -1,13 +1,13 @@ /** - * FieldModelAbstractClass.h + * ItemModelAbstractClass.h * * @brief: 场地模型抽象类 * @author: zhanke * @history: 2024-08-01, create file */ -#ifndef FIELDMODELABSTRACTCLASS_H -#define FIELDMODELABSTRACTCLASS_H +#ifndef ITEMMODELABSTRACTCLASS_H +#define ITEMMODELABSTRACTCLASS_H #include "AutomaticServiceDefines.h" #include "GraphicDefines.h" @@ -20,7 +20,8 @@ using graphic::AutoLine; using graphic::AutoPoint; using graphic::AutoRect; -enum ItemStatus { +enum ItemStatus +{ NotEnter = 0, // 未进入项目 Enter, // 在项目中 Leave // 出项目 @@ -28,18 +29,18 @@ enum ItemStatus { struct TeachPoint { - bool isPass = false; // 是否触发教学点标志 + bool isPass = false; // 教学点已触发 AutoLine line; // 教学点标志线 TeachPointInfo info; // 教学点信息(外部json文件输入) std::vector params; // 教学点参数(外部json文件输入) }; -class FieldModelAbstractClass +class ItemModelAbstractClass { public: void initModelPoint(); // 初始化模型点,将经纬度转为相对基准点坐标 virtual void initTeachPoint(); // 初始化教学点 - virtual void initTeachPointLines() = 0; + virtual void initTeachPointLines() = 0; // 初始化教学点依赖的模型线 virtual bool isModelInMapArea(AutoRect mapArea); // 判断项目是否在绘图范围内 virtual void drawModel(IGraphicAbstract* pGraphicTool, const Pointi& padding, double unit) = 0; @@ -47,8 +48,7 @@ public: virtual ItemStatus updateItemStatus(double x, double y); virtual int calculateTeachPoint(double x, double y); - std::string getModelName(); - std::vector& getModelPointList(); + std::string getItemName(); // 相对坐标点转绘图像素点 static void transferPoint2ImagePixel(const std::vector& inPointList, @@ -62,7 +62,7 @@ public: protected: ItemStatus status_ = NotEnter; - std::string modelName_; // 模型名称 + std::string itemName_; // 名称 std::vector teachPointList_; // 教学点列表(本质是两点连线和到线的距离) std::vector pointList_; // 普通点 @@ -73,4 +73,4 @@ protected: AutoLine outLine_; // 出项目判断线 }; -#endif // FIELDMODELABSTRACTCLASS_H +#endif // ITEMMODELABSTRACTCLASS_H diff --git a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelCftc.cpp b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelCftc.cpp similarity index 78% rename from entry/src/main/cpp/sdk/assistdrive/field/FieldModelCftc.cpp rename to entry/src/main/cpp/sdk/assistdrive/item/ItemModelCftc.cpp index d80dea0..5bc2592 100644 --- a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelCftc.cpp +++ b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelCftc.cpp @@ -1,13 +1,13 @@ -#include "FieldModelCftc.h" +#include "ItemModelCftc.h" #include "GraphicTools.h" -FieldModelCftc::FieldModelCftc() +ItemModelCftc::ItemModelCftc() { - modelName_ = automatic_service::CFTC; + itemName_ = automatic_service::CFTC; } -void FieldModelCftc::drawModel(IGraphicAbstract *pGraphicTool, const Pointi &padding, double unit) +void ItemModelCftc::drawModel(IGraphicAbstract *pGraphicTool, const Pointi &padding, double unit) { std::vector pixelList; transferPoint2ImagePixel(pointList_, padding, unit, pixelList); @@ -20,7 +20,7 @@ void FieldModelCftc::drawModel(IGraphicAbstract *pGraphicTool, const Pointi &pad pGraphicTool->drawLine(pixelList[5], pixelList[6]); } -void FieldModelCftc::initTeachPointLines() +void ItemModelCftc::initTeachPointLines() { // FIXME: 判断规则后续修改 // 车辆当前位置距离模型线3米,判断进入项目 diff --git a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelCftc.h b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelCftc.h similarity index 58% rename from entry/src/main/cpp/sdk/assistdrive/field/FieldModelCftc.h rename to entry/src/main/cpp/sdk/assistdrive/item/ItemModelCftc.h index 3e3da64..c199bde 100644 --- a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelCftc.h +++ b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelCftc.h @@ -1,24 +1,24 @@ /** - * FieldModelCftc.h + * ItemModelCftc.h * * @brief: 侧方停车场地模型 * @author: zhanke * @history: 2024-08-01, create file */ -#ifndef FIELDMODELCFTC_H -#define FIELDMODELCFTC_H +#ifndef ITEMMODELCFTC_H +#define ITEMMODELCFTC_H -#include "FieldModelAbstractClass.h" +#include "ItemModelAbstractClass.h" -class FieldModelCftc : public FieldModelAbstractClass +class ItemModelCftc : public ItemModelAbstractClass { public: - explicit FieldModelCftc(); + explicit ItemModelCftc(); virtual void drawModel(IGraphicAbstract* pGraphicTool, const Pointi& padding, double unit) override; virtual void initTeachPointLines() override; }; -#endif // FIELDMODELCFTC_H +#endif // ITEMMODELCFTC_H diff --git a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelDcrk.cpp b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelDcrk.cpp similarity index 77% rename from entry/src/main/cpp/sdk/assistdrive/field/FieldModelDcrk.cpp rename to entry/src/main/cpp/sdk/assistdrive/item/ItemModelDcrk.cpp index ebc5fe7..1acdd51 100644 --- a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelDcrk.cpp +++ b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelDcrk.cpp @@ -1,4 +1,4 @@ -#include "FieldModelDcrk.h" +#include "ItemModelDcrk.h" #include "AutomaticServiceDataManager.h" #include "GpsMath.h" @@ -6,12 +6,12 @@ using namespace graphic; -FieldModelDcrk::FieldModelDcrk() +ItemModelDcrk::ItemModelDcrk() { - modelName_ = automatic_service::DCRK; + itemName_ = automatic_service::DCRK; } -void FieldModelDcrk::drawModel(IGraphicAbstract* pGraphicTool, const Pointi& padding, double unit) +void ItemModelDcrk::drawModel(IGraphicAbstract* pGraphicTool, const Pointi& padding, double unit) { std::vector pixelList; transferPoint2ImagePixel(pointList_, padding, unit, pixelList); @@ -25,7 +25,7 @@ void FieldModelDcrk::drawModel(IGraphicAbstract* pGraphicTool, const Pointi& pad pGraphicTool->drawDashedLine(pixelList[0], pixelList[1]); } -void FieldModelDcrk::initTeachPointLines() +void ItemModelDcrk::initTeachPointLines() { /** * 倒车入库一共16个教学点 diff --git a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelDcrk.h b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelDcrk.h similarity index 62% rename from entry/src/main/cpp/sdk/assistdrive/field/FieldModelDcrk.h rename to entry/src/main/cpp/sdk/assistdrive/item/ItemModelDcrk.h index e09e383..858e06c 100644 --- a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelDcrk.h +++ b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelDcrk.h @@ -1,27 +1,27 @@ /** - * FieldModelDcrk.h + * ItemModelDcrk.h * * @brief: 倒车入库场地模型 * @author: zhanke * @history: 2024-08-01, create file */ -#ifndef FIELDMODELDCRK_H -#define FIELDMODELDCRK_H +#ifndef ITEMMODELDCRK_H +#define ITEMMODELDCRK_H -#include "FieldModelAbstractClass.h" #include "GraphicDefines.h" +#include "ItemModelAbstractClass.h" using graphic::AutoPoint; -class FieldModelDcrk : public FieldModelAbstractClass +class ItemModelDcrk : public ItemModelAbstractClass { public: - explicit FieldModelDcrk(); + explicit ItemModelDcrk(); virtual void drawModel(IGraphicAbstract* pGraphicTool, const Pointi& padding, double unit) override; virtual void initTeachPointLines() override; }; -#endif // FIELDMODELDCRK_H +#endif // ITEMMODELDCRK_H diff --git a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelPdqb.cpp b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelPdqb.cpp similarity index 65% rename from entry/src/main/cpp/sdk/assistdrive/field/FieldModelPdqb.cpp rename to entry/src/main/cpp/sdk/assistdrive/item/ItemModelPdqb.cpp index 99d5a5c..c11d3de 100644 --- a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelPdqb.cpp +++ b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelPdqb.cpp @@ -1,11 +1,11 @@ -#include "FieldModelPdqb.h" +#include "ItemModelPdqb.h" -FieldModelPdqb::FieldModelPdqb() +ItemModelPdqb::ItemModelPdqb() { - modelName_ = automatic_service::PDQB; + itemName_ = automatic_service::PDQB; } -void FieldModelPdqb::drawModel(IGraphicAbstract *pGraphicTool, const Pointi &padding, double unit) +void ItemModelPdqb::drawModel(IGraphicAbstract *pGraphicTool, const Pointi &padding, double unit) { std::vector pixelList; transferPoint2ImagePixel(pointList_, padding, unit, pixelList); diff --git a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelPdqb.h b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelPdqb.h similarity index 62% rename from entry/src/main/cpp/sdk/assistdrive/field/FieldModelPdqb.h rename to entry/src/main/cpp/sdk/assistdrive/item/ItemModelPdqb.h index 9c61488..aeb0fc9 100644 --- a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelPdqb.h +++ b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelPdqb.h @@ -1,20 +1,20 @@ /** - * FieldModelPdqb.h + * ItemModelPdqb.h * * @brief: 坡道起步场地模型 * @author: zhanke * @history: 2024-08-01, create file */ -#ifndef FIELDMODELPDQB_H -#define FIELDMODELPDQB_H +#ifndef ITEMMODELPDQB_H +#define ITEMMODELPDQB_H -#include "FieldModelAbstractClass.h" +#include "ItemModelAbstractClass.h" -class FieldModelPdqb : public FieldModelAbstractClass +class ItemModelPdqb : public ItemModelAbstractClass { public: - explicit FieldModelPdqb(); + explicit ItemModelPdqb(); virtual void drawModel(IGraphicAbstract* pGraphicTool, const Pointi& padding, double unit) override; @@ -22,4 +22,4 @@ public: virtual void initTeachPointLines() override {} }; -#endif // FIELDMODELPDQB_H +#endif // ITEMMODELPDQB_H diff --git a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelQxxs.cpp b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelQxxs.cpp similarity index 78% rename from entry/src/main/cpp/sdk/assistdrive/field/FieldModelQxxs.cpp rename to entry/src/main/cpp/sdk/assistdrive/item/ItemModelQxxs.cpp index 20d7b4f..d54dcf1 100644 --- a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelQxxs.cpp +++ b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelQxxs.cpp @@ -1,14 +1,14 @@ -#include "FieldModelQxxs.h" +#include "ItemModelQxxs.h" -#include "GraphicTools.h" #include "AutomaticServiceDataManager.h" +#include "GraphicTools.h" -FieldModelQxxs::FieldModelQxxs() +ItemModelQxxs::ItemModelQxxs() { - modelName_ = automatic_service::QXXS; + itemName_ = automatic_service::QXXS; } -void FieldModelQxxs::drawModel(IGraphicAbstract *pGraphicTool, const Pointi &padding, double unit) +void ItemModelQxxs::drawModel(IGraphicAbstract *pGraphicTool, const Pointi &padding, double unit) { std::vector leftPixelList; std::vector rightPixelList; @@ -25,7 +25,7 @@ void FieldModelQxxs::drawModel(IGraphicAbstract *pGraphicTool, const Pointi &pad } } -bool FieldModelQxxs::isModelInMapArea(AutoRect mapArea) +bool ItemModelQxxs::isModelInMapArea(AutoRect mapArea) { for (size_t i = 0; i < leftPointList_.size(); i++) { diff --git a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelQxxs.h b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelQxxs.h similarity index 62% rename from entry/src/main/cpp/sdk/assistdrive/field/FieldModelQxxs.h rename to entry/src/main/cpp/sdk/assistdrive/item/ItemModelQxxs.h index d41c8d2..c7e0fab 100644 --- a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelQxxs.h +++ b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelQxxs.h @@ -1,20 +1,20 @@ /** - * FieldModelQxxs.h + * ItemModelQxxs.h * * @brief: 曲线行驶场地模型 * @author: zhanke * @history: 2024-08-01, create file */ -#ifndef FIELDMODELQXXS_H -#define FIELDMODELQXXS_H +#ifndef ITEMMODELQXXS_H +#define ITEMMODELQXXS_H -#include "FieldModelAbstractClass.h" +#include "ItemModelAbstractClass.h" -class FieldModelQxxs : public FieldModelAbstractClass +class ItemModelQxxs : public ItemModelAbstractClass { public: - explicit FieldModelQxxs(); + explicit ItemModelQxxs(); virtual void drawModel(IGraphicAbstract* pGraphicTool, const Pointi& padding, double unit) override; @@ -22,4 +22,4 @@ public: virtual bool isModelInMapArea(AutoRect mapArea) override; }; -#endif // FIELDMODELQXXS_H +#endif // ITEMMODELQXXS_H diff --git a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelZjzw.cpp b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelZjzw.cpp similarity index 78% rename from entry/src/main/cpp/sdk/assistdrive/field/FieldModelZjzw.cpp rename to entry/src/main/cpp/sdk/assistdrive/item/ItemModelZjzw.cpp index a8c9298..d8cfaf5 100644 --- a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelZjzw.cpp +++ b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelZjzw.cpp @@ -1,13 +1,13 @@ -#include "FieldModelZjzw.h" +#include "ItemModelZjzw.h" #include "GraphicTools.h" -FieldModelZjzw::FieldModelZjzw() +ItemModelZjzw::ItemModelZjzw() { - modelName_ = automatic_service::ZJZW; + itemName_ = automatic_service::ZJZW; } -void FieldModelZjzw::drawModel(IGraphicAbstract* pGraphicTool, const Pointi& padding, double unit) +void ItemModelZjzw::drawModel(IGraphicAbstract* pGraphicTool, const Pointi& padding, double unit) { std::vector pixelList; transferPoint2ImagePixel(pointList_, padding, unit, pixelList); @@ -18,7 +18,7 @@ void FieldModelZjzw::drawModel(IGraphicAbstract* pGraphicTool, const Pointi& pad pGraphicTool->drawLine(pixelList[4], pixelList[5]); } -void FieldModelZjzw::initTeachPointLines() +void ItemModelZjzw::initTeachPointLines() { // 初始化进项目和出项目标志线 inLine_ = AutoLine(pointList_[0], pointList_[1]); diff --git a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelZjzw.h b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelZjzw.h similarity index 58% rename from entry/src/main/cpp/sdk/assistdrive/field/FieldModelZjzw.h rename to entry/src/main/cpp/sdk/assistdrive/item/ItemModelZjzw.h index a52c393..d920110 100644 --- a/entry/src/main/cpp/sdk/assistdrive/field/FieldModelZjzw.h +++ b/entry/src/main/cpp/sdk/assistdrive/item/ItemModelZjzw.h @@ -1,24 +1,24 @@ /** - * FieldModelZjzw.h + * ItemModelZjzw.h * * @brief: 直角转弯场地模型 * @author: zhanke * @history: 2024-08-01, create file */ -#ifndef FIELDMODELZJZW_H -#define FIELDMODELZJZW_H +#ifndef ITEMMODELZJZW_H +#define ITEMMODELZJZW_H -#include "FieldModelAbstractClass.h" +#include "ItemModelAbstractClass.h" -class FieldModelZjzw : public FieldModelAbstractClass +class ItemModelZjzw : public ItemModelAbstractClass { public: - explicit FieldModelZjzw(); + explicit ItemModelZjzw(); virtual void drawModel(IGraphicAbstract* pGraphicTool, const Pointi& padding, double unit) override; virtual void initTeachPointLines() override; }; -#endif // FIELDMODELZJZW_H +#endif // ITEMMODELZJZW_H diff --git a/entry/src/main/cpp/sdk/assistdrive/track/TrackModeDefines.h b/entry/src/main/cpp/sdk/assistdrive/track/TrackModeDefines.h index 2f98f3d..544090e 100644 --- a/entry/src/main/cpp/sdk/assistdrive/track/TrackModeDefines.h +++ b/entry/src/main/cpp/sdk/assistdrive/track/TrackModeDefines.h @@ -11,6 +11,8 @@ #include +#include "json.hpp" + namespace track_mode { static constexpr auto MODE_TEACH = "teach"; @@ -30,4 +32,26 @@ static constexpr auto LATERAL_LIB = 4; // 侧方入库 } // namespace track_mode +// 车辆控制参数 +struct ControlParam +{ + ControlParam() = default; + + ControlParam(double fxp) + { + this->fxp = fxp; + this->move = -1000; + } + + ControlParam(double fxp, int move) + { + this->fxp = fxp; + this->move = move; + } + + double fxp = 0.0; // 方向盘 + int move = -1000; // 行进模式代码 +}; +NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ControlParam, fxp, move) + #endif // TRACKMODEDEFINES_H diff --git a/entry/src/main/cpp/sdk/assistdrive/track/TrackModeManager.cpp b/entry/src/main/cpp/sdk/assistdrive/track/TrackModeManager.cpp index d360ee0..ddbb05b 100644 --- a/entry/src/main/cpp/sdk/assistdrive/track/TrackModeManager.cpp +++ b/entry/src/main/cpp/sdk/assistdrive/track/TrackModeManager.cpp @@ -21,9 +21,10 @@ void TrackModeManager::init(TrackInfo &trackInfo) } } -std::string TrackModeManager::run(TrackInfo &trackInfo) +ControlParam TrackModeManager::run(TrackInfo &trackInfo) { - std::string trackOrder; + ControlParam trackOrder; + // 计算车辆当前位置 calculateCarLocate(trackInfo); // 判断当前触发模式 diff --git a/entry/src/main/cpp/sdk/assistdrive/track/TrackModeManager.h b/entry/src/main/cpp/sdk/assistdrive/track/TrackModeManager.h index e001284..0c2243d 100644 --- a/entry/src/main/cpp/sdk/assistdrive/track/TrackModeManager.h +++ b/entry/src/main/cpp/sdk/assistdrive/track/TrackModeManager.h @@ -11,6 +11,7 @@ #include "TrackInfo.h" #include "TrackModeAbstractClass.h" +#include "TrackModeDefines.h" class TrackModeManager { @@ -21,7 +22,7 @@ public: void init(TrackInfo &trackInfo); // 运行 - std::string run(TrackInfo &trackInfo); + ControlParam run(TrackInfo &trackInfo); // 结束 void end() {} diff --git a/entry/src/main/cpp/sdk/assistdrive/track/libTrack/LibModeAbstractClass.h b/entry/src/main/cpp/sdk/assistdrive/track/libTrack/LibModeAbstractClass.h index 7dc946a..ea306ed 100644 --- a/entry/src/main/cpp/sdk/assistdrive/track/libTrack/LibModeAbstractClass.h +++ b/entry/src/main/cpp/sdk/assistdrive/track/libTrack/LibModeAbstractClass.h @@ -21,7 +21,7 @@ public: virtual bool isTrigger(double x, double y, double yaw) = 0; virtual void doCalculate(double x, double y, double yaw) = 0; virtual void out() = 0; - virtual std::string doRun(double x, double y, double yaw) = 0; + virtual ControlParam doRun(double x, double y, double yaw) = 0; bool getIsModeTrigger() { return isModeTrigger_; } void setModeTrigger(bool modeTrigger) { this->isModeTrigger_ = modeTrigger; } @@ -51,7 +51,7 @@ protected: * 自动驾驶输出内容(格式: "方向盘;车辆状态") * 方向盘(-540 ~ +540)、扭矩(前进1、停车0、后退-1)、EHB液压(刹车10) */ - std::string order_ = ""; + ControlParam order_; AutoPointList pointList_; // 原始点 std::vector sensors_ = std::vector(10); // 计算结果的传感值 diff --git a/entry/src/main/cpp/sdk/assistdrive/track/libTrack/LibModeLateral.h b/entry/src/main/cpp/sdk/assistdrive/track/libTrack/LibModeLateral.h index fdeb032..a2d4529 100644 --- a/entry/src/main/cpp/sdk/assistdrive/track/libTrack/LibModeLateral.h +++ b/entry/src/main/cpp/sdk/assistdrive/track/libTrack/LibModeLateral.h @@ -20,7 +20,7 @@ public: virtual void out() override {} - virtual std::string doRun(double x, double y, double yaw) override { return ""; } + virtual ControlParam doRun(double x, double y, double yaw) override { return ControlParam(); } }; #endif // LIBMODELATERAL_H diff --git a/entry/src/main/cpp/sdk/assistdrive/track/libTrack/LibModeReverse.cpp b/entry/src/main/cpp/sdk/assistdrive/track/libTrack/LibModeReverse.cpp index 940d02c..32ee4e6 100644 --- a/entry/src/main/cpp/sdk/assistdrive/track/libTrack/LibModeReverse.cpp +++ b/entry/src/main/cpp/sdk/assistdrive/track/libTrack/LibModeReverse.cpp @@ -56,7 +56,7 @@ void LibModeReverse::out() state_ = 1; } -std::string LibModeReverse::doRun(double x, double y, double yaw) +ControlParam LibModeReverse::doRun(double x, double y, double yaw) { if (1 == state_) { // 开始后倒右打满方向盘 @@ -94,7 +94,8 @@ std::string LibModeReverse::doRun(double x, double y, double yaw) } } - order_ = std::to_string(fxpOrder_) + ";" + std::to_string(moveOrder_); + order_.fxp = fxpOrder_; + order_.move = moveOrder_; return order_; } diff --git a/entry/src/main/cpp/sdk/assistdrive/track/libTrack/LibModeReverse.h b/entry/src/main/cpp/sdk/assistdrive/track/libTrack/LibModeReverse.h index c1e7100..386c2ee 100644 --- a/entry/src/main/cpp/sdk/assistdrive/track/libTrack/LibModeReverse.h +++ b/entry/src/main/cpp/sdk/assistdrive/track/libTrack/LibModeReverse.h @@ -29,7 +29,7 @@ public: virtual void out() override; - virtual std::string doRun(double x, double y, double yaw) override; + virtual ControlParam doRun(double x, double y, double yaw) override; private: /** diff --git a/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/PathTrackAbstractClass.h b/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/PathTrackAbstractClass.h new file mode 100644 index 0000000..4d67f34 --- /dev/null +++ b/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/PathTrackAbstractClass.h @@ -0,0 +1,27 @@ +/** + * PathTrackAbstractClass.h + * + * @brief: 轨迹跟踪抽象类 + * @author: zhanke + * @history: 2024-08-01, move from java project + * 2024-09-04, change name from PathMethod to PathTrackAbstractClass + */ + +#ifndef PATHTRACKABSTRACTCLASS_H +#define PATHTRACKABSTRACTCLASS_H + +#include "GraphicDefines.h" +#include "State.h" +#include "TrackModeDefines.h" + +using graphic::AutoPoint; + +class PathTrackAbstractClass +{ +public: + virtual void init(State initState, std::vector pointList) = 0; + virtual ControlParam step(State currState) = 0; + virtual std::string getMethodName() = 0; +}; + +#endif // PATHTRACKABSTRACTCLASS_H diff --git a/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/PathTrackDefines.h b/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/PathTrackDefines.h new file mode 100644 index 0000000..ccc0af4 --- /dev/null +++ b/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/PathTrackDefines.h @@ -0,0 +1,31 @@ +/** + * PathTrackDefines.h + * + * @brief: 轨迹跟踪相关定义 + * @author: zhanke + * @history: 2024-09-04, create file + */ + +#ifndef PATHTRACKDEFINES_H +#define PATHTRACKDEFINES_H + +namespace path_track +{ +constexpr auto kMethodPursuit = "PURSUIT"; +constexpr auto kMethodLQR = "LQR"; + +namespace pursuit_method +{ +// NOTE_zhanke: 不清楚以下参数的具体作用 +constexpr auto k = 0.1; // look forward gain +constexpr auto Lfc = 6.5; // [m] look-ahead distance +constexpr auto Kp = 1.0; // speed proportional gain +constexpr auto dt = 0.1; // [s] time tick +constexpr auto WB = 2.42; // [m] wheel base of vehicle + +// 哪吒V型车转向比(哪吒底盘人员提供,与速度关系不大,与方向盘关系大,一般为抛物线关系,已获取到文档) +constexpr auto STEERING_RATIO = 16; +}; // namespace pursuit_method +}; // namespace path_track + +#endif // PATHTRACKDEFINES_H diff --git a/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/PathTrackMethodLQR.h b/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/PathTrackMethodLQR.h new file mode 100644 index 0000000..7ad41c1 --- /dev/null +++ b/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/PathTrackMethodLQR.h @@ -0,0 +1,26 @@ +/** + * PathTrackMethodLQR.h + * + * @brief: LQR轨迹跟踪算法(暂未实现) + * @author: zhanke + * @history: 2024-08-01, move from java project + * 2024-09-04, change name from PathMethodLqr to PathTrackMethodLQR + */ + +#ifndef PATHTRACKMETHODLQR_H +#define PATHTRACKMETHODLQR_H + +#include "PathTrackAbstractClass.h" +#include "PathTrackDefines.h" + +using graphic::AutoPoint; + +class PathTrackMethodLQR : public PathTrackAbstractClass +{ +public: + virtual void init(State initState, std::vector pointList) override {} + virtual ControlParam step(State currState) override { return ControlParam(); } + virtual std::string getMethodName() override { return path_track::kMethodLQR; } +}; + +#endif // PATHTRACKMETHODLQR_H diff --git a/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/PathTrackMethodPursuit.cpp b/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/PathTrackMethodPursuit.cpp new file mode 100644 index 0000000..ce49105 --- /dev/null +++ b/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/PathTrackMethodPursuit.cpp @@ -0,0 +1,18 @@ +#include "PathTrackMethodPursuit.h" + +void PathTrackMethodPursuit::init(State initState, std::vector pointList) +{ + pathTracking_.init(initState.x, initState.y, initState.yaw, initState.v, pointList); +} + +ControlParam PathTrackMethodPursuit::step(State currState) +{ + std::vector temp; + pathTracking_.initPt(); + return pathTracking_.step(temp, currState); +} + +std::string PathTrackMethodPursuit::getMethodName() +{ + return path_track::kMethodPursuit; +} diff --git a/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/PathTrackMethodPursuit.h b/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/PathTrackMethodPursuit.h new file mode 100644 index 0000000..f54ab7a --- /dev/null +++ b/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/PathTrackMethodPursuit.h @@ -0,0 +1,30 @@ +/** + * PathTrackMethodPursuit.h + * + * @brief: 简单追踪方法 + * @author: zhanke + * @history: 2024-08-01, move from java project + * 2024-09-04, change name from PathMethodPurp to PathTrackMethodPursuit + */ + +#ifndef PATHTRACKMETHODPURSUIT_H +#define PATHTRACKMETHODPURSUIT_H + +#include "PathTrackAbstractClass.h" +#include "PathTrackDefines.h" +#include "PathTracking.h" + +using graphic::AutoPoint; + +class PathTrackMethodPursuit : public PathTrackAbstractClass +{ +public: + virtual void init(State initState, std::vector pointList) override; + virtual ControlParam step(State currState) override; + virtual std::string getMethodName() override; + +private: + PathTracking pathTracking_; +}; + +#endif // PATHTRACKMETHODPURSUIT_H diff --git a/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/purp/CtrlParam.h b/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/purp/CtrlParam.h deleted file mode 100644 index fbfdf2c..0000000 --- a/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/purp/CtrlParam.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef CTRLPARAM_H -#define CTRLPARAM_H - -class CtrlParam -{ -public: - static constexpr auto k = 0.1; // look forward gain - static constexpr auto Lfc = 6.5; // [m] look-ahead distance - static constexpr auto Kp = 1.0; // speed proportional gain - static constexpr auto dt = 0.1; // [s] time tick - static constexpr auto WB = 2.42; // [m] wheel base of vehicle - - // 哪吒V型车转向比(哪吒底盘人员提供,与速度关系不大,与方向盘关系大,一般为抛物线关系,已获取到文档) - static const int STEERING_RATIO = 16; -}; - -#endif // CTRLPARAM_H diff --git a/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/purp/PathTracking.cpp b/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/pursuitMethod/PathTracking.cpp similarity index 59% rename from entry/src/main/cpp/sdk/assistdrive/track/pathTrack/purp/PathTracking.cpp rename to entry/src/main/cpp/sdk/assistdrive/track/pathTrack/pursuitMethod/PathTracking.cpp index 360b850..a76bd1f 100644 --- a/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/purp/PathTracking.cpp +++ b/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/pursuitMethod/PathTracking.cpp @@ -23,35 +23,38 @@ void PathTracking::initPt() } } -double PathTracking::step(std::vector points, State current_state) +ControlParam PathTracking::step(std::vector points, State current_state) { if (lastIndex_ >= target_ind_) { - double di = pure_pursuit_steer_control(current_state, target_course_, target_ind_); + ControlParam di = pure_pursuit_steer_control(current_state, target_course_, target_ind_); points.emplace_back(AutoPoint(current_state.x, current_state.y, current_state.yaw)); return di; } - return 360; + return ControlParam(360); } double PathTracking::proportional_control(double target, double current) { - double a = CtrlParam::Kp * (target - current); + double a = path_track::pursuit_method::Kp * (target - current); return a; } -double PathTracking::pure_pursuit_steer_control(State state, TargetCourse trajectory, int pind) +ControlParam PathTracking::pure_pursuit_steer_control(State state, TargetCourse trajectory, + int pind) { - std::string logText = "[PathTracking] carCurState_ = (" + std::to_string(state.x) + ", " - + std::to_string(state.y) + ", " + std::to_string(state.yaw) + ", " - + std::to_string(state.v) + ")"; + std::string logText = "[PathTracking] carCurState_ = (" + std::to_string(state.x) + ", " + + std::to_string(state.y) + ", " + std::to_string(state.yaw) + ", " + + std::to_string(state.v) + ")"; AutomaticServiceLogManager::GetInstance()->log(logText); Target target = trajectory.search_target_index(state); int ind = target.ind; double Lf = target.Lf; ind = std::max(pind, ind); + logText = "[PathTracking] ind = " + std::to_string(ind); + AutomaticServiceLogManager::GetInstance()->log(logText); double tx, ty; if (ind < (int)trajectory.cx().size()) @@ -66,18 +69,27 @@ double PathTracking::pure_pursuit_steer_control(State state, TargetCourse trajec ind = trajectory.cx().size() - 1; } + double dx = tx - state.rear_x; + double dy = ty - state.rear_y; + if (ind == (int)trajectory.cx().size() - 1 && dx * dx + dy * dy <= 4) + { + // 到达最后一个导航点,停车 + return ControlParam(0.0, 0); + } + target_ind_ = ind; target_l_ = Lf; // 车辆偏转角度 = 目标方向角度 - 当前航向角 double alpha = atan2(ty - state.rear_y, tx - state.rear_x) - state.yaw; // 通过车辆偏转角度计算轮胎偏转角度 - double delta = atan2(2.0 * CtrlParam::WB * sin(alpha) / Lf, 1.0); + double delta = atan2(2.0 * path_track::pursuit_method::WB * sin(alpha) / Lf, 1.0); logText = "[PathTracking] alpha = " + std::to_string(alpha) + ", delta = " + std::to_string(delta); AutomaticServiceLogManager::GetInstance()->log(logText); - return alpha; - // return delta; + return ControlParam(delta); + // FIXME: [zhanke] 虚拟数据调试返回车辆偏转角度,实际返回方向盘转动角度 + // return ControlParam(alpha); } diff --git a/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/purp/PathTracking.h b/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/pursuitMethod/PathTracking.h similarity index 81% rename from entry/src/main/cpp/sdk/assistdrive/track/pathTrack/purp/PathTracking.h rename to entry/src/main/cpp/sdk/assistdrive/track/pathTrack/pursuitMethod/PathTracking.h index 795a9a1..f9bc302 100644 --- a/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/purp/PathTracking.h +++ b/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/pursuitMethod/PathTracking.h @@ -15,7 +15,7 @@ public: void initPt(); - double step(std::vector points, State current_state); + ControlParam step(std::vector points, State current_state); States getStates() { return states_; } int getTarget_ind() { return target_ind_; } @@ -23,7 +23,7 @@ public: private: double proportional_control(double target, double current); - double pure_pursuit_steer_control(State state, TargetCourse trajectory, int pind); + ControlParam pure_pursuit_steer_control(State state, TargetCourse trajectory, int pind); bool tag_ = false; int lastIndex_; diff --git a/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/purp/State.h b/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/pursuitMethod/State.h similarity index 100% rename from entry/src/main/cpp/sdk/assistdrive/track/pathTrack/purp/State.h rename to entry/src/main/cpp/sdk/assistdrive/track/pathTrack/pursuitMethod/State.h diff --git a/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/purp/States.h b/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/pursuitMethod/States.h similarity index 100% rename from entry/src/main/cpp/sdk/assistdrive/track/pathTrack/purp/States.h rename to entry/src/main/cpp/sdk/assistdrive/track/pathTrack/pursuitMethod/States.h diff --git a/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/purp/TargetCourse.cpp b/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/pursuitMethod/TargetCourse.cpp similarity index 93% rename from entry/src/main/cpp/sdk/assistdrive/track/pathTrack/purp/TargetCourse.cpp rename to entry/src/main/cpp/sdk/assistdrive/track/pathTrack/pursuitMethod/TargetCourse.cpp index 898102d..a4b69f6 100644 --- a/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/purp/TargetCourse.cpp +++ b/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/pursuitMethod/TargetCourse.cpp @@ -1,5 +1,7 @@ #include "TargetCourse.h" +#include "PathTrackDefines.h" + Target::Target(int ind, double Lf) { this->ind = ind; @@ -61,7 +63,7 @@ Target TargetCourse::search_target_index(State state) } } - double Lf = CtrlParam::Lfc; // 左右控制,前后速度恒定不考虑 + double Lf = path_track::pursuit_method::Lfc; // 左右控制,前后速度恒定不考虑 while (Lf > state.calc_distance(cx_[ind], cy_[ind])) { if (ind >= (int)cx_.size() - 1) diff --git a/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/purp/TargetCourse.h b/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/pursuitMethod/TargetCourse.h similarity index 94% rename from entry/src/main/cpp/sdk/assistdrive/track/pathTrack/purp/TargetCourse.h rename to entry/src/main/cpp/sdk/assistdrive/track/pathTrack/pursuitMethod/TargetCourse.h index 0047a1c..5ccbc38 100644 --- a/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/purp/TargetCourse.h +++ b/entry/src/main/cpp/sdk/assistdrive/track/pathTrack/pursuitMethod/TargetCourse.h @@ -5,7 +5,7 @@ #include #include -#include "CtrlParam.h" +#include "PathTrackDefines.h" #include "HFactory.h" #include "State.h" diff --git a/entry/src/main/cpp/sdk/assistdrive/track/teachTrack/CacuTeach.h b/entry/src/main/cpp/sdk/assistdrive/track/teachTrack/CacuTeach.h index 9f30d9a..e2395e4 100644 --- a/entry/src/main/cpp/sdk/assistdrive/track/teachTrack/CacuTeach.h +++ b/entry/src/main/cpp/sdk/assistdrive/track/teachTrack/CacuTeach.h @@ -6,12 +6,13 @@ #include #include "AutomaticServiceLogManager.h" +#include "TrackModeDefines.h" class CacuTeach { public: /* 输入教学点,输出角度和前进状态 */ - std::string getCarFxpAndStates(int teachPoint, std::string curItem, std::string lastItem) + ControlParam getCarFxpAndStates(int teachPoint, std::string curItem, std::string lastItem) { bool result = true; @@ -270,7 +271,9 @@ public: // } else if (teachPoint == 1) { - fxp_ = 540; + // FIXME: 模拟场景中直接输出车辆偏转角度 + // fxp_ = 540; + fxp_ = 90; state_ = 10; trigerPt_ = 2; timeGap_ = FXP_WAIT_TIME; @@ -391,87 +394,87 @@ public: { switch (trigerPt_) { - case 1: - case 7: - case 8: - case 9: - case 15: - case 16: - case 17: - state_ = 1; - result = true; - break; - case 2: - case 3: - case 4: - case 5: - case 6: - case 10: - case 11: - case 12: - case 13: - case 14: - state_ = -1; - result = true; - break; + case 1: + case 7: + case 8: + case 9: + case 15: + case 16: + case 17: + state_ = 1; + result = true; + break; + case 2: + case 3: + case 4: + case 5: + case 6: + case 10: + case 11: + case 12: + case 13: + case 14: + state_ = -1; + result = true; + break; } } else if ("20400" == curItem) { switch (trigerPt_) { - case 1: - case 6: - case 7: - case 8: - case 9: - state_ = 1; - result = true; - break; - case 2: - case 3: - case 4: - case 5: - state_ = -1; - result = true; - break; + case 1: + case 6: + case 7: + case 8: + case 9: + state_ = 1; + result = true; + break; + case 2: + case 3: + case 4: + case 5: + state_ = -1; + result = true; + break; } } else if ("20700" == curItem) { switch (trigerPt_) { - case 1: - case 2: - case 3: - state_ = 1; - result = true; - break; + case 1: + case 2: + case 3: + state_ = 1; + result = true; + break; } } else if ("20300" == curItem) { switch (trigerPt_) { - case 1: - case 2: - state_ = 1; - result = true; - break; + case 1: + case 2: + state_ = 1; + result = true; + break; } } else if ("20600" == curItem) { switch (trigerPt_) { - case 1: - case 2: - case 3: - case 4: - case 5: - state_ = 1; - result = true; - break; + case 1: + case 2: + case 3: + case 4: + case 5: + state_ = 1; + result = true; + break; } } tag1_ = false; @@ -480,11 +483,11 @@ public: if (result) { - return std::to_string(fxp_) + ";" + std::to_string(state_); + return ControlParam(fxp_, state_); } else { - return std::to_string(fxp_) + ";" + "-1000"; + return ControlParam(fxp_); } } diff --git a/entry/src/main/cpp/sdk/assistdrive/track/trackMode/TrackModeAbstractClass.h b/entry/src/main/cpp/sdk/assistdrive/track/trackMode/TrackModeAbstractClass.h index a6fc0d8..26ef8d4 100644 --- a/entry/src/main/cpp/sdk/assistdrive/track/trackMode/TrackModeAbstractClass.h +++ b/entry/src/main/cpp/sdk/assistdrive/track/trackMode/TrackModeAbstractClass.h @@ -11,12 +11,13 @@ #define TRACKMODEABSTRACTCLASS_H #include "TrackInfo.h" +#include "TrackModeDefines.h" class TrackModeAbstractClass { public: virtual void doInit(TrackInfo trackInfo) = 0; - virtual std::string doRun(TrackInfo trackInfo) = 0; + virtual ControlParam doRun(TrackInfo trackInfo) = 0; virtual void doEnd() = 0; virtual bool isTrigger(TrackInfo trackInfo) = 0; diff --git a/entry/src/main/cpp/sdk/assistdrive/track/trackMode/TrackModeLib.h b/entry/src/main/cpp/sdk/assistdrive/track/trackMode/TrackModeLib.h index 05d43e6..cc882e0 100644 --- a/entry/src/main/cpp/sdk/assistdrive/track/trackMode/TrackModeLib.h +++ b/entry/src/main/cpp/sdk/assistdrive/track/trackMode/TrackModeLib.h @@ -22,7 +22,7 @@ public: } } - virtual std::string doRun(TrackInfo trackInfo) override + virtual ControlParam doRun(TrackInfo trackInfo) override { return pCurrLibMode_->doRun(trackInfo.getCarCurState().x, trackInfo.getCarCurState().y, trackInfo.getCarCurState().yaw); diff --git a/entry/src/main/cpp/sdk/assistdrive/track/trackMode/TrackModePath.h b/entry/src/main/cpp/sdk/assistdrive/track/trackMode/TrackModePath.h index 21c7fd2..4b9949b 100644 --- a/entry/src/main/cpp/sdk/assistdrive/track/trackMode/TrackModePath.h +++ b/entry/src/main/cpp/sdk/assistdrive/track/trackMode/TrackModePath.h @@ -1,9 +1,16 @@ -#ifndef TRACK_MODE_PATH_H_ -#define TRACK_MODE_PATH_H_ +/** + * TrackModePath.h + * + * @brief: 路径跟踪模式 + * @author: zhanke + * @history: 2024-08-01, move from java project + */ -#include "PathMethod.h" -#include "PathMethodLqr.h" -#include "PathMethodPurp.h" +#ifndef TRACKMODEPATH_H +#define TRACKMODEPATH_H + +#include "PathTrackMethodLQR.h" +#include "PathTrackMethodPursuit.h" #include "TrackModeAbstractClass.h" class TrackModePath : public TrackModeAbstractClass @@ -11,14 +18,14 @@ class TrackModePath : public TrackModeAbstractClass public: TrackModePath() { - pathMethodPtrList_.emplace_back(new PathMethodPurp()); - pathMethodPtrList_.emplace_back(new PathMethodLqr()); + pathMethodPtrList_.emplace_back(new PathTrackMethodLQR()); + pathMethodPtrList_.emplace_back(new PathTrackMethodPursuit()); - for (PathMethod *pm : pathMethodPtrList_) + for (PathTrackAbstractClass *pMethod : pathMethodPtrList_) { - if (CUR_PATH_CACULATE == pm->getName()) + if (currMethod == pMethod->getMethodName()) { - pCurrPathMethod_ = pm; + pCurrPathMethod_ = pMethod; } } } @@ -28,11 +35,11 @@ public: pCurrPathMethod_->init(trackInfo.getCarInitState(), trackInfo.getSelectedPath()); } - virtual std::string doRun(TrackInfo trackInfo) override + virtual ControlParam doRun(TrackInfo trackInfo) override { - double temp = pCurrPathMethod_->step(trackInfo.getCarCurState()); + ControlParam temp = pCurrPathMethod_->step(trackInfo.getCarCurState()); - return std::to_string(temp) + ";-1000"; + return ControlParam(temp); } virtual void doEnd() override {} @@ -44,10 +51,9 @@ public: virtual std::string getTrackModeName() override { return track_mode::MODE_PATH; } private: - static constexpr auto CUR_PATH_CACULATE = PathMethod::PURE_PERSUIT; // ��ǰѡ��ĸ����㷨 - - PathMethod *pCurrPathMethod_; - std::vector pathMethodPtrList_; + std::string currMethod = path_track::kMethodPursuit; // 当前选用的循迹方法名称 + PathTrackAbstractClass *pCurrPathMethod_ = nullptr; + std::vector pathMethodPtrList_; }; -#endif // !TRACK_MODE_PATH_H_ +#endif // TRACKMODEPATH_H diff --git a/entry/src/main/cpp/sdk/assistdrive/track/trackMode/TrackModeTeach.cpp b/entry/src/main/cpp/sdk/assistdrive/track/trackMode/TrackModeTeach.cpp index 1b4f192..de92051 100644 --- a/entry/src/main/cpp/sdk/assistdrive/track/trackMode/TrackModeTeach.cpp +++ b/entry/src/main/cpp/sdk/assistdrive/track/trackMode/TrackModeTeach.cpp @@ -2,7 +2,7 @@ #include "TrackModeDefines.h" -std::string TrackModeTeach::doRun(TrackInfo trackInfo) +ControlParam TrackModeTeach::doRun(TrackInfo trackInfo) { return cacuTeach_.getCarFxpAndStates(trackInfo.getCurTeachPoint(), trackInfo.getCurItem(), ""); } diff --git a/entry/src/main/cpp/sdk/assistdrive/track/trackMode/TrackModeTeach.h b/entry/src/main/cpp/sdk/assistdrive/track/trackMode/TrackModeTeach.h index c656027..346bdec 100644 --- a/entry/src/main/cpp/sdk/assistdrive/track/trackMode/TrackModeTeach.h +++ b/entry/src/main/cpp/sdk/assistdrive/track/trackMode/TrackModeTeach.h @@ -8,7 +8,7 @@ class TrackModeTeach : public TrackModeAbstractClass { public: virtual void doInit(TrackInfo trackInfo) override {} - virtual std::string doRun(TrackInfo trackInfo) override; + virtual ControlParam doRun(TrackInfo trackInfo) override; virtual void doEnd() override {} virtual bool isTrigger(TrackInfo trackInfo) override; diff --git a/entry/src/main/cpp/sdk/exam/ExamService.h b/entry/src/main/cpp/sdk/exam/ExamService.h index 91685db..a52f39e 100644 --- a/entry/src/main/cpp/sdk/exam/ExamService.h +++ b/entry/src/main/cpp/sdk/exam/ExamService.h @@ -8,8 +8,8 @@ #ifndef EXAMSERVICE_H #define EXAMSERVICE_H -#include "IExamService.h" #include "IExamCar.h" +#include "IExamService.h" class JUDGE_API ExamService : public IExamService { @@ -38,7 +38,7 @@ public: virtual const char* examJudgeMapImage() override; virtual int examJudgeMapImageSetCallback(examJudgeCallbackMapImage callback) override; - //暂时未导出给APP端使用 + // 暂时未导出给APP端使用 virtual int examJudgeMapWidth() override; virtual int examJudgeMapHeight() override; virtual int examJudgeMapSize() override; @@ -51,15 +51,16 @@ public: virtual IExamCar* getExamCar() const override; virtual const std::string& getInitData() const override; virtual const TInitInfo* getInitInfo() const override; + private: std::string m_initData; TInitInfo* m_initInfo = nullptr; IExamCar* m_car = nullptr; examJudgeCallbackLog m_cbLog = nullptr; examJudgeCallbackRealExam m_cbRealExam = nullptr; - examJudgeCallbackPerform m_cbPerform = nullptr; + examJudgeCallbackPerform m_cbPerform = nullptr; examJudgeCallbackMapImage m_cbMapImage = nullptr; - bool m_init = false; //for-surface-test + bool m_init = false; // for-surface-test }; #endif // EXAMSERVICE_H diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 86be2ec..83a6eee 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -91,21 +91,21 @@ struct Index { }) await nativeSDKInit() await nativeLogCallback((message: string, len: number) => { - LogHelper.I("NativeSDK", message) + LogHelper.I("NativeSDK Callback", message) }) await setImageSize(500, 300) await setConfigFile(this.basePoint, this.fieldModel, this.teachPoint, this.teachPointParams, this.carModel, this.line, this.lib) this.outWireControl = new OutWireControl() await this.outWireControl.init("192.168.7.181", 30021) - await this.initPlatformUDP() - await this.initAudioPlayer() - await this.initBackMachineUDP() + // await this.initPlatformUDP() + // await this.initAudioPlayer() + // await this.initBackMachineUDP() } catch (err) { promptAction.showToast({ - message: JSON.stringify(err), + message: JSON.stringify(err?.message || err), duration: 3000 }) - LogHelper.E("View ", JSON.stringify(err)) + LogHelper.E("View", JSON.stringify(err?.message || err)) } } @@ -165,7 +165,7 @@ struct Index { // 初始化后置机UDP async initBackMachineUDP() { - this.backupUdpClient = new BackMachineUdpClient("", 0, "", 0) + this.backupUdpClient = new BackMachineUdpClient("0.0.0.0", 8991, "", 0) try { await this.backupUdpClient.bindUdp() this.backupUdpClient.onMessage((arr) => { diff --git a/entry/src/main/ets/utils/wireControl/WireControl.ets b/entry/src/main/ets/utils/wireControl/WireControl.ets index ace70b6..72c7b50 100644 --- a/entry/src/main/ets/utils/wireControl/WireControl.ets +++ b/entry/src/main/ets/utils/wireControl/WireControl.ets @@ -145,7 +145,7 @@ export class WireControl { this.apaPort = port; this.socket = socket.constructUDPSocketInstance() this.socket.setExtraOptions({ reuseAddress: true }); - return this.socket.bind({ address: "192.168.7.170", port: 31021 }).then(() => { + return this.socket.bind({ address: "0.0.0.0", port: 31021 }).then(() => { this.isInit = true; }) } @@ -159,8 +159,36 @@ export class WireControl { if (this.apaWorking) return; this.apaWorking = true; setInterval(() => { - + if (this.apaWorking) { + this.sendAutomaticMsg() + } }, 20) + sleep(3000).then(() => { + this.initStatus = 1; + this.APA_EPSAngleValueReq = 0; + this.APA_WorkSts_CH = 0x2; + return sleep(2000) + }).then(() => { + this.APA_WorkSts_CH = 0x3; + this.APA3_TorqReq = 1; + this.APA4_ApaBrkMod = 1; + this.APA4_ApaMod = 1; + this.APA4_APASwFd = 1; + return sleep(60) + }).then(() => { + this.APA_WorkSts_CH = 0x4; + this.APA4_ApaBrkMod = 2; + this.APA4_ApaStopReq = 1; + this.APA4_ApaEpbReq = 1; + this.APA4_ApaTarDecel = 0xc8; + return sleep(2000) + }).then(() => { + this.APA4_ApaMaxSpd = 0x80; + this.APA4_ApaTarDecel = 0; + this.initStatus = 3; + return sleep(2000) + }); + this.mApaListener.onApaStart(); } public apaStop() {