cpp
This commit is contained in:
parent
2d82810d61
commit
28545e9651
@ -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/*.*
|
||||
)
|
||||
|
||||
#设置编译的包含的目标工程
|
||||
|
||||
@ -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);
|
||||
|
||||
/**
|
||||
* 说明: 辅助驾驶日志回调函数原型
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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<JSAsyncContextLog> m_methodLog;
|
||||
JSAsyncMethod<JSAsyncContextReal> m_methodReal;
|
||||
JSAsyncMethod<JSAsyncContextPerform> m_methodPerform;
|
||||
JSAsyncMethod<JSAsyncContextMap> m_methodMap;
|
||||
// uv_work_t* m_work = nullptr;
|
||||
JSAsyncMethod<JSAsyncContextLog> m_methodLog;
|
||||
JSAsyncMethod<JSAsyncContextReal> m_methodReal;
|
||||
JSAsyncMethod<JSAsyncContextPerform> m_methodPerform;
|
||||
JSAsyncMethod<JSAsyncContextMap> m_methodMap;
|
||||
|
||||
JSAsyncMethod<JSAsyncContextString> m_autoServiceControl;
|
||||
JSAsyncMethod<JSAsyncContextString> m_autoServiceSound;
|
||||
JSAsyncMethod<JSAsyncContextString> 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
|
||||
|
||||
@ -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<std::codecvt_utf8<wchar_t>> convert;
|
||||
std::wstring str = convert.from_bytes(data);
|
||||
nlohmann::json fieldModelListJson = nlohmann::json::parse(str);
|
||||
AutomaticServiceDataManager::GetInstance()->fieldModelList() =
|
||||
fieldModelListJson.get<FieldModelList>();
|
||||
AutomaticServiceDataManager::GetInstance()->itemModelList() =
|
||||
fieldModelListJson.get<ItemModelList>();
|
||||
}
|
||||
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<std::codecvt_utf8<wchar_t>> convert;
|
||||
std::wstring str = convert.from_bytes(temp.c_str());
|
||||
nlohmann::json lineInfoJson = nlohmann::json::parse(str);
|
||||
auto temp1 = lineInfoJson.get<Track>();
|
||||
AutomaticServiceDataManager::GetInstance()->lineInfo() = lineInfoJson.get<Track>();
|
||||
}
|
||||
catch (std::exception &e)
|
||||
@ -168,7 +175,6 @@ int AutomaticService::autoServiceSetLibInfo(const char *data, int length)
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> convert;
|
||||
std::wstring str = convert.from_bytes(temp.c_str());
|
||||
nlohmann::json libInfiJson = nlohmann::json::parse(str);
|
||||
auto temp1 = libInfiJson.get<Track>();
|
||||
AutomaticServiceDataManager::GetInstance()->libInfo() = libInfiJson.get<Track>();
|
||||
}
|
||||
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<Pointi> 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<Pointi> 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<Pointi> 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++)
|
||||
{
|
||||
|
||||
@ -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<FieldModelAbstractClass *> fieldModelPtrList_; // 场地模型指针列表
|
||||
std::vector<std::vector<double>> historyPosList_; // 车辆历史位置
|
||||
std::vector<ItemModelAbstractClass *> fieldModelPtrList_; // 场地模型指针列表
|
||||
std::vector<std::vector<double>> historyPosList_; // 车辆历史位置
|
||||
};
|
||||
|
||||
#endif // !AUTOMATIC_SERVICE_H_
|
||||
|
||||
@ -7,9 +7,9 @@ BasePoint& AutomaticServiceDataManager::basePoint()
|
||||
return basePoint_;
|
||||
}
|
||||
|
||||
FieldModelList& AutomaticServiceDataManager::fieldModelList()
|
||||
ItemModelList& AutomaticServiceDataManager::itemModelList()
|
||||
{
|
||||
return fieldModelList_;
|
||||
return itemModelList_;
|
||||
}
|
||||
|
||||
TeachItemList& AutomaticServiceDataManager::teachPointInfo()
|
||||
|
||||
@ -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_; // 车辆模型
|
||||
|
||||
@ -37,7 +37,7 @@ static std::unordered_map<std::string, int> 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<ModelPoint> 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<FieldModel> model;
|
||||
std::vector<ItemModel> model;
|
||||
};
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(FieldModelList, model)
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ItemModelList, model)
|
||||
|
||||
// 教学点信息定义
|
||||
struct TeachPointInfo
|
||||
|
||||
@ -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
|
||||
|
||||
277
entry/src/main/cpp/sdk/assistdrive/data/aiconfig.json
Normal file
277
entry/src/main/cpp/sdk/assistdrive/data/aiconfig.json
Normal file
@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
6
entry/src/main/cpp/sdk/assistdrive/data/basepoint.json
Normal file
6
entry/src/main/cpp/sdk/assistdrive/data/basepoint.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"basegpsn": "31.92780567",
|
||||
"basegpse": "118.86541574",
|
||||
"basegpsnO": "31.92780567",
|
||||
"basegpseO": "118.86541574"
|
||||
}
|
||||
204
entry/src/main/cpp/sdk/assistdrive/data/car.json
Normal file
204
entry/src/main/cpp/sdk/assistdrive/data/car.json
Normal file
@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
1360
entry/src/main/cpp/sdk/assistdrive/data/collect.json
Normal file
1360
entry/src/main/cpp/sdk/assistdrive/data/collect.json
Normal file
File diff suppressed because it is too large
Load Diff
99
entry/src/main/cpp/sdk/assistdrive/data/collectParams.json
Normal file
99
entry/src/main/cpp/sdk/assistdrive/data/collectParams.json
Normal file
@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
50
entry/src/main/cpp/sdk/assistdrive/data/destLib.json
Normal file
50
entry/src/main/cpp/sdk/assistdrive/data/destLib.json
Normal file
@ -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
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
216
entry/src/main/cpp/sdk/assistdrive/data/naviPath.json
Normal file
216
entry/src/main/cpp/sdk/assistdrive/data/naviPath.json
Normal file
@ -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
|
||||
]
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -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<int, int> 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<AutoPoint> &FieldModelAbstractClass::getModelPointList()
|
||||
{
|
||||
return pointList_;
|
||||
}
|
||||
|
||||
void FieldModelAbstractClass::transferPoint2ImagePixel(const std::vector<AutoPoint> &inPointList,
|
||||
const Pointi &padding, double unit,
|
||||
std::vector<Pointi> &outPointList)
|
||||
void ItemModelAbstractClass::transferPoint2ImagePixel(const std::vector<AutoPoint> &inPointList,
|
||||
const Pointi &padding, double unit,
|
||||
std::vector<Pointi> &outPointList)
|
||||
{
|
||||
for (size_t i = 0; i < inPointList.size(); i++)
|
||||
{
|
||||
@ -186,7 +181,7 @@ void FieldModelAbstractClass::transferPoint2ImagePixel(const std::vector<AutoPoi
|
||||
}
|
||||
}
|
||||
|
||||
void FieldModelAbstractClass::transferPoint2ImagePixel(
|
||||
void ItemModelAbstractClass::transferPoint2ImagePixel(
|
||||
const std::vector<std::vector<double>> &inPointList, const Pointi &padding, double unit,
|
||||
std::vector<Pointi> &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;
|
||||
@ -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<TeachPointParam> 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<AutoPoint>& getModelPointList();
|
||||
std::string getItemName();
|
||||
|
||||
// 相对坐标点转绘图像素点
|
||||
static void transferPoint2ImagePixel(const std::vector<AutoPoint>& inPointList,
|
||||
@ -62,7 +62,7 @@ public:
|
||||
|
||||
protected:
|
||||
ItemStatus status_ = NotEnter;
|
||||
std::string modelName_; // 模型名称
|
||||
std::string itemName_; // 名称
|
||||
std::vector<TeachPoint> teachPointList_; // 教学点列表(本质是两点连线和到线的距离)
|
||||
|
||||
std::vector<AutoPoint> pointList_; // 普通点
|
||||
@ -73,4 +73,4 @@ protected:
|
||||
AutoLine outLine_; // 出项目判断线
|
||||
};
|
||||
|
||||
#endif // FIELDMODELABSTRACTCLASS_H
|
||||
#endif // ITEMMODELABSTRACTCLASS_H
|
||||
@ -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<Pointi> 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米,判断进入项目
|
||||
@ -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
|
||||
@ -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<Pointi> 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个教学点
|
||||
@ -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
|
||||
@ -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<Pointi> pixelList;
|
||||
transferPoint2ImagePixel(pointList_, padding, unit, pixelList);
|
||||
@ -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
|
||||
@ -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<Pointi> leftPixelList;
|
||||
std::vector<Pointi> 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++)
|
||||
{
|
||||
@ -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
|
||||
@ -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<Pointi> 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]);
|
||||
@ -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
|
||||
@ -11,6 +11,8 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#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
|
||||
|
||||
@ -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);
|
||||
// 判断当前触发模式
|
||||
|
||||
@ -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() {}
|
||||
|
||||
@ -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<double> sensors_ = std::vector<double>(10); // 计算结果的传感值
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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_;
|
||||
}
|
||||
|
||||
@ -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:
|
||||
/**
|
||||
|
||||
@ -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<AutoPoint> pointList) = 0;
|
||||
virtual ControlParam step(State currState) = 0;
|
||||
virtual std::string getMethodName() = 0;
|
||||
};
|
||||
|
||||
#endif // PATHTRACKABSTRACTCLASS_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
|
||||
@ -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<AutoPoint> pointList) override {}
|
||||
virtual ControlParam step(State currState) override { return ControlParam(); }
|
||||
virtual std::string getMethodName() override { return path_track::kMethodLQR; }
|
||||
};
|
||||
|
||||
#endif // PATHTRACKMETHODLQR_H
|
||||
@ -0,0 +1,18 @@
|
||||
#include "PathTrackMethodPursuit.h"
|
||||
|
||||
void PathTrackMethodPursuit::init(State initState, std::vector<AutoPoint> pointList)
|
||||
{
|
||||
pathTracking_.init(initState.x, initState.y, initState.yaw, initState.v, pointList);
|
||||
}
|
||||
|
||||
ControlParam PathTrackMethodPursuit::step(State currState)
|
||||
{
|
||||
std::vector<AutoPoint> temp;
|
||||
pathTracking_.initPt();
|
||||
return pathTracking_.step(temp, currState);
|
||||
}
|
||||
|
||||
std::string PathTrackMethodPursuit::getMethodName()
|
||||
{
|
||||
return path_track::kMethodPursuit;
|
||||
}
|
||||
@ -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<AutoPoint> pointList) override;
|
||||
virtual ControlParam step(State currState) override;
|
||||
virtual std::string getMethodName() override;
|
||||
|
||||
private:
|
||||
PathTracking pathTracking_;
|
||||
};
|
||||
|
||||
#endif // PATHTRACKMETHODPURSUIT_H
|
||||
@ -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
|
||||
@ -23,35 +23,38 @@ void PathTracking::initPt()
|
||||
}
|
||||
}
|
||||
|
||||
double PathTracking::step(std::vector<AutoPoint> points, State current_state)
|
||||
ControlParam PathTracking::step(std::vector<AutoPoint> 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);
|
||||
}
|
||||
@ -15,7 +15,7 @@ public:
|
||||
|
||||
void initPt();
|
||||
|
||||
double step(std::vector<AutoPoint> points, State current_state);
|
||||
ControlParam step(std::vector<AutoPoint> 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_;
|
||||
@ -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)
|
||||
@ -5,7 +5,7 @@
|
||||
#include <climits>
|
||||
#include <vector>
|
||||
|
||||
#include "CtrlParam.h"
|
||||
#include "PathTrackDefines.h"
|
||||
#include "HFactory.h"
|
||||
#include "State.h"
|
||||
|
||||
@ -6,12 +6,13 @@
|
||||
#include <string>
|
||||
|
||||
#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_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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; // <20><>ǰѡ<C7B0><D1A1>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD>㷨
|
||||
|
||||
PathMethod *pCurrPathMethod_;
|
||||
std::vector<PathMethod *> pathMethodPtrList_;
|
||||
std::string currMethod = path_track::kMethodPursuit; // 当前选用的循迹方法名称
|
||||
PathTrackAbstractClass *pCurrPathMethod_ = nullptr;
|
||||
std::vector<PathTrackAbstractClass *> pathMethodPtrList_;
|
||||
};
|
||||
|
||||
#endif // !TRACK_MODE_PATH_H_
|
||||
#endif // TRACKMODEPATH_H
|
||||
|
||||
@ -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(), "");
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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) => {
|
||||
|
||||
@ -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() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user