mirror of
https://gitee.com/cv_team/uestc-careye.git
synced 2024-12-01 19:28:44 +08:00
Init:清理冗余的无效历史记录
This commit is contained in:
commit
dd192e6233
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
build/
|
||||
data/
|
||||
.idea/
|
||||
.vs/
|
||||
cmake-build-debug/
|
||||
|
30
.travis.yml
Normal file
30
.travis.yml
Normal file
@ -0,0 +1,30 @@
|
||||
language: cpp
|
||||
sudo: required
|
||||
dist: trusty
|
||||
compiler:
|
||||
- gcc
|
||||
- msvc
|
||||
os:
|
||||
- linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-7
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
|
||||
- windows
|
||||
branches:
|
||||
only:
|
||||
- Robot
|
||||
env:
|
||||
global:
|
||||
- LANG="en_US.UTF-8"
|
||||
before_install:
|
||||
- test -n $CC && unset CC
|
||||
- test -n $CXX && unset CXX
|
||||
- sudo apt-get install flex
|
||||
- sudo apt-get install git build-essential pkg-config libtool automake autopoint gettext
|
||||
- sudo apt-get install libgtkgl2.0-dev libgtk2.0-dev libgtkmm-2.4-dev
|
||||
- sudo apt-get install libcanberra-gtk-module
|
56
3rdparty/README.MD
vendored
Normal file
56
3rdparty/README.MD
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
# linux
|
||||
> Run script _download.sh_ to clone 3rdparty sorce code and build it.
|
||||
|
||||
## Install linux build toolchain
|
||||
```
|
||||
sudo apt-get install git build-essential pkg-config libtool automake autopoint gettext
|
||||
sudo apt-get install libgtkgl2.0-dev libgtk2.0-dev libgtkmm-2.4-dev
|
||||
sudo apt-get install libcanberra-gtk-module
|
||||
```
|
||||
## 3rdparty Dependies
|
||||
|
||||
如果您想要追求极致的性能或者您有Intel的神经网络计算棒的话,这里推荐安装OpenVino版本的OpenCV
|
||||
|
||||
* opencv 4.1.2
|
||||
```bash
|
||||
git clone -b 4.1.2 https://github.com/opencv/opencv.git
|
||||
```
|
||||
* googeltest
|
||||
```bash
|
||||
git clone https://github.com/google/googletest.git
|
||||
```
|
||||
* mavlink
|
||||
```bash
|
||||
git clone https://github.com/mavlink/mavlink.git
|
||||
```
|
||||
* openmpi
|
||||
```bash
|
||||
sudo apt install openmpi-bin openmpi-common libopenmpi-dev
|
||||
```
|
||||
* gflags
|
||||
```bash
|
||||
git clone https://github.com/gflags/gflags.git
|
||||
```
|
||||
* grpc
|
||||
```bash
|
||||
git clone https://github.com/grpc/grpc.git
|
||||
git submodule update --init
|
||||
```
|
||||
* flex
|
||||
```bash
|
||||
sudo apt-get install flex
|
||||
```
|
||||
## Download and install Qt5
|
||||
|
||||
```url
|
||||
http://download.qt.io/official_releases/qt/
|
||||
```
|
||||
|
||||
|
||||
# Windows
|
||||
Install higher version than boost 1.67.0
|
||||
|
||||
Download and install Qt5
|
||||
```url
|
||||
http://download.qt.io/official_releases/qt/
|
||||
```
|
13
3rdparty/download.sh
vendored
Normal file
13
3rdparty/download.sh
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
git clone https://github.com/BVLC/caffe.git ./caffe
|
||||
git clone -b 3.4.1 https://github.com/opencv/opencv.git ./opencv
|
||||
git clone git://git.videolan.org/vlc.git ./vlc
|
||||
mkdir opencv/opencv_build
|
||||
cd ../opencv_build
|
||||
cmake ../opencv
|
||||
make -j4
|
||||
|
||||
mkdir caffe_build
|
||||
cd caffe_build
|
||||
cmake ../caffe
|
||||
make -j4
|
1
3rdparty/gflags
vendored
Submodule
1
3rdparty/gflags
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit addd749114fab4f24b7ea1e0f2f837584389e52c
|
1
3rdparty/grpc
vendored
Submodule
1
3rdparty/grpc
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit e29f3b27b18717c7c3dba27c3bd4008200f01390
|
1
3rdparty/libserv
vendored
Submodule
1
3rdparty/libserv
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit ab3b95b9faab4b03c914924bd58132fc7fcfffc1
|
28
CMakeLists.txt
Normal file
28
CMakeLists.txt
Normal file
@ -0,0 +1,28 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
option(WITH_CONTROL_CENTER "Build Robot Control Center" ON)
|
||||
set(RC_LIB ON)
|
||||
|
||||
####################################
|
||||
## to use C++11
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
|
||||
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
|
||||
endif ()
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-fPIC -no-pie")
|
||||
|
||||
####################################
|
||||
|
||||
|
||||
add_subdirectory(3rdparty/gflags)
|
||||
#add_subdirectory(3rdparty/grpc)
|
||||
add_subdirectory(3rdparty/libserv)
|
||||
|
||||
add_definitions(-D DEBUG)
|
||||
add_subdirectory(robot_client)
|
||||
|
||||
#if (${WITH_CONTROL_CENTER} STREQUAL "ON")
|
||||
# add_subdirectory(robot_center)
|
||||
#endif ()
|
||||
|
202
LICENCE
Normal file
202
LICENCE
Normal file
@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
21
README.MD
Normal file
21
README.MD
Normal file
@ -0,0 +1,21 @@
|
||||
## SLAM自动控制系统 SLAM auto control system
|
||||
|
||||
> [编译依赖 build dependes](./3rdparty/README.MD)
|
||||
|
||||
## 项目的演示[视屏地址](https://www.bilibili.com/video/av45616046/)
|
||||
|
||||
# 关于外设 About dvice
|
||||
1. STM32/Arduino/MSP430
|
||||
2. 思岚激光雷达 Slamtec rplidar A2
|
||||
3. IMU惯性导航模块 JY901 IMU
|
||||
|
||||
[通信数据包结构](./doc/DATA_STRUCTURE.md)
|
||||
|
||||
*PS:脑电模块未开源*
|
||||
*PS:Brain wave mode is or core model and instable please wait our team dev open its code*
|
||||
# 关于我们 About US
|
||||
或许我们做的东西还不够成熟,我们的Teamate也在不断的学习新的算法和复现论文,期望在未来能够达到产品的水平
|
||||
同时也不要说我们为什么不用ROS,因为我们想要更多的从底层出发挑战自我。
|
||||
我们的团队概览在[这里](https://gitee.com/cv_team)
|
||||
我们的群号是 [极客&硬件] 616767956
|
||||
如果您有什么问题或者建议或者需要答疑,请加群联系我们
|
25
cmake/rcBoostCmake.cmake
Normal file
25
cmake/rcBoostCmake.cmake
Normal file
@ -0,0 +1,25 @@
|
||||
message(STATUS "FIND Boost")
|
||||
find_package(Boost REQUIRED COMPONENTS
|
||||
date_time filesystem iostreams python thread system)
|
||||
set(Boost_USE_STATIC_LIBS ON) # only find static libs
|
||||
set(Boost_USE_DEBUG_LIBS OFF) # ignore debug libs and
|
||||
set(Boost_USE_RELEASE_LIBS ON) # only find release libs
|
||||
message(STATUS "Boost_VERSION ${Boost_VERSION}")
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
link_directories(${Boost_LIBRARY_DIRS})
|
||||
#Boost_FOUND - True if headers and requested libraries were found
|
||||
#Boost_INCLUDE_DIRS - Boost include directories
|
||||
#Boost_LIBRARY_DIRS - Link directories for Boost libraries
|
||||
#Boost_LIBRARIES - Boost component libraries to be linked
|
||||
#Boost_<C>_FOUND - True if component <C> was found (<C> is upper-case)
|
||||
#Boost_<C>_LIBRARY - Libraries to link for component <C> (may include
|
||||
#target_link_libraries debug/optimized keywords)
|
||||
#Boost_VERSION - BOOST_VERSION value from boost/version.hpp
|
||||
#Boost_LIB_VERSION - Version string appended to library filenames
|
||||
#Boost_MAJOR_VERSION - Boost major version number (X in X.y.z)
|
||||
#Boost_MINOR_VERSION - Boost minor version number (Y in x.Y.z)
|
||||
#Boost_SUBMINOR_VERSION - Boost subminor version number (Z in x.y.Z)
|
||||
#Boost_LIB_DIAGNOSTIC_DEFINITIONS (Windows)
|
||||
#- Pass to add_definitions() to have diagnostic
|
||||
#information about Boost's automatic linking
|
||||
#displayed during compilation
|
1
cmake/rcGlobalIncludeCmake.cmake
Normal file
1
cmake/rcGlobalIncludeCmake.cmake
Normal file
@ -0,0 +1 @@
|
||||
include_directories(${PROJECT_SOURCE_DIR}/src/include)
|
16
cmake/rcMpiCmake.cmake
Normal file
16
cmake/rcMpiCmake.cmake
Normal file
@ -0,0 +1,16 @@
|
||||
message(STATUS "FIND OpenMPI")
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
set(MPI_C_LIBRARIES
|
||||
/usr/local/lib/libmpi.so
|
||||
)
|
||||
set(MPI_CXX_LIBRARIES
|
||||
/usr/local/lib/libmpi.so
|
||||
)
|
||||
set(MPI_C_INCLUDE_PATH /usr/local/include/openmpi)
|
||||
set(MPI_CXX_INCLUDE_PATH /usr/local/include/openmpi)
|
||||
find_package(MPI REQUIRED)
|
||||
if ( MPI_FOUND )
|
||||
include_directories( ${MPI_INCLUDE_PATH} )
|
||||
endif( MPI_FOUND )
|
||||
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
endif ()
|
6
cmake/rcOpenCVCmake.cmake
Normal file
6
cmake/rcOpenCVCmake.cmake
Normal file
@ -0,0 +1,6 @@
|
||||
message(STATUS "FIND OpenCV")
|
||||
set(OpenCV_DIR /opt/openvino/openvino_2020.2.120/opencv/cmake)
|
||||
# set(OpenCV_DIR ${PROJECT_SOURCE_DIR}/3rdparty/opencv/cmake)
|
||||
find_package(OpenCV REQUIRED)
|
||||
message(STATUS "opencv_dir is ${OpenCV_DIR}")
|
||||
message(STATUS "OpenCV VERSION is ${OpenCV_VERSION}")
|
22
cmake/rcOpenGLCmake.cmake
Normal file
22
cmake/rcOpenGLCmake.cmake
Normal file
@ -0,0 +1,22 @@
|
||||
#########################################################
|
||||
# FIND GLUT
|
||||
#########################################################
|
||||
message(STATUS FIND OpenGL)
|
||||
find_package(GLUT REQUIRED)
|
||||
include_directories(${GLUT_INCLUDE_DIRS})
|
||||
link_directories(${GLUT_LIBRARY_DIRS})
|
||||
add_definitions(${GLUT_DEFINITIONS})
|
||||
if(NOT GLUT_FOUND)
|
||||
message(ERROR " GLUT not found!")
|
||||
endif(NOT GLUT_FOUND)
|
||||
#########################################################
|
||||
# FIND OPENGL
|
||||
#########################################################
|
||||
set(OpenGL_GL_PREFERENCE GLVND)
|
||||
find_package(OpenGL REQUIRED)
|
||||
include_directories(${OpenGL_INCLUDE_DIRS})
|
||||
link_directories(${OpenGL_LIBRARY_DIRS})
|
||||
add_definitions(${OpenGL_DEFINITIONS})
|
||||
if(NOT OPENGL_FOUND)
|
||||
message(ERROR " OPENGL not found!")
|
||||
endif(NOT OPENGL_FOUND)
|
11
cmake/rcPlathformConfigCmake.cmake
Normal file
11
cmake/rcPlathformConfigCmake.cmake
Normal file
@ -0,0 +1,11 @@
|
||||
message(STATUS CHOOSE Plathform)
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
MESSAGE(STATUS "current platform: Linux ")
|
||||
set(SYSTEM_LIB_DIR /usr/local/libs)
|
||||
set(USER_LIB_DIR /usr/lib)
|
||||
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
|
||||
MESSAGE(STATUS "current platform: Windows")
|
||||
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
MESSAGE(STATUS "current platform: FreeBSD")
|
||||
endif ()
|
114
doc/DATA_STRUCTURE.md
Normal file
114
doc/DATA_STRUCTURE.md
Normal file
@ -0,0 +1,114 @@
|
||||
# 串口数据
|
||||
<table>
|
||||
<tr>
|
||||
<td>数据包类型</td>
|
||||
<td>十六进制值</td>
|
||||
<td>十进制</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>握手请求</td>
|
||||
<td>0x10</td>
|
||||
<td>16</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>图像</td>
|
||||
<td>0x11</td>
|
||||
<td>17</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>加速度</td>
|
||||
<td>0x12</td>
|
||||
<td>18</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>角加速度</td>
|
||||
<td>0x13</td>
|
||||
<td>19</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>磁场</td>
|
||||
<td>0x14</td>
|
||||
<td>20</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>文件</td>
|
||||
<td>0x15</td>
|
||||
<td>21</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>电量</td>
|
||||
<td>0x16</td>
|
||||
<td>22</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>结束符</td>
|
||||
<td>0x17</td>
|
||||
<td>23</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## 握手包
|
||||
|
||||
```c++
|
||||
typedef struct _touch{
|
||||
uchar head;
|
||||
uchar type_h;
|
||||
uchar type_l;
|
||||
uchar len_hh;
|
||||
uchar len_hl;
|
||||
uchar len_lh;
|
||||
uchar len_ll;
|
||||
uchar sum;
|
||||
}touch;
|
||||
```
|
||||
<table>
|
||||
<tr>
|
||||
<td>数据包头</td>
|
||||
<td>数据包类型H</td>
|
||||
<td>数据包类型L</td>
|
||||
<td>包长度</td>
|
||||
<td>包长度</td>
|
||||
<td>包长度</td>
|
||||
<td>包长度</td>
|
||||
<td>校验和</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0x10</td>
|
||||
<td>TYPE_H</td>
|
||||
<td>TYPE_L</td>
|
||||
<td>HH</td>
|
||||
<td>HL</td>
|
||||
<td>LH</td>
|
||||
<td>LL</td>
|
||||
<td>SUM</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## 数据体
|
||||
|
||||
#TCP数据
|
||||
|
||||
TCP数据分为报头和请求体
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>数据包头</td>
|
||||
<td>数据包类型H</td>
|
||||
<td>数据包类型L</td>
|
||||
<td>包长度</td>
|
||||
<td>包长度</td>
|
||||
<td>包长度</td>
|
||||
<td>包长度</td>
|
||||
<td>校验和</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0x10</td>
|
||||
<td>TYPE_H</td>
|
||||
<td>TYPE_L</td>
|
||||
<td>HH</td>
|
||||
<td>HL</td>
|
||||
<td>LH</td>
|
||||
<td>LL</td>
|
||||
<td>SUM</td>
|
||||
</tr>
|
||||
</table>
|
28
robot_center/CMakeLists.txt
Normal file
28
robot_center/CMakeLists.txt
Normal file
@ -0,0 +1,28 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
project(RobotCenter)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
message(STATUS ===================================RobotCenter============================)
|
||||
|
||||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
set(PROJECT_BINARY_DIR ${PROJECT_BINARY_DIR}/bin)
|
||||
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
|
||||
set(ENV_CMAKE_FILES_PATH ${PROJECT_SOURCE_DIR}/../cmake/)
|
||||
|
||||
include(${ENV_CMAKE_FILES_PATH}rcPlathformConfigCmake.cmake)
|
||||
include(${ENV_CMAKE_FILES_PATH}rcBoostCmake.cmake)
|
||||
include(${ENV_CMAKE_FILES_PATH}rcGlobalIncludeCmake.cmake)
|
||||
include(${ENV_CMAKE_FILES_PATH}rcOpenGLCmake.cmake)
|
||||
include(${ENV_CMAKE_FILES_PATH}rcOpenCVCmake.cmake)
|
||||
include(${ENV_CMAKE_FILES_PATH}rcMpiCmake.cmake)
|
||||
include(${PROJECT_SOURCE_DIR}/src/cmake/Qt5Import.cmake)
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/../robot_client/src/include)
|
||||
|
||||
|
||||
include(${PROJECT_SOURCE_DIR}/src/cmake/RC_ServerCenterCmake.cmake)
|
||||
include(${PROJECT_SOURCE_DIR}/src/cmake/RC_MainAPPCmake.cmake)
|
||||
|
||||
include(${PROJECT_SOURCE_DIR}/test/CMakeLists.txt)
|
||||
message(STATUS ===================================DONE============================)
|
1
robot_center/README.MD
Normal file
1
robot_center/README.MD
Normal file
@ -0,0 +1 @@
|
||||
# 机器人下位机程序
|
29
robot_center/src/cmake/Qt5Import.cmake
Normal file
29
robot_center/src/cmake/Qt5Import.cmake
Normal file
@ -0,0 +1,29 @@
|
||||
#set(QT5_DIR /home/pulsarv/Qt5.12.3/5.12.3/gcc_64/lib/cmake)
|
||||
set(QT_SELECT qt5.13)
|
||||
set(QT5_DIR /opt/Qt5.12.3/5.12.3/gcc_64/lib/cmake)
|
||||
#set(Qt5_DIR ${QT5_DIR}/Qt5)
|
||||
#find_package(Qt5)
|
||||
include_directories(${PROJECT_BINARY_DIR})
|
||||
set(Qt5Widgets_DIR ${QT5_DIR}/Qt5Widgets)
|
||||
find_package(Qt5Widgets)
|
||||
|
||||
set(Qt5Core_DIR ${QT5_DIR}/Qt5Core)
|
||||
find_package(Qt5Core)
|
||||
|
||||
set(Qt5Gui_DIR ${QT5_DIR}/Qt5Gui)
|
||||
find_package(Qt5Gui)
|
||||
|
||||
set(Qt5OpenGL_DIR ${QT5_DIR}/Qt5OpenGL)
|
||||
find_package(Qt5OpenGL)
|
||||
|
||||
set(Qt5Network_DIR ${QT5_DIR}/Qt5Network)
|
||||
find_package(Qt5Network)
|
||||
|
||||
#set(QtQml_DIR ${QT5_DIR}/QtQml)
|
||||
#find_package(QtQml)
|
||||
|
||||
#set(QPainter_DIR ${QT5_DIR}/QPainter)
|
||||
#set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
#set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
24
robot_center/src/cmake/RC_BoostCmake.cmake
Normal file
24
robot_center/src/cmake/RC_BoostCmake.cmake
Normal file
@ -0,0 +1,24 @@
|
||||
message(STATUS "RoboCenter Load Boost")
|
||||
find_package(Boost REQUIRED COMPONENTS
|
||||
date_time filesystem iostreams python thread system)
|
||||
set(Boost_USE_STATIC_LIBS ON) # only find static libs
|
||||
set(Boost_USE_DEBUG_LIBS OFF) # ignore debug libs and
|
||||
set(Boost_USE_RELEASE_LIBS ON) # only find release libs
|
||||
message(STATUS "Boost_VERSION ${Boost_VERSION}")
|
||||
|
||||
#Boost_FOUND - True if headers and requested libraries were found
|
||||
#Boost_INCLUDE_DIRS - Boost include directories
|
||||
#Boost_LIBRARY_DIRS - Link directories for Boost libraries
|
||||
#Boost_LIBRARIES - Boost component libraries to be linked
|
||||
#Boost_<C>_FOUND - True if component <C> was found (<C> is upper-case)
|
||||
#Boost_<C>_LIBRARY - Libraries to link for component <C> (may include
|
||||
#target_link_libraries debug/optimized keywords)
|
||||
#Boost_VERSION - BOOST_VERSION value from boost/version.hpp
|
||||
#Boost_LIB_VERSION - Version string appended to library filenames
|
||||
#Boost_MAJOR_VERSION - Boost major version number (X in X.y.z)
|
||||
#Boost_MINOR_VERSION - Boost minor version number (Y in x.Y.z)
|
||||
#Boost_SUBMINOR_VERSION - Boost subminor version number (Z in x.y.Z)
|
||||
#Boost_LIB_DIAGNOSTIC_DEFINITIONS (Windows)
|
||||
#- Pass to add_definitions() to have diagnostic
|
||||
#information about Boost's automatic linking
|
||||
#displayed during compilation
|
5
robot_center/src/cmake/RC_LibRCCmake.cmake
Normal file
5
robot_center/src/cmake/RC_LibRCCmake.cmake
Normal file
@ -0,0 +1,5 @@
|
||||
set(LibRcCmakePath ${PROJECT_SOURCE_DIR}/../robot_client/cmake)
|
||||
file(GLOB LIBRC_CMAKE_FILES ${LibRcCmakePath}/*.cmake)
|
||||
foreach (FILE ${LIBRC_CMAKE_FILES})
|
||||
message(STATUS ${FILE})
|
||||
endforeach ()
|
54
robot_center/src/cmake/RC_MainAPPCmake.cmake
Normal file
54
robot_center/src/cmake/RC_MainAPPCmake.cmake
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/src/include)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/../robot_client/src/include)
|
||||
message(STATUS "Load Main RobotCenter Application")
|
||||
|
||||
set(MAIN_APP_SOUECRS_DIR ${PROJECT_SOURCE_DIR}/src/sources)
|
||||
set(MAIN_APP_HEADERS_DIR ${PROJECT_SOURCE_DIR}/src/include)
|
||||
set(MAIN_APP_RESOURCES_DIR ${PROJECT_SOURCE_DIR}/src/resources)
|
||||
set(MAIN_APP_QML_DIR ${MAIN_APP_RESOURCES_DIR}/qml)
|
||||
|
||||
file(GLOB MAIN_APP_SOURCE_FILES
|
||||
${MAIN_APP_SOUECRS_DIR}/*.cpp
|
||||
${MAIN_APP_SOUECRS_DIR}/*.c
|
||||
)
|
||||
file(GLOB MAIN_APP_HEADER_FILES
|
||||
${MAIN_APP_HEADERS_DIR}/*.h
|
||||
${MAIN_APP_HEADERS_DIR}/*.hpp
|
||||
${MAIN_APP_HEADERS_DIR}/*/*.h
|
||||
${MAIN_APP_HEADERS_DIR}/*/*.hpp
|
||||
)
|
||||
qt5_wrap_cpp(MOC_MAIN_APP_HEADER_FILES ${MAIN_APP_HEADER_FILES})
|
||||
set(MAIN_APP_SOURCE
|
||||
${MAIN_APP_HEADER_FILES}
|
||||
${MAIN_APP_SOURCE_FILES}
|
||||
${MOC_MAIN_APP_HEADER_FILES}
|
||||
)
|
||||
|
||||
foreach(FILE ${MAIN_APP_SOURCE})
|
||||
message(STATUS ${FILE})
|
||||
endforeach()
|
||||
|
||||
file(GLOB MAIN_APP_QML ${MAIN_APP_QML_DIR}/*.qml)
|
||||
foreach(FILE ${MAIN_APP_QML})
|
||||
message(STATUS ${FILE})
|
||||
endforeach()
|
||||
|
||||
qt5_wrap_ui(MIAN_APP_UI_FILES ${MAIN_APP_RESOURCES_DIR}/ui/mainwindow.ui)
|
||||
qt5_add_resources(MIAN_APP_QRC_FILES ${MAIN_APP_RESOURCES_DIR}/robot_center.qrc)
|
||||
|
||||
add_executable(RobotCenter
|
||||
|
||||
${MAIN_APP_SOURCE}
|
||||
${MIAN_APP_UI_FILES}
|
||||
${MIAN_APP_QRC_FILES}
|
||||
${MAIN_APP_QML}
|
||||
)
|
||||
target_link_libraries(RobotCenter
|
||||
rc
|
||||
Qt5::Widgets
|
||||
Qt5::Core Qt5::Gui Qt5::OpenGL
|
||||
Qt5::Network ${Boost_LIBRARIES}
|
||||
center_server
|
||||
)
|
||||
qt5_use_modules(RobotCenter Core Widgets Gui OpenGL Network)
|
33
robot_center/src/cmake/RC_ServerCenterCmake.cmake
Normal file
33
robot_center/src/cmake/RC_ServerCenterCmake.cmake
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/src/include)
|
||||
message(STATUS "Load ControllCenter Lib")
|
||||
set(CONTROL_CENTER_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/src/include)
|
||||
set(CONTROL_CENTER_SOURCES_DIR ${PROJECT_SOURCE_DIR}/src/sources)
|
||||
file(GLOB CONTROL_CENTER_HEADER_FILES
|
||||
# ${CONTROL_CENTER_INCLUDE_DIR}/*.h
|
||||
# ${CONTROL_CENTER_INCLUDE_DIR}/*.hpp
|
||||
${CONTROL_CENTER_INCLUDE_DIR}/*/*.hpp
|
||||
${CONTROL_CENTER_INCLUDE_DIR}/*/*.h
|
||||
)
|
||||
file(GLOB CONTROL_CENTER_SOURCE_FILES
|
||||
# ${CONTROL_CENTER_SOURCES_DIR}/*.c
|
||||
# ${CONTROL_CENTER_SOURCES_DIR}/*.cpp
|
||||
# ${CONTROL_CENTER_SOURCES_DIR}/*.cxx
|
||||
${CONTROL_CENTER_SOURCES_DIR}/*/*.c
|
||||
${CONTROL_CENTER_SOURCES_DIR}/*/*.cpp
|
||||
${CONTROL_CENTER_SOURCES_DIR}/*/*.cxx
|
||||
)
|
||||
qt5_wrap_cpp(MOC_CONTROL_CENTER_HEADER_FILES ${CONTROL_CENTER_HEADERS_FILES})
|
||||
set(CONTROL_CENTER_SOURCE
|
||||
${CONTROL_CENTER_HEADER_FILES}
|
||||
${CONTROL_CENTER_SOURCE_FILES}
|
||||
${MOC_CONTROL_CENTER_HEADER_FILES}
|
||||
)
|
||||
foreach(FILE ${CONTROL_CENTER_SOURCE})
|
||||
message(STATUS FIND:${FILE})
|
||||
endforeach()
|
||||
|
||||
add_library(center_server SHARED ${CONTROL_CENTER_SOURCE})
|
||||
target_link_libraries(center_server Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Quick ${Boost_LIBRARIES})
|
||||
qt5_use_modules(center_server Core Widgets Gui Network Xml Quick)
|
14
robot_center/src/include/asio/rc_serial_server.h
Normal file
14
robot_center/src/include/asio/rc_serial_server.h
Normal file
@ -0,0 +1,14 @@
|
||||
//
|
||||
// Created by pulsarv on 19-5-2.
|
||||
//
|
||||
|
||||
#ifndef UESTC_CAREYE_RC_SERIAL_SERVER_H
|
||||
#define UESTC_CAREYE_RC_SERIAL_SERVER_H
|
||||
|
||||
|
||||
class rc_serial_server {
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //UESTC_CAREYE_RC_SERIAL_SERVER_H
|
46
robot_center/src/include/asio/rc_socket_server.h
Normal file
46
robot_center/src/include/asio/rc_socket_server.h
Normal file
@ -0,0 +1,46 @@
|
||||
//
|
||||
// Created by pulsarv on 19-5-2.
|
||||
//
|
||||
#ifndef UESTC_CAREYE_RC_SOCKET_SERVER_H
|
||||
#define UESTC_CAREYE_RC_SOCKET_SERVER_H
|
||||
|
||||
#include <QTcpServer>
|
||||
#include <QTcpSocket>
|
||||
|
||||
class rc_socket_server : public QTcpServer {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit rc_socket_server(QObject *parent = 0);
|
||||
|
||||
explicit rc_socket_server(int port, int max_buffer_size,QObject *parent = 0);
|
||||
|
||||
void set_server_properties(int port, int max_buffer_size);
|
||||
|
||||
void bind_call(void(*bind_function)(void *));
|
||||
|
||||
void start_listen();
|
||||
|
||||
~rc_socket_server();
|
||||
|
||||
public:
|
||||
int port;
|
||||
int max_buffer_size;
|
||||
QTcpServer *tcp_server;
|
||||
QTcpSocket *tcp_socket;
|
||||
|
||||
void (*bind_function)(void *);
|
||||
|
||||
private slots:
|
||||
|
||||
void server_new_connection();
|
||||
|
||||
void server_read_data();
|
||||
|
||||
void server_disconnect();
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //UESTC_CAREYE_RC_SOCKET_SERVER_H
|
29
robot_center/src/include/asio/rc_tcp_server_boost.h
Normal file
29
robot_center/src/include/asio/rc_tcp_server_boost.h
Normal file
@ -0,0 +1,29 @@
|
||||
//
|
||||
// Created by pulsarv on 19-5-2.
|
||||
//
|
||||
|
||||
#ifndef UESTC_CAREYE_RC_TCP_SERVER_BOOST_H
|
||||
#define UESTC_CAREYE_RC_TCP_SERVER_BOOST_H
|
||||
#include <boost/asio.hpp>
|
||||
#include <string>
|
||||
class rc_tcp_server_boost {
|
||||
public:
|
||||
rc_tcp_server_boost(int port,boost::asio::io_service &ios);
|
||||
void start_listen();
|
||||
|
||||
~rc_tcp_server_boost();
|
||||
|
||||
private:
|
||||
int port;
|
||||
std::string address;
|
||||
boost::asio::io_service& ios_;
|
||||
|
||||
typedef boost::shared_ptr<boost::asio::ip::tcp::socket> socket_ptr;
|
||||
|
||||
void accept_handler(const boost::system::error_code& _ec, socket_ptr _socket);
|
||||
|
||||
void write_handler(const boost::system::error_code& _ec);
|
||||
};
|
||||
|
||||
|
||||
#endif //UESTC_CAREYE_RC_TCP_SERVER_BOOST_H
|
38
robot_center/src/include/mainwindow.h
Normal file
38
robot_center/src/include/mainwindow.h
Normal file
@ -0,0 +1,38 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QKeyEvent>
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
|
||||
~MainWindow();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_start_server_clicked();
|
||||
void on_pushButton_Q_clicked();
|
||||
void on_pushButton_W_clicked();
|
||||
void on_pushButton_A_clicked();
|
||||
void on_pushButton_S_clicked();
|
||||
void on_pushButton_D_clicked();
|
||||
void on_pushButton_R_clicked();
|
||||
void on_pushButton_E_clicked();
|
||||
void on_clicked();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void keyReleaseEvent(QKeyEvent *event);
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
73
robot_center/src/include/origin/tcpserver.h
Normal file
73
robot_center/src/include/origin/tcpserver.h
Normal file
@ -0,0 +1,73 @@
|
||||
//
|
||||
// Created by pulsarv on 19-5-2.
|
||||
//
|
||||
|
||||
#ifndef TCPSERVER_H
|
||||
#define TCPSERVER_H
|
||||
|
||||
#include <QTcpSocket>
|
||||
#include <QTcpServer>
|
||||
#include <QStringList>
|
||||
|
||||
class TcpClient : public QTcpSocket
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TcpClient(int clientID, QObject *parent = 0);
|
||||
|
||||
private:
|
||||
int clientID;
|
||||
|
||||
signals:
|
||||
void clientReadData(int clientID, QString ip, int port, QByteArray data);
|
||||
void clientDisConnect(int clientID, QString ip, int port);
|
||||
|
||||
private slots:
|
||||
void readData();
|
||||
void disConnect();
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
class TcpServer : public QTcpServer
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TcpServer(QObject *parent = 0);
|
||||
|
||||
int getClientCount()const
|
||||
{
|
||||
return clientCount;
|
||||
}
|
||||
|
||||
QStringList getClientInfo()const
|
||||
{
|
||||
return clientInfo;
|
||||
}
|
||||
|
||||
private:
|
||||
QList<TcpClient *> clientLists;
|
||||
QList<int> clientIDs;
|
||||
|
||||
int clientCount;
|
||||
QStringList clientInfo;
|
||||
|
||||
protected:
|
||||
void incomingConnection(int handle);
|
||||
|
||||
signals:
|
||||
void clientReadData(int clientID, QString ip, int port, QByteArray data);
|
||||
void clientConnect(int clientID, QString ip, int port);
|
||||
void clientDisConnect(int clientID, QString ip, int port);
|
||||
|
||||
private slots:
|
||||
void disConnect(int clientID, QString ip, int port);
|
||||
|
||||
public slots:
|
||||
void sendData(QString ip, int port, QByteArray data);
|
||||
void sendData(QByteArray data);
|
||||
void closeAll();
|
||||
};
|
||||
|
||||
#endif // TCPSERVER_H
|
20
robot_center/src/include/radarviewer.h
Normal file
20
robot_center/src/include/radarviewer.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef RADARVIEWER_H
|
||||
#define RADARVIEWER_H
|
||||
|
||||
#include<QOpenGLWidget>
|
||||
|
||||
|
||||
class RadarViewer : public QOpenGLWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
RadarViewer(QWidget *parent);
|
||||
|
||||
~RadarViewer();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
||||
void paintGL();
|
||||
};
|
||||
|
||||
#endif // RADARVIEWER_H
|
BIN
robot_center/src/resources/fonts/DejaVuSans.ttf
Normal file
BIN
robot_center/src/resources/fonts/DejaVuSans.ttf
Normal file
Binary file not shown.
BIN
robot_center/src/resources/images/defualt_background.jpg
Normal file
BIN
robot_center/src/resources/images/defualt_background.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 267 KiB |
BIN
robot_center/src/resources/images/fuel-icon.png
Normal file
BIN
robot_center/src/resources/images/fuel-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 409 B |
BIN
robot_center/src/resources/images/temperature-icon.png
Normal file
BIN
robot_center/src/resources/images/temperature-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
174
robot_center/src/resources/qml/DashboardGaugeStyle.qml
Normal file
174
robot_center/src/resources/qml/DashboardGaugeStyle.qml
Normal file
@ -0,0 +1,174 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** BSD License Usage
|
||||
** Alternatively, you may use this file under the terms of the BSD license
|
||||
** as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of The Qt Company Ltd nor the names of its
|
||||
** contributors may be used to endorse or promote products derived
|
||||
** from this software without specific prior written permission.
|
||||
**
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
|
||||
CircularGaugeStyle {
|
||||
tickmarkInset: toPixels(0.04)
|
||||
minorTickmarkInset: tickmarkInset
|
||||
labelStepSize: 20
|
||||
labelInset: toPixels(0.23)
|
||||
|
||||
property real xCenter: outerRadius
|
||||
property real yCenter: outerRadius
|
||||
property real needleLength: outerRadius - tickmarkInset * 1.25
|
||||
property real needleTipWidth: toPixels(0.02)
|
||||
property real needleBaseWidth: toPixels(0.06)
|
||||
property bool halfGauge: false
|
||||
|
||||
function toPixels(percentage) {
|
||||
return percentage * outerRadius;
|
||||
}
|
||||
|
||||
function degToRad(degrees) {
|
||||
return degrees * (Math.PI / 180);
|
||||
}
|
||||
|
||||
function radToDeg(radians) {
|
||||
return radians * (180 / Math.PI);
|
||||
}
|
||||
|
||||
function paintBackground(ctx) {
|
||||
if (halfGauge) {
|
||||
ctx.beginPath();
|
||||
ctx.rect(0, 0, ctx.canvas.width, ctx.canvas.height / 2);
|
||||
ctx.clip();
|
||||
}
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.fillStyle = "black";
|
||||
ctx.ellipse(0, 0, ctx.canvas.width, ctx.canvas.height);
|
||||
ctx.fill();
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.lineWidth = tickmarkInset;
|
||||
ctx.strokeStyle = "black";
|
||||
ctx.arc(xCenter, yCenter, outerRadius - ctx.lineWidth / 2, outerRadius - ctx.lineWidth / 2, 0, Math.PI * 2);
|
||||
ctx.stroke();
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.lineWidth = tickmarkInset / 2;
|
||||
ctx.strokeStyle = "#222";
|
||||
ctx.arc(xCenter, yCenter, outerRadius - ctx.lineWidth / 2, outerRadius - ctx.lineWidth / 2, 0, Math.PI * 2);
|
||||
ctx.stroke();
|
||||
|
||||
ctx.beginPath();
|
||||
var gradient = ctx.createRadialGradient(xCenter, yCenter, 0, xCenter, yCenter, outerRadius * 1.5);
|
||||
gradient.addColorStop(0, Qt.rgba(1, 1, 1, 0));
|
||||
gradient.addColorStop(0.7, Qt.rgba(1, 1, 1, 0.13));
|
||||
gradient.addColorStop(1, Qt.rgba(1, 1, 1, 1));
|
||||
ctx.fillStyle = gradient;
|
||||
ctx.arc(xCenter, yCenter, outerRadius - tickmarkInset, outerRadius - tickmarkInset, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
}
|
||||
|
||||
background: Canvas {
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
ctx.reset();
|
||||
paintBackground(ctx);
|
||||
}
|
||||
|
||||
Text {
|
||||
id: speedText
|
||||
font.pixelSize: toPixels(0.3)
|
||||
text: kphInt
|
||||
color: "white"
|
||||
horizontalAlignment: Text.AlignRight
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: parent.verticalCenter
|
||||
anchors.topMargin: toPixels(0.1)
|
||||
|
||||
readonly property int kphInt: control.value
|
||||
}
|
||||
Text {
|
||||
text: "km/h"
|
||||
color: "white"
|
||||
font.pixelSize: toPixels(0.09)
|
||||
anchors.top: speedText.bottom
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
}
|
||||
|
||||
needle: Canvas {
|
||||
implicitWidth: needleBaseWidth
|
||||
implicitHeight: needleLength
|
||||
|
||||
property real xCenter: width / 2
|
||||
property real yCenter: height / 2
|
||||
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
ctx.reset();
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(xCenter, height);
|
||||
ctx.lineTo(xCenter - needleBaseWidth / 2, height - needleBaseWidth / 2);
|
||||
ctx.lineTo(xCenter - needleTipWidth / 2, 0);
|
||||
ctx.lineTo(xCenter, yCenter - needleLength);
|
||||
ctx.lineTo(xCenter, 0);
|
||||
ctx.closePath();
|
||||
ctx.fillStyle = Qt.rgba(0.66, 0, 0, 0.66);
|
||||
ctx.fill();
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(xCenter, height)
|
||||
ctx.lineTo(width, height - needleBaseWidth / 2);
|
||||
ctx.lineTo(xCenter + needleTipWidth / 2, 0);
|
||||
ctx.lineTo(xCenter, 0);
|
||||
ctx.closePath();
|
||||
ctx.fillStyle = Qt.lighter(Qt.rgba(0.66, 0, 0, 0.66));
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
|
||||
foreground: null
|
||||
}
|
134
robot_center/src/resources/qml/IconGaugeStyle.qml
Normal file
134
robot_center/src/resources/qml/IconGaugeStyle.qml
Normal file
@ -0,0 +1,134 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** BSD License Usage
|
||||
** Alternatively, you may use this file under the terms of the BSD license
|
||||
** as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of The Qt Company Ltd nor the names of its
|
||||
** contributors may be used to endorse or promote products derived
|
||||
** from this software without specific prior written permission.
|
||||
**
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import QtQuick.Extras 1.4
|
||||
|
||||
DashboardGaugeStyle {
|
||||
id: fuelGaugeStyle
|
||||
minimumValueAngle: -60
|
||||
maximumValueAngle: 60
|
||||
tickmarkStepSize: 1
|
||||
labelStepSize: 1
|
||||
labelInset: toPixels(-0.25)
|
||||
minorTickmarkCount: 3
|
||||
|
||||
needleLength: toPixels(0.85)
|
||||
needleBaseWidth: toPixels(0.08)
|
||||
needleTipWidth: toPixels(0.03)
|
||||
|
||||
halfGauge: true
|
||||
|
||||
property string icon: ""
|
||||
property color minWarningColor: "transparent"
|
||||
property color maxWarningColor: "transparent"
|
||||
readonly property real minWarningStartAngle: minimumValueAngle - 90
|
||||
readonly property real maxWarningStartAngle: maximumValueAngle - 90
|
||||
|
||||
tickmark: Rectangle {
|
||||
implicitWidth: toPixels(0.06)
|
||||
antialiasing: true
|
||||
implicitHeight: toPixels(0.2)
|
||||
color: "#c8c8c8"
|
||||
}
|
||||
|
||||
minorTickmark: Rectangle {
|
||||
implicitWidth: toPixels(0.03)
|
||||
antialiasing: true
|
||||
implicitHeight: toPixels(0.15)
|
||||
color: "#c8c8c8"
|
||||
}
|
||||
|
||||
background: Item {
|
||||
Canvas {
|
||||
anchors.fill: parent
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
ctx.reset();
|
||||
|
||||
paintBackground(ctx);
|
||||
|
||||
if (minWarningColor != "transparent") {
|
||||
ctx.beginPath();
|
||||
ctx.lineWidth = fuelGaugeStyle.toPixels(0.08);
|
||||
ctx.strokeStyle = minWarningColor;
|
||||
ctx.arc(outerRadius, outerRadius,
|
||||
// Start the line in from the decorations, and account for the width of the line itself.
|
||||
outerRadius - tickmarkInset - ctx.lineWidth / 2,
|
||||
degToRad(minWarningStartAngle),
|
||||
degToRad(minWarningStartAngle + angleRange / (minorTickmarkCount + 1)), false);
|
||||
ctx.stroke();
|
||||
}
|
||||
if (maxWarningColor != "transparent") {
|
||||
ctx.beginPath();
|
||||
ctx.lineWidth = fuelGaugeStyle.toPixels(0.08);
|
||||
ctx.strokeStyle = maxWarningColor;
|
||||
ctx.arc(outerRadius, outerRadius,
|
||||
// Start the line in from the decorations, and account for the width of the line itself.
|
||||
outerRadius - tickmarkInset - ctx.lineWidth / 2,
|
||||
degToRad(maxWarningStartAngle - angleRange / (minorTickmarkCount + 1)),
|
||||
degToRad(maxWarningStartAngle), false);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
source: icon
|
||||
anchors.bottom: parent.verticalCenter
|
||||
anchors.bottomMargin: toPixels(0.3)
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: toPixels(0.3)
|
||||
height: width
|
||||
fillMode: Image.PreserveAspectFit
|
||||
}
|
||||
}
|
||||
}
|
126
robot_center/src/resources/qml/TachometerStyle.qml
Normal file
126
robot_center/src/resources/qml/TachometerStyle.qml
Normal file
@ -0,0 +1,126 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** BSD License Usage
|
||||
** Alternatively, you may use this file under the terms of the BSD license
|
||||
** as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of The Qt Company Ltd nor the names of its
|
||||
** contributors may be used to endorse or promote products derived
|
||||
** from this software without specific prior written permission.
|
||||
**
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import QtQuick.Extras 1.4
|
||||
|
||||
DashboardGaugeStyle {
|
||||
id: tachometerStyle
|
||||
tickmarkStepSize: 1
|
||||
labelStepSize: 1
|
||||
needleLength: toPixels(0.85)
|
||||
needleBaseWidth: toPixels(0.08)
|
||||
needleTipWidth: toPixels(0.03)
|
||||
|
||||
tickmark: Rectangle {
|
||||
implicitWidth: toPixels(0.03)
|
||||
antialiasing: true
|
||||
implicitHeight: toPixels(0.08)
|
||||
color: styleData.index === 7 || styleData.index === 8 ? Qt.rgba(0.5, 0, 0, 1) : "#c8c8c8"
|
||||
}
|
||||
|
||||
minorTickmark: null
|
||||
|
||||
tickmarkLabel: Text {
|
||||
font.pixelSize: Math.max(6, toPixels(0.12))
|
||||
text: styleData.value
|
||||
color: styleData.index === 7 || styleData.index === 8 ? Qt.rgba(0.5, 0, 0, 1) : "#c8c8c8"
|
||||
antialiasing: true
|
||||
}
|
||||
|
||||
background: Canvas {
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
ctx.reset();
|
||||
paintBackground(ctx);
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.lineWidth = tachometerStyle.toPixels(0.08);
|
||||
ctx.strokeStyle = Qt.rgba(0.5, 0, 0, 1);
|
||||
var warningCircumference = maximumValueAngle - minimumValueAngle * 0.1;
|
||||
var startAngle = maximumValueAngle - 90;
|
||||
ctx.arc(outerRadius, outerRadius,
|
||||
// Start the line in from the decorations, and account for the width of the line itself.
|
||||
outerRadius - tickmarkInset - ctx.lineWidth / 2,
|
||||
degToRad(startAngle - angleRange / 8 + angleRange * 0.015),
|
||||
degToRad(startAngle - angleRange * 0.015), false);
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
Text {
|
||||
id: rpmText
|
||||
font.pixelSize: tachometerStyle.toPixels(0.3)
|
||||
text: rpmInt
|
||||
color: "white"
|
||||
horizontalAlignment: Text.AlignRight
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: parent.verticalCenter
|
||||
anchors.topMargin: 20
|
||||
|
||||
readonly property int rpmInt: valueSource.rpm
|
||||
}
|
||||
Text {
|
||||
text: "x1000"
|
||||
color: "white"
|
||||
font.pixelSize: tachometerStyle.toPixels(0.1)
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: parent.height / 4
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
Text {
|
||||
text: "RPM"
|
||||
color: "white"
|
||||
font.pixelSize: tachometerStyle.toPixels(0.1)
|
||||
anchors.top: rpmText.bottom
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
}
|
||||
}
|
116
robot_center/src/resources/qml/TurnIndicator.qml
Normal file
116
robot_center/src/resources/qml/TurnIndicator.qml
Normal file
@ -0,0 +1,116 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** BSD License Usage
|
||||
** Alternatively, you may use this file under the terms of the BSD license
|
||||
** as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of The Qt Company Ltd nor the names of its
|
||||
** contributors may be used to endorse or promote products derived
|
||||
** from this software without specific prior written permission.
|
||||
**
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
|
||||
Item {
|
||||
// This enum is actually keyboard-related, but it serves its purpose
|
||||
// as an indication of direction for us.
|
||||
property int direction: Qt.LeftArrow
|
||||
property bool on: false
|
||||
|
||||
property bool flashing: false
|
||||
|
||||
scale: direction === Qt.LeftArrow ? 1 : -1
|
||||
//! [1]
|
||||
Timer {
|
||||
id: flashTimer
|
||||
interval: 500
|
||||
running: on
|
||||
repeat: true
|
||||
onTriggered: flashing = !flashing
|
||||
}
|
||||
//! [1]
|
||||
//! [2]
|
||||
function paintOutlinePath(ctx) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(0, height * 0.5);
|
||||
ctx.lineTo(0.6 * width, 0);
|
||||
ctx.lineTo(0.6 * width, height * 0.28);
|
||||
ctx.lineTo(width, height * 0.28);
|
||||
ctx.lineTo(width, height * 0.72);
|
||||
ctx.lineTo(0.6 * width, height * 0.72);
|
||||
ctx.lineTo(0.6 * width, height);
|
||||
ctx.lineTo(0, height * 0.5);
|
||||
}
|
||||
//! [2]
|
||||
Canvas {
|
||||
id: backgroundCanvas
|
||||
anchors.fill: parent
|
||||
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
ctx.reset();
|
||||
|
||||
paintOutlinePath(ctx);
|
||||
|
||||
ctx.lineWidth = 1;
|
||||
ctx.strokeStyle = "black";
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
//! [3]
|
||||
Canvas {
|
||||
id: foregroundCanvas
|
||||
anchors.fill: parent
|
||||
visible: on && flashing
|
||||
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
ctx.reset();
|
||||
|
||||
paintOutlinePath(ctx);
|
||||
|
||||
ctx.fillStyle = "green";
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
//! [3]
|
||||
}
|
332
robot_center/src/resources/qml/ValueSource.qml
Normal file
332
robot_center/src/resources/qml/ValueSource.qml
Normal file
@ -0,0 +1,332 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** BSD License Usage
|
||||
** Alternatively, you may use this file under the terms of the BSD license
|
||||
** as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of The Qt Company Ltd nor the names of its
|
||||
** contributors may be used to endorse or promote products derived
|
||||
** from this software without specific prior written permission.
|
||||
**
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
//! [0]
|
||||
Item {
|
||||
id: valueSource
|
||||
property real kph: 0
|
||||
property real rpm: 1
|
||||
property real fuel: 0.85
|
||||
property string gear: {
|
||||
var g;
|
||||
if (kph == 0) {
|
||||
return "P";
|
||||
}
|
||||
if (kph < 30) {
|
||||
return "1";
|
||||
}
|
||||
if (kph < 50) {
|
||||
return "2";
|
||||
}
|
||||
if (kph < 80) {
|
||||
return "3";
|
||||
}
|
||||
if (kph < 120) {
|
||||
return "4";
|
||||
}
|
||||
if (kph < 160) {
|
||||
return "5";
|
||||
}
|
||||
}
|
||||
property int turnSignal: gear == "P" && !start ? randomDirection() : -1
|
||||
property real temperature: 0.6
|
||||
property bool start: true
|
||||
//! [0]
|
||||
|
||||
function randomDirection() {
|
||||
return Math.random() > 0.5 ? Qt.LeftArrow : Qt.RightArrow;
|
||||
}
|
||||
|
||||
SequentialAnimation {
|
||||
running: true
|
||||
loops: 1
|
||||
|
||||
// We want a small pause at the beginning, but we only want it to happen once.
|
||||
PauseAnimation {
|
||||
duration: 1000
|
||||
}
|
||||
|
||||
PropertyAction {
|
||||
target: valueSource
|
||||
property: "start"
|
||||
value: false
|
||||
}
|
||||
|
||||
SequentialAnimation {
|
||||
loops: Animation.Infinite
|
||||
//! [1]
|
||||
ParallelAnimation {
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "kph"
|
||||
easing.type: Easing.InOutSine
|
||||
from: 0
|
||||
to: 30
|
||||
duration: 3000
|
||||
}
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "rpm"
|
||||
easing.type: Easing.InOutSine
|
||||
from: 1
|
||||
to: 6.1
|
||||
duration: 3000
|
||||
}
|
||||
}
|
||||
//! [1]
|
||||
ParallelAnimation {
|
||||
// We changed gears so we lost a bit of speed.
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "kph"
|
||||
easing.type: Easing.InOutSine
|
||||
from: 30
|
||||
to: 26
|
||||
duration: 600
|
||||
}
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "rpm"
|
||||
easing.type: Easing.InOutSine
|
||||
from: 6
|
||||
to: 2.4
|
||||
duration: 600
|
||||
}
|
||||
}
|
||||
ParallelAnimation {
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "kph"
|
||||
easing.type: Easing.InOutSine
|
||||
to: 60
|
||||
duration: 3000
|
||||
}
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "rpm"
|
||||
easing.type: Easing.InOutSine
|
||||
to: 5.6
|
||||
duration: 3000
|
||||
}
|
||||
}
|
||||
ParallelAnimation {
|
||||
// We changed gears so we lost a bit of speed.
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "kph"
|
||||
easing.type: Easing.InOutSine
|
||||
to: 56
|
||||
duration: 600
|
||||
}
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "rpm"
|
||||
easing.type: Easing.InOutSine
|
||||
to: 2.3
|
||||
duration: 600
|
||||
}
|
||||
}
|
||||
ParallelAnimation {
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "kph"
|
||||
easing.type: Easing.InOutSine
|
||||
to: 100
|
||||
duration: 3000
|
||||
}
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "rpm"
|
||||
easing.type: Easing.InOutSine
|
||||
to: 5.1
|
||||
duration: 3000
|
||||
}
|
||||
}
|
||||
ParallelAnimation {
|
||||
// We changed gears so we lost a bit of speed.
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "kph"
|
||||
easing.type: Easing.InOutSine
|
||||
to: 96
|
||||
duration: 600
|
||||
}
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "rpm"
|
||||
easing.type: Easing.InOutSine
|
||||
to: 2.2
|
||||
duration: 600
|
||||
}
|
||||
}
|
||||
|
||||
ParallelAnimation {
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "kph"
|
||||
easing.type: Easing.InOutSine
|
||||
to: 140
|
||||
duration: 3000
|
||||
}
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "rpm"
|
||||
easing.type: Easing.InOutSine
|
||||
to: 6.2
|
||||
duration: 3000
|
||||
}
|
||||
}
|
||||
|
||||
// Start downshifting.
|
||||
|
||||
// Fifth to fourth gear.
|
||||
ParallelAnimation {
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "kph"
|
||||
easing.type: Easing.Linear
|
||||
to: 100
|
||||
duration: 5000
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "rpm"
|
||||
easing.type: Easing.InOutSine
|
||||
to: 3.1
|
||||
duration: 5000
|
||||
}
|
||||
}
|
||||
|
||||
// Fourth to third gear.
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "rpm"
|
||||
easing.type: Easing.InOutSine
|
||||
to: 5.5
|
||||
duration: 600
|
||||
}
|
||||
|
||||
ParallelAnimation {
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "kph"
|
||||
easing.type: Easing.InOutSine
|
||||
to: 60
|
||||
duration: 5000
|
||||
}
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "rpm"
|
||||
easing.type: Easing.InOutSine
|
||||
to: 2.6
|
||||
duration: 5000
|
||||
}
|
||||
}
|
||||
|
||||
// Third to second gear.
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "rpm"
|
||||
easing.type: Easing.InOutSine
|
||||
to: 6.3
|
||||
duration: 600
|
||||
}
|
||||
|
||||
ParallelAnimation {
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "kph"
|
||||
easing.type: Easing.InOutSine
|
||||
to: 30
|
||||
duration: 5000
|
||||
}
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "rpm"
|
||||
easing.type: Easing.InOutSine
|
||||
to: 2.6
|
||||
duration: 5000
|
||||
}
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "rpm"
|
||||
easing.type: Easing.InOutSine
|
||||
to: 6.5
|
||||
duration: 600
|
||||
}
|
||||
|
||||
// Second to first gear.
|
||||
ParallelAnimation {
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "kph"
|
||||
easing.type: Easing.InOutSine
|
||||
to: 0
|
||||
duration: 5000
|
||||
}
|
||||
NumberAnimation {
|
||||
target: valueSource
|
||||
property: "rpm"
|
||||
easing.type: Easing.InOutSine
|
||||
to: 1
|
||||
duration: 4500
|
||||
}
|
||||
}
|
||||
|
||||
PauseAnimation {
|
||||
duration: 5000
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
184
robot_center/src/resources/qml/dashboard.qml
Normal file
184
robot_center/src/resources/qml/dashboard.qml
Normal file
@ -0,0 +1,184 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** BSD License Usage
|
||||
** Alternatively, you may use this file under the terms of the BSD license
|
||||
** as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of The Qt Company Ltd nor the names of its
|
||||
** contributors may be used to endorse or promote products derived
|
||||
** from this software without specific prior written permission.
|
||||
**
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Window 2.1
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import QtQuick.Extras 1.4
|
||||
|
||||
Window {
|
||||
id: root
|
||||
visible: true
|
||||
width: 1024
|
||||
height: 600
|
||||
|
||||
color: "#161616"
|
||||
title: "Qt Quick Extras Demo"
|
||||
|
||||
ValueSource {
|
||||
id: valueSource
|
||||
}
|
||||
|
||||
// Dashboards are typically in a landscape orientation, so we need to ensure
|
||||
// our height is never greater than our width.
|
||||
Item {
|
||||
id: container
|
||||
width: root.width
|
||||
height: Math.min(root.width, root.height)
|
||||
anchors.centerIn: parent
|
||||
|
||||
Row {
|
||||
id: gaugeRow
|
||||
spacing: container.width * 0.02
|
||||
anchors.centerIn: parent
|
||||
|
||||
TurnIndicator {
|
||||
id: leftIndicator
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: height
|
||||
height: container.height * 0.1 - gaugeRow.spacing
|
||||
|
||||
direction: Qt.LeftArrow
|
||||
on: valueSource.turnSignal == Qt.LeftArrow
|
||||
}
|
||||
|
||||
Item {
|
||||
width: height
|
||||
height: container.height * 0.25 - gaugeRow.spacing
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
CircularGauge {
|
||||
id: fuelGauge
|
||||
value: valueSource.fuel
|
||||
maximumValue: 1
|
||||
y: parent.height / 2 - height / 2 - container.height * 0.01
|
||||
width: parent.width
|
||||
height: parent.height * 0.7
|
||||
|
||||
style: IconGaugeStyle {
|
||||
id: fuelGaugeStyle
|
||||
|
||||
icon: "qrc:/images/fuel-icon.png"
|
||||
minWarningColor: Qt.rgba(0.5, 0, 0, 1)
|
||||
|
||||
tickmarkLabel: Text {
|
||||
color: "white"
|
||||
visible: styleData.value === 0 || styleData.value === 1
|
||||
font.pixelSize: fuelGaugeStyle.toPixels(0.225)
|
||||
text: styleData.value === 0 ? "E" : (styleData.value === 1 ? "F" : "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CircularGauge {
|
||||
value: valueSource.temperature
|
||||
maximumValue: 1
|
||||
width: parent.width
|
||||
height: parent.height * 0.7
|
||||
y: parent.height / 2 + container.height * 0.01
|
||||
|
||||
style: IconGaugeStyle {
|
||||
id: tempGaugeStyle
|
||||
|
||||
icon: "qrc:/images/temperature-icon.png"
|
||||
maxWarningColor: Qt.rgba(0.5, 0, 0, 1)
|
||||
|
||||
tickmarkLabel: Text {
|
||||
color: "white"
|
||||
visible: styleData.value === 0 || styleData.value === 1
|
||||
font.pixelSize: tempGaugeStyle.toPixels(0.225)
|
||||
text: styleData.value === 0 ? "C" : (styleData.value === 1 ? "H" : "")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CircularGauge {
|
||||
id: speedometer
|
||||
value: valueSource.kph
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
maximumValue: 280
|
||||
// We set the width to the height, because the height will always be
|
||||
// the more limited factor. Also, all circular controls letterbox
|
||||
// their contents to ensure that they remain circular. However, we
|
||||
// don't want to extra space on the left and right of our gauges,
|
||||
// because they're laid out horizontally, and that would create
|
||||
// large horizontal gaps between gauges on wide screens.
|
||||
width: height
|
||||
height: container.height * 0.5
|
||||
|
||||
style: DashboardGaugeStyle {}
|
||||
}
|
||||
|
||||
CircularGauge {
|
||||
id: tachometer
|
||||
width: height
|
||||
height: container.height * 0.25 - gaugeRow.spacing
|
||||
value: valueSource.rpm
|
||||
maximumValue: 8
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
style: TachometerStyle {}
|
||||
}
|
||||
|
||||
TurnIndicator {
|
||||
id: rightIndicator
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: height
|
||||
height: container.height * 0.1 - gaugeRow.spacing
|
||||
|
||||
direction: Qt.RightArrow
|
||||
on: valueSource.turnSignal == Qt.RightArrow
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
14
robot_center/src/resources/robot_center.qrc
Normal file
14
robot_center/src/resources/robot_center.qrc
Normal file
@ -0,0 +1,14 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>fonts/DejaVuSans.ttf</file>
|
||||
<file>images/fuel-icon.png</file>
|
||||
<file>images/temperature-icon.png</file>
|
||||
<file>images/defualt_background.jpg</file>
|
||||
<file>qml/dashboard.qml</file>
|
||||
<file>qml/DashboardGaugeStyle.qml</file>
|
||||
<file>qml/IconGaugeStyle.qml</file>
|
||||
<file>qml/TachometerStyle.qml</file>
|
||||
<file>qml/TurnIndicator.qml</file>
|
||||
<file>qml/ValueSource.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
322
robot_center/src/resources/ui/mainwindow.ui
Normal file
322
robot_center/src/resources/ui/mainwindow.ui
Normal file
@ -0,0 +1,322 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1024</width>
|
||||
<height>750</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>1024</width>
|
||||
<height>750</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>1024</width>
|
||||
<height>750</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>RobotCenter</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<widget class="QWidget" name="formLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>350</x>
|
||||
<y>460</y>
|
||||
<width>179</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_Port">
|
||||
<property name="text">
|
||||
<string>端口</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="edit_Port">
|
||||
<property name="text">
|
||||
<string>1090</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_IP">
|
||||
<property name="text">
|
||||
<string>IP地址</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="edit_IP">
|
||||
<property name="text">
|
||||
<string>0.0.0.0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="pushButton_start_server">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>启动服务</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="gridLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>460</y>
|
||||
<width>281</width>
|
||||
<height>107</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="pushButton_W">
|
||||
<property name="text">
|
||||
<string>前进</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="pushButton_S">
|
||||
<property name="text">
|
||||
<string>后退</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="pushButton_R">
|
||||
<property name="text">
|
||||
<string>运动复位</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="pushButton_A">
|
||||
<property name="text">
|
||||
<string>左旋</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="pushButton_D">
|
||||
<property name="text">
|
||||
<string>右旋</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="pushButton_Q">
|
||||
<property name="text">
|
||||
<string>顺时针左旋</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pushButton_E">
|
||||
<property name="text">
|
||||
<string>逆时针左旋</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="pushButton_up">
|
||||
<property name="text">
|
||||
<string>加速</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="pushButton_down">
|
||||
<property name="text">
|
||||
<string>减速</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="horizontalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>1</y>
|
||||
<width>1021</width>
|
||||
<height>451</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>雷达视图</string>
|
||||
</attribute>
|
||||
<widget class="RadarViewer" name="openGLWidget_Show">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>10</y>
|
||||
<width>400</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>400</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>4000</width>
|
||||
<height>4000</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>传感器视图</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget_2">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_5">
|
||||
<attribute name="title">
|
||||
<string>源图像</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_6">
|
||||
<attribute name="title">
|
||||
<string>二值</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_9">
|
||||
<attribute name="title">
|
||||
<string>深度图</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_10">
|
||||
<attribute name="title">
|
||||
<string>目标图</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>540</x>
|
||||
<y>460</y>
|
||||
<width>61</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton">
|
||||
<property name="text">
|
||||
<string>追踪</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_3">
|
||||
<property name="text">
|
||||
<string>遥控</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_2">
|
||||
<property name="text">
|
||||
<string>寻线</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QTextBrowser" name="textBrowser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>570</y>
|
||||
<width>1011</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QListView" name="client_robot">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>620</x>
|
||||
<y>460</y>
|
||||
<width>391</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1024</width>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="mainToolBar">
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>RadarViewer</class>
|
||||
<extends>QOpenGLWidget</extends>
|
||||
<header location="global">radarviewer.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
5
robot_center/src/sources/asio/rc_serial_server.cpp
Normal file
5
robot_center/src/sources/asio/rc_serial_server.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
//
|
||||
// Created by pulsarv on 19-5-2.
|
||||
//
|
||||
|
||||
#include "src/include/asio/rc_serial_server.h"
|
63
robot_center/src/sources/asio/rc_socket_server.cpp
Normal file
63
robot_center/src/sources/asio/rc_socket_server.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
//
|
||||
// Created by pulsarv on 19-5-2.
|
||||
//
|
||||
|
||||
#include <asio/rc_socket_server.h>
|
||||
#include <iostream>
|
||||
|
||||
rc_socket_server::rc_socket_server(QObject *parent) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void rc_socket_server::set_server_properties(int port, int max_buffer_size) {
|
||||
|
||||
}
|
||||
|
||||
rc_socket_server::rc_socket_server(int port, int max_buffer_size,QObject *parent) :QTcpServer(parent), port(port), max_buffer_size(max_buffer_size) {
|
||||
this->tcp_server = new QTcpServer();
|
||||
|
||||
}
|
||||
|
||||
|
||||
rc_socket_server::~rc_socket_server() {
|
||||
this->tcp_server->close();
|
||||
this->tcp_server->deleteLater();
|
||||
}
|
||||
|
||||
void rc_socket_server::bind_call(void (*bind_function)(void *)) {
|
||||
this->bind_function = bind_function;
|
||||
}
|
||||
|
||||
void rc_socket_server::start_listen() {
|
||||
std::cout << "Start Listen On:"<<this->port << std::endl;
|
||||
this->tcp_server->listen(QHostAddress::LocalHost, this->port);
|
||||
connect(this->tcp_server, &QTcpServer::newConnection, this, &rc_socket_server::server_new_connection);
|
||||
}
|
||||
|
||||
void rc_socket_server::server_new_connection() {
|
||||
|
||||
std::cout << "New User" << std::endl;
|
||||
this->tcp_socket = this->tcp_server->nextPendingConnection();
|
||||
if (!this->tcp_socket) {
|
||||
return;
|
||||
} else {
|
||||
connect(tcp_socket, SIGNAL(readyRead()), this, SLOT(server_read_data()));
|
||||
connect(tcp_socket, SIGNAL(disconnected()), this, SLOT(server_disconnect()));
|
||||
}
|
||||
}
|
||||
|
||||
void rc_socket_server::server_read_data() {
|
||||
char *buffer = new char[this->max_buffer_size];
|
||||
this->tcp_socket->read(buffer, this->max_buffer_size);
|
||||
if (strlen(buffer) > 0) {
|
||||
std::string message = buffer;
|
||||
// this->bind_function((void*)(&message));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void rc_socket_server::server_disconnect() {
|
||||
return;
|
||||
}
|
44
robot_center/src/sources/asio/rc_tcp_server_boost.cpp
Normal file
44
robot_center/src/sources/asio/rc_tcp_server_boost.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
//
|
||||
// Created by pulsarv on 19-5-2.
|
||||
//
|
||||
|
||||
#include <asio/rc_tcp_server_boost.h>
|
||||
#include <boost/bind.hpp>
|
||||
#include <iostream>
|
||||
void connect_handler(const boost::system::error_code &ec){
|
||||
|
||||
}
|
||||
rc_tcp_server_boost::rc_tcp_server_boost(int port, boost::asio::io_service &ios):ios_(ios){
|
||||
boost::asio::ip::tcp::endpoint ep(boost::asio::ip::address::from_string("0.0.0.0"), port);
|
||||
boost::asio::ip::tcp::acceptor acceptor_(ios,ep);
|
||||
boost::asio::ip::tcp::socket sock(ios);
|
||||
sock.async_connect(ep,connect_handler);
|
||||
ios.run();
|
||||
start_listen();
|
||||
}
|
||||
|
||||
rc_tcp_server_boost::~rc_tcp_server_boost() {
|
||||
|
||||
}
|
||||
|
||||
void rc_tcp_server_boost::start_listen() {
|
||||
socket_ptr socket(new boost::asio::ip::tcp::socket(ios_));
|
||||
|
||||
}
|
||||
void rc_tcp_server_boost::accept_handler(const boost::system::error_code& _ec, socket_ptr _socket) {
|
||||
// 错误码检测
|
||||
if (_ec) {
|
||||
return;
|
||||
}
|
||||
// 打印当前连接进来的客户端
|
||||
std::cout << "client: " << _socket->remote_endpoint().address() << std::endl;
|
||||
// 异步发送 "hello CSND_Ayo" 消息到客户端,发送成功后,自动调用Server::write_handler函数
|
||||
_socket->async_write_some(boost::asio::buffer("hello CSND_Ayo"),
|
||||
boost::bind(&rc_tcp_server_boost::write_handler, this,
|
||||
boost::asio::placeholders::error/* 此处作为占位符 */));
|
||||
// 启动新的异步监听
|
||||
start_listen();
|
||||
}
|
||||
void rc_tcp_server_boost::write_handler(const boost::system::error_code& _ec) {
|
||||
std::cout << "server: send message complete." << std::endl;
|
||||
}
|
21
robot_center/src/sources/main.cpp
Normal file
21
robot_center/src/sources/main.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include <mainwindow.h>
|
||||
#include <QApplication>
|
||||
|
||||
#include <QtQml/QQmlApplicationEngine>
|
||||
#include <QtGui/QFont>
|
||||
#include <QtGui/QFontDatabase>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
MainWindow window;
|
||||
window.show();
|
||||
// QFontDatabase::addApplicationFont(":/fonts/DejaVuSans.ttf");
|
||||
// app.setFont(QFont("DejaVu Sans"));
|
||||
//
|
||||
// QQmlApplicationEngine engine(QUrl("qrc:/qml/dashboard.qml"));
|
||||
// if (engine.rootObjects().isEmpty())
|
||||
// return -1;
|
||||
|
||||
return app.exec();
|
||||
}
|
151
robot_center/src/sources/mainwindow.cpp
Normal file
151
robot_center/src/sources/mainwindow.cpp
Normal file
@ -0,0 +1,151 @@
|
||||
#include <mainwindow.h>
|
||||
#include <iostream>
|
||||
#include <asio/rc_socket_server.h>
|
||||
#include <asio/rc_tcp_server_boost.h>
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow) {
|
||||
ui->setupUi(this);
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_start_server_clicked() {
|
||||
if (ui->edit_IP->isEnabled() and ui->edit_Port->isEnabled()) {
|
||||
ui->edit_IP->setEnabled(false);
|
||||
ui->edit_Port->setEnabled(false);
|
||||
ui->pushButton_start_server->setText("关闭服务");
|
||||
// try {
|
||||
// std::cout << "server start." << std::endl;
|
||||
// boost::asio::io_service ios;
|
||||
// rc_tcp_server_boost rcTcpServerBoost(1090, ios);
|
||||
// ios.run();
|
||||
// }
|
||||
// catch (std::exception &_e) {
|
||||
// ui->edit_IP->setEnabled(true);
|
||||
// ui->edit_Port->setEnabled(true);
|
||||
// ui->pushButton_start_server->setText("开启服务");
|
||||
// std::cout << _e.what() << std::endl;
|
||||
// }
|
||||
} else {
|
||||
ui->edit_IP->setEnabled(true);
|
||||
ui->edit_Port->setEnabled(true);
|
||||
ui->pushButton_start_server->setText("开启服务");
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::keyPressEvent(QKeyEvent *event) {
|
||||
switch (event->key()) {
|
||||
case Qt::Key_W:
|
||||
ui->pushButton_W->setDown(true);
|
||||
break;
|
||||
case Qt::Key_S:
|
||||
ui->pushButton_S->setDown(true);
|
||||
break;
|
||||
case Qt::Key_A:
|
||||
ui->pushButton_A->setDown(true);
|
||||
break;
|
||||
case Qt::Key_D:
|
||||
ui->pushButton_D->setDown(true);
|
||||
break;
|
||||
case Qt::Key_R:
|
||||
ui->pushButton_R->setDown(true);
|
||||
break;
|
||||
case Qt::Key_E:
|
||||
ui->pushButton_E->setDown(true);
|
||||
break;
|
||||
case Qt::Key_Q:
|
||||
ui->pushButton_Q->setDown(true);
|
||||
break;
|
||||
case Qt::Key_Z:
|
||||
ui->pushButton_up->setDown(true);
|
||||
break;
|
||||
case Qt::Key_C:
|
||||
ui->pushButton_down->setDown(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::keyReleaseEvent(QKeyEvent *event) {
|
||||
switch (event->key()) {
|
||||
case Qt::Key_W:
|
||||
ui->pushButton_W->setDown(false);
|
||||
ui->pushButton_W->clicked();
|
||||
break;
|
||||
case Qt::Key_S:
|
||||
ui->pushButton_S->setDown(false);
|
||||
ui->pushButton_S->clicked();
|
||||
break;
|
||||
case Qt::Key_A:
|
||||
ui->pushButton_A->setDown(false);
|
||||
ui->pushButton_A->clicked();
|
||||
break;
|
||||
case Qt::Key_D:
|
||||
ui->pushButton_D->setDown(false);
|
||||
ui->pushButton_D->clicked();
|
||||
break;
|
||||
case Qt::Key_R:
|
||||
ui->pushButton_R->setDown(false);
|
||||
ui->pushButton_R->clicked();
|
||||
break;
|
||||
case Qt::Key_E:
|
||||
ui->pushButton_E->setDown(false);
|
||||
ui->pushButton_E->clicked();
|
||||
break;
|
||||
case Qt::Key_Q:
|
||||
ui->pushButton_Q->setDown(false);
|
||||
ui->pushButton_Q->clicked();
|
||||
break;
|
||||
case Qt::Key_Z:
|
||||
ui->pushButton_up->setDown(false);
|
||||
ui->pushButton_up->clicked();
|
||||
break;
|
||||
case Qt::Key_C:
|
||||
ui->pushButton_down->setDown(false);
|
||||
ui->pushButton_down->clicked();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_Q_clicked() {
|
||||
std::cout << "Q pressed" << std::endl;
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_W_clicked() {
|
||||
std::cout << "W pressed" << std::endl;
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_A_clicked() {
|
||||
std::cout << "A pressed" << std::endl;
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_S_clicked() {
|
||||
std::cout << "S pressed" << std::endl;
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_D_clicked() {
|
||||
std::cout << "D pressed" << std::endl;
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_R_clicked() {
|
||||
std::cout << "R pressed" << std::endl;
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_E_clicked() {
|
||||
std::cout << "E pressed" << std::endl;
|
||||
}
|
||||
|
||||
void MainWindow::on_clicked() {
|
||||
|
||||
std::cout << " on_clicked" << std::endl;
|
||||
}
|
323
robot_center/src/sources/mainwindow.ui
Normal file
323
robot_center/src/sources/mainwindow.ui
Normal file
@ -0,0 +1,323 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1024</width>
|
||||
<height>750</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>1024</width>
|
||||
<height>750</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>1024</width>
|
||||
<height>750</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>RobotCenter</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<widget class="QWidget" name="formLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>350</x>
|
||||
<y>460</y>
|
||||
<width>179</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_Port">
|
||||
<property name="text">
|
||||
<string>端口</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="edit_Port">
|
||||
<property name="text">
|
||||
<string>1090</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_IP">
|
||||
<property name="text">
|
||||
<string>IP地址</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="edit_IP">
|
||||
<property name="text">
|
||||
|
||||
<string>0.0.0.0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="pushButton_start_server">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>启动服务</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="gridLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>460</y>
|
||||
<width>281</width>
|
||||
<height>107</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="pushButton_W">
|
||||
<property name="text">
|
||||
<string>前进</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="pushButton_S">
|
||||
<property name="text">
|
||||
<string>后退</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="pushButton_R">
|
||||
<property name="text">
|
||||
<string>运动复位</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="pushButton_A">
|
||||
<property name="text">
|
||||
<string>左旋</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="pushButton_D">
|
||||
<property name="text">
|
||||
<string>右旋</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="pushButton_Q">
|
||||
<property name="text">
|
||||
<string>顺时针左旋</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pushButton_E">
|
||||
<property name="text">
|
||||
<string>逆时针左旋</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="pushButton_up">
|
||||
<property name="text">
|
||||
<string>加速</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="pushButton_down">
|
||||
<property name="text">
|
||||
<string>减速</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="horizontalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>1</y>
|
||||
<width>1021</width>
|
||||
<height>451</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>雷达视图</string>
|
||||
</attribute>
|
||||
<widget class="RadarViewer" name="openGLWidget_Show">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>10</y>
|
||||
<width>400</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>400</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>4000</width>
|
||||
<height>4000</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>传感器视图</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget_2">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_5">
|
||||
<attribute name="title">
|
||||
<string>源图像</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_6">
|
||||
<attribute name="title">
|
||||
<string>二值</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_9">
|
||||
<attribute name="title">
|
||||
<string>深度图</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_10">
|
||||
<attribute name="title">
|
||||
<string>目标图</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>540</x>
|
||||
<y>460</y>
|
||||
<width>61</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton">
|
||||
<property name="text">
|
||||
<string>追踪</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_3">
|
||||
<property name="text">
|
||||
<string>遥控</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_2">
|
||||
<property name="text">
|
||||
<string>寻线</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QTextBrowser" name="textBrowser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>570</y>
|
||||
<width>1011</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QListView" name="client_robot">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>620</x>
|
||||
<y>460</y>
|
||||
<width>391</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1024</width>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="mainToolBar">
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>RadarViewer</class>
|
||||
<extends>QOpenGLWidget</extends>
|
||||
<header location="global">radarviewer.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
100
robot_center/src/sources/origin/tcpserver.cpp
Normal file
100
robot_center/src/sources/origin/tcpserver.cpp
Normal file
@ -0,0 +1,100 @@
|
||||
//
|
||||
// Created by pulsarv on 19-5-2.
|
||||
//
|
||||
|
||||
#include <origin/tcpserver.h>
|
||||
#include "qhostaddress.h"
|
||||
|
||||
TcpClient::TcpClient(int clientID, QObject *parent) :
|
||||
QTcpSocket(parent)
|
||||
{
|
||||
this->clientID = clientID;
|
||||
connect(this, SIGNAL(readyRead()), this, SLOT(readData()));
|
||||
connect(this, SIGNAL(disconnected()), this, SLOT(disConnect()));
|
||||
}
|
||||
|
||||
void TcpClient::readData()
|
||||
{
|
||||
if (bytesAvailable() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray data = readAll();
|
||||
emit clientReadData(clientID, peerAddress().toString(), peerPort(), data);
|
||||
}
|
||||
|
||||
void TcpClient::disConnect()
|
||||
{
|
||||
emit clientDisConnect(clientID, peerAddress().toString(), peerPort());
|
||||
}
|
||||
|
||||
|
||||
TcpServer::TcpServer(QObject *parent) :
|
||||
QTcpServer(parent)
|
||||
{
|
||||
clientCount = 0;
|
||||
}
|
||||
|
||||
void TcpServer::incomingConnection(int handle)
|
||||
{
|
||||
TcpClient *client = new TcpClient(handle, this);
|
||||
client->setSocketDescriptor(handle);
|
||||
|
||||
connect(client, SIGNAL(clientReadData(int, QString, int, QByteArray)),
|
||||
this, SIGNAL(clientReadData(int, QString, int, QByteArray)));
|
||||
connect(client, SIGNAL(clientDisConnect(int, QString, int)),
|
||||
this, SLOT(disConnect(int, QString, int)));
|
||||
|
||||
QString ip = client->peerAddress().toString();
|
||||
int port = client->peerPort();
|
||||
|
||||
clientLists.append(client);
|
||||
clientIDs.append(handle);
|
||||
clientInfo.append(QString("%1:%2").arg(ip).arg(port));
|
||||
clientCount++;
|
||||
|
||||
emit clientConnect(handle, ip, port);
|
||||
}
|
||||
|
||||
void TcpServer::disConnect(int clientID, QString ip, int port)
|
||||
{
|
||||
for (int i = 0; i < clientCount; i++) {
|
||||
if (clientIDs.at(i) == clientID) {
|
||||
clientLists.at(i)->close();
|
||||
clientLists.removeAt(i);
|
||||
clientIDs.removeAt(i);
|
||||
clientInfo.removeAt(i);
|
||||
clientCount--;
|
||||
emit clientDisConnect(clientID, ip, port);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TcpServer::sendData(QString ip, int port, QByteArray data)
|
||||
{
|
||||
for (int i = 0; i < clientCount; i++) {
|
||||
QString str = QString("%1:%2").arg(ip).arg(port);
|
||||
|
||||
if (str == clientInfo.at(i)) {
|
||||
clientLists.at(i)->write(data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TcpServer::sendData(QByteArray data)
|
||||
{
|
||||
for (int i = 0; i < clientCount; i++) {
|
||||
clientLists.at(i)->write(data);
|
||||
}
|
||||
}
|
||||
|
||||
void TcpServer::closeAll()
|
||||
{
|
||||
foreach (TcpClient *client, clientLists) {
|
||||
client->close();
|
||||
}
|
||||
|
||||
this->close();
|
||||
}
|
25
robot_center/src/sources/radarviewer.cpp
Normal file
25
robot_center/src/sources/radarviewer.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include <radarviewer.h>
|
||||
#include <QOpenGLWidget>
|
||||
#include <QPainter>
|
||||
|
||||
RadarViewer::RadarViewer(QWidget *parent)
|
||||
: QOpenGLWidget(parent) {
|
||||
}
|
||||
|
||||
RadarViewer::~RadarViewer() {
|
||||
}
|
||||
|
||||
void RadarViewer::paintGL() {
|
||||
glClear(GL_ACCUM_BUFFER_BIT);
|
||||
|
||||
}
|
||||
|
||||
void RadarViewer::paintEvent(QPaintEvent *e) {
|
||||
QPainter painter;
|
||||
painter.begin(this);
|
||||
|
||||
QImage img;
|
||||
img.load("./test.jpg");
|
||||
painter.drawImage(QPoint(0, 0), img);
|
||||
painter.end();
|
||||
}
|
5
robot_center/test/CMakeLists.txt
Normal file
5
robot_center/test/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
###############################(rc_socket_boost_test)###################################
|
||||
set(ROBOT_TEST_DIR ${PROJECT_SOURCE_DIR}/test)
|
||||
add_executable(rc_socket_boost_test ${ROBOT_TEST_DIR}/rc_socket_boost_test.cpp )
|
||||
target_link_libraries(rc_socket_boost_test ${Boost_LIBRARIES})
|
||||
##################################################################
|
170
robot_center/test/rc_socket_boost_test.cpp
Normal file
170
robot_center/test/rc_socket_boost_test.cpp
Normal file
@ -0,0 +1,170 @@
|
||||
//
|
||||
// Created by pulsarv on 19-5-2.
|
||||
//
|
||||
#ifdef WIN32
|
||||
#define _WIN32_WINNT 0x0501
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#include <iostream>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
using namespace boost::asio;
|
||||
using namespace boost::posix_time;
|
||||
io_service service;
|
||||
|
||||
class talk_to_client;
|
||||
typedef boost::shared_ptr<talk_to_client> client_ptr;
|
||||
typedef std::vector<client_ptr> array;
|
||||
array clients;
|
||||
|
||||
#define MEM_FN(x) boost::bind(&self_type::x, shared_from_this())
|
||||
#define MEM_FN1(x,y) boost::bind(&self_type::x, shared_from_this(),y)
|
||||
#define MEM_FN2(x,y,z) boost::bind(&self_type::x, shared_from_this(),y,z)
|
||||
|
||||
void update_clients_changed();
|
||||
|
||||
/** simple connection to server:
|
||||
- logs in just with username (no password)
|
||||
- all connections are initiated by the client: client asks, server answers
|
||||
- server disconnects any client that hasn't pinged for 5 seconds
|
||||
Possible client requests:
|
||||
- gets a list of all connected clients
|
||||
- ping: the server answers either with "ping ok" or "ping client_list_changed"
|
||||
*/
|
||||
class talk_to_client : public boost::enable_shared_from_this<talk_to_client>
|
||||
, boost::noncopyable {
|
||||
typedef talk_to_client self_type;
|
||||
talk_to_client() : sock_(service), started_(false),
|
||||
timer_(service), clients_changed_(false) {
|
||||
}
|
||||
public:
|
||||
typedef boost::system::error_code error_code;
|
||||
typedef boost::shared_ptr<talk_to_client> ptr;
|
||||
|
||||
void start() {
|
||||
started_ = true;
|
||||
clients.push_back(shared_from_this());
|
||||
last_ping = boost::posix_time::microsec_clock::local_time();
|
||||
do_read();
|
||||
}
|
||||
static ptr new_() {
|
||||
ptr new_(new talk_to_client);
|
||||
return new_;
|
||||
}
|
||||
void stop() {
|
||||
if (!started_) return;
|
||||
started_ = false;
|
||||
sock_.close();
|
||||
|
||||
ptr self = shared_from_this();
|
||||
array::iterator it = std::find(clients.begin(), clients.end(), self);
|
||||
clients.erase(it);
|
||||
update_clients_changed();
|
||||
}
|
||||
bool started() const { return started_; }
|
||||
ip::tcp::socket & sock() { return sock_; }
|
||||
std::string username() const { return username_; }
|
||||
void set_clients_changed() { clients_changed_ = true; }
|
||||
private:
|
||||
void on_read(const error_code & err, size_t bytes) {
|
||||
if (err) stop();
|
||||
if (!started()) return;
|
||||
// process the msg
|
||||
std::string msg(read_buffer_, bytes);
|
||||
std::cout<<msg<<std::endl;
|
||||
if (msg.find("login ") == 0) on_login(msg);
|
||||
else if (msg.find("ping") == 0) on_ping();
|
||||
else if (msg.find("ask_clients") == 0) on_clients();
|
||||
else std::cerr << "invalid msg " << msg << std::endl;
|
||||
}
|
||||
|
||||
void on_login(const std::string & msg) {
|
||||
std::istringstream in(msg);
|
||||
in >> username_ >> username_;
|
||||
std::cout << username_ << " logged in" << std::endl;
|
||||
do_write("login ok\n");
|
||||
update_clients_changed();
|
||||
}
|
||||
void on_ping() {
|
||||
do_write(clients_changed_ ? "ping client_list_changed\n" : "ping ok\n");
|
||||
clients_changed_ = false;
|
||||
}
|
||||
void on_clients() {
|
||||
std::string msg;
|
||||
for (array::const_iterator b = clients.begin(), e = clients.end(); b != e; ++b)
|
||||
msg += (*b)->username() + " ";
|
||||
do_write("clients " + msg + "\n");
|
||||
}
|
||||
|
||||
void do_ping() {
|
||||
do_write("ping\n");
|
||||
}
|
||||
void do_ask_clients() {
|
||||
do_write("ask_clients\n");
|
||||
}
|
||||
|
||||
void on_check_ping() {
|
||||
boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time();
|
||||
if ((now - last_ping).total_milliseconds() > 5000) {
|
||||
std::cout << "stopping " << username_ << " - no ping in time" << std::endl;
|
||||
stop();
|
||||
}
|
||||
last_ping = boost::posix_time::microsec_clock::local_time();
|
||||
}
|
||||
void post_check_ping() {
|
||||
timer_.expires_from_now(boost::posix_time::millisec(5000));
|
||||
timer_.async_wait(MEM_FN(on_check_ping));
|
||||
}
|
||||
|
||||
void on_write(const error_code & err, size_t bytes) {
|
||||
do_read();
|
||||
}
|
||||
void do_read() {
|
||||
async_read(sock_, buffer(read_buffer_),
|
||||
MEM_FN2(read_complete, _1, _2), MEM_FN2(on_read, _1, _2));
|
||||
post_check_ping();
|
||||
}
|
||||
void do_write(const std::string & msg) {
|
||||
if (!started()) return;
|
||||
std::copy(msg.begin(), msg.end(), write_buffer_);
|
||||
sock_.async_write_some(buffer(write_buffer_, msg.size()),
|
||||
MEM_FN2(on_write, _1, _2));
|
||||
}
|
||||
size_t read_complete(const boost::system::error_code & err, size_t bytes) {
|
||||
if (err) return 0;
|
||||
bool found = std::find(read_buffer_, read_buffer_ + bytes, '\n') < read_buffer_ + bytes;
|
||||
return found ? 0 : 1;
|
||||
}
|
||||
private:
|
||||
ip::tcp::socket sock_;
|
||||
enum { max_msg = 1024 };
|
||||
char read_buffer_[max_msg];
|
||||
char write_buffer_[max_msg];
|
||||
bool started_;
|
||||
std::string username_;
|
||||
deadline_timer timer_;
|
||||
boost::posix_time::ptime last_ping;
|
||||
bool clients_changed_;
|
||||
};
|
||||
|
||||
void update_clients_changed() {
|
||||
for (array::iterator b = clients.begin(), e = clients.end(); b != e; ++b)
|
||||
(*b)->set_clients_changed();
|
||||
}
|
||||
|
||||
ip::tcp::acceptor acceptor(service, ip::tcp::endpoint(ip::tcp::v4(), 9002));
|
||||
|
||||
void handle_accept(talk_to_client::ptr client, const boost::system::error_code & err) {
|
||||
std::cout<<"New User"<<std::endl;
|
||||
client->start();
|
||||
talk_to_client::ptr new_client = talk_to_client::new_();
|
||||
acceptor.async_accept(new_client->sock(), boost::bind(handle_accept, new_client, _1));
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
talk_to_client::ptr client = talk_to_client::new_();
|
||||
acceptor.async_accept(client->sock(), boost::bind(handle_accept, client, _1));
|
||||
service.run();
|
||||
}
|
34
robot_client/CMakeLists.txt
Normal file
34
robot_client/CMakeLists.txt
Normal file
@ -0,0 +1,34 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
project(RoboCar)
|
||||
message(STATUS ===================================RobotClient============================)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/common)
|
||||
|
||||
set(ENV_CMAKE_FILES_PATH ${PROJECT_SOURCE_DIR}/../cmake)
|
||||
set(CMAKE_FILES_PATH ${PROJECT_SOURCE_DIR}/src/cmake)
|
||||
include(${CMAKE_FILES_PATH}/rcEnviromentVariableCmake.cmake)
|
||||
|
||||
include(${ENV_CMAKE_FILES_PATH}/rcMpiCmake.cmake)
|
||||
include(${ENV_CMAKE_FILES_PATH}/rcBoostCmake.cmake)
|
||||
include(${ENV_CMAKE_FILES_PATH}/rcPlathformConfigCmake.cmake)
|
||||
include(${ENV_CMAKE_FILES_PATH}/rcGlobalIncludeCmake.cmake)
|
||||
include(${ENV_CMAKE_FILES_PATH}/rcOpenGLCmake.cmake)
|
||||
include(${ENV_CMAKE_FILES_PATH}/rcOpenCVCmake.cmake)
|
||||
|
||||
include(${CMAKE_FILES_PATH}/rcSLAMRadarCmake.cmake)
|
||||
include(${CMAKE_FILES_PATH}/rcNetworkCmake.cmake)
|
||||
include(${CMAKE_FILES_PATH}/rcJsonCmake.cmake)
|
||||
include(${CMAKE_FILES_PATH}/rcLogCmake.cmake)
|
||||
include(${CMAKE_FILES_PATH}/rcMappingCmake.cmake)
|
||||
include(${CMAKE_FILES_PATH}/rcMessageCmake.cmake)
|
||||
include(${CMAKE_FILES_PATH}/rcTaskCmake.cmake)
|
||||
include(${CMAKE_FILES_PATH}/rcMoveCmake.cmake)
|
||||
include(${CMAKE_FILES_PATH}/rcCVCmake.cmake)
|
||||
include(${CMAKE_FILES_PATH}/rcGUICmake.cmake)
|
||||
include(${CMAKE_FILES_PATH}/rcSerialCmake.cmake)
|
||||
|
||||
include(${CMAKE_FILES_PATH}/rcNetCmake.cmake)
|
||||
include(${CMAKE_FILES_PATH}/rcCmake.cmake)
|
||||
include(${CMAKE_FILES_PATH}/rcMainCmake.cmake)
|
||||
include(${CMAKE_FILES_PATH}/rcTestCmake.cmake)
|
||||
message(STATUS ===================================DONE============================)
|
1
robot_client/README.MD
Normal file
1
robot_client/README.MD
Normal file
@ -0,0 +1 @@
|
||||
# 机器人控制中心程序
|
85
robot_client/src/cmake/mrcOpenVinoCmake.cmake
Normal file
85
robot_client/src/cmake/mrcOpenVinoCmake.cmake
Normal file
@ -0,0 +1,85 @@
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
project(MobileSearch)
|
||||
if (IE_MAIN_SOURCE_DIR AND NOT ENABLE_SAMPLES)
|
||||
return()
|
||||
endif ()
|
||||
#
|
||||
# ie_add_executable(NAME <target name>
|
||||
# SOURCES <source files>
|
||||
# [HEADERS <header files>]
|
||||
# [QT5_USE_MODELS <qt5 dependencies>]
|
||||
# [INCLUDE_DIRECTORIES <include dir>]
|
||||
# [DEPENDENCIES <dependencies>]
|
||||
# [OPENCV_DENENDENCIES <opencv modules>]
|
||||
# [EXCLUDE_CPPLINT]
|
||||
#
|
||||
|
||||
|
||||
macro(ie_add_executable)
|
||||
set(oneValueArgs NAME)
|
||||
set(multiValueArgs SOURCES HEADERS DEPENDENCIES QT5_USE_MODELS OPENCV_DEPENDENCIES INCLUDE_DIRECTORIES)
|
||||
cmake_parse_arguments(IE_TARGET "${options}" "${oneValueArgs}"
|
||||
"${multiValueArgs}" ${ARGN})
|
||||
# Find OpenCV components if exist
|
||||
if (IE_TARGET_OPENCV_DEPENDENCIES)
|
||||
find_package(OpenCV COMPONENTS ${IE_TARGET_OPENCV_DEPENDENCIES} QUIET)
|
||||
if (NOT OpenCV_FOUND)
|
||||
message(WARNING "OPENCV is disabled or not found, " ${IE_TARGET_NAME} " skipped")
|
||||
return()
|
||||
else ()
|
||||
add_definitions(-DUSE_OPENCV)
|
||||
endif ()
|
||||
endif ()
|
||||
if (TARGET IE::ie_cpu_extension)
|
||||
add_definitions(-DWITH_EXTENSIONS)
|
||||
endif ()
|
||||
# use this flag if you need to throw custom message in case if the IE package is not found.
|
||||
if (IE_NOT_FOUND_MESSAGE)
|
||||
find_package(InferenceEngine 2.0 QUIET)
|
||||
if (NOT (InferenceEngine_FOUND))
|
||||
message(FATAL_ERROR ${IE_NOT_FOUND_MESSAGE})
|
||||
endif ()
|
||||
else ()
|
||||
find_package(InferenceEngine 2.0 REQUIRED)
|
||||
endif ()
|
||||
|
||||
# Create executable file from sources
|
||||
add_executable(${IE_TARGET_NAME} ${IE_TARGET_SOURCES} ${IE_SAMPLES_HEADERS})
|
||||
target_include_directories(${IE_TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/common")
|
||||
|
||||
# if (TARGET IE::ie_cpu_extension)
|
||||
target_link_libraries(${IE_TARGET_NAME} IE::ie_cpu_extension)
|
||||
# endif ()
|
||||
|
||||
foreach (OpenCV_LIBRARIE ${OpenCV_LIBRARIES})
|
||||
message(STATUS "LINK:${OpenCV_LIBRARIE}")
|
||||
endforeach ()
|
||||
foreach (InferenceEngine_LIBRARIE ${InferenceEngine_LIBRARIES})
|
||||
message(STATUS "LINK:${InferenceEngine_LIBRARIE}")
|
||||
endforeach ()
|
||||
foreach (OPENGL_LIBRARIE ${OPENGL_LIBRARIES})
|
||||
message(STATUS "LINK:${OPENGL_LIBRARIE}")
|
||||
endforeach ()
|
||||
target_link_libraries(${IE_TARGET_NAME}
|
||||
${OpenCV_LIBRARIES}
|
||||
${InferenceEngine_LIBRARIES}
|
||||
${IE_TARGET_DEPENDENCIES}
|
||||
gflags
|
||||
boost_system
|
||||
boost_thread
|
||||
pthread
|
||||
${OPENGL_LIBRARIES}
|
||||
${GLUT_LIBRARY}
|
||||
glib-2.0
|
||||
rt
|
||||
m
|
||||
stdc++
|
||||
)
|
||||
message(STATUS "QT_MODELS:${IE_TARGET_QT5_USE_MODELS}")
|
||||
message(STATUS "TARGET:${IE_TARGET_NAME}")
|
||||
qt5_use_modules(${IE_TARGET_NAME} ${IE_TARGET_QT5_USE_MODELS})
|
||||
endmacro()
|
||||
|
||||
|
||||
|
||||
|
4
robot_client/src/cmake/rcCVCmake.cmake
Normal file
4
robot_client/src/cmake/rcCVCmake.cmake
Normal file
@ -0,0 +1,4 @@
|
||||
set(RCCV_DIR ${PROJECT_SOURCE_DIR}/src/sources/rc_cv)
|
||||
set(RC_CV_FILES ${RCCV_DIR}/rcCV.cpp)
|
||||
|
||||
|
28
robot_client/src/cmake/rcCmake.cmake
Normal file
28
robot_client/src/cmake/rcCmake.cmake
Normal file
@ -0,0 +1,28 @@
|
||||
set(LIB_NAME rc)
|
||||
set(RC_FILES
|
||||
${RC_SERAIL_FILES}
|
||||
${RC_TASK_FILES}
|
||||
${RC_RTMP_FILES}
|
||||
${RC_MOVE_FILES}
|
||||
${RC_MAPPING_FILES}
|
||||
${RC_GUI_FILES}
|
||||
${RC_CV_FILES}
|
||||
${RC_JSON_FILES}
|
||||
${RC_LOG_FILES}
|
||||
${RC_NNET_FILES}
|
||||
${RC_NETWORK_FILES}
|
||||
)
|
||||
add_library(${LIB_NAME} SHARED ${RC_FILES})
|
||||
|
||||
target_link_libraries(${LIB_NAME} ${OpenCV_LIBS}
|
||||
boost_system
|
||||
boost_thread
|
||||
pthread
|
||||
${OPENGL_LIBRARIES}
|
||||
${GLUT_LIBRARY}
|
||||
glib-2.0
|
||||
stdc++
|
||||
m
|
||||
${MPI_CXX_LIBRARIES}
|
||||
)
|
||||
|
66
robot_client/src/cmake/rcEnviromentVariableCmake.cmake
Normal file
66
robot_client/src/cmake/rcEnviromentVariableCmake.cmake
Normal file
@ -0,0 +1,66 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
set(PROJECT_BINARY_DIR ${PROJECT_BINARY_DIR}/bin)
|
||||
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
|
||||
message(STATUS "Author:Pulsar-V")
|
||||
message(STATUS "Version:1.0.1")
|
||||
|
||||
set(RC_TEST ON)
|
||||
set(RC_LIB ON)
|
||||
|
||||
option(RC_TEST "build test" ON)
|
||||
|
||||
set(MAIN_DIR ${PROJECT_SOURCE_DIR}/src)
|
||||
message(STATUS "MAIN_DIR is ${MAIN_DIR}")
|
||||
set(LIB_DIR ${PROJECT_BINARY_DIR}/libs)
|
||||
|
||||
set(SYSTEM_LIB_DIR /usr/local/libs)
|
||||
set(USER_LIB_DIR /usr/lib)
|
||||
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "")
|
||||
message(STATUS "CMAKE_BUILD_TYPE not defined, 'Release' will be used")
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
endif ()
|
||||
|
||||
if (NOT (BIN_FOLDER))
|
||||
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} ARCH)
|
||||
if (ARCH STREQUAL "x86_64" OR ARCH STREQUAL "amd64") # Windows detects Intel's 64-bit CPU as AMD64
|
||||
set(ARCH intel64)
|
||||
elseif (ARCH STREQUAL "i386")
|
||||
set(ARCH ia32)
|
||||
endif ()
|
||||
set(BIN_FOLDER ${ARCH})
|
||||
endif ()
|
||||
|
||||
if (NOT (IE_MAIN_SOURCE_DIR))
|
||||
# in case if samples are built out of IE repo
|
||||
set(IE_MAIN_SAMPLES_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
else ()
|
||||
# in case if samples are built from IE repo
|
||||
set(IE_MAIN_SAMPLES_DIR ${IE_MAIN_SOURCE_DIR})
|
||||
endif ()
|
||||
|
||||
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE}/lib)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE}/lib)
|
||||
set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE})
|
||||
set(CMAKE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE})
|
||||
set(LIBRARY_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE}/lib)
|
||||
set(LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_DIRECTORY}/lib)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wuninitialized -Winit-self")
|
||||
if (NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wmaybe-uninitialized")
|
||||
endif ()
|
||||
|
||||
set(GFLAGS_IS_SUBPROJECT TRUE)
|
||||
set(HAVE_SYS_STAT_H 1)
|
||||
set(HAVE_INTTYPES_H 1)
|
||||
|
||||
|
||||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
endif ()
|
8
robot_client/src/cmake/rcGUICmake.cmake
Normal file
8
robot_client/src/cmake/rcGUICmake.cmake
Normal file
@ -0,0 +1,8 @@
|
||||
set(RCGUI_DIR ${PROJECT_SOURCE_DIR}/src/sources/rc_gui)
|
||||
set(RC_GUI_FILES
|
||||
${RCGUI_DIR}/rcGUI.cpp
|
||||
# ${PROJECT_SOURCE_DIR}/src/rc_gui/subWindow.cpp
|
||||
# ${PROJECT_SOURCE_DIR}/src/rc_gui/mainWindow.cpp
|
||||
# ${PROJECT_SOURCE_DIR}/src/rc_gui/rc_gtk_mainwindow.cpp
|
||||
)
|
||||
|
9
robot_client/src/cmake/rcJsonCmake.cmake
Normal file
9
robot_client/src/cmake/rcJsonCmake.cmake
Normal file
@ -0,0 +1,9 @@
|
||||
set(RCJSON_DIR ${PROJECT_SOURCE_DIR}/src/sources/rc_json)
|
||||
set(RC_JSON_FILES
|
||||
${RCJSON_DIR}/json_reader.cpp
|
||||
${RCJSON_DIR}/json_tool.h
|
||||
${RCJSON_DIR}/json_value.cpp
|
||||
${RCJSON_DIR}/json_valueiterator.inl
|
||||
${RCJSON_DIR}/json_writer.cpp
|
||||
)
|
||||
|
2
robot_client/src/cmake/rcLogCmake.cmake
Normal file
2
robot_client/src/cmake/rcLogCmake.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
set(RCLOG_DIR ${PROJECT_SOURCE_DIR}/src/sources/rc_log)
|
||||
set(RC_LOG_FILES ${RCLOG_DIR}/rclog.cpp)
|
5
robot_client/src/cmake/rcMainCmake.cmake
Normal file
5
robot_client/src/cmake/rcMainCmake.cmake
Normal file
@ -0,0 +1,5 @@
|
||||
set(EXE_NAME RoboCar)
|
||||
set(RCMAIN_DIR ${PROJECT_SOURCE_DIR}/src/sources/rc_main)
|
||||
set(SOURCE_FILES ${RCMAIN_DIR}/main.cpp)
|
||||
add_executable(${EXE_NAME} ${SOURCE_FILES})
|
||||
target_link_libraries(${EXE_NAME} ${OpenCV_LIBS} rc pthread gflags)
|
13
robot_client/src/cmake/rcMappingCmake.cmake
Normal file
13
robot_client/src/cmake/rcMappingCmake.cmake
Normal file
@ -0,0 +1,13 @@
|
||||
message(STATUS "Load Mapping Module")
|
||||
set(RCMAPPING_DIR ${PROJECT_SOURCE_DIR}/src)
|
||||
|
||||
file(GLOB RC_MAPPING_FILES ${RCMAPPING_DIR}/sources/rc_mapping/*.cpp)
|
||||
set(RC_MAPPING_FILES
|
||||
${RC_MAPPING_FILES}
|
||||
${RCSLAMRADAR_FILES}
|
||||
)
|
||||
foreach(FILE ${RC_MAPPING_FILES})
|
||||
message(STATUS "RC_MAPPING:${FILE}")
|
||||
endforeach()
|
||||
include_directories(${RCMAPPING_DIR}/include)
|
||||
|
13
robot_client/src/cmake/rcMessageCmake.cmake
Normal file
13
robot_client/src/cmake/rcMessageCmake.cmake
Normal file
@ -0,0 +1,13 @@
|
||||
message(STATUS "Load Message Module")
|
||||
set(RCMESSAGE_DIR ${PROJECT_SOURCE_DIR}/src)
|
||||
file(GLOB RC_MESSAGE_FILES ${RCMESSAGE_DIR}/sources/rc_message/*.cpp)
|
||||
set(RC_MESSAGE_FILES
|
||||
${RC_MESSAGE_FILES}
|
||||
)
|
||||
foreach(FILE ${RC_MESSAGE_FILES})
|
||||
message(STATUS "RC_MESSAGE: ${FILE}")
|
||||
endforeach()
|
||||
include_directories(${RCMESSAGE_DIR}/include)
|
||||
|
||||
|
||||
|
6
robot_client/src/cmake/rcMoveCmake.cmake
Normal file
6
robot_client/src/cmake/rcMoveCmake.cmake
Normal file
@ -0,0 +1,6 @@
|
||||
set(RCMOVE_DIR ${PROJECT_SOURCE_DIR}/src/sources/rc_move)
|
||||
set(RC_MOVE_FILES
|
||||
${RCMOVE_DIR}/rcmove.cpp
|
||||
${RCMOVE_DIR}/rc_move_wheel.cpp
|
||||
)
|
||||
|
132
robot_client/src/cmake/rcNetCmake.cmake
Normal file
132
robot_client/src/cmake/rcNetCmake.cmake
Normal file
@ -0,0 +1,132 @@
|
||||
|
||||
message(STATUS "Load Machine Learning Net Module")
|
||||
set(RCNET_DIR ${PROJECT_SOURCE_DIR}/src/sources/rc_cv/rcnet)
|
||||
include_directories(${RCNET_DIR}/include)
|
||||
set(RC_NNET_FILES
|
||||
${RCNET_DIR}/src/activation_layer.c
|
||||
${RCNET_DIR}/src/activation_layer.h
|
||||
${RCNET_DIR}/src/activations.c
|
||||
${RCNET_DIR}/src/activations.h
|
||||
${RCNET_DIR}/src/avgpool_layer.c
|
||||
${RCNET_DIR}/src/avgpool_layer.h
|
||||
${RCNET_DIR}/src/batchnorm_layer.c
|
||||
${RCNET_DIR}/src/batchnorm_layer.h
|
||||
${RCNET_DIR}/src/blas.c
|
||||
${RCNET_DIR}/src/blas.h
|
||||
${RCNET_DIR}/src/box.c
|
||||
${RCNET_DIR}/src/box.h
|
||||
${RCNET_DIR}/src/classifier.h
|
||||
${RCNET_DIR}/src/col2im.c
|
||||
${RCNET_DIR}/src/col2im.h
|
||||
${RCNET_DIR}/src/compare.c
|
||||
${RCNET_DIR}/src/connected_layer.c
|
||||
${RCNET_DIR}/src/connected_layer.h
|
||||
${RCNET_DIR}/src/convolutional_layer.c
|
||||
${RCNET_DIR}/src/convolutional_layer.h
|
||||
${RCNET_DIR}/src/cost_layer.c
|
||||
${RCNET_DIR}/src/cost_layer.h
|
||||
${RCNET_DIR}/src/crnn_layer.c
|
||||
${RCNET_DIR}/src/crnn_layer.h
|
||||
${RCNET_DIR}/src/crop_layer.c
|
||||
${RCNET_DIR}/src/crop_layer.h
|
||||
${RCNET_DIR}/src/cuda.c
|
||||
${RCNET_DIR}/src/cuda.h
|
||||
${RCNET_DIR}/src/data.c
|
||||
${RCNET_DIR}/src/data.h
|
||||
${RCNET_DIR}/src/deconvolutional_layer.c
|
||||
${RCNET_DIR}/src/deconvolutional_layer.h
|
||||
${RCNET_DIR}/src/demo.c
|
||||
${RCNET_DIR}/src/demo.h
|
||||
${RCNET_DIR}/src/detection_layer.c
|
||||
${RCNET_DIR}/src/detection_layer.h
|
||||
${RCNET_DIR}/src/dropout_layer.c
|
||||
${RCNET_DIR}/src/dropout_layer.h
|
||||
${RCNET_DIR}/src/gemm.c
|
||||
${RCNET_DIR}/src/gemm.h
|
||||
${RCNET_DIR}/src/gru_layer.c
|
||||
${RCNET_DIR}/src/gru_layer.h
|
||||
${RCNET_DIR}/src/im2col.c
|
||||
${RCNET_DIR}/src/im2col.h
|
||||
${RCNET_DIR}/src/image.c
|
||||
${RCNET_DIR}/src/image.h
|
||||
${RCNET_DIR}/src/image_opencv.cpp
|
||||
${RCNET_DIR}/src/stb_image_write.h
|
||||
${RCNET_DIR}/src/iseg_layer.c
|
||||
${RCNET_DIR}/src/iseg_layer.h
|
||||
${RCNET_DIR}/src/l2norm_layer.c
|
||||
${RCNET_DIR}/src/l2norm_layer.h
|
||||
${RCNET_DIR}/src/layer.c
|
||||
${RCNET_DIR}/src/layer.h
|
||||
${RCNET_DIR}/src/list.c
|
||||
${RCNET_DIR}/src/list.h
|
||||
${RCNET_DIR}/src/local_layer.c
|
||||
${RCNET_DIR}/src/local_layer.h
|
||||
${RCNET_DIR}/src/logistic_layer.c
|
||||
${RCNET_DIR}/src/logistic_layer.h
|
||||
${RCNET_DIR}/src/lstm_layer.c
|
||||
${RCNET_DIR}/src/lstm_layer.h
|
||||
${RCNET_DIR}/src/matrix.c
|
||||
${RCNET_DIR}/src/matrix.h
|
||||
${RCNET_DIR}/src/maxpool_layer.c
|
||||
${RCNET_DIR}/src/maxpool_layer.h
|
||||
${RCNET_DIR}/src/network.c
|
||||
${RCNET_DIR}/src/network.h
|
||||
${RCNET_DIR}/src/normalization_layer.c
|
||||
${RCNET_DIR}/src/normalization_layer.h
|
||||
${RCNET_DIR}/src/option_list.c
|
||||
${RCNET_DIR}/src/option_list.h
|
||||
${RCNET_DIR}/src/parser.c
|
||||
${RCNET_DIR}/src/parser.h
|
||||
${RCNET_DIR}/src/region_layer.c
|
||||
${RCNET_DIR}/src/region_layer.h
|
||||
${RCNET_DIR}/src/region_layer.c
|
||||
${RCNET_DIR}/src/region_layer.h
|
||||
${RCNET_DIR}/src/reorg_layer.c
|
||||
${RCNET_DIR}/src/reorg_layer.h
|
||||
${RCNET_DIR}/src/rnn_layer.c
|
||||
${RCNET_DIR}/src/rnn_layer.h
|
||||
${RCNET_DIR}/src/route_layer.c
|
||||
${RCNET_DIR}/src/route_layer.h
|
||||
${RCNET_DIR}/src/shortcut_layer.c
|
||||
${RCNET_DIR}/src/shortcut_layer.h
|
||||
${RCNET_DIR}/src/softmax_layer.c
|
||||
${RCNET_DIR}/src/softmax_layer.h
|
||||
${RCNET_DIR}/src/stb_image.h
|
||||
${RCNET_DIR}/src/tree.c
|
||||
${RCNET_DIR}/src/tree.h
|
||||
${RCNET_DIR}/src/upsample_layer.c
|
||||
${RCNET_DIR}/src/upsample_layer.h
|
||||
${RCNET_DIR}/src/utils.c
|
||||
${RCNET_DIR}/src/utils.h
|
||||
${RCNET_DIR}/src/yolo_layer.c
|
||||
${RCNET_DIR}/src/yolo_layer.h
|
||||
)
|
||||
set(YOLO3
|
||||
${RCNET_DIR}/examples/darknet.c
|
||||
${RCNET_DIR}/examples/detector.c
|
||||
${RCNET_DIR}/examples/dice.c
|
||||
${RCNET_DIR}/examples/rnn.c
|
||||
${RCNET_DIR}/examples/rnn_vid.c
|
||||
${RCNET_DIR}/examples/segmenter.c
|
||||
${RCNET_DIR}/examples/super.c
|
||||
${RCNET_DIR}/examples/swag.c
|
||||
${RCNET_DIR}/examples/tag.c
|
||||
${RCNET_DIR}/examples/voxel.c
|
||||
${RCNET_DIR}/examples/writing.c
|
||||
${RCNET_DIR}/examples/coco.c
|
||||
${RCNET_DIR}/examples/art.c
|
||||
${RCNET_DIR}/examples/attention.c
|
||||
${RCNET_DIR}/examples/captcha.c
|
||||
${RCNET_DIR}/examples/cifar.c
|
||||
${RCNET_DIR}/examples/classifier.c
|
||||
${RCNET_DIR}/examples/lsd.c
|
||||
${RCNET_DIR}/examples/regressor.c
|
||||
${RCNET_DIR}/examples/nightmare.c
|
||||
${RCNET_DIR}/examples/instance-segmenter.c
|
||||
${RCNET_DIR}/examples/go.c
|
||||
${RCNET_DIR}/examples/yolo.c
|
||||
)
|
||||
foreach(FILE ${RC_NNET_FILES})
|
||||
message(STATUS "RC_NET:${FILE}")
|
||||
endforeach()
|
||||
add_executable(rcnetapp ${YOLO3})
|
20
robot_client/src/cmake/rcNetworkCmake.cmake
Normal file
20
robot_client/src/cmake/rcNetworkCmake.cmake
Normal file
@ -0,0 +1,20 @@
|
||||
message(STATUS "Load RC Network")
|
||||
set(LIB_NAME rcnetwork)
|
||||
set(RCNETWORK_SOURCES_DIR ${PROJECT_SOURCE_DIR}/src/sources/rc_network)
|
||||
set(RCNETWORK_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/src/include/rc_network)
|
||||
|
||||
file(GLOB RCNETWORK_INCLUDE ${RCNETWORK_INCLUDE_DIR}/*.h)
|
||||
file(GLOB RCNETWORK_SOURCES ${RCNETWORK_SOURCES_DIR}/*.cpp)
|
||||
|
||||
foreach (FILE ${RCNETWORK_INCLUDE})
|
||||
message(STATUS ${FILE})
|
||||
endforeach ()
|
||||
|
||||
foreach (FILE ${RCNETWORK_SOURCES})
|
||||
message(STATUS ${FILE})
|
||||
endforeach ()
|
||||
set(RC_NETWORK_FILES
|
||||
${RCNETWORK_SOURCES}
|
||||
${RCNETWORK_INCLUDE}
|
||||
)
|
||||
|
69
robot_client/src/cmake/rcSLAMRadarCmake.cmake
Normal file
69
robot_client/src/cmake/rcSLAMRadarCmake.cmake
Normal file
@ -0,0 +1,69 @@
|
||||
set(RPLIDAR_SDK_PATH ${PROJECT_SOURCE_DIR}/src/sources/rc_mapping/slam_radar)
|
||||
|
||||
include_directories(${RPLIDAR_SDK_PATH}/include)
|
||||
include_directories(${RPLIDAR_SDK_PATH})
|
||||
include_directories(${RPLIDAR_SDK_PATH}/src)
|
||||
include_directories(${RPLIDAR_SDK_PATH}/src/hal)
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
include_directories(${RPLIDAR_SDK_PATH}/src/arch/linux)
|
||||
set(RCSLAMRADAR_FILES
|
||||
${RPLIDAR_SDK_PATH}/include/rplidar.h
|
||||
${RPLIDAR_SDK_PATH}/include/rplidar_cmd.h
|
||||
${RPLIDAR_SDK_PATH}/include/rplidar_driver.h
|
||||
${RPLIDAR_SDK_PATH}/include/rplidar_protocol.h
|
||||
${RPLIDAR_SDK_PATH}/include/rptypes.h
|
||||
${RPLIDAR_SDK_PATH}/src/sdkcommon.h
|
||||
${RPLIDAR_SDK_PATH}/src/rplidar_driver.cpp
|
||||
${RPLIDAR_SDK_PATH}/src/rplidar_driver_TCP.h
|
||||
${RPLIDAR_SDK_PATH}/src/rplidar_driver_impl.h
|
||||
${RPLIDAR_SDK_PATH}/src/rplidar_driver_serial.h
|
||||
${RPLIDAR_SDK_PATH}/src/hal/abs_rxtx.h
|
||||
${RPLIDAR_SDK_PATH}/src/hal/assert.h
|
||||
${RPLIDAR_SDK_PATH}/src/hal/byteops.h
|
||||
${RPLIDAR_SDK_PATH}/src/hal/event.h
|
||||
${RPLIDAR_SDK_PATH}/src/hal/locker.h
|
||||
${RPLIDAR_SDK_PATH}/src/hal/socket.h
|
||||
${RPLIDAR_SDK_PATH}/src/hal/thread.cpp
|
||||
${RPLIDAR_SDK_PATH}/src/hal/thread.h
|
||||
${RPLIDAR_SDK_PATH}/src/hal/types.h
|
||||
${RPLIDAR_SDK_PATH}/src/hal/util.h
|
||||
${RPLIDAR_SDK_PATH}/src/arch/linux/arch_linux.h
|
||||
${RPLIDAR_SDK_PATH}/src/arch/linux/net_serial.cpp
|
||||
${RPLIDAR_SDK_PATH}/src/arch/linux/net_serial.h
|
||||
${RPLIDAR_SDK_PATH}/src/arch/linux/net_socket.cpp
|
||||
${RPLIDAR_SDK_PATH}/src/arch/linux/thread.hpp
|
||||
${RPLIDAR_SDK_PATH}/src/arch/linux/timer.cpp
|
||||
${RPLIDAR_SDK_PATH}/src/arch/linux/timer.h
|
||||
)
|
||||
else(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
include_directories(${RPLIDAR_SDK_PATH}/src/arch/win32)
|
||||
set(RCSLAMRADAR_FILES
|
||||
${RPLIDAR_SDK_PATH}/include/rplidar.h
|
||||
${RPLIDAR_SDK_PATH}/include/rplidar_cmd.h
|
||||
${RPLIDAR_SDK_PATH}/include/rplidar_driver.h
|
||||
${RPLIDAR_SDK_PATH}/include/rplidar_protocol.h
|
||||
${RPLIDAR_SDK_PATH}/include/rptypes.h
|
||||
${RPLIDAR_SDK_PATH}/src/sdkcommon.h
|
||||
${RPLIDAR_SDK_PATH}/src/rplidar_driver.cpp
|
||||
${RPLIDAR_SDK_PATH}/src/rplidar_driver_TCP.h
|
||||
${RPLIDAR_SDK_PATH}/src/rplidar_driver_impl.h
|
||||
${RPLIDAR_SDK_PATH}/src/rplidar_driver_serial.h
|
||||
${RPLIDAR_SDK_PATH}/src/hal/abs_rxtx.h
|
||||
${RPLIDAR_SDK_PATH}/src/hal/assert.h
|
||||
${RPLIDAR_SDK_PATH}/src/hal/byteops.h
|
||||
${RPLIDAR_SDK_PATH}/src/hal/event.h
|
||||
${RPLIDAR_SDK_PATH}/src/hal/locker.h
|
||||
${RPLIDAR_SDK_PATH}/src/hal/socket.h
|
||||
${RPLIDAR_SDK_PATH}/src/hal/thread.cpp
|
||||
${RPLIDAR_SDK_PATH}/src/hal/thread.h
|
||||
${RPLIDAR_SDK_PATH}/src/hal/types.h
|
||||
${RPLIDAR_SDK_PATH}/src/hal/util.h
|
||||
${RPLIDAR_SDK_PATH}/src/arch/win32/timer.h
|
||||
${RPLIDAR_SDK_PATH}/src/arch/win32/timer.cpp
|
||||
${RPLIDAR_SDK_PATH}/src/arch/win32/net_socket.cpp
|
||||
${RPLIDAR_SDK_PATH}/src/arch/win32/net_serial.h
|
||||
${RPLIDAR_SDK_PATH}/src/arch/win32/net_serial.cpp
|
||||
${RPLIDAR_SDK_PATH}/src/arch/win32/arch_win32.h
|
||||
${RPLIDAR_SDK_PATH}/src/arch/win32/winthread.hpp
|
||||
)
|
||||
endif()
|
9
robot_client/src/cmake/rcSerialCmake.cmake
Normal file
9
robot_client/src/cmake/rcSerialCmake.cmake
Normal file
@ -0,0 +1,9 @@
|
||||
message(STATUS "Load Serial Module")
|
||||
|
||||
set(RCSERAIL_DIR ${PROJECT_SOURCE_DIR}/src)
|
||||
file(GLOB RC_SERAIL_FILES ${RCMAPPING_DIR}/sources/rc_serial/*.cpp)
|
||||
|
||||
foreach(FILE ${RC_SERAIL_FILES})
|
||||
message(STATUS "RC_SERIAL: ${FILE}")
|
||||
endforeach()
|
||||
include_directories(${RCSERAIL_DIR}/include)
|
9
robot_client/src/cmake/rcTaskCmake.cmake
Normal file
9
robot_client/src/cmake/rcTaskCmake.cmake
Normal file
@ -0,0 +1,9 @@
|
||||
message(STATUS "Load Task Module")
|
||||
set(LIB_NAME rctask)
|
||||
set(RCTASK_DIR ${PROJECT_SOURCE_DIR}/src)
|
||||
file(GLOB RC_TASK_FILES ${RCTASK_DIR}/sources/rc_task/*.cpp)
|
||||
foreach(FILE ${RC_TASK_FILES})
|
||||
message(STATUS "RC_TASK:${FILE}")
|
||||
endforeach()
|
||||
include_directories(${RCTASK_DIR}/include)
|
||||
|
79
robot_client/src/cmake/rcTestCmake.cmake
Normal file
79
robot_client/src/cmake/rcTestCmake.cmake
Normal file
@ -0,0 +1,79 @@
|
||||
set(TEST_SOURCES_DIR ${PROJECT_SOURCE_DIR}/src/sources/rc_test)
|
||||
################################(rc_serial_test)#######################################
|
||||
if (RC_TEST)
|
||||
set(SERIAL_TEST ${TEST_SOURCES_DIR}/rc_serial_test.cpp)
|
||||
add_executable(rc_serial_test ${SERIAL_TEST})
|
||||
target_link_libraries(rc_serial_test ${OpenCV_LIBS} rc pthread)
|
||||
#######################################################################
|
||||
|
||||
################################(rc_cv_test)#######################################
|
||||
set(CV_TEST ${TEST_SOURCES_DIR}/rc_cv_test.cpp)
|
||||
add_executable(rc_cv_test ${CV_TEST})
|
||||
target_link_libraries(rc_cv_test ${OpenCV_LIBS} rc)
|
||||
#######################################################################
|
||||
|
||||
################################(rc_radar_test)#######################################
|
||||
set(RADAR_TEST ${TEST_SOURCES_DIR}/rc_radar_test.cpp)
|
||||
add_executable(rc_radar_test ${RADAR_TEST})
|
||||
target_link_libraries(rc_radar_test ${OpenCV_LIBS} rc)
|
||||
|
||||
#######################################################################
|
||||
|
||||
################################(rc_radar_map_test)#######################################
|
||||
set(RADAR_MAP_TEST ${TEST_SOURCES_DIR}/rc_radar_map_test.cpp)
|
||||
add_executable(rc_radar_map_test ${RADAR_MAP_TEST})
|
||||
target_link_libraries(rc_radar_map_test ${OpenCV_LIBS} rc)
|
||||
#######################################################################
|
||||
|
||||
################################(rc_imu_ju901_test)#######################################
|
||||
set(RC_IMU_TEST ${TEST_SOURCES_DIR}/rc_imu_ju901_test.cpp)
|
||||
add_executable(rc_imu_ju901_test ${RC_IMU_TEST})
|
||||
target_link_libraries(rc_imu_ju901_test ${OpenCV_LIBS} rc)
|
||||
#######################################################################
|
||||
|
||||
################################(rc_mpi_test)#######################################
|
||||
set(RC_MPI_TEST ${TEST_SOURCES_DIR}/rc_mpi_test.cpp)
|
||||
add_executable(rc_mpi_test ${RC_MPI_TEST})
|
||||
find_package(MPI REQUIRED)
|
||||
target_link_libraries(rc_mpi_test ${OpenCV_LIBS} ${MPI_CXX_LIBRARIES} mpi)
|
||||
#######################################################################
|
||||
|
||||
################################(rc_cv_mpi_test)#######################################
|
||||
set(RC_CV_MPI_TEST ${TEST_SOURCES_DIR}/rc_cv_mpi_test.cpp)
|
||||
add_executable(rc_cv_mpi_test ${RC_CV_MPI_TEST})
|
||||
target_link_libraries(rc_cv_mpi_test ${OpenCV_LIBS} ${MPI_CXX_LIBRARIES} mpi)
|
||||
################################(rc_cv_mpi_test)#######################################
|
||||
set(RC_GUI_GL_ON_GTK_TEST ${TEST_SOURCES_DIR}/rc_gl_on_gtk_test.cpp)
|
||||
add_executable(rc_gl_on_gtk_test ${RC_GUI_GL_ON_GTK_TEST})
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
pkg_check_modules(GTK3 REQUIRED gtk+-2.0)
|
||||
include_directories(${GTK2_INCLUDE_DIRS})
|
||||
link_directories(${GTK2_LIBRARY_DIRS})
|
||||
|
||||
pkg_check_modules(GTKMM2 gtkmm-2.4)
|
||||
link_directories(${GTKMM2_LIBRARY_DIRS})
|
||||
include_directories(${GTKMM3_INCLUDE_DIRS})
|
||||
|
||||
pkg_check_modules(GLEW glew)
|
||||
link_directories(${GLEW_LIBRARY_DIRS})
|
||||
include_directories(${GLEW_INCLUDE_DIRS})
|
||||
|
||||
include_directories(/usr/include/gtkgl-2.0)
|
||||
target_link_libraries(rc_gl_on_gtk_test ${OpenCV_LIBS} ${OPENGL_LIBRARIES}
|
||||
${GLUT_LIBRARY} ${MPI_CXX_LIBRARIES} ${GTK2_LIBRARIES}
|
||||
${GTKMM2_LIBRARIES} GLEW GLU gtkgl-2.0)
|
||||
#######################################################################
|
||||
################################(rc_socket_tcp_test)#######################################
|
||||
set(RC_TCP_TEST ${TEST_SOURCES_DIR}/rc_socket_tcp_test.cpp)
|
||||
add_executable(rc_socket_tcp_test ${RC_TCP_TEST})
|
||||
target_link_libraries(rc_socket_tcp_test ${OpenCV_LIBS} ${MPI_CXX_LIBRARIES} ${Boost_LIBRARIES} rc)
|
||||
#######################################################################
|
||||
|
||||
################################(rc_decode_test)#######################################
|
||||
set(RC_WHEEL_DECODE_TEST ${TEST_SOURCES_DIR}/rc_wheel_decode_test.cpp)
|
||||
add_executable(rc_wheel_decode_test ${RC_WHEEL_DECODE_TEST})
|
||||
target_link_libraries(rc_wheel_decode_test ${OpenCV_LIBS} ${MPI_CXX_LIBRARIES} ${Boost_LIBRARIES} rc)
|
||||
#######################################################################
|
||||
|
||||
endif ()
|
144
robot_client/src/common/base/args_helper.hpp
Normal file
144
robot_client/src/common/base/args_helper.hpp
Normal file
@ -0,0 +1,144 @@
|
||||
// Copyright (C) 2018-2019 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
/**
|
||||
* @brief a header file with common samples functionality
|
||||
* @file args_helper.hpp
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <gflags/gflags.h>
|
||||
#include <iostream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <base/slog.hpp>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <os/windows/w_dirent.h>
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief This function checks input args and existence of specified files in a given folder
|
||||
* @param arg path to a file to be checked for existence
|
||||
* @return files updated vector of verified input files
|
||||
*/
|
||||
inline void readInputFilesArguments(std::vector<std::string> &files, const std::string& arg) {
|
||||
struct stat sb;
|
||||
if (stat(arg.c_str(), &sb) != 0) {
|
||||
if (arg.find("rtsp:") != 0) {
|
||||
slog::warn << "File " << arg << " cannot be opened!" << slog::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (S_ISDIR(sb.st_mode)) {
|
||||
DIR *dp;
|
||||
dp = opendir(arg.c_str());
|
||||
if (dp == nullptr) {
|
||||
slog::warn << "Directory " << arg << " cannot be opened!" << slog::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
struct dirent *ep;
|
||||
while (nullptr != (ep = readdir(dp))) {
|
||||
std::string fileName = ep->d_name;
|
||||
if (fileName == "." || fileName == "..") continue;
|
||||
files.push_back(arg + "/" + ep->d_name);
|
||||
}
|
||||
closedir(dp);
|
||||
} else {
|
||||
files.push_back(arg);
|
||||
}
|
||||
|
||||
if (files.size() < 20) {
|
||||
slog::info << "Files were added: " << files.size() << slog::endl;
|
||||
for (std::string filePath : files) {
|
||||
slog::info << " " << filePath << slog::endl;
|
||||
}
|
||||
} else {
|
||||
slog::info << "Files were added: " << files.size() << ". Too many to display each of them." << slog::endl;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function find -i/--images key in input args
|
||||
* It's necessary to process multiple values for single key
|
||||
* @return files updated vector of verified input files
|
||||
*/
|
||||
inline void parseInputFilesArguments(std::vector<std::string> &files) {
|
||||
std::vector<std::string> args = gflags::GetArgvs();
|
||||
bool readArguments = false;
|
||||
for (size_t i = 0; i < args.size(); i++) {
|
||||
if (args.at(i) == "-i" || args.at(i) == "--images") {
|
||||
readArguments = true;
|
||||
continue;
|
||||
}
|
||||
if (!readArguments) {
|
||||
continue;
|
||||
}
|
||||
if (args.at(i).c_str()[0] == '-') {
|
||||
break;
|
||||
}
|
||||
readInputFilesArguments(files, args.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
inline std::vector<std::string> split(const std::string &s, char delim) {
|
||||
std::vector<std::string> result;
|
||||
std::stringstream ss(s);
|
||||
std::string item;
|
||||
|
||||
while (getline(ss, item, delim)) {
|
||||
result.push_back(item);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::vector<std::string> parseDevices(const std::string& device_string) {
|
||||
std::string comma_separated_devices = device_string;
|
||||
const std::string::size_type colon_position = comma_separated_devices.find(":");
|
||||
if (colon_position != std::string::npos) {
|
||||
comma_separated_devices = comma_separated_devices.substr(colon_position + 1);
|
||||
}
|
||||
auto devices = split(comma_separated_devices, ',');
|
||||
for (auto& device : devices)
|
||||
device = device.substr(0, device.find("("));
|
||||
return devices;
|
||||
}
|
||||
|
||||
inline std::map<std::string, uint32_t> parseValuePerDevice(const std::set<std::string>& devices,
|
||||
const std::string& values_string) {
|
||||
// Format: <device1>:<value1>,<device2>:<value2> or just <value>
|
||||
auto values_string_upper = values_string;
|
||||
std::transform(values_string_upper.begin(),
|
||||
values_string_upper.end(),
|
||||
values_string_upper.begin(),
|
||||
[](unsigned char c){ return std::toupper(c); });
|
||||
std::map<std::string, uint32_t> result;
|
||||
auto device_value_strings = split(values_string_upper, ',');
|
||||
for (auto& device_value_string : device_value_strings) {
|
||||
auto device_value_vec = split(device_value_string, ':');
|
||||
if (device_value_vec.size() == 2) {
|
||||
auto it = std::find(devices.begin(), devices.end(), device_value_vec.at(0));
|
||||
if (it != devices.end()) {
|
||||
result[device_value_vec.at(0)] = std::stoi(device_value_vec.at(1));
|
||||
}
|
||||
} else if (device_value_vec.size() == 1) {
|
||||
uint32_t value = std::stoi(device_value_vec.at(0));
|
||||
for (auto& device : devices) {
|
||||
result[device] = value;
|
||||
}
|
||||
} else if (device_value_vec.size() != 0) {
|
||||
throw std::runtime_error("Unknown string format: " + values_string);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
92
robot_client/src/common/base/classification_results.h
Normal file
92
robot_client/src/common/base/classification_results.h
Normal file
@ -0,0 +1,92 @@
|
||||
// Copyright (C) 2019 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
/**
|
||||
* @brief a header file with ouput classification results
|
||||
* @file classification_results.hpp
|
||||
*/
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
|
||||
#include <ie_blob.h>
|
||||
|
||||
/**
|
||||
* @class ClassificationResult
|
||||
* @brief A ClassificationResult creates an output table with results
|
||||
*/
|
||||
class ClassificationResult {
|
||||
private:
|
||||
const std::string _classidStr = "classid";
|
||||
const std::string _probabilityStr = "probability";
|
||||
const std::string _labelStr = "label";
|
||||
size_t _nTop;
|
||||
InferenceEngine::Blob::Ptr _outBlob;
|
||||
const std::vector<std::string> _labels;
|
||||
const std::vector<std::string> _imageNames;
|
||||
const size_t _batchSize;
|
||||
|
||||
void printHeader() {
|
||||
std::cout << _classidStr << " " << _probabilityStr;
|
||||
if (!_labels.empty())
|
||||
std::cout << " " << _labelStr;
|
||||
std::string classidColumn(_classidStr.length(), '-');
|
||||
std::string probabilityColumn(_probabilityStr.length(), '-');
|
||||
std::string labelColumn(_labelStr.length(), '-');
|
||||
std::cout << std::endl << classidColumn << " " << probabilityColumn;
|
||||
if (!_labels.empty())
|
||||
std::cout << " " << labelColumn;
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
public:
|
||||
explicit ClassificationResult(InferenceEngine::Blob::Ptr output_blob,
|
||||
std::vector<std::string> image_names = {},
|
||||
size_t batch_size = 1,
|
||||
size_t num_of_top = 10,
|
||||
std::vector<std::string> labels = {}) :
|
||||
_nTop(num_of_top),
|
||||
_outBlob(std::move(output_blob)),
|
||||
_labels(std::move(labels)),
|
||||
_imageNames(std::move(image_names)),
|
||||
_batchSize(batch_size) {
|
||||
if (_imageNames.size() != _batchSize) {
|
||||
throw std::logic_error("Batch size should be equal to the number of images.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief prints formatted classification results
|
||||
*/
|
||||
void print() {
|
||||
/** This vector stores id's of top N results **/
|
||||
std::vector<unsigned> results;
|
||||
TopResults(_nTop, *_outBlob, results);
|
||||
|
||||
/** Print the result iterating over each batch **/
|
||||
std::cout << std::endl << "Top " << _nTop << " results:" << std::endl << std::endl;
|
||||
for (unsigned int image_id = 0; image_id < _batchSize; ++image_id) {
|
||||
std::cout << "Image " << _imageNames[image_id] << std::endl << std::endl;
|
||||
printHeader();
|
||||
|
||||
for (size_t id = image_id * _nTop, cnt = 0; id < (image_id + 1) * _nTop; ++cnt, ++id) {
|
||||
std::cout.precision(7);
|
||||
/** Getting probability for resulting class **/
|
||||
const auto result = _outBlob->buffer().
|
||||
as<InferenceEngine::PrecisionTrait<InferenceEngine::Precision::FP32>::value_type*>()
|
||||
[results[id] + image_id * (_outBlob->size() / _batchSize)];
|
||||
|
||||
std::cout << std::setw(static_cast<int>(_classidStr.length())) << std::left << results[id] << " ";
|
||||
std::cout << std::left << std::setw(static_cast<int>(_probabilityStr.length())) << std::fixed << result;
|
||||
|
||||
if (!_labels.empty()) {
|
||||
std::cout << " " + _labels[results[id]];
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
};
|
1158
robot_client/src/common/base/common.hpp
Normal file
1158
robot_client/src/common/base/common.hpp
Normal file
File diff suppressed because it is too large
Load Diff
90
robot_client/src/common/base/console_progress.hpp
Normal file
90
robot_client/src/common/base/console_progress.hpp
Normal file
@ -0,0 +1,90 @@
|
||||
// Copyright (C) 2019 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
/**
|
||||
* @class ConsoleProgress
|
||||
* @brief A ConsoleProgress class provides functionality for printing progress dynamics
|
||||
*/
|
||||
class ConsoleProgress {
|
||||
static const int DEFAULT_DETALIZATION = 20;
|
||||
|
||||
size_t total;
|
||||
size_t current = 0;
|
||||
bool stream_output;
|
||||
size_t detalization;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief A constructor of ConsoleProgress class
|
||||
* @param _total - maximum value that is correspondent to 100%
|
||||
* @param _detalization - number of symbols(.) to use to represent progress
|
||||
*/
|
||||
explicit ConsoleProgress(size_t _total, bool _stream_output = false, size_t _detalization = DEFAULT_DETALIZATION) :
|
||||
total(_total), detalization(_detalization) {
|
||||
stream_output = _stream_output;
|
||||
if (total == 0) {
|
||||
total = 1;
|
||||
}
|
||||
std::cout << std::unitbuf;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Shows progress with current data. Progress is shown from the beginning of the current line.
|
||||
* @return
|
||||
*/
|
||||
void showProgress() const {
|
||||
std::stringstream strm;
|
||||
if (!stream_output) {
|
||||
strm << '\r';
|
||||
}
|
||||
strm << "Progress: [";
|
||||
size_t i = 0;
|
||||
for (; i < detalization * current / total; i++) {
|
||||
strm << ".";
|
||||
}
|
||||
for (; i < detalization; i++) {
|
||||
strm << " ";
|
||||
}
|
||||
strm << "] " << std::fixed << std::setprecision(2) << 100 * static_cast<float>(current) / total << "% done";
|
||||
if (stream_output) {
|
||||
std::cout << strm.str() << std::endl;
|
||||
} else {
|
||||
std::cout << strm.str() << std::flush;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Updates current value and progressbar
|
||||
* @param newProgress - new value to represent
|
||||
*/
|
||||
void updateProgress(size_t newProgress) {
|
||||
current = newProgress;
|
||||
if (current > total) current = total;
|
||||
showProgress();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Adds value to currently represented and redraw progressbar
|
||||
* @param add - value to add
|
||||
*/
|
||||
void addProgress(int add) {
|
||||
if (add < 0 && -add > static_cast<int>(current)) {
|
||||
add = -static_cast<int>(current);
|
||||
}
|
||||
updateProgress(current + add);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Output end line.
|
||||
* @return
|
||||
*/
|
||||
void finish() {
|
||||
std::cerr << std::nounitbuf << "\n";
|
||||
}
|
||||
};
|
98
robot_client/src/common/base/csv_dumper.hpp
Normal file
98
robot_client/src/common/base/csv_dumper.hpp
Normal file
@ -0,0 +1,98 @@
|
||||
// Copyright (C) 2019 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <time.h>
|
||||
|
||||
#include <samples/slog.hpp>
|
||||
|
||||
/**
|
||||
* @class CsvDumper
|
||||
* @brief A CsvDumper class provides functionality for dumping the values in CSV files
|
||||
*/
|
||||
class CsvDumper {
|
||||
std::ofstream file;
|
||||
std::string filename;
|
||||
bool canDump = true;
|
||||
char delimiter = ';';
|
||||
|
||||
std::string generateFilename() {
|
||||
std::stringstream filename;
|
||||
filename << "dumpfile-";
|
||||
filename << time(nullptr);
|
||||
filename << ".csv";
|
||||
return filename.str();
|
||||
}
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief A constructor. Disables dumping in case dump file cannot be created
|
||||
* @param enabled - True if dumping is enabled by default.
|
||||
* @param name - name of file to dump to. File won't be created if first parameter is false.
|
||||
*/
|
||||
explicit CsvDumper(bool enabled = true, const std::string& name = "") : canDump(enabled) {
|
||||
if (!canDump) {
|
||||
return;
|
||||
}
|
||||
filename = (name == "" ? generateFilename() : name);
|
||||
file.open(filename, std::ios::out);
|
||||
if (!file) {
|
||||
slog::warn << "Cannot create dump file! Disabling dump." << slog::endl;
|
||||
canDump = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets a delimiter to use in csv file
|
||||
* @param c - Delimiter char
|
||||
* @return
|
||||
*/
|
||||
void setDelimiter(char c) {
|
||||
delimiter = c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Overloads operator to organize streaming values to file. Does nothing if dumping is disabled
|
||||
* Adds delimiter at the end of value provided
|
||||
* @param add - value to add to dump
|
||||
* @return reference to same object
|
||||
*/
|
||||
template<class T>
|
||||
CsvDumper& operator<<(const T& add) {
|
||||
if (canDump) {
|
||||
file << add << delimiter;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Finishes line in dump file. Does nothing if dumping is disabled
|
||||
*/
|
||||
void endLine() {
|
||||
if (canDump) {
|
||||
file << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets information if dump is enabled.
|
||||
* @return true if dump is enabled and file was successfully created
|
||||
*/
|
||||
bool dumpEnabled() {
|
||||
return canDump;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets name of a dump file
|
||||
* @return name of a dump file
|
||||
*/
|
||||
std::string getFilename() const {
|
||||
return filename;
|
||||
}
|
||||
};
|
91
robot_client/src/common/base/ocv_common.hpp
Normal file
91
robot_client/src/common/base/ocv_common.hpp
Normal file
@ -0,0 +1,91 @@
|
||||
//
|
||||
// Created by pulsarv on 19-12-8.
|
||||
//
|
||||
|
||||
|
||||
|
||||
#ifndef MOBILESEARCH_OCV_COMMON_HPP
|
||||
#define MOBILESEARCH_OCV_COMMON_HPP
|
||||
|
||||
/**
|
||||
* @brief a header file with common samples functionality using OpenCV
|
||||
* @file ocv_common.hpp
|
||||
*/
|
||||
|
||||
|
||||
#include <base/common.hpp>
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
/**
|
||||
* @brief Sets image data stored in cv::Mat object to a given Blob object.
|
||||
* @param orig_image - given cv::Mat object with an image data.
|
||||
* @param blob - Blob object which to be filled by an image data.
|
||||
* @param batchIndex - batch index of an image inside of the blob.
|
||||
*/
|
||||
template<typename T>
|
||||
void matU8ToBlob(const cv::Mat &orig_image, InferenceEngine::Blob::Ptr &blob, int batchIndex = 0) {
|
||||
InferenceEngine::SizeVector blobSize = blob->getTensorDesc().getDims();
|
||||
const size_t width = blobSize[3];
|
||||
const size_t height = blobSize[2];
|
||||
const size_t channels = blobSize[1];
|
||||
T *blob_data = blob->buffer().as<T *>();
|
||||
|
||||
cv::Mat resized_image(orig_image);
|
||||
if (static_cast<int>(width) != orig_image.size().width ||
|
||||
static_cast<int>(height) != orig_image.size().height) {
|
||||
cv::resize(orig_image, resized_image, cv::Size(width, height));
|
||||
}
|
||||
|
||||
int batchOffset = batchIndex * width * height * channels;
|
||||
|
||||
if (channels == 1) {
|
||||
for (size_t h = 0; h < height; h++) {
|
||||
for (size_t w = 0; w < width; w++) {
|
||||
blob_data[batchOffset + h * width + w] = resized_image.at<uchar>(h, w);
|
||||
}
|
||||
}
|
||||
} else if (channels == 3) {
|
||||
for (size_t c = 0; c < channels; c++) {
|
||||
for (size_t h = 0; h < height; h++) {
|
||||
for (size_t w = 0; w < width; w++) {
|
||||
blob_data[batchOffset + c * width * height + h * width + w] =
|
||||
resized_image.at<cv::Vec3b>(h, w)[c];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
THROW_IE_EXCEPTION << "Unsupported number of channels";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Wraps data stored inside of a passed cv::Mat object by new Blob pointer.
|
||||
* @note: No memory allocation is happened. The blob just points to already existing
|
||||
* cv::Mat data.
|
||||
* @param mat - given cv::Mat object with an image data.
|
||||
* @return resulting Blob pointer.
|
||||
*/
|
||||
static UNUSED InferenceEngine::Blob::Ptr wrapMat2Blob(const cv::Mat &mat) {
|
||||
size_t channels = mat.channels();
|
||||
size_t height = mat.size().height;
|
||||
size_t width = mat.size().width;
|
||||
|
||||
size_t strideH = mat.step.buf[0];
|
||||
size_t strideW = mat.step.buf[1];
|
||||
|
||||
bool is_dense =
|
||||
strideW == channels &&
|
||||
strideH == channels * width;
|
||||
|
||||
if (!is_dense)
|
||||
THROW_IE_EXCEPTION
|
||||
<< "Doesn't support conversion from not dense cv::Mat";
|
||||
|
||||
InferenceEngine::TensorDesc tDesc(InferenceEngine::Precision::U8,
|
||||
{1, channels, height, width},
|
||||
InferenceEngine::Layout::NHWC);
|
||||
|
||||
return InferenceEngine::make_shared_blob<uint8_t>(tDesc, mat.data);
|
||||
}
|
||||
|
||||
#endif
|
91
robot_client/src/common/base/slog.hpp
Normal file
91
robot_client/src/common/base/slog.hpp
Normal file
@ -0,0 +1,91 @@
|
||||
|
||||
|
||||
/**
|
||||
* @brief a header file with logging facility for common samples
|
||||
* @file log.hpp
|
||||
*/
|
||||
|
||||
#ifndef SLOG_HPP
|
||||
#define SLOG_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace slog {
|
||||
|
||||
/**
|
||||
* @class LogStreamEndLine
|
||||
* @brief The LogStreamEndLine class implements an end line marker for a log stream
|
||||
*/
|
||||
class LogStreamEndLine {
|
||||
};
|
||||
|
||||
static constexpr LogStreamEndLine endl;
|
||||
|
||||
|
||||
/**
|
||||
* @class LogStreamBoolAlpha
|
||||
* @brief The LogStreamBoolAlpha class implements bool printing for a log stream
|
||||
*/
|
||||
class LogStreamBoolAlpha {
|
||||
};
|
||||
|
||||
static constexpr LogStreamBoolAlpha boolalpha;
|
||||
|
||||
|
||||
/**
|
||||
* @class LogStream
|
||||
* @brief The LogStream class implements a stream for sample logging
|
||||
*/
|
||||
class LogStream {
|
||||
std::string _prefix;
|
||||
std::ostream *_log_stream;
|
||||
bool _new_line;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief A constructor. Creates an LogStream object
|
||||
* @param prefix The prefix to print
|
||||
*/
|
||||
LogStream(const std::string &prefix, std::ostream &log_stream)
|
||||
: _prefix(prefix), _new_line(true) {
|
||||
_log_stream = &log_stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A stream output operator to be used within the logger
|
||||
* @param arg Object for serialization in the logger message
|
||||
*/
|
||||
template<class T>
|
||||
LogStream &operator<<(const T &arg) {
|
||||
if (_new_line) {
|
||||
(*_log_stream) << "[ " << _prefix << " ] ";
|
||||
_new_line = false;
|
||||
}
|
||||
|
||||
(*_log_stream) << arg;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Specializing for LogStreamEndLine to support slog::endl
|
||||
LogStream &operator<<(const LogStreamEndLine &/*arg*/) {
|
||||
_new_line = true;
|
||||
|
||||
(*_log_stream) << std::endl;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Specializing for LogStreamBoolAlpha to support slog::boolalpha
|
||||
LogStream &operator<<(const LogStreamBoolAlpha &/*arg*/) {
|
||||
(*_log_stream) << std::boolalpha;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static LogStream info("\033[1;32;34mINFO\033[0m", std::cout);
|
||||
static LogStream success("\033[1;32;32mSUCCESS\033[0m", std::cout);
|
||||
static LogStream warn("\033[1;32;33mWARNING\033[0m", std::cout);
|
||||
static LogStream err("\033[1;32;31mERROR\033[0m", std::cout);
|
||||
|
||||
} // namespace slog
|
||||
#endif
|
45
robot_client/src/common/format_reader/CMakeLists.txt
Normal file
45
robot_client/src/common/format_reader/CMakeLists.txt
Normal file
@ -0,0 +1,45 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
set (TARGET_NAME "format_reader")
|
||||
|
||||
file (GLOB MAIN_SRC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
|
||||
)
|
||||
|
||||
file (GLOB LIBRARY_HEADERS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/*.h
|
||||
)
|
||||
|
||||
# Find OpenCV components if exist
|
||||
find_package(OpenCV COMPONENTS imgcodecs videoio imgproc QUIET)
|
||||
if(NOT(OpenCV_FOUND))
|
||||
message(WARNING "OPENCV is disabled or not found, " ${TARGET_NAME} " is built without OPENCV support")
|
||||
endif()
|
||||
|
||||
# Create named folders for the sources within the .vcproj
|
||||
# Empty name lists them directly under the .vcproj
|
||||
source_group("src" FILES ${LIBRARY_SRC})
|
||||
source_group("include" FILES ${LIBRARY_HEADERS})
|
||||
|
||||
|
||||
# Create library file from sources.
|
||||
add_library(${TARGET_NAME} SHARED ${MAIN_SRC} ${LIBRARY_HEADERS})
|
||||
|
||||
if(OpenCV_FOUND)
|
||||
target_link_libraries(${TARGET_NAME} PRIVATE ${OpenCV_LIBRARIES})
|
||||
target_compile_definitions(${TARGET_NAME} PRIVATE USE_OPENCV)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(${TARGET_NAME} PRIVATE IMPLEMENT_FORMAT_READER)
|
||||
|
||||
target_include_directories(${TARGET_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
|
||||
set_target_properties(${TARGET_NAME} PROPERTIES COMPILE_PDB_NAME ${TARGET_NAME})
|
||||
|
||||
# developer package
|
||||
|
||||
export(TARGETS ${TARGET_NAME} NAMESPACE IE::
|
||||
APPEND FILE "${CMAKE_BINARY_DIR}/targets_developer.cmake")
|
63
robot_client/src/common/format_reader/MnistUbyte.cpp
Normal file
63
robot_client/src/common/format_reader/MnistUbyte.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
// Copyright (C) 2018-2019 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <MnistUbyte.h>
|
||||
|
||||
using namespace FormatReader;
|
||||
|
||||
int MnistUbyte::reverseInt(int i) {
|
||||
unsigned char ch1, ch2, ch3, ch4;
|
||||
ch1 = (unsigned char) (i & 255);
|
||||
ch2 = (unsigned char) ((i >> 8) & 255);
|
||||
ch3 = (unsigned char) ((i >> 16) & 255);
|
||||
ch4 = (unsigned char) ((i >> 24) & 255);
|
||||
return (static_cast<int>(ch1) << 24) + (static_cast<int>(ch2) << 16) + (static_cast<int>(ch3) << 8) + ch4;
|
||||
}
|
||||
|
||||
MnistUbyte::MnistUbyte(const std::string &filename) {
|
||||
std::ifstream file(filename, std::ios::binary);
|
||||
if (!file.is_open()) {
|
||||
return;
|
||||
}
|
||||
int magic_number = 0;
|
||||
int number_of_images = 0;
|
||||
int n_rows = 0;
|
||||
int n_cols = 0;
|
||||
file.read(reinterpret_cast<char *>(&magic_number), sizeof(magic_number));
|
||||
magic_number = reverseInt(magic_number);
|
||||
if (magic_number != 2051) {
|
||||
return;
|
||||
}
|
||||
file.read(reinterpret_cast<char *>(&number_of_images), sizeof(number_of_images));
|
||||
number_of_images = reverseInt(number_of_images);
|
||||
file.read(reinterpret_cast<char *>(&n_rows), sizeof(n_rows));
|
||||
n_rows = reverseInt(n_rows);
|
||||
_height = (size_t) n_rows;
|
||||
file.read(reinterpret_cast<char *>(&n_cols), sizeof(n_cols));
|
||||
n_cols = reverseInt(n_cols);
|
||||
_width = (size_t) n_cols;
|
||||
if (number_of_images > 1) {
|
||||
std::cout << "[MNIST] Warning: number_of_images in mnist file equals " << number_of_images
|
||||
<< ". Only a first image will be read." << std::endl;
|
||||
}
|
||||
|
||||
size_t size = _width * _height * 1;
|
||||
|
||||
_data.reset(new unsigned char[size], std::default_delete<unsigned char[]>());
|
||||
size_t count = 0;
|
||||
if (0 < number_of_images) {
|
||||
for (int r = 0; r < n_rows; ++r) {
|
||||
for (int c = 0; c < n_cols; ++c) {
|
||||
unsigned char temp = 0;
|
||||
file.read(reinterpret_cast<char *>(&temp), sizeof(temp));
|
||||
_data.get()[count++] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
file.close();
|
||||
}
|
58
robot_client/src/common/format_reader/MnistUbyte.h
Normal file
58
robot_client/src/common/format_reader/MnistUbyte.h
Normal file
@ -0,0 +1,58 @@
|
||||
// Copyright (C) 2018-2019 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
/**
|
||||
* \brief Mnist reader
|
||||
* \file MnistUbyte.h
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <format_reader.h>
|
||||
|
||||
#include "register.h"
|
||||
|
||||
namespace FormatReader {
|
||||
/**
|
||||
* \class MnistUbyte
|
||||
* \brief Reader for mnist db files
|
||||
*/
|
||||
class MnistUbyte : public Reader {
|
||||
private:
|
||||
int reverseInt(int i);
|
||||
|
||||
static Register<MnistUbyte> reg;
|
||||
|
||||
public:
|
||||
/**
|
||||
* \brief Constructor of Mnist reader
|
||||
* @param filename - path to input data
|
||||
* @return MnistUbyte reader object
|
||||
*/
|
||||
explicit MnistUbyte(const std::string &filename);
|
||||
virtual ~MnistUbyte() {
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get size
|
||||
* @return size
|
||||
*/
|
||||
size_t size() const override {
|
||||
return _width * _height * 1;
|
||||
}
|
||||
|
||||
void Release() noexcept override {
|
||||
delete this;
|
||||
}
|
||||
|
||||
std::shared_ptr<unsigned char> getData(size_t width, size_t height) override {
|
||||
if ((width * height != 0) && (_width * _height != width * height)) {
|
||||
std::cout << "[ WARNING ] Image won't be resized! Please use OpenCV.\n";
|
||||
return nullptr;
|
||||
}
|
||||
return _data;
|
||||
}
|
||||
};
|
||||
} // namespace FormatReader
|
63
robot_client/src/common/format_reader/bmp.cpp
Normal file
63
robot_client/src/common/format_reader/bmp.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
// Copyright (C) 2018-2019 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "bmp.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace FormatReader;
|
||||
|
||||
|
||||
BitMap::BitMap(const string &filename) {
|
||||
BmpHeader header;
|
||||
BmpInfoHeader infoHeader;
|
||||
|
||||
ifstream input(filename, ios::binary);
|
||||
if (!input) {
|
||||
return;
|
||||
}
|
||||
|
||||
input.read(reinterpret_cast<char *>(&header.type), 2);
|
||||
|
||||
if (header.type != 'M'*256+'B') {
|
||||
std::cerr << "[BMP] file is not bmp type\n";
|
||||
return;
|
||||
}
|
||||
|
||||
input.read(reinterpret_cast<char *>(&header.size), 4);
|
||||
input.read(reinterpret_cast<char *>(&header.reserved), 4);
|
||||
input.read(reinterpret_cast<char *>(&header.offset), 4);
|
||||
|
||||
input.read(reinterpret_cast<char *>(&infoHeader), sizeof(BmpInfoHeader));
|
||||
|
||||
|
||||
bool rowsReversed = infoHeader.height < 0;
|
||||
_width = infoHeader.width;
|
||||
_height = abs(infoHeader.height);
|
||||
|
||||
if (infoHeader.bits != 24) {
|
||||
cerr << "[BMP] 24bpp only supported. But input has:" << infoHeader.bits << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
if (infoHeader.compression != 0) {
|
||||
cerr << "[BMP] compression not supported\n";
|
||||
}
|
||||
|
||||
int padSize = _width & 3;
|
||||
char pad[3];
|
||||
size_t size = _width * _height * 3;
|
||||
|
||||
_data.reset(new unsigned char[size], std::default_delete<unsigned char[]>());
|
||||
|
||||
input.seekg(header.offset, ios::beg);
|
||||
|
||||
// reading by rows in invert vertically
|
||||
for (uint32_t i = 0; i < _height; i++) {
|
||||
uint32_t storeAt = rowsReversed ? i : (uint32_t)_height - 1 - i;
|
||||
input.read(reinterpret_cast<char *>(_data.get()) + _width * 3 * storeAt, _width * 3);
|
||||
input.read(pad, padSize);
|
||||
}
|
||||
}
|
75
robot_client/src/common/format_reader/bmp.h
Normal file
75
robot_client/src/common/format_reader/bmp.h
Normal file
@ -0,0 +1,75 @@
|
||||
// Copyright (C) 2018-2019 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
/**
|
||||
* \brief BMP reader
|
||||
* \file bmp.h
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <format_reader.h>
|
||||
|
||||
#include "register.h"
|
||||
|
||||
namespace FormatReader {
|
||||
/**
|
||||
* \class BitMap
|
||||
* \brief Reader for bmp files
|
||||
*/
|
||||
class BitMap : public Reader {
|
||||
private:
|
||||
static Register<BitMap> reg;
|
||||
|
||||
typedef struct {
|
||||
unsigned short type = 0u; /* Magic identifier */
|
||||
unsigned int size = 0u; /* File size in bytes */
|
||||
unsigned int reserved = 0u;
|
||||
unsigned int offset = 0u; /* Offset to image data, bytes */
|
||||
} BmpHeader;
|
||||
|
||||
typedef struct {
|
||||
unsigned int size = 0u; /* Header size in bytes */
|
||||
int width = 0, height = 0; /* Width and height of image */
|
||||
unsigned short planes = 0u; /* Number of colour planes */
|
||||
unsigned short bits = 0u; /* Bits per pixel */
|
||||
unsigned int compression = 0u; /* Compression type */
|
||||
unsigned int imagesize = 0u; /* Image size in bytes */
|
||||
int xresolution = 0, yresolution = 0; /* Pixels per meter */
|
||||
unsigned int ncolours = 0u; /* Number of colours */
|
||||
unsigned int importantcolours = 0u; /* Important colours */
|
||||
} BmpInfoHeader;
|
||||
|
||||
public:
|
||||
/**
|
||||
* \brief Constructor of BMP reader
|
||||
* @param filename - path to input data
|
||||
* @return BitMap reader object
|
||||
*/
|
||||
explicit BitMap(const std::string &filename);
|
||||
virtual ~BitMap() {
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get size
|
||||
* @return size
|
||||
*/
|
||||
size_t size() const override {
|
||||
return _width * _height * 3;
|
||||
}
|
||||
|
||||
void Release() noexcept override {
|
||||
delete this;
|
||||
}
|
||||
|
||||
std::shared_ptr<unsigned char> getData(size_t width, size_t height) override {
|
||||
if ((width * height != 0) && (_width * _height != width * height)) {
|
||||
std::cout << "[ WARNING ] Image won't be resized! Please use OpenCV.\n";
|
||||
return nullptr;
|
||||
}
|
||||
return _data;
|
||||
}
|
||||
};
|
||||
} // namespace FormatReader
|
37
robot_client/src/common/format_reader/format_reader.cpp
Normal file
37
robot_client/src/common/format_reader/format_reader.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2018-2019 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include <format_reader.h>
|
||||
#include "bmp.h"
|
||||
#include "MnistUbyte.h"
|
||||
#include "opencv_wraper.h"
|
||||
|
||||
using namespace FormatReader;
|
||||
|
||||
std::vector<Registry::CreatorFunction> Registry::_data;
|
||||
|
||||
Register<MnistUbyte> MnistUbyte::reg;
|
||||
#ifdef USE_OPENCV
|
||||
Register<OCVReader> OCVReader::reg;
|
||||
#else
|
||||
Register<BitMap> BitMap::reg;
|
||||
#endif
|
||||
|
||||
Reader *Registry::CreateReader(const char *filename) {
|
||||
for (auto maker : _data) {
|
||||
Reader *ol = maker(filename);
|
||||
if (ol != nullptr && ol->size() != 0) return ol;
|
||||
if (ol != nullptr) ol->Release();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Registry::RegisterReader(CreatorFunction f) {
|
||||
_data.push_back(f);
|
||||
}
|
||||
|
||||
FORMAT_READER_API(Reader*) CreateFormatReader(const char *filename) {
|
||||
return Registry::CreateReader(filename);
|
||||
}
|
81
robot_client/src/common/format_reader/format_reader.h
Normal file
81
robot_client/src/common/format_reader/format_reader.h
Normal file
@ -0,0 +1,81 @@
|
||||
// Copyright (C) 2018-2019 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
/**
|
||||
* \brief Format reader abstract class implementation
|
||||
* \file format_reader.h
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
#if defined(_WIN32)
|
||||
# ifdef IMPLEMENT_FORMAT_READER
|
||||
# define FORMAT_READER_API(type) extern "C" __declspec(dllexport) type
|
||||
# else
|
||||
# define FORMAT_READER_API(type) extern "C" type
|
||||
# endif
|
||||
#elif(__GNUC__ >= 4)
|
||||
# ifdef IMPLEMENT_FORMAT_READER
|
||||
# define FORMAT_READER_API(type) extern "C" __attribute__((visibility("default"))) type
|
||||
# else
|
||||
# define FORMAT_READER_API(type) extern "C" type
|
||||
# endif
|
||||
#else
|
||||
# define FORMAT_READER_API(TYPE) extern "C" TYPE
|
||||
#endif
|
||||
|
||||
|
||||
namespace FormatReader {
|
||||
/**
|
||||
* \class FormatReader
|
||||
* \brief This is an abstract class for reading input data
|
||||
*/
|
||||
class Reader {
|
||||
protected:
|
||||
/// \brief height
|
||||
size_t _height = 0;
|
||||
/// \brief width
|
||||
size_t _width = 0;
|
||||
/// \brief data
|
||||
std::shared_ptr<unsigned char> _data;
|
||||
|
||||
public:
|
||||
/**
|
||||
* \brief Get width
|
||||
* @return width
|
||||
*/
|
||||
size_t width() const { return _width; }
|
||||
|
||||
/**
|
||||
* \brief Get height
|
||||
* @return height
|
||||
*/
|
||||
size_t height() const { return _height; }
|
||||
|
||||
/**
|
||||
* \brief Get input data ptr
|
||||
* @return shared pointer with input data
|
||||
* @In case of using OpenCV, parameters width and height will be used for image resizing
|
||||
*/
|
||||
virtual std::shared_ptr<unsigned char> getData(size_t width = 0, size_t height = 0) = 0;
|
||||
|
||||
/**
|
||||
* \brief Get size
|
||||
* @return size
|
||||
*/
|
||||
virtual size_t size() const = 0;
|
||||
|
||||
virtual void Release() noexcept = 0;
|
||||
};
|
||||
} // namespace FormatReader
|
||||
|
||||
/**
|
||||
* \brief Function for create reader
|
||||
* @return FormatReader pointer
|
||||
*/
|
||||
FORMAT_READER_API(FormatReader::Reader*) CreateFormatReader(const char *filename);
|
45
robot_client/src/common/format_reader/format_reader_ptr.h
Normal file
45
robot_client/src/common/format_reader/format_reader_ptr.h
Normal file
@ -0,0 +1,45 @@
|
||||
// Copyright (C) 2018-2019 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
/**
|
||||
* \brief Implementation of smart pointer for Reader class
|
||||
* \file format_reader_ptr.h
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "format_reader.h"
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
namespace FormatReader {
|
||||
class ReaderPtr {
|
||||
public:
|
||||
explicit ReaderPtr(const char *imageName) : reader(CreateFormatReader(imageName),
|
||||
[](Reader *p) {
|
||||
p->Release();
|
||||
}) {}
|
||||
/**
|
||||
* @brief dereference operator overload
|
||||
* @return Reader
|
||||
*/
|
||||
Reader *operator->() const noexcept {
|
||||
return reader.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief dereference operator overload
|
||||
* @return Reader
|
||||
*/
|
||||
Reader *operator*() const noexcept {
|
||||
return reader.get();
|
||||
}
|
||||
|
||||
Reader *get() {
|
||||
return reader.get();
|
||||
}
|
||||
|
||||
protected:
|
||||
std::unique_ptr<Reader, std::function<void(Reader *)>> reader;
|
||||
};
|
||||
} // namespace FormatReader
|
48
robot_client/src/common/format_reader/opencv_wraper.cpp
Normal file
48
robot_client/src/common/format_reader/opencv_wraper.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
// Copyright (C) 2018-2019 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#ifdef USE_OPENCV
|
||||
#include "opencv_wraper.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
#include <base/slog.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace FormatReader;
|
||||
|
||||
OCVReader::OCVReader(const string &filename) {
|
||||
img = cv::imread(filename);
|
||||
_size = 0;
|
||||
|
||||
if (img.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
_size = img.size().width * img.size().height * img.channels();
|
||||
_width = img.size().width;
|
||||
_height = img.size().height;
|
||||
}
|
||||
|
||||
std::shared_ptr<unsigned char> OCVReader::getData(size_t width = 0, size_t height = 0) {
|
||||
cv::Mat resized(img);
|
||||
if (width != 0 && height != 0) {
|
||||
size_t iw = img.size().width;
|
||||
size_t ih = img.size().height;
|
||||
if (width != iw || height != ih) {
|
||||
slog::warn << "Image is resized from (" << iw << ", " << ih << ") to (" << width << ", " << height << ")" << slog::endl;
|
||||
}
|
||||
cv::resize(img, resized, cv::Size(width, height));
|
||||
}
|
||||
|
||||
size_t size = resized.size().width * resized.size().height * resized.channels();
|
||||
_data.reset(new unsigned char[size], std::default_delete<unsigned char[]>());
|
||||
for (size_t id = 0; id < size; ++id) {
|
||||
_data.get()[id] = resized.data[id];
|
||||
}
|
||||
return _data;
|
||||
}
|
||||
#endif
|
56
robot_client/src/common/format_reader/opencv_wraper.h
Normal file
56
robot_client/src/common/format_reader/opencv_wraper.h
Normal file
@ -0,0 +1,56 @@
|
||||
// Copyright (C) 2018-2019 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
/**
|
||||
* \brief Image reader
|
||||
* \file opencv_wraper.h
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifdef USE_OPENCV
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <format_reader.h>
|
||||
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
#include "register.h"
|
||||
|
||||
namespace FormatReader {
|
||||
/**
|
||||
* \class OCVMAT
|
||||
* \brief OpenCV Wraper
|
||||
*/
|
||||
class OCVReader : public Reader {
|
||||
private:
|
||||
cv::Mat img;
|
||||
size_t _size;
|
||||
static Register<OCVReader> reg;
|
||||
|
||||
public:
|
||||
/**
|
||||
* \brief Constructor of BMP reader
|
||||
* @param filename - path to input data
|
||||
* @return BitMap reader object
|
||||
*/
|
||||
explicit OCVReader(const std::string &filename);
|
||||
virtual ~OCVReader() {
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get size
|
||||
* @return size
|
||||
*/
|
||||
size_t size() const override {
|
||||
return _size;
|
||||
}
|
||||
|
||||
void Release() noexcept override {
|
||||
delete this;
|
||||
}
|
||||
|
||||
std::shared_ptr<unsigned char> getData(size_t width, size_t height) override;
|
||||
};
|
||||
} // namespace FormatReader
|
||||
#endif
|
56
robot_client/src/common/format_reader/register.h
Normal file
56
robot_client/src/common/format_reader/register.h
Normal file
@ -0,0 +1,56 @@
|
||||
// Copyright (C) 2018-2019 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
/**
|
||||
* \brief Register for readers
|
||||
* \file register.h
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <format_reader.h>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace FormatReader {
|
||||
/**
|
||||
* \class Registry
|
||||
* \brief Create reader from fabric
|
||||
*/
|
||||
class Registry {
|
||||
private:
|
||||
typedef std::function<Reader *(const std::string &filename)> CreatorFunction;
|
||||
static std::vector<CreatorFunction> _data;
|
||||
public:
|
||||
/**
|
||||
* \brief Create reader
|
||||
* @param filename - path to input data
|
||||
* @return Reader for input data or nullptr
|
||||
*/
|
||||
static Reader *CreateReader(const char *filename);
|
||||
|
||||
/**
|
||||
* \brief Registers reader in fabric
|
||||
* @param f - a creation function
|
||||
*/
|
||||
static void RegisterReader(CreatorFunction f);
|
||||
};
|
||||
|
||||
/**
|
||||
* \class Register
|
||||
* \brief Registers reader in fabric
|
||||
*/
|
||||
template<typename To>
|
||||
class Register {
|
||||
public:
|
||||
/**
|
||||
* \brief Constructor creates creation function for fabric
|
||||
* @return Register object
|
||||
*/
|
||||
Register() {
|
||||
Registry::RegisterReader([](const std::string &filename) -> Reader * {
|
||||
return new To(filename);
|
||||
});
|
||||
}
|
||||
};
|
||||
} // namespace FormatReader
|
114
robot_client/src/common/os/windows/w_dirent.h
Normal file
114
robot_client/src/common/os/windows/w_dirent.h
Normal file
@ -0,0 +1,114 @@
|
||||
// Copyright (C) 2018-2019 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
#ifndef NOMINMAX
|
||||
# define NOMINMAX
|
||||
#endif
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#else
|
||||
|
||||
#include <unistd.h>
|
||||
#include <cstdlib>
|
||||
#include <string.h>
|
||||
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if defined(WIN32)
|
||||
// Copied from linux libc sys/stat.h:
|
||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
struct dirent {
|
||||
char *d_name;
|
||||
|
||||
explicit dirent(const wchar_t *wsFilePath) {
|
||||
size_t i;
|
||||
auto slen = wcslen(wsFilePath);
|
||||
d_name = static_cast<char*>(malloc(slen + 1));
|
||||
wcstombs_s(&i, d_name, slen + 1, wsFilePath, slen);
|
||||
}
|
||||
|
||||
~dirent() {
|
||||
free(d_name);
|
||||
}
|
||||
};
|
||||
|
||||
class DIR {
|
||||
WIN32_FIND_DATAA FindFileData;
|
||||
HANDLE hFind;
|
||||
dirent *next;
|
||||
|
||||
static inline bool endsWith(const std::string &src, const char *with) {
|
||||
int wl = static_cast<int>(strlen(with));
|
||||
int so = static_cast<int>(src.length()) - wl;
|
||||
if (so < 0) return false;
|
||||
return 0 == strncmp(with, &src[so], wl);
|
||||
}
|
||||
|
||||
public:
|
||||
explicit DIR(const char *dirPath) : next(nullptr) {
|
||||
std::string ws = dirPath;
|
||||
if (endsWith(ws, "\\"))
|
||||
ws += "*";
|
||||
else
|
||||
ws += "\\*";
|
||||
hFind = FindFirstFileA(ws.c_str(), &FindFileData);
|
||||
FindFileData.dwReserved0 = hFind != INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
~DIR() {
|
||||
if (!next) delete next;
|
||||
FindClose(hFind);
|
||||
}
|
||||
|
||||
bool isValid() const {
|
||||
return (hFind != INVALID_HANDLE_VALUE && FindFileData.dwReserved0);
|
||||
}
|
||||
|
||||
dirent* nextEnt() {
|
||||
if (next != nullptr) delete next;
|
||||
next = nullptr;
|
||||
|
||||
if (!FindFileData.dwReserved0) return nullptr;
|
||||
|
||||
wchar_t wbuf[4096];
|
||||
|
||||
size_t outSize;
|
||||
mbstowcs_s(&outSize, wbuf, 4094, FindFileData.cFileName, 4094);
|
||||
next = new dirent(wbuf);
|
||||
FindFileData.dwReserved0 = FindNextFileA(hFind, &FindFileData);
|
||||
return next;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static DIR *opendir(const char* dirPath) {
|
||||
auto dp = new DIR(dirPath);
|
||||
if (!dp->isValid()) {
|
||||
delete dp;
|
||||
return nullptr;
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
|
||||
static struct dirent *readdir(DIR *dp) {
|
||||
return dp->nextEnt();
|
||||
}
|
||||
|
||||
static void closedir(DIR *dp) {
|
||||
delete dp;
|
||||
}
|
11
robot_client/src/common/vpu/vpu_tools_common.hpp
Normal file
11
robot_client/src/common/vpu/vpu_tools_common.hpp
Normal file
@ -0,0 +1,11 @@
|
||||
// Copyright (C) 2019 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <ios>
|
||||
|
||||
|
33
robot_client/src/include/rc_cv/rcCV.h
Normal file
33
robot_client/src/include/rc_cv/rcCV.h
Normal file
@ -0,0 +1,33 @@
|
||||
//
|
||||
// Created by PulsarV on 18-5-9.
|
||||
//
|
||||
|
||||
#ifndef ROBOCAR_RCCV_CPP_H
|
||||
#define ROBOCAR_RCCV_CPP_H
|
||||
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <rc_globalVarable/rc_global.h>
|
||||
namespace RC {
|
||||
typedef struct rc_line{
|
||||
int theta;
|
||||
int r;
|
||||
}rc_line;
|
||||
typedef std::vector<cv::Vec4i> lines;
|
||||
namespace CV{
|
||||
void fillter_8UC1(int max, cv::Mat *gray);
|
||||
|
||||
std::vector<cv::Rect> detcetFace(cv::Mat src);
|
||||
void detectLine(cv::Mat src,cv::Mat *dst);
|
||||
std::vector<RC::rc_line> detectLine(cv::Mat &img, int threshold);
|
||||
void drawDetectLines(cv::Mat& image,const std::vector<cv::Vec4i>& lines,cv::Scalar & color);
|
||||
void detcetByRightAndLeft(cv::Mat &src,int *ans);
|
||||
class BodyDetceter{
|
||||
public:
|
||||
int init_body_cascade(std::string file_path);
|
||||
std::vector<cv::Rect> detcetBody(cv::Mat src);
|
||||
private:
|
||||
cv::CascadeClassifier body_cascade;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif //ROBOCAR_RCCV_CPP_H
|
32
robot_client/src/include/rc_globalVarable/rc_global.h
Normal file
32
robot_client/src/include/rc_globalVarable/rc_global.h
Normal file
@ -0,0 +1,32 @@
|
||||
//
|
||||
// Created by PulsarV on 18-5-10.
|
||||
//
|
||||
|
||||
#define RADIAN CV_PI/180.0
|
||||
#define LOADING_IMAGE "background.jpg"
|
||||
|
||||
#ifndef ROBOCAR_RC_GLOBAL_H
|
||||
#define ROBOCAR_RC_GLOBAL_H
|
||||
|
||||
#define TEST 0
|
||||
enum {
|
||||
RC_CAMERA_DEVICE=0,//USB摄像头
|
||||
RC_VIDEO_FILE, //文件
|
||||
RC_WEBCAM //网络摄像头
|
||||
};
|
||||
enum {
|
||||
RC_PLAY_BY_CAMERA=0,
|
||||
RC_PLAY_BY_VIDEO
|
||||
};
|
||||
|
||||
//#define RC_BODY_CASCADES_FILE_PATH "./haarcascades/haarcascade_fullbody.xml"
|
||||
#define RC_BODY_CASCADES_FILE_PATH "/opt/openvino/openvino_2020.2.120/opencv/etc/haarcascades/haarcascade_frontalcatface.xml"
|
||||
#define RC_FACE_CASCADES_FILE_PATH "./haarcascades/haarcascade_frontalcatface.xml"
|
||||
|
||||
#define RUN_STATE std::cout<<"\033[1;32;31m ON: "<<__FILE__\
|
||||
<<" "<<__FUNCTION__<<"()"<<" "<<__LINE__<<"\033[0m"<<std::endl;
|
||||
|
||||
#ifdef __linux__
|
||||
#define RC_NULL_POINT nullptr
|
||||
#endif
|
||||
#endif //ROBOCAR_RC_GLOBAL_H
|
@ -0,0 +1,9 @@
|
||||
//
|
||||
// Created by PulsarV on 18-5-14.
|
||||
//
|
||||
|
||||
#ifndef ROBOCAR_RC_GLOBAL_MOVE_H
|
||||
#define ROBOCAR_RC_GLOBAL_MOVE_H
|
||||
#include "rc_global.h"
|
||||
#define RC_MOVE_MAX_RECIVE_BUFFER 64
|
||||
#endif //ROBOCAR_RC_GLOBAL_MOVE_H
|
63
robot_client/src/include/rc_globalVarable/rc_global_serial.h
Normal file
63
robot_client/src/include/rc_globalVarable/rc_global_serial.h
Normal file
@ -0,0 +1,63 @@
|
||||
//
|
||||
// Created by PulsarV on 18-5-10.
|
||||
//
|
||||
|
||||
#ifndef ROBOCAR_RC_GLOBAL_SERIAL_H
|
||||
#define ROBOCAR_RC_GLOBAL_SERIAL_H
|
||||
|
||||
#include "rc_global.h"
|
||||
#include "rc_global_wheel.h"
|
||||
//Usb COM recive buffer size
|
||||
#define RC_SERIAL_MAX_SEND_BUFFER_SIZE 64
|
||||
//encode search size
|
||||
#define RC_SERIAL_SEARCH_SIZE 2
|
||||
#define RC_SERIAL_SUB_BIT {'\r','\n'}
|
||||
//USB serial open state output
|
||||
#define RC_SERIAL_STRING_USB_OPEN_ERROR (char*)"Cant Open Serial Device"
|
||||
#define RC_SERIAL_ERROR -1
|
||||
#define RC_SERIAL_MAX_RECIVE_BUFFER_SIZE 64
|
||||
//JY901 COMMMOND
|
||||
#define GYRO_COMMOND_ERROE "Commond Error or no commond default to set to once"
|
||||
#define GYRO_0D1HZ 1
|
||||
#define GYRO_0D5HZ 2
|
||||
#define GYRO_1HZ 3
|
||||
#define GYRO_2HZ 4
|
||||
#define GYRO_5HZ 5
|
||||
#define GYRO_10HZ 6
|
||||
#define GYRO_20HZ 7
|
||||
#define GYRO_50HZ 8
|
||||
#define GYRO_100HZ 9
|
||||
#define GYRO_200HZ 10
|
||||
#define GYRO_ONCE 11
|
||||
#define GYRO_CLOSE 12
|
||||
|
||||
#define GYRO_SERIAL_BACK_SPEED_0D1HZ 0xffaa030100
|
||||
#define GYRO_SERIAL_BACK_SPEED_0D5HZ 0xffaa030200
|
||||
#define GYRO_SERIAL_BACK_SPEED_1HZ 0xffaa030300
|
||||
#define GYRO_SERIAL_BACK_SPEED_2HZ 0xffaa030400
|
||||
#define GYRO_SERIAL_BACK_SPEED_5HZ 0xffaa030500
|
||||
#define GYRO_SERIAL_BACK_SPEED_10HZ 0xffaa030600
|
||||
#define GYRO_SERIAL_BACK_SPEED_20HZ 0xffaa030700
|
||||
#define GYRO_SERIAL_BACK_SPEED_50HZ 0xffaa030800
|
||||
#define GYRO_SERIAL_BACK_SPEED_100HZ 0xffaa030900
|
||||
#define GYRO_SERIAL_BACK_SPEED_ONCE 0xffaa030a00
|
||||
#define GYRO_SERIAL_BACK_SPEED_200HZ 0xffaa030b00
|
||||
#define GYRO_SERIAL_BACK_SPEED_CLOSE 0xffaa030c00
|
||||
|
||||
#endif //ROBOCAR_RC_GLOBAL_SERIAL_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
11
robot_client/src/include/rc_globalVarable/rc_global_task.h
Normal file
11
robot_client/src/include/rc_globalVarable/rc_global_task.h
Normal file
@ -0,0 +1,11 @@
|
||||
//
|
||||
// Created by PulsarV on 18-5-14.
|
||||
//
|
||||
|
||||
#ifndef ROBOCAR_RC_GLOBAL_TASK_H_H
|
||||
#define ROBOCAR_RC_GLOBAL_TASK_H_H
|
||||
#define RC_MAX_WEBSTREAM_QUEUE 20
|
||||
#define RC_MAX_GUI_QUEUE 20
|
||||
#define RC_MAX_CAMERA_IMAGE_QUEUE 20
|
||||
#define RC_VIDEOQUEUE_STRING_INITATION (char*)"Init Videi Stream Pool"
|
||||
#endif //ROBOCAR_RC_GLOBAL_TASK_H_H
|
30
robot_client/src/include/rc_globalVarable/rc_global_wheel.h
Normal file
30
robot_client/src/include/rc_globalVarable/rc_global_wheel.h
Normal file
@ -0,0 +1,30 @@
|
||||
//
|
||||
// Created by PulsarV on 18-5-10.
|
||||
//
|
||||
|
||||
#ifndef ROBOCAR_RC_GLOBAL_WHEEL_H
|
||||
#define ROBOCAR_RC_GLOBAL_WHEEL_H
|
||||
#include "rc_global.h"
|
||||
//wheel serial commond
|
||||
#define RC_WHEEL_1_FORWARD "010000000000000"
|
||||
//[1轮方向,1轮速度,2轮方向,2轮速度,3轮方向,3轮速度]
|
||||
// 1 1000 0 0000 0 0000
|
||||
#define RC_WHEEL_1_BACKWARD "110000000000000"
|
||||
|
||||
#define RC_WHEEL_2_FORWARD "000001100000000"
|
||||
#define RC_WHEEL_2_BACKWARD "000000100000000"
|
||||
#define RC_WHEEL_3_FORWARD "000000000001000"
|
||||
#define RC_WHEEL_3_BACKWARD "000000000011000"
|
||||
|
||||
#define RC_WHEEL_GO_FORWARD "000000030000300"
|
||||
#define RC_WHEEL_GO_BACKWARD "000001030010300"
|
||||
|
||||
#define RC_WHEEL_CW "002001020000200"
|
||||
#define RC_WHEEL_AC "102000020010200"
|
||||
|
||||
#define RC_WHEEL_STOP "000000000000000"
|
||||
|
||||
#define RC_MOVE_DEVICE_PORT_INITATION_ERROR (char *) "You should be initation the camera index before start"
|
||||
#define RC_OPEN_CAMERA_ERROR (char *) "Can not open such device or video"
|
||||
|
||||
#endif //ROBOCAR_RC_GLOBAL_WHEEL_H
|
8
robot_client/src/include/rc_gui/rcGUI.h
Normal file
8
robot_client/src/include/rc_gui/rcGUI.h
Normal file
@ -0,0 +1,8 @@
|
||||
//
|
||||
// Created by PulsarV on 18-5-9.
|
||||
//
|
||||
|
||||
#ifndef ROBOCAR_RCGUI_H
|
||||
#define ROBOCAR_RCGUI_H
|
||||
|
||||
#endif //ROBOCAR_RCGUI_H
|
31
robot_client/src/include/rc_gui/rc_gtk_mainwindow.h
Normal file
31
robot_client/src/include/rc_gui/rc_gtk_mainwindow.h
Normal file
@ -0,0 +1,31 @@
|
||||
//
|
||||
// Created by PulsarV on 18-5-14.
|
||||
//
|
||||
|
||||
#ifndef ROBOCAR_RC_GTK_MAINWINDOW_H
|
||||
#define ROBOCAR_RC_GTK_MAINWINDOW_H
|
||||
#include <opencv/highgui.h>
|
||||
#include <iostream>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <gdkmm-2.4/gdkmm.h>
|
||||
#include <gtk-2.0/gdk/gdk.h>
|
||||
#include <gtk-2.0/gtk/gtk.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <rc_gui/rc_gtk_mainwindow.h>
|
||||
#include "map"
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/fb.h>
|
||||
#include <xcb/xcb.h>
|
||||
#include <sys/mman.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
|
||||
namespace RC{
|
||||
class rc_gtk_mainwindow {
|
||||
rc_gtk_mainwindow();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif //ROBOCAR_RC_GTK_MAINWINDOW_H
|
11
robot_client/src/include/rc_gui/subWindow.h
Normal file
11
robot_client/src/include/rc_gui/subWindow.h
Normal file
@ -0,0 +1,11 @@
|
||||
//
|
||||
// Created by norse on 17-6-6.
|
||||
//
|
||||
#include <string>
|
||||
namespace RC {
|
||||
namespace {
|
||||
class subWindow {
|
||||
subWindow(std::string type);
|
||||
};
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user