Compare commits
13 Commits
main
...
calibratio
| Author | SHA1 | Date | |
|---|---|---|---|
| b3c29dbc0b | |||
| ff72592a3c | |||
| aed9f40c18 | |||
| 9b57620232 | |||
| cb66f29777 | |||
| 4054712a35 | |||
| f1316b00b7 | |||
| cfb5277e3c | |||
| 78d278dab7 | |||
| 2640bf9ec7 | |||
| d477e511f5 | |||
| 1ab6ca603f | |||
| cbfb14a843 |
756
CMakeLists.txt
756
CMakeLists.txt
@ -1,362 +1,398 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
project(CmvrControlStation VERSION 1.0.0 LANGUAGES CXX)
|
project(CmvrControlStation VERSION 1.0.0 LANGUAGES CXX)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
set(CMAKE_AUTORCC ON)
|
set(CMAKE_AUTORCC ON)
|
||||||
set(CMAKE_AUTOUIC ON)
|
set(CMAKE_AUTOUIC ON)
|
||||||
set(CMAKE_AUTOUIC_SEARCH_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/ui")
|
set(CMAKE_AUTOUIC_SEARCH_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/ui")
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(CMVR_MSQUIC_DEFAULT ON)
|
set(CMVR_MSQUIC_DEFAULT ON)
|
||||||
else()
|
else()
|
||||||
set(CMVR_MSQUIC_DEFAULT OFF)
|
set(CMVR_MSQUIC_DEFAULT OFF)
|
||||||
endif()
|
endif()
|
||||||
option(CMVR_WITH_MSQUIC "Build the embedded MsQuic test server" ${CMVR_MSQUIC_DEFAULT})
|
option(CMVR_WITH_MSQUIC "Build the embedded MsQuic test server" ${CMVR_MSQUIC_DEFAULT})
|
||||||
set(CMVR_MSQUIC_ROOT "" CACHE PATH "Optional MsQuic installation prefix on Linux")
|
set(CMVR_MSQUIC_ROOT "" CACHE PATH "Optional MsQuic installation prefix on Linux")
|
||||||
set(CMVR_CXX_RUNTIME "" CACHE FILEPATH
|
set(CMVR_CXX_RUNTIME "" CACHE FILEPATH
|
||||||
"Optional libstdc++.so.6 matching a non-system Linux dependency prefix")
|
"Optional libstdc++.so.6 matching a non-system Linux dependency prefix")
|
||||||
set(CMVR_ASSIMP_SCENE_PARSER "" CACHE FILEPATH
|
set(CMVR_ASSIMP_SCENE_PARSER "" CACHE FILEPATH
|
||||||
"Qt3D Assimp scene parser plugin used for URDF mesh files")
|
"Qt3D Assimp scene parser plugin used for URDF mesh files")
|
||||||
|
|
||||||
set(CMVR_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
set(CMVR_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||||
set(CMVR_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib")
|
set(CMVR_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib")
|
||||||
set(CMVR_TOOLS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tools")
|
set(CMVR_TOOLS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tools")
|
||||||
set(CMVR_CERT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/certs")
|
set(CMVR_CERT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/certs")
|
||||||
set(PROTO_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/protos")
|
set(PROTO_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/protos")
|
||||||
set(GENERATED_ROOT "${CMAKE_CURRENT_BINARY_DIR}/generated_cpp")
|
set(GENERATED_ROOT "${CMAKE_CURRENT_BINARY_DIR}/generated_cpp")
|
||||||
|
|
||||||
find_package(Qt5 5.12 REQUIRED COMPONENTS
|
find_package(Qt5 5.12 REQUIRED COMPONENTS
|
||||||
Core Gui Widgets Multimedia 3DCore 3DRender 3DExtras 3DInput 3DAnimation)
|
Core Gui Widgets Multimedia 3DCore 3DRender 3DExtras 3DInput 3DAnimation)
|
||||||
|
|
||||||
get_target_property(CMVR_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)
|
get_target_property(CMVR_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)
|
||||||
if(CMVR_QMAKE_EXECUTABLE)
|
if(CMVR_QMAKE_EXECUTABLE)
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND "${CMVR_QMAKE_EXECUTABLE}" -query QT_INSTALL_PLUGINS
|
COMMAND "${CMVR_QMAKE_EXECUTABLE}" -query QT_INSTALL_PLUGINS
|
||||||
OUTPUT_VARIABLE CMVR_QT_PLUGIN_ROOT
|
OUTPUT_VARIABLE CMVR_QT_PLUGIN_ROOT
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
endif()
|
endif()
|
||||||
if(NOT CMVR_ASSIMP_SCENE_PARSER)
|
if(NOT CMVR_ASSIMP_SCENE_PARSER)
|
||||||
find_file(CMVR_ASSIMP_SCENE_PARSER
|
find_file(CMVR_ASSIMP_SCENE_PARSER
|
||||||
NAMES assimpsceneimport.dll assimpsceneimportd.dll libassimpsceneimport.so
|
NAMES assimpsceneimport.dll assimpsceneimportd.dll libassimpsceneimport.so
|
||||||
HINTS
|
HINTS
|
||||||
"${CMVR_QT_PLUGIN_ROOT}/sceneparsers"
|
"${CMVR_QT_PLUGIN_ROOT}/sceneparsers"
|
||||||
"/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/qt5/plugins/sceneparsers")
|
"/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/qt5/plugins/sceneparsers")
|
||||||
endif()
|
endif()
|
||||||
if(NOT CMVR_ASSIMP_SCENE_PARSER OR NOT EXISTS "${CMVR_ASSIMP_SCENE_PARSER}")
|
if(NOT CMVR_ASSIMP_SCENE_PARSER OR NOT EXISTS "${CMVR_ASSIMP_SCENE_PARSER}")
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"Qt3D's Assimp scene parser was not found. It is required to display "
|
"Qt3D's Assimp scene parser was not found. It is required to display "
|
||||||
"STL, DAE, and 3DS meshes from bundled URDF models. On Ubuntu install "
|
"STL, DAE, and 3DS meshes from bundled URDF models. On Ubuntu install "
|
||||||
"qt3d-assimpsceneimport-plugin, or set CMVR_ASSIMP_SCENE_PARSER to the "
|
"qt3d-assimpsceneimport-plugin, or set CMVR_ASSIMP_SCENE_PARSER to the "
|
||||||
"plugin file supplied by the selected Qt installation.")
|
"plugin file supplied by the selected Qt installation.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
# The checked-in native libraries use the Qt 5.12.4 MinGW 7.3 64-bit ABI.
|
# The checked-in native libraries use the Qt 5.12.4 MinGW 7.3 64-bit ABI.
|
||||||
set(PROTOC "${CMVR_TOOLS_DIR}/run_protoc.cmd")
|
set(PROTOC "${CMVR_TOOLS_DIR}/run_protoc.cmd")
|
||||||
set(GRPC_CPP_PLUGIN "${CMVR_TOOLS_DIR}/grpc_cpp_plugin.exe")
|
set(GRPC_CPP_PLUGIN "${CMVR_TOOLS_DIR}/grpc_cpp_plugin.exe")
|
||||||
foreach(REQUIRED_FILE IN ITEMS
|
foreach(REQUIRED_FILE IN ITEMS
|
||||||
"${PROTOC}"
|
"${PROTOC}"
|
||||||
"${GRPC_CPP_PLUGIN}"
|
"${GRPC_CPP_PLUGIN}"
|
||||||
"${CMVR_LIB_DIR}/libgrpc++.a"
|
"${CMVR_LIB_DIR}/libgrpc++.a"
|
||||||
"${CMVR_LIB_DIR}/libprotobuf.a"
|
"${CMVR_LIB_DIR}/libprotobuf.a"
|
||||||
"${CMVR_LIB_DIR}/libavcodec.dll.a"
|
"${CMVR_LIB_DIR}/libavcodec.dll.a"
|
||||||
"${CMVR_LIB_DIR}/liburdfdom_model.dll.a")
|
"${CMVR_LIB_DIR}/liburdfdom_model.dll.a")
|
||||||
if(NOT EXISTS "${REQUIRED_FILE}")
|
if(NOT EXISTS "${REQUIRED_FILE}")
|
||||||
message(FATAL_ERROR "Required Windows dependency not found: ${REQUIRED_FILE}")
|
message(FATAL_ERROR "Required Windows dependency not found: ${REQUIRED_FILE}")
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
else()
|
else()
|
||||||
find_package(Protobuf CONFIG QUIET)
|
find_package(Protobuf CONFIG QUIET)
|
||||||
if(NOT Protobuf_FOUND)
|
if(NOT Protobuf_FOUND)
|
||||||
find_package(Protobuf REQUIRED)
|
find_package(Protobuf REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
find_package(gRPC CONFIG REQUIRED)
|
find_package(gRPC CONFIG REQUIRED)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_check_modules(FFMPEG REQUIRED IMPORTED_TARGET
|
pkg_check_modules(FFMPEG REQUIRED IMPORTED_TARGET
|
||||||
libavcodec libavutil libswscale)
|
libavcodec libavutil libswscale)
|
||||||
find_path(CMVR_URDFDOM_INCLUDE_DIR urdf_parser/urdf_parser.h
|
find_path(CMVR_URDFDOM_INCLUDE_DIR urdf_parser/urdf_parser.h
|
||||||
PATH_SUFFIXES include include/urdfdom)
|
PATH_SUFFIXES include include/urdfdom)
|
||||||
find_path(CMVR_TINYXML_INCLUDE_DIR tinyxml.h PATH_SUFFIXES include)
|
find_path(CMVR_TINYXML_INCLUDE_DIR tinyxml.h PATH_SUFFIXES include)
|
||||||
find_library(CMVR_URDFDOM_MODEL_LIBRARY NAMES urdfdom_model)
|
find_library(CMVR_URDFDOM_MODEL_LIBRARY NAMES urdfdom_model)
|
||||||
if(NOT CMVR_URDFDOM_INCLUDE_DIR OR NOT CMVR_TINYXML_INCLUDE_DIR OR
|
if(NOT CMVR_URDFDOM_INCLUDE_DIR OR NOT CMVR_TINYXML_INCLUDE_DIR OR
|
||||||
NOT CMVR_URDFDOM_MODEL_LIBRARY)
|
NOT CMVR_URDFDOM_MODEL_LIBRARY)
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"urdfdom/tinyxml was not found. Install liburdfdom-dev or add its prefix "
|
"urdfdom/tinyxml was not found. Install liburdfdom-dev or add its prefix "
|
||||||
"to CMAKE_PREFIX_PATH.")
|
"to CMAKE_PREFIX_PATH.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT TARGET protobuf::protoc)
|
if(NOT TARGET protobuf::protoc)
|
||||||
message(FATAL_ERROR "The Protobuf package does not provide protobuf::protoc")
|
message(FATAL_ERROR "The Protobuf package does not provide protobuf::protoc")
|
||||||
endif()
|
endif()
|
||||||
if(NOT TARGET gRPC::grpc_cpp_plugin)
|
if(NOT TARGET gRPC::grpc_cpp_plugin)
|
||||||
message(FATAL_ERROR "The gRPC package does not provide gRPC::grpc_cpp_plugin")
|
message(FATAL_ERROR "The gRPC package does not provide gRPC::grpc_cpp_plugin")
|
||||||
endif()
|
endif()
|
||||||
set(PROTOC "$<TARGET_FILE:protobuf::protoc>")
|
set(PROTOC "$<TARGET_FILE:protobuf::protoc>")
|
||||||
set(GRPC_CPP_PLUGIN "$<TARGET_FILE:gRPC::grpc_cpp_plugin>")
|
set(GRPC_CPP_PLUGIN "$<TARGET_FILE:gRPC::grpc_cpp_plugin>")
|
||||||
|
|
||||||
# A Conda-provided Qt/gRPC stack may carry an older libstdc++ than the
|
# A Conda-provided Qt/gRPC stack may carry an older libstdc++ than the
|
||||||
# host compiler. Link against the runtime next to the imported dependency
|
# host compiler. Link against the runtime next to the imported dependency
|
||||||
# so symbol versions selected at link time match the library loaded from
|
# so symbol versions selected at link time match the library loaded from
|
||||||
# the generated RUNPATH. System packages resolve to the system runtime.
|
# the generated RUNPATH. System packages resolve to the system runtime.
|
||||||
if(NOT CMVR_CXX_RUNTIME)
|
if(NOT CMVR_CXX_RUNTIME)
|
||||||
foreach(DEPENDENCY_TARGET IN ITEMS gRPC::grpc++ Qt5::Core)
|
foreach(DEPENDENCY_TARGET IN ITEMS gRPC::grpc++ Qt5::Core)
|
||||||
get_target_property(DEPENDENCY_LOCATION
|
get_target_property(DEPENDENCY_LOCATION
|
||||||
${DEPENDENCY_TARGET} IMPORTED_LOCATION_RELEASE)
|
${DEPENDENCY_TARGET} IMPORTED_LOCATION_RELEASE)
|
||||||
if(NOT DEPENDENCY_LOCATION)
|
if(NOT DEPENDENCY_LOCATION)
|
||||||
get_target_property(DEPENDENCY_LOCATION
|
get_target_property(DEPENDENCY_LOCATION
|
||||||
${DEPENDENCY_TARGET} IMPORTED_LOCATION)
|
${DEPENDENCY_TARGET} IMPORTED_LOCATION)
|
||||||
endif()
|
endif()
|
||||||
if(DEPENDENCY_LOCATION)
|
if(DEPENDENCY_LOCATION)
|
||||||
get_filename_component(DEPENDENCY_LIB_DIR
|
get_filename_component(DEPENDENCY_LIB_DIR
|
||||||
"${DEPENDENCY_LOCATION}" DIRECTORY)
|
"${DEPENDENCY_LOCATION}" DIRECTORY)
|
||||||
if(EXISTS "${DEPENDENCY_LIB_DIR}/libstdc++.so.6")
|
if(EXISTS "${DEPENDENCY_LIB_DIR}/libstdc++.so.6")
|
||||||
set(CMVR_CXX_RUNTIME
|
set(CMVR_CXX_RUNTIME
|
||||||
"${DEPENDENCY_LIB_DIR}/libstdc++.so.6")
|
"${DEPENDENCY_LIB_DIR}/libstdc++.so.6")
|
||||||
message(STATUS
|
message(STATUS
|
||||||
"Using dependency-prefix C++ runtime: ${CMVR_CXX_RUNTIME}")
|
"Using dependency-prefix C++ runtime: ${CMVR_CXX_RUNTIME}")
|
||||||
break()
|
break()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMVR_WITH_MSQUIC)
|
if(CMVR_WITH_MSQUIC)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
if(NOT EXISTS "${CMVR_INCLUDE_DIR}/msquic.h" OR
|
if(NOT EXISTS "${CMVR_INCLUDE_DIR}/msquic.h" OR
|
||||||
NOT EXISTS "${CMVR_LIB_DIR}/msquic.dll")
|
NOT EXISTS "${CMVR_LIB_DIR}/msquic.dll")
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"CMVR_WITH_MSQUIC is enabled, but include/msquic.h or lib/msquic.dll is missing")
|
"CMVR_WITH_MSQUIC is enabled, but include/msquic.h or lib/msquic.dll is missing")
|
||||||
endif()
|
endif()
|
||||||
set(CMVR_MSQUIC_INCLUDE_DIR "${CMVR_INCLUDE_DIR}")
|
set(CMVR_MSQUIC_INCLUDE_DIR "${CMVR_INCLUDE_DIR}")
|
||||||
else()
|
else()
|
||||||
find_path(CMVR_MSQUIC_INCLUDE_DIR msquic.h
|
find_path(CMVR_MSQUIC_INCLUDE_DIR msquic.h
|
||||||
HINTS "${CMVR_MSQUIC_ROOT}"
|
HINTS "${CMVR_MSQUIC_ROOT}"
|
||||||
PATH_SUFFIXES include)
|
PATH_SUFFIXES include)
|
||||||
find_library(CMVR_MSQUIC_LIBRARY NAMES msquic
|
find_library(CMVR_MSQUIC_LIBRARY NAMES msquic
|
||||||
HINTS "${CMVR_MSQUIC_ROOT}"
|
HINTS "${CMVR_MSQUIC_ROOT}"
|
||||||
PATH_SUFFIXES lib lib64)
|
PATH_SUFFIXES lib lib64)
|
||||||
if(NOT CMVR_MSQUIC_INCLUDE_DIR OR NOT CMVR_MSQUIC_LIBRARY)
|
if(NOT CMVR_MSQUIC_INCLUDE_DIR OR NOT CMVR_MSQUIC_LIBRARY)
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"CMVR_WITH_MSQUIC=ON requires a Linux MsQuic installation. "
|
"CMVR_WITH_MSQUIC=ON requires a Linux MsQuic installation. "
|
||||||
"Set CMVR_MSQUIC_ROOT or configure with -DCMVR_WITH_MSQUIC=OFF.")
|
"Set CMVR_MSQUIC_ROOT or configure with -DCMVR_WITH_MSQUIC=OFF.")
|
||||||
endif()
|
endif()
|
||||||
get_filename_component(CMVR_MSQUIC_LIBRARY_DIR
|
get_filename_component(CMVR_MSQUIC_LIBRARY_DIR
|
||||||
"${CMVR_MSQUIC_LIBRARY}" DIRECTORY)
|
"${CMVR_MSQUIC_LIBRARY}" DIRECTORY)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMVR_SOURCES
|
set(CMVR_SOURCES
|
||||||
src/agvmapviewwidget.cpp
|
src/audiostreammanager.cpp
|
||||||
src/agvmapviewwidget.h
|
src/audiostreammanager.h
|
||||||
src/audiostreammanager.cpp
|
src/configeditorwidget.cpp
|
||||||
src/audiostreammanager.h
|
src/configeditorwidget.h
|
||||||
src/configeditorwidget.cpp
|
src/main.cpp
|
||||||
src/configeditorwidget.h
|
src/mainwindow.cpp
|
||||||
src/main.cpp
|
src/mainwindow_ui.cpp
|
||||||
src/mainwindow.cpp
|
src/mainwindow.h
|
||||||
src/mainwindow_ui.cpp
|
src/quictestserver.cpp
|
||||||
src/mainwindow.h
|
src/quictestserver.h
|
||||||
src/quictestserver.cpp
|
src/rpcservicewidget.cpp
|
||||||
src/quictestserver.h
|
src/rpcservicewidget.h
|
||||||
src/rpcservicewidget.cpp
|
src/robotclient.cpp
|
||||||
src/rpcservicewidget.h
|
src/robotclient.h
|
||||||
src/robotclient.cpp
|
src/trendwidget.cpp
|
||||||
src/robotclient.h
|
src/trendwidget.h
|
||||||
src/trendwidget.cpp
|
src/uiicons.h
|
||||||
src/trendwidget.h
|
src/urdfviewerwidget.cpp
|
||||||
src/uiicons.h
|
src/urdfviewerwidget.h
|
||||||
src/urdfviewerwidget.cpp
|
src/videodecoder.cpp
|
||||||
src/urdfviewerwidget.h
|
src/videodecoder.h
|
||||||
src/videodecoder.cpp
|
src/videoframe.h
|
||||||
src/videodecoder.h
|
src/videorenderwidget.cpp
|
||||||
src/videoframe.h
|
src/videorenderwidget.h
|
||||||
src/videorenderwidget.cpp
|
ui/handeyecalibrationwidget.cpp
|
||||||
src/videorenderwidget.h
|
ui/handeyecalibrationwidget.h
|
||||||
ui/handeyecalibrationwidget.cpp
|
ui/handeyecalibrationwidget.ui
|
||||||
ui/handeyecalibrationwidget.h
|
ui/mainwindow.ui
|
||||||
ui/handeyecalibrationwidget.ui
|
ui/systemservicepage.ui
|
||||||
ui/mainwindow.ui
|
ui/armservicepage.ui
|
||||||
ui/systemservicepage.ui
|
ui/cameraservicepage.ui
|
||||||
ui/armservicepage.ui
|
ui/agvservicepage.ui
|
||||||
ui/cameraservicepage.ui
|
ui/agvstatusdialog.ui
|
||||||
ui/agvservicepage.ui
|
ui/audioservicepage.ui
|
||||||
ui/agvstatusdialog.ui
|
ui/quicserverpage.ui
|
||||||
ui/audioservicepage.ui
|
ui/diagnosticspage.ui
|
||||||
ui/quicserverpage.ui
|
ui/rpcservicewidget.ui
|
||||||
ui/diagnosticspage.ui
|
resources.qrc)
|
||||||
ui/rpcservicewidget.ui
|
|
||||||
resources.qrc)
|
list(APPEND CMVR_SOURCES
|
||||||
|
src/handeyebridge.cpp src/handeyebridge.h
|
||||||
|
src/handeyestore.cpp src/handeyestore.h
|
||||||
|
src/handeyeurdf.cpp src/handeyeurdf.h
|
||||||
|
src/touchplanner.cpp src/touchplanner.h
|
||||||
|
src/touchsequencecontroller.cpp src/touchsequencecontroller.h
|
||||||
|
src/touchvideowidget.cpp src/touchvideowidget.h
|
||||||
|
src/touchoperationwidget.cpp src/touchoperationwidget.h
|
||||||
|
src/handeyemotionwidget.cpp src/handeyemotionwidget.h
|
||||||
|
src/tcpcalibration.cpp src/tcpcalibration.h
|
||||||
|
src/tcpjogcontroller.cpp src/tcpjogcontroller.h
|
||||||
|
src/tcptoolstore.cpp src/tcptoolstore.h
|
||||||
|
src/tcpcalibrationwidget.cpp src/tcpcalibrationwidget.h)
|
||||||
add_executable(CmvrControlStation ${CMVR_SOURCES})
|
add_executable(CmvrControlStation ${CMVR_SOURCES})
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set_target_properties(CmvrControlStation PROPERTIES WIN32_EXECUTABLE TRUE)
|
set_target_properties(CmvrControlStation PROPERTIES WIN32_EXECUTABLE TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set_target_properties(CmvrControlStation PROPERTIES
|
set_target_properties(CmvrControlStation PROPERTIES
|
||||||
DEBUG_POSTFIX "_d"
|
DEBUG_POSTFIX "_d"
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin/$<LOWER_CASE:$<CONFIG>>")
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin/$<LOWER_CASE:$<CONFIG>>")
|
||||||
|
|
||||||
target_compile_definitions(CmvrControlStation PRIVATE
|
target_compile_definitions(CmvrControlStation PRIVATE
|
||||||
CMVR_WITH_GRPC=1
|
CMVR_WITH_GRPC=1
|
||||||
CMVR_WITH_MSQUIC=$<BOOL:${CMVR_WITH_MSQUIC}>)
|
CMVR_WITH_MSQUIC=$<BOOL:${CMVR_WITH_MSQUIC}>)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_compile_definitions(CmvrControlStation PRIVATE _WIN32_WINNT=0x0600)
|
target_compile_definitions(CmvrControlStation PRIVATE _WIN32_WINNT=0x0600)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(CmvrControlStation PRIVATE "${GENERATED_ROOT}")
|
target_include_directories(CmvrControlStation PRIVATE "${GENERATED_ROOT}")
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_include_directories(CmvrControlStation PRIVATE
|
target_include_directories(CmvrControlStation PRIVATE
|
||||||
"${CMVR_INCLUDE_DIR}"
|
"${CMVR_INCLUDE_DIR}"
|
||||||
"${CMVR_INCLUDE_DIR}/urdfdom_headers")
|
"${CMVR_INCLUDE_DIR}/urdfdom_headers")
|
||||||
else()
|
else()
|
||||||
target_include_directories(CmvrControlStation PRIVATE
|
target_include_directories(CmvrControlStation PRIVATE
|
||||||
"${CMVR_URDFDOM_INCLUDE_DIR}"
|
"${CMVR_URDFDOM_INCLUDE_DIR}"
|
||||||
"${CMVR_TINYXML_INCLUDE_DIR}"
|
"${CMVR_TINYXML_INCLUDE_DIR}"
|
||||||
"${CMVR_INCLUDE_DIR}/urdfdom_headers")
|
"${CMVR_INCLUDE_DIR}/urdfdom_headers")
|
||||||
endif()
|
endif()
|
||||||
if(CMVR_WITH_MSQUIC)
|
if(CMVR_WITH_MSQUIC)
|
||||||
target_include_directories(CmvrControlStation PRIVATE "${CMVR_MSQUIC_INCLUDE_DIR}")
|
target_include_directories(CmvrControlStation PRIVATE "${CMVR_MSQUIC_INCLUDE_DIR}")
|
||||||
if(UNIX AND CMVR_MSQUIC_LIBRARY_DIR)
|
if(UNIX AND CMVR_MSQUIC_LIBRARY_DIR)
|
||||||
set_property(TARGET CmvrControlStation APPEND PROPERTY
|
set_property(TARGET CmvrControlStation APPEND PROPERTY
|
||||||
BUILD_RPATH "${CMVR_MSQUIC_LIBRARY_DIR}")
|
BUILD_RPATH "${CMVR_MSQUIC_LIBRARY_DIR}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(CmvrControlStation PRIVATE
|
target_link_libraries(CmvrControlStation PRIVATE
|
||||||
Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Multimedia
|
Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Multimedia
|
||||||
Qt5::3DCore Qt5::3DRender Qt5::3DExtras Qt5::3DInput Qt5::3DAnimation)
|
Qt5::3DCore Qt5::3DRender Qt5::3DExtras Qt5::3DInput Qt5::3DAnimation)
|
||||||
|
|
||||||
# Generate every project-local CMVR message. This avoids source-tree generated
|
# Generate every project-local CMVR message. This avoids source-tree generated
|
||||||
# files and automatically picks up newly added configuration messages.
|
# files and automatically picks up newly added configuration messages.
|
||||||
file(GLOB_RECURSE PROTO_FILES CONFIGURE_DEPENDS
|
file(GLOB_RECURSE PROTO_FILES CONFIGURE_DEPENDS
|
||||||
"${PROTO_ROOT}/cmvr/api/*.proto"
|
"${PROTO_ROOT}/cmvr/api/*.proto"
|
||||||
"${PROTO_ROOT}/cmvr/common/*.proto"
|
"${PROTO_ROOT}/cmvr/common/*.proto"
|
||||||
"${PROTO_ROOT}/cmvr/config/*.proto"
|
"${PROTO_ROOT}/cmvr/config/*.proto"
|
||||||
"${PROTO_ROOT}/cmvr/msgs/agv.proto"
|
"${PROTO_ROOT}/cmvr/msgs/agv.proto"
|
||||||
"${PROTO_ROOT}/cmvr/quic_edge/v1/*.proto")
|
"${PROTO_ROOT}/cmvr/quic_edge/v1/*.proto")
|
||||||
|
|
||||||
set(SERVICE_NAMES
|
set(SERVICE_NAMES
|
||||||
cmvr/api/agv_service
|
cmvr/api/agv_service
|
||||||
cmvr/api/arm_service
|
cmvr/api/arm_service
|
||||||
cmvr/api/biohead_service
|
cmvr/api/biohead_service
|
||||||
cmvr/api/camera_service
|
cmvr/api/camera_service
|
||||||
cmvr/api/configuration_service
|
cmvr/api/configuration_service
|
||||||
cmvr/api/dexhand_service
|
cmvr/api/dexhand_service
|
||||||
cmvr/api/hlc_service
|
cmvr/api/hlc_service
|
||||||
cmvr/api/microphone_service
|
cmvr/api/microphone_service
|
||||||
cmvr/api/speaker_service
|
cmvr/api/speaker_service
|
||||||
cmvr/api/system_service
|
cmvr/api/system_service
|
||||||
cmvr/api/test_service)
|
cmvr/api/test_service)
|
||||||
|
|
||||||
set(GENERATED_FILES)
|
set(GENERATED_FILES)
|
||||||
foreach(PROTO_FILE IN LISTS PROTO_FILES)
|
foreach(PROTO_FILE IN LISTS PROTO_FILES)
|
||||||
file(RELATIVE_PATH PROTO_RELATIVE "${PROTO_ROOT}" "${PROTO_FILE}")
|
file(RELATIVE_PATH PROTO_RELATIVE "${PROTO_ROOT}" "${PROTO_FILE}")
|
||||||
string(REGEX REPLACE "\\.proto$" "" PROTO_NAME "${PROTO_RELATIVE}")
|
string(REGEX REPLACE "\\.proto$" "" PROTO_NAME "${PROTO_RELATIVE}")
|
||||||
set(PB_CC "${GENERATED_ROOT}/${PROTO_NAME}.pb.cc")
|
set(PB_CC "${GENERATED_ROOT}/${PROTO_NAME}.pb.cc")
|
||||||
set(PB_H "${GENERATED_ROOT}/${PROTO_NAME}.pb.h")
|
set(PB_H "${GENERATED_ROOT}/${PROTO_NAME}.pb.h")
|
||||||
get_filename_component(PROTO_OUTPUT_DIR "${PB_CC}" DIRECTORY)
|
get_filename_component(PROTO_OUTPUT_DIR "${PB_CC}" DIRECTORY)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${PB_CC}" "${PB_H}"
|
OUTPUT "${PB_CC}" "${PB_H}"
|
||||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${PROTO_OUTPUT_DIR}"
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${PROTO_OUTPUT_DIR}"
|
||||||
COMMAND "${PROTOC}"
|
COMMAND "${PROTOC}"
|
||||||
"--proto_path=${PROTO_ROOT}"
|
"--proto_path=${PROTO_ROOT}"
|
||||||
"--cpp_out=${GENERATED_ROOT}"
|
"--cpp_out=${GENERATED_ROOT}"
|
||||||
"${PROTO_FILE}"
|
"${PROTO_FILE}"
|
||||||
DEPENDS "${PROTO_FILE}" ${PROTO_FILES}
|
DEPENDS "${PROTO_FILE}" ${PROTO_FILES}
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
list(APPEND GENERATED_FILES "${PB_CC}" "${PB_H}")
|
list(APPEND GENERATED_FILES "${PB_CC}" "${PB_H}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
foreach(SERVICE_NAME IN LISTS SERVICE_NAMES)
|
foreach(SERVICE_NAME IN LISTS SERVICE_NAMES)
|
||||||
set(PROTO_FILE "${PROTO_ROOT}/${SERVICE_NAME}.proto")
|
set(PROTO_FILE "${PROTO_ROOT}/${SERVICE_NAME}.proto")
|
||||||
set(GRPC_CC "${GENERATED_ROOT}/${SERVICE_NAME}.grpc.pb.cc")
|
set(GRPC_CC "${GENERATED_ROOT}/${SERVICE_NAME}.grpc.pb.cc")
|
||||||
set(GRPC_H "${GENERATED_ROOT}/${SERVICE_NAME}.grpc.pb.h")
|
set(GRPC_H "${GENERATED_ROOT}/${SERVICE_NAME}.grpc.pb.h")
|
||||||
get_filename_component(PROTO_OUTPUT_DIR "${GRPC_CC}" DIRECTORY)
|
get_filename_component(PROTO_OUTPUT_DIR "${GRPC_CC}" DIRECTORY)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${GRPC_CC}" "${GRPC_H}"
|
OUTPUT "${GRPC_CC}" "${GRPC_H}"
|
||||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${PROTO_OUTPUT_DIR}"
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${PROTO_OUTPUT_DIR}"
|
||||||
COMMAND "${PROTOC}"
|
COMMAND "${PROTOC}"
|
||||||
"--proto_path=${PROTO_ROOT}"
|
"--proto_path=${PROTO_ROOT}"
|
||||||
"--grpc_out=${GENERATED_ROOT}"
|
"--grpc_out=${GENERATED_ROOT}"
|
||||||
"--plugin=protoc-gen-grpc=${GRPC_CPP_PLUGIN}"
|
"--plugin=protoc-gen-grpc=${GRPC_CPP_PLUGIN}"
|
||||||
"${PROTO_FILE}"
|
"${PROTO_FILE}"
|
||||||
DEPENDS "${PROTO_FILE}" ${PROTO_FILES}
|
DEPENDS "${PROTO_FILE}" ${PROTO_FILES}
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
list(APPEND GENERATED_FILES "${GRPC_CC}" "${GRPC_H}")
|
list(APPEND GENERATED_FILES "${GRPC_CC}" "${GRPC_H}")
|
||||||
endforeach()
|
endforeach()
|
||||||
target_sources(CmvrControlStation PRIVATE ${GENERATED_FILES})
|
target_sources(CmvrControlStation PRIVATE ${GENERATED_FILES})
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
file(GLOB ABSL_STATIC_LIBS "${CMVR_LIB_DIR}/libabsl_*.a")
|
file(GLOB ABSL_STATIC_LIBS "${CMVR_LIB_DIR}/libabsl_*.a")
|
||||||
target_link_libraries(CmvrControlStation PRIVATE
|
target_link_libraries(CmvrControlStation PRIVATE
|
||||||
"-Wl,--start-group"
|
"-Wl,--start-group"
|
||||||
"${CMVR_LIB_DIR}/libgrpc++.a"
|
"${CMVR_LIB_DIR}/libgrpc++.a"
|
||||||
"${CMVR_LIB_DIR}/libgrpc.a"
|
"${CMVR_LIB_DIR}/libgrpc.a"
|
||||||
"${CMVR_LIB_DIR}/libgpr.a"
|
"${CMVR_LIB_DIR}/libgpr.a"
|
||||||
"${CMVR_LIB_DIR}/libaddress_sorting.a"
|
"${CMVR_LIB_DIR}/libaddress_sorting.a"
|
||||||
"${CMVR_LIB_DIR}/libre2.a"
|
"${CMVR_LIB_DIR}/libre2.a"
|
||||||
"${CMVR_LIB_DIR}/libupb.a"
|
"${CMVR_LIB_DIR}/libupb.a"
|
||||||
"${CMVR_LIB_DIR}/libcares.a"
|
"${CMVR_LIB_DIR}/libcares.a"
|
||||||
"${CMVR_LIB_DIR}/libssl.a"
|
"${CMVR_LIB_DIR}/libssl.a"
|
||||||
"${CMVR_LIB_DIR}/libcrypto.a"
|
"${CMVR_LIB_DIR}/libcrypto.a"
|
||||||
"${CMVR_LIB_DIR}/libzlibstatic.a"
|
"${CMVR_LIB_DIR}/libzlibstatic.a"
|
||||||
"${CMVR_LIB_DIR}/libprotobuf.a"
|
"${CMVR_LIB_DIR}/libprotobuf.a"
|
||||||
${ABSL_STATIC_LIBS}
|
${ABSL_STATIC_LIBS}
|
||||||
"-Wl,--end-group"
|
"-Wl,--end-group"
|
||||||
"${CMVR_LIB_DIR}/libavcodec.dll.a"
|
"${CMVR_LIB_DIR}/libavcodec.dll.a"
|
||||||
"${CMVR_LIB_DIR}/libavutil.dll.a"
|
"${CMVR_LIB_DIR}/libavutil.dll.a"
|
||||||
"${CMVR_LIB_DIR}/libswscale.dll.a"
|
"${CMVR_LIB_DIR}/libswscale.dll.a"
|
||||||
"${CMVR_LIB_DIR}/liburdfdom_model.dll.a"
|
"${CMVR_LIB_DIR}/liburdfdom_model.dll.a"
|
||||||
ws2_32 crypt32 advapi32 bcrypt dbghelp iphlpapi secur32 ntdll)
|
ws2_32 crypt32 advapi32 bcrypt dbghelp iphlpapi secur32 ntdll)
|
||||||
else()
|
else()
|
||||||
if(CMVR_CXX_RUNTIME)
|
if(CMVR_CXX_RUNTIME)
|
||||||
target_link_libraries(CmvrControlStation PRIVATE "${CMVR_CXX_RUNTIME}")
|
target_link_libraries(CmvrControlStation PRIVATE "${CMVR_CXX_RUNTIME}")
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(CmvrControlStation PRIVATE
|
target_link_libraries(CmvrControlStation PRIVATE
|
||||||
protobuf::libprotobuf
|
protobuf::libprotobuf
|
||||||
gRPC::grpc++
|
gRPC::grpc++
|
||||||
PkgConfig::FFMPEG
|
PkgConfig::FFMPEG
|
||||||
Threads::Threads
|
Threads::Threads
|
||||||
"${CMVR_URDFDOM_MODEL_LIBRARY}")
|
"${CMVR_URDFDOM_MODEL_LIBRARY}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
file(GLOB CMVR_RUNTIME_DLLS "${CMVR_LIB_DIR}/*.dll")
|
file(GLOB CMVR_RUNTIME_DLLS "${CMVR_LIB_DIR}/*.dll")
|
||||||
foreach(RUNTIME_DLL IN LISTS CMVR_RUNTIME_DLLS)
|
foreach(RUNTIME_DLL IN LISTS CMVR_RUNTIME_DLLS)
|
||||||
add_custom_command(TARGET CmvrControlStation POST_BUILD
|
add_custom_command(TARGET CmvrControlStation POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
"${RUNTIME_DLL}" "$<TARGET_FILE_DIR:CmvrControlStation>")
|
"${RUNTIME_DLL}" "$<TARGET_FILE_DIR:CmvrControlStation>")
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
foreach(CERTIFICATE IN ITEMS quic-test-server.pfx quic-test-ca.crt)
|
foreach(CERTIFICATE IN ITEMS quic-test-server.pfx quic-test-ca.crt)
|
||||||
if(EXISTS "${CMVR_CERT_DIR}/${CERTIFICATE}")
|
if(EXISTS "${CMVR_CERT_DIR}/${CERTIFICATE}")
|
||||||
add_custom_command(TARGET CmvrControlStation POST_BUILD
|
add_custom_command(TARGET CmvrControlStation POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
"${CMVR_CERT_DIR}/${CERTIFICATE}"
|
"${CMVR_CERT_DIR}/${CERTIFICATE}"
|
||||||
"$<TARGET_FILE_DIR:CmvrControlStation>/${CERTIFICATE}")
|
"$<TARGET_FILE_DIR:CmvrControlStation>/${CERTIFICATE}")
|
||||||
install(FILES "${CMVR_CERT_DIR}/${CERTIFICATE}" DESTINATION bin)
|
install(FILES "${CMVR_CERT_DIR}/${CERTIFICATE}" DESTINATION bin)
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
add_custom_command(TARGET CmvrControlStation POST_BUILD
|
add_custom_command(TARGET CmvrControlStation POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E make_directory
|
COMMAND ${CMAKE_COMMAND} -E make_directory
|
||||||
"$<TARGET_FILE_DIR:CmvrControlStation>/sceneparsers"
|
"$<TARGET_FILE_DIR:CmvrControlStation>/sceneparsers"
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
"${CMVR_ASSIMP_SCENE_PARSER}"
|
"${CMVR_ASSIMP_SCENE_PARSER}"
|
||||||
"$<TARGET_FILE_DIR:CmvrControlStation>/sceneparsers/"
|
"$<TARGET_FILE_DIR:CmvrControlStation>/sceneparsers/"
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/models"
|
"${CMAKE_CURRENT_SOURCE_DIR}/models"
|
||||||
"$<TARGET_FILE_DIR:CmvrControlStation>/models")
|
"$<TARGET_FILE_DIR:CmvrControlStation>/models")
|
||||||
|
|
||||||
install(TARGETS CmvrControlStation RUNTIME DESTINATION bin)
|
install(TARGETS CmvrControlStation RUNTIME DESTINATION bin)
|
||||||
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/models/"
|
add_custom_command(TARGET CmvrControlStation POST_BUILD
|
||||||
DESTINATION bin/models)
|
COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_FILE_DIR:CmvrControlStation>/scripts"
|
||||||
install(PROGRAMS "${CMVR_ASSIMP_SCENE_PARSER}"
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
DESTINATION bin/sceneparsers)
|
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/handeye_worker.py"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/handeye_math.py"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/handeye_refinement.py"
|
||||||
|
"$<TARGET_FILE_DIR:CmvrControlStation>/scripts")
|
||||||
|
install(FILES scripts/handeye_worker.py scripts/handeye_math.py scripts/handeye_refinement.py DESTINATION bin/scripts)
|
||||||
|
if(WIN32)
|
||||||
|
set(CMVR_HAND_EYE_JPEG_PLUGIN "${CMVR_QT_PLUGIN_ROOT}/imageformats/qjpeg$<$<CONFIG:Debug>:d>.dll")
|
||||||
|
add_custom_command(TARGET CmvrControlStation POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_FILE_DIR:CmvrControlStation>/imageformats"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMVR_HAND_EYE_JPEG_PLUGIN}"
|
||||||
|
"$<TARGET_FILE_DIR:CmvrControlStation>/imageformats/")
|
||||||
|
install(FILES "${CMVR_HAND_EYE_JPEG_PLUGIN}" DESTINATION bin/imageformats)
|
||||||
|
set(CMVR_HAND_EYE_RUNTIME_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/handeye-runtime" CACHE PATH "Bundled Windows x64 hand-eye runtime")
|
||||||
|
if(NOT EXISTS "${CMVR_HAND_EYE_RUNTIME_DIR}/manifest.json")
|
||||||
|
message(FATAL_ERROR "Build the bundled runtime with scripts/package_handeye_runtime.py first")
|
||||||
|
endif()
|
||||||
|
add_custom_command(TARGET CmvrControlStation POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_FILE_DIR:CmvrControlStation>/runtime/handeye"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMVR_HAND_EYE_RUNTIME_DIR}"
|
||||||
|
"$<TARGET_FILE_DIR:CmvrControlStation>/runtime/handeye")
|
||||||
|
install(DIRECTORY "${CMVR_HAND_EYE_RUNTIME_DIR}/" DESTINATION bin/runtime/handeye)
|
||||||
|
endif()
|
||||||
|
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/models/"
|
||||||
|
DESTINATION bin/models)
|
||||||
|
install(PROGRAMS "${CMVR_ASSIMP_SCENE_PARSER}"
|
||||||
|
DESTINATION bin/sceneparsers)
|
||||||
|
|||||||
@ -1,303 +1,341 @@
|
|||||||
QT += core gui widgets multimedia 3dcore 3drender 3dextras 3dinput 3danimation
|
QT += core gui widgets multimedia 3dcore 3drender 3dextras 3dinput 3danimation
|
||||||
|
|
||||||
CONFIG += c++14 warn_on debug_and_release
|
CONFIG += c++14 warn_on debug_and_release
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
|
|
||||||
DEFINES += QT_DEPRECATED_WARNINGS _WIN32_WINNT=0x0600
|
DEFINES += QT_DEPRECATED_WARNINGS _WIN32_WINNT=0x0600
|
||||||
|
|
||||||
INCLUDE_DIR = $$clean_path($$PWD/include)
|
INCLUDE_DIR = $$clean_path($$PWD/include)
|
||||||
LIB_DIR = $$clean_path($$PWD/lib)
|
LIB_DIR = $$clean_path($$PWD/lib)
|
||||||
TOOLS_DIR = $$clean_path($$PWD/tools)
|
TOOLS_DIR = $$clean_path($$PWD/tools)
|
||||||
CERT_DIR = $$clean_path($$PWD/certs)
|
CERT_DIR = $$clean_path($$PWD/certs)
|
||||||
PROTO_ROOT = $$clean_path($$PWD/protos)
|
PROTO_ROOT = $$clean_path($$PWD/protos)
|
||||||
PROTO_GEN_DIR = $$clean_path($$PWD/generated_cpp)
|
PROTO_GEN_DIR = $$clean_path($$PWD/generated_cpp)
|
||||||
PROTOC = $$TOOLS_DIR/run_protoc.cmd
|
PROTOC = $$TOOLS_DIR/run_protoc.cmd
|
||||||
GRPC_CPP_PLUGIN = $$TOOLS_DIR/grpc_cpp_plugin.exe
|
GRPC_CPP_PLUGIN = $$TOOLS_DIR/grpc_cpp_plugin.exe
|
||||||
MSQUIC_DLL = $$LIB_DIR/msquic.dll
|
MSQUIC_DLL = $$LIB_DIR/msquic.dll
|
||||||
MSQUIC_TEST_CERT = $$CERT_DIR/quic-test-server.pfx
|
MSQUIC_TEST_CERT = $$CERT_DIR/quic-test-server.pfx
|
||||||
MSQUIC_TEST_CA = $$CERT_DIR/quic-test-ca.crt
|
MSQUIC_TEST_CA = $$CERT_DIR/quic-test-ca.crt
|
||||||
RUNTIME_DLLS = $$files($$LIB_DIR/*.dll)
|
RUNTIME_DLLS = $$files($$LIB_DIR/*.dll)
|
||||||
MODEL_DIR = $$clean_path($$PWD/models)
|
MODEL_DIR = $$clean_path($$PWD/models)
|
||||||
QT_SCENEPARSER_DIR = $$clean_path($$[QT_INSTALL_PLUGINS]/sceneparsers)
|
QT_SCENEPARSER_DIR = $$clean_path($$[QT_INSTALL_PLUGINS]/sceneparsers)
|
||||||
|
|
||||||
!exists($$PROTOC): error("protoc launcher not found. Run scripts/build_native_deps.ps1 first.")
|
!exists($$PROTOC): error("protoc launcher not found. Run scripts/build_native_deps.ps1 first.")
|
||||||
!exists($$GRPC_CPP_PLUGIN): error("grpc_cpp_plugin.exe not found. Run scripts/build_native_deps.ps1 first.")
|
!exists($$GRPC_CPP_PLUGIN): error("grpc_cpp_plugin.exe not found. Run scripts/build_native_deps.ps1 first.")
|
||||||
!exists($$MSQUIC_DLL): error("msquic.dll not found. Run scripts/install_msquic.ps1 first.")
|
!exists($$MSQUIC_DLL): error("msquic.dll not found. Run scripts/install_msquic.ps1 first.")
|
||||||
!exists($$MSQUIC_TEST_CERT): error("QUIC test certificate not found. Run scripts/install_msquic.ps1 first.")
|
!exists($$MSQUIC_TEST_CERT): error("QUIC test certificate not found. Run scripts/install_msquic.ps1 first.")
|
||||||
!exists($$MSQUIC_TEST_CA): error("QUIC test CA not found. Run scripts/install_msquic.ps1 first.")
|
!exists($$MSQUIC_TEST_CA): error("QUIC test CA not found. Run scripts/install_msquic.ps1 first.")
|
||||||
!exists($$INCLUDE_DIR/libavcodec/avcodec.h): error("FFmpeg headers not found in include.")
|
!exists($$INCLUDE_DIR/libavcodec/avcodec.h): error("FFmpeg headers not found in include.")
|
||||||
!exists($$LIB_DIR/avcodec-58.dll): error("FFmpeg runtime DLLs not found in lib.")
|
!exists($$LIB_DIR/avcodec-58.dll): error("FFmpeg runtime DLLs not found in lib.")
|
||||||
!exists($$INCLUDE_DIR/urdf_parser/urdf_parser.h): error("urdfdom headers not found in include.")
|
!exists($$INCLUDE_DIR/urdf_parser/urdf_parser.h): error("urdfdom headers not found in include.")
|
||||||
!exists($$LIB_DIR/liburdfdom_model.dll.a): error("urdfdom link library not found in lib.")
|
!exists($$LIB_DIR/liburdfdom_model.dll.a): error("urdfdom link library not found in lib.")
|
||||||
!exists($$LIB_DIR/liburdfdom_model.dll): error("urdfdom runtime DLL not found in lib.")
|
!exists($$LIB_DIR/liburdfdom_model.dll): error("urdfdom runtime DLL not found in lib.")
|
||||||
|
|
||||||
PROTO_FILES = \
|
PROTO_FILES = \
|
||||||
$$PROTO_ROOT/cmvr/api/common.proto \
|
$$PROTO_ROOT/cmvr/api/common.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/agv_command.proto \
|
$$PROTO_ROOT/cmvr/api/agv_command.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/agv_service.proto \
|
$$PROTO_ROOT/cmvr/api/agv_service.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/arm_command.proto \
|
$$PROTO_ROOT/cmvr/api/arm_command.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/arm_service.proto \
|
$$PROTO_ROOT/cmvr/api/arm_service.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/biohead_command.proto \
|
$$PROTO_ROOT/cmvr/api/biohead_command.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/biohead_service.proto \
|
$$PROTO_ROOT/cmvr/api/biohead_service.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/camera_command.proto \
|
$$PROTO_ROOT/cmvr/api/camera_command.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/camera_service.proto \
|
$$PROTO_ROOT/cmvr/api/camera_service.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/configuration_command.proto \
|
$$PROTO_ROOT/cmvr/api/configuration_command.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/configuration_service.proto \
|
$$PROTO_ROOT/cmvr/api/configuration_service.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/dexhand_command.proto \
|
$$PROTO_ROOT/cmvr/api/dexhand_command.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/dexhand_service.proto \
|
$$PROTO_ROOT/cmvr/api/dexhand_service.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/hlc_command.proto \
|
$$PROTO_ROOT/cmvr/api/hlc_command.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/hlc_service.proto \
|
$$PROTO_ROOT/cmvr/api/hlc_service.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/microphone_command.proto \
|
$$PROTO_ROOT/cmvr/api/microphone_command.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/microphone_service.proto \
|
$$PROTO_ROOT/cmvr/api/microphone_service.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/speaker_command.proto \
|
$$PROTO_ROOT/cmvr/api/speaker_command.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/speaker_service.proto \
|
$$PROTO_ROOT/cmvr/api/speaker_service.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/system_command.proto \
|
$$PROTO_ROOT/cmvr/api/system_command.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/system_service.proto \
|
$$PROTO_ROOT/cmvr/api/system_service.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/test_service.proto
|
$$PROTO_ROOT/cmvr/api/test_service.proto
|
||||||
|
|
||||||
GRPC_PROTO_FILES = \
|
GRPC_PROTO_FILES = \
|
||||||
$$PROTO_ROOT/cmvr/api/agv_service.proto \
|
$$PROTO_ROOT/cmvr/api/agv_service.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/arm_service.proto \
|
$$PROTO_ROOT/cmvr/api/arm_service.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/biohead_service.proto \
|
$$PROTO_ROOT/cmvr/api/biohead_service.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/camera_service.proto \
|
$$PROTO_ROOT/cmvr/api/camera_service.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/configuration_service.proto \
|
$$PROTO_ROOT/cmvr/api/configuration_service.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/dexhand_service.proto \
|
$$PROTO_ROOT/cmvr/api/dexhand_service.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/hlc_service.proto \
|
$$PROTO_ROOT/cmvr/api/hlc_service.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/microphone_service.proto \
|
$$PROTO_ROOT/cmvr/api/microphone_service.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/speaker_service.proto \
|
$$PROTO_ROOT/cmvr/api/speaker_service.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/system_service.proto \
|
$$PROTO_ROOT/cmvr/api/system_service.proto \
|
||||||
$$PROTO_ROOT/cmvr/api/test_service.proto
|
$$PROTO_ROOT/cmvr/api/test_service.proto
|
||||||
|
|
||||||
MSG_PROTO_FILES = \
|
MSG_PROTO_FILES = \
|
||||||
$$PROTO_ROOT/cmvr/msgs/agv.proto
|
$$PROTO_ROOT/cmvr/msgs/agv.proto
|
||||||
|
|
||||||
CONFIG_PROTO_FILES = \
|
CONFIG_PROTO_FILES = \
|
||||||
$$PROTO_ROOT/cmvr/config/agv_config/agv_config.proto \
|
$$PROTO_ROOT/cmvr/config/agv_config/agv_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/arm_config/arm_config.proto \
|
$$PROTO_ROOT/cmvr/config/arm_config/arm_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/aubo_robot_config/aubo_robot_config.proto \
|
$$PROTO_ROOT/cmvr/config/aubo_robot_config/aubo_robot_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/biohead_config/biohead_config.proto \
|
$$PROTO_ROOT/cmvr/config/biohead_config/biohead_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/camera_config/camera_config.proto \
|
$$PROTO_ROOT/cmvr/config/camera_config/camera_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/cmvr_es_config/cmvr_es_config.proto \
|
$$PROTO_ROOT/cmvr/config/cmvr_es_config/cmvr_es_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/device_manager_config/device_manager_config.proto \
|
$$PROTO_ROOT/cmvr/config/device_manager_config/device_manager_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/dexhand_config/dexhand_config.proto \
|
$$PROTO_ROOT/cmvr/config/dexhand_config/dexhand_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/grpc_server_config/grpc_server_config.proto \
|
$$PROTO_ROOT/cmvr/config/grpc_server_config/grpc_server_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/logger_config/logger_config.proto \
|
$$PROTO_ROOT/cmvr/config/logger_config/logger_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/microphone_config/microphone_config.proto \
|
$$PROTO_ROOT/cmvr/config/microphone_config/microphone_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/motor_config/motor_config.proto \
|
$$PROTO_ROOT/cmvr/config/motor_config/motor_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/quic_edge_config/quic_edge_config.proto \
|
$$PROTO_ROOT/cmvr/config/quic_edge_config/quic_edge_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/self_collision_task_config/self_collision_task_config.proto \
|
$$PROTO_ROOT/cmvr/config/self_collision_task_config/self_collision_task_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/speaker_config/speaker_config.proto \
|
$$PROTO_ROOT/cmvr/config/speaker_config/speaker_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/task_manager_config/task_manager_config.proto \
|
$$PROTO_ROOT/cmvr/config/task_manager_config/task_manager_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/touch_screen_task_config/touch_screen_task_config.proto
|
$$PROTO_ROOT/cmvr/config/touch_screen_task_config/touch_screen_task_config.proto
|
||||||
|
|
||||||
CONFIG_ROOT_PROTO_FILES = \
|
CONFIG_ROOT_PROTO_FILES = \
|
||||||
$$PROTO_ROOT/cmvr/config/cartesian_motion_validation_config.proto \
|
$$PROTO_ROOT/cmvr/config/cartesian_motion_validation_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/joint_limits_config.proto \
|
$$PROTO_ROOT/cmvr/config/joint_limits_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/lawba_ik_config.proto \
|
$$PROTO_ROOT/cmvr/config/lawba_ik_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/pinocchio_dls_ik_config.proto \
|
$$PROTO_ROOT/cmvr/config/pinocchio_dls_ik_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/pinocchio_qp_ik_config.proto \
|
$$PROTO_ROOT/cmvr/config/pinocchio_qp_ik_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/srs_ik_config.proto \
|
$$PROTO_ROOT/cmvr/config/srs_ik_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/touch_screen_algorithm_config.proto \
|
$$PROTO_ROOT/cmvr/config/touch_screen_algorithm_config.proto \
|
||||||
$$PROTO_ROOT/cmvr/config/touch_screen_common_config.proto
|
$$PROTO_ROOT/cmvr/config/touch_screen_common_config.proto
|
||||||
|
|
||||||
COMMON_PROTO_FILES = \
|
COMMON_PROTO_FILES = \
|
||||||
$$PROTO_ROOT/cmvr/common/geometry.proto
|
$$PROTO_ROOT/cmvr/common/geometry.proto
|
||||||
|
|
||||||
MUJOCO_PROTO_FILES = \
|
MUJOCO_PROTO_FILES = \
|
||||||
$$PROTO_ROOT/cmvr/config/mujoco_config/mujoco_world_config.proto
|
$$PROTO_ROOT/cmvr/config/mujoco_config/mujoco_world_config.proto
|
||||||
|
|
||||||
QUIC_PROTO_FILES = \
|
QUIC_PROTO_FILES = \
|
||||||
$$PROTO_ROOT/cmvr/quic_edge/v1/quic_edge.proto
|
$$PROTO_ROOT/cmvr/quic_edge/v1/quic_edge.proto
|
||||||
|
|
||||||
# Show the complete local proto tree in Qt Creator without compiling unused APIs.
|
# Show the complete local proto tree in Qt Creator without compiling unused APIs.
|
||||||
OTHER_FILES += $$files($$PROTO_ROOT/*.proto, true) $$files($$MODEL_DIR/*.urdf, true)
|
OTHER_FILES += $$files($$PROTO_ROOT/*.proto, true) $$files($$MODEL_DIR/*.urdf, true)
|
||||||
|
|
||||||
INCLUDEPATH += \
|
INCLUDEPATH += \
|
||||||
$$PROTO_GEN_DIR \
|
$$PROTO_GEN_DIR \
|
||||||
$$INCLUDE_DIR \
|
$$INCLUDE_DIR \
|
||||||
$$INCLUDE_DIR/urdfdom_headers
|
$$INCLUDE_DIR/urdfdom_headers
|
||||||
|
|
||||||
protobuf_compiler.name = Protobuf ${QMAKE_FILE_IN}
|
protobuf_compiler.name = Protobuf ${QMAKE_FILE_IN}
|
||||||
protobuf_compiler.input = PROTO_FILES
|
protobuf_compiler.input = PROTO_FILES
|
||||||
protobuf_compiler.output = $$PROTO_GEN_DIR/cmvr/api/${QMAKE_FILE_BASE}.pb.cc
|
protobuf_compiler.output = $$PROTO_GEN_DIR/cmvr/api/${QMAKE_FILE_BASE}.pb.cc
|
||||||
protobuf_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --cpp_out=$$quote($$PROTO_GEN_DIR) $$quote($$PROTO_ROOT/cmvr/api/${QMAKE_FILE_BASE}.proto)
|
protobuf_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --cpp_out=$$quote($$PROTO_GEN_DIR) $$quote($$PROTO_ROOT/cmvr/api/${QMAKE_FILE_BASE}.proto)
|
||||||
protobuf_compiler.depends = $$PROTO_FILES $$MSG_PROTO_FILES
|
protobuf_compiler.depends = $$PROTO_FILES $$MSG_PROTO_FILES
|
||||||
protobuf_compiler.variable_out = SOURCES
|
protobuf_compiler.variable_out = SOURCES
|
||||||
protobuf_compiler.CONFIG += target_predeps
|
protobuf_compiler.CONFIG += target_predeps
|
||||||
|
|
||||||
msg_protobuf_compiler.name = Protobuf ${QMAKE_FILE_IN}
|
msg_protobuf_compiler.name = Protobuf ${QMAKE_FILE_IN}
|
||||||
msg_protobuf_compiler.input = MSG_PROTO_FILES
|
msg_protobuf_compiler.input = MSG_PROTO_FILES
|
||||||
msg_protobuf_compiler.output = $$PROTO_GEN_DIR/cmvr/msgs/${QMAKE_FILE_BASE}.pb.cc
|
msg_protobuf_compiler.output = $$PROTO_GEN_DIR/cmvr/msgs/${QMAKE_FILE_BASE}.pb.cc
|
||||||
msg_protobuf_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --cpp_out=$$quote($$PROTO_GEN_DIR) $$quote($$PROTO_ROOT/cmvr/msgs/${QMAKE_FILE_BASE}.proto)
|
msg_protobuf_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --cpp_out=$$quote($$PROTO_GEN_DIR) $$quote($$PROTO_ROOT/cmvr/msgs/${QMAKE_FILE_BASE}.proto)
|
||||||
msg_protobuf_compiler.depends = $$MSG_PROTO_FILES
|
msg_protobuf_compiler.depends = $$MSG_PROTO_FILES
|
||||||
msg_protobuf_compiler.variable_out = SOURCES
|
msg_protobuf_compiler.variable_out = SOURCES
|
||||||
msg_protobuf_compiler.CONFIG += target_predeps
|
msg_protobuf_compiler.CONFIG += target_predeps
|
||||||
|
|
||||||
config_protobuf_compiler.name = Protobuf ${QMAKE_FILE_IN}
|
config_protobuf_compiler.name = Protobuf ${QMAKE_FILE_IN}
|
||||||
config_protobuf_compiler.input = CONFIG_PROTO_FILES
|
config_protobuf_compiler.input = CONFIG_PROTO_FILES
|
||||||
config_protobuf_compiler.output = $$PROTO_GEN_DIR/cmvr/config/${QMAKE_FILE_BASE}/${QMAKE_FILE_BASE}.pb.cc
|
config_protobuf_compiler.output = $$PROTO_GEN_DIR/cmvr/config/${QMAKE_FILE_BASE}/${QMAKE_FILE_BASE}.pb.cc
|
||||||
config_protobuf_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --cpp_out=$$quote($$PROTO_GEN_DIR) $$quote($$PWD/${QMAKE_FILE_IN})
|
config_protobuf_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --cpp_out=$$quote($$PROTO_GEN_DIR) $$quote($$PROTO_ROOT/cmvr/config/${QMAKE_FILE_BASE}/${QMAKE_FILE_BASE}.proto)
|
||||||
config_protobuf_compiler.depends = $$CONFIG_PROTO_FILES
|
config_protobuf_compiler.depends = $$CONFIG_PROTO_FILES
|
||||||
config_protobuf_compiler.variable_out = SOURCES
|
config_protobuf_compiler.variable_out = SOURCES
|
||||||
config_protobuf_compiler.CONFIG += target_predeps
|
config_protobuf_compiler.CONFIG += target_predeps
|
||||||
|
|
||||||
config_root_protobuf_compiler.name = Protobuf ${QMAKE_FILE_IN}
|
config_root_protobuf_compiler.name = Protobuf ${QMAKE_FILE_IN}
|
||||||
config_root_protobuf_compiler.input = CONFIG_ROOT_PROTO_FILES
|
config_root_protobuf_compiler.input = CONFIG_ROOT_PROTO_FILES
|
||||||
config_root_protobuf_compiler.output = $$PROTO_GEN_DIR/cmvr/config/${QMAKE_FILE_BASE}.pb.cc
|
config_root_protobuf_compiler.output = $$PROTO_GEN_DIR/cmvr/config/${QMAKE_FILE_BASE}.pb.cc
|
||||||
config_root_protobuf_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --cpp_out=$$quote($$PROTO_GEN_DIR) $$quote($$PWD/${QMAKE_FILE_IN})
|
config_root_protobuf_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --cpp_out=$$quote($$PROTO_GEN_DIR) $$quote($$PROTO_ROOT/cmvr/config/${QMAKE_FILE_BASE}.proto)
|
||||||
config_root_protobuf_compiler.depends = $$CONFIG_ROOT_PROTO_FILES $$COMMON_PROTO_FILES
|
config_root_protobuf_compiler.depends = $$CONFIG_ROOT_PROTO_FILES $$COMMON_PROTO_FILES
|
||||||
config_root_protobuf_compiler.variable_out = SOURCES
|
config_root_protobuf_compiler.variable_out = SOURCES
|
||||||
config_root_protobuf_compiler.CONFIG += target_predeps
|
config_root_protobuf_compiler.CONFIG += target_predeps
|
||||||
|
|
||||||
common_protobuf_compiler.name = Protobuf ${QMAKE_FILE_IN}
|
common_protobuf_compiler.name = Protobuf ${QMAKE_FILE_IN}
|
||||||
common_protobuf_compiler.input = COMMON_PROTO_FILES
|
common_protobuf_compiler.input = COMMON_PROTO_FILES
|
||||||
common_protobuf_compiler.output = $$PROTO_GEN_DIR/cmvr/common/${QMAKE_FILE_BASE}.pb.cc
|
common_protobuf_compiler.output = $$PROTO_GEN_DIR/cmvr/common/${QMAKE_FILE_BASE}.pb.cc
|
||||||
common_protobuf_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --cpp_out=$$quote($$PROTO_GEN_DIR) $$quote($$PWD/${QMAKE_FILE_IN})
|
common_protobuf_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --cpp_out=$$quote($$PROTO_GEN_DIR) $$quote($$PROTO_ROOT/cmvr/common/${QMAKE_FILE_BASE}.proto)
|
||||||
common_protobuf_compiler.depends = $$COMMON_PROTO_FILES
|
common_protobuf_compiler.depends = $$COMMON_PROTO_FILES
|
||||||
common_protobuf_compiler.variable_out = SOURCES
|
common_protobuf_compiler.variable_out = SOURCES
|
||||||
common_protobuf_compiler.CONFIG += target_predeps
|
common_protobuf_compiler.CONFIG += target_predeps
|
||||||
|
|
||||||
mujoco_protobuf_compiler.name = Protobuf ${QMAKE_FILE_IN}
|
mujoco_protobuf_compiler.name = Protobuf ${QMAKE_FILE_IN}
|
||||||
mujoco_protobuf_compiler.input = MUJOCO_PROTO_FILES
|
mujoco_protobuf_compiler.input = MUJOCO_PROTO_FILES
|
||||||
mujoco_protobuf_compiler.output = $$PROTO_GEN_DIR/cmvr/config/mujoco_config/${QMAKE_FILE_BASE}.pb.cc
|
mujoco_protobuf_compiler.output = $$PROTO_GEN_DIR/cmvr/config/mujoco_config/${QMAKE_FILE_BASE}.pb.cc
|
||||||
mujoco_protobuf_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --cpp_out=$$quote($$PROTO_GEN_DIR) $$quote($$PWD/${QMAKE_FILE_IN})
|
mujoco_protobuf_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --cpp_out=$$quote($$PROTO_GEN_DIR) $$quote($$PROTO_ROOT/cmvr/config/mujoco_config/${QMAKE_FILE_BASE}.proto)
|
||||||
mujoco_protobuf_compiler.depends = $$MUJOCO_PROTO_FILES
|
mujoco_protobuf_compiler.depends = $$MUJOCO_PROTO_FILES
|
||||||
mujoco_protobuf_compiler.variable_out = SOURCES
|
mujoco_protobuf_compiler.variable_out = SOURCES
|
||||||
mujoco_protobuf_compiler.CONFIG += target_predeps
|
mujoco_protobuf_compiler.CONFIG += target_predeps
|
||||||
|
|
||||||
grpc_compiler.name = gRPC ${QMAKE_FILE_IN}
|
grpc_compiler.name = gRPC ${QMAKE_FILE_IN}
|
||||||
grpc_compiler.input = GRPC_PROTO_FILES
|
grpc_compiler.input = GRPC_PROTO_FILES
|
||||||
grpc_compiler.output = $$PROTO_GEN_DIR/cmvr/api/${QMAKE_FILE_BASE}.grpc.pb.cc
|
grpc_compiler.output = $$PROTO_GEN_DIR/cmvr/api/${QMAKE_FILE_BASE}.grpc.pb.cc
|
||||||
grpc_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --grpc_out=$$quote($$PROTO_GEN_DIR) --plugin=protoc-gen-grpc=$$quote($$GRPC_CPP_PLUGIN) $$quote($$PROTO_ROOT/cmvr/api/${QMAKE_FILE_BASE}.proto)
|
grpc_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --grpc_out=$$quote($$PROTO_GEN_DIR) --plugin=protoc-gen-grpc=$$quote($$GRPC_CPP_PLUGIN) $$quote($$PROTO_ROOT/cmvr/api/${QMAKE_FILE_BASE}.proto)
|
||||||
grpc_compiler.depends = $$PROTO_FILES $$MSG_PROTO_FILES
|
grpc_compiler.depends = $$PROTO_FILES $$MSG_PROTO_FILES
|
||||||
grpc_compiler.variable_out = SOURCES
|
grpc_compiler.variable_out = SOURCES
|
||||||
grpc_compiler.CONFIG += target_predeps
|
grpc_compiler.CONFIG += target_predeps
|
||||||
|
|
||||||
quic_protobuf_compiler.name = Protobuf ${QMAKE_FILE_IN}
|
quic_protobuf_compiler.name = Protobuf ${QMAKE_FILE_IN}
|
||||||
quic_protobuf_compiler.input = QUIC_PROTO_FILES
|
quic_protobuf_compiler.input = QUIC_PROTO_FILES
|
||||||
quic_protobuf_compiler.output = $$PROTO_GEN_DIR/cmvr/quic_edge/v1/${QMAKE_FILE_BASE}.pb.cc
|
quic_protobuf_compiler.output = $$PROTO_GEN_DIR/cmvr/quic_edge/v1/${QMAKE_FILE_BASE}.pb.cc
|
||||||
quic_protobuf_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --cpp_out=$$quote($$PROTO_GEN_DIR) $$quote($$PROTO_ROOT/cmvr/quic_edge/v1/${QMAKE_FILE_BASE}.proto)
|
quic_protobuf_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --cpp_out=$$quote($$PROTO_GEN_DIR) $$quote($$PROTO_ROOT/cmvr/quic_edge/v1/${QMAKE_FILE_BASE}.proto)
|
||||||
quic_protobuf_compiler.depends = $$QUIC_PROTO_FILES
|
quic_protobuf_compiler.depends = $$QUIC_PROTO_FILES
|
||||||
quic_protobuf_compiler.variable_out = SOURCES
|
quic_protobuf_compiler.variable_out = SOURCES
|
||||||
quic_protobuf_compiler.CONFIG += target_predeps
|
quic_protobuf_compiler.CONFIG += target_predeps
|
||||||
|
|
||||||
QMAKE_EXTRA_COMPILERS += protobuf_compiler msg_protobuf_compiler config_protobuf_compiler config_root_protobuf_compiler common_protobuf_compiler mujoco_protobuf_compiler grpc_compiler quic_protobuf_compiler
|
QMAKE_EXTRA_COMPILERS += protobuf_compiler msg_protobuf_compiler config_protobuf_compiler config_root_protobuf_compiler common_protobuf_compiler mujoco_protobuf_compiler grpc_compiler quic_protobuf_compiler
|
||||||
|
|
||||||
ABSL_STATIC_LIBS = $$files($$LIB_DIR/libabsl_*.a)
|
ABSL_STATIC_LIBS = $$files($$LIB_DIR/libabsl_*.a)
|
||||||
LIBS += \
|
LIBS += \
|
||||||
-Wl,--start-group \
|
-Wl,--start-group \
|
||||||
$$LIB_DIR/libgrpc++.a \
|
$$LIB_DIR/libgrpc++.a \
|
||||||
$$LIB_DIR/libgrpc.a \
|
$$LIB_DIR/libgrpc.a \
|
||||||
$$LIB_DIR/libgpr.a \
|
$$LIB_DIR/libgpr.a \
|
||||||
$$LIB_DIR/libaddress_sorting.a \
|
$$LIB_DIR/libaddress_sorting.a \
|
||||||
$$LIB_DIR/libre2.a \
|
$$LIB_DIR/libre2.a \
|
||||||
$$LIB_DIR/libupb.a \
|
$$LIB_DIR/libupb.a \
|
||||||
$$LIB_DIR/libcares.a \
|
$$LIB_DIR/libcares.a \
|
||||||
$$LIB_DIR/libssl.a \
|
$$LIB_DIR/libssl.a \
|
||||||
$$LIB_DIR/libcrypto.a \
|
$$LIB_DIR/libcrypto.a \
|
||||||
$$LIB_DIR/libzlibstatic.a \
|
$$LIB_DIR/libzlibstatic.a \
|
||||||
$$LIB_DIR/libprotobuf.a \
|
$$LIB_DIR/libprotobuf.a \
|
||||||
$$ABSL_STATIC_LIBS \
|
$$ABSL_STATIC_LIBS \
|
||||||
-Wl,--end-group \
|
-Wl,--end-group \
|
||||||
$$LIB_DIR/libavcodec.dll.a \
|
$$LIB_DIR/libavcodec.dll.a \
|
||||||
$$LIB_DIR/libavutil.dll.a \
|
$$LIB_DIR/libavutil.dll.a \
|
||||||
$$LIB_DIR/libswscale.dll.a \
|
$$LIB_DIR/libswscale.dll.a \
|
||||||
$$LIB_DIR/liburdfdom_model.dll.a \
|
$$LIB_DIR/liburdfdom_model.dll.a \
|
||||||
-lws2_32 \
|
-lws2_32 \
|
||||||
-lcrypt32 \
|
-lcrypt32 \
|
||||||
-ladvapi32 \
|
-ladvapi32 \
|
||||||
-lbcrypt \
|
-lbcrypt \
|
||||||
-ldbghelp \
|
-ldbghelp \
|
||||||
-liphlpapi \
|
-liphlpapi \
|
||||||
-lsecur32 \
|
-lsecur32 \
|
||||||
-lntdll
|
-lntdll
|
||||||
|
|
||||||
DEFINES += CMVR_WITH_GRPC=1 CMVR_WITH_MSQUIC=1
|
DEFINES += CMVR_WITH_GRPC=1 CMVR_WITH_MSQUIC=1
|
||||||
|
|
||||||
CONFIG(debug, debug|release) {
|
CONFIG(debug, debug|release) {
|
||||||
TARGET = CmvrControlStation_d
|
TARGET = CmvrControlStation_d
|
||||||
DESTDIR = $$clean_path($$PWD/bin/debug)
|
DESTDIR = $$clean_path($$PWD/bin/debug)
|
||||||
OBJECTS_DIR = build/debug/obj
|
OBJECTS_DIR = build/debug/obj
|
||||||
MOC_DIR = build/debug/moc
|
MOC_DIR = build/debug/moc
|
||||||
RCC_DIR = build/debug/rcc
|
RCC_DIR = build/debug/rcc
|
||||||
UI_DIR = build/debug/ui
|
UI_DIR = build/debug/ui
|
||||||
DEFINES += CMVR_DEBUG_BUILD
|
DEFINES += CMVR_DEBUG_BUILD
|
||||||
ASSIMP_SCENE_PARSER = $$QT_SCENEPARSER_DIR/assimpsceneimportd.dll
|
ASSIMP_SCENE_PARSER = $$QT_SCENEPARSER_DIR/assimpsceneimportd.dll
|
||||||
} else {
|
} else {
|
||||||
TARGET = CmvrControlStation
|
TARGET = CmvrControlStation
|
||||||
DESTDIR = $$clean_path($$PWD/bin/release)
|
DESTDIR = $$clean_path($$PWD/bin/release)
|
||||||
OBJECTS_DIR = build/release/obj
|
OBJECTS_DIR = build/release/obj
|
||||||
MOC_DIR = build/release/moc
|
MOC_DIR = build/release/moc
|
||||||
RCC_DIR = build/release/rcc
|
RCC_DIR = build/release/rcc
|
||||||
UI_DIR = build/release/ui
|
UI_DIR = build/release/ui
|
||||||
DEFINES += NDEBUG
|
DEFINES += NDEBUG
|
||||||
ASSIMP_SCENE_PARSER = $$QT_SCENEPARSER_DIR/assimpsceneimport.dll
|
ASSIMP_SCENE_PARSER = $$QT_SCENEPARSER_DIR/assimpsceneimport.dll
|
||||||
}
|
}
|
||||||
|
|
||||||
!exists($$ASSIMP_SCENE_PARSER): error("Qt3D Assimp scene parser not found in the selected Qt Kit.")
|
!exists($$ASSIMP_SCENE_PARSER): error("Qt3D Assimp scene parser not found in the selected Qt Kit.")
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
src/agvmapviewwidget.cpp \
|
src/handeyebridge.cpp \
|
||||||
src/audiostreammanager.cpp \
|
src/handeyestore.cpp \
|
||||||
src/configeditorwidget.cpp \
|
src/handeyeurdf.cpp \
|
||||||
src/main.cpp \
|
src/touchplanner.cpp \
|
||||||
src/mainwindow.cpp \
|
src/touchsequencecontroller.cpp \
|
||||||
src/mainwindow_ui.cpp \
|
src/touchvideowidget.cpp \
|
||||||
src/quictestserver.cpp \
|
src/touchoperationwidget.cpp \
|
||||||
src/rpcservicewidget.cpp \
|
src/handeyemotionwidget.cpp \
|
||||||
src/robotclient.cpp \
|
src/tcpcalibration.cpp \
|
||||||
src/trendwidget.cpp \
|
src/tcpjogcontroller.cpp \
|
||||||
src/urdfviewerwidget.cpp \
|
src/tcptoolstore.cpp \
|
||||||
src/videodecoder.cpp \
|
src/tcpcalibrationwidget.cpp \
|
||||||
src/videorenderwidget.cpp \
|
src/audiostreammanager.cpp \
|
||||||
ui/handeyecalibrationwidget.cpp
|
src/configeditorwidget.cpp \
|
||||||
|
src/main.cpp \
|
||||||
|
src/mainwindow.cpp \
|
||||||
|
src/mainwindow_ui.cpp \
|
||||||
|
src/quictestserver.cpp \
|
||||||
|
src/rpcservicewidget.cpp \
|
||||||
|
src/robotclient.cpp \
|
||||||
|
src/trendwidget.cpp \
|
||||||
|
src/urdfviewerwidget.cpp \
|
||||||
|
src/videodecoder.cpp \
|
||||||
|
src/videorenderwidget.cpp \
|
||||||
|
ui/handeyecalibrationwidget.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/agvmapviewwidget.h \
|
src/handeyebridge.h \
|
||||||
src/audiostreammanager.h \
|
src/handeyestore.h \
|
||||||
src/configeditorwidget.h \
|
src/handeyeurdf.h \
|
||||||
src/mainwindow.h \
|
src/touchplanner.h \
|
||||||
src/quictestserver.h \
|
src/touchsequencecontroller.h \
|
||||||
src/rpcservicewidget.h \
|
src/touchvideowidget.h \
|
||||||
src/robotclient.h \
|
src/touchoperationwidget.h \
|
||||||
src/trendwidget.h \
|
src/handeyemotionwidget.h \
|
||||||
src/uiicons.h \
|
src/tcpcalibration.h \
|
||||||
src/urdfviewerwidget.h \
|
src/tcpjogcontroller.h \
|
||||||
src/videodecoder.h \
|
src/tcptoolstore.h \
|
||||||
src/videoframe.h \
|
src/tcpcalibrationwidget.h \
|
||||||
src/videorenderwidget.h \
|
src/audiostreammanager.h \
|
||||||
ui/handeyecalibrationwidget.h
|
src/configeditorwidget.h \
|
||||||
|
src/mainwindow.h \
|
||||||
FORMS += \
|
src/quictestserver.h \
|
||||||
ui/handeyecalibrationwidget.ui \
|
src/rpcservicewidget.h \
|
||||||
ui/mainwindow.ui \
|
src/robotclient.h \
|
||||||
ui/systemservicepage.ui \
|
src/trendwidget.h \
|
||||||
ui/armservicepage.ui \
|
src/uiicons.h \
|
||||||
ui/cameraservicepage.ui \
|
src/urdfviewerwidget.h \
|
||||||
ui/agvservicepage.ui \
|
src/videodecoder.h \
|
||||||
ui/agvstatusdialog.ui \
|
src/videoframe.h \
|
||||||
ui/audioservicepage.ui \
|
src/videorenderwidget.h \
|
||||||
ui/quicserverpage.ui \
|
ui/handeyecalibrationwidget.h
|
||||||
ui/diagnosticspage.ui \
|
|
||||||
ui/rpcservicewidget.ui
|
FORMS += \
|
||||||
|
ui/handeyecalibrationwidget.ui \
|
||||||
RESOURCES += resources.qrc
|
ui/mainwindow.ui \
|
||||||
|
ui/systemservicepage.ui \
|
||||||
runtime_library_deployment.files = $$RUNTIME_DLLS
|
ui/armservicepage.ui \
|
||||||
runtime_library_deployment.path = $$DESTDIR
|
ui/cameraservicepage.ui \
|
||||||
quic_certificate_deployment.files = $$MSQUIC_TEST_CERT
|
ui/agvservicepage.ui \
|
||||||
quic_certificate_deployment.path = $$DESTDIR
|
ui/agvstatusdialog.ui \
|
||||||
quic_ca_deployment.files = $$MSQUIC_TEST_CA
|
ui/audioservicepage.ui \
|
||||||
quic_ca_deployment.path = $$DESTDIR
|
ui/quicserverpage.ui \
|
||||||
assimp_scene_parser_deployment.files = $$ASSIMP_SCENE_PARSER
|
ui/diagnosticspage.ui \
|
||||||
assimp_scene_parser_deployment.path = $$DESTDIR/sceneparsers
|
ui/rpcservicewidget.ui
|
||||||
|
|
||||||
|
RESOURCES += resources.qrc
|
||||||
|
|
||||||
|
runtime_library_deployment.files = $$RUNTIME_DLLS
|
||||||
|
runtime_library_deployment.path = $$DESTDIR
|
||||||
|
quic_certificate_deployment.files = $$MSQUIC_TEST_CERT
|
||||||
|
quic_certificate_deployment.path = $$DESTDIR
|
||||||
|
quic_ca_deployment.files = $$MSQUIC_TEST_CA
|
||||||
|
quic_ca_deployment.path = $$DESTDIR
|
||||||
|
assimp_scene_parser_deployment.files = $$ASSIMP_SCENE_PARSER
|
||||||
|
assimp_scene_parser_deployment.path = $$DESTDIR/sceneparsers
|
||||||
COPIES += runtime_library_deployment quic_certificate_deployment quic_ca_deployment assimp_scene_parser_deployment
|
COPIES += runtime_library_deployment quic_certificate_deployment quic_ca_deployment assimp_scene_parser_deployment
|
||||||
|
handeye_algorithm_deployment.files = $$PWD/scripts/handeye_worker.py $$PWD/scripts/handeye_math.py $$PWD/scripts/handeye_refinement.py
|
||||||
QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$shell_quote($$shell_path($$MODEL_DIR)) $$shell_quote($$shell_path($$DESTDIR/models))
|
handeye_algorithm_deployment.path = $$DESTDIR/scripts
|
||||||
|
COPIES += handeye_algorithm_deployment
|
||||||
win32 {
|
win32 {
|
||||||
QMAKE_POST_LINK += $$escape_expand(\n\t) $$QMAKE_COPY_FILE $$shell_quote($$shell_path($$MSQUIC_TEST_CERT)) $$shell_quote($$shell_path($$DESTDIR/quic-test-server.pfx))
|
CONFIG(debug, debug|release): HAND_EYE_JPEG_PLUGIN = $$[QT_INSTALL_PLUGINS]/imageformats/qjpegd.dll
|
||||||
QMAKE_POST_LINK += $$escape_expand(\n\t) $$QMAKE_COPY_FILE $$shell_quote($$shell_path($$MSQUIC_TEST_CA)) $$shell_quote($$shell_path($$DESTDIR/quic-test-ca.crt))
|
else: HAND_EYE_JPEG_PLUGIN = $$[QT_INSTALL_PLUGINS]/imageformats/qjpeg.dll
|
||||||
|
handeye_image_plugin.files = $$HAND_EYE_JPEG_PLUGIN
|
||||||
|
handeye_image_plugin.path = $$DESTDIR/imageformats
|
||||||
|
COPIES += handeye_image_plugin
|
||||||
}
|
}
|
||||||
|
DISTFILES += scripts/handeye_worker.py scripts/handeye_math.py scripts/handeye_refinement.py
|
||||||
win32:RC_ICONS =
|
DISTFILES += scripts/package_handeye_runtime.py
|
||||||
|
|
||||||
|
QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$shell_quote($$shell_path($$MODEL_DIR)) $$shell_quote($$shell_path($$DESTDIR/models))
|
||||||
|
|
||||||
|
win32 {
|
||||||
|
isEmpty(HAND_EYE_RUNTIME_DIR): HAND_EYE_RUNTIME_DIR = $$PWD/third_party/handeye-runtime
|
||||||
|
!exists($$HAND_EYE_RUNTIME_DIR/manifest.json): error(Build the bundled runtime with scripts/package_handeye_runtime.py first)
|
||||||
|
QMAKE_POST_LINK += $$escape_expand(\n\t) if not exist $$shell_quote($$shell_path($$DESTDIR/runtime)) $$QMAKE_MKDIR $$shell_quote($$shell_path($$DESTDIR/runtime))
|
||||||
|
QMAKE_POST_LINK += $$escape_expand(\n\t) $$QMAKE_COPY_DIR $$shell_quote($$shell_path($$HAND_EYE_RUNTIME_DIR)) $$shell_quote($$shell_path($$DESTDIR/runtime/handeye))
|
||||||
|
QMAKE_POST_LINK += $$escape_expand(\n\t) $$QMAKE_COPY_FILE $$shell_quote($$shell_path($$MSQUIC_TEST_CERT)) $$shell_quote($$shell_path($$DESTDIR/quic-test-server.pfx))
|
||||||
|
QMAKE_POST_LINK += $$escape_expand(\n\t) $$QMAKE_COPY_FILE $$shell_quote($$shell_path($$MSQUIC_TEST_CA)) $$shell_quote($$shell_path($$DESTDIR/quic-test-ca.crt))
|
||||||
|
}
|
||||||
|
|
||||||
|
win32:RC_ICONS =
|
||||||
|
|||||||
398
feature/CMakeLists.txt
Normal file
398
feature/CMakeLists.txt
Normal file
@ -0,0 +1,398 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
project(CmvrControlStation VERSION 1.0.0 LANGUAGES CXX)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
set(CMAKE_AUTORCC ON)
|
||||||
|
set(CMAKE_AUTOUIC ON)
|
||||||
|
set(CMAKE_AUTOUIC_SEARCH_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/ui")
|
||||||
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set(CMVR_MSQUIC_DEFAULT ON)
|
||||||
|
else()
|
||||||
|
set(CMVR_MSQUIC_DEFAULT OFF)
|
||||||
|
endif()
|
||||||
|
option(CMVR_WITH_MSQUIC "Build the embedded MsQuic test server" ${CMVR_MSQUIC_DEFAULT})
|
||||||
|
set(CMVR_MSQUIC_ROOT "" CACHE PATH "Optional MsQuic installation prefix on Linux")
|
||||||
|
set(CMVR_CXX_RUNTIME "" CACHE FILEPATH
|
||||||
|
"Optional libstdc++.so.6 matching a non-system Linux dependency prefix")
|
||||||
|
set(CMVR_ASSIMP_SCENE_PARSER "" CACHE FILEPATH
|
||||||
|
"Qt3D Assimp scene parser plugin used for URDF mesh files")
|
||||||
|
|
||||||
|
set(CMVR_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||||
|
set(CMVR_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib")
|
||||||
|
set(CMVR_TOOLS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tools")
|
||||||
|
set(CMVR_CERT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/certs")
|
||||||
|
set(PROTO_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/protos")
|
||||||
|
set(GENERATED_ROOT "${CMAKE_CURRENT_BINARY_DIR}/generated_cpp")
|
||||||
|
|
||||||
|
find_package(Qt5 5.12 REQUIRED COMPONENTS
|
||||||
|
Core Gui Widgets Multimedia 3DCore 3DRender 3DExtras 3DInput 3DAnimation)
|
||||||
|
|
||||||
|
get_target_property(CMVR_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)
|
||||||
|
if(CMVR_QMAKE_EXECUTABLE)
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${CMVR_QMAKE_EXECUTABLE}" -query QT_INSTALL_PLUGINS
|
||||||
|
OUTPUT_VARIABLE CMVR_QT_PLUGIN_ROOT
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
endif()
|
||||||
|
if(NOT CMVR_ASSIMP_SCENE_PARSER)
|
||||||
|
find_file(CMVR_ASSIMP_SCENE_PARSER
|
||||||
|
NAMES assimpsceneimport.dll assimpsceneimportd.dll libassimpsceneimport.so
|
||||||
|
HINTS
|
||||||
|
"${CMVR_QT_PLUGIN_ROOT}/sceneparsers"
|
||||||
|
"/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/qt5/plugins/sceneparsers")
|
||||||
|
endif()
|
||||||
|
if(NOT CMVR_ASSIMP_SCENE_PARSER OR NOT EXISTS "${CMVR_ASSIMP_SCENE_PARSER}")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Qt3D's Assimp scene parser was not found. It is required to display "
|
||||||
|
"STL, DAE, and 3DS meshes from bundled URDF models. On Ubuntu install "
|
||||||
|
"qt3d-assimpsceneimport-plugin, or set CMVR_ASSIMP_SCENE_PARSER to the "
|
||||||
|
"plugin file supplied by the selected Qt installation.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
# The checked-in native libraries use the Qt 5.12.4 MinGW 7.3 64-bit ABI.
|
||||||
|
set(PROTOC "${CMVR_TOOLS_DIR}/run_protoc.cmd")
|
||||||
|
set(GRPC_CPP_PLUGIN "${CMVR_TOOLS_DIR}/grpc_cpp_plugin.exe")
|
||||||
|
foreach(REQUIRED_FILE IN ITEMS
|
||||||
|
"${PROTOC}"
|
||||||
|
"${GRPC_CPP_PLUGIN}"
|
||||||
|
"${CMVR_LIB_DIR}/libgrpc++.a"
|
||||||
|
"${CMVR_LIB_DIR}/libprotobuf.a"
|
||||||
|
"${CMVR_LIB_DIR}/libavcodec.dll.a"
|
||||||
|
"${CMVR_LIB_DIR}/liburdfdom_model.dll.a")
|
||||||
|
if(NOT EXISTS "${REQUIRED_FILE}")
|
||||||
|
message(FATAL_ERROR "Required Windows dependency not found: ${REQUIRED_FILE}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
else()
|
||||||
|
find_package(Protobuf CONFIG QUIET)
|
||||||
|
if(NOT Protobuf_FOUND)
|
||||||
|
find_package(Protobuf REQUIRED)
|
||||||
|
endif()
|
||||||
|
find_package(gRPC CONFIG REQUIRED)
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
find_package(PkgConfig REQUIRED)
|
||||||
|
pkg_check_modules(FFMPEG REQUIRED IMPORTED_TARGET
|
||||||
|
libavcodec libavutil libswscale)
|
||||||
|
find_path(CMVR_URDFDOM_INCLUDE_DIR urdf_parser/urdf_parser.h
|
||||||
|
PATH_SUFFIXES include include/urdfdom)
|
||||||
|
find_path(CMVR_TINYXML_INCLUDE_DIR tinyxml.h PATH_SUFFIXES include)
|
||||||
|
find_library(CMVR_URDFDOM_MODEL_LIBRARY NAMES urdfdom_model)
|
||||||
|
if(NOT CMVR_URDFDOM_INCLUDE_DIR OR NOT CMVR_TINYXML_INCLUDE_DIR OR
|
||||||
|
NOT CMVR_URDFDOM_MODEL_LIBRARY)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"urdfdom/tinyxml was not found. Install liburdfdom-dev or add its prefix "
|
||||||
|
"to CMAKE_PREFIX_PATH.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT TARGET protobuf::protoc)
|
||||||
|
message(FATAL_ERROR "The Protobuf package does not provide protobuf::protoc")
|
||||||
|
endif()
|
||||||
|
if(NOT TARGET gRPC::grpc_cpp_plugin)
|
||||||
|
message(FATAL_ERROR "The gRPC package does not provide gRPC::grpc_cpp_plugin")
|
||||||
|
endif()
|
||||||
|
set(PROTOC "$<TARGET_FILE:protobuf::protoc>")
|
||||||
|
set(GRPC_CPP_PLUGIN "$<TARGET_FILE:gRPC::grpc_cpp_plugin>")
|
||||||
|
|
||||||
|
# A Conda-provided Qt/gRPC stack may carry an older libstdc++ than the
|
||||||
|
# host compiler. Link against the runtime next to the imported dependency
|
||||||
|
# so symbol versions selected at link time match the library loaded from
|
||||||
|
# the generated RUNPATH. System packages resolve to the system runtime.
|
||||||
|
if(NOT CMVR_CXX_RUNTIME)
|
||||||
|
foreach(DEPENDENCY_TARGET IN ITEMS gRPC::grpc++ Qt5::Core)
|
||||||
|
get_target_property(DEPENDENCY_LOCATION
|
||||||
|
${DEPENDENCY_TARGET} IMPORTED_LOCATION_RELEASE)
|
||||||
|
if(NOT DEPENDENCY_LOCATION)
|
||||||
|
get_target_property(DEPENDENCY_LOCATION
|
||||||
|
${DEPENDENCY_TARGET} IMPORTED_LOCATION)
|
||||||
|
endif()
|
||||||
|
if(DEPENDENCY_LOCATION)
|
||||||
|
get_filename_component(DEPENDENCY_LIB_DIR
|
||||||
|
"${DEPENDENCY_LOCATION}" DIRECTORY)
|
||||||
|
if(EXISTS "${DEPENDENCY_LIB_DIR}/libstdc++.so.6")
|
||||||
|
set(CMVR_CXX_RUNTIME
|
||||||
|
"${DEPENDENCY_LIB_DIR}/libstdc++.so.6")
|
||||||
|
message(STATUS
|
||||||
|
"Using dependency-prefix C++ runtime: ${CMVR_CXX_RUNTIME}")
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMVR_WITH_MSQUIC)
|
||||||
|
if(WIN32)
|
||||||
|
if(NOT EXISTS "${CMVR_INCLUDE_DIR}/msquic.h" OR
|
||||||
|
NOT EXISTS "${CMVR_LIB_DIR}/msquic.dll")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"CMVR_WITH_MSQUIC is enabled, but include/msquic.h or lib/msquic.dll is missing")
|
||||||
|
endif()
|
||||||
|
set(CMVR_MSQUIC_INCLUDE_DIR "${CMVR_INCLUDE_DIR}")
|
||||||
|
else()
|
||||||
|
find_path(CMVR_MSQUIC_INCLUDE_DIR msquic.h
|
||||||
|
HINTS "${CMVR_MSQUIC_ROOT}"
|
||||||
|
PATH_SUFFIXES include)
|
||||||
|
find_library(CMVR_MSQUIC_LIBRARY NAMES msquic
|
||||||
|
HINTS "${CMVR_MSQUIC_ROOT}"
|
||||||
|
PATH_SUFFIXES lib lib64)
|
||||||
|
if(NOT CMVR_MSQUIC_INCLUDE_DIR OR NOT CMVR_MSQUIC_LIBRARY)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"CMVR_WITH_MSQUIC=ON requires a Linux MsQuic installation. "
|
||||||
|
"Set CMVR_MSQUIC_ROOT or configure with -DCMVR_WITH_MSQUIC=OFF.")
|
||||||
|
endif()
|
||||||
|
get_filename_component(CMVR_MSQUIC_LIBRARY_DIR
|
||||||
|
"${CMVR_MSQUIC_LIBRARY}" DIRECTORY)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMVR_SOURCES
|
||||||
|
src/audiostreammanager.cpp
|
||||||
|
src/audiostreammanager.h
|
||||||
|
src/configeditorwidget.cpp
|
||||||
|
src/configeditorwidget.h
|
||||||
|
src/main.cpp
|
||||||
|
src/mainwindow.cpp
|
||||||
|
src/mainwindow_ui.cpp
|
||||||
|
src/mainwindow.h
|
||||||
|
src/quictestserver.cpp
|
||||||
|
src/quictestserver.h
|
||||||
|
src/rpcservicewidget.cpp
|
||||||
|
src/rpcservicewidget.h
|
||||||
|
src/robotclient.cpp
|
||||||
|
src/robotclient.h
|
||||||
|
src/trendwidget.cpp
|
||||||
|
src/trendwidget.h
|
||||||
|
src/uiicons.h
|
||||||
|
src/urdfviewerwidget.cpp
|
||||||
|
src/urdfviewerwidget.h
|
||||||
|
src/videodecoder.cpp
|
||||||
|
src/videodecoder.h
|
||||||
|
src/videoframe.h
|
||||||
|
src/videorenderwidget.cpp
|
||||||
|
src/videorenderwidget.h
|
||||||
|
ui/handeyecalibrationwidget.cpp
|
||||||
|
ui/handeyecalibrationwidget.h
|
||||||
|
ui/handeyecalibrationwidget.ui
|
||||||
|
ui/mainwindow.ui
|
||||||
|
ui/systemservicepage.ui
|
||||||
|
ui/armservicepage.ui
|
||||||
|
ui/cameraservicepage.ui
|
||||||
|
ui/agvservicepage.ui
|
||||||
|
ui/agvstatusdialog.ui
|
||||||
|
ui/audioservicepage.ui
|
||||||
|
ui/quicserverpage.ui
|
||||||
|
ui/diagnosticspage.ui
|
||||||
|
ui/rpcservicewidget.ui
|
||||||
|
resources.qrc)
|
||||||
|
|
||||||
|
list(APPEND CMVR_SOURCES
|
||||||
|
src/handeyebridge.cpp src/handeyebridge.h
|
||||||
|
src/handeyestore.cpp src/handeyestore.h
|
||||||
|
src/handeyeurdf.cpp src/handeyeurdf.h
|
||||||
|
src/touchplanner.cpp src/touchplanner.h
|
||||||
|
src/touchsequencecontroller.cpp src/touchsequencecontroller.h
|
||||||
|
src/touchvideowidget.cpp src/touchvideowidget.h
|
||||||
|
src/touchoperationwidget.cpp src/touchoperationwidget.h
|
||||||
|
src/handeyemotionwidget.cpp src/handeyemotionwidget.h
|
||||||
|
src/tcpcalibration.cpp src/tcpcalibration.h
|
||||||
|
src/tcpjogcontroller.cpp src/tcpjogcontroller.h
|
||||||
|
src/tcptoolstore.cpp src/tcptoolstore.h
|
||||||
|
src/tcpcalibrationwidget.cpp src/tcpcalibrationwidget.h)
|
||||||
|
add_executable(CmvrControlStation ${CMVR_SOURCES})
|
||||||
|
if(WIN32)
|
||||||
|
set_target_properties(CmvrControlStation PROPERTIES WIN32_EXECUTABLE TRUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set_target_properties(CmvrControlStation PROPERTIES
|
||||||
|
DEBUG_POSTFIX "_d"
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin/$<LOWER_CASE:$<CONFIG>>")
|
||||||
|
|
||||||
|
target_compile_definitions(CmvrControlStation PRIVATE
|
||||||
|
CMVR_WITH_GRPC=1
|
||||||
|
CMVR_WITH_MSQUIC=$<BOOL:${CMVR_WITH_MSQUIC}>)
|
||||||
|
if(WIN32)
|
||||||
|
target_compile_definitions(CmvrControlStation PRIVATE _WIN32_WINNT=0x0600)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_include_directories(CmvrControlStation PRIVATE "${GENERATED_ROOT}")
|
||||||
|
if(WIN32)
|
||||||
|
target_include_directories(CmvrControlStation PRIVATE
|
||||||
|
"${CMVR_INCLUDE_DIR}"
|
||||||
|
"${CMVR_INCLUDE_DIR}/urdfdom_headers")
|
||||||
|
else()
|
||||||
|
target_include_directories(CmvrControlStation PRIVATE
|
||||||
|
"${CMVR_URDFDOM_INCLUDE_DIR}"
|
||||||
|
"${CMVR_TINYXML_INCLUDE_DIR}"
|
||||||
|
"${CMVR_INCLUDE_DIR}/urdfdom_headers")
|
||||||
|
endif()
|
||||||
|
if(CMVR_WITH_MSQUIC)
|
||||||
|
target_include_directories(CmvrControlStation PRIVATE "${CMVR_MSQUIC_INCLUDE_DIR}")
|
||||||
|
if(UNIX AND CMVR_MSQUIC_LIBRARY_DIR)
|
||||||
|
set_property(TARGET CmvrControlStation APPEND PROPERTY
|
||||||
|
BUILD_RPATH "${CMVR_MSQUIC_LIBRARY_DIR}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_link_libraries(CmvrControlStation PRIVATE
|
||||||
|
Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Multimedia
|
||||||
|
Qt5::3DCore Qt5::3DRender Qt5::3DExtras Qt5::3DInput Qt5::3DAnimation)
|
||||||
|
|
||||||
|
# Generate every project-local CMVR message. This avoids source-tree generated
|
||||||
|
# files and automatically picks up newly added configuration messages.
|
||||||
|
file(GLOB_RECURSE PROTO_FILES CONFIGURE_DEPENDS
|
||||||
|
"${PROTO_ROOT}/cmvr/api/*.proto"
|
||||||
|
"${PROTO_ROOT}/cmvr/common/*.proto"
|
||||||
|
"${PROTO_ROOT}/cmvr/config/*.proto"
|
||||||
|
"${PROTO_ROOT}/cmvr/msgs/agv.proto"
|
||||||
|
"${PROTO_ROOT}/cmvr/quic_edge/v1/*.proto")
|
||||||
|
|
||||||
|
set(SERVICE_NAMES
|
||||||
|
cmvr/api/agv_service
|
||||||
|
cmvr/api/arm_service
|
||||||
|
cmvr/api/biohead_service
|
||||||
|
cmvr/api/camera_service
|
||||||
|
cmvr/api/configuration_service
|
||||||
|
cmvr/api/dexhand_service
|
||||||
|
cmvr/api/hlc_service
|
||||||
|
cmvr/api/microphone_service
|
||||||
|
cmvr/api/speaker_service
|
||||||
|
cmvr/api/system_service
|
||||||
|
cmvr/api/test_service)
|
||||||
|
|
||||||
|
set(GENERATED_FILES)
|
||||||
|
foreach(PROTO_FILE IN LISTS PROTO_FILES)
|
||||||
|
file(RELATIVE_PATH PROTO_RELATIVE "${PROTO_ROOT}" "${PROTO_FILE}")
|
||||||
|
string(REGEX REPLACE "\\.proto$" "" PROTO_NAME "${PROTO_RELATIVE}")
|
||||||
|
set(PB_CC "${GENERATED_ROOT}/${PROTO_NAME}.pb.cc")
|
||||||
|
set(PB_H "${GENERATED_ROOT}/${PROTO_NAME}.pb.h")
|
||||||
|
get_filename_component(PROTO_OUTPUT_DIR "${PB_CC}" DIRECTORY)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT "${PB_CC}" "${PB_H}"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${PROTO_OUTPUT_DIR}"
|
||||||
|
COMMAND "${PROTOC}"
|
||||||
|
"--proto_path=${PROTO_ROOT}"
|
||||||
|
"--cpp_out=${GENERATED_ROOT}"
|
||||||
|
"${PROTO_FILE}"
|
||||||
|
DEPENDS "${PROTO_FILE}" ${PROTO_FILES}
|
||||||
|
VERBATIM)
|
||||||
|
list(APPEND GENERATED_FILES "${PB_CC}" "${PB_H}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
foreach(SERVICE_NAME IN LISTS SERVICE_NAMES)
|
||||||
|
set(PROTO_FILE "${PROTO_ROOT}/${SERVICE_NAME}.proto")
|
||||||
|
set(GRPC_CC "${GENERATED_ROOT}/${SERVICE_NAME}.grpc.pb.cc")
|
||||||
|
set(GRPC_H "${GENERATED_ROOT}/${SERVICE_NAME}.grpc.pb.h")
|
||||||
|
get_filename_component(PROTO_OUTPUT_DIR "${GRPC_CC}" DIRECTORY)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT "${GRPC_CC}" "${GRPC_H}"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${PROTO_OUTPUT_DIR}"
|
||||||
|
COMMAND "${PROTOC}"
|
||||||
|
"--proto_path=${PROTO_ROOT}"
|
||||||
|
"--grpc_out=${GENERATED_ROOT}"
|
||||||
|
"--plugin=protoc-gen-grpc=${GRPC_CPP_PLUGIN}"
|
||||||
|
"${PROTO_FILE}"
|
||||||
|
DEPENDS "${PROTO_FILE}" ${PROTO_FILES}
|
||||||
|
VERBATIM)
|
||||||
|
list(APPEND GENERATED_FILES "${GRPC_CC}" "${GRPC_H}")
|
||||||
|
endforeach()
|
||||||
|
target_sources(CmvrControlStation PRIVATE ${GENERATED_FILES})
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
file(GLOB ABSL_STATIC_LIBS "${CMVR_LIB_DIR}/libabsl_*.a")
|
||||||
|
target_link_libraries(CmvrControlStation PRIVATE
|
||||||
|
"-Wl,--start-group"
|
||||||
|
"${CMVR_LIB_DIR}/libgrpc++.a"
|
||||||
|
"${CMVR_LIB_DIR}/libgrpc.a"
|
||||||
|
"${CMVR_LIB_DIR}/libgpr.a"
|
||||||
|
"${CMVR_LIB_DIR}/libaddress_sorting.a"
|
||||||
|
"${CMVR_LIB_DIR}/libre2.a"
|
||||||
|
"${CMVR_LIB_DIR}/libupb.a"
|
||||||
|
"${CMVR_LIB_DIR}/libcares.a"
|
||||||
|
"${CMVR_LIB_DIR}/libssl.a"
|
||||||
|
"${CMVR_LIB_DIR}/libcrypto.a"
|
||||||
|
"${CMVR_LIB_DIR}/libzlibstatic.a"
|
||||||
|
"${CMVR_LIB_DIR}/libprotobuf.a"
|
||||||
|
${ABSL_STATIC_LIBS}
|
||||||
|
"-Wl,--end-group"
|
||||||
|
"${CMVR_LIB_DIR}/libavcodec.dll.a"
|
||||||
|
"${CMVR_LIB_DIR}/libavutil.dll.a"
|
||||||
|
"${CMVR_LIB_DIR}/libswscale.dll.a"
|
||||||
|
"${CMVR_LIB_DIR}/liburdfdom_model.dll.a"
|
||||||
|
ws2_32 crypt32 advapi32 bcrypt dbghelp iphlpapi secur32 ntdll)
|
||||||
|
else()
|
||||||
|
if(CMVR_CXX_RUNTIME)
|
||||||
|
target_link_libraries(CmvrControlStation PRIVATE "${CMVR_CXX_RUNTIME}")
|
||||||
|
endif()
|
||||||
|
target_link_libraries(CmvrControlStation PRIVATE
|
||||||
|
protobuf::libprotobuf
|
||||||
|
gRPC::grpc++
|
||||||
|
PkgConfig::FFMPEG
|
||||||
|
Threads::Threads
|
||||||
|
"${CMVR_URDFDOM_MODEL_LIBRARY}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
file(GLOB CMVR_RUNTIME_DLLS "${CMVR_LIB_DIR}/*.dll")
|
||||||
|
foreach(RUNTIME_DLL IN LISTS CMVR_RUNTIME_DLLS)
|
||||||
|
add_custom_command(TARGET CmvrControlStation POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
"${RUNTIME_DLL}" "$<TARGET_FILE_DIR:CmvrControlStation>")
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
foreach(CERTIFICATE IN ITEMS quic-test-server.pfx quic-test-ca.crt)
|
||||||
|
if(EXISTS "${CMVR_CERT_DIR}/${CERTIFICATE}")
|
||||||
|
add_custom_command(TARGET CmvrControlStation POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
"${CMVR_CERT_DIR}/${CERTIFICATE}"
|
||||||
|
"$<TARGET_FILE_DIR:CmvrControlStation>/${CERTIFICATE}")
|
||||||
|
install(FILES "${CMVR_CERT_DIR}/${CERTIFICATE}" DESTINATION bin)
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
add_custom_command(TARGET CmvrControlStation POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory
|
||||||
|
"$<TARGET_FILE_DIR:CmvrControlStation>/sceneparsers"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
"${CMVR_ASSIMP_SCENE_PARSER}"
|
||||||
|
"$<TARGET_FILE_DIR:CmvrControlStation>/sceneparsers/"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/models"
|
||||||
|
"$<TARGET_FILE_DIR:CmvrControlStation>/models")
|
||||||
|
|
||||||
|
install(TARGETS CmvrControlStation RUNTIME DESTINATION bin)
|
||||||
|
add_custom_command(TARGET CmvrControlStation POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_FILE_DIR:CmvrControlStation>/scripts"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/handeye_worker.py"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/handeye_math.py"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/handeye_refinement.py"
|
||||||
|
"$<TARGET_FILE_DIR:CmvrControlStation>/scripts")
|
||||||
|
install(FILES scripts/handeye_worker.py scripts/handeye_math.py scripts/handeye_refinement.py DESTINATION bin/scripts)
|
||||||
|
if(WIN32)
|
||||||
|
set(CMVR_HAND_EYE_JPEG_PLUGIN "${CMVR_QT_PLUGIN_ROOT}/imageformats/qjpeg$<$<CONFIG:Debug>:d>.dll")
|
||||||
|
add_custom_command(TARGET CmvrControlStation POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_FILE_DIR:CmvrControlStation>/imageformats"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMVR_HAND_EYE_JPEG_PLUGIN}"
|
||||||
|
"$<TARGET_FILE_DIR:CmvrControlStation>/imageformats/")
|
||||||
|
install(FILES "${CMVR_HAND_EYE_JPEG_PLUGIN}" DESTINATION bin/imageformats)
|
||||||
|
set(CMVR_HAND_EYE_RUNTIME_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/handeye-runtime" CACHE PATH "Bundled Windows x64 hand-eye runtime")
|
||||||
|
if(NOT EXISTS "${CMVR_HAND_EYE_RUNTIME_DIR}/manifest.json")
|
||||||
|
message(FATAL_ERROR "Build the bundled runtime with scripts/package_handeye_runtime.py first")
|
||||||
|
endif()
|
||||||
|
add_custom_command(TARGET CmvrControlStation POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_FILE_DIR:CmvrControlStation>/runtime/handeye"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMVR_HAND_EYE_RUNTIME_DIR}"
|
||||||
|
"$<TARGET_FILE_DIR:CmvrControlStation>/runtime/handeye")
|
||||||
|
install(DIRECTORY "${CMVR_HAND_EYE_RUNTIME_DIR}/" DESTINATION bin/runtime/handeye)
|
||||||
|
endif()
|
||||||
|
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/models/"
|
||||||
|
DESTINATION bin/models)
|
||||||
|
install(PROGRAMS "${CMVR_ASSIMP_SCENE_PARSER}"
|
||||||
|
DESTINATION bin/sceneparsers)
|
||||||
341
feature/CmvrControlStation.pro
Normal file
341
feature/CmvrControlStation.pro
Normal file
@ -0,0 +1,341 @@
|
|||||||
|
QT += core gui widgets multimedia 3dcore 3drender 3dextras 3dinput 3danimation
|
||||||
|
|
||||||
|
CONFIG += c++14 warn_on debug_and_release
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
DEFINES += QT_DEPRECATED_WARNINGS _WIN32_WINNT=0x0600
|
||||||
|
|
||||||
|
INCLUDE_DIR = $$clean_path($$PWD/include)
|
||||||
|
LIB_DIR = $$clean_path($$PWD/lib)
|
||||||
|
TOOLS_DIR = $$clean_path($$PWD/tools)
|
||||||
|
CERT_DIR = $$clean_path($$PWD/certs)
|
||||||
|
PROTO_ROOT = $$clean_path($$PWD/protos)
|
||||||
|
PROTO_GEN_DIR = $$clean_path($$PWD/generated_cpp)
|
||||||
|
PROTOC = $$TOOLS_DIR/run_protoc.cmd
|
||||||
|
GRPC_CPP_PLUGIN = $$TOOLS_DIR/grpc_cpp_plugin.exe
|
||||||
|
MSQUIC_DLL = $$LIB_DIR/msquic.dll
|
||||||
|
MSQUIC_TEST_CERT = $$CERT_DIR/quic-test-server.pfx
|
||||||
|
MSQUIC_TEST_CA = $$CERT_DIR/quic-test-ca.crt
|
||||||
|
RUNTIME_DLLS = $$files($$LIB_DIR/*.dll)
|
||||||
|
MODEL_DIR = $$clean_path($$PWD/models)
|
||||||
|
QT_SCENEPARSER_DIR = $$clean_path($$[QT_INSTALL_PLUGINS]/sceneparsers)
|
||||||
|
|
||||||
|
!exists($$PROTOC): error("protoc launcher not found. Run scripts/build_native_deps.ps1 first.")
|
||||||
|
!exists($$GRPC_CPP_PLUGIN): error("grpc_cpp_plugin.exe not found. Run scripts/build_native_deps.ps1 first.")
|
||||||
|
!exists($$MSQUIC_DLL): error("msquic.dll not found. Run scripts/install_msquic.ps1 first.")
|
||||||
|
!exists($$MSQUIC_TEST_CERT): error("QUIC test certificate not found. Run scripts/install_msquic.ps1 first.")
|
||||||
|
!exists($$MSQUIC_TEST_CA): error("QUIC test CA not found. Run scripts/install_msquic.ps1 first.")
|
||||||
|
!exists($$INCLUDE_DIR/libavcodec/avcodec.h): error("FFmpeg headers not found in include.")
|
||||||
|
!exists($$LIB_DIR/avcodec-58.dll): error("FFmpeg runtime DLLs not found in lib.")
|
||||||
|
!exists($$INCLUDE_DIR/urdf_parser/urdf_parser.h): error("urdfdom headers not found in include.")
|
||||||
|
!exists($$LIB_DIR/liburdfdom_model.dll.a): error("urdfdom link library not found in lib.")
|
||||||
|
!exists($$LIB_DIR/liburdfdom_model.dll): error("urdfdom runtime DLL not found in lib.")
|
||||||
|
|
||||||
|
PROTO_FILES = \
|
||||||
|
$$PROTO_ROOT/cmvr/api/common.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/agv_command.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/agv_service.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/arm_command.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/arm_service.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/biohead_command.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/biohead_service.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/camera_command.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/camera_service.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/configuration_command.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/configuration_service.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/dexhand_command.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/dexhand_service.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/hlc_command.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/hlc_service.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/microphone_command.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/microphone_service.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/speaker_command.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/speaker_service.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/system_command.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/system_service.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/test_service.proto
|
||||||
|
|
||||||
|
GRPC_PROTO_FILES = \
|
||||||
|
$$PROTO_ROOT/cmvr/api/agv_service.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/arm_service.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/biohead_service.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/camera_service.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/configuration_service.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/dexhand_service.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/hlc_service.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/microphone_service.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/speaker_service.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/system_service.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/api/test_service.proto
|
||||||
|
|
||||||
|
MSG_PROTO_FILES = \
|
||||||
|
$$PROTO_ROOT/cmvr/msgs/agv.proto
|
||||||
|
|
||||||
|
CONFIG_PROTO_FILES = \
|
||||||
|
$$PROTO_ROOT/cmvr/config/agv_config/agv_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/arm_config/arm_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/aubo_robot_config/aubo_robot_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/biohead_config/biohead_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/camera_config/camera_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/cmvr_es_config/cmvr_es_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/device_manager_config/device_manager_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/dexhand_config/dexhand_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/grpc_server_config/grpc_server_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/logger_config/logger_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/microphone_config/microphone_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/motor_config/motor_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/quic_edge_config/quic_edge_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/self_collision_task_config/self_collision_task_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/speaker_config/speaker_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/task_manager_config/task_manager_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/touch_screen_task_config/touch_screen_task_config.proto
|
||||||
|
|
||||||
|
CONFIG_ROOT_PROTO_FILES = \
|
||||||
|
$$PROTO_ROOT/cmvr/config/cartesian_motion_validation_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/joint_limits_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/lawba_ik_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/pinocchio_dls_ik_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/pinocchio_qp_ik_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/srs_ik_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/touch_screen_algorithm_config.proto \
|
||||||
|
$$PROTO_ROOT/cmvr/config/touch_screen_common_config.proto
|
||||||
|
|
||||||
|
COMMON_PROTO_FILES = \
|
||||||
|
$$PROTO_ROOT/cmvr/common/geometry.proto
|
||||||
|
|
||||||
|
MUJOCO_PROTO_FILES = \
|
||||||
|
$$PROTO_ROOT/cmvr/config/mujoco_config/mujoco_world_config.proto
|
||||||
|
|
||||||
|
QUIC_PROTO_FILES = \
|
||||||
|
$$PROTO_ROOT/cmvr/quic_edge/v1/quic_edge.proto
|
||||||
|
|
||||||
|
# Show the complete local proto tree in Qt Creator without compiling unused APIs.
|
||||||
|
OTHER_FILES += $$files($$PROTO_ROOT/*.proto, true) $$files($$MODEL_DIR/*.urdf, true)
|
||||||
|
|
||||||
|
INCLUDEPATH += \
|
||||||
|
$$PROTO_GEN_DIR \
|
||||||
|
$$INCLUDE_DIR \
|
||||||
|
$$INCLUDE_DIR/urdfdom_headers
|
||||||
|
|
||||||
|
protobuf_compiler.name = Protobuf ${QMAKE_FILE_IN}
|
||||||
|
protobuf_compiler.input = PROTO_FILES
|
||||||
|
protobuf_compiler.output = $$PROTO_GEN_DIR/cmvr/api/${QMAKE_FILE_BASE}.pb.cc
|
||||||
|
protobuf_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --cpp_out=$$quote($$PROTO_GEN_DIR) $$quote($$PROTO_ROOT/cmvr/api/${QMAKE_FILE_BASE}.proto)
|
||||||
|
protobuf_compiler.depends = $$PROTO_FILES $$MSG_PROTO_FILES
|
||||||
|
protobuf_compiler.variable_out = SOURCES
|
||||||
|
protobuf_compiler.CONFIG += target_predeps
|
||||||
|
|
||||||
|
msg_protobuf_compiler.name = Protobuf ${QMAKE_FILE_IN}
|
||||||
|
msg_protobuf_compiler.input = MSG_PROTO_FILES
|
||||||
|
msg_protobuf_compiler.output = $$PROTO_GEN_DIR/cmvr/msgs/${QMAKE_FILE_BASE}.pb.cc
|
||||||
|
msg_protobuf_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --cpp_out=$$quote($$PROTO_GEN_DIR) $$quote($$PROTO_ROOT/cmvr/msgs/${QMAKE_FILE_BASE}.proto)
|
||||||
|
msg_protobuf_compiler.depends = $$MSG_PROTO_FILES
|
||||||
|
msg_protobuf_compiler.variable_out = SOURCES
|
||||||
|
msg_protobuf_compiler.CONFIG += target_predeps
|
||||||
|
|
||||||
|
config_protobuf_compiler.name = Protobuf ${QMAKE_FILE_IN}
|
||||||
|
config_protobuf_compiler.input = CONFIG_PROTO_FILES
|
||||||
|
config_protobuf_compiler.output = $$PROTO_GEN_DIR/cmvr/config/${QMAKE_FILE_BASE}/${QMAKE_FILE_BASE}.pb.cc
|
||||||
|
config_protobuf_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --cpp_out=$$quote($$PROTO_GEN_DIR) $$quote($$PROTO_ROOT/cmvr/config/${QMAKE_FILE_BASE}/${QMAKE_FILE_BASE}.proto)
|
||||||
|
config_protobuf_compiler.depends = $$CONFIG_PROTO_FILES
|
||||||
|
config_protobuf_compiler.variable_out = SOURCES
|
||||||
|
config_protobuf_compiler.CONFIG += target_predeps
|
||||||
|
|
||||||
|
config_root_protobuf_compiler.name = Protobuf ${QMAKE_FILE_IN}
|
||||||
|
config_root_protobuf_compiler.input = CONFIG_ROOT_PROTO_FILES
|
||||||
|
config_root_protobuf_compiler.output = $$PROTO_GEN_DIR/cmvr/config/${QMAKE_FILE_BASE}.pb.cc
|
||||||
|
config_root_protobuf_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --cpp_out=$$quote($$PROTO_GEN_DIR) $$quote($$PROTO_ROOT/cmvr/config/${QMAKE_FILE_BASE}.proto)
|
||||||
|
config_root_protobuf_compiler.depends = $$CONFIG_ROOT_PROTO_FILES $$COMMON_PROTO_FILES
|
||||||
|
config_root_protobuf_compiler.variable_out = SOURCES
|
||||||
|
config_root_protobuf_compiler.CONFIG += target_predeps
|
||||||
|
|
||||||
|
common_protobuf_compiler.name = Protobuf ${QMAKE_FILE_IN}
|
||||||
|
common_protobuf_compiler.input = COMMON_PROTO_FILES
|
||||||
|
common_protobuf_compiler.output = $$PROTO_GEN_DIR/cmvr/common/${QMAKE_FILE_BASE}.pb.cc
|
||||||
|
common_protobuf_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --cpp_out=$$quote($$PROTO_GEN_DIR) $$quote($$PROTO_ROOT/cmvr/common/${QMAKE_FILE_BASE}.proto)
|
||||||
|
common_protobuf_compiler.depends = $$COMMON_PROTO_FILES
|
||||||
|
common_protobuf_compiler.variable_out = SOURCES
|
||||||
|
common_protobuf_compiler.CONFIG += target_predeps
|
||||||
|
|
||||||
|
mujoco_protobuf_compiler.name = Protobuf ${QMAKE_FILE_IN}
|
||||||
|
mujoco_protobuf_compiler.input = MUJOCO_PROTO_FILES
|
||||||
|
mujoco_protobuf_compiler.output = $$PROTO_GEN_DIR/cmvr/config/mujoco_config/${QMAKE_FILE_BASE}.pb.cc
|
||||||
|
mujoco_protobuf_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --cpp_out=$$quote($$PROTO_GEN_DIR) $$quote($$PROTO_ROOT/cmvr/config/mujoco_config/${QMAKE_FILE_BASE}.proto)
|
||||||
|
mujoco_protobuf_compiler.depends = $$MUJOCO_PROTO_FILES
|
||||||
|
mujoco_protobuf_compiler.variable_out = SOURCES
|
||||||
|
mujoco_protobuf_compiler.CONFIG += target_predeps
|
||||||
|
|
||||||
|
grpc_compiler.name = gRPC ${QMAKE_FILE_IN}
|
||||||
|
grpc_compiler.input = GRPC_PROTO_FILES
|
||||||
|
grpc_compiler.output = $$PROTO_GEN_DIR/cmvr/api/${QMAKE_FILE_BASE}.grpc.pb.cc
|
||||||
|
grpc_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --grpc_out=$$quote($$PROTO_GEN_DIR) --plugin=protoc-gen-grpc=$$quote($$GRPC_CPP_PLUGIN) $$quote($$PROTO_ROOT/cmvr/api/${QMAKE_FILE_BASE}.proto)
|
||||||
|
grpc_compiler.depends = $$PROTO_FILES $$MSG_PROTO_FILES
|
||||||
|
grpc_compiler.variable_out = SOURCES
|
||||||
|
grpc_compiler.CONFIG += target_predeps
|
||||||
|
|
||||||
|
quic_protobuf_compiler.name = Protobuf ${QMAKE_FILE_IN}
|
||||||
|
quic_protobuf_compiler.input = QUIC_PROTO_FILES
|
||||||
|
quic_protobuf_compiler.output = $$PROTO_GEN_DIR/cmvr/quic_edge/v1/${QMAKE_FILE_BASE}.pb.cc
|
||||||
|
quic_protobuf_compiler.commands = $$quote($$PROTOC) --proto_path=$$quote($$PROTO_ROOT) --cpp_out=$$quote($$PROTO_GEN_DIR) $$quote($$PROTO_ROOT/cmvr/quic_edge/v1/${QMAKE_FILE_BASE}.proto)
|
||||||
|
quic_protobuf_compiler.depends = $$QUIC_PROTO_FILES
|
||||||
|
quic_protobuf_compiler.variable_out = SOURCES
|
||||||
|
quic_protobuf_compiler.CONFIG += target_predeps
|
||||||
|
|
||||||
|
QMAKE_EXTRA_COMPILERS += protobuf_compiler msg_protobuf_compiler config_protobuf_compiler config_root_protobuf_compiler common_protobuf_compiler mujoco_protobuf_compiler grpc_compiler quic_protobuf_compiler
|
||||||
|
|
||||||
|
ABSL_STATIC_LIBS = $$files($$LIB_DIR/libabsl_*.a)
|
||||||
|
LIBS += \
|
||||||
|
-Wl,--start-group \
|
||||||
|
$$LIB_DIR/libgrpc++.a \
|
||||||
|
$$LIB_DIR/libgrpc.a \
|
||||||
|
$$LIB_DIR/libgpr.a \
|
||||||
|
$$LIB_DIR/libaddress_sorting.a \
|
||||||
|
$$LIB_DIR/libre2.a \
|
||||||
|
$$LIB_DIR/libupb.a \
|
||||||
|
$$LIB_DIR/libcares.a \
|
||||||
|
$$LIB_DIR/libssl.a \
|
||||||
|
$$LIB_DIR/libcrypto.a \
|
||||||
|
$$LIB_DIR/libzlibstatic.a \
|
||||||
|
$$LIB_DIR/libprotobuf.a \
|
||||||
|
$$ABSL_STATIC_LIBS \
|
||||||
|
-Wl,--end-group \
|
||||||
|
$$LIB_DIR/libavcodec.dll.a \
|
||||||
|
$$LIB_DIR/libavutil.dll.a \
|
||||||
|
$$LIB_DIR/libswscale.dll.a \
|
||||||
|
$$LIB_DIR/liburdfdom_model.dll.a \
|
||||||
|
-lws2_32 \
|
||||||
|
-lcrypt32 \
|
||||||
|
-ladvapi32 \
|
||||||
|
-lbcrypt \
|
||||||
|
-ldbghelp \
|
||||||
|
-liphlpapi \
|
||||||
|
-lsecur32 \
|
||||||
|
-lntdll
|
||||||
|
|
||||||
|
DEFINES += CMVR_WITH_GRPC=1 CMVR_WITH_MSQUIC=1
|
||||||
|
|
||||||
|
CONFIG(debug, debug|release) {
|
||||||
|
TARGET = CmvrControlStation_d
|
||||||
|
DESTDIR = $$clean_path($$PWD/bin/debug)
|
||||||
|
OBJECTS_DIR = build/debug/obj
|
||||||
|
MOC_DIR = build/debug/moc
|
||||||
|
RCC_DIR = build/debug/rcc
|
||||||
|
UI_DIR = build/debug/ui
|
||||||
|
DEFINES += CMVR_DEBUG_BUILD
|
||||||
|
ASSIMP_SCENE_PARSER = $$QT_SCENEPARSER_DIR/assimpsceneimportd.dll
|
||||||
|
} else {
|
||||||
|
TARGET = CmvrControlStation
|
||||||
|
DESTDIR = $$clean_path($$PWD/bin/release)
|
||||||
|
OBJECTS_DIR = build/release/obj
|
||||||
|
MOC_DIR = build/release/moc
|
||||||
|
RCC_DIR = build/release/rcc
|
||||||
|
UI_DIR = build/release/ui
|
||||||
|
DEFINES += NDEBUG
|
||||||
|
ASSIMP_SCENE_PARSER = $$QT_SCENEPARSER_DIR/assimpsceneimport.dll
|
||||||
|
}
|
||||||
|
|
||||||
|
!exists($$ASSIMP_SCENE_PARSER): error("Qt3D Assimp scene parser not found in the selected Qt Kit.")
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
src/handeyebridge.cpp \
|
||||||
|
src/handeyestore.cpp \
|
||||||
|
src/handeyeurdf.cpp \
|
||||||
|
src/touchplanner.cpp \
|
||||||
|
src/touchsequencecontroller.cpp \
|
||||||
|
src/touchvideowidget.cpp \
|
||||||
|
src/touchoperationwidget.cpp \
|
||||||
|
src/handeyemotionwidget.cpp \
|
||||||
|
src/tcpcalibration.cpp \
|
||||||
|
src/tcpjogcontroller.cpp \
|
||||||
|
src/tcptoolstore.cpp \
|
||||||
|
src/tcpcalibrationwidget.cpp \
|
||||||
|
src/audiostreammanager.cpp \
|
||||||
|
src/configeditorwidget.cpp \
|
||||||
|
src/main.cpp \
|
||||||
|
src/mainwindow.cpp \
|
||||||
|
src/mainwindow_ui.cpp \
|
||||||
|
src/quictestserver.cpp \
|
||||||
|
src/rpcservicewidget.cpp \
|
||||||
|
src/robotclient.cpp \
|
||||||
|
src/trendwidget.cpp \
|
||||||
|
src/urdfviewerwidget.cpp \
|
||||||
|
src/videodecoder.cpp \
|
||||||
|
src/videorenderwidget.cpp \
|
||||||
|
ui/handeyecalibrationwidget.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
src/handeyebridge.h \
|
||||||
|
src/handeyestore.h \
|
||||||
|
src/handeyeurdf.h \
|
||||||
|
src/touchplanner.h \
|
||||||
|
src/touchsequencecontroller.h \
|
||||||
|
src/touchvideowidget.h \
|
||||||
|
src/touchoperationwidget.h \
|
||||||
|
src/handeyemotionwidget.h \
|
||||||
|
src/tcpcalibration.h \
|
||||||
|
src/tcpjogcontroller.h \
|
||||||
|
src/tcptoolstore.h \
|
||||||
|
src/tcpcalibrationwidget.h \
|
||||||
|
src/audiostreammanager.h \
|
||||||
|
src/configeditorwidget.h \
|
||||||
|
src/mainwindow.h \
|
||||||
|
src/quictestserver.h \
|
||||||
|
src/rpcservicewidget.h \
|
||||||
|
src/robotclient.h \
|
||||||
|
src/trendwidget.h \
|
||||||
|
src/uiicons.h \
|
||||||
|
src/urdfviewerwidget.h \
|
||||||
|
src/videodecoder.h \
|
||||||
|
src/videoframe.h \
|
||||||
|
src/videorenderwidget.h \
|
||||||
|
ui/handeyecalibrationwidget.h
|
||||||
|
|
||||||
|
FORMS += \
|
||||||
|
ui/handeyecalibrationwidget.ui \
|
||||||
|
ui/mainwindow.ui \
|
||||||
|
ui/systemservicepage.ui \
|
||||||
|
ui/armservicepage.ui \
|
||||||
|
ui/cameraservicepage.ui \
|
||||||
|
ui/agvservicepage.ui \
|
||||||
|
ui/agvstatusdialog.ui \
|
||||||
|
ui/audioservicepage.ui \
|
||||||
|
ui/quicserverpage.ui \
|
||||||
|
ui/diagnosticspage.ui \
|
||||||
|
ui/rpcservicewidget.ui
|
||||||
|
|
||||||
|
RESOURCES += resources.qrc
|
||||||
|
|
||||||
|
runtime_library_deployment.files = $$RUNTIME_DLLS
|
||||||
|
runtime_library_deployment.path = $$DESTDIR
|
||||||
|
quic_certificate_deployment.files = $$MSQUIC_TEST_CERT
|
||||||
|
quic_certificate_deployment.path = $$DESTDIR
|
||||||
|
quic_ca_deployment.files = $$MSQUIC_TEST_CA
|
||||||
|
quic_ca_deployment.path = $$DESTDIR
|
||||||
|
assimp_scene_parser_deployment.files = $$ASSIMP_SCENE_PARSER
|
||||||
|
assimp_scene_parser_deployment.path = $$DESTDIR/sceneparsers
|
||||||
|
COPIES += runtime_library_deployment quic_certificate_deployment quic_ca_deployment assimp_scene_parser_deployment
|
||||||
|
handeye_algorithm_deployment.files = $$PWD/scripts/handeye_worker.py $$PWD/scripts/handeye_math.py $$PWD/scripts/handeye_refinement.py
|
||||||
|
handeye_algorithm_deployment.path = $$DESTDIR/scripts
|
||||||
|
COPIES += handeye_algorithm_deployment
|
||||||
|
win32 {
|
||||||
|
CONFIG(debug, debug|release): HAND_EYE_JPEG_PLUGIN = $$[QT_INSTALL_PLUGINS]/imageformats/qjpegd.dll
|
||||||
|
else: HAND_EYE_JPEG_PLUGIN = $$[QT_INSTALL_PLUGINS]/imageformats/qjpeg.dll
|
||||||
|
handeye_image_plugin.files = $$HAND_EYE_JPEG_PLUGIN
|
||||||
|
handeye_image_plugin.path = $$DESTDIR/imageformats
|
||||||
|
COPIES += handeye_image_plugin
|
||||||
|
}
|
||||||
|
DISTFILES += scripts/handeye_worker.py scripts/handeye_math.py scripts/handeye_refinement.py
|
||||||
|
DISTFILES += scripts/package_handeye_runtime.py
|
||||||
|
|
||||||
|
QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$shell_quote($$shell_path($$MODEL_DIR)) $$shell_quote($$shell_path($$DESTDIR/models))
|
||||||
|
|
||||||
|
win32 {
|
||||||
|
isEmpty(HAND_EYE_RUNTIME_DIR): HAND_EYE_RUNTIME_DIR = $$PWD/third_party/handeye-runtime
|
||||||
|
!exists($$HAND_EYE_RUNTIME_DIR/manifest.json): error(Build the bundled runtime with scripts/package_handeye_runtime.py first)
|
||||||
|
QMAKE_POST_LINK += $$escape_expand(\n\t) if not exist $$shell_quote($$shell_path($$DESTDIR/runtime)) $$QMAKE_MKDIR $$shell_quote($$shell_path($$DESTDIR/runtime))
|
||||||
|
QMAKE_POST_LINK += $$escape_expand(\n\t) $$QMAKE_COPY_DIR $$shell_quote($$shell_path($$HAND_EYE_RUNTIME_DIR)) $$shell_quote($$shell_path($$DESTDIR/runtime/handeye))
|
||||||
|
QMAKE_POST_LINK += $$escape_expand(\n\t) $$QMAKE_COPY_FILE $$shell_quote($$shell_path($$MSQUIC_TEST_CERT)) $$shell_quote($$shell_path($$DESTDIR/quic-test-server.pfx))
|
||||||
|
QMAKE_POST_LINK += $$escape_expand(\n\t) $$QMAKE_COPY_FILE $$shell_quote($$shell_path($$MSQUIC_TEST_CA)) $$shell_quote($$shell_path($$DESTDIR/quic-test-ca.crt))
|
||||||
|
}
|
||||||
|
|
||||||
|
win32:RC_ICONS =
|
||||||
1606
feature/styles.qss
Normal file
1606
feature/styles.qss
Normal file
File diff suppressed because it is too large
Load Diff
4236
src/mainwindow.cpp
4236
src/mainwindow.cpp
File diff suppressed because it is too large
Load Diff
646
src/mainwindow.h
646
src/mainwindow.h
@ -1,323 +1,329 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QVariantList>
|
#include <QVariantList>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
|
||||||
#include "videoframe.h"
|
#include "videoframe.h"
|
||||||
|
|
||||||
class QButtonGroup;
|
class QButtonGroup;
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QDoubleSpinBox;
|
class QDoubleSpinBox;
|
||||||
class QDialog;
|
class QDialog;
|
||||||
class QEvent;
|
class QEvent;
|
||||||
class QHBoxLayout;
|
class QHBoxLayout;
|
||||||
class QGridLayout;
|
class QGridLayout;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QProgressBar;
|
class QProgressBar;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QResizeEvent;
|
class QResizeEvent;
|
||||||
class QSlider;
|
class QSlider;
|
||||||
class QSpinBox;
|
class QSpinBox;
|
||||||
class QStackedWidget;
|
class QStackedWidget;
|
||||||
class QTableWidget;
|
class QTableWidget;
|
||||||
class QTabWidget;
|
class QTabWidget;
|
||||||
class QTextEdit;
|
class QTextEdit;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
class TrendWidget;
|
class TrendWidget;
|
||||||
class RobotClient;
|
class RobotClient;
|
||||||
class QuicTestServer;
|
class QuicTestServer;
|
||||||
class UrdfViewerWidget;
|
class UrdfViewerWidget;
|
||||||
class AudioStreamManager;
|
class AudioStreamManager;
|
||||||
class VideoRenderWidget;
|
class VideoRenderWidget;
|
||||||
class AgvMapViewWidget;
|
class TcpCalibrationWidget;
|
||||||
|
class TouchOperationWidget;
|
||||||
class MainWindow : public QMainWindow
|
class TcpJogController;
|
||||||
{
|
class HandEyeCalibrationWidget;
|
||||||
Q_OBJECT
|
class HandEyeMotionWidget;
|
||||||
|
|
||||||
public:
|
class MainWindow : public QMainWindow
|
||||||
explicit MainWindow(QWidget *parent = nullptr);
|
{
|
||||||
~MainWindow() override;
|
Q_OBJECT
|
||||||
|
|
||||||
protected:
|
public:
|
||||||
bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
|
explicit MainWindow(QWidget *parent = nullptr);
|
||||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
~MainWindow() override;
|
||||||
void changeEvent(QEvent *event) override;
|
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
protected:
|
||||||
|
bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
|
||||||
private slots:
|
void changeEvent(QEvent *event) override;
|
||||||
void selectPage(int index);
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
void toggleConnection();
|
|
||||||
void updateConnection(bool connected, int latencyMs, const QString &detail);
|
private slots:
|
||||||
void updateArmInfo(const QString &deviceId, const QVariantMap &info);
|
void selectPage(int index);
|
||||||
void updateTelemetry(const QString &deviceId, const QVariantList &joints,
|
void toggleConnection();
|
||||||
const QVariantMap &pose, const QVariantMap &state);
|
void updateConnection(bool connected, int latencyMs, const QString &detail);
|
||||||
void updateArmTelemetryHealth(const QString &deviceId, bool available,
|
void updateArmInfo(const QString &deviceId, const QVariantMap &info);
|
||||||
const QString &detail);
|
void updateTelemetry(const QString &deviceId, const QVariantList &joints,
|
||||||
void updateSystemStatus(double cpu, double memory, double disk,
|
const QVariantMap &pose, const QVariantMap &state);
|
||||||
const QVariantList &devices);
|
void updateArmTelemetryHealth(const QString &deviceId, bool available,
|
||||||
void updateSystemInfo(const QVariantMap &info);
|
const QString &detail);
|
||||||
void updateImage(const QImage &image, const QString &detail);
|
void updateSystemStatus(double cpu, double memory, double disk,
|
||||||
void updateVideoFrame(const QString &cameraId, const VideoFrame &frame,
|
const QVariantList &devices);
|
||||||
const QString &detail);
|
void updateSystemInfo(const QVariantMap &info);
|
||||||
void updateCameraStreamState(const QString &cameraId, bool running,
|
void updateImage(const QImage &image, const QString &detail);
|
||||||
const QString &detail);
|
void updateVideoFrame(const QString &cameraId, const VideoFrame &frame,
|
||||||
void updateCameraRecordingState(bool recording, const QString &detail);
|
const QString &detail);
|
||||||
void updateAgvState(const QVariantMap &state, const QVariantMap &navigation);
|
void updateCameraStreamState(const QString &cameraId, bool running,
|
||||||
void updateAgvInventory(const QStringList &maps, const QVariantList &stations);
|
const QString &detail);
|
||||||
void handleCommand(const QString &command, bool success, const QString &detail);
|
void updateCameraRecordingState(bool recording, const QString &detail);
|
||||||
void appendLog(const QString &level, const QString &message);
|
void updateAgvState(const QVariantMap &state, const QVariantMap &navigation);
|
||||||
void toggleQuicServer();
|
void updateAgvInventory(const QStringList &maps, const QVariantList &stations);
|
||||||
void updateQuicRunning(bool running, quint16 port, const QString &detail);
|
void handleCommand(const QString &command, bool success, const QString &detail);
|
||||||
void appendQuicLog(const QString &level, const QString &message);
|
void appendLog(const QString &level, const QString &message);
|
||||||
void sendMoveJ();
|
void toggleQuicServer();
|
||||||
void sendMoveJPose();
|
void updateQuicRunning(bool running, quint16 port, const QString &detail);
|
||||||
void saveSnapshot();
|
void appendQuicLog(const QString &level, const QString &message);
|
||||||
|
void sendMoveJ();
|
||||||
private:
|
void sendMoveJPose();
|
||||||
QWidget *createSystemPage();
|
void saveSnapshot();
|
||||||
QWidget *createArmPage();
|
|
||||||
QWidget *createCameraPage();
|
private:
|
||||||
QStringList configuredCameraIds() const;
|
QWidget *createSystemPage();
|
||||||
void rebuildCameraPreviewGrid(const QStringList &cameraIds);
|
QWidget *createArmPage();
|
||||||
void refreshCameraStreamControls();
|
QWidget *createCameraPage();
|
||||||
QWidget *createAgvPage();
|
QStringList configuredCameraIds() const;
|
||||||
QWidget *createAudioPage(bool speaker);
|
void rebuildCameraPreviewGrid(const QStringList &cameraIds);
|
||||||
QWidget *createRpcPage(const QString &serviceName);
|
void refreshCameraStreamControls();
|
||||||
QWidget *createQuicPage();
|
QWidget *createAgvPage();
|
||||||
QWidget *createDiagnosticsPage();
|
QWidget *createAudioPage(bool speaker);
|
||||||
void loadSettings();
|
QWidget *createRpcPage(const QString &serviceName);
|
||||||
void saveSettings();
|
QWidget *createQuicPage();
|
||||||
void setControlsEnabled(bool enabled);
|
QWidget *createDiagnosticsPage();
|
||||||
void updateWindowChrome();
|
void loadSettings();
|
||||||
void ensureArmModelLoaded();
|
void saveSettings();
|
||||||
void rebuildArmJointTables(const QStringList &jointNames);
|
void setControlsEnabled(bool enabled);
|
||||||
void rebuildArmJogControls();
|
void updateWindowChrome();
|
||||||
void setArmTelemetryEnabled(bool enabled);
|
void ensureArmModelLoaded();
|
||||||
void startJointJog(int jointIndex, int direction);
|
void rebuildArmJointTables(const QStringList &jointNames);
|
||||||
void startCartesianJog(int axisIndex, int direction);
|
void rebuildArmJogControls();
|
||||||
|
void startJointJog(int jointIndex, int direction);
|
||||||
|
void startCartesianJog(int axisIndex, int direction);
|
||||||
void stopArmJog();
|
void stopArmJog();
|
||||||
void startAgvManualMotion(double vx, double vy, double wz);
|
void refreshTcpChoices(const QString &savedName = QString());
|
||||||
void stopAgvManualMotion(bool sendStop = true);
|
void updateArmPoseFrames();
|
||||||
void restartAgvMapStream(const QString &mapName = QString());
|
bool selectedLocalTcp() const;
|
||||||
void updateArmAlert(const QString &deviceId, const QString &alertKey,
|
void setupHandEye();
|
||||||
const QString &level, const QString &summary,
|
void setupTouchOperation();
|
||||||
const QString &detail = QString());
|
void syncHandEyeContext();
|
||||||
QString endpoint() const;
|
void updateArmAlert(const QString &deviceId, const QString &alertKey,
|
||||||
|
const QString &level, const QString &summary,
|
||||||
|
const QString &detail = QString());
|
||||||
|
QString endpoint() const;
|
||||||
|
|
||||||
RobotClient *m_client = nullptr;
|
RobotClient *m_client = nullptr;
|
||||||
AudioStreamManager *m_audioManager = nullptr;
|
TcpCalibrationWidget *m_tcpCalibration = nullptr;
|
||||||
QuicTestServer *m_quicServer = nullptr;
|
TcpJogController *m_tcpJog = nullptr;
|
||||||
QStackedWidget *m_pages = nullptr;
|
HandEyeCalibrationWidget *m_handEye = nullptr;
|
||||||
QButtonGroup *m_navGroup = nullptr;
|
HandEyeMotionWidget *m_handEyeMotion = nullptr;
|
||||||
QList<QPushButton *> m_navButtons;
|
QString m_handEyeOwnedCamera;
|
||||||
|
TouchOperationWidget *m_touchOperation = nullptr;
|
||||||
QWidget *m_windowSurface = nullptr;
|
QString m_touchOwnedCamera;
|
||||||
QWidget *m_customTitleBar = nullptr;
|
QString m_tcpChoiceEndpoint, m_tcpChoiceDevice;
|
||||||
QLabel *m_titleBarPage = nullptr;
|
QStringList m_controllerTcpFrames;
|
||||||
QLabel *m_titleBarBuild = nullptr;
|
QLabel *m_armPoseSubtitle = nullptr;
|
||||||
QPushButton *m_minimizeWindowButton = nullptr;
|
AudioStreamManager *m_audioManager = nullptr;
|
||||||
QPushButton *m_maximizeWindowButton = nullptr;
|
QuicTestServer *m_quicServer = nullptr;
|
||||||
QPushButton *m_closeWindowButton = nullptr;
|
QStackedWidget *m_pages = nullptr;
|
||||||
QSize m_windowChromeSize;
|
QButtonGroup *m_navGroup = nullptr;
|
||||||
bool m_windowChromeInitialized = false;
|
QList<QPushButton *> m_navButtons;
|
||||||
bool m_windowChromeMaximized = false;
|
|
||||||
bool m_updatingWindowChrome = false;
|
QWidget *m_windowSurface = nullptr;
|
||||||
|
QWidget *m_customTitleBar = nullptr;
|
||||||
QLineEdit *m_hostEdit = nullptr;
|
QLabel *m_titleBarPage = nullptr;
|
||||||
QSpinBox *m_portSpin = nullptr;
|
QLabel *m_titleBarBuild = nullptr;
|
||||||
QCheckBox *m_demoCheck = nullptr;
|
QPushButton *m_minimizeWindowButton = nullptr;
|
||||||
QPushButton *m_connectButton = nullptr;
|
QPushButton *m_maximizeWindowButton = nullptr;
|
||||||
QLabel *m_connectionDot = nullptr;
|
QPushButton *m_closeWindowButton = nullptr;
|
||||||
QLabel *m_connectionText = nullptr;
|
QSize m_windowChromeSize;
|
||||||
QLabel *m_latencyLabel = nullptr;
|
bool m_windowChromeInitialized = false;
|
||||||
QLabel *m_pageTitle = nullptr;
|
bool m_windowChromeMaximized = false;
|
||||||
QLabel *m_pageSubtitle = nullptr;
|
bool m_updatingWindowChrome = false;
|
||||||
QHBoxLayout *m_headerLayout = nullptr;
|
|
||||||
QWidget *m_armHeaderControls = nullptr;
|
QLineEdit *m_hostEdit = nullptr;
|
||||||
QLabel *m_sidebarEndpointValue = nullptr;
|
QSpinBox *m_portSpin = nullptr;
|
||||||
QLabel *m_sidebarQuicValue = nullptr;
|
QCheckBox *m_demoCheck = nullptr;
|
||||||
QLabel *m_bottomLogLevel = nullptr;
|
QPushButton *m_connectButton = nullptr;
|
||||||
QLabel *m_bottomLogMessage = nullptr;
|
QLabel *m_connectionDot = nullptr;
|
||||||
QLabel *m_bottomVersion = nullptr;
|
QLabel *m_connectionText = nullptr;
|
||||||
|
QLabel *m_latencyLabel = nullptr;
|
||||||
QLabel *m_cpuValue = nullptr;
|
QLabel *m_pageTitle = nullptr;
|
||||||
QLabel *m_memoryValue = nullptr;
|
QLabel *m_pageSubtitle = nullptr;
|
||||||
QLabel *m_diskValue = nullptr;
|
QHBoxLayout *m_headerLayout = nullptr;
|
||||||
QLabel *m_deviceValue = nullptr;
|
QWidget *m_armHeaderControls = nullptr;
|
||||||
QLabel *m_systemNameValue = nullptr;
|
QLabel *m_sidebarEndpointValue = nullptr;
|
||||||
QLabel *m_systemVersionValue = nullptr;
|
QLabel *m_sidebarQuicValue = nullptr;
|
||||||
QLabel *m_systemOsValue = nullptr;
|
QLabel *m_bottomLogLevel = nullptr;
|
||||||
QLineEdit *m_systemTargetEdit = nullptr;
|
QLabel *m_bottomLogMessage = nullptr;
|
||||||
QPushButton *m_systemRefreshButton = nullptr;
|
QLabel *m_bottomVersion = nullptr;
|
||||||
QPushButton *m_systemStopButton = nullptr;
|
|
||||||
|
QLabel *m_cpuValue = nullptr;
|
||||||
QLineEdit *m_armIdEdit = nullptr;
|
QLabel *m_memoryValue = nullptr;
|
||||||
QComboBox *m_armSideCombo = nullptr;
|
QLabel *m_diskValue = nullptr;
|
||||||
QPushButton *m_armTelemetryButton = nullptr;
|
QLabel *m_deviceValue = nullptr;
|
||||||
QPushButton *m_armGlobalStopButton = nullptr;
|
QLabel *m_systemNameValue = nullptr;
|
||||||
QLabel *m_armDeviceSummary = nullptr;
|
QLabel *m_systemVersionValue = nullptr;
|
||||||
QLabel *m_servoStatusValue = nullptr;
|
QLabel *m_systemOsValue = nullptr;
|
||||||
QLabel *m_faultStatusValue = nullptr;
|
QLineEdit *m_systemTargetEdit = nullptr;
|
||||||
QList<QLabel *> m_poseMetricValues;
|
QPushButton *m_systemRefreshButton = nullptr;
|
||||||
TrendWidget *m_trend = nullptr;
|
QPushButton *m_systemStopButton = nullptr;
|
||||||
QTableWidget *m_jointTable = nullptr;
|
|
||||||
QTableWidget *m_motionTable = nullptr;
|
QLineEdit *m_armIdEdit = nullptr;
|
||||||
QList<QDoubleSpinBox *> m_targetSpins;
|
QComboBox *m_armSideCombo = nullptr;
|
||||||
QStringList m_activeArmJointNames;
|
QPushButton *m_armTelemetryButton = nullptr;
|
||||||
QTabWidget *m_motionCommandTabs = nullptr;
|
QPushButton *m_armGlobalStopButton = nullptr;
|
||||||
QList<QDoubleSpinBox *> m_moveJPoseSpins;
|
QLabel *m_armDeviceSummary = nullptr;
|
||||||
QComboBox *m_moveJPoseBaseLinkCombo = nullptr;
|
QLabel *m_servoStatusValue = nullptr;
|
||||||
QPushButton *m_copyCurrentPoseButton = nullptr;
|
QLabel *m_faultStatusValue = nullptr;
|
||||||
QVariantMap m_latestArmPose;
|
QList<QLabel *> m_poseMetricValues;
|
||||||
QString m_armDefaultBaseFrame;
|
TrendWidget *m_trend = nullptr;
|
||||||
QString m_armDefaultTcpFrame;
|
QTableWidget *m_jointTable = nullptr;
|
||||||
QTabWidget *m_jogModeTabs = nullptr;
|
QTableWidget *m_motionTable = nullptr;
|
||||||
QWidget *m_jointJogRowsHost = nullptr;
|
QList<QDoubleSpinBox *> m_targetSpins;
|
||||||
QVBoxLayout *m_jointJogRowsLayout = nullptr;
|
QStringList m_activeArmJointNames;
|
||||||
QList<QLabel *> m_jointJogPositionLabels;
|
QTabWidget *m_motionCommandTabs = nullptr;
|
||||||
QList<QSlider *> m_jointJogPositionSliders;
|
QList<QDoubleSpinBox *> m_moveJPoseSpins;
|
||||||
QList<QPushButton *> m_jointJogMinusButtons;
|
QComboBox *m_moveJPoseBaseLinkCombo = nullptr;
|
||||||
QList<QPushButton *> m_jointJogPlusButtons;
|
QPushButton *m_copyCurrentPoseButton = nullptr;
|
||||||
QList<QLabel *> m_cartesianJogPoseLabels;
|
QVariantMap m_latestArmPose;
|
||||||
QComboBox *m_baseFrameCombo = nullptr;
|
QString m_armDefaultBaseFrame;
|
||||||
QComboBox *m_tcpFrameCombo = nullptr;
|
QString m_armDefaultTcpFrame;
|
||||||
QSlider *m_jogSpeedSlider = nullptr;
|
QTabWidget *m_jogModeTabs = nullptr;
|
||||||
QLabel *m_jogSpeedValue = nullptr;
|
QWidget *m_jointJogRowsHost = nullptr;
|
||||||
QPushButton *m_jogStopButton = nullptr;
|
QVBoxLayout *m_jointJogRowsLayout = nullptr;
|
||||||
QHash<QString, double> m_previousJointVelocities;
|
QList<QLabel *> m_jointJogPositionLabels;
|
||||||
qint64 m_lastArmTelemetryMs = 0;
|
QList<QSlider *> m_jointJogPositionSliders;
|
||||||
QHash<QString, QString> m_armAlertStates;
|
QList<QPushButton *> m_jointJogMinusButtons;
|
||||||
QHash<QString, qint64> m_armLastAlertPopupMs;
|
QList<QPushButton *> m_jointJogPlusButtons;
|
||||||
bool m_armJogActive = false;
|
QList<QLabel *> m_cartesianJogPoseLabels;
|
||||||
QDoubleSpinBox *m_velocitySpin = nullptr;
|
QComboBox *m_baseFrameCombo = nullptr;
|
||||||
QDoubleSpinBox *m_accelerationSpin = nullptr;
|
QComboBox *m_tcpFrameCombo = nullptr;
|
||||||
QDoubleSpinBox *m_cartesianVelocitySpin = nullptr;
|
QSlider *m_jogSpeedSlider = nullptr;
|
||||||
QDoubleSpinBox *m_cartesianAccelerationSpin = nullptr;
|
QLabel *m_jogSpeedValue = nullptr;
|
||||||
QPushButton *m_sendMoveButton = nullptr;
|
QPushButton *m_jogStopButton = nullptr;
|
||||||
QPushButton *m_torqueOnButton = nullptr;
|
QHash<QString, double> m_previousJointVelocities;
|
||||||
QPushButton *m_torqueOffButton = nullptr;
|
qint64 m_lastArmTelemetryMs = 0;
|
||||||
QPushButton *m_clearFaultButton = nullptr;
|
QHash<QString, QString> m_armAlertStates;
|
||||||
QComboBox *m_zeroJointCombo = nullptr;
|
QHash<QString, qint64> m_armLastAlertPopupMs;
|
||||||
QPushButton *m_calibrateZeroButton = nullptr;
|
bool m_armJogActive = false;
|
||||||
QPushButton *m_stopButton = nullptr;
|
QDoubleSpinBox *m_velocitySpin = nullptr;
|
||||||
UrdfViewerWidget *m_urdfViewer = nullptr;
|
QDoubleSpinBox *m_accelerationSpin = nullptr;
|
||||||
QPushButton *m_teachModeButton = nullptr;
|
QDoubleSpinBox *m_cartesianVelocitySpin = nullptr;
|
||||||
QPushButton *m_teachRestoreButton = nullptr;
|
QDoubleSpinBox *m_cartesianAccelerationSpin = nullptr;
|
||||||
QPushButton *m_teachSendButton = nullptr;
|
QPushButton *m_sendMoveButton = nullptr;
|
||||||
QLabel *m_teachSelectedLabel = nullptr;
|
QPushButton *m_torqueOnButton = nullptr;
|
||||||
QDoubleSpinBox *m_teachPositionSpin = nullptr;
|
QPushButton *m_torqueOffButton = nullptr;
|
||||||
QTableWidget *m_teachJointTable = nullptr;
|
QPushButton *m_clearFaultButton = nullptr;
|
||||||
QString m_teachSelectedJoint;
|
QComboBox *m_zeroJointCombo = nullptr;
|
||||||
QString m_pendingUrdfPath;
|
QPushButton *m_calibrateZeroButton = nullptr;
|
||||||
bool m_armModelLoadScheduled = false;
|
QPushButton *m_stopButton = nullptr;
|
||||||
|
UrdfViewerWidget *m_urdfViewer = nullptr;
|
||||||
QLineEdit *m_cameraIdEdit = nullptr;
|
QPushButton *m_teachModeButton = nullptr;
|
||||||
VideoRenderWidget *m_videoRender = nullptr;
|
QPushButton *m_teachRestoreButton = nullptr;
|
||||||
QLabel *m_imageMetaLabel = nullptr;
|
QPushButton *m_teachSendButton = nullptr;
|
||||||
QPushButton *m_snapshotButton = nullptr;
|
QLabel *m_teachSelectedLabel = nullptr;
|
||||||
QPushButton *m_cameraStreamButton = nullptr;
|
QDoubleSpinBox *m_teachPositionSpin = nullptr;
|
||||||
QPushButton *m_saveImageButton = nullptr;
|
QTableWidget *m_teachJointTable = nullptr;
|
||||||
QComboBox *m_cameraCodecCombo = nullptr;
|
QString m_teachSelectedJoint;
|
||||||
QComboBox *m_cameraStreamModeCombo = nullptr;
|
QString m_pendingUrdfPath;
|
||||||
QLabel *m_cameraStreamStateLabel = nullptr;
|
bool m_armModelLoadScheduled = false;
|
||||||
QLineEdit *m_cameraRecordPathEdit = nullptr;
|
|
||||||
QPushButton *m_cameraRecordButton = nullptr;
|
QLineEdit *m_cameraIdEdit = nullptr;
|
||||||
QLabel *m_cameraRecordStateLabel = nullptr;
|
VideoRenderWidget *m_videoRender = nullptr;
|
||||||
QWidget *m_cameraPreviewContainer = nullptr;
|
QLabel *m_imageMetaLabel = nullptr;
|
||||||
QGridLayout *m_cameraPreviewGrid = nullptr;
|
QPushButton *m_snapshotButton = nullptr;
|
||||||
struct CameraPreviewTile {
|
QPushButton *m_cameraStreamButton = nullptr;
|
||||||
QWidget *container = nullptr;
|
QPushButton *m_saveImageButton = nullptr;
|
||||||
VideoRenderWidget *render = nullptr;
|
QComboBox *m_cameraCodecCombo = nullptr;
|
||||||
QLabel *status = nullptr;
|
QComboBox *m_cameraStreamModeCombo = nullptr;
|
||||||
QLabel *meta = nullptr;
|
QLabel *m_cameraStreamStateLabel = nullptr;
|
||||||
};
|
QLineEdit *m_cameraRecordPathEdit = nullptr;
|
||||||
QHash<QString, CameraPreviewTile> m_cameraPreviewTiles;
|
QPushButton *m_cameraRecordButton = nullptr;
|
||||||
QSet<QString> m_runningCameraIds;
|
QLabel *m_cameraRecordStateLabel = nullptr;
|
||||||
QImage m_lastImage;
|
QWidget *m_cameraPreviewContainer = nullptr;
|
||||||
bool m_cameraStreaming = false;
|
QGridLayout *m_cameraPreviewGrid = nullptr;
|
||||||
bool m_cameraRecording = false;
|
struct CameraPreviewTile {
|
||||||
|
QWidget *container = nullptr;
|
||||||
QLineEdit *m_agvIdEdit = nullptr;
|
VideoRenderWidget *render = nullptr;
|
||||||
QDialog *m_agvStatusDialog = nullptr;
|
QLabel *status = nullptr;
|
||||||
QTimer *m_agvStatusRefreshTimer = nullptr;
|
QLabel *meta = nullptr;
|
||||||
QTimer *m_agvManualVelocityTimer = nullptr;
|
};
|
||||||
QLabel *m_agvConnectionValue = nullptr;
|
QHash<QString, CameraPreviewTile> m_cameraPreviewTiles;
|
||||||
QLabel *m_agvPoseValue = nullptr;
|
QSet<QString> m_runningCameraIds;
|
||||||
QLabel *m_agvMotionValue = nullptr;
|
QImage m_lastImage;
|
||||||
QLabel *m_agvBatteryValue = nullptr;
|
bool m_cameraStreaming = false;
|
||||||
QLabel *m_agvMapValue = nullptr;
|
bool m_cameraRecording = false;
|
||||||
QLabel *m_agvNavigationValue = nullptr;
|
|
||||||
QLabel *m_agvErrorValue = nullptr;
|
QLineEdit *m_agvIdEdit = nullptr;
|
||||||
QLabel *m_agvModeValue = nullptr;
|
QDialog *m_agvStatusDialog = nullptr;
|
||||||
QLabel *m_agvMotionStateValue = nullptr;
|
QCheckBox *m_agvStatusSwitch = nullptr;
|
||||||
QLabel *m_agvSafetyValue = nullptr;
|
QTimer *m_agvStatusRefreshTimer = nullptr;
|
||||||
QLabel *m_agvPowerValue = nullptr;
|
QLabel *m_agvConnectionValue = nullptr;
|
||||||
QLabel *m_agvTimestampValue = nullptr;
|
QLabel *m_agvPoseValue = nullptr;
|
||||||
QLabel *m_agvMapOverview = nullptr;
|
QLabel *m_agvMotionValue = nullptr;
|
||||||
QLabel *m_agvMappingPreview = nullptr;
|
QLabel *m_agvBatteryValue = nullptr;
|
||||||
QLabel *m_agvMappingStateLabel = nullptr;
|
QLabel *m_agvMapValue = nullptr;
|
||||||
AgvMapViewWidget *m_agvMapView = nullptr;
|
QLabel *m_agvNavigationValue = nullptr;
|
||||||
QWidget *m_agvControlWorkspace = nullptr;
|
QLabel *m_agvErrorValue = nullptr;
|
||||||
QPushButton *m_agvDeleteMapButton = nullptr;
|
QLabel *m_agvModeValue = nullptr;
|
||||||
QProgressBar *m_agvProgress = nullptr;
|
QLabel *m_agvMotionStateValue = nullptr;
|
||||||
QDoubleSpinBox *m_agvXSpin = nullptr;
|
QLabel *m_agvSafetyValue = nullptr;
|
||||||
QDoubleSpinBox *m_agvYSpin = nullptr;
|
QLabel *m_agvPowerValue = nullptr;
|
||||||
QDoubleSpinBox *m_agvThetaSpin = nullptr;
|
QLabel *m_agvTimestampValue = nullptr;
|
||||||
QDoubleSpinBox *m_agvMaxSpeedSpin = nullptr;
|
QLabel *m_agvMapOverview = nullptr;
|
||||||
QDoubleSpinBox *m_agvVxSpin = nullptr;
|
QLabel *m_agvMappingPreview = nullptr;
|
||||||
QDoubleSpinBox *m_agvVySpin = nullptr;
|
QLabel *m_agvMappingStateLabel = nullptr;
|
||||||
QDoubleSpinBox *m_agvWzSpin = nullptr;
|
QProgressBar *m_agvProgress = nullptr;
|
||||||
QComboBox *m_agvMapCombo = nullptr;
|
QDoubleSpinBox *m_agvXSpin = nullptr;
|
||||||
QComboBox *m_agvStationCombo = nullptr;
|
QDoubleSpinBox *m_agvYSpin = nullptr;
|
||||||
QTableWidget *m_agvStationTable = nullptr;
|
QDoubleSpinBox *m_agvThetaSpin = nullptr;
|
||||||
QString m_agvDownloadPath;
|
QDoubleSpinBox *m_agvMaxSpeedSpin = nullptr;
|
||||||
QVariantMap m_latestAgvState;
|
QDoubleSpinBox *m_agvVxSpin = nullptr;
|
||||||
double m_agvManualVx = 0.0;
|
QDoubleSpinBox *m_agvVySpin = nullptr;
|
||||||
double m_agvManualVy = 0.0;
|
QDoubleSpinBox *m_agvWzSpin = nullptr;
|
||||||
double m_agvManualWz = 0.0;
|
QComboBox *m_agvMapCombo = nullptr;
|
||||||
bool m_agvManualMotionActive = false;
|
QComboBox *m_agvStationCombo = nullptr;
|
||||||
bool m_agvMapStreamActive = false;
|
QTableWidget *m_agvStationTable = nullptr;
|
||||||
QList<QPushButton *> m_serviceButtons;
|
QString m_agvDownloadPath;
|
||||||
QPushButton *m_speakerStreamStartButton = nullptr;
|
QList<QPushButton *> m_serviceButtons;
|
||||||
QPushButton *m_speakerStreamStopButton = nullptr;
|
QPushButton *m_speakerStreamStartButton = nullptr;
|
||||||
QPushButton *m_microphoneStreamStartButton = nullptr;
|
QPushButton *m_speakerStreamStopButton = nullptr;
|
||||||
QPushButton *m_microphoneStreamStopButton = nullptr;
|
QPushButton *m_microphoneStreamStartButton = nullptr;
|
||||||
QLineEdit *m_speakerIdEdit = nullptr;
|
QPushButton *m_microphoneStreamStopButton = nullptr;
|
||||||
QLineEdit *m_microphoneIdEdit = nullptr;
|
QLineEdit *m_speakerIdEdit = nullptr;
|
||||||
|
QLineEdit *m_microphoneIdEdit = nullptr;
|
||||||
QLineEdit *m_quicBindEdit = nullptr;
|
|
||||||
QSpinBox *m_quicPortSpin = nullptr;
|
QLineEdit *m_quicBindEdit = nullptr;
|
||||||
QLineEdit *m_quicAlpnEdit = nullptr;
|
QSpinBox *m_quicPortSpin = nullptr;
|
||||||
QLineEdit *m_quicCertificateEdit = nullptr;
|
QLineEdit *m_quicAlpnEdit = nullptr;
|
||||||
QLineEdit *m_quicPasswordEdit = nullptr;
|
QLineEdit *m_quicCertificateEdit = nullptr;
|
||||||
QPushButton *m_quicToggleButton = nullptr;
|
QLineEdit *m_quicPasswordEdit = nullptr;
|
||||||
QLabel *m_quicStateValue = nullptr;
|
QPushButton *m_quicToggleButton = nullptr;
|
||||||
QLabel *m_quicBoundValue = nullptr;
|
QLabel *m_quicStateValue = nullptr;
|
||||||
QLabel *m_quicClientValue = nullptr;
|
QLabel *m_quicBoundValue = nullptr;
|
||||||
QLabel *m_quicRegistrationValue = nullptr;
|
QLabel *m_quicClientValue = nullptr;
|
||||||
QLabel *m_quicHeartbeatValue = nullptr;
|
QLabel *m_quicRegistrationValue = nullptr;
|
||||||
QLabel *m_quicDatagramValue = nullptr;
|
QLabel *m_quicHeartbeatValue = nullptr;
|
||||||
QLabel *m_quicDatagramBytesValue = nullptr;
|
QLabel *m_quicDatagramValue = nullptr;
|
||||||
QLabel *m_quicNodeValue = nullptr;
|
QLabel *m_quicDatagramBytesValue = nullptr;
|
||||||
QLabel *m_quicBootValue = nullptr;
|
QLabel *m_quicNodeValue = nullptr;
|
||||||
QLabel *m_quicGrpcValue = nullptr;
|
QLabel *m_quicBootValue = nullptr;
|
||||||
QLabel *m_quicPeerValue = nullptr;
|
QLabel *m_quicGrpcValue = nullptr;
|
||||||
QTextEdit *m_quicLogView = nullptr;
|
QLabel *m_quicPeerValue = nullptr;
|
||||||
|
QTextEdit *m_quicLogView = nullptr;
|
||||||
QTextEdit *m_logView = nullptr;
|
|
||||||
QLabel *m_endpointValue = nullptr;
|
QTextEdit *m_logView = nullptr;
|
||||||
QLabel *m_backendValue = nullptr;
|
QLabel *m_endpointValue = nullptr;
|
||||||
QLabel *m_buildValue = nullptr;
|
QLabel *m_backendValue = nullptr;
|
||||||
bool m_connected = false;
|
QLabel *m_buildValue = nullptr;
|
||||||
};
|
bool m_connected = false;
|
||||||
|
};
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
7673
src/robotclient.cpp
7673
src/robotclient.cpp
File diff suppressed because it is too large
Load Diff
@ -1,206 +1,228 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QVariantList>
|
#include <QVariantList>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
|
||||||
#include "videoframe.h"
|
#include "videoframe.h"
|
||||||
|
|
||||||
class BackendWorker;
|
class BackendWorker;
|
||||||
|
|
||||||
class RobotClient : public QObject
|
class RobotClient : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RobotClient(QObject *parent = nullptr);
|
explicit RobotClient(QObject *parent = nullptr);
|
||||||
~RobotClient() override;
|
~RobotClient() override;
|
||||||
|
|
||||||
bool grpcAvailable() const;
|
bool grpcAvailable() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void connectToServer(const QString &host, int port, bool demoMode);
|
void connectToServer(const QString &host, int port, bool demoMode);
|
||||||
void disconnectFromServer();
|
void disconnectFromServer();
|
||||||
void setArmTelemetry(const QString &deviceId, bool enabled);
|
void setArmTelemetry(const QString &deviceId, bool enabled);
|
||||||
void requestArmInfo(const QString &deviceId);
|
void requestArmInfo(const QString &deviceId);
|
||||||
void requestArmFrames(const QString &deviceId);
|
void requestTcpCalibrationPose(const QString &deviceId, quint64 requestId);
|
||||||
void setArmTelemetryFrames(const QString &deviceId, const QString &baseFrame,
|
void requestTcpJogMove(const QString &deviceId, const QVariantMap &pose,
|
||||||
const QString &tcpFrame);
|
double velocity, double acceleration, quint64 token);
|
||||||
void requestSpeedJ(const QString &deviceId, const QVariantList &velocities,
|
void requestArmFrames(const QString &deviceId);
|
||||||
double acceleration, double duration);
|
void setArmTelemetryFrames(const QString &deviceId, const QString &baseFrame,
|
||||||
void requestSpeedL(const QString &deviceId, const QVariantMap &velocity,
|
const QString &tcpFrame);
|
||||||
double acceleration, double duration, bool toolFrame);
|
void requestSpeedJ(const QString &deviceId, const QVariantList &velocities,
|
||||||
void requestMoveJ(const QString &deviceId, const QVariantList &positions,
|
double acceleration, double duration);
|
||||||
double velocity, double acceleration);
|
void requestSpeedL(const QString &deviceId, const QVariantMap &velocity,
|
||||||
void requestMoveJPose(const QString &deviceId, const QVariantMap &pose,
|
double acceleration, double duration, bool toolFrame);
|
||||||
const QString &baseLink, const QString &eeLink,
|
void requestMoveJ(const QString &deviceId, const QVariantList &positions,
|
||||||
double velocity, double acceleration);
|
double velocity, double acceleration);
|
||||||
void requestTorque(const QString &deviceId, bool enabled);
|
void requestMoveJPose(const QString &deviceId, const QVariantMap &pose,
|
||||||
void requestArmStop(const QString &deviceId);
|
const QString &baseLink, const QString &eeLink,
|
||||||
void requestArmClearFault(const QString &deviceId);
|
double velocity, double acceleration);
|
||||||
void requestArmCalibrateZero(const QString &deviceId, const QString &jointName);
|
void requestTorque(const QString &deviceId, bool enabled);
|
||||||
void requestSnapshot(const QString &cameraId);
|
void requestArmStop(const QString &deviceId);
|
||||||
void startCameraStream(const QString &cameraId, const QString &codec,
|
void requestArmClearFault(const QString &deviceId);
|
||||||
const QString &mode = QStringLiteral("rgb"));
|
void requestArmCalibrateZero(const QString &deviceId, const QString &jointName);
|
||||||
void setCameraStreamCodec(const QString &codec);
|
void requestSnapshot(const QString &cameraId);
|
||||||
void stopCameraStream(const QString &cameraId = QString());
|
void requestHandEyeImage(const QString &cameraId, quint64 token);
|
||||||
void startCameraRecording(const QString &cameraId, const QString &videoPath);
|
void requestTouchRgbdImage(const QString &cameraId, quint64 token);
|
||||||
void stopCameraRecording(const QString &cameraId);
|
void startCameraStream(const QString &cameraId, const QString &codec,
|
||||||
void requestSystemRefresh();
|
const QString &mode = QStringLiteral("rgb"));
|
||||||
void requestSystemStopAll(const QString &deviceId);
|
void setCameraStreamCodec(const QString &codec);
|
||||||
void requestAgvRefresh(const QString &deviceId);
|
void stopCameraStream(const QString &cameraId = QString());
|
||||||
void requestAgvRelocalize(const QString &deviceId, double x, double y,
|
void startCameraRecording(const QString &cameraId, const QString &videoPath);
|
||||||
double theta);
|
void stopCameraRecording(const QString &cameraId);
|
||||||
void requestAgvNavigatePose(const QString &deviceId, double x, double y,
|
void requestSystemRefresh();
|
||||||
double theta, double maxSpeed);
|
void requestSystemStopAll(const QString &deviceId);
|
||||||
void requestAgvNavigateStation(const QString &deviceId, const QString &stationId,
|
void requestAgvRefresh(const QString &deviceId);
|
||||||
double maxSpeed);
|
void requestAgvNavigatePose(const QString &deviceId, double x, double y,
|
||||||
void requestAgvFollowPath(const QString &deviceId, const QVariantList &path,
|
double theta, double maxSpeed);
|
||||||
double maxSpeed);
|
void requestAgvNavigateStation(const QString &deviceId, const QString &stationId,
|
||||||
void requestAgvVelocity(const QString &deviceId, double vx, double vy, double wz);
|
double maxSpeed);
|
||||||
void requestAgvAction(const QString &deviceId, const QString &action);
|
void requestAgvFollowPath(const QString &deviceId, const QVariantList &path,
|
||||||
void requestAgvInventory(const QString &deviceId);
|
double maxSpeed);
|
||||||
void requestAgvSwitchMap(const QString &deviceId, const QString &mapName);
|
void requestAgvVelocity(const QString &deviceId, double vx, double vy, double wz);
|
||||||
void startAgvMapStream(const QString &deviceId, const QString &mapName,
|
void requestAgvAction(const QString &deviceId, const QString &action);
|
||||||
int dimension, bool snapshot, bool incremental);
|
void requestAgvInventory(const QString &deviceId);
|
||||||
void stopAgvMapStream();
|
void requestAgvSwitchMap(const QString &deviceId, const QString &mapName);
|
||||||
void requestRpc(const QString &serviceName, const QString &methodName,
|
void startAgvMapStream(const QString &deviceId, const QString &mapName,
|
||||||
const QString &requestJson, const QString &deviceId = QString());
|
int dimension, bool snapshot, bool incremental);
|
||||||
void startSpeakerAudioStream(const QString &deviceId);
|
void stopAgvMapStream();
|
||||||
void sendSpeakerAudioFrame(const QByteArray &data, int sampleRate, int channels,
|
void requestRpc(const QString &serviceName, const QString &methodName,
|
||||||
qint64 pts, int samples);
|
const QString &requestJson, const QString &deviceId = QString());
|
||||||
void stopSpeakerAudioStream();
|
void startSpeakerAudioStream(const QString &deviceId);
|
||||||
void startMicrophoneAudioStream(const QString &deviceId);
|
void sendSpeakerAudioFrame(const QByteArray &data, int sampleRate, int channels,
|
||||||
void stopMicrophoneAudioStream();
|
qint64 pts, int samples);
|
||||||
void connectConfigurationServer(const QString &host, int port);
|
void stopSpeakerAudioStream();
|
||||||
void disconnectConfigurationServer();
|
void startMicrophoneAudioStream(const QString &deviceId);
|
||||||
void requestConfigurationFiles();
|
void stopMicrophoneAudioStream();
|
||||||
void readConfigurationFile(const QString &relativePath);
|
void connectConfigurationServer(const QString &host, int port);
|
||||||
void validateConfigurationFile(const QString &relativePath, const QString &content);
|
void disconnectConfigurationServer();
|
||||||
void saveConfigurationFile(const QString &relativePath, const QString &content,
|
void requestConfigurationFiles();
|
||||||
const QString &expectedRevision);
|
void readConfigurationFile(const QString &relativePath);
|
||||||
|
void validateConfigurationFile(const QString &relativePath, const QString &content);
|
||||||
signals:
|
void saveConfigurationFile(const QString &relativePath, const QString &content,
|
||||||
void connectRequested(const QString &host, int port, bool demoMode);
|
const QString &expectedRevision);
|
||||||
void disconnectRequested();
|
|
||||||
void armTelemetryRequested(const QString &deviceId, bool enabled);
|
signals:
|
||||||
void armInfoRequested(const QString &deviceId);
|
// Synchronous arbitration before manual arm commands enter the worker queue.
|
||||||
void armFramesRequested(const QString &deviceId);
|
void armCommandStarting(const QString &deviceId);
|
||||||
void armTelemetryFramesRequested(const QString &deviceId, const QString &baseFrame,
|
// Emitted synchronously before a command that may select another active TCP.
|
||||||
const QString &tcpFrame);
|
void tcpReferenceInvalidated(const QString &deviceId);
|
||||||
void speedJRequested(const QString &deviceId, const QVariantList &velocities,
|
void connectRequested(const QString &host, int port, bool demoMode);
|
||||||
double acceleration, double duration);
|
void disconnectRequested();
|
||||||
void speedLRequested(const QString &deviceId, const QVariantMap &velocity,
|
void armTelemetryRequested(const QString &deviceId, bool enabled);
|
||||||
double acceleration, double duration, bool toolFrame);
|
void armInfoRequested(const QString &deviceId);
|
||||||
void moveJRequested(const QString &deviceId, const QVariantList &positions,
|
void tcpCalibrationPoseRequested(const QString &deviceId, quint64 requestId);
|
||||||
double velocity, double acceleration);
|
void tcpJogMoveRequested(const QString &deviceId, const QVariantMap &pose,
|
||||||
void moveJPoseRequested(const QString &deviceId, const QVariantMap &pose,
|
double velocity, double acceleration, quint64 token);
|
||||||
const QString &baseLink, const QString &eeLink,
|
void armFramesRequested(const QString &deviceId);
|
||||||
double velocity, double acceleration);
|
void armTelemetryFramesRequested(const QString &deviceId, const QString &baseFrame,
|
||||||
void torqueRequested(const QString &deviceId, bool enabled);
|
const QString &tcpFrame);
|
||||||
void armStopRequested(const QString &deviceId);
|
void speedJRequested(const QString &deviceId, const QVariantList &velocities,
|
||||||
void armClearFaultRequested(const QString &deviceId);
|
double acceleration, double duration);
|
||||||
void armCalibrateZeroRequested(const QString &deviceId, const QString &jointName);
|
void speedLRequested(const QString &deviceId, const QVariantMap &velocity,
|
||||||
void snapshotRequested(const QString &cameraId);
|
double acceleration, double duration, bool toolFrame);
|
||||||
void cameraStreamStartRequested(const QString &cameraId, const QString &codec,
|
void moveJRequested(const QString &deviceId, const QVariantList &positions,
|
||||||
const QString &mode);
|
double velocity, double acceleration);
|
||||||
void cameraStreamCodecRequested(const QString &codec);
|
void moveJPoseRequested(const QString &deviceId, const QVariantMap &pose,
|
||||||
void cameraStreamStopRequested(const QString &cameraId);
|
const QString &baseLink, const QString &eeLink,
|
||||||
void cameraRecordingStartRequested(const QString &cameraId, const QString &videoPath);
|
double velocity, double acceleration);
|
||||||
void cameraRecordingStopRequested(const QString &cameraId);
|
void torqueRequested(const QString &deviceId, bool enabled);
|
||||||
void systemRefreshRequested();
|
void armStopRequested(const QString &deviceId);
|
||||||
void systemStopAllRequested(const QString &deviceId);
|
void armClearFaultRequested(const QString &deviceId);
|
||||||
void agvRefreshRequested(const QString &deviceId);
|
void armCalibrateZeroRequested(const QString &deviceId, const QString &jointName);
|
||||||
void agvRelocalizeRequested(const QString &deviceId, double x, double y,
|
void snapshotRequested(const QString &cameraId);
|
||||||
double theta);
|
void handEyeImageRequested(const QString &cameraId, quint64 token);
|
||||||
void agvNavigatePoseRequested(const QString &deviceId, double x, double y,
|
void touchRgbdImageRequested(const QString &cameraId, quint64 token);
|
||||||
double theta, double maxSpeed);
|
void cameraStreamStartRequested(const QString &cameraId, const QString &codec,
|
||||||
void agvNavigateStationRequested(const QString &deviceId, const QString &stationId,
|
const QString &mode);
|
||||||
double maxSpeed);
|
void cameraStreamCodecRequested(const QString &codec);
|
||||||
void agvFollowPathRequested(const QString &deviceId, const QVariantList &path,
|
void cameraStreamStopRequested(const QString &cameraId);
|
||||||
double maxSpeed);
|
void cameraRecordingStartRequested(const QString &cameraId, const QString &videoPath);
|
||||||
void agvVelocityRequested(const QString &deviceId, double vx, double vy, double wz);
|
void cameraRecordingStopRequested(const QString &cameraId);
|
||||||
void agvActionRequested(const QString &deviceId, const QString &action);
|
void systemRefreshRequested();
|
||||||
void agvInventoryRequested(const QString &deviceId);
|
void systemStopAllRequested(const QString &deviceId);
|
||||||
void agvSwitchMapRequested(const QString &deviceId, const QString &mapName);
|
void agvRefreshRequested(const QString &deviceId);
|
||||||
void agvMapStreamStartRequested(const QString &deviceId, const QString &mapName,
|
void agvNavigatePoseRequested(const QString &deviceId, double x, double y,
|
||||||
int dimension, bool snapshot, bool incremental);
|
double theta, double maxSpeed);
|
||||||
void agvMapStreamStopRequested();
|
void agvNavigateStationRequested(const QString &deviceId, const QString &stationId,
|
||||||
void rpcRequested(const QString &serviceName, const QString &methodName,
|
double maxSpeed);
|
||||||
const QString &requestJson, const QString &deviceId);
|
void agvFollowPathRequested(const QString &deviceId, const QVariantList &path,
|
||||||
void speakerAudioStreamStartRequested(const QString &deviceId);
|
double maxSpeed);
|
||||||
void speakerAudioFrameRequested(const QByteArray &data, int sampleRate, int channels,
|
void agvVelocityRequested(const QString &deviceId, double vx, double vy, double wz);
|
||||||
qint64 pts, int samples);
|
void agvActionRequested(const QString &deviceId, const QString &action);
|
||||||
void speakerAudioStreamStopRequested();
|
void agvInventoryRequested(const QString &deviceId);
|
||||||
void microphoneAudioStreamStartRequested(const QString &deviceId);
|
void agvSwitchMapRequested(const QString &deviceId, const QString &mapName);
|
||||||
void microphoneAudioStreamStopRequested();
|
void agvMapStreamStartRequested(const QString &deviceId, const QString &mapName,
|
||||||
void configurationConnectRequested(const QString &host, int port);
|
int dimension, bool snapshot, bool incremental);
|
||||||
void configurationDisconnectRequested();
|
void agvMapStreamStopRequested();
|
||||||
void configurationFilesRequested();
|
void rpcRequested(const QString &serviceName, const QString &methodName,
|
||||||
void configurationFileReadRequested(const QString &relativePath);
|
const QString &requestJson, const QString &deviceId);
|
||||||
void configurationFileValidateRequested(const QString &relativePath,
|
void speakerAudioStreamStartRequested(const QString &deviceId);
|
||||||
const QString &content);
|
void speakerAudioFrameRequested(const QByteArray &data, int sampleRate, int channels,
|
||||||
void configurationFileSaveRequested(const QString &relativePath, const QString &content,
|
qint64 pts, int samples);
|
||||||
const QString &expectedRevision);
|
void speakerAudioStreamStopRequested();
|
||||||
|
void microphoneAudioStreamStartRequested(const QString &deviceId);
|
||||||
void connectionChanged(bool connected, int latencyMs, const QString &detail);
|
void microphoneAudioStreamStopRequested();
|
||||||
void armInfoReceived(const QString &deviceId, const QVariantMap &info);
|
void configurationConnectRequested(const QString &host, int port);
|
||||||
void armFramesReceived(const QString &deviceId, const QStringList &baseFrames,
|
void configurationDisconnectRequested();
|
||||||
const QStringList &tcpFrames);
|
void configurationFilesRequested();
|
||||||
void telemetryReceived(const QString &deviceId, const QVariantList &joints,
|
void configurationFileReadRequested(const QString &relativePath);
|
||||||
const QVariantMap &pose, const QVariantMap &state);
|
void configurationFileValidateRequested(const QString &relativePath,
|
||||||
void armTelemetryHealthChanged(const QString &deviceId, bool available,
|
const QString &content);
|
||||||
const QString &detail);
|
void configurationFileSaveRequested(const QString &relativePath, const QString &content,
|
||||||
void systemStatusReceived(double cpu, double memory, double disk,
|
const QString &expectedRevision);
|
||||||
const QVariantList &devices);
|
|
||||||
void systemInfoReceived(const QVariantMap &info);
|
void connectionChanged(bool connected, int latencyMs, const QString &detail);
|
||||||
void imageReceived(const QImage &image, const QString &detail);
|
void armInfoReceived(const QString &deviceId, const QVariantMap &info);
|
||||||
void videoFrameReceived(const QString &cameraId, const VideoFrame &frame,
|
// Raw active TCP in the driver's base frame; this is not a flange pose.
|
||||||
const QString &detail);
|
void tcpCalibrationPoseReceived(quint64 requestId, const QString &deviceId,
|
||||||
void cameraStreamStateChanged(const QString &cameraId, bool running,
|
const QVariantMap &pose, const QVariantMap &state,
|
||||||
const QString &detail);
|
bool success, const QString &detail);
|
||||||
void cameraRecordingStateChanged(bool recording, const QString &detail);
|
void armFramesReceived(const QString &deviceId, const QStringList &baseFrames,
|
||||||
void agvStateReceived(const QVariantMap &state, const QVariantMap &navigation);
|
const QStringList &tcpFrames);
|
||||||
void agvInventoryReceived(const QStringList &maps, const QVariantList &stations);
|
void telemetryReceived(const QString &deviceId, const QVariantList &joints,
|
||||||
void agvMapFrameReceived(const QImage &image, const QVariantMap &metadata,
|
const QVariantMap &pose, const QVariantMap &state);
|
||||||
const QString &detail);
|
void armTelemetryHealthChanged(const QString &deviceId, bool available,
|
||||||
void agvMapStreamStateChanged(bool running, const QString &detail);
|
const QString &detail);
|
||||||
void rpcFinished(const QString &serviceName, const QString &methodName,
|
void systemStatusReceived(double cpu, double memory, double disk,
|
||||||
bool success, const QString &responseJson);
|
const QVariantList &devices);
|
||||||
void audioStreamStateChanged(const QString &serviceName, bool running,
|
void systemInfoReceived(const QVariantMap &info);
|
||||||
const QString &detail);
|
void imageReceived(const QImage &image, const QString &detail);
|
||||||
void audioStreamStatistics(const QString &serviceName, quint64 frames,
|
// success validates image/intrinsics only. Pairing must additionally check
|
||||||
quint64 bytes, qint64 durationMs);
|
// metadata.captureTimestampAvailable and its captureUtcNs against robot poses.
|
||||||
void audioFrameReceived(const QByteArray &data, int sampleRate, int channels,
|
void handEyeImageReceived(quint64 token, const QString &cameraId,
|
||||||
int format, const QString &codec, qint64 pts, int samples);
|
const QImage &image, const QVariantMap &intrinsics,
|
||||||
void configurationConnectionChanged(bool connected, const QString &detail);
|
const QVariantMap &metadata, bool success,
|
||||||
void configurationFilesReceived(const QString &configRoot, const QVariantList &files,
|
const QString &detail);
|
||||||
bool success, const QString &detail);
|
void touchRgbdImageReceived(quint64 token, const QString &cameraId,
|
||||||
void configurationFileReceived(const QString &relativePath, const QString &content,
|
const QImage &image, const QVariantMap &intrinsics,
|
||||||
const QString &revision, const QString &messageType,
|
const QVariantMap &metadata, bool success, const QString &detail);
|
||||||
bool success, const QString &detail);
|
void videoFrameReceived(const QString &cameraId, const VideoFrame &frame,
|
||||||
void configurationValidationFinished(const QString &relativePath, bool success,
|
const QString &detail);
|
||||||
const QString &detail);
|
void cameraStreamStateChanged(const QString &cameraId, bool running,
|
||||||
void configurationSaveFinished(const QString &relativePath, const QString &revision,
|
const QString &detail);
|
||||||
bool success, const QString &detail);
|
void cameraRecordingStateChanged(bool recording, const QString &detail);
|
||||||
void commandFinished(const QString &command, bool success, const QString &detail);
|
void agvStateReceived(const QVariantMap &state, const QVariantMap &navigation);
|
||||||
void logMessage(const QString &level, const QString &message);
|
void agvInventoryReceived(const QStringList &maps, const QVariantList &stations);
|
||||||
|
void agvMapFrameReceived(const QImage &image, const QString &detail);
|
||||||
private:
|
void agvMapStreamStateChanged(bool running, const QString &detail);
|
||||||
QThread m_thread;
|
void rpcFinished(const QString &serviceName, const QString &methodName,
|
||||||
BackendWorker *m_worker = nullptr;
|
bool success, const QString &responseJson);
|
||||||
QMutex m_videoFrameMutex;
|
void audioStreamStateChanged(const QString &serviceName, bool running,
|
||||||
struct PendingVideoFrame {
|
const QString &detail);
|
||||||
VideoFrame frame;
|
void audioStreamStatistics(const QString &serviceName, quint64 frames,
|
||||||
QString detail;
|
quint64 bytes, qint64 durationMs);
|
||||||
};
|
void audioFrameReceived(const QByteArray &data, int sampleRate, int channels,
|
||||||
QHash<QString, PendingVideoFrame> m_pendingVideoFrames;
|
int format, const QString &codec, qint64 pts, int samples);
|
||||||
QSet<QString> m_videoFrameDeliveryScheduled;
|
void configurationConnectionChanged(bool connected, const QString &detail);
|
||||||
};
|
void configurationFilesReceived(const QString &configRoot, const QVariantList &files,
|
||||||
|
bool success, const QString &detail);
|
||||||
|
void configurationFileReceived(const QString &relativePath, const QString &content,
|
||||||
|
const QString &revision, const QString &messageType,
|
||||||
|
bool success, const QString &detail);
|
||||||
|
void configurationValidationFinished(const QString &relativePath, bool success,
|
||||||
|
const QString &detail);
|
||||||
|
void configurationSaveFinished(const QString &relativePath, const QString &revision,
|
||||||
|
bool success, const QString &detail);
|
||||||
|
void commandFinished(const QString &command, bool success, const QString &detail);
|
||||||
|
void logMessage(const QString &level, const QString &message);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QThread m_thread;
|
||||||
|
BackendWorker *m_worker = nullptr;
|
||||||
|
QMutex m_videoFrameMutex;
|
||||||
|
struct PendingVideoFrame {
|
||||||
|
VideoFrame frame;
|
||||||
|
QString detail;
|
||||||
|
};
|
||||||
|
QHash<QString, PendingVideoFrame> m_pendingVideoFrames;
|
||||||
|
QSet<QString> m_videoFrameDeliveryScheduled;
|
||||||
|
};
|
||||||
|
|||||||
599
src/tcpcalibrationwidget.cpp
Normal file
599
src/tcpcalibrationwidget.cpp
Normal file
@ -0,0 +1,599 @@
|
|||||||
|
#include "tcpcalibrationwidget.h"
|
||||||
|
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QDoubleSpinBox>
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QScrollArea>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QSignalBlocker>
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QtMath>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
QVBoxLayout *panel(QBoxLayout *parent, const QString &title)
|
||||||
|
{
|
||||||
|
auto *frame = new QFrame;
|
||||||
|
frame->setObjectName(QStringLiteral("panel"));
|
||||||
|
auto *layout = new QVBoxLayout(frame);
|
||||||
|
layout->setContentsMargins(14, 12, 14, 12);
|
||||||
|
layout->setSpacing(8);
|
||||||
|
auto *label = new QLabel(title);
|
||||||
|
label->setObjectName(QStringLiteral("sectionTitle"));
|
||||||
|
layout->addWidget(label);
|
||||||
|
parent->addWidget(frame);
|
||||||
|
return layout;
|
||||||
|
}
|
||||||
|
QLabel *hint(const QString &text)
|
||||||
|
{
|
||||||
|
auto *label = new QLabel(text);
|
||||||
|
label->setObjectName(QStringLiteral("mutedLabel"));
|
||||||
|
label->setWordWrap(true);
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
const char *keys[] = {"x", "y", "z", "rx", "ry", "rz"};
|
||||||
|
QString axis(int i) { return QString::fromLatin1(keys[i]).toUpper(); }
|
||||||
|
double fromDisplay(double value, int axisIndex)
|
||||||
|
{
|
||||||
|
return axisIndex < 3 ? value / 1000.0 : qDegreesToRadians(value);
|
||||||
|
}
|
||||||
|
double toDisplay(double value, int axisIndex)
|
||||||
|
{
|
||||||
|
return axisIndex < 3 ? value * 1000.0 : qRadiansToDegrees(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TcpCalibrationWidget::TcpCalibrationWidget(QWidget *parent) : QWidget(parent)
|
||||||
|
{
|
||||||
|
setObjectName(QStringLiteral("tcpCalibrationPage"));
|
||||||
|
buildUi();
|
||||||
|
m_captureTimer = new QTimer(this);
|
||||||
|
m_captureTimer->setSingleShot(true);
|
||||||
|
m_captureTimer->setInterval(6000);
|
||||||
|
connect(m_captureTimer, &QTimer::timeout, this, [this] {
|
||||||
|
if (m_pendingRow < 0) return;
|
||||||
|
++m_serial;
|
||||||
|
m_pendingRow = -1;
|
||||||
|
refresh();
|
||||||
|
reportError(QStringLiteral("读取实时位姿超时,请检查机械臂连接后重试"));
|
||||||
|
});
|
||||||
|
resizeSamples(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TcpCalibrationWidget::buildUi()
|
||||||
|
{
|
||||||
|
auto *outer = new QVBoxLayout(this);
|
||||||
|
outer->setContentsMargins(12, 10, 12, 10);
|
||||||
|
auto *scroll = new QScrollArea(this);
|
||||||
|
scroll->setWidgetResizable(true);
|
||||||
|
scroll->setFrameShape(QFrame::NoFrame);
|
||||||
|
auto *content = new QWidget;
|
||||||
|
auto *layout = new QVBoxLayout(content);
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
layout->setSpacing(10);
|
||||||
|
scroll->setWidget(content);
|
||||||
|
outer->addWidget(scroll);
|
||||||
|
|
||||||
|
auto *configuration = new QHBoxLayout;
|
||||||
|
configuration->setSpacing(10);
|
||||||
|
layout->addLayout(configuration);
|
||||||
|
auto *toolPanel = panel(configuration, QStringLiteral("工具信息"));
|
||||||
|
auto *toolGrid = new QGridLayout;
|
||||||
|
toolGrid->setHorizontalSpacing(12);
|
||||||
|
m_toolCombo = new QComboBox;
|
||||||
|
m_toolCombo->setObjectName(QStringLiteral("tcpLocalTools"));
|
||||||
|
m_toolCombo->addItem(QStringLiteral("新建工具"));
|
||||||
|
m_name = new QLineEdit;
|
||||||
|
m_name->setObjectName(QStringLiteral("tcpToolName"));
|
||||||
|
m_name->setMaxLength(80);
|
||||||
|
m_name->setPlaceholderText(QStringLiteral("输入工具名称"));
|
||||||
|
m_name->setToolTip(QStringLiteral("保存至当前机械臂,并同步至工具坐标列表。"));
|
||||||
|
m_reload = new QPushButton(QStringLiteral("刷新"));
|
||||||
|
m_delete = new QPushButton(QStringLiteral("删除"));
|
||||||
|
m_delete->setObjectName(QStringLiteral("tcpDelete"));
|
||||||
|
toolGrid->addWidget(new QLabel(QStringLiteral("工具")), 0, 0);
|
||||||
|
toolGrid->addWidget(m_toolCombo, 0, 1);
|
||||||
|
toolGrid->addWidget(new QLabel(QStringLiteral("名称")), 1, 0);
|
||||||
|
toolGrid->addWidget(m_name, 1, 1, 1, 3);
|
||||||
|
toolGrid->addWidget(m_reload, 0, 2);
|
||||||
|
toolGrid->addWidget(m_delete, 0, 3);
|
||||||
|
toolGrid->setColumnStretch(1, 1);
|
||||||
|
toolPanel->addLayout(toolGrid);
|
||||||
|
m_currentTool = hint(QStringLiteral("正在标定:新工具"));
|
||||||
|
toolPanel->addWidget(m_currentTool);
|
||||||
|
toolPanel->addStretch();
|
||||||
|
auto *sourcePanel = panel(configuration, QStringLiteral("控制器 TCP 偏移"));
|
||||||
|
sourcePanel->parentWidget()->setToolTip(QStringLiteral("与示教器当前活动 TCP 一致,用于还原法兰位姿。仅零偏移工具可填全零;采样期间不得切换。"));
|
||||||
|
configuration->setStretch(0,1); configuration->setStretch(1,1);
|
||||||
|
auto *sourceGrid = new QGridLayout;
|
||||||
|
for (int i = 0; i < 6; ++i) {
|
||||||
|
auto *spin = new QDoubleSpinBox;
|
||||||
|
spin->setObjectName(QStringLiteral("tcpSource%1").arg(i));
|
||||||
|
spin->setRange(i < 3 ? -10000 : -360, i < 3 ? 10000 : 360);
|
||||||
|
spin->setDecimals(4);
|
||||||
|
spin->setSuffix(i < 3 ? QStringLiteral(" mm") : QStringLiteral(" °"));
|
||||||
|
m_source.append(spin);
|
||||||
|
sourceGrid->addWidget(new QLabel(axis(i)), i/3, (i%3)*2);
|
||||||
|
sourceGrid->addWidget(spin, i/3, (i%3)*2+1);
|
||||||
|
sourceGrid->setColumnStretch((i%3)*2+1,1);
|
||||||
|
connect(spin, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
|
||||||
|
[this](double) { updateSource(); });
|
||||||
|
}
|
||||||
|
sourcePanel->addLayout(sourceGrid);
|
||||||
|
m_sourceConfirmed = new QCheckBox(QStringLiteral(
|
||||||
|
"已确认控制器 TCP 偏移"));
|
||||||
|
m_sourceConfirmed->setToolTip(QStringLiteral("RX/RY/RZ 为 ZYX 欧拉角,非旋转向量。偏移必须与控制器当前活动工具一致。"));
|
||||||
|
m_sourceConfirmed->setObjectName(QStringLiteral("tcpSourceConfirmed"));
|
||||||
|
sourcePanel->addWidget(m_sourceConfirmed);
|
||||||
|
connect(m_sourceConfirmed, &QCheckBox::toggled, this, [this](bool) {
|
||||||
|
resetCalibration();
|
||||||
|
refresh();
|
||||||
|
emit referenceChanged();
|
||||||
|
});
|
||||||
|
|
||||||
|
auto *pointsPanel = panel(layout, QStringLiteral("TCP 采样"));
|
||||||
|
m_instructions = hint(QString());
|
||||||
|
pointsPanel->addWidget(m_instructions);
|
||||||
|
auto *pointActions = new QHBoxLayout;
|
||||||
|
m_method = new QComboBox;
|
||||||
|
m_method->setObjectName(QStringLiteral("tcpCalibrationMethod"));
|
||||||
|
m_method->addItem(QStringLiteral("四点法"),QStringLiteral("four_point"));
|
||||||
|
m_method->addItem(QStringLiteral("六点法 · XZ"),QStringLiteral("six_point_xz"));
|
||||||
|
m_method->addItem(QStringLiteral("六点法 · XY"),QStringLiteral("six_point_xy"));
|
||||||
|
pointActions->addWidget(new QLabel(QStringLiteral("标定方式")));
|
||||||
|
pointActions->addWidget(m_method);
|
||||||
|
pointActions->addStretch();
|
||||||
|
auto *restart = new QPushButton(QStringLiteral("重新标定"));
|
||||||
|
restart->setObjectName(QStringLiteral("tcpClear"));
|
||||||
|
pointActions->addWidget(restart);
|
||||||
|
pointsPanel->addLayout(pointActions);
|
||||||
|
m_table = new QTableWidget(0, 10);
|
||||||
|
m_table->setObjectName(QStringLiteral("tcpSamples"));
|
||||||
|
m_table->setHorizontalHeaderLabels({QStringLiteral("点位"), QStringLiteral("状态"),
|
||||||
|
QStringLiteral("X mm"), QStringLiteral("Y mm"), QStringLiteral("Z mm"),
|
||||||
|
QStringLiteral("RX °"), QStringLiteral("RY °"), QStringLiteral("RZ °"),
|
||||||
|
QStringLiteral("残差 mm"), QStringLiteral("操作")});
|
||||||
|
m_table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
|
m_table->setSelectionMode(QAbstractItemView::NoSelection);
|
||||||
|
m_table->setAlternatingRowColors(true);
|
||||||
|
m_table->verticalHeader()->hide();
|
||||||
|
m_table->verticalHeader()->setDefaultSectionSize(36);
|
||||||
|
m_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||||
|
m_table->setMinimumHeight(180);
|
||||||
|
pointsPanel->addWidget(m_table);
|
||||||
|
connect(m_method, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this] {
|
||||||
|
resizeSamples(m_method->currentIndex()==0 ? 4 : 6);
|
||||||
|
for (auto *spin : m_orientation) spin->setValue(0);
|
||||||
|
});
|
||||||
|
connect(restart, &QPushButton::clicked, this, &TcpCalibrationWidget::resetCalibration);
|
||||||
|
|
||||||
|
auto *resultPanel = panel(layout, QStringLiteral("TCP 参数(相对法兰)"));
|
||||||
|
auto *resultGrid = new QGridLayout;
|
||||||
|
for (int i = 0; i < 6; ++i) {
|
||||||
|
auto *axisLabel = new QLabel(axis(i) + (i < 3 ? QStringLiteral(" mm") : QStringLiteral(" °(手动)")));
|
||||||
|
resultGrid->addWidget(axisLabel, 0, i);
|
||||||
|
if (i>=3) m_orientationLabels.append(axisLabel);
|
||||||
|
if (i < 3) {
|
||||||
|
auto *value = new QLabel(QStringLiteral("--"));
|
||||||
|
value->setObjectName(QStringLiteral("tcpResult%1").arg(i));
|
||||||
|
value->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||||
|
m_results.append(value);
|
||||||
|
resultGrid->addWidget(value, 1, i);
|
||||||
|
} else {
|
||||||
|
auto *spin = new QDoubleSpinBox;
|
||||||
|
spin->setObjectName(QStringLiteral("tcpOrientation%1").arg(i));
|
||||||
|
spin->setRange(-360, 360);
|
||||||
|
spin->setDecimals(4);
|
||||||
|
spin->setSuffix(QStringLiteral(" °"));
|
||||||
|
m_orientation.append(spin);
|
||||||
|
resultGrid->addWidget(spin, 1, i);
|
||||||
|
connect(spin, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
|
||||||
|
[this](double) { refresh(); });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resultPanel->addLayout(resultGrid);
|
||||||
|
for (auto *spin : m_orientation) spin->setToolTip(QStringLiteral("固定点法仅求解平移;工具姿态需手动设置,采用 ZYX 欧拉角。"));
|
||||||
|
m_rms = new QLabel(QStringLiteral("固定点 RMS:--(合格上限 2.000 mm)"));
|
||||||
|
m_rms->setObjectName(QStringLiteral("tcpRms"));
|
||||||
|
resultPanel->addWidget(m_rms);
|
||||||
|
m_preview = hint(QStringLiteral("基座下工具位姿:--"));
|
||||||
|
m_preview->setObjectName(QStringLiteral("tcpToolPreview"));
|
||||||
|
resultPanel->addWidget(m_preview);
|
||||||
|
auto *actions = new QHBoxLayout;
|
||||||
|
m_status = hint(QStringLiteral("等待采样"));
|
||||||
|
m_status->setObjectName(QStringLiteral("tcpStatus"));
|
||||||
|
actions->addWidget(m_status, 1);
|
||||||
|
m_calculate = new QPushButton(QStringLiteral("TCP 标定"));
|
||||||
|
m_calculate->setObjectName(QStringLiteral("primaryButton"));
|
||||||
|
m_calculate->setProperty("tcpAction", QStringLiteral("calculate"));
|
||||||
|
m_save = new QPushButton(QStringLiteral("保存工具"));
|
||||||
|
m_save->setObjectName(QStringLiteral("tcpSave"));
|
||||||
|
actions->addWidget(m_calculate);
|
||||||
|
actions->addWidget(m_save);
|
||||||
|
outer->addLayout(actions);
|
||||||
|
layout->addStretch();
|
||||||
|
connect(m_calculate, &QPushButton::clicked, this, &TcpCalibrationWidget::calculate);
|
||||||
|
connect(m_save, &QPushButton::clicked, this, &TcpCalibrationWidget::saveTool);
|
||||||
|
connect(m_name, &QLineEdit::textChanged, this, [this](const QString &) { refresh(); });
|
||||||
|
connect(m_toolCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &TcpCalibrationWidget::selectTool);
|
||||||
|
connect(m_reload, &QPushButton::clicked, this, [this] { reloadTools(); });
|
||||||
|
connect(m_delete, &QPushButton::clicked, this, &TcpCalibrationWidget::deleteTool);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TcpCalibrationWidget::setContext(const QString &endpoint, const QString &deviceId,
|
||||||
|
bool connected, bool demoMode)
|
||||||
|
{
|
||||||
|
const bool identityChanged = endpoint != m_endpoint || deviceId != m_device;
|
||||||
|
const bool sessionChanged = connected != m_connected || demoMode != m_demo;
|
||||||
|
m_endpoint = endpoint;
|
||||||
|
m_device = deviceId;
|
||||||
|
m_connected = connected;
|
||||||
|
m_demo = demoMode;
|
||||||
|
if (identityChanged || sessionChanged) {
|
||||||
|
const QSignalBlocker blocker(m_sourceConfirmed);
|
||||||
|
m_sourceConfirmed->setChecked(false);
|
||||||
|
resetCalibration();
|
||||||
|
if (identityChanged) {
|
||||||
|
m_loading = true;
|
||||||
|
for (auto *spin : m_source) spin->setValue(0);
|
||||||
|
m_loading = false;
|
||||||
|
}
|
||||||
|
reloadTools();
|
||||||
|
}
|
||||||
|
refresh();
|
||||||
|
emit referenceChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TcpCalibrationWidget::referenceConfirmed() const
|
||||||
|
{
|
||||||
|
return m_connected && !m_demo && !m_device.trimmed().isEmpty() && m_sourceConfirmed->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TcpCalibrationWidget::invalidateReference()
|
||||||
|
{
|
||||||
|
const QSignalBlocker blocker(m_sourceConfirmed);
|
||||||
|
m_sourceConfirmed->setChecked(false);
|
||||||
|
resetCalibration();
|
||||||
|
emit referenceChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TcpCalibrationWidget::hasSamples() const
|
||||||
|
{
|
||||||
|
for (const auto &sample : m_samples) if (sample.captured) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
void TcpCalibrationWidget::invalidateResult()
|
||||||
|
{
|
||||||
|
m_resultValid = false;
|
||||||
|
m_loadedResult = false;
|
||||||
|
m_result = TcpCalibration::Result{};
|
||||||
|
for (auto *label : m_results) label->setText(QStringLiteral("--"));
|
||||||
|
m_rms->setText(QStringLiteral("固定点 RMS:--(合格上限 2.000 mm)"));
|
||||||
|
m_preview->setText(QStringLiteral("基座下工具位姿:--"));
|
||||||
|
}
|
||||||
|
void TcpCalibrationWidget::resetCalibration()
|
||||||
|
{
|
||||||
|
++m_serial;
|
||||||
|
m_pendingRow = -1;
|
||||||
|
if (m_captureTimer) m_captureTimer->stop();
|
||||||
|
for (auto &sample : m_samples) sample = Sample{};
|
||||||
|
invalidateResult();
|
||||||
|
refresh();
|
||||||
|
emit logMessage(QStringLiteral("INFO"), QStringLiteral("TCP 标定临时采样已重置,已保存工具保持不变"));
|
||||||
|
}
|
||||||
|
void TcpCalibrationWidget::resizeSamples(int count)
|
||||||
|
{
|
||||||
|
++m_serial;
|
||||||
|
m_pendingRow = -1;
|
||||||
|
if (m_captureTimer) m_captureTimer->stop();
|
||||||
|
m_samples.assign(size_t(count),Sample{});
|
||||||
|
invalidateResult();
|
||||||
|
m_table->setRowCount(count);
|
||||||
|
m_table->setMinimumHeight(count*36+40);
|
||||||
|
for (int row = 0; row < count; ++row) {
|
||||||
|
for (int col = 0; col < 9; ++col)
|
||||||
|
if (!m_table->item(row, col)) m_table->setItem(row, col, new QTableWidgetItem);
|
||||||
|
if (!m_table->cellWidget(row, 9)) {
|
||||||
|
auto *button = new QPushButton(QStringLiteral("采集"));
|
||||||
|
button->setObjectName(QStringLiteral("tcpCapture%1").arg(row));
|
||||||
|
m_table->setCellWidget(row, 9, button);
|
||||||
|
connect(button, &QPushButton::clicked, this, [this, row] { capture(row); });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
TcpCalibration::Pose TcpCalibrationWidget::serverOffset() const
|
||||||
|
{
|
||||||
|
TcpCalibration::Pose pose{};
|
||||||
|
for (int i = 0; i < 6; ++i) pose[size_t(i)] = fromDisplay(m_source.at(i)->value(), i);
|
||||||
|
return pose;
|
||||||
|
}
|
||||||
|
void TcpCalibrationWidget::updateSource()
|
||||||
|
{
|
||||||
|
if (m_loading) return;
|
||||||
|
const QSignalBlocker blocker(m_sourceConfirmed);
|
||||||
|
m_sourceConfirmed->setChecked(false);
|
||||||
|
resetCalibration();
|
||||||
|
emit referenceChanged();
|
||||||
|
}
|
||||||
|
void TcpCalibrationWidget::refresh()
|
||||||
|
{
|
||||||
|
if (!m_table) return;
|
||||||
|
int captured = 0;
|
||||||
|
const bool busy = m_pendingRow >= 0;
|
||||||
|
const bool six = m_method->currentIndex()>0;
|
||||||
|
const bool xz = m_method->currentData().toString()=="six_point_xz";
|
||||||
|
m_instructions->setText(six
|
||||||
|
? QStringLiteral("1–3:固定尖端位置并改变姿态;4:方向原点;5:+X;6:+%1。后三点保持相同姿态。").arg(xz?"Z":"Y")
|
||||||
|
: QStringLiteral("保持尖端位置不变,以四个不同姿态采样;工具方向手动设置。"));
|
||||||
|
m_instructions->setToolTip(six ? QStringLiteral("方向点从原点沿所需工具正轴平移,返回原点姿态后采下一轴。程序不会自动移动机器人。最小方向基线 10 mm;建议在安全行程内增加基线。") : QString());
|
||||||
|
const bool ready = m_connected && !m_demo && !m_device.trimmed().isEmpty()
|
||||||
|
&& m_sourceConfirmed->isChecked() && !busy;
|
||||||
|
for (int row = 0; row < int(m_samples.size()); ++row) {
|
||||||
|
const auto &sample = m_samples[size_t(row)];
|
||||||
|
captured += sample.captured;
|
||||||
|
const QString purpose=!six ? QStringLiteral("固定点") : row<3 ? QStringLiteral("接近点")
|
||||||
|
: row==3 ? QStringLiteral("方向原点") : row==4 ? QStringLiteral("+X") : xz?QStringLiteral("+Z"):QStringLiteral("+Y");
|
||||||
|
m_table->item(row, 0)->setText(QStringLiteral("%1 · %2").arg(row+1).arg(purpose));
|
||||||
|
m_table->item(row, 1)->setText(row == m_pendingRow ? QStringLiteral("读取中")
|
||||||
|
: sample.captured ? QStringLiteral("已采集") : QStringLiteral("未采集"));
|
||||||
|
for (int i = 0; i < 6; ++i) m_table->item(row, 2 + i)->setText(sample.captured
|
||||||
|
? QString::number(toDisplay(sample.flange[size_t(i)], i), 'f', 3) : QStringLiteral("--"));
|
||||||
|
m_table->item(row, 8)->setText(m_resultValid && !m_loadedResult
|
||||||
|
&& row < int(m_result.residualsMm.size())
|
||||||
|
? QString::number(m_result.residualsMm[size_t(row)], 'f', 3) : QStringLiteral("--"));
|
||||||
|
auto *button = qobject_cast<QPushButton *>(m_table->cellWidget(row, 9));
|
||||||
|
button->setText(sample.captured ? QStringLiteral("重新采集") : QStringLiteral("采集"));
|
||||||
|
button->setEnabled(ready);
|
||||||
|
}
|
||||||
|
m_method->setEnabled(!busy);
|
||||||
|
for (int i=0;i<m_orientation.size();++i) {
|
||||||
|
m_orientation[i]->setReadOnly(six); m_orientation[i]->setButtonSymbols(six?QAbstractSpinBox::NoButtons:QAbstractSpinBox::UpDownArrows);
|
||||||
|
m_orientationLabels[i]->setText(axis(i+3)+(six?QStringLiteral(" °(计算)"):QStringLiteral(" °(手动)")));
|
||||||
|
m_orientation[i]->setToolTip(six?QStringLiteral("由方向原点、+X 与第二方向点计算,ZYX 欧拉角。"):QStringLiteral("四点法仅求平移;工具方向手动设置,ZYX 欧拉角。"));
|
||||||
|
}
|
||||||
|
m_toolCombo->setEnabled(!busy);
|
||||||
|
m_name->setEnabled(!busy);
|
||||||
|
m_reload->setEnabled(!busy && !m_device.isEmpty());
|
||||||
|
m_delete->setEnabled(!busy && m_toolCombo->currentIndex() > 0);
|
||||||
|
for (auto *spin : m_source) spin->setEnabled(!busy);
|
||||||
|
m_sourceConfirmed->setEnabled(!busy && m_connected && !m_demo);
|
||||||
|
m_calculate->setEnabled(!busy && captured >= 4 && captured == int(m_samples.size()));
|
||||||
|
m_save->setEnabled(!busy && m_resultValid && m_result.rmsMm <= 2.0
|
||||||
|
&& !m_name->text().trimmed().isEmpty());
|
||||||
|
m_status->setText(busy ? QStringLiteral("正在读取真实位姿…") : m_resultValid
|
||||||
|
? (m_result.rmsMm > 2.0 ? QStringLiteral("误差超限,禁止保存,请重新采样")
|
||||||
|
: m_loadedResult ? (six ? QStringLiteral("已加载六点标定结果") : QStringLiteral("已加载标定结果,可修改名称或手动方向"))
|
||||||
|
: QStringLiteral("已计算,尚未保存"))
|
||||||
|
: QStringLiteral("已采集 %1 / %2 点%3").arg(captured).arg(m_samples.size())
|
||||||
|
.arg(!m_sourceConfirmed->isChecked() ? QStringLiteral(" · 请先核对活动 TCP 偏移") : QString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TcpCalibrationWidget::capture(int index)
|
||||||
|
{
|
||||||
|
if (index < 0 || index >= int(m_samples.size()) || m_pendingRow >= 0) return;
|
||||||
|
if (!m_connected || m_demo || !m_sourceConfirmed->isChecked() || m_device.isEmpty()) {
|
||||||
|
reportError(QStringLiteral("请连接真实机械臂并核对服务端活动 TCP 偏移"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
invalidateResult();
|
||||||
|
// A failed replacement must not silently reuse the previous observation.
|
||||||
|
m_samples[size_t(index)] = Sample{};
|
||||||
|
m_pendingRow = index;
|
||||||
|
++m_serial;
|
||||||
|
m_captureTimer->start();
|
||||||
|
refresh();
|
||||||
|
emit captureRequested(m_device, m_serial);
|
||||||
|
}
|
||||||
|
bool TcpCalibrationWidget::readPose(const QVariantMap &map, TcpCalibration::Pose &pose) const
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 6; ++i) {
|
||||||
|
const QString name = QString::fromLatin1(keys[i]);
|
||||||
|
bool ok = false;
|
||||||
|
pose[size_t(i)] = map.value(name).toDouble(&ok);
|
||||||
|
if (!map.contains(name) || !ok || !std::isfinite(pose[size_t(i)])) return false;
|
||||||
|
}
|
||||||
|
return TcpCalibration::validPose(pose);
|
||||||
|
}
|
||||||
|
void TcpCalibrationWidget::acceptPose(quint64 requestId, const QString &deviceId,
|
||||||
|
const QVariantMap &pose, const QVariantMap &state,
|
||||||
|
bool success, const QString &detail)
|
||||||
|
{
|
||||||
|
if (requestId != m_serial || deviceId != m_device || m_pendingRow < 0) return;
|
||||||
|
const int row = m_pendingRow;
|
||||||
|
m_pendingRow = -1;
|
||||||
|
m_captureTimer->stop();
|
||||||
|
if (!success) { refresh(); reportError(detail); return; }
|
||||||
|
if (!m_connected || m_demo || !m_sourceConfirmed->isChecked()
|
||||||
|
|| !state.value(QStringLiteral("connected")).toBool()
|
||||||
|
|| state.value(QStringLiteral("moving"), true).toBool()
|
||||||
|
|| state.value(QStringLiteral("fault"), true).toBool()) {
|
||||||
|
refresh(); reportError(QStringLiteral("机械臂状态不可用于采点,请停稳并重新核对")); return;
|
||||||
|
}
|
||||||
|
TcpCalibration::Pose tcp{}, flange{};
|
||||||
|
QString error;
|
||||||
|
if (!readPose(pose, tcp) || !TcpCalibration::flangePose(tcp, serverOffset(), flange, &error)) {
|
||||||
|
refresh(); reportError(QStringLiteral("位姿数据无效:%1").arg(error)); return;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < int(m_samples.size()); ++i) {
|
||||||
|
// Direction origin may legitimately repeat one of the position poses.
|
||||||
|
if (m_method->currentIndex()>0 && ((i<3)!=(row<3))) continue;
|
||||||
|
if (i != row && m_samples[size_t(i)].captured
|
||||||
|
&& TcpCalibration::tooSimilar(m_samples[size_t(i)].flange, flange)) {
|
||||||
|
refresh(); reportError(QStringLiteral("与点位 %1 姿态过于接近,请改变腕部姿态后采集").arg(i + 1)); return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_samples[size_t(row)].flange = flange;
|
||||||
|
m_samples[size_t(row)].captured = true;
|
||||||
|
if (m_toolCombo->currentIndex() > 0 && m_toolCombo->currentIndex() <= m_tools.tools.size()) {
|
||||||
|
TcpCalibration::Pose preview{};
|
||||||
|
if (TcpCalibration::toolPose(flange, m_tools.tools.at(m_toolCombo->currentIndex() - 1).offset, preview)) {
|
||||||
|
QStringList values;
|
||||||
|
for (int i = 0; i < 6; ++i) values << QString::number(toDisplay(preview[size_t(i)], i), 'f', 3);
|
||||||
|
m_preview->setText(QStringLiteral("基座下工具位姿(mm / °):%1").arg(values.join(QStringLiteral(", "))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
refresh();
|
||||||
|
emit logMessage(QStringLiteral("OK"), QStringLiteral("TCP 点位 %1 已采集 · %2 · 法兰位姿 m/rad,活动 TCP 偏移已换算")
|
||||||
|
.arg(row + 1).arg(m_device));
|
||||||
|
}
|
||||||
|
void TcpCalibrationWidget::calculate()
|
||||||
|
{
|
||||||
|
std::vector<TcpCalibration::Pose> poses;
|
||||||
|
for (const auto &sample : m_samples) {
|
||||||
|
if (!sample.captured) { reportError(QStringLiteral("请先完成所有点位采集")); return; }
|
||||||
|
poses.push_back(sample.flange);
|
||||||
|
}
|
||||||
|
invalidateResult();
|
||||||
|
QString error;
|
||||||
|
const bool solved=m_method->currentIndex()==0 ? TcpCalibration::solve(poses,m_result,&error)
|
||||||
|
: TcpCalibration::solveSixPoint(poses,m_method->currentData().toString()=="six_point_xz"
|
||||||
|
? TcpCalibration::DirectionMethod::XZ : TcpCalibration::DirectionMethod::XY,m_result,&error);
|
||||||
|
if (!solved) {
|
||||||
|
refresh(); reportError(error); return;
|
||||||
|
}
|
||||||
|
m_resultValid = true;
|
||||||
|
showResult(m_result.offset, m_result.rmsMm, false);
|
||||||
|
refresh();
|
||||||
|
emit logMessage(m_result.rmsMm <= 2.0 ? QStringLiteral("OK") : QStringLiteral("WARN"),
|
||||||
|
QStringLiteral("TCP 计算完成,%1 点,RMS %2 mm%3").arg(poses.size())
|
||||||
|
.arg(m_result.rmsMm, 0, 'f', 3)
|
||||||
|
.arg(m_result.rmsMm > 2.0 ? QStringLiteral(",超过 2 mm,禁止保存") : QString()));
|
||||||
|
}
|
||||||
|
void TcpCalibrationWidget::showResult(const TcpCalibration::Pose &offset, double rmsMm, bool loaded)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 3; ++i) m_results.at(i)->setText(QString::number(offset[size_t(i)] * 1000, 'f', 3));
|
||||||
|
if (m_method->currentIndex()>0)
|
||||||
|
for (int i=0;i<3;++i) m_orientation[i]->setValue(qRadiansToDegrees(offset[size_t(i+3)]));
|
||||||
|
m_rms->setText(QStringLiteral("固定点 RMS:%1 mm · %2%3").arg(rmsMm, 0, 'f', 3)
|
||||||
|
.arg(rmsMm <= 2.0 ? QStringLiteral("合格(≤ 2.000 mm)") : QStringLiteral("超限,禁止保存"))
|
||||||
|
.arg(loaded ? QStringLiteral(" · 已保存结果") : QString()));
|
||||||
|
}
|
||||||
|
void TcpCalibrationWidget::reportError(const QString &message)
|
||||||
|
{
|
||||||
|
emit logMessage(QStringLiteral("ERROR"), QStringLiteral("TCP 标定:%1").arg(message));
|
||||||
|
QMessageBox::warning(this, QStringLiteral("工具坐标标定"), message);
|
||||||
|
}
|
||||||
|
void TcpCalibrationWidget::saveTool()
|
||||||
|
{
|
||||||
|
if (!m_resultValid || !std::isfinite(m_result.rmsMm) || m_result.rmsMm > 2.0) {
|
||||||
|
reportError(QStringLiteral("请先得到 RMS 不超过 2 mm 的有效标定结果")); return;
|
||||||
|
}
|
||||||
|
TcpToolStore::Tool tool;
|
||||||
|
tool.name = m_name->text().trimmed();
|
||||||
|
tool.offset = m_result.offset;
|
||||||
|
if (m_method->currentIndex()==0)
|
||||||
|
for (int i = 0; i < 3; ++i) tool.offset[size_t(i + 3)] = qDegreesToRadians(m_orientation.at(i)->value());
|
||||||
|
tool.rmsMm = m_result.rmsMm;
|
||||||
|
tool.sampleCount = m_loadedResult ? m_loadedSampleCount : int(m_samples.size());
|
||||||
|
tool.method = m_loadedResult ? m_loadedMethod : m_method->currentData().toString();
|
||||||
|
bool replace = false;
|
||||||
|
for (const auto &saved : m_tools.tools) if (saved.name == tool.name) replace = true;
|
||||||
|
if (replace && QMessageBox::question(this, QStringLiteral("覆盖工具"),
|
||||||
|
QStringLiteral("当前机械臂的工具“%1”已存在,是否覆盖?").arg(tool.name),
|
||||||
|
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes) return;
|
||||||
|
QSettings settings;
|
||||||
|
QString error;
|
||||||
|
// TODO(controller TCP): ArmService currently has only ListTCPFrame;
|
||||||
|
// there is no Get/Set/Create/Delete TCP-offset RPC to call or verify.
|
||||||
|
// Keep local records distinct until actual persistent controller APIs exist.
|
||||||
|
if (!TcpToolStore::save(settings, m_endpoint, m_device, tool, replace, error)) {
|
||||||
|
reportError(error); return;
|
||||||
|
}
|
||||||
|
reloadTools(tool.name);
|
||||||
|
emit toolsChanged(m_endpoint, m_device, tool.name);
|
||||||
|
emit logMessage(QStringLiteral("OK"), QStringLiteral("TCP 本机工具“%1”已保存 · %2 / %3")
|
||||||
|
.arg(tool.name, m_endpoint, m_device));
|
||||||
|
QMessageBox::information(this, QStringLiteral("保存成功"),
|
||||||
|
QStringLiteral("已保存到当前机器人的工具配置,并同步到机械臂的工具坐标列表。选择该工具后可进行 TCP 点动。"));
|
||||||
|
}
|
||||||
|
void TcpCalibrationWidget::reloadTools(const QString &preferred)
|
||||||
|
{
|
||||||
|
if (m_device.trimmed().isEmpty() || m_endpoint.trimmed().isEmpty()) {
|
||||||
|
m_tools = TcpToolStore::Snapshot{};
|
||||||
|
const QSignalBlocker blocker(m_toolCombo);
|
||||||
|
m_toolCombo->clear();
|
||||||
|
m_toolCombo->addItem(QStringLiteral("新建工具"));
|
||||||
|
selectTool(0);
|
||||||
|
m_currentTool->setText(QStringLiteral("请先选择机械臂"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QSettings settings;
|
||||||
|
QString error;
|
||||||
|
TcpToolStore::Snapshot snapshot;
|
||||||
|
if (!TcpToolStore::load(settings, m_endpoint, m_device, snapshot, error)) {
|
||||||
|
emit logMessage(QStringLiteral("ERROR"), error);
|
||||||
|
m_currentTool->setText(error);
|
||||||
|
m_tools = TcpToolStore::Snapshot{};
|
||||||
|
const QSignalBlocker blocker(m_toolCombo);
|
||||||
|
m_toolCombo->clear(); m_toolCombo->addItem(QStringLiteral("配置读取失败"));
|
||||||
|
resetCalibration();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_tools = snapshot;
|
||||||
|
const QString wanted = preferred.isEmpty() ? snapshot.current : preferred;
|
||||||
|
int selected = 0;
|
||||||
|
{
|
||||||
|
const QSignalBlocker blocker(m_toolCombo);
|
||||||
|
m_toolCombo->clear();
|
||||||
|
m_toolCombo->addItem(QStringLiteral("新建工具"));
|
||||||
|
for (const auto &tool : snapshot.tools) {
|
||||||
|
m_toolCombo->addItem(tool.name);
|
||||||
|
if (tool.name == wanted) selected = m_toolCombo->count() - 1;
|
||||||
|
}
|
||||||
|
m_toolCombo->setCurrentIndex(selected);
|
||||||
|
}
|
||||||
|
selectTool(selected);
|
||||||
|
}
|
||||||
|
void TcpCalibrationWidget::selectTool(int index)
|
||||||
|
{
|
||||||
|
resetCalibration();
|
||||||
|
m_loading = true;
|
||||||
|
if (index <= 0 || index > m_tools.tools.size()) {
|
||||||
|
m_name->clear();
|
||||||
|
for (auto *spin : m_orientation) spin->setValue(0);
|
||||||
|
m_currentTool->setText(QStringLiteral("新工具 · 未保存"));
|
||||||
|
} else {
|
||||||
|
const auto &tool = m_tools.tools.at(index - 1);
|
||||||
|
{ const QSignalBlocker blocker(m_method);
|
||||||
|
m_method->setCurrentIndex(qMax(0,m_method->findData(tool.method))); }
|
||||||
|
resizeSamples(m_method->currentIndex()==0 ? 4 : 6);
|
||||||
|
m_name->setText(tool.name);
|
||||||
|
m_result.offset = tool.offset;
|
||||||
|
m_result.rmsMm = tool.rmsMm;
|
||||||
|
m_loadedSampleCount = tool.sampleCount;
|
||||||
|
m_loadedMethod = tool.method;
|
||||||
|
m_resultValid = true;
|
||||||
|
m_loadedResult = true;
|
||||||
|
for (int i = 0; i < 3; ++i) m_orientation.at(i)->setValue(qRadiansToDegrees(tool.offset[size_t(i + 3)]));
|
||||||
|
showResult(tool.offset, tool.rmsMm, true);
|
||||||
|
m_currentTool->setText(QStringLiteral("%1 · %2 点标定").arg(tool.name).arg(tool.sampleCount));
|
||||||
|
emit logMessage(QStringLiteral("INFO"), QStringLiteral("已加载工具标定结果:%1").arg(tool.name));
|
||||||
|
}
|
||||||
|
m_loading = false;
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
void TcpCalibrationWidget::deleteTool()
|
||||||
|
{
|
||||||
|
const int index = m_toolCombo->currentIndex() - 1;
|
||||||
|
if (index < 0 || index >= m_tools.tools.size()) return;
|
||||||
|
const QString name = m_tools.tools.at(index).name;
|
||||||
|
if (QMessageBox::question(this, QStringLiteral("删除工具"),
|
||||||
|
QStringLiteral("删除当前机械臂的工具“%1”?对应的工具坐标选项也将移除。").arg(name),
|
||||||
|
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes) return;
|
||||||
|
QSettings settings;
|
||||||
|
QString error;
|
||||||
|
if (!TcpToolStore::remove(settings, m_endpoint, m_device, name, error)) { reportError(error); return; }
|
||||||
|
reloadTools();
|
||||||
|
emit toolsChanged(m_endpoint, m_device, QString());
|
||||||
|
emit logMessage(QStringLiteral("INFO"), QStringLiteral("已删除本机 TCP 工具:%1").arg(name));
|
||||||
|
}
|
||||||
446
src/touchoperationwidget.cpp
Normal file
446
src/touchoperationwidget.cpp
Normal file
@ -0,0 +1,446 @@
|
|||||||
|
#include "touchoperationwidget.h"
|
||||||
|
#include "touchvideowidget.h"
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QCryptographicHash>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QDoubleSpinBox>
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QHideEvent>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QScrollArea>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QSignalBlocker>
|
||||||
|
#include <QSpinBox>
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
using Pose=TcpCalibration::Pose;
|
||||||
|
constexpr quint64 kPosePrefix=quint64(1)<<58;
|
||||||
|
constexpr quint64 kImagePrefix=quint64(1)<<57;
|
||||||
|
QVariantList values(const Pose &pose) { QVariantList result; for(double v:pose) result<<v; return result; }
|
||||||
|
bool poseFrom(const QVariant &value,Pose &pose) {
|
||||||
|
auto list=value.toList(); if(list.size()!=6) return false;
|
||||||
|
for(int i=0;i<6;++i) { bool ok=false; pose[i]=list[i].toDouble(&ok); if(!ok) return false; }
|
||||||
|
return TcpCalibration::validPose(pose);
|
||||||
|
}
|
||||||
|
bool decodePose(const QVariantMap &map,Pose &pose) {
|
||||||
|
QVariantList list; for(const auto &key:QStringList{"x","y","z","rx","ry","rz"}) list<<map.value(key);
|
||||||
|
return poseFrom(list,pose);
|
||||||
|
}
|
||||||
|
bool nearPose(const Pose &a,const Pose &b) {
|
||||||
|
TcpCalibration::Matrix x{},y{};
|
||||||
|
if(!TcpCalibration::poseMatrix(a,x)||!TcpCalibration::poseMatrix(b,y)) return false;
|
||||||
|
double distance=0,trace=0;
|
||||||
|
for(int i=0;i<3;++i) { distance+=std::pow(a[i]-b[i],2); for(int j=0;j<3;++j) trace+=x[i*4+j]*y[i*4+j]; }
|
||||||
|
return distance<=.0005*.0005 && std::acos(qBound(-1.0,(trace-1)/2,1.0))<=.2*3.141592653589793/180;
|
||||||
|
}
|
||||||
|
QString poseText(const Pose &pose) {
|
||||||
|
QStringList result; for(int i=0;i<6;++i) result<<QString::number(pose[i]*(i<3?1000:180/3.141592653589793),'f',2);
|
||||||
|
return result.join(" / ");
|
||||||
|
}
|
||||||
|
QVBoxLayout *panel(QBoxLayout *parent,const QString &title) {
|
||||||
|
auto *frame=new QFrame; frame->setObjectName("panel"); parent->addWidget(frame);
|
||||||
|
auto *layout=new QVBoxLayout(frame); layout->setContentsMargins(12,12,12,12); layout->setSpacing(8);
|
||||||
|
auto *label=new QLabel(title); label->setObjectName("sectionTitle"); layout->addWidget(label); return layout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TouchOperationWidget::TouchOperationWidget(QWidget *parent):QWidget(parent),
|
||||||
|
m_sequence(new TouchSequenceController(this)),m_video(new TouchVideoWidget(this))
|
||||||
|
{
|
||||||
|
setObjectName("touchOperationPage");
|
||||||
|
m_video->setMaxPoints(2);
|
||||||
|
auto *outer=new QVBoxLayout(this); outer->setContentsMargins(12,10,12,10); outer->setSpacing(8);
|
||||||
|
auto *scroll=new QScrollArea; scroll->setWidgetResizable(true); scroll->setFrameShape(QFrame::NoFrame);
|
||||||
|
auto *content=new QWidget; scroll->setWidget(content); outer->addWidget(scroll);
|
||||||
|
auto *root=new QVBoxLayout(content); root->setContentsMargins(0,0,0,0); root->setSpacing(10);
|
||||||
|
auto *top=new QHBoxLayout; top->setSpacing(10); root->addLayout(top);
|
||||||
|
auto *vision=panel(top,QStringLiteral("视觉取点"));
|
||||||
|
m_video->setMinimumWidth(320); m_video->setMaximumWidth(640); m_video->setFrameAspectLayoutEnabled(true);
|
||||||
|
vision->setAlignment(Qt::AlignTop);
|
||||||
|
vision->addWidget(m_video,0,Qt::AlignTop|Qt::AlignHCenter);
|
||||||
|
auto *videoActions=new QHBoxLayout;
|
||||||
|
m_previewButton=new QPushButton(QStringLiteral("开始视频")); m_stopPreviewButton=new QPushButton(QStringLiteral("停止视频"));
|
||||||
|
m_lockButton=new QPushButton(QStringLiteral("锁定观察画面")); m_liveButton=new QPushButton(QStringLiteral("恢复实时"));
|
||||||
|
for(auto *b:{m_previewButton,m_stopPreviewButton,m_lockButton,m_liveButton}) videoActions->addWidget(b);
|
||||||
|
vision->addLayout(videoActions);
|
||||||
|
auto *hint=new QLabel(QStringLiteral("在锁定画面中选择 A / B 点;滑动按 A → B 执行。")); hint->setObjectName("mutedLabel"); vision->addWidget(hint);
|
||||||
|
auto *config=panel(top,QStringLiteral("任务配置")); top->setStretch(0,1); top->setStretch(1,1);
|
||||||
|
auto *grid=new QGridLayout; config->addLayout(grid);
|
||||||
|
m_handEyeChoice=new QComboBox; m_handEyeChoice->setObjectName("touchHandEye");
|
||||||
|
m_toolChoice=new QComboBox; m_toolChoice->setObjectName("touchTcp");
|
||||||
|
for(auto *c:{m_handEyeChoice,m_toolChoice}) { c->setSizePolicy(QSizePolicy::Ignored,QSizePolicy::Fixed); c->setMinimumWidth(130); }
|
||||||
|
m_cameraName=new QLabel; m_cameraName->setWordWrap(true);
|
||||||
|
grid->setColumnStretch(1,1);
|
||||||
|
grid->addWidget(new QLabel(QStringLiteral("手眼标定")),0,0); grid->addWidget(m_handEyeChoice,0,1,1,2);
|
||||||
|
grid->addWidget(new QLabel(QStringLiteral("工具 TCP")),1,0); grid->addWidget(m_toolChoice,1,1,1,2);
|
||||||
|
grid->addWidget(new QLabel(QStringLiteral("相机")),2,0); grid->addWidget(m_cameraName,2,1);
|
||||||
|
m_reloadButton=new QPushButton(QStringLiteral("刷新标定")); grid->addWidget(m_reloadButton,2,2);
|
||||||
|
m_cameraConfirmed=new QCheckBox(QStringLiteral("已核对相机内参与时钟"));
|
||||||
|
m_cameraConfirmed->setToolTip(QStringLiteral("使用该相机 RGB 光学坐标系及标准 Brown 畸变模型;服务与上位机时钟同步,目标保持静止;深度单位及配准由服务提供。")); config->addWidget(m_cameraConfirmed);
|
||||||
|
m_teachObservation=new QPushButton(QStringLiteral("录入当前观察位")); m_teachObservation->setObjectName("touchTeachObservation");
|
||||||
|
m_returnButton=new QPushButton(QStringLiteral("回观察位"));
|
||||||
|
auto *teachRow=new QHBoxLayout; teachRow->addWidget(m_teachObservation,1); teachRow->addWidget(m_returnButton); config->addLayout(teachRow);
|
||||||
|
m_observationText=new QLabel; m_observationText->setWordWrap(true); m_observationText->setObjectName("mutedLabel"); config->addWidget(m_observationText);
|
||||||
|
config->addSpacing(8);
|
||||||
|
auto *actionTitle=new QLabel(QStringLiteral("动作参数")); actionTitle->setObjectName("sectionTitle"); config->addWidget(actionTitle);
|
||||||
|
auto *params=new QGridLayout; params->setHorizontalSpacing(8); params->setVerticalSpacing(8);
|
||||||
|
params->setColumnStretch(1,1); params->setColumnStretch(3,1); config->addLayout(params);
|
||||||
|
m_action=new QComboBox; m_action->setObjectName("touchAction"); m_action->addItems({QStringLiteral("单击"),QStringLiteral("双击"),QStringLiteral("滑动")});
|
||||||
|
params->addWidget(new QLabel(QStringLiteral("动作")),0,0); params->addWidget(m_action,0,1,1,3);
|
||||||
|
auto addSpin=[params](const QString &label,int row,int col,double value,double min,double max,const QString &suffix) {
|
||||||
|
auto *spin=new QDoubleSpinBox; spin->setRange(min,max); spin->setDecimals(2); spin->setValue(value); spin->setSuffix(suffix); spin->setKeyboardTracking(false);
|
||||||
|
params->addWidget(new QLabel(label),row,col); params->addWidget(spin,row,col+1); return spin;
|
||||||
|
};
|
||||||
|
m_approach=addSpin(QStringLiteral("接近高度"),1,0,10,1,50," mm");
|
||||||
|
m_press=addSpin(QStringLiteral("接触偏移"),1,2,0,0,2," mm");
|
||||||
|
m_lift=addSpin(QStringLiteral("双击抬笔"),4,0,1,1,20," mm");
|
||||||
|
m_speed=addSpin(QStringLiteral("移动速度"),2,0,30,5,50," mm/s");
|
||||||
|
m_contactSpeed=addSpin(QStringLiteral("接触速度"),2,2,10,5,30," mm/s");
|
||||||
|
m_travel=addSpin(QStringLiteral("运动范围"),3,0,300,10,1000," mm");
|
||||||
|
m_dwell=new QSpinBox; m_dwell->setRange(0,2000); m_dwell->setValue(50); m_dwell->setSuffix(" ms");
|
||||||
|
params->addWidget(new QLabel(QStringLiteral("接触停留")),3,2); params->addWidget(m_dwell,3,3);
|
||||||
|
m_gap=new QSpinBox; m_gap->setRange(20,500); m_gap->setValue(50); m_gap->setSuffix(" ms");
|
||||||
|
params->addWidget(new QLabel(QStringLiteral("双击间隔")),4,2); params->addWidget(m_gap,4,3);
|
||||||
|
config->addStretch();
|
||||||
|
m_press->setToolTip(QStringLiteral("沿相机 +Z 方向的几何位移,不是力控。首次验证建议为 0。"));
|
||||||
|
m_travel->setToolTip(QStringLiteral("相对观察位的最大位移与每段最大行程;不代替碰撞检查。"));
|
||||||
|
m_gap->setToolTip(QStringLiteral("抬笔到位后的停留;实际两次触点间隔还包含机械臂运动时间。"));
|
||||||
|
auto *bottom=new QHBoxLayout; root->addLayout(bottom);
|
||||||
|
auto *targetPanel=panel(bottom,QStringLiteral("目标点坐标换算结果"));
|
||||||
|
m_conversionStatus=new QLabel; m_conversionStatus->setObjectName("touchConversionStatus"); m_conversionStatus->setWordWrap(true);
|
||||||
|
m_conversionStatus->setToolTip(QStringLiteral("显示深度测量目标点,尚未叠加接触偏移;控制器 TCP 的实际运动目标见执行路径。"));
|
||||||
|
targetPanel->addWidget(m_conversionStatus);
|
||||||
|
m_targets=new QTableWidget(0,4); m_targets->setObjectName("touchTargets");
|
||||||
|
m_targets->setHorizontalHeaderLabels({QStringLiteral("点"),QStringLiteral("像素 · px"),QStringLiteral("相机 XYZ · mm"),QStringLiteral("基座 XYZ · mm")}); targetPanel->addWidget(m_targets);
|
||||||
|
auto *pathPanel=panel(bottom,QStringLiteral("执行路径"));
|
||||||
|
m_steps=new QTableWidget(0,3); m_steps->setObjectName("touchSteps"); m_steps->setHorizontalHeaderLabels({QStringLiteral("步骤"),QStringLiteral("控制器 TCP · XYZ mm / RxRyRz °"),QStringLiteral("速度 mm/s")}); pathPanel->addWidget(m_steps);
|
||||||
|
for(auto *table:{m_targets,m_steps}) { table->verticalHeader()->hide(); table->setEditTriggers(QAbstractItemView::NoEditTriggers); table->setMinimumHeight(150); table->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); table->horizontalHeader()->setStretchLastSection(true); }
|
||||||
|
m_targets->setMinimumHeight(188); m_targets->setMaximumHeight(230); m_targets->setWordWrap(false);
|
||||||
|
m_steps->setMinimumHeight(188); m_steps->setMaximumHeight(260);
|
||||||
|
for(auto *table:{m_targets,m_steps}) { table->setAlternatingRowColors(true); table->setShowGrid(false); }
|
||||||
|
m_targets->horizontalHeader()->setSectionResizeMode(2,QHeaderView::Stretch);
|
||||||
|
m_targets->horizontalHeader()->setSectionResizeMode(3,QHeaderView::Stretch);
|
||||||
|
bottom->setStretch(0,1); bottom->setStretch(1,1);
|
||||||
|
root->addStretch(1);
|
||||||
|
auto *footer=new QHBoxLayout; outer->addLayout(footer);
|
||||||
|
m_status=new QLabel; m_status->setWordWrap(true); m_status->setObjectName("mutedLabel"); outer->insertWidget(1,m_status);
|
||||||
|
m_pathConfirmed=new QCheckBox(QStringLiteral("已核对目标、笔姿及路径净空")); footer->addWidget(m_pathConfirmed);
|
||||||
|
footer->addStretch(1);
|
||||||
|
m_calculateButton=new QPushButton(QStringLiteral("转换 / 预览")); m_executeButton=new QPushButton(QStringLiteral("执行动作")); m_executeButton->setObjectName("primaryButton");
|
||||||
|
auto *stopButton=new QPushButton(QStringLiteral("停止")); stopButton->setObjectName("dangerOutlineButton");
|
||||||
|
footer->addWidget(m_calculateButton); footer->addWidget(m_executeButton); footer->addWidget(stopButton);
|
||||||
|
m_timeout.setSingleShot(true); m_timeout.setInterval(12000);
|
||||||
|
connect(&m_timeout,&QTimer::timeout,this,[this] { fail(QStringLiteral("读取超时,请检查连接后重试。")); });
|
||||||
|
connect(m_previewButton,&QPushButton::clicked,this,&TouchOperationWidget::startPreview);
|
||||||
|
connect(m_stopPreviewButton,&QPushButton::clicked,this,&TouchOperationWidget::stopPreview);
|
||||||
|
connect(m_lockButton,&QPushButton::clicked,this,&TouchOperationWidget::lockFrame);
|
||||||
|
connect(m_liveButton,&QPushButton::clicked,this,[this] { invalidateFrame(); refresh(); });
|
||||||
|
connect(m_teachObservation,&QPushButton::clicked,this,[this] { teach(Phase::Observation); });
|
||||||
|
connect(m_returnButton,&QPushButton::clicked,this,[this] { teach(Phase::Return); });
|
||||||
|
connect(m_calculateButton,&QPushButton::clicked,this,&TouchOperationWidget::calculate);
|
||||||
|
connect(m_executeButton,&QPushButton::clicked,this,&TouchOperationWidget::execute);
|
||||||
|
connect(stopButton,&QPushButton::clicked,this,[this] {
|
||||||
|
const bool active=running(); stop();
|
||||||
|
if(!active&&!m_device.isEmpty()) emit stopRequested(m_device);
|
||||||
|
});
|
||||||
|
connect(m_reloadButton,&QPushButton::clicked,this,&TouchOperationWidget::reloadCalibrations);
|
||||||
|
connect(m_video,&TouchVideoWidget::pointsChanged,this,[this] { invalidatePlan(); refresh(); });
|
||||||
|
connect(m_cameraConfirmed,&QCheckBox::toggled,this,[this] { invalidateFrame(); refresh(); });
|
||||||
|
connect(m_pathConfirmed,&QCheckBox::toggled,this,[this] { refresh(); });
|
||||||
|
connect(m_handEyeChoice,QOverload<int>::of(&QComboBox::currentIndexChanged),this,[this] { if(m_loading) return; stopPreview(); invalidateFrame(); m_cameraConfirmed->setChecked(false); saveTeaching(); refresh(); });
|
||||||
|
connect(m_toolChoice,QOverload<int>::of(&QComboBox::currentIndexChanged),this,[this] { if(m_loading) return; stop(); saveTeaching(); refresh(); });
|
||||||
|
connect(m_action,QOverload<int>::of(&QComboBox::currentIndexChanged),this,[this] { invalidatePlan(); refresh(); });
|
||||||
|
for(auto *spin:{m_approach,m_press,m_lift,m_speed,m_contactSpeed,m_travel}) connect(spin,QOverload<double>::of(&QDoubleSpinBox::valueChanged),this,[this] { invalidatePlan(); refresh(); });
|
||||||
|
for(auto *spin:{m_dwell,m_gap}) connect(spin,QOverload<int>::of(&QSpinBox::valueChanged),this,[this] { invalidatePlan(); refresh(); });
|
||||||
|
connect(m_sequence,&TouchSequenceController::captureRequested,this,&TouchOperationWidget::captureRequested);
|
||||||
|
connect(m_sequence,&TouchSequenceController::moveRequested,this,&TouchOperationWidget::moveRequested);
|
||||||
|
connect(m_sequence,&TouchSequenceController::stopRequested,this,&TouchOperationWidget::stopRequested);
|
||||||
|
connect(m_sequence,&TouchSequenceController::progressChanged,this,[this](int step,int count,const QString &label) { m_status->setText(QStringLiteral("执行 %1 / %2 · %3").arg(step).arg(count).arg(label)); refresh(); });
|
||||||
|
connect(m_sequence,&TouchSequenceController::errorOccurred,this,[this](const QString &error) { emit logMessage("ERROR",error); });
|
||||||
|
connect(m_sequence,&TouchSequenceController::finished,this,[this](bool success,const QString &detail) { invalidateFrame(); refresh(); m_status->setText(detail); emit logMessage(success?"OK":"WARN",QStringLiteral("末端操作:%1").arg(detail)); });
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TouchOperationWidget::running() const { return m_sequence->running(); }
|
||||||
|
bool TouchOperationWidget::ready() const { return m_connected&&!m_demo&&m_reference&&!m_device.isEmpty()&&TcpCalibration::validPose(m_activeOffset); }
|
||||||
|
const HandEyeStore::Record *TouchOperationWidget::handEye() const {
|
||||||
|
int i=m_handEyeChoice->currentIndex(); return i>=0&&i<m_handEyes.records.size()?&m_handEyes.records[i]:nullptr;
|
||||||
|
}
|
||||||
|
QString TouchOperationWidget::cameraId() const { auto *r=handEye(); return r?r->cameraId:QString(); }
|
||||||
|
bool TouchOperationWidget::selectedTool(Pose &offset) const {
|
||||||
|
int i=m_toolChoice->currentIndex(); if(i<0||i>=m_tools.tools.size()) return false;
|
||||||
|
offset=m_tools.tools[i].offset; return true;
|
||||||
|
}
|
||||||
|
void TouchOperationWidget::setContext(const QString &endpoint,const QString &device,bool connected,bool demo,bool reference,const Pose &offset) {
|
||||||
|
bool scope=endpoint!=m_endpoint||device!=m_device;
|
||||||
|
if(!scope&&offset!=m_activeOffset) { m_observed=false; }
|
||||||
|
if(scope||connected!=m_connected||demo!=m_demo||reference!=m_reference||offset!=m_activeOffset) {
|
||||||
|
stopPreview(); stop(); m_cameraConfirmed->setChecked(false);
|
||||||
|
}
|
||||||
|
m_endpoint=endpoint; m_device=device; m_connected=connected; m_demo=demo; m_reference=reference; m_activeOffset=offset;
|
||||||
|
if(scope) { m_observed=false; reloadCalibrations(); loadTeaching(); }
|
||||||
|
if(m_observed&&m_reference&&m_teachingOffset!=m_activeOffset) { m_observed=false; }
|
||||||
|
m_sequence->setContext(endpoint,device,ready(),offset); refresh();
|
||||||
|
}
|
||||||
|
void TouchOperationWidget::reloadCalibrations() {
|
||||||
|
stopPreview(); stop();
|
||||||
|
const QString oldHand=m_handEyeChoice->currentText(),oldTool=m_toolChoice->currentText();
|
||||||
|
m_loading=true; m_handEyeChoice->clear(); m_toolChoice->clear(); m_handEyes={}; m_tools={};
|
||||||
|
QSettings settings; QString error;
|
||||||
|
bool ok=m_endpoint.isEmpty()||m_device.isEmpty()||
|
||||||
|
(HandEyeStore::load(settings,m_endpoint,m_device,m_handEyes,error)&&TcpToolStore::load(settings,m_endpoint,m_device,m_tools,error));
|
||||||
|
if(ok) {
|
||||||
|
for(const auto &r:m_handEyes.records) m_handEyeChoice->addItem(r.name);
|
||||||
|
for(const auto &t:m_tools.tools) m_toolChoice->addItem(t.name);
|
||||||
|
int h=m_handEyeChoice->findText(oldHand),t=m_toolChoice->findText(oldTool);
|
||||||
|
if(h>=0) m_handEyeChoice->setCurrentIndex(h);
|
||||||
|
if(t>=0) m_toolChoice->setCurrentIndex(t);
|
||||||
|
}
|
||||||
|
m_loading=false;
|
||||||
|
m_cameraConfirmed->setChecked(false); refresh(); if(!ok) fail(error);
|
||||||
|
}
|
||||||
|
void TouchOperationWidget::invalidatePlan() { m_planValid=false; m_plan={}; m_pathConfirmed->setChecked(false); m_steps->setRowCount(0); }
|
||||||
|
void TouchOperationWidget::invalidateFrame() {
|
||||||
|
invalidatePlan(); m_lockedAt=0; m_pendingImage={}; m_depth={}; m_video->unlock(); m_video->clearSelection();
|
||||||
|
}
|
||||||
|
void TouchOperationWidget::stop() {
|
||||||
|
m_sequence->stop(); ++m_serial; m_poseToken=0; m_imageToken=0; m_phase=Phase::Idle; m_timeout.stop(); invalidateFrame(); refresh();
|
||||||
|
}
|
||||||
|
void TouchOperationWidget::fail(const QString &message) {
|
||||||
|
stop(); m_status->setText(message); emit logMessage("ERROR",QStringLiteral("末端操作:%1").arg(message));
|
||||||
|
QMessageBox::warning(this,QStringLiteral("末端操作"),message);
|
||||||
|
}
|
||||||
|
void TouchOperationWidget::hideEvent(QHideEvent *event) { stopPreview(); stop(); QWidget::hideEvent(event); }
|
||||||
|
void TouchOperationWidget::startPreview() {
|
||||||
|
if(!m_connected||m_demo||!handEye()) { fail(QStringLiteral("请连接机器人服务并选择手眼标定。")); return; }
|
||||||
|
stopPreview(); m_previewCamera=cameraId(); m_preview=true; emit previewRequested(m_previewCamera,true); refresh();
|
||||||
|
}
|
||||||
|
void TouchOperationWidget::stopPreview() {
|
||||||
|
const QString camera=m_previewCamera; bool active=m_preview; m_preview=false; m_previewCamera.clear();
|
||||||
|
if(active) emit previewRequested(camera,false);
|
||||||
|
stop(); m_video->clearFrame();
|
||||||
|
}
|
||||||
|
void TouchOperationWidget::acceptFrame(const QString &camera,const VideoFrame &frame,const QString &) {
|
||||||
|
if(!m_preview||camera!=m_previewCamera||!frame.isValid()) return;
|
||||||
|
if(frame.metadata.value("kind").toString()!="rgb") { m_status->setText(QStringLiteral("当前流不是 RGB,请在相机页面切换为彩色视频。")); return; }
|
||||||
|
m_video->present(frame);
|
||||||
|
|
||||||
|
}
|
||||||
|
void TouchOperationWidget::acceptStreamState(const QString &camera,bool active,const QString &detail) {
|
||||||
|
if(m_preview&&camera==m_previewCamera&&!active) { stopPreview(); m_status->setText(QStringLiteral("视频已停止:%1").arg(detail)); }
|
||||||
|
}
|
||||||
|
void TouchOperationWidget::teach(Phase phase) {
|
||||||
|
Pose offset{};
|
||||||
|
if(!ready()||running()||m_phase!=Phase::Idle||(phase!=Phase::Observation&&!selectedTool(offset))) { fail(QStringLiteral("请先连接机械臂、选择 TCP 标定并核对控制器偏移。")); return; }
|
||||||
|
if(phase==Phase::Return&&!m_observed) return;
|
||||||
|
invalidateFrame(); m_phase=phase; readPose();
|
||||||
|
}
|
||||||
|
void TouchOperationWidget::readPose() {
|
||||||
|
m_poseToken=kPosePrefix|++m_serial; m_requestAt=QDateTime::currentMSecsSinceEpoch(); m_timeout.start();
|
||||||
|
emit captureRequested(m_device,m_poseToken); refresh();
|
||||||
|
}
|
||||||
|
void TouchOperationWidget::lockFrame() {
|
||||||
|
if(!ready()||!m_preview||!m_observed||!m_cameraConfirmed->isChecked()||running()||m_phase!=Phase::Idle) return;
|
||||||
|
invalidateFrame(); m_phase=Phase::LockBefore; readPose();
|
||||||
|
}
|
||||||
|
void TouchOperationWidget::acceptPose(quint64 token,const QString &device,const QVariantMap &map,const QVariantMap &state,bool success,const QString &detail) {
|
||||||
|
m_sequence->acceptPose(token,device,map,state,success,detail);
|
||||||
|
if(!m_poseToken||token!=m_poseToken||device!=m_device) return;
|
||||||
|
m_poseToken=0; Pose pose{},tool{},flange{},selected{};
|
||||||
|
const qint64 requested=state.value("requestedAtMs").toLongLong(),received=state.value("receivedAtMs").toLongLong();
|
||||||
|
const qint64 now=QDateTime::currentMSecsSinceEpoch();
|
||||||
|
if(!success||!ready()||!decodePose(map,pose)||(m_phase!=Phase::Observation&&!selectedTool(tool))||requested<m_requestAt||received<requested||received>now||now-received>1500
|
||||||
|
||!state.value("connected").toBool()||state.value("moving",true).toBool()||state.value("fault",true).toBool()
|
||||||
|
||state.value("protectiveStopped",true).toBool()||state.value("emergencyStopped",true).toBool()
|
||||||
|
||state.value("source").toString()!=QStringLiteral("getRobotState.actual_tcp_pose")) { fail(QStringLiteral("实时位姿不可用:%1").arg(detail)); return; }
|
||||||
|
if(!TcpCalibration::flangePose(pose,m_activeOffset,flange)||!TcpCalibration::toolPose(flange,tool,selected)) { fail(QStringLiteral("TCP 位姿转换失败。")); return; }
|
||||||
|
const auto phase=m_phase;
|
||||||
|
if(phase==Phase::LockBefore) {
|
||||||
|
if(!nearPose(pose,m_observation)) { fail(QStringLiteral("机械臂不在观察位,请先回观察位并停稳。")); return; }
|
||||||
|
m_before=pose; m_beforeAt=received; m_phase=Phase::LockImage; m_imageToken=kImagePrefix|++m_serial;
|
||||||
|
emit imageRequested(cameraId(),m_imageToken); refresh(); return;
|
||||||
|
}
|
||||||
|
if(phase==Phase::LockAfter) {
|
||||||
|
if(requested<m_captureAt||!nearPose(m_before,pose)||!nearPose(pose,m_observation)||received-m_beforeAt>10000) { fail(QStringLiteral("取图期间位姿变化或时间窗无效,请停稳后重试。")); return; }
|
||||||
|
TcpCalibration::flangePose(m_before,m_activeOffset,m_lockedFlange);
|
||||||
|
if(!(m_video->lockImage(m_pendingImage))) { fail(QStringLiteral("观察图像无效。")); return; }
|
||||||
|
m_pendingImage={}; m_lockedAt=QDateTime::currentMSecsSinceEpoch();
|
||||||
|
} else if(phase==Phase::Observation) {
|
||||||
|
m_observation=pose; m_observed=true; m_teachingOffset=m_activeOffset; saveTeaching();
|
||||||
|
} else if(phase==Phase::Return) {
|
||||||
|
m_phase=Phase::Idle; m_timeout.stop(); returnObservation(pose); return;
|
||||||
|
}
|
||||||
|
m_phase=Phase::Idle; m_timeout.stop(); refresh(); emit logMessage("OK",QStringLiteral("末端操作:已录入位姿 / 锁定观察图像"));
|
||||||
|
}
|
||||||
|
void TouchOperationWidget::acceptImage(quint64 token,const QString &camera,const QImage &image,const QVariantMap &intrinsics,const QVariantMap &metadata,bool success,const QString &detail) {
|
||||||
|
if(!m_imageToken||token!=m_imageToken||camera!=cameraId()||m_phase!=Phase::LockImage) return;
|
||||||
|
m_imageToken=0; QString error;
|
||||||
|
if(!success) { fail(QStringLiteral("读取 RGBD 失败:%1").arg(detail)); return; }
|
||||||
|
const qint64 colorAt=metadata.value("captureUtcNs").toLongLong()/1000000;
|
||||||
|
const qint64 depthAt=metadata.value("depthCaptureUtcNs").toLongLong()/1000000;
|
||||||
|
const qint64 now=QDateTime::currentMSecsSinceEpoch();
|
||||||
|
if(!metadata.value("alignedToColor").toBool()||!metadata.value("colorAxialZ").toBool()
|
||||||
|
||metadata.value("byteOrder").toString()!="little"||colorAt<=0||depthAt<=0
|
||||||
|
||std::abs(colorAt-depthAt)>33||colorAt>now||depthAt>now) {
|
||||||
|
fail(QStringLiteral("RGBD 缺少有效配准、深度单位或同步时间戳,请更新相机服务。")); return;
|
||||||
|
}
|
||||||
|
if(colorAt<m_beforeAt||depthAt<m_beforeAt||now-qMin(colorAt,depthAt)>1500) {
|
||||||
|
// The server snapshots its acquisition thread. Wait for a new pair;
|
||||||
|
// never combine a live color frame with an older depth image.
|
||||||
|
const quint64 generation=m_serial;
|
||||||
|
QTimer::singleShot(80,this,[this,generation] {
|
||||||
|
if(m_serial!=generation||m_phase!=Phase::LockImage||m_imageToken) return;
|
||||||
|
m_imageToken=kImagePrefix|++m_serial; emit imageRequested(cameraId(),m_imageToken);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TouchPlanner::DepthImage depth;
|
||||||
|
depth.width=metadata.value("depthWidth").toInt(); depth.height=metadata.value("depthHeight").toInt();
|
||||||
|
depth.data=metadata.value("depthData").toByteArray(); depth.float32=metadata.value("depthFloat32").toBool();
|
||||||
|
depth.metresPerUnit=metadata.value("metresPerUnit").toDouble();
|
||||||
|
if(image.isNull()||!TouchPlanner::cameraModel(intrinsics,image.width(),image.height(),m_cameraModel,&error)
|
||||||
|
||depth.width!=image.width()||depth.height!=image.height()
|
||||||
|
||!std::isfinite(depth.metresPerUnit)||depth.metresPerUnit<=0||depth.metresPerUnit>1
|
||||||
|
||qint64(depth.width)*depth.height*(depth.float32?4:2)!=depth.data.size()) {
|
||||||
|
fail(QStringLiteral("RGBD 尺寸、单位或内参无效:%1").arg(error)); return;
|
||||||
|
}
|
||||||
|
m_depth=depth; m_pendingImage=image; m_captureAt=qMax(colorAt,depthAt); m_phase=Phase::LockAfter; readPose();
|
||||||
|
}
|
||||||
|
void TouchOperationWidget::acceptCommand(const QString &command,bool success,const QString &detail) { m_sequence->acceptCommand(command,success,detail); }
|
||||||
|
TouchPlanner::Parameters TouchOperationWidget::parameters() const {
|
||||||
|
TouchPlanner::Parameters p; p.approachM=m_approach->value()/1000; p.contactOffsetM=m_press->value()/1000;
|
||||||
|
p.doubleLiftM=m_lift->value()/1000; p.travelVelocityMps=m_speed->value()/1000; p.contactVelocityMps=m_contactSpeed->value()/1000;
|
||||||
|
p.maxTravelM=m_travel->value()/1000; p.contactDwellMs=m_dwell->value(); p.doubleIntervalMs=m_gap->value(); return p;
|
||||||
|
}
|
||||||
|
bool TouchOperationWidget::buildPlane(TouchPlanner::Plane &plane,QString &error) const {
|
||||||
|
QVector<TouchPlanner::Point> points,cameraPoints;
|
||||||
|
TouchPlanner::Matrix baseCamera{}; Pose offset{},tip{};
|
||||||
|
if(!resolveTargets(points,cameraPoints,error)||!selectedTool(offset)
|
||||||
|
||!TcpCalibration::toolPose(m_lockedFlange,offset,tip,&error)
|
||||||
|
||!TouchPlanner::cameraTransform(*handEye(),m_lockedFlange,baseCamera,&error)) return false;
|
||||||
|
plane.origin=points.first();
|
||||||
|
// Same free-pixel approach direction as phone: negative camera Z.
|
||||||
|
// Preserve the selected stylus orientation taught at the observation pose.
|
||||||
|
for(int i=0;i<3;++i) { plane.normal[i]=-baseCamera[i*4+2]; plane.orientationRad[i]=tip[i+3]; }
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void TouchOperationWidget::calculate() {
|
||||||
|
invalidatePlan(); QString error; Pose tool{}; TouchPlanner::Plane plane; QVector<TouchPlanner::Point> points,cameraPoints;
|
||||||
|
TouchPlanner::Matrix baseCamera{};
|
||||||
|
if(!ready()||!handEye()||!selectedTool(tool)||!m_video->locked()||!m_lockedAt||QDateTime::currentMSecsSinceEpoch()-m_lockedAt>60000) { fail(QStringLiteral("请在观察位重新锁定画面后取点。")); return; }
|
||||||
|
if(!buildPlane(plane,error)||!resolveTargets(points,cameraPoints,error)
|
||||||
|
||!TouchPlanner::cameraTransform(*handEye(),m_lockedFlange,baseCamera,&error)
|
||||||
|
||(m_action->currentIndex()==2&&!TouchPlanner::validateDepthSwipe(m_video->selectedPoints(),m_cameraModel,m_depth,baseCamera,parameters(),&error))
|
||||||
|
||!TouchPlanner::buildPlan(static_cast<TouchPlanner::Action>(m_action->currentIndex()),points,plane,m_observation,m_activeOffset,tool,parameters(),m_plan,&error,true)) { fail(error); return; }
|
||||||
|
m_planValid=true; m_steps->setRowCount(m_plan.steps.size());
|
||||||
|
for(int i=0;i<m_plan.steps.size();++i) { const auto &step=m_plan.steps[i]; m_steps->setItem(i,0,new QTableWidgetItem(QString::number(i+1)+" · "+step.label));
|
||||||
|
m_steps->setItem(i,1,new QTableWidgetItem(poseText(step.target))); m_steps->setItem(i,2,new QTableWidgetItem(QString::number(step.velocityMps*1000,'f',1))); }
|
||||||
|
refresh(); emit logMessage("INFO",QStringLiteral("末端操作:已转换 %1 个目标,规划 %2 个动作步骤").arg(points.size()).arg(m_plan.steps.size()));
|
||||||
|
}
|
||||||
|
void TouchOperationWidget::execute() {
|
||||||
|
if(!m_planValid||!m_pathConfirmed->isChecked()||running()||!ready()||QDateTime::currentMSecsSinceEpoch()-m_lockedAt>60000) { fail(QStringLiteral("请重新预览路径并确认后执行。")); return; }
|
||||||
|
QVector<TouchSequenceController::Step> steps;
|
||||||
|
for(const auto &s:m_plan.steps) steps.append({s.target,s.velocityMps,s.accelerationMps2,s.pauseMs,s.label});
|
||||||
|
m_sequence->setContext(m_endpoint,m_device,ready(),m_activeOffset);
|
||||||
|
m_sequence->start(steps,m_observation); refresh();
|
||||||
|
}
|
||||||
|
void TouchOperationWidget::returnObservation(const Pose ¤t) {
|
||||||
|
// Explicit straight return; automatic touch sequences retract before return.
|
||||||
|
auto p=parameters(); double distance=0; for(int i=0;i<3;++i) distance+=std::pow(current[i]-m_observation[i],2);
|
||||||
|
if(std::sqrt(distance)>p.maxTravelM) { fail(QStringLiteral("当前位置超出所设回程范围,请手动接近观察位。")); return; }
|
||||||
|
QVector<TouchSequenceController::Step> steps; Pose tool{};
|
||||||
|
steps.append({m_observation,p.travelVelocityMps,p.accelerationMps2,0,QStringLiteral("返回观察位")});
|
||||||
|
if(!selectedTool(tool)) { fail(QStringLiteral("请选择有效 TCP。")); return; }
|
||||||
|
Pose previous=current,previousFlange{},previousTip{},obsFlange{},obsTip{};
|
||||||
|
if(!TcpCalibration::flangePose(current,m_activeOffset,previousFlange)||!TcpCalibration::toolPose(previousFlange,tool,previousTip)
|
||||||
|
||!TcpCalibration::flangePose(m_observation,m_activeOffset,obsFlange)||!TcpCalibration::toolPose(obsFlange,tool,obsTip)) { fail(QStringLiteral("回程位姿转换失败。")); return; }
|
||||||
|
for(const auto &step:steps) {
|
||||||
|
Pose nextFlange{},nextTip{};
|
||||||
|
if(!TcpCalibration::flangePose(step.target,m_activeOffset,nextFlange)||!TcpCalibration::toolPose(nextFlange,tool,nextTip)) { fail(QStringLiteral("回程位姿转换失败。")); return; }
|
||||||
|
auto norm=[](const Pose &a,const Pose &b) { double sum=0; for(int i=0;i<3;++i) sum+=std::pow(a[i]-b[i],2); return std::sqrt(sum); };
|
||||||
|
const Pose origin{};
|
||||||
|
if(norm(step.target,previous)>p.maxTravelM||norm(nextTip,previousTip)>p.maxTravelM||norm(nextFlange,previousFlange)>p.maxTravelM
|
||||||
|
||norm(step.target,m_observation)>p.maxTravelM||norm(nextTip,obsTip)>p.maxTravelM||norm(nextFlange,obsFlange)>p.maxTravelM
|
||||||
|
||norm(step.target,origin)>p.maxReachM||norm(nextTip,origin)>p.maxReachM||norm(nextFlange,origin)>p.maxReachM) { fail(QStringLiteral("回程路径超出所设运动范围。")); return; }
|
||||||
|
previous=step.target; previousTip=nextTip; previousFlange=nextFlange;
|
||||||
|
}
|
||||||
|
m_sequence->setContext(m_endpoint,m_device,ready(),m_activeOffset); m_sequence->start(steps,current); refresh();
|
||||||
|
}
|
||||||
|
QString TouchOperationWidget::settingsKey() const {
|
||||||
|
QByteArray identity=m_endpoint.toUtf8(); identity.append('\0'); identity.append(m_device.toUtf8());
|
||||||
|
return QStringLiteral("touchOperation/v1/")+QString::fromLatin1(QCryptographicHash::hash(identity,QCryptographicHash::Sha256).toHex());
|
||||||
|
}
|
||||||
|
void TouchOperationWidget::saveTeaching() {
|
||||||
|
if(m_loading||m_endpoint.isEmpty()||m_device.isEmpty()) return;
|
||||||
|
Pose tool{}; QVariantMap data{{"endpoint",m_endpoint},{"device",m_device},{"handEye",m_handEyeChoice->currentText()},{"tool",m_toolChoice->currentText()},
|
||||||
|
{"observed",m_observed},{"observation",values(m_observation)},{"activeOffset",values(m_teachingOffset)}};
|
||||||
|
if(selectedTool(tool)) data.insert("toolOffset",values(tool));
|
||||||
|
QSettings settings; settings.setValue(settingsKey(),QJsonDocument::fromVariant(data).toJson(QJsonDocument::Compact)); settings.sync();
|
||||||
|
if(settings.status()!=QSettings::NoError) { m_status->setText(QStringLiteral("示教配置写入失败")); emit logMessage("ERROR",m_status->text()); }
|
||||||
|
}
|
||||||
|
void TouchOperationWidget::loadTeaching() {
|
||||||
|
QSettings settings; auto bytes=settings.value(settingsKey()).toByteArray(); if(bytes.isEmpty()) return;
|
||||||
|
const auto data=QJsonDocument::fromJson(bytes).toVariant().toMap();
|
||||||
|
if(data.value("endpoint").toString()!=m_endpoint||data.value("device").toString()!=m_device) return;
|
||||||
|
m_loading=true; const int h=m_handEyeChoice->findText(data.value("handEye").toString()),t=m_toolChoice->findText(data.value("tool").toString());
|
||||||
|
if(h>=0) m_handEyeChoice->setCurrentIndex(h);
|
||||||
|
if(t>=0) m_toolChoice->setCurrentIndex(t);
|
||||||
|
m_loading=false;
|
||||||
|
m_observed=data.value("observed").toBool()&&poseFrom(data.value("observation"),m_observation)&&poseFrom(data.value("activeOffset"),m_teachingOffset);
|
||||||
|
|
||||||
|
}
|
||||||
|
void TouchOperationWidget::refresh() {
|
||||||
|
bool busy=running()||m_phase!=Phase::Idle; Pose offset{}; bool selected=selectedTool(offset);
|
||||||
|
m_cameraName->setText(cameraId().isEmpty()?QStringLiteral("请先选择手眼标定"):cameraId());
|
||||||
|
for(auto *w:QList<QWidget*>{m_handEyeChoice,m_toolChoice,m_action,m_reloadButton,m_cameraConfirmed,m_approach,m_press,m_lift,m_speed,m_contactSpeed,m_travel,m_dwell,m_gap}) w->setEnabled(!busy);
|
||||||
|
m_teachObservation->setEnabled(ready()&&!busy); m_returnButton->setEnabled(ready()&&selected&&m_observed&&!busy);
|
||||||
|
|
||||||
|
m_previewButton->setEnabled(m_connected&&!m_demo&&handEye()&&!m_preview&&!busy); m_stopPreviewButton->setEnabled(m_preview);
|
||||||
|
m_lockButton->setEnabled(ready()&&m_observed&&m_preview&&m_cameraConfirmed->isChecked()&&!busy);
|
||||||
|
m_liveButton->setEnabled(m_video->locked()&&!busy); m_video->setEnabled(!busy);
|
||||||
|
m_calculateButton->setEnabled(ready()&&m_video->locked()&&!m_video->selectedPoints().isEmpty()&&!busy);
|
||||||
|
m_executeButton->setEnabled(ready()&&m_planValid&&m_pathConfirmed->isChecked()&&!busy);
|
||||||
|
m_pathConfirmed->setEnabled(m_planValid&&!busy);
|
||||||
|
m_observationText->setText(m_observed?QStringLiteral("观察位 · %1").arg(poseText(m_observation)):QStringLiteral("尚未录入观察位"));
|
||||||
|
refreshTargetResults();
|
||||||
|
if(!running()) m_status->setText(!ready()?QStringLiteral("请连接机械臂并在 TCP 标定页核对控制器工具偏移"):
|
||||||
|
busy?QStringLiteral("正在读取真实位姿 / 图像…"):m_planValid?QStringLiteral("路径已就绪,核对后执行"):m_video->locked()?QStringLiteral("画面已锁定,请选择 1–2 个目标点"):QStringLiteral("录入示教位、选择标定后,在观察位锁定画面"));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TouchOperationWidget::resolveTargets(QVector<TouchPlanner::Point> &basePoints,
|
||||||
|
QVector<TouchPlanner::Point> &cameraPoints,QString &error) const {
|
||||||
|
if(!m_video->locked()||!m_lockedAt) { error=QStringLiteral("请锁定观察画面后选择目标点"); return false; }
|
||||||
|
if(m_video->selectedPoints().isEmpty()) { error=QStringLiteral("请选择 A / B 目标点"); return false; }
|
||||||
|
if(QDateTime::currentMSecsSinceEpoch()-m_lockedAt>60000) { error=QStringLiteral("观察画面已过期,请重新锁定"); return false; }
|
||||||
|
if(!ready()||!handEye()) { error=QStringLiteral("请核对连接、手眼标定与 TCP 偏移"); return false; }
|
||||||
|
TouchPlanner::Matrix baseCamera{};
|
||||||
|
if(!TouchPlanner::cameraTransform(*handEye(),m_lockedFlange,baseCamera,&error)) return false;
|
||||||
|
return TouchPlanner::resolveDepthPixels(m_video->selectedPoints(),m_cameraModel,m_depth,baseCamera,
|
||||||
|
parameters(),basePoints,cameraPoints,&error);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchOperationWidget::refreshTargetResults() {
|
||||||
|
const auto pixels=m_video->selectedPoints(); QVector<TouchPlanner::Point> base,camera; QString error;
|
||||||
|
const bool valid=resolveTargets(base,camera,error);
|
||||||
|
m_conversionStatus->setText(valid?QStringLiteral("%1 个深度目标点 · 换算完成").arg(base.size()):error);
|
||||||
|
m_targets->setRowCount(pixels.size());
|
||||||
|
auto xyz=[](const TouchPlanner::Point &point) {
|
||||||
|
return QStringLiteral("X %1\nY %2\nZ %3").arg(point[0]*1000,0,'f',3).arg(point[1]*1000,0,'f',3).arg(point[2]*1000,0,'f',3);
|
||||||
|
};
|
||||||
|
for(int i=0;i<pixels.size();++i) {
|
||||||
|
const QStringList row={i==0?"A":"B",QStringLiteral("u %1\nv %2").arg(pixels[i].x(),0,'f',1).arg(pixels[i].y(),0,'f',1),
|
||||||
|
valid?xyz(camera[i]):QStringLiteral("待换算"),valid?xyz(base[i]):QStringLiteral("待换算")};
|
||||||
|
for(int col=0;col<row.size();++col) { auto *item=new QTableWidgetItem(row[col]); item->setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter); m_targets->setItem(i,col,item); }
|
||||||
|
m_targets->setRowHeight(i,74);
|
||||||
|
}
|
||||||
|
}
|
||||||
99
src/touchoperationwidget.h
Normal file
99
src/touchoperationwidget.h
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "touchplanner.h"
|
||||||
|
#include "touchsequencecontroller.h"
|
||||||
|
#include "tcptoolstore.h"
|
||||||
|
#include "videoframe.h"
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QImage>
|
||||||
|
|
||||||
|
class QComboBox;
|
||||||
|
class QDoubleSpinBox;
|
||||||
|
class QSpinBox;
|
||||||
|
class QCheckBox;
|
||||||
|
class QLabel;
|
||||||
|
class QPushButton;
|
||||||
|
class QTableWidget;
|
||||||
|
class TouchVideoWidget;
|
||||||
|
|
||||||
|
// Page-level workflow. Geometry and motion sequencing live in separate helpers;
|
||||||
|
// all camera/arm I/O is routed through the existing MainWindow / RobotClient.
|
||||||
|
class TouchOperationWidget : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit TouchOperationWidget(QWidget *parent=nullptr);
|
||||||
|
void setContext(const QString &endpoint,const QString &device,bool connected,bool demo,
|
||||||
|
bool reference,const TcpCalibration::Pose &activeOffset);
|
||||||
|
bool running() const;
|
||||||
|
public slots:
|
||||||
|
void reloadCalibrations();
|
||||||
|
void stop();
|
||||||
|
void acceptPose(quint64 token,const QString &device,const QVariantMap &pose,
|
||||||
|
const QVariantMap &state,bool success,const QString &detail);
|
||||||
|
void acceptImage(quint64 token,const QString &camera,const QImage &image,
|
||||||
|
const QVariantMap &intrinsics,const QVariantMap &metadata,bool success,const QString &detail);
|
||||||
|
void acceptFrame(const QString &camera,const VideoFrame &frame,const QString &detail);
|
||||||
|
void acceptStreamState(const QString &camera,bool running,const QString &detail);
|
||||||
|
void acceptCommand(const QString &command,bool success,const QString &detail);
|
||||||
|
signals:
|
||||||
|
void captureRequested(const QString &device,quint64 token);
|
||||||
|
void imageRequested(const QString &camera,quint64 token);
|
||||||
|
void previewRequested(const QString &camera,bool start);
|
||||||
|
void moveRequested(const QString &device,const QVariantMap &target,double speed,double acceleration,quint64 token);
|
||||||
|
void stopRequested(const QString &device);
|
||||||
|
void logMessage(const QString &level,const QString &message);
|
||||||
|
protected:
|
||||||
|
void hideEvent(QHideEvent *event) override;
|
||||||
|
private:
|
||||||
|
enum class Phase { Idle, Observation, LockBefore, LockImage, LockAfter, Return };
|
||||||
|
using Pose=TcpCalibration::Pose;
|
||||||
|
void refresh();
|
||||||
|
void invalidateFrame();
|
||||||
|
void invalidatePlan();
|
||||||
|
void teach(Phase phase);
|
||||||
|
void readPose();
|
||||||
|
void lockFrame();
|
||||||
|
void startPreview();
|
||||||
|
void stopPreview();
|
||||||
|
void calculate();
|
||||||
|
void execute();
|
||||||
|
void returnObservation(const Pose ¤t);
|
||||||
|
void fail(const QString &message);
|
||||||
|
bool ready() const;
|
||||||
|
bool selectedTool(Pose &offset) const;
|
||||||
|
const HandEyeStore::Record *handEye() const;
|
||||||
|
QString cameraId() const;
|
||||||
|
QString settingsKey() const;
|
||||||
|
void loadTeaching();
|
||||||
|
void saveTeaching();
|
||||||
|
TouchPlanner::Parameters parameters() const;
|
||||||
|
bool buildPlane(TouchPlanner::Plane &plane,QString &error) const;
|
||||||
|
bool resolveTargets(QVector<TouchPlanner::Point> &basePoints,
|
||||||
|
QVector<TouchPlanner::Point> &cameraPoints,QString &error) const;
|
||||||
|
void refreshTargetResults();
|
||||||
|
|
||||||
|
QString m_endpoint,m_device,m_previewCamera;
|
||||||
|
bool m_connected=false,m_demo=false,m_reference=false,m_loading=false,m_preview=false;
|
||||||
|
bool m_observed=false,m_planValid=false;
|
||||||
|
Pose m_activeOffset{},m_observation{},m_before{},m_lockedFlange{},m_teachingOffset{};
|
||||||
|
HandEyeStore::Snapshot m_handEyes;
|
||||||
|
TcpToolStore::Snapshot m_tools;
|
||||||
|
TouchPlanner::Plan m_plan;
|
||||||
|
TouchPlanner::CameraModel m_cameraModel;
|
||||||
|
TouchPlanner::DepthImage m_depth;
|
||||||
|
QImage m_pendingImage;
|
||||||
|
qint64 m_beforeAt=0,m_captureAt=0,m_lockedAt=0,m_requestAt=0;
|
||||||
|
quint64 m_serial=0,m_poseToken=0,m_imageToken=0;
|
||||||
|
Phase m_phase=Phase::Idle;
|
||||||
|
QTimer m_timeout;
|
||||||
|
TouchSequenceController *m_sequence;
|
||||||
|
TouchVideoWidget *m_video;
|
||||||
|
QComboBox *m_handEyeChoice,*m_toolChoice,*m_action;
|
||||||
|
QLabel *m_cameraName,*m_status,*m_observationText;
|
||||||
|
QLabel *m_conversionStatus;
|
||||||
|
QCheckBox *m_cameraConfirmed,*m_pathConfirmed;
|
||||||
|
QPushButton *m_previewButton,*m_stopPreviewButton,*m_lockButton,*m_liveButton,*m_teachObservation;
|
||||||
|
QPushButton *m_returnButton,*m_calculateButton,*m_executeButton,*m_reloadButton;
|
||||||
|
QDoubleSpinBox *m_approach,*m_press,*m_lift,*m_speed,*m_contactSpeed,*m_travel;
|
||||||
|
QSpinBox *m_dwell,*m_gap;
|
||||||
|
QTableWidget *m_targets,*m_steps;
|
||||||
|
};
|
||||||
369
src/touchplanner.cpp
Normal file
369
src/touchplanner.cpp
Normal file
@ -0,0 +1,369 @@
|
|||||||
|
#include "touchplanner.h"
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cmath>
|
||||||
|
#include <cstring>
|
||||||
|
#include <QtEndian>
|
||||||
|
|
||||||
|
namespace TouchPlanner {
|
||||||
|
namespace {
|
||||||
|
bool fail(QString *error, const char *message) {
|
||||||
|
if (error) *error=QString::fromUtf8(message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
void clear(QString *error) { if (error) error->clear(); }
|
||||||
|
bool finite(const Point &p) { return std::all_of(p.begin(),p.end(),[](double v){return std::isfinite(v);}); }
|
||||||
|
double norm(const Point &p) { return std::hypot(std::hypot(p[0],p[1]),p[2]); }
|
||||||
|
Point subtract(const Point &a,const Point &b) { return {{a[0]-b[0],a[1]-b[1],a[2]-b[2]}}; }
|
||||||
|
double dot(const Point &a,const Point &b) { return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]; }
|
||||||
|
Point position(const Pose &p) { return {{p[0],p[1],p[2]}}; }
|
||||||
|
Point shifted(const Point &p,const Point &n,double distance) {
|
||||||
|
return {{p[0]+n[0]*distance,p[1]+n[1]*distance,p[2]+n[2]*distance}};
|
||||||
|
}
|
||||||
|
bool within(double value,double minimum,double maximum) {
|
||||||
|
return std::isfinite(value) && value>=minimum && value<=maximum;
|
||||||
|
}
|
||||||
|
bool validParameters(const Parameters &p,QString *error) {
|
||||||
|
if (!within(p.approachM,.001,.05) || !within(p.contactOffsetM,0,.002)
|
||||||
|
|| !within(p.doubleLiftM,.0005,.05)
|
||||||
|
|| !within(p.contactVelocityMps,.005,.03) || !within(p.travelVelocityMps,.005,.1)
|
||||||
|
|| !within(p.accelerationMps2,.01,.5) || p.contactDwellMs<0 || p.contactDwellMs>5000
|
||||||
|
|| p.doubleIntervalMs<0 || p.doubleIntervalMs>500
|
||||||
|
|| !within(p.maxTravelM,.01,1) || !within(p.maxReachM,.05,3)
|
||||||
|
|| !within(p.maxCameraRangeM,.05,5))
|
||||||
|
return fail(error,"触控参数超出允许范围,检查距离、速度、加速度和停留时间。");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool validPlane(const Plane &p,QString *error) {
|
||||||
|
if (!finite(p.origin) || !finite(p.normal) || !finite(p.orientationRad)
|
||||||
|
|| norm(p.origin)>3 || std::abs(norm(p.normal)-1)>1e-6)
|
||||||
|
return fail(error,"目标位置、触控姿态或接近方向无效,请重新取点。");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool validCamera(const CameraModel &c,QString *error) {
|
||||||
|
if (c.width<2 || c.width>16384 || c.height<2 || c.height>16384
|
||||||
|
|| !within(c.fx,1,1e6) || !within(c.fy,1,1e6)
|
||||||
|
|| !within(c.cx,-c.width,2.0*c.width) || !within(c.cy,-c.height,2.0*c.height))
|
||||||
|
return fail(error,"RGB 图像尺寸、焦距或主点无效。");
|
||||||
|
const auto size=c.distortion.size();
|
||||||
|
if (size!=0 && size!=4 && size!=5 && size!=8)
|
||||||
|
return fail(error,"仅支持无畸变或 4、5、8 项标准 Brown 畸变系数。");
|
||||||
|
for (double v:c.distortion) if (!within(v,-100,100))
|
||||||
|
return fail(error,"RGB 畸变系数不是有效的有限数值。");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool number(const QVariant &v,double &out) {
|
||||||
|
if (v.type()!=QVariant::Double && v.type()!=QVariant::Int && v.type()!=QVariant::UInt
|
||||||
|
&& v.type()!=QVariant::LongLong && v.type()!=QVariant::ULongLong) return false;
|
||||||
|
out=v.toDouble(); return std::isfinite(out);
|
||||||
|
}
|
||||||
|
// Brown forward projection and analytic Jacobian. A positive, non-singular
|
||||||
|
// Jacobian is required so an inverse on a folded distortion branch is rejected.
|
||||||
|
bool distort(double x,double y,const std::array<double,8> &k,
|
||||||
|
double &dx,double &dy,std::array<double,4> &j) {
|
||||||
|
if (!within(x,-5,5) || !within(y,-5,5)) return false;
|
||||||
|
const double r2=x*x+y*y,r4=r2*r2,r6=r4*r2;
|
||||||
|
const double a=1+k[0]*r2+k[1]*r4+k[4]*r6;
|
||||||
|
const double b=1+k[5]*r2+k[6]*r4+k[7]*r6;
|
||||||
|
if (!std::isfinite(a) || !std::isfinite(b) || a<=1e-9 || b<=1e-9) return false;
|
||||||
|
const double radial=a/b;
|
||||||
|
const double derivative=((k[0]+2*k[1]*r2+3*k[4]*r4)*b
|
||||||
|
-a*(k[5]+2*k[6]*r2+3*k[7]*r4))/(b*b);
|
||||||
|
dx=x*radial+2*k[2]*x*y+k[3]*(r2+2*x*x);
|
||||||
|
dy=y*radial+k[2]*(r2+2*y*y)+2*k[3]*x*y;
|
||||||
|
j={{radial+2*x*x*derivative+2*k[2]*y+6*k[3]*x,
|
||||||
|
2*x*y*derivative+2*k[2]*x+2*k[3]*y,
|
||||||
|
2*x*y*derivative+2*k[2]*x+2*k[3]*y,
|
||||||
|
radial+2*y*y*derivative+6*k[2]*y+2*k[3]*x}};
|
||||||
|
const double det=j[0]*j[3]-j[1]*j[2];
|
||||||
|
return std::isfinite(dx) && std::isfinite(dy) && std::isfinite(det) && det>1e-10;
|
||||||
|
}
|
||||||
|
bool ray(const QPointF &pixel,const CameraModel &c,Point &direction,QString *error) {
|
||||||
|
if (!within(pixel.x(),0,c.width-1.0) || !within(pixel.y(),0,c.height-1.0))
|
||||||
|
return fail(error,"触控像素必须位于所锁定的 RGB 图像内。");
|
||||||
|
const double wantedX=(pixel.x()-c.cx)/c.fx,wantedY=(pixel.y()-c.cy)/c.fy;
|
||||||
|
double x=wantedX,y=wantedY;
|
||||||
|
std::array<double,8> k{};
|
||||||
|
std::copy(c.distortion.begin(),c.distortion.end(),k.begin());
|
||||||
|
bool converged=false;
|
||||||
|
for (int iteration=0;iteration<30;++iteration) {
|
||||||
|
double actualX=0,actualY=0; std::array<double,4> j{};
|
||||||
|
if (!distort(x,y,k,actualX,actualY,j))
|
||||||
|
return fail(error,"畸变反解不稳定,不能生成触控射线。");
|
||||||
|
const double ex=actualX-wantedX,ey=actualY-wantedY;
|
||||||
|
if (std::hypot(ex,ey)<1e-12) { converged=true; break; }
|
||||||
|
const double det=j[0]*j[3]-j[1]*j[2];
|
||||||
|
const double sx=(j[3]*ex-j[1]*ey)/det,sy=(-j[2]*ex+j[0]*ey)/det;
|
||||||
|
bool improved=false;
|
||||||
|
for (int search=0;search<12;++search) {
|
||||||
|
const double scale=std::ldexp(1.0,-search);
|
||||||
|
const double tx=x-scale*sx,ty=y-scale*sy;
|
||||||
|
double px=0,py=0; std::array<double,4> unused{};
|
||||||
|
if (distort(tx,ty,k,px,py,unused) && std::hypot(px-wantedX,py-wantedY)<std::hypot(ex,ey)) {
|
||||||
|
x=tx; y=ty; improved=true; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!improved) break;
|
||||||
|
}
|
||||||
|
if (!converged) return fail(error,"RGB 像素畸变反解未收敛,请核对相机内参与模型。");
|
||||||
|
const double length=std::hypot(std::hypot(x,y),1.0);
|
||||||
|
direction={{x/length,y/length,1.0/length}};
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool teachPlane(const std::array<Pose,3> &contacts,const Pose &observation,Plane &plane,QString *error) {
|
||||||
|
if (!TcpCalibration::validPose(observation) || norm(position(observation))>3)
|
||||||
|
return fail(error,"观察位必须是有限的米制 TCP 位姿。");
|
||||||
|
for (const Pose &p:contacts) if (!TcpCalibration::validPose(p) || norm(position(p))>3)
|
||||||
|
return fail(error,"平面示教点必须是有限的米制 TCP 位姿。");
|
||||||
|
const Point a=subtract(position(contacts[1]),position(contacts[0]));
|
||||||
|
const Point b=subtract(position(contacts[2]),position(contacts[0]));
|
||||||
|
const double la=norm(a),lb=norm(b);
|
||||||
|
if (!within(la,.01,1) || !within(lb,.01,1)
|
||||||
|
|| !within(norm(subtract(position(contacts[2]),position(contacts[1]))),.01,1))
|
||||||
|
return fail(error,"三个平面示教点之间至少间隔 10 mm,最大基线不超过 1 m。");
|
||||||
|
Point n{{a[1]*b[2]-a[2]*b[1],a[2]*b[0]-a[0]*b[2],a[0]*b[1]-a[1]*b[0]}};
|
||||||
|
const double length=norm(n);
|
||||||
|
if (length/(la*lb)<.08715574274765817)
|
||||||
|
return fail(error,"平面示教点共线或接近共线,请扩大点位三角形(夹角至少 5 度)。");
|
||||||
|
for (double &v:n) v/=length;
|
||||||
|
const double side=dot(subtract(position(observation),position(contacts[0])),n);
|
||||||
|
if (std::abs(side)<.001)
|
||||||
|
return fail(error,"观察位必须离开触控平面至少 1 mm,以确定安全回撤方向。");
|
||||||
|
if (side<0) for (double &v:n) v=-v;
|
||||||
|
Plane result; result.origin=position(contacts[0]); result.normal=n;
|
||||||
|
result.orientationRad={{contacts[0][3],contacts[0][4],contacts[0][5]}};
|
||||||
|
plane=result; clear(error); return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cameraTransform(const HandEyeStore::Record &record,const Pose &flange,Matrix &baseCamera,QString *error) {
|
||||||
|
QString detail;
|
||||||
|
if (!HandEyeStore::validateRecord(record,detail)) { if (error) *error=detail; return false; }
|
||||||
|
Matrix result=record.transform;
|
||||||
|
if (record.mode==QStringLiteral("eye_in_hand")) {
|
||||||
|
Matrix baseFlange{};
|
||||||
|
if (!TcpCalibration::poseMatrix(flange,baseFlange,error)) return false;
|
||||||
|
result.fill(0);
|
||||||
|
for (int r=0;r<4;++r) for (int c=0;c<4;++c) for (int k=0;k<4;++k)
|
||||||
|
result[size_t(4*r+c)]+=baseFlange[size_t(4*r+k)]*record.transform[size_t(4*k+c)];
|
||||||
|
}
|
||||||
|
Pose checked{};
|
||||||
|
if (!TcpCalibration::matrixPose(result,checked,error)) return false;
|
||||||
|
baseCamera=result; clear(error); return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cameraModel(const QVariantMap &data,int width,int height,CameraModel &camera,QString *error) {
|
||||||
|
CameraModel result; result.width=width; result.height=height;
|
||||||
|
for (const QString &key:{QStringLiteral("width"),QStringLiteral("height")}) if (data.contains(key)) {
|
||||||
|
double value=0;
|
||||||
|
if (!number(data.value(key),value) || value!=(key=="width"?width:height))
|
||||||
|
return fail(error,"RGB 内参尺寸与图像不一致,禁止自动缩放或使用裁剪图。");
|
||||||
|
}
|
||||||
|
for (const QString &key:{QStringLiteral("model"),QStringLiteral("distortion_model")}) if (data.contains(key)) {
|
||||||
|
const QString model=data.value(key).toString().trimmed().toLower();
|
||||||
|
if (model!="none" && model!="0" && model!="4" && model!="brown_conrady"
|
||||||
|
&& model!="brown-conrady" && model!="opencv" && model!="plumb_bob"
|
||||||
|
&& model!="rational_polynomial")
|
||||||
|
return fail(error,"当前 RGB 畸变模型不是受支持的标准 Brown 模型。");
|
||||||
|
}
|
||||||
|
if (data.contains("camera_matrix")) {
|
||||||
|
const auto values=data.value("camera_matrix").toList();
|
||||||
|
std::array<double,9> k{};
|
||||||
|
if (values.size()!=9) return fail(error,"相机内参矩阵需要 9 个有限数值。");
|
||||||
|
for (int i=0;i<9;++i) if (!number(values[i],k[size_t(i)]))
|
||||||
|
return fail(error,"相机内参矩阵需要 9 个有限数值。");
|
||||||
|
if (std::abs(k[1])+std::abs(k[3])+std::abs(k[6])+std::abs(k[7])+std::abs(k[8]-1)>1e-9)
|
||||||
|
return fail(error,"相机内参必须为无斜切的标准针孔矩阵。");
|
||||||
|
result.fx=k[0]; result.fy=k[4]; result.cx=k[2]; result.cy=k[5];
|
||||||
|
} else if (!number(data.value("fx"),result.fx) || !number(data.value("fy"),result.fy)
|
||||||
|
|| !number(data.value("cx"),result.cx) || !number(data.value("cy"),result.cy)) {
|
||||||
|
return fail(error,"缺少有效的 RGB 焦距与主点参数。");
|
||||||
|
}
|
||||||
|
const QVariant coefficients=data.value(data.contains("coeffs")?"coeffs":"distortion");
|
||||||
|
if (coefficients.type()!=QVariant::List)
|
||||||
|
return fail(error,"RGB 内参必须明确提供畸变系数列表(无畸变时为空列表)。");
|
||||||
|
for (const QVariant &v:coefficients.toList()) {
|
||||||
|
double value=0;
|
||||||
|
if (!number(v,value)) return fail(error,"畸变系数必须为有限数值。");
|
||||||
|
result.distortion.push_back(value);
|
||||||
|
}
|
||||||
|
if (!validCamera(result,error)) return false;
|
||||||
|
camera=result; clear(error); return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool resolvePixels(const QVector<QPointF> &pixels,const CameraModel &camera,const Matrix &baseCamera,
|
||||||
|
const Plane &plane,const Parameters ¶meters,QVector<Point> &points,QString *error) {
|
||||||
|
if (pixels.isEmpty() || pixels.size()>2) return fail(error,"请选择 1 至 2 个 RGB 图像点。");
|
||||||
|
if (!validCamera(camera,error) || !validPlane(plane,error) || !validParameters(parameters,error)) return false;
|
||||||
|
Pose cameraPose{};
|
||||||
|
if (!TcpCalibration::matrixPose(baseCamera,cameraPose,error)) return false;
|
||||||
|
const Point origin=position(cameraPose);
|
||||||
|
if (norm(origin)>parameters.maxReachM) return fail(error,"相机基座坐标超出配置的工作空间范围。");
|
||||||
|
QVector<Point> result;
|
||||||
|
for (const QPointF &pixel:pixels) {
|
||||||
|
Point cameraRay{},baseRay{};
|
||||||
|
if (!ray(pixel,camera,cameraRay,error)) return false;
|
||||||
|
for (int r=0;r<3;++r) for (int c=0;c<3;++c)
|
||||||
|
baseRay[size_t(r)]+=baseCamera[size_t(r*4+c)]*cameraRay[size_t(c)];
|
||||||
|
const double cosine=dot(plane.normal,baseRay);
|
||||||
|
if (std::abs(cosine)<.02) return fail(error,"像素射线与示教平面接近平行,无法可靠求交。");
|
||||||
|
const double distance=dot(plane.normal,subtract(plane.origin,origin))/cosine;
|
||||||
|
if (!within(distance,.005,parameters.maxCameraRangeM))
|
||||||
|
return fail(error,"触控交点位于相机后方、过近或超出相机距离限制。");
|
||||||
|
const Point point=shifted(origin,baseRay,distance);
|
||||||
|
if (!finite(point) || norm(point)>parameters.maxReachM)
|
||||||
|
return fail(error,"触控交点超出配置的基座工作空间范围。");
|
||||||
|
if (norm(subtract(point,plane.origin))>parameters.maxTravelM)
|
||||||
|
return fail(error,"触控交点离平面示教原点过远,超过最大行程。");
|
||||||
|
result.append(point);
|
||||||
|
}
|
||||||
|
points=result; clear(error); return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool resolveDepthPixels(const QVector<QPointF> &pixels,const CameraModel &camera,
|
||||||
|
const DepthImage &depth,const Matrix &baseCamera,const Parameters &p,
|
||||||
|
QVector<Point> &basePoints,QVector<Point> &cameraPoints,QString *error) {
|
||||||
|
if (pixels.isEmpty() || pixels.size()>2 || !validCamera(camera,error) || !validParameters(p,error))
|
||||||
|
return fail(error,"请选择 1 至 2 个有效 RGB 点并核对相机参数。");
|
||||||
|
Pose pose{};
|
||||||
|
if (!TcpCalibration::matrixPose(baseCamera,pose,error)) return false;
|
||||||
|
const int bytes=depth.float32?4:2;
|
||||||
|
if (depth.width!=camera.width || depth.height!=camera.height
|
||||||
|
|| !within(depth.metresPerUnit,1e-9,1)
|
||||||
|
|| qint64(depth.width)*depth.height*bytes!=depth.data.size())
|
||||||
|
return fail(error,"缺少与锁定 RGB 对齐的原始深度或有效深度单位。");
|
||||||
|
if (norm(position(pose))>p.maxReachM) return fail(error,"相机位置超出工作空间。");
|
||||||
|
QVector<Point> base,cameraResult;
|
||||||
|
for (const auto &pixel:pixels) {
|
||||||
|
Point direction{}; if (!ray(pixel,camera,direction,error)) return false;
|
||||||
|
const int x=qRound(pixel.x()),y=qRound(pixel.y());
|
||||||
|
std::vector<double> samples;
|
||||||
|
// Phone _depth_mm: local valid-depth median. Keep a small 5x5 patch;
|
||||||
|
// reject depth edges instead of expanding onto an unrelated surface.
|
||||||
|
for (int v=qMax(0,y-2);v<=qMin(depth.height-1,y+2);++v)
|
||||||
|
for (int u=qMax(0,x-2);u<=qMin(depth.width-1,x+2);++u) {
|
||||||
|
const auto *raw=reinterpret_cast<const uchar*>(depth.data.constData())+(v*depth.width+u)*bytes;
|
||||||
|
double value=0;
|
||||||
|
if (depth.float32) {
|
||||||
|
const quint32 bits=qFromLittleEndian<quint32>(raw); float f=0;
|
||||||
|
std::memcpy(&f,&bits,sizeof(f)); value=f;
|
||||||
|
} else value=qFromLittleEndian<quint16>(raw);
|
||||||
|
value*=depth.metresPerUnit;
|
||||||
|
if (within(value,.05,p.maxCameraRangeM)) samples.push_back(value);
|
||||||
|
}
|
||||||
|
if (samples.size()<5) return fail(error,"目标点附近有效深度不足,请重新取图或选择可测量位置。");
|
||||||
|
std::sort(samples.begin(),samples.end());
|
||||||
|
const double z=samples[samples.size()/2];
|
||||||
|
if (samples.back()-samples.front()>.005)
|
||||||
|
return fail(error,"目标点处深度跳变超过 5 mm,请避开遮挡边缘或重新取图。");
|
||||||
|
Point cp{},bp{};
|
||||||
|
for (int i=0;i<3;++i) cp[i]=direction[i]*z/direction[2]; // Z, not Euclidean range.
|
||||||
|
if (norm(cp)>p.maxCameraRangeM) return fail(error,"目标超出相机测量范围。");
|
||||||
|
for (int r=0;r<3;++r) {
|
||||||
|
bp[r]=baseCamera[r*4+3];
|
||||||
|
for (int c=0;c<3;++c) bp[r]+=baseCamera[r*4+c]*cp[c];
|
||||||
|
}
|
||||||
|
if (!finite(bp) || norm(bp)>p.maxReachM) return fail(error,"深度目标超出基座工作空间。");
|
||||||
|
base.append(bp); cameraResult.append(cp);
|
||||||
|
}
|
||||||
|
basePoints=base; cameraPoints=cameraResult; clear(error); return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool validateDepthSwipe(const QVector<QPointF> &pixels,const CameraModel &camera,
|
||||||
|
const DepthImage &depth,const Matrix &baseCamera,const Parameters &p,QString *error) {
|
||||||
|
if (pixels.size()!=2) return fail(error,"滑动需要 A/B 两点。");
|
||||||
|
QVector<Point> ends,unused;
|
||||||
|
if (!resolveDepthPixels(pixels,camera,depth,baseCamera,p,ends,unused,error)) return false;
|
||||||
|
const Point segment=subtract(ends[1],ends[0]); const double length=norm(segment);
|
||||||
|
if (length<.0001) return fail(error,"滑动端点间距不足 0.1 mm。");
|
||||||
|
const int count=qMax(2,int(std::ceil(std::hypot(pixels[1].x()-pixels[0].x(),pixels[1].y()-pixels[0].y())/2)));
|
||||||
|
for (int i=1;i<count;++i) {
|
||||||
|
const double t=double(i)/count;
|
||||||
|
QVector<Point> current;
|
||||||
|
if (!resolveDepthPixels({pixels[0]*(1-t)+pixels[1]*t},camera,depth,baseCamera,p,current,unused,error)) return false;
|
||||||
|
const Point delta=subtract(current[0],ends[0]);
|
||||||
|
const double along=dot(delta,segment)/(length*length);
|
||||||
|
if (along<-.01 || along>1.01 || norm(subtract(delta,shifted(Point{},segment,along)))>.003)
|
||||||
|
return fail(error,"滑动路径深度偏离直线超过 3 mm,不能执行直线触控。");
|
||||||
|
}
|
||||||
|
clear(error); return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool buildPlan(Action action,const QVector<Point> &points,const Plane &plane,const Pose &observationActive,
|
||||||
|
const Pose &flangeActive,const Pose &flangeSelected,const Parameters &p,Plan &plan,QString *error,bool depthTargets) {
|
||||||
|
if (action!=Action::SingleTap && action!=Action::DoubleTap && action!=Action::Swipe)
|
||||||
|
return fail(error,"未知触控动作。");
|
||||||
|
if (points.isEmpty() || points.size()>2 || (action==Action::Swipe && points.size()!=2))
|
||||||
|
return fail(error,"单击或双击需要 1 至 2 点,滑动必须恰好选择 2 点。");
|
||||||
|
if (!validPlane(plane,error) || !validParameters(p,error)) return false;
|
||||||
|
if (action==Action::DoubleTap && (p.doubleLiftM<p.contactOffsetM+.0005 || p.doubleLiftM>p.approachM+p.contactOffsetM))
|
||||||
|
return fail(error,"双击短抬必须越过接触偏移至少 0.5 mm,且不超过接近点。");
|
||||||
|
Pose observationFlange{},observationSelected{};
|
||||||
|
if (!TcpCalibration::flangePose(observationActive,flangeActive,observationFlange,error)
|
||||||
|
|| !TcpCalibration::toolPose(observationFlange,flangeSelected,observationSelected,error)) return false;
|
||||||
|
if (dot(subtract(position(observationSelected),plane.origin),plane.normal)<p.approachM-1e-9)
|
||||||
|
return fail(error,"观察 TCP 必须位于平面外侧,且离面距离不少于接近距离。");
|
||||||
|
for (const Point &point:points) {
|
||||||
|
if (!finite(point) || (!depthTargets && std::abs(dot(subtract(point,plane.origin),plane.normal))>1e-5))
|
||||||
|
return fail(error,"触控目标不在已示教平面上。");
|
||||||
|
if (depthTargets && dot(subtract(position(observationSelected),point),plane.normal)<p.approachM)
|
||||||
|
return fail(error,"观察位必须位于每个深度目标的接近方向外侧。");
|
||||||
|
if (norm(subtract(point,plane.origin))>p.maxTravelM)
|
||||||
|
return fail(error,"触控目标之间的距离超过最大行程。");
|
||||||
|
}
|
||||||
|
if (action==Action::Swipe && norm(subtract(points[0],points[1]))<.0001)
|
||||||
|
return fail(error,"滑动起点和终点至少间隔 0.1 mm。");
|
||||||
|
Plan result; result.contacts=points;
|
||||||
|
Pose previousActive=observationActive,previousSelected=observationSelected;
|
||||||
|
double totalTravel=0;
|
||||||
|
const auto append=[&](const QString &label,const Pose &active,const Pose &selected,
|
||||||
|
double speed,int pause)->bool {
|
||||||
|
Pose flange{};
|
||||||
|
if (!TcpCalibration::flangePose(active,flangeActive,flange,error)) return false;
|
||||||
|
if (!TcpCalibration::validPose(active) || !TcpCalibration::validPose(selected)
|
||||||
|
|| norm(position(active))>p.maxReachM || norm(position(selected))>p.maxReachM
|
||||||
|
|| norm(position(flange))>p.maxReachM)
|
||||||
|
return fail(error,"规划路径超出配置的 TCP / 法兰工作空间半径。");
|
||||||
|
const double activeTravel=norm(subtract(position(active),position(previousActive)));
|
||||||
|
const double tipTravel=norm(subtract(position(selected),position(previousSelected)));
|
||||||
|
if (activeTravel>p.maxTravelM || tipTravel>p.maxTravelM
|
||||||
|
|| norm(subtract(position(active),position(observationActive)))>p.maxTravelM
|
||||||
|
|| norm(subtract(position(selected),position(observationSelected)))>p.maxTravelM)
|
||||||
|
return fail(error,"规划路径超出单段行程或观察位距离限制。");
|
||||||
|
totalTravel+=std::max(activeTravel,tipTravel);
|
||||||
|
if (totalTravel>12*p.maxTravelM || result.steps.size()>=12)
|
||||||
|
return fail(error,"触控路径总行程或步骤数量超出限制。");
|
||||||
|
result.steps.append(Step{label,active,speed,p.accelerationMps2,pause});
|
||||||
|
previousActive=active; previousSelected=selected; return true;
|
||||||
|
};
|
||||||
|
// Check the starting poses too, including a potentially long saved tool offset.
|
||||||
|
if (norm(position(observationActive))>p.maxReachM || norm(position(observationSelected))>p.maxReachM
|
||||||
|
|| norm(position(observationFlange))>p.maxReachM)
|
||||||
|
return fail(error,"观察位超出配置的 TCP / 法兰工作空间半径。");
|
||||||
|
const auto target=[&](const QString &label,const Point &surface,double normalOffset,double speed,int pause)->bool {
|
||||||
|
const Point xyz=shifted(surface,plane.normal,normalOffset);
|
||||||
|
const Pose selected{{xyz[0],xyz[1],xyz[2],plane.orientationRad[0],plane.orientationRad[1],plane.orientationRad[2]}};
|
||||||
|
Pose flange{},active{};
|
||||||
|
if (!TcpCalibration::flangePose(selected,flangeSelected,flange,error)
|
||||||
|
|| !TcpCalibration::toolPose(flange,flangeActive,active,error)) return false;
|
||||||
|
return append(label,active,selected,speed,pause);
|
||||||
|
};
|
||||||
|
const int visits=action==Action::Swipe?1:points.size();
|
||||||
|
for (int visit=0;visit<visits;++visit) {
|
||||||
|
const Point &start=points[visit];
|
||||||
|
const QString index=QString::number(visit+1);
|
||||||
|
if (!target(QStringLiteral("接近点 ")+index,start,p.approachM,p.travelVelocityMps,0)
|
||||||
|
|| !target(QStringLiteral("接触点 ")+index,start,-p.contactOffsetM,p.contactVelocityMps,
|
||||||
|
action==Action::Swipe?0:p.contactDwellMs)) return false;
|
||||||
|
if (action==Action::DoubleTap) {
|
||||||
|
if (!target(QStringLiteral("双击短抬 ")+index,start,p.doubleLiftM-p.contactOffsetM,p.contactVelocityMps,p.doubleIntervalMs)
|
||||||
|
|| !target(QStringLiteral("第二次接触 ")+index,start,-p.contactOffsetM,p.contactVelocityMps,p.contactDwellMs)) return false;
|
||||||
|
}
|
||||||
|
if (action==Action::Swipe && !target(QStringLiteral("滑动到终点"),points[1],-p.contactOffsetM,p.contactVelocityMps,p.contactDwellMs)) return false;
|
||||||
|
const Point &end=action==Action::Swipe?points[1]:start;
|
||||||
|
if (!target(QStringLiteral("回撤"),end,p.approachM,p.contactVelocityMps,0)
|
||||||
|
|| !append(QStringLiteral("返回观察位"),observationActive,observationSelected,p.travelVelocityMps,0)) return false;
|
||||||
|
}
|
||||||
|
plan=result; clear(error); return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
83
src/touchplanner.h
Normal file
83
src/touchplanner.h
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "handeyestore.h"
|
||||||
|
#include <QPointF>
|
||||||
|
#include <QVector>
|
||||||
|
#include <QByteArray>
|
||||||
|
|
||||||
|
// Offline geometry only. All distances are metres and all angles are ZYX radians.
|
||||||
|
// The caller owns frame provenance, observation matching, controller reach/IK
|
||||||
|
// checks, collision clearance, and execution; no hardware is accessed here.
|
||||||
|
namespace TouchPlanner {
|
||||||
|
using Pose = TcpCalibration::Pose;
|
||||||
|
using Matrix = TcpCalibration::Matrix;
|
||||||
|
using Point = std::array<double, 3>;
|
||||||
|
|
||||||
|
struct CameraModel {
|
||||||
|
int width = 0, height = 0;
|
||||||
|
double fx = 0, fy = 0, cx = 0, cy = 0;
|
||||||
|
std::vector<double> distortion; // OpenCV Brown order: k1,k2,p1,p2[,k3[,k4,k5,k6]].
|
||||||
|
};
|
||||||
|
struct Plane {
|
||||||
|
Point origin{};
|
||||||
|
Point normal{}; // Unit outward normal, toward the taught observation tip.
|
||||||
|
Point orientationRad{}; // Selected-tip orientation from the first contact teach.
|
||||||
|
};
|
||||||
|
struct DepthImage {
|
||||||
|
int width = 0, height = 0;
|
||||||
|
QByteArray data; // Owning raw little-endian samples, aligned to native RGB.
|
||||||
|
bool float32 = false;
|
||||||
|
double metresPerUnit = 0; // Explicit transport contract, never inferred from type.
|
||||||
|
};
|
||||||
|
struct Parameters {
|
||||||
|
double approachM = .01;
|
||||||
|
double contactOffsetM = 0; // Positive presses inward, opposite the outward normal.
|
||||||
|
double doubleLiftM = .003;
|
||||||
|
double contactVelocityMps = .01;
|
||||||
|
double travelVelocityMps = .03;
|
||||||
|
double accelerationMps2 = .1;
|
||||||
|
int contactDwellMs = 80;
|
||||||
|
int doubleIntervalMs = 100;
|
||||||
|
double maxTravelM = .3; // Radius from observation AND maximum movement per segment.
|
||||||
|
double maxReachM = 2; // Conservative base-origin sphere, not a substitute for IK.
|
||||||
|
double maxCameraRangeM = 3;
|
||||||
|
};
|
||||||
|
enum class Action { SingleTap, DoubleTap, Swipe };
|
||||||
|
struct Step {
|
||||||
|
QString label;
|
||||||
|
Pose target{}; // Target of the controller's existing active TCP.
|
||||||
|
double velocityMps = 0;
|
||||||
|
double accelerationMps2 = 0;
|
||||||
|
int pauseMs = 0; // Applied after the target has been reached.
|
||||||
|
};
|
||||||
|
struct Plan {
|
||||||
|
QVector<Step> steps;
|
||||||
|
QVector<Point> contacts; // Unpressed surface points in base coordinates.
|
||||||
|
};
|
||||||
|
|
||||||
|
// All functions leave output unchanged on failure and clear error on success.
|
||||||
|
bool teachPlane(const std::array<Pose, 3> &selectedContacts,
|
||||||
|
const Pose &observationSelected, Plane &plane, QString *error = nullptr);
|
||||||
|
bool cameraTransform(const HandEyeStore::Record &record, const Pose &lockedBaseFlange,
|
||||||
|
Matrix &baseCamera, QString *error = nullptr);
|
||||||
|
// Exact-size intrinsics only; callers must establish the RGB distortion model.
|
||||||
|
// Supports fx/fy/cx/cy + coeffs, or camera_matrix + distortion. Does not rescale.
|
||||||
|
bool cameraModel(const QVariantMap &intrinsics, int imageWidth, int imageHeight,
|
||||||
|
CameraModel &camera, QString *error = nullptr);
|
||||||
|
bool resolvePixels(const QVector<QPointF> &pixels, const CameraModel &camera,
|
||||||
|
const Matrix &baseCamera, const Plane &plane, const Parameters ¶meters,
|
||||||
|
QVector<Point> &points, QString *error = nullptr);
|
||||||
|
bool resolveDepthPixels(const QVector<QPointF> &pixels, const CameraModel &camera,
|
||||||
|
const DepthImage &depth, const Matrix &baseCamera,
|
||||||
|
const Parameters ¶meters, QVector<Point> &basePoints,
|
||||||
|
QVector<Point> &cameraPoints, QString *error = nullptr);
|
||||||
|
bool validateDepthSwipe(const QVector<QPointF> &pixels, const CameraModel &camera,
|
||||||
|
const DepthImage &depth, const Matrix &baseCamera,
|
||||||
|
const Parameters ¶meters, QString *error = nullptr);
|
||||||
|
// Single/double tap visit 1-2 contacts sequentially, returning to observation after
|
||||||
|
// each. Swipe requires two distinct contacts. All use approach/contact/retract.
|
||||||
|
bool buildPlan(Action action, const QVector<Point> &points, const Plane &plane,
|
||||||
|
const Pose &observationActive, const Pose &flangeActive,
|
||||||
|
const Pose &flangeSelected, const Parameters ¶meters,
|
||||||
|
Plan &plan, QString *error = nullptr, bool depthTargets = false);
|
||||||
|
}
|
||||||
228
src/touchsequencecontroller.cpp
Normal file
228
src/touchsequencecontroller.cpp
Normal file
@ -0,0 +1,228 @@
|
|||||||
|
#include "touchsequencecontroller.h"
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
constexpr int kReadTimeoutMs = 6000;
|
||||||
|
constexpr int kMoveTimeoutMs = 30000;
|
||||||
|
constexpr int kSequenceTimeoutMs = 180000;
|
||||||
|
constexpr double kPositionToleranceM = .0005;
|
||||||
|
constexpr double kRotationToleranceRad = .2 * 3.14159265358979323846 / 180;
|
||||||
|
|
||||||
|
bool poseMatches(const TcpCalibration::Pose &actual, const TcpCalibration::Pose &expected)
|
||||||
|
{
|
||||||
|
double squaredDistance = 0;
|
||||||
|
for (int i = 0; i < 3; ++i)
|
||||||
|
squaredDistance += std::pow(actual[size_t(i)] - expected[size_t(i)], 2);
|
||||||
|
if (squaredDistance > kPositionToleranceM * kPositionToleranceM)
|
||||||
|
return false;
|
||||||
|
TcpCalibration::Matrix a{}, b{};
|
||||||
|
if (!TcpCalibration::poseMatrix(actual, a) || !TcpCalibration::poseMatrix(expected, b))
|
||||||
|
return false;
|
||||||
|
// Relative rotation, including equivalent Euler representations at +/-pi.
|
||||||
|
double trace = 0;
|
||||||
|
for (int row = 0; row < 3; ++row)
|
||||||
|
for (int col = 0; col < 3; ++col)
|
||||||
|
trace += a[size_t(row * 4 + col)] * b[size_t(row * 4 + col)];
|
||||||
|
const double angle = std::acos(std::max(-1.0, std::min(1.0, (trace - 1) / 2)));
|
||||||
|
return angle <= kRotationToleranceRad;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool stoppedHealthy(const QVariantMap &state)
|
||||||
|
{
|
||||||
|
return state.value("connected").toBool()
|
||||||
|
&& !state.value("moving", true).toBool()
|
||||||
|
&& !state.value("fault", true).toBool()
|
||||||
|
&& !state.value("protectiveStopped", true).toBool()
|
||||||
|
&& !state.value("emergencyStopped", true).toBool();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TouchSequenceController::TouchSequenceController(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
m_timeout.setSingleShot(true);
|
||||||
|
m_deadline.setSingleShot(true);
|
||||||
|
m_dwell.setSingleShot(true);
|
||||||
|
m_dwell.setTimerType(Qt::PreciseTimer);
|
||||||
|
connect(&m_timeout, &QTimer::timeout, this, [this] {
|
||||||
|
fail(QStringLiteral("触控动作反馈超时,已请求停止;不会自动回程"));
|
||||||
|
});
|
||||||
|
connect(&m_deadline, &QTimer::timeout, this, [this] {
|
||||||
|
fail(QStringLiteral("触控任务超出总时限,已请求停止;不会自动回程"));
|
||||||
|
});
|
||||||
|
connect(&m_dwell, &QTimer::timeout, this, [this] {
|
||||||
|
if (m_phase == Phase::Dwelling) readPose(Phase::AfterDwellRead);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
QString TouchSequenceController::commandName(quint64 token)
|
||||||
|
{
|
||||||
|
// RobotClient::requestTcpJogMove uses this existing command namespace.
|
||||||
|
return QStringLiteral("TCPJog/%1").arg(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchSequenceController::setContext(const QString &endpoint, const QString &device,
|
||||||
|
bool ready, const TcpCalibration::Pose &activeOffset,
|
||||||
|
const QString &contextRevision)
|
||||||
|
{
|
||||||
|
if (m_endpoint != endpoint || m_device != device || m_ready != ready
|
||||||
|
|| m_activeOffset != activeOffset || m_contextRevision != contextRevision)
|
||||||
|
stop(); // Stop the old device before replacing its identity.
|
||||||
|
m_endpoint = endpoint;
|
||||||
|
m_device = device;
|
||||||
|
m_ready = ready;
|
||||||
|
m_activeOffset = activeOffset;
|
||||||
|
m_contextRevision = contextRevision;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TouchSequenceController::start(const QVector<Step> &steps,
|
||||||
|
const TcpCalibration::Pose &expectedInitialPose)
|
||||||
|
{
|
||||||
|
if (running()) return false;
|
||||||
|
bool valid = m_ready && !m_endpoint.trimmed().isEmpty() && !m_device.trimmed().isEmpty()
|
||||||
|
&& TcpCalibration::validPose(m_activeOffset)
|
||||||
|
&& TcpCalibration::validPose(expectedInitialPose)
|
||||||
|
&& !steps.isEmpty() && steps.size() <= 128;
|
||||||
|
for (const auto &step : steps) {
|
||||||
|
valid = valid && TcpCalibration::validPose(step.target)
|
||||||
|
&& std::isfinite(step.speed) && step.speed > 0 && step.speed <= .05
|
||||||
|
&& std::isfinite(step.acceleration) && step.acceleration > 0 && step.acceleration <= .5
|
||||||
|
&& step.dwellMs >= 0 && step.dwellMs <= 5000;
|
||||||
|
}
|
||||||
|
if (!valid) {
|
||||||
|
emit errorOccurred(QStringLiteral("触控路径或机械臂上下文无效,请核对连接、活动 TCP 和运动参数"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
m_steps = steps;
|
||||||
|
m_expected = expectedInitialPose;
|
||||||
|
m_index = 0;
|
||||||
|
m_deadline.start(kSequenceTimeoutMs);
|
||||||
|
readPose(Phase::InitialRead);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchSequenceController::readPose(Phase phase)
|
||||||
|
{
|
||||||
|
m_phase = phase;
|
||||||
|
++m_token;
|
||||||
|
m_captureIssuedAtMs = QDateTime::currentMSecsSinceEpoch();
|
||||||
|
m_timeout.start(kReadTimeoutMs);
|
||||||
|
emit captureRequested(m_device, m_token);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchSequenceController::moveNext()
|
||||||
|
{
|
||||||
|
if (!running()) return;
|
||||||
|
const Step step = m_steps.at(m_index);
|
||||||
|
m_phase = Phase::Moving;
|
||||||
|
const quint64 token = ++m_token;
|
||||||
|
m_timeout.start(kMoveTimeoutMs);
|
||||||
|
emit progressChanged(m_index + 1, m_steps.size(), step.label);
|
||||||
|
// A direct progress listener may cancel or change context synchronously.
|
||||||
|
if (m_phase != Phase::Moving || m_token != token) return;
|
||||||
|
QVariantMap target;
|
||||||
|
const char *keys[] = {"x", "y", "z", "rx", "ry", "rz"};
|
||||||
|
for (int i = 0; i < 6; ++i) target[keys[i]] = step.target[size_t(i)];
|
||||||
|
emit moveRequested(m_device, target, step.speed, step.acceleration, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchSequenceController::acceptPose(quint64 token, const QString &device,
|
||||||
|
const QVariantMap &pose, const QVariantMap &state,
|
||||||
|
bool success, const QString &detail)
|
||||||
|
{
|
||||||
|
if ((m_phase != Phase::InitialRead && m_phase != Phase::VerifyRead
|
||||||
|
&& m_phase != Phase::AfterDwellRead) || token != m_token || device != m_device)
|
||||||
|
return;
|
||||||
|
if (!success) {
|
||||||
|
fail(detail.isEmpty() ? QStringLiteral("触控任务读取实时位姿失败") : detail);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!stoppedHealthy(state)) {
|
||||||
|
fail(QStringLiteral("机械臂未停稳、未连接或处于故障/停止状态,已取消触控任务"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bool requestedOk = false, receivedOk = false;
|
||||||
|
const qint64 requested = state.value("requestedAtMs").toLongLong(&requestedOk);
|
||||||
|
const qint64 received = state.value("receivedAtMs").toLongLong(&receivedOk);
|
||||||
|
const qint64 now = QDateTime::currentMSecsSinceEpoch();
|
||||||
|
if (!requestedOk || !receivedOk || requested < m_captureIssuedAtMs
|
||||||
|
|| received < requested || received > now + 50 || now - received > 1500
|
||||||
|
|| state.value("source").toString() != QStringLiteral("getRobotState.actual_tcp_pose")) {
|
||||||
|
fail(QStringLiteral("触控任务收到过期或来源不明的位姿,已请求停止"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TcpCalibration::Pose actual{};
|
||||||
|
const char *keys[] = {"x", "y", "z", "rx", "ry", "rz"};
|
||||||
|
for (int i = 0; i < 6; ++i) {
|
||||||
|
bool ok = false;
|
||||||
|
actual[size_t(i)] = pose.value(keys[i]).toDouble(&ok);
|
||||||
|
if (!ok || !std::isfinite(actual[size_t(i)])) {
|
||||||
|
fail(QStringLiteral("触控任务收到无效的 TCP 位姿"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!poseMatches(actual, m_expected)) {
|
||||||
|
fail(m_phase == Phase::InitialRead
|
||||||
|
? QStringLiteral("当前位姿已偏离观察位(允许 0.5 mm / 0.2°),请重新定位并确认画面")
|
||||||
|
: QStringLiteral("实际 TCP 未到达触控路径目标(允许 0.5 mm / 0.2°),已停止且不会自动回程"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_timeout.stop();
|
||||||
|
if (m_phase == Phase::InitialRead) {
|
||||||
|
moveNext();
|
||||||
|
} else if (m_phase == Phase::VerifyRead && m_steps.at(m_index).dwellMs > 0) {
|
||||||
|
m_phase = Phase::Dwelling;
|
||||||
|
++m_token;
|
||||||
|
m_dwell.start(m_steps.at(m_index).dwellMs);
|
||||||
|
} else {
|
||||||
|
completeStep();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchSequenceController::acceptCommand(const QString &command, bool success,
|
||||||
|
const QString &detail)
|
||||||
|
{
|
||||||
|
if (m_phase != Phase::Moving || command != commandName(m_token)) return;
|
||||||
|
if (!success) {
|
||||||
|
fail(detail.isEmpty() ? QStringLiteral("触控运动命令失败") : detail);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_expected = m_steps.at(m_index).target;
|
||||||
|
readPose(Phase::VerifyRead);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchSequenceController::completeStep()
|
||||||
|
{
|
||||||
|
++m_index;
|
||||||
|
if (m_index == m_steps.size())
|
||||||
|
finish(true, QStringLiteral("触控路径已完成,实际 TCP 已到达最终目标"), false);
|
||||||
|
else
|
||||||
|
moveNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchSequenceController::finish(bool success, const QString &detail, bool requestStop)
|
||||||
|
{
|
||||||
|
if (!running()) return;
|
||||||
|
const QString device = m_device;
|
||||||
|
m_phase = Phase::Idle;
|
||||||
|
++m_token;
|
||||||
|
m_timeout.stop();
|
||||||
|
m_deadline.stop();
|
||||||
|
m_dwell.stop();
|
||||||
|
m_steps.clear();
|
||||||
|
if (requestStop) emit stopRequested(device);
|
||||||
|
emit finished(success, detail);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchSequenceController::stop()
|
||||||
|
{
|
||||||
|
finish(false, QStringLiteral("触控任务已取消并请求停止;不会自动回程"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchSequenceController::fail(const QString &message)
|
||||||
|
{
|
||||||
|
if (!running()) return;
|
||||||
|
finish(false, message, true);
|
||||||
|
emit errorOccurred(message);
|
||||||
|
}
|
||||||
65
src/touchsequencecontroller.h
Normal file
65
src/touchsequencecontroller.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "tcpcalibration.h"
|
||||||
|
#include <QObject>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QVariantMap>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
// Runs an already reviewed path of targets for the driver's ACTIVE TCP.
|
||||||
|
// Connect its requests to the existing RobotClient; it owns no transport.
|
||||||
|
class TouchSequenceController : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
struct Step {
|
||||||
|
TcpCalibration::Pose target{};
|
||||||
|
double speed = .01;
|
||||||
|
double acceleration = .1;
|
||||||
|
int dwellMs = 0;
|
||||||
|
QString label;
|
||||||
|
};
|
||||||
|
|
||||||
|
explicit TouchSequenceController(QObject *parent = nullptr);
|
||||||
|
void setContext(const QString &endpoint, const QString &device, bool ready,
|
||||||
|
const TcpCalibration::Pose &activeOffset,
|
||||||
|
const QString &contextRevision = QString());
|
||||||
|
// expectedInitialPose is the taught observation pose, or a separately
|
||||||
|
// verified current pose for an explicitly requested return movement.
|
||||||
|
bool start(const QVector<Step> &steps, const TcpCalibration::Pose &expectedInitialPose);
|
||||||
|
bool running() const { return m_phase != Phase::Idle; }
|
||||||
|
static QString commandName(quint64 token);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void stop();
|
||||||
|
void acceptPose(quint64 token, const QString &device, const QVariantMap &pose,
|
||||||
|
const QVariantMap &state, bool success, const QString &detail);
|
||||||
|
void acceptCommand(const QString &command, bool success, const QString &detail);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void captureRequested(const QString &device, quint64 token);
|
||||||
|
void moveRequested(const QString &device, const QVariantMap &target,
|
||||||
|
double speed, double acceleration, quint64 token);
|
||||||
|
void stopRequested(const QString &device);
|
||||||
|
void progressChanged(int step, int total, const QString &label);
|
||||||
|
void errorOccurred(const QString &message);
|
||||||
|
void finished(bool success, const QString &detail);
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum class Phase { Idle, InitialRead, Moving, VerifyRead, Dwelling, AfterDwellRead };
|
||||||
|
void readPose(Phase phase);
|
||||||
|
void moveNext();
|
||||||
|
void completeStep();
|
||||||
|
void fail(const QString &message);
|
||||||
|
void finish(bool success, const QString &detail, bool requestStop);
|
||||||
|
|
||||||
|
QString m_endpoint, m_device, m_contextRevision;
|
||||||
|
TcpCalibration::Pose m_activeOffset{}, m_expected{};
|
||||||
|
bool m_ready = false;
|
||||||
|
Phase m_phase = Phase::Idle;
|
||||||
|
QVector<Step> m_steps;
|
||||||
|
int m_index = 0;
|
||||||
|
quint64 m_token = quint64(1) << 59;
|
||||||
|
qint64 m_captureIssuedAtMs = 0;
|
||||||
|
QTimer m_timeout, m_deadline, m_dwell;
|
||||||
|
};
|
||||||
186
src/touchvideowidget.cpp
Normal file
186
src/touchvideowidget.cpp
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
#include "touchvideowidget.h"
|
||||||
|
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
QRect imageRectangle(const QSize &widgetSize, const QSize &imageSize)
|
||||||
|
{
|
||||||
|
if (widgetSize.isEmpty() || imageSize.isEmpty()) return {};
|
||||||
|
QSize target = imageSize;
|
||||||
|
target.scale(widgetSize, Qt::KeepAspectRatio);
|
||||||
|
return QRect((widgetSize.width() - target.width()) / 2,
|
||||||
|
(widgetSize.height() - target.height()) / 2,
|
||||||
|
target.width(), target.height());
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF frameRectangle(const QSize &widgetSize, const QSize &imageSize, VideoPixelFormat format)
|
||||||
|
{
|
||||||
|
if (format == VideoPixelFormat::RGBA) return imageRectangle(widgetSize, imageSize);
|
||||||
|
if (widgetSize.isEmpty() || imageSize.isEmpty()) return {};
|
||||||
|
// The GL video renderer preserves fractional dimensions and centres the
|
||||||
|
// quad exactly; its geometry differs from the integer RGBA image path.
|
||||||
|
const double scale = qMin(double(widgetSize.width()) / imageSize.width(),
|
||||||
|
double(widgetSize.height()) / imageSize.height());
|
||||||
|
const QSizeF target(imageSize.width() * scale, imageSize.height() * scale);
|
||||||
|
return QRectF((widgetSize.width() - target.width()) / 2,
|
||||||
|
(widgetSize.height() - target.height()) / 2,
|
||||||
|
target.width(), target.height());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool mapPoint(const QPointF &position, const QRectF &area, const QSize &imageSize, QPointF *pixel)
|
||||||
|
{
|
||||||
|
if (!pixel || !std::isfinite(position.x()) || !std::isfinite(position.y())
|
||||||
|
|| imageSize.isEmpty() || area.isEmpty()
|
||||||
|
|| position.x() < area.x() || position.y() < area.y()
|
||||||
|
|| position.x() >= area.x() + area.width()
|
||||||
|
|| position.y() >= area.y() + area.height()) return false;
|
||||||
|
const double x = (position.x() - area.x()) * imageSize.width() / area.width() - .5;
|
||||||
|
const double y = (position.y() - area.y()) * imageSize.height() / area.height() - .5;
|
||||||
|
*pixel = QPointF(qBound(0.0, x, double(imageSize.width() - 1)),
|
||||||
|
qBound(0.0, y, double(imageSize.height() - 1)));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TouchVideoWidget::TouchVideoWidget(QWidget *parent) : VideoRenderWidget(parent)
|
||||||
|
{
|
||||||
|
setMinimumSize(320, 240);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchVideoWidget::present(const VideoFrame &frame)
|
||||||
|
{
|
||||||
|
if (!frame.isValid()) return;
|
||||||
|
m_latestFrame = frame;
|
||||||
|
if (m_locked) return;
|
||||||
|
m_imageSize = QSize(frame.width, frame.height);
|
||||||
|
setFrame(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TouchVideoWidget::lockImage(const QImage &image)
|
||||||
|
{
|
||||||
|
if (image.isNull()) return false;
|
||||||
|
m_locked = true;
|
||||||
|
m_imageSize = image.size();
|
||||||
|
m_lockedFormat = VideoPixelFormat::RGBA;
|
||||||
|
setImage(image);
|
||||||
|
clearSelection();
|
||||||
|
setCursor(Qt::CrossCursor);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TouchVideoWidget::lockFrame(const VideoFrame &frame)
|
||||||
|
{
|
||||||
|
if (!frame.isValid()) return false;
|
||||||
|
m_locked = true;
|
||||||
|
m_imageSize = QSize(frame.width, frame.height);
|
||||||
|
m_lockedFormat = frame.format;
|
||||||
|
// VideoFrame keeps its backing AVFrame alive through its shared owner.
|
||||||
|
// Keep the exact frame, including timestamps and matching intrinsics.
|
||||||
|
setFrame(frame);
|
||||||
|
clearSelection();
|
||||||
|
setCursor(Qt::CrossCursor);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchVideoWidget::unlock()
|
||||||
|
{
|
||||||
|
m_locked = false;
|
||||||
|
m_lockedFormat = VideoPixelFormat::Invalid;
|
||||||
|
clearSelection();
|
||||||
|
unsetCursor();
|
||||||
|
if (m_latestFrame.isValid()) {
|
||||||
|
m_imageSize = QSize(m_latestFrame.width, m_latestFrame.height);
|
||||||
|
setFrame(m_latestFrame);
|
||||||
|
} else {
|
||||||
|
m_imageSize = {};
|
||||||
|
VideoRenderWidget::clearFrame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchVideoWidget::clearFrame(const QString &message)
|
||||||
|
{
|
||||||
|
m_latestFrame = {};
|
||||||
|
m_imageSize = {};
|
||||||
|
m_locked = false;
|
||||||
|
m_lockedFormat = VideoPixelFormat::Invalid;
|
||||||
|
clearSelection();
|
||||||
|
unsetCursor();
|
||||||
|
VideoRenderWidget::clearFrame(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchVideoWidget::clearSelection()
|
||||||
|
{
|
||||||
|
if (m_points.isEmpty()) return;
|
||||||
|
m_points.clear();
|
||||||
|
update();
|
||||||
|
emit pointsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchVideoWidget::setMaxPoints(int count)
|
||||||
|
{
|
||||||
|
count = qBound(1, count, 2);
|
||||||
|
if (count == m_maxPoints) return;
|
||||||
|
m_maxPoints = count;
|
||||||
|
clearSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TouchVideoWidget::mapToImage(const QPointF &position, const QSizeF &widgetSize,
|
||||||
|
const QSize &imageSize, QPointF *pixel)
|
||||||
|
{
|
||||||
|
if (!std::isfinite(widgetSize.width()) || !std::isfinite(widgetSize.height())
|
||||||
|
|| widgetSize.isEmpty() || imageSize.isEmpty()) return false;
|
||||||
|
return mapPoint(position, imageRectangle(widgetSize.toSize(), imageSize), imageSize, pixel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchVideoWidget::mousePressEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
QPointF pixel;
|
||||||
|
if (event->button() != Qt::LeftButton || !m_locked
|
||||||
|
|| !mapPoint(event->localPos(), frameRectangle(size(), m_imageSize, m_lockedFormat), m_imageSize, &pixel)) {
|
||||||
|
VideoRenderWidget::mousePressEvent(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (m_points.size() >= m_maxPoints) m_points.clear();
|
||||||
|
m_points.append(pixel);
|
||||||
|
update();
|
||||||
|
emit pointsChanged();
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchVideoWidget::paintGL()
|
||||||
|
{
|
||||||
|
VideoRenderWidget::paintGL();
|
||||||
|
if (!m_locked || m_points.isEmpty() || m_imageSize.isEmpty()) return;
|
||||||
|
const QRectF area = frameRectangle(size(), m_imageSize, m_lockedFormat);
|
||||||
|
if (area.isEmpty()) return;
|
||||||
|
QVector<QPointF> screenPoints;
|
||||||
|
for (const QPointF &point : m_points) {
|
||||||
|
screenPoints.append(QPointF(area.x() + (point.x() + .5) * area.width() / m_imageSize.width(),
|
||||||
|
area.y() + (point.y() + .5) * area.height() / m_imageSize.height()));
|
||||||
|
}
|
||||||
|
QPainter painter(this);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
painter.setClipRect(area);
|
||||||
|
painter.setPen(QPen(QColor(QStringLiteral("#f4d26c")), 2));
|
||||||
|
if (screenPoints.size() == 2) painter.drawLine(screenPoints[0], screenPoints[1]);
|
||||||
|
for (int i = 0; i < screenPoints.size(); ++i) {
|
||||||
|
const QPointF center = screenPoints[i];
|
||||||
|
painter.setPen(QPen(i == 0 ? QColor(QStringLiteral("#4cdd9b"))
|
||||||
|
: QColor(QStringLiteral("#ffac60")), 2));
|
||||||
|
painter.setBrush(QColor(14, 17, 21, 180));
|
||||||
|
painter.drawEllipse(center, 7, 7);
|
||||||
|
const QString label = i == 0 ? QStringLiteral("A") : QStringLiteral("B");
|
||||||
|
const qreal labelWidth = painter.fontMetrics().horizontalAdvance(label) + 8;
|
||||||
|
const qreal labelHeight = painter.fontMetrics().height() + 4;
|
||||||
|
const qreal left = qBound(qreal(area.left()), center.x() + 11,
|
||||||
|
qMax(qreal(area.left()), area.x() + area.width() - labelWidth));
|
||||||
|
const qreal top = qBound(qreal(area.top()), center.y() - labelHeight - 3,
|
||||||
|
qMax(qreal(area.top()), area.y() + area.height() - labelHeight));
|
||||||
|
const QRectF labelRect(left, top, labelWidth, labelHeight);
|
||||||
|
painter.fillRect(labelRect, QColor(14, 17, 21, 210));
|
||||||
|
painter.drawText(labelRect, Qt::AlignCenter, label);
|
||||||
|
}
|
||||||
|
}
|
||||||
49
src/touchvideowidget.h
Normal file
49
src/touchvideowidget.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "videorenderwidget.h"
|
||||||
|
|
||||||
|
#include <QPointF>
|
||||||
|
#include <QSizeF>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
class QMouseEvent;
|
||||||
|
|
||||||
|
// Presents an existing camera session. Selection belongs to a frozen native
|
||||||
|
// image, whose matching intrinsics and robot pose are owned by the caller.
|
||||||
|
class TouchVideoWidget : public VideoRenderWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit TouchVideoWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
void present(const VideoFrame &frame);
|
||||||
|
bool lockImage(const QImage &image);
|
||||||
|
bool lockFrame(const VideoFrame &frame);
|
||||||
|
void unlock();
|
||||||
|
void clearFrame(const QString &message = QStringLiteral("暂无画面"));
|
||||||
|
void clearSelection();
|
||||||
|
void setMaxPoints(int count);
|
||||||
|
QVector<QPointF> selectedPoints() const { return m_points; }
|
||||||
|
bool locked() const { return m_locked; }
|
||||||
|
QSize imageSize() const { return m_imageSize; }
|
||||||
|
|
||||||
|
// OpenCV coordinates: the centre of the first pixel is (0, 0).
|
||||||
|
// Uses the same integer letterbox rectangle as the base RGBA renderer.
|
||||||
|
static bool mapToImage(const QPointF &position, const QSizeF &widgetSize,
|
||||||
|
const QSize &imageSize, QPointF *pixel);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void pointsChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void mousePressEvent(QMouseEvent *event) override;
|
||||||
|
void paintGL() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VideoFrame m_latestFrame;
|
||||||
|
QSize m_imageSize;
|
||||||
|
VideoPixelFormat m_lockedFormat = VideoPixelFormat::Invalid;
|
||||||
|
QVector<QPointF> m_points;
|
||||||
|
int m_maxPoints = 1;
|
||||||
|
bool m_locked = false;
|
||||||
|
};
|
||||||
@ -1,267 +1,307 @@
|
|||||||
#include "videorenderwidget.h"
|
#include "videorenderwidget.h"
|
||||||
|
|
||||||
#include <QOpenGLShaderProgram>
|
#include <QOpenGLShaderProgram>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const char *vertexShaderSource = R"(
|
const char *vertexShaderSource = R"(
|
||||||
attribute vec2 position;
|
attribute vec2 position;
|
||||||
attribute vec2 texCoord;
|
attribute vec2 texCoord;
|
||||||
varying vec2 textureCoordinate;
|
varying vec2 textureCoordinate;
|
||||||
uniform vec2 contentScale;
|
uniform vec2 contentScale;
|
||||||
void main()
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = vec4(position * contentScale, 0.0, 1.0);
|
||||||
|
textureCoordinate = texCoord;
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
const char *fragmentShaderSource = R"(
|
||||||
|
#ifdef GL_ES
|
||||||
|
precision mediump float;
|
||||||
|
#endif
|
||||||
|
varying vec2 textureCoordinate;
|
||||||
|
uniform sampler2D textureY;
|
||||||
|
uniform sampler2D textureU;
|
||||||
|
uniform sampler2D textureV;
|
||||||
|
uniform float pixelFormat;
|
||||||
|
uniform float scaleY;
|
||||||
|
uniform float scaleU;
|
||||||
|
uniform float scaleV;
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
if (pixelFormat > 1.5) {
|
||||||
|
gl_FragColor = texture2D(textureY, textureCoordinate);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float y = texture2D(textureY,
|
||||||
|
vec2(textureCoordinate.x * scaleY, textureCoordinate.y)).r;
|
||||||
|
float u;
|
||||||
|
float v;
|
||||||
|
if (pixelFormat > 0.5) {
|
||||||
|
vec4 uv = texture2D(textureU,
|
||||||
|
vec2(textureCoordinate.x * scaleU, textureCoordinate.y));
|
||||||
|
u = uv.r - 0.5;
|
||||||
|
v = uv.a - 0.5;
|
||||||
|
} else {
|
||||||
|
u = texture2D(textureU,
|
||||||
|
vec2(textureCoordinate.x * scaleU, textureCoordinate.y)).r - 0.5;
|
||||||
|
v = texture2D(textureV,
|
||||||
|
vec2(textureCoordinate.x * scaleV, textureCoordinate.y)).r - 0.5;
|
||||||
|
}
|
||||||
|
y = 1.16438356 * (y - 0.0625);
|
||||||
|
gl_FragColor = vec4(y + 1.59602678 * v,
|
||||||
|
y - 0.39176229 * u - 0.81296764 * v,
|
||||||
|
y + 2.01723214 * u, 1.0);
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
}
|
||||||
|
|
||||||
|
VideoRenderWidget::VideoRenderWidget(QWidget *parent)
|
||||||
|
: QOpenGLWidget(parent)
|
||||||
|
{
|
||||||
|
setAutoFillBackground(false);
|
||||||
|
setUpdateBehavior(QOpenGLWidget::NoPartialUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
VideoRenderWidget::~VideoRenderWidget()
|
||||||
|
{
|
||||||
|
if (context()) {
|
||||||
|
makeCurrent();
|
||||||
|
releaseTextures();
|
||||||
|
doneCurrent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VideoRenderWidget::setFrameAspectLayoutEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
gl_Position = vec4(position * contentScale, 0.0, 1.0);
|
m_frameAspectLayout = enabled;
|
||||||
textureCoordinate = texCoord;
|
QSizePolicy policy(QSizePolicy::Expanding, enabled ? QSizePolicy::Fixed : QSizePolicy::Expanding);
|
||||||
}
|
policy.setHeightForWidth(enabled);
|
||||||
)";
|
setSizePolicy(policy);
|
||||||
|
if (enabled) updateAspectHeight();
|
||||||
const char *fragmentShaderSource = R"(
|
else { setMinimumHeight(0); setMaximumHeight(QWIDGETSIZE_MAX); }
|
||||||
#ifdef GL_ES
|
updateGeometry();
|
||||||
precision mediump float;
|
|
||||||
#endif
|
|
||||||
varying vec2 textureCoordinate;
|
|
||||||
uniform sampler2D textureY;
|
|
||||||
uniform sampler2D textureU;
|
|
||||||
uniform sampler2D textureV;
|
|
||||||
uniform float pixelFormat;
|
|
||||||
uniform float scaleY;
|
|
||||||
uniform float scaleU;
|
|
||||||
uniform float scaleV;
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
if (pixelFormat > 1.5) {
|
|
||||||
gl_FragColor = texture2D(textureY, textureCoordinate);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
float y = texture2D(textureY,
|
|
||||||
vec2(textureCoordinate.x * scaleY, textureCoordinate.y)).r;
|
|
||||||
float u;
|
|
||||||
float v;
|
|
||||||
if (pixelFormat > 0.5) {
|
|
||||||
vec4 uv = texture2D(textureU,
|
|
||||||
vec2(textureCoordinate.x * scaleU, textureCoordinate.y));
|
|
||||||
u = uv.r - 0.5;
|
|
||||||
v = uv.a - 0.5;
|
|
||||||
} else {
|
|
||||||
u = texture2D(textureU,
|
|
||||||
vec2(textureCoordinate.x * scaleU, textureCoordinate.y)).r - 0.5;
|
|
||||||
v = texture2D(textureV,
|
|
||||||
vec2(textureCoordinate.x * scaleV, textureCoordinate.y)).r - 0.5;
|
|
||||||
}
|
|
||||||
y = 1.16438356 * (y - 0.0625);
|
|
||||||
gl_FragColor = vec4(y + 1.59602678 * v,
|
|
||||||
y - 0.39176229 * u - 0.81296764 * v,
|
|
||||||
y + 2.01723214 * u, 1.0);
|
|
||||||
}
|
|
||||||
)";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoRenderWidget::VideoRenderWidget(QWidget *parent)
|
int VideoRenderWidget::heightForWidth(int width) const
|
||||||
: QOpenGLWidget(parent)
|
|
||||||
{
|
{
|
||||||
setAutoFillBackground(false);
|
return m_frameAspectLayout ? qMax(1, qRound(double(width) * m_layoutFrameSize.height()
|
||||||
setUpdateBehavior(QOpenGLWidget::NoPartialUpdate);
|
/ m_layoutFrameSize.width())) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoRenderWidget::~VideoRenderWidget()
|
QSize VideoRenderWidget::sizeHint() const
|
||||||
{
|
{
|
||||||
if (context()) {
|
return m_frameAspectLayout ? QSize(640,heightForWidth(640)) : QOpenGLWidget::sizeHint();
|
||||||
makeCurrent();
|
}
|
||||||
releaseTextures();
|
|
||||||
doneCurrent();
|
void VideoRenderWidget::updateAspectHeight()
|
||||||
}
|
{
|
||||||
|
if (!m_frameAspectLayout) return;
|
||||||
|
const int wanted = heightForWidth(width());
|
||||||
|
if (minimumHeight() != wanted || maximumHeight() != wanted) setFixedHeight(wanted);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VideoRenderWidget::resizeEvent(QResizeEvent *event)
|
||||||
|
{
|
||||||
|
QOpenGLWidget::resizeEvent(event);
|
||||||
|
updateAspectHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoRenderWidget::setFrame(const VideoFrame &frame)
|
void VideoRenderWidget::setFrame(const VideoFrame &frame)
|
||||||
{
|
{
|
||||||
if (!frame.isValid())
|
if (!frame.isValid())
|
||||||
return;
|
return;
|
||||||
m_frame = frame;
|
m_frame = frame;
|
||||||
m_message.clear();
|
if (m_layoutFrameSize != QSize(frame.width, frame.height)) {
|
||||||
m_frameDirty = true;
|
m_layoutFrameSize = QSize(frame.width, frame.height);
|
||||||
update();
|
updateAspectHeight();
|
||||||
}
|
if (m_frameAspectLayout) updateGeometry();
|
||||||
|
|
||||||
void VideoRenderWidget::setImage(const QImage &image)
|
|
||||||
{
|
|
||||||
if (image.isNull())
|
|
||||||
return;
|
|
||||||
const QImage converted = image.convertToFormat(QImage::Format_RGBA8888);
|
|
||||||
VideoFrame frame;
|
|
||||||
frame.width = converted.width();
|
|
||||||
frame.height = converted.height();
|
|
||||||
frame.format = VideoPixelFormat::RGBA;
|
|
||||||
frame.stride0 = frame.width * 4;
|
|
||||||
frame.plane0.resize(frame.width * frame.height * 4);
|
|
||||||
for (int row = 0; row < frame.height; ++row) {
|
|
||||||
std::memcpy(frame.plane0.data() + row * frame.width * 4,
|
|
||||||
converted.constScanLine(row), static_cast<size_t>(frame.width * 4));
|
|
||||||
}
|
}
|
||||||
setFrame(frame);
|
m_message.clear();
|
||||||
}
|
m_frameDirty = true;
|
||||||
|
update();
|
||||||
void VideoRenderWidget::clearFrame(const QString &message)
|
}
|
||||||
{
|
|
||||||
m_frame = VideoFrame();
|
void VideoRenderWidget::setImage(const QImage &image)
|
||||||
m_message = message;
|
{
|
||||||
m_frameDirty = false;
|
if (image.isNull())
|
||||||
update();
|
return;
|
||||||
}
|
const QImage converted = image.convertToFormat(QImage::Format_RGBA8888);
|
||||||
|
VideoFrame frame;
|
||||||
void VideoRenderWidget::initializeGL()
|
frame.width = converted.width();
|
||||||
{
|
frame.height = converted.height();
|
||||||
initializeOpenGLFunctions();
|
frame.format = VideoPixelFormat::RGBA;
|
||||||
glClearColor(0.055f, 0.067f, 0.078f, 1.0f);
|
frame.stride0 = frame.width * 4;
|
||||||
glGenTextures(3, m_textures);
|
frame.plane0.resize(frame.width * frame.height * 4);
|
||||||
|
for (int row = 0; row < frame.height; ++row) {
|
||||||
m_program.reset(new QOpenGLShaderProgram);
|
std::memcpy(frame.plane0.data() + row * frame.width * 4,
|
||||||
if (!m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource) ||
|
converted.constScanLine(row), static_cast<size_t>(frame.width * 4));
|
||||||
!m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource) ||
|
}
|
||||||
!m_program->link()) {
|
setFrame(frame);
|
||||||
m_message = QStringLiteral("OpenGL 视频着色器初始化失败:%1").arg(m_program->log());
|
}
|
||||||
m_program.reset();
|
|
||||||
return;
|
void VideoRenderWidget::clearFrame(const QString &message)
|
||||||
}
|
{
|
||||||
m_glReady = true;
|
m_frame = VideoFrame();
|
||||||
}
|
m_message = message;
|
||||||
|
m_frameDirty = false;
|
||||||
void VideoRenderWidget::uploadPlane(unsigned int texture, int unit, int width,
|
update();
|
||||||
int height, unsigned int format,
|
}
|
||||||
const QByteArray &data, int textureIndex)
|
|
||||||
{
|
void VideoRenderWidget::initializeGL()
|
||||||
glActiveTexture(GL_TEXTURE0 + unit);
|
{
|
||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
initializeOpenGLFunctions();
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glClearColor(0.055f, 0.067f, 0.078f, 1.0f);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glGenTextures(3, m_textures);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
m_program.reset(new QOpenGLShaderProgram);
|
||||||
if (m_textureWidths[textureIndex] != width ||
|
if (!m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource) ||
|
||||||
m_textureHeights[textureIndex] != height ||
|
!m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource) ||
|
||||||
m_textureFormats[textureIndex] != format) {
|
!m_program->link()) {
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, static_cast<int>(format), width, height, 0,
|
m_message = QStringLiteral("OpenGL 视频着色器初始化失败:%1").arg(m_program->log());
|
||||||
format, GL_UNSIGNED_BYTE, data.constData());
|
m_program.reset();
|
||||||
m_textureWidths[textureIndex] = width;
|
return;
|
||||||
m_textureHeights[textureIndex] = height;
|
}
|
||||||
m_textureFormats[textureIndex] = format;
|
m_glReady = true;
|
||||||
} else {
|
}
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, format,
|
|
||||||
GL_UNSIGNED_BYTE, data.constData());
|
void VideoRenderWidget::uploadPlane(unsigned int texture, int unit, int width,
|
||||||
}
|
int height, unsigned int format,
|
||||||
}
|
const QByteArray &data, int textureIndex)
|
||||||
|
{
|
||||||
void VideoRenderWidget::paintGL()
|
glActiveTexture(GL_TEXTURE0 + unit);
|
||||||
{
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
if (!m_glReady || !m_program || !m_frame.isValid()) {
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
drawMessage(m_message);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
return;
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
}
|
if (m_textureWidths[textureIndex] != width ||
|
||||||
|
m_textureHeights[textureIndex] != height ||
|
||||||
// Qt 5.12's ANGLE backend can upload RGBA QImage data with an incorrect
|
m_textureFormats[textureIndex] != format) {
|
||||||
// channel layout. Draw still RGBA frames with the CPU painter instead.
|
glTexImage2D(GL_TEXTURE_2D, 0, static_cast<int>(format), width, height, 0,
|
||||||
if (m_frame.format == VideoPixelFormat::RGBA) {
|
format, GL_UNSIGNED_BYTE, data.constData());
|
||||||
const QImage image(reinterpret_cast<const uchar *>(m_frame.plane0.constData()),
|
m_textureWidths[textureIndex] = width;
|
||||||
m_frame.width, m_frame.height, m_frame.stride0,
|
m_textureHeights[textureIndex] = height;
|
||||||
QImage::Format_RGBA8888);
|
m_textureFormats[textureIndex] = format;
|
||||||
QPainter painter(this);
|
} else {
|
||||||
painter.fillRect(rect(), QColor(QStringLiteral("#0e1115")));
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, format,
|
||||||
QSize target = image.size();
|
GL_UNSIGNED_BYTE, data.constData());
|
||||||
target.scale(size(), Qt::KeepAspectRatio);
|
}
|
||||||
const QRect destination((width() - target.width()) / 2,
|
}
|
||||||
(height() - target.height()) / 2,
|
|
||||||
target.width(), target.height());
|
void VideoRenderWidget::paintGL()
|
||||||
painter.drawImage(destination, image);
|
{
|
||||||
m_frameDirty = false;
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
return;
|
if (!m_glReady || !m_program || !m_frame.isValid()) {
|
||||||
}
|
drawMessage(m_message);
|
||||||
|
return;
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
}
|
||||||
if (m_frameDirty) {
|
|
||||||
if (m_frame.format == VideoPixelFormat::I420) {
|
// Qt 5.12's ANGLE backend can upload RGBA QImage data with an incorrect
|
||||||
uploadPlane(m_textures[0], 0, m_frame.stride0, m_frame.height,
|
// channel layout. Draw still RGBA frames with the CPU painter instead.
|
||||||
GL_LUMINANCE, m_frame.plane0, 0);
|
if (m_frame.format == VideoPixelFormat::RGBA) {
|
||||||
uploadPlane(m_textures[1], 1, m_frame.stride1,
|
const QImage image(reinterpret_cast<const uchar *>(m_frame.plane0.constData()),
|
||||||
(m_frame.height + 1) / 2, GL_LUMINANCE, m_frame.plane1, 1);
|
m_frame.width, m_frame.height, m_frame.stride0,
|
||||||
uploadPlane(m_textures[2], 2, m_frame.stride2,
|
QImage::Format_RGBA8888);
|
||||||
(m_frame.height + 1) / 2, GL_LUMINANCE, m_frame.plane2, 2);
|
QPainter painter(this);
|
||||||
} else if (m_frame.format == VideoPixelFormat::NV12) {
|
painter.fillRect(rect(), QColor(QStringLiteral("#0e1115")));
|
||||||
uploadPlane(m_textures[0], 0, m_frame.stride0, m_frame.height,
|
QSize target = image.size();
|
||||||
GL_LUMINANCE, m_frame.plane0, 0);
|
target.scale(size(), Qt::KeepAspectRatio);
|
||||||
uploadPlane(m_textures[1], 1, m_frame.stride1 / 2,
|
const QRect destination((width() - target.width()) / 2,
|
||||||
(m_frame.height + 1) / 2, GL_LUMINANCE_ALPHA,
|
(height() - target.height()) / 2,
|
||||||
m_frame.plane1, 1);
|
target.width(), target.height());
|
||||||
} else {
|
painter.drawImage(destination, image);
|
||||||
uploadPlane(m_textures[0], 0, m_frame.width, m_frame.height,
|
m_frameDirty = false;
|
||||||
GL_RGBA, m_frame.plane0, 0);
|
return;
|
||||||
}
|
}
|
||||||
m_frameDirty = false;
|
|
||||||
}
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
if (m_frameDirty) {
|
||||||
const GLfloat vertices[] = {
|
if (m_frame.format == VideoPixelFormat::I420) {
|
||||||
-1.0f, -1.0f, 0.0f, 1.0f,
|
uploadPlane(m_textures[0], 0, m_frame.stride0, m_frame.height,
|
||||||
1.0f, -1.0f, 1.0f, 1.0f,
|
GL_LUMINANCE, m_frame.plane0, 0);
|
||||||
-1.0f, 1.0f, 0.0f, 0.0f,
|
uploadPlane(m_textures[1], 1, m_frame.stride1,
|
||||||
1.0f, 1.0f, 1.0f, 0.0f
|
(m_frame.height + 1) / 2, GL_LUMINANCE, m_frame.plane1, 1);
|
||||||
};
|
uploadPlane(m_textures[2], 2, m_frame.stride2,
|
||||||
float scaleX = 1.0f;
|
(m_frame.height + 1) / 2, GL_LUMINANCE, m_frame.plane2, 2);
|
||||||
float scaleY = 1.0f;
|
} else if (m_frame.format == VideoPixelFormat::NV12) {
|
||||||
const float frameAspect = static_cast<float>(m_frame.width) / m_frame.height;
|
uploadPlane(m_textures[0], 0, m_frame.stride0, m_frame.height,
|
||||||
const float widgetAspect = width() > 0 && height() > 0
|
GL_LUMINANCE, m_frame.plane0, 0);
|
||||||
? static_cast<float>(width()) / height() : frameAspect;
|
uploadPlane(m_textures[1], 1, m_frame.stride1 / 2,
|
||||||
if (frameAspect > widgetAspect)
|
(m_frame.height + 1) / 2, GL_LUMINANCE_ALPHA,
|
||||||
scaleY = widgetAspect / frameAspect;
|
m_frame.plane1, 1);
|
||||||
else
|
} else {
|
||||||
scaleX = frameAspect / widgetAspect;
|
uploadPlane(m_textures[0], 0, m_frame.width, m_frame.height,
|
||||||
|
GL_RGBA, m_frame.plane0, 0);
|
||||||
m_program->bind();
|
}
|
||||||
m_program->setUniformValue("contentScale", scaleX, scaleY);
|
m_frameDirty = false;
|
||||||
m_program->setUniformValue("textureY", 0);
|
}
|
||||||
m_program->setUniformValue("textureU", 1);
|
|
||||||
m_program->setUniformValue("textureV", 2);
|
const GLfloat vertices[] = {
|
||||||
m_program->setUniformValue("pixelFormat",
|
-1.0f, -1.0f, 0.0f, 1.0f,
|
||||||
m_frame.format == VideoPixelFormat::NV12 ? 1.0f :
|
1.0f, -1.0f, 1.0f, 1.0f,
|
||||||
m_frame.format == VideoPixelFormat::RGBA ? 2.0f : 0.0f);
|
-1.0f, 1.0f, 0.0f, 0.0f,
|
||||||
m_program->setUniformValue("scaleY", m_frame.format == VideoPixelFormat::RGBA
|
1.0f, 1.0f, 1.0f, 0.0f
|
||||||
? 1.0f : static_cast<float>(m_frame.width) / m_frame.stride0);
|
};
|
||||||
m_program->setUniformValue("scaleU", m_frame.format == VideoPixelFormat::NV12
|
float scaleX = 1.0f;
|
||||||
? static_cast<float>((m_frame.width + 1) / 2) / (m_frame.stride1 / 2)
|
float scaleY = 1.0f;
|
||||||
: static_cast<float>((m_frame.width + 1) / 2) / m_frame.stride1);
|
const float frameAspect = static_cast<float>(m_frame.width) / m_frame.height;
|
||||||
m_program->setUniformValue("scaleV", m_frame.format == VideoPixelFormat::I420
|
const float widgetAspect = width() > 0 && height() > 0
|
||||||
? static_cast<float>((m_frame.width + 1) / 2) / m_frame.stride2 : 1.0f);
|
? static_cast<float>(width()) / height() : frameAspect;
|
||||||
const int position = m_program->attributeLocation("position");
|
if (frameAspect > widgetAspect)
|
||||||
const int texCoord = m_program->attributeLocation("texCoord");
|
scaleY = widgetAspect / frameAspect;
|
||||||
m_program->enableAttributeArray(position);
|
else
|
||||||
m_program->enableAttributeArray(texCoord);
|
scaleX = frameAspect / widgetAspect;
|
||||||
m_program->setAttributeArray(position, GL_FLOAT, vertices, 2, 4 * sizeof(GLfloat));
|
|
||||||
m_program->setAttributeArray(texCoord, GL_FLOAT, vertices + 2, 2,
|
m_program->bind();
|
||||||
4 * sizeof(GLfloat));
|
m_program->setUniformValue("contentScale", scaleX, scaleY);
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
m_program->setUniformValue("textureY", 0);
|
||||||
m_program->disableAttributeArray(position);
|
m_program->setUniformValue("textureU", 1);
|
||||||
m_program->disableAttributeArray(texCoord);
|
m_program->setUniformValue("textureV", 2);
|
||||||
m_program->release();
|
m_program->setUniformValue("pixelFormat",
|
||||||
}
|
m_frame.format == VideoPixelFormat::NV12 ? 1.0f :
|
||||||
|
m_frame.format == VideoPixelFormat::RGBA ? 2.0f : 0.0f);
|
||||||
void VideoRenderWidget::drawMessage(const QString &message)
|
m_program->setUniformValue("scaleY", m_frame.format == VideoPixelFormat::RGBA
|
||||||
{
|
? 1.0f : static_cast<float>(m_frame.width) / m_frame.stride0);
|
||||||
if (message.isEmpty())
|
m_program->setUniformValue("scaleU", m_frame.format == VideoPixelFormat::NV12
|
||||||
return;
|
? static_cast<float>((m_frame.width + 1) / 2) / (m_frame.stride1 / 2)
|
||||||
QPainter painter(this);
|
: static_cast<float>((m_frame.width + 1) / 2) / m_frame.stride1);
|
||||||
painter.setPen(QColor(QStringLiteral("#8d98a5")));
|
m_program->setUniformValue("scaleV", m_frame.format == VideoPixelFormat::I420
|
||||||
painter.drawText(rect(), Qt::AlignCenter | Qt::TextWordWrap, message);
|
? static_cast<float>((m_frame.width + 1) / 2) / m_frame.stride2 : 1.0f);
|
||||||
}
|
const int position = m_program->attributeLocation("position");
|
||||||
|
const int texCoord = m_program->attributeLocation("texCoord");
|
||||||
void VideoRenderWidget::releaseTextures()
|
m_program->enableAttributeArray(position);
|
||||||
{
|
m_program->enableAttributeArray(texCoord);
|
||||||
if (m_textures[0]) {
|
m_program->setAttributeArray(position, GL_FLOAT, vertices, 2, 4 * sizeof(GLfloat));
|
||||||
glDeleteTextures(3, m_textures);
|
m_program->setAttributeArray(texCoord, GL_FLOAT, vertices + 2, 2,
|
||||||
m_textures[0] = m_textures[1] = m_textures[2] = 0;
|
4 * sizeof(GLfloat));
|
||||||
std::fill(m_textureWidths, m_textureWidths + 3, 0);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
std::fill(m_textureHeights, m_textureHeights + 3, 0);
|
m_program->disableAttributeArray(position);
|
||||||
std::fill(m_textureFormats, m_textureFormats + 3, 0);
|
m_program->disableAttributeArray(texCoord);
|
||||||
}
|
m_program->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VideoRenderWidget::drawMessage(const QString &message)
|
||||||
|
{
|
||||||
|
if (message.isEmpty())
|
||||||
|
return;
|
||||||
|
QPainter painter(this);
|
||||||
|
painter.setPen(QColor(QStringLiteral("#8d98a5")));
|
||||||
|
painter.drawText(rect(), Qt::AlignCenter | Qt::TextWordWrap, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VideoRenderWidget::releaseTextures()
|
||||||
|
{
|
||||||
|
if (m_textures[0]) {
|
||||||
|
glDeleteTextures(3, m_textures);
|
||||||
|
m_textures[0] = m_textures[1] = m_textures[2] = 0;
|
||||||
|
std::fill(m_textureWidths, m_textureWidths + 3, 0);
|
||||||
|
std::fill(m_textureHeights, m_textureHeights + 3, 0);
|
||||||
|
std::fill(m_textureFormats, m_textureFormats + 3, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1,47 +1,55 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "videoframe.h"
|
#include "videoframe.h"
|
||||||
|
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QOpenGLFunctions>
|
#include <QOpenGLFunctions>
|
||||||
#include <QOpenGLWidget>
|
#include <QOpenGLWidget>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class QOpenGLShaderProgram;
|
class QOpenGLShaderProgram;
|
||||||
|
|
||||||
class VideoRenderWidget : public QOpenGLWidget, protected QOpenGLFunctions
|
class VideoRenderWidget : public QOpenGLWidget, protected QOpenGLFunctions
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit VideoRenderWidget(QWidget *parent = nullptr);
|
explicit VideoRenderWidget(QWidget *parent = nullptr);
|
||||||
~VideoRenderWidget() override;
|
~VideoRenderWidget() override;
|
||||||
|
|
||||||
void setFrame(const VideoFrame &frame);
|
void setFrame(const VideoFrame &frame);
|
||||||
void setImage(const QImage &image);
|
void setImage(const QImage &image);
|
||||||
void clearFrame(const QString &message = QStringLiteral("暂无画面"));
|
void clearFrame(const QString &message = QStringLiteral("暂无画面"));
|
||||||
bool hasFrame() const { return m_frame.isValid(); }
|
bool hasFrame() const { return m_frame.isValid(); }
|
||||||
|
// Opt-in for calibration panels; other video pages keep their layout.
|
||||||
protected:
|
void setFrameAspectLayoutEnabled(bool enabled);
|
||||||
void initializeGL() override;
|
int heightForWidth(int width) const override;
|
||||||
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void initializeGL() override;
|
||||||
void paintGL() override;
|
void paintGL() override;
|
||||||
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
private:
|
|
||||||
void releaseTextures();
|
private:
|
||||||
void uploadPlane(unsigned int texture, int unit, int width, int height,
|
void releaseTextures();
|
||||||
unsigned int format, const QByteArray &data,
|
void uploadPlane(unsigned int texture, int unit, int width, int height,
|
||||||
int textureIndex);
|
unsigned int format, const QByteArray &data,
|
||||||
|
int textureIndex);
|
||||||
void drawMessage(const QString &message);
|
void drawMessage(const QString &message);
|
||||||
|
void updateAspectHeight();
|
||||||
std::unique_ptr<QOpenGLShaderProgram> m_program;
|
bool m_frameAspectLayout = false;
|
||||||
VideoFrame m_frame;
|
QSize m_layoutFrameSize{640, 480}; // Placeholder until the first camera frame.
|
||||||
QString m_message = QStringLiteral("暂无画面");
|
|
||||||
unsigned int m_textures[3] = {0, 0, 0};
|
std::unique_ptr<QOpenGLShaderProgram> m_program;
|
||||||
int m_textureWidths[3] = {0, 0, 0};
|
VideoFrame m_frame;
|
||||||
int m_textureHeights[3] = {0, 0, 0};
|
QString m_message = QStringLiteral("暂无画面");
|
||||||
unsigned int m_textureFormats[3] = {0, 0, 0};
|
unsigned int m_textures[3] = {0, 0, 0};
|
||||||
bool m_frameDirty = false;
|
int m_textureWidths[3] = {0, 0, 0};
|
||||||
bool m_glReady = false;
|
int m_textureHeights[3] = {0, 0, 0};
|
||||||
};
|
unsigned int m_textureFormats[3] = {0, 0, 0};
|
||||||
|
bool m_frameDirty = false;
|
||||||
|
bool m_glReady = false;
|
||||||
|
};
|
||||||
|
|||||||
3185
styles.qss
3185
styles.qss
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user