From 1597b6a6a91f4b521e76149031a66a45dee0ef30 Mon Sep 17 00:00:00 2001 From: jzq <1391797124@qq.com> Date: Fri, 22 Sep 2023 16:40:51 +0800 Subject: [PATCH] 9.21 V1 --- librviz_tutorial/CHANGELOG.rst | 0 librviz_tutorial/CMakeLists.txt | 3 +- librviz_tutorial/launch/rplidar.launch | 0 librviz_tutorial/package.xml | 0 librviz_tutorial/rosdoc.yaml | 0 librviz_tutorial/sdk/README.txt | 0 librviz_tutorial/sdk/include/rplidar.h | 0 librviz_tutorial/sdk/include/rplidar_cmd.h | 0 librviz_tutorial/sdk/include/rplidar_driver.h | 0 .../sdk/include/rplidar_protocol.h | 0 librviz_tutorial/sdk/include/rptypes.h | 0 .../sdk/src/arch/linux/arch_linux.h | 0 .../sdk/src/arch/linux/net_serial.cpp | 0 .../sdk/src/arch/linux/net_serial.h | 0 .../sdk/src/arch/linux/net_socket.cpp | 0 .../sdk/src/arch/linux/thread.hpp | 0 librviz_tutorial/sdk/src/arch/linux/timer.cpp | 0 librviz_tutorial/sdk/src/arch/linux/timer.h | 0 .../sdk/src/arch/macOS/arch_macOS.h | 0 .../sdk/src/arch/macOS/net_serial.cpp | 0 .../sdk/src/arch/macOS/net_serial.h | 0 .../sdk/src/arch/macOS/net_socket.cpp | 0 .../sdk/src/arch/macOS/thread.hpp | 0 librviz_tutorial/sdk/src/arch/macOS/timer.cpp | 0 librviz_tutorial/sdk/src/arch/macOS/timer.h | 0 .../sdk/src/arch/win32/arch_win32.h | 0 .../sdk/src/arch/win32/net_serial.cpp | 0 .../sdk/src/arch/win32/net_serial.h | 0 .../sdk/src/arch/win32/net_socket.cpp | 0 librviz_tutorial/sdk/src/arch/win32/timer.cpp | 0 librviz_tutorial/sdk/src/arch/win32/timer.h | 0 .../sdk/src/arch/win32/winthread.hpp | 0 librviz_tutorial/sdk/src/hal/abs_rxtx.h | 0 librviz_tutorial/sdk/src/hal/assert.h | 0 librviz_tutorial/sdk/src/hal/byteops.h | 0 librviz_tutorial/sdk/src/hal/event.h | 0 librviz_tutorial/sdk/src/hal/locker.h | 0 librviz_tutorial/sdk/src/hal/socket.h | 0 librviz_tutorial/sdk/src/hal/thread.cpp | 0 librviz_tutorial/sdk/src/hal/thread.h | 0 librviz_tutorial/sdk/src/hal/types.h | 0 librviz_tutorial/sdk/src/hal/util.h | 0 librviz_tutorial/sdk/src/rplidar_driver.cpp | 0 librviz_tutorial/sdk/src/rplidar_driver_TCP.h | 0 .../sdk/src/rplidar_driver_impl.h | 0 .../sdk/src/rplidar_driver_serial.h | 0 librviz_tutorial/sdk/src/sdkcommon.h | 0 librviz_tutorial/sources/images/black.png | Bin 0 -> 191 bytes librviz_tutorial/sources/images/blue.png | Bin 0 -> 188 bytes librviz_tutorial/sources/images/green.png | Bin 0 -> 188 bytes .../sources/images/lightgreen.png | Bin 0 -> 157 bytes librviz_tutorial/sources/images/orange.png | Bin 0 -> 155 bytes librviz_tutorial/sources/images/pink.png | Bin 0 -> 157 bytes librviz_tutorial/sources/images/purple.png | Bin 0 -> 154 bytes librviz_tutorial/sources/images/red.png | Bin 0 -> 154 bytes librviz_tutorial/sources/images/skyblue.png | Bin 0 -> 157 bytes librviz_tutorial/sources/images/white.png | Bin 0 -> 152 bytes librviz_tutorial/sources/images/yellow.png | Bin 0 -> 155 bytes librviz_tutorial/src/doc/conf.py | 0 librviz_tutorial/src/doc/index.rst | 0 librviz_tutorial/src/doc/myviz.png | Bin librviz_tutorial/src/doc/tutorialformatter.py | 0 librviz_tutorial/src/main.cpp | 0 librviz_tutorial/src/myviz.cpp | 863 ++++++++++++++++-- librviz_tutorial/src/myviz.h | 71 +- librviz_tutorial/src/node.cpp | 0 66 files changed, 846 insertions(+), 91 deletions(-) mode change 100755 => 100644 librviz_tutorial/CHANGELOG.rst mode change 100755 => 100644 librviz_tutorial/CMakeLists.txt mode change 100755 => 100644 librviz_tutorial/launch/rplidar.launch mode change 100755 => 100644 librviz_tutorial/package.xml mode change 100755 => 100644 librviz_tutorial/rosdoc.yaml mode change 100755 => 100644 librviz_tutorial/sdk/README.txt mode change 100755 => 100644 librviz_tutorial/sdk/include/rplidar.h mode change 100755 => 100644 librviz_tutorial/sdk/include/rplidar_cmd.h mode change 100755 => 100644 librviz_tutorial/sdk/include/rplidar_driver.h mode change 100755 => 100644 librviz_tutorial/sdk/include/rplidar_protocol.h mode change 100755 => 100644 librviz_tutorial/sdk/include/rptypes.h mode change 100755 => 100644 librviz_tutorial/sdk/src/arch/linux/arch_linux.h mode change 100755 => 100644 librviz_tutorial/sdk/src/arch/linux/net_serial.cpp mode change 100755 => 100644 librviz_tutorial/sdk/src/arch/linux/net_serial.h mode change 100755 => 100644 librviz_tutorial/sdk/src/arch/linux/net_socket.cpp mode change 100755 => 100644 librviz_tutorial/sdk/src/arch/linux/thread.hpp mode change 100755 => 100644 librviz_tutorial/sdk/src/arch/linux/timer.cpp mode change 100755 => 100644 librviz_tutorial/sdk/src/arch/linux/timer.h mode change 100755 => 100644 librviz_tutorial/sdk/src/arch/macOS/arch_macOS.h mode change 100755 => 100644 librviz_tutorial/sdk/src/arch/macOS/net_serial.cpp mode change 100755 => 100644 librviz_tutorial/sdk/src/arch/macOS/net_serial.h mode change 100755 => 100644 librviz_tutorial/sdk/src/arch/macOS/net_socket.cpp mode change 100755 => 100644 librviz_tutorial/sdk/src/arch/macOS/thread.hpp mode change 100755 => 100644 librviz_tutorial/sdk/src/arch/macOS/timer.cpp mode change 100755 => 100644 librviz_tutorial/sdk/src/arch/macOS/timer.h mode change 100755 => 100644 librviz_tutorial/sdk/src/arch/win32/arch_win32.h mode change 100755 => 100644 librviz_tutorial/sdk/src/arch/win32/net_serial.cpp mode change 100755 => 100644 librviz_tutorial/sdk/src/arch/win32/net_serial.h mode change 100755 => 100644 librviz_tutorial/sdk/src/arch/win32/net_socket.cpp mode change 100755 => 100644 librviz_tutorial/sdk/src/arch/win32/timer.cpp mode change 100755 => 100644 librviz_tutorial/sdk/src/arch/win32/timer.h mode change 100755 => 100644 librviz_tutorial/sdk/src/arch/win32/winthread.hpp mode change 100755 => 100644 librviz_tutorial/sdk/src/hal/abs_rxtx.h mode change 100755 => 100644 librviz_tutorial/sdk/src/hal/assert.h mode change 100755 => 100644 librviz_tutorial/sdk/src/hal/byteops.h mode change 100755 => 100644 librviz_tutorial/sdk/src/hal/event.h mode change 100755 => 100644 librviz_tutorial/sdk/src/hal/locker.h mode change 100755 => 100644 librviz_tutorial/sdk/src/hal/socket.h mode change 100755 => 100644 librviz_tutorial/sdk/src/hal/thread.cpp mode change 100755 => 100644 librviz_tutorial/sdk/src/hal/thread.h mode change 100755 => 100644 librviz_tutorial/sdk/src/hal/types.h mode change 100755 => 100644 librviz_tutorial/sdk/src/hal/util.h mode change 100755 => 100644 librviz_tutorial/sdk/src/rplidar_driver.cpp mode change 100755 => 100644 librviz_tutorial/sdk/src/rplidar_driver_TCP.h mode change 100755 => 100644 librviz_tutorial/sdk/src/rplidar_driver_impl.h mode change 100755 => 100644 librviz_tutorial/sdk/src/rplidar_driver_serial.h mode change 100755 => 100644 librviz_tutorial/sdk/src/sdkcommon.h create mode 100644 librviz_tutorial/sources/images/black.png create mode 100644 librviz_tutorial/sources/images/blue.png create mode 100644 librviz_tutorial/sources/images/green.png create mode 100644 librviz_tutorial/sources/images/lightgreen.png create mode 100644 librviz_tutorial/sources/images/orange.png create mode 100644 librviz_tutorial/sources/images/pink.png create mode 100644 librviz_tutorial/sources/images/purple.png create mode 100644 librviz_tutorial/sources/images/red.png create mode 100644 librviz_tutorial/sources/images/skyblue.png create mode 100644 librviz_tutorial/sources/images/white.png create mode 100644 librviz_tutorial/sources/images/yellow.png mode change 100755 => 100644 librviz_tutorial/src/doc/conf.py mode change 100755 => 100644 librviz_tutorial/src/doc/index.rst mode change 100755 => 100644 librviz_tutorial/src/doc/myviz.png mode change 100755 => 100644 librviz_tutorial/src/doc/tutorialformatter.py mode change 100755 => 100644 librviz_tutorial/src/main.cpp mode change 100755 => 100644 librviz_tutorial/src/myviz.cpp mode change 100755 => 100644 librviz_tutorial/src/myviz.h mode change 100755 => 100644 librviz_tutorial/src/node.cpp diff --git a/librviz_tutorial/CHANGELOG.rst b/librviz_tutorial/CHANGELOG.rst old mode 100755 new mode 100644 diff --git a/librviz_tutorial/CMakeLists.txt b/librviz_tutorial/CMakeLists.txt old mode 100755 new mode 100644 index e654dea..5077048 --- a/librviz_tutorial/CMakeLists.txt +++ b/librviz_tutorial/CMakeLists.txt @@ -16,7 +16,8 @@ FILE(GLOB SDK_SRC find_package(catkin REQUIRED COMPONENTS rviz roscpp std_msgs -rosconsole sensor_msgs # node.cpp +rosconsole sensor_msgs # node.cpp +rosbag ) diff --git a/librviz_tutorial/launch/rplidar.launch b/librviz_tutorial/launch/rplidar.launch old mode 100755 new mode 100644 diff --git a/librviz_tutorial/package.xml b/librviz_tutorial/package.xml old mode 100755 new mode 100644 diff --git a/librviz_tutorial/rosdoc.yaml b/librviz_tutorial/rosdoc.yaml old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/README.txt b/librviz_tutorial/sdk/README.txt old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/include/rplidar.h b/librviz_tutorial/sdk/include/rplidar.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/include/rplidar_cmd.h b/librviz_tutorial/sdk/include/rplidar_cmd.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/include/rplidar_driver.h b/librviz_tutorial/sdk/include/rplidar_driver.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/include/rplidar_protocol.h b/librviz_tutorial/sdk/include/rplidar_protocol.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/include/rptypes.h b/librviz_tutorial/sdk/include/rptypes.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/arch/linux/arch_linux.h b/librviz_tutorial/sdk/src/arch/linux/arch_linux.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/arch/linux/net_serial.cpp b/librviz_tutorial/sdk/src/arch/linux/net_serial.cpp old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/arch/linux/net_serial.h b/librviz_tutorial/sdk/src/arch/linux/net_serial.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/arch/linux/net_socket.cpp b/librviz_tutorial/sdk/src/arch/linux/net_socket.cpp old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/arch/linux/thread.hpp b/librviz_tutorial/sdk/src/arch/linux/thread.hpp old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/arch/linux/timer.cpp b/librviz_tutorial/sdk/src/arch/linux/timer.cpp old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/arch/linux/timer.h b/librviz_tutorial/sdk/src/arch/linux/timer.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/arch/macOS/arch_macOS.h b/librviz_tutorial/sdk/src/arch/macOS/arch_macOS.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/arch/macOS/net_serial.cpp b/librviz_tutorial/sdk/src/arch/macOS/net_serial.cpp old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/arch/macOS/net_serial.h b/librviz_tutorial/sdk/src/arch/macOS/net_serial.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/arch/macOS/net_socket.cpp b/librviz_tutorial/sdk/src/arch/macOS/net_socket.cpp old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/arch/macOS/thread.hpp b/librviz_tutorial/sdk/src/arch/macOS/thread.hpp old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/arch/macOS/timer.cpp b/librviz_tutorial/sdk/src/arch/macOS/timer.cpp old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/arch/macOS/timer.h b/librviz_tutorial/sdk/src/arch/macOS/timer.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/arch/win32/arch_win32.h b/librviz_tutorial/sdk/src/arch/win32/arch_win32.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/arch/win32/net_serial.cpp b/librviz_tutorial/sdk/src/arch/win32/net_serial.cpp old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/arch/win32/net_serial.h b/librviz_tutorial/sdk/src/arch/win32/net_serial.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/arch/win32/net_socket.cpp b/librviz_tutorial/sdk/src/arch/win32/net_socket.cpp old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/arch/win32/timer.cpp b/librviz_tutorial/sdk/src/arch/win32/timer.cpp old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/arch/win32/timer.h b/librviz_tutorial/sdk/src/arch/win32/timer.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/arch/win32/winthread.hpp b/librviz_tutorial/sdk/src/arch/win32/winthread.hpp old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/hal/abs_rxtx.h b/librviz_tutorial/sdk/src/hal/abs_rxtx.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/hal/assert.h b/librviz_tutorial/sdk/src/hal/assert.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/hal/byteops.h b/librviz_tutorial/sdk/src/hal/byteops.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/hal/event.h b/librviz_tutorial/sdk/src/hal/event.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/hal/locker.h b/librviz_tutorial/sdk/src/hal/locker.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/hal/socket.h b/librviz_tutorial/sdk/src/hal/socket.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/hal/thread.cpp b/librviz_tutorial/sdk/src/hal/thread.cpp old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/hal/thread.h b/librviz_tutorial/sdk/src/hal/thread.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/hal/types.h b/librviz_tutorial/sdk/src/hal/types.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/hal/util.h b/librviz_tutorial/sdk/src/hal/util.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/rplidar_driver.cpp b/librviz_tutorial/sdk/src/rplidar_driver.cpp old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/rplidar_driver_TCP.h b/librviz_tutorial/sdk/src/rplidar_driver_TCP.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/rplidar_driver_impl.h b/librviz_tutorial/sdk/src/rplidar_driver_impl.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/rplidar_driver_serial.h b/librviz_tutorial/sdk/src/rplidar_driver_serial.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sdk/src/sdkcommon.h b/librviz_tutorial/sdk/src/sdkcommon.h old mode 100755 new mode 100644 diff --git a/librviz_tutorial/sources/images/black.png b/librviz_tutorial/sources/images/black.png new file mode 100644 index 0000000000000000000000000000000000000000..db1fb0f44f9054105e6af4588ed48809623d4d77 GIT binary patch literal 191 zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1|+Qw)-3{3jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85qP=L734qNaX`iFvQcvF~r0B=!uQI3<^94HvIcv@{nPDi$|Q% w_P;Hg4@5rDDG;;Zp2K>MDZP<6uKa9UgA)y_))qZ#2Aa>{>FVdQ&MBb@0JCB{mdKI;Vst0P7z%5C8xG literal 0 HcmV?d00001 diff --git a/librviz_tutorial/sources/images/green.png b/librviz_tutorial/sources/images/green.png new file mode 100644 index 0000000000000000000000000000000000000000..babf5e3dbe846f345700a405b7f5234c8bf617dd GIT binary patch literal 188 zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1|+Qw)-3{3jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85qP=L734qNaX`iFwoP*F~r0B=!uPt3<^947R-D1{3~PF;{%7z p%>3IFnIJZUHLa0&>gSy|tX3DCPHeu`JsoH`gQu&X%Q~loCIH5XIpP2S literal 0 HcmV?d00001 diff --git a/librviz_tutorial/sources/images/lightgreen.png b/librviz_tutorial/sources/images/lightgreen.png new file mode 100644 index 0000000000000000000000000000000000000000..5a219d8ec3fbfef5ce4a51779bd37305aede34f7 GIT binary patch literal 157 zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1|+Qw)-3{3jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85qP=L734qNaX`i(8$xpF~r0B?O8=e1_q8J4!>6Wd$DF1vIs9< oe`zN7F^S|JLnLBGeqkD8<^NsYE97Q{0Ch8Xy85}Sb4q9e0MG&|od5s; literal 0 HcmV?d00001 diff --git a/librviz_tutorial/sources/images/orange.png b/librviz_tutorial/sources/images/orange.png new file mode 100644 index 0000000000000000000000000000000000000000..d18a9c76ec614dfc297c975a64b792f25f552bec GIT binary patch literal 155 zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1|+Qw)-3{3jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85qP=L734qNaX`i(7@BhF~r0B?O8)c1_qA98-9LoJoj*s%$E~$ mOD=IAlSu9{L?UM77w(!A?>fci(xX*Cy$qhNelF{r5}E)!>@H~l literal 0 HcmV?d00001 diff --git a/librviz_tutorial/sources/images/pink.png b/librviz_tutorial/sources/images/pink.png new file mode 100644 index 0000000000000000000000000000000000000000..c07b3852a8a0a1be8b4f62d3c84fc201fd3f6e36 GIT binary patch literal 157 zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1|+Qw)-3{3jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85qP=L734qNaX`i(8$xpF~r0B?O8=e1_q8J4!@Qk5`L9w$RfOa o{iVs=$0U+_43UT#`5#jlt0v_|{^61R57f=z>FVdQ&MBb@01cfh`2YX_ literal 0 HcmV?d00001 diff --git a/librviz_tutorial/sources/images/purple.png b/librviz_tutorial/sources/images/purple.png new file mode 100644 index 0000000000000000000000000000000000000000..648272527cbf1dff419b12e4623193270ee35fd9 GIT binary patch literal 154 zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1|+Qw)-3{3jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85qP=L734qNaX`iP~X$VF~r0B?b(Hl3=ABHH_Y94{$aP$iVnY7 m=U9__439}55ofmV*z9tH<=JE7dk27889ZJ6T-G@yGywqaR4t+a literal 0 HcmV?d00001 diff --git a/librviz_tutorial/sources/images/red.png b/librviz_tutorial/sources/images/red.png new file mode 100644 index 0000000000000000000000000000000000000000..203bee1f776fcc06b8e1e017a14ed9de012abf8a GIT binary patch literal 154 zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1|+Qw)-3{3jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85qP=L734qNaX`iP~X$VF~r0B?b(Hl3fmdR u)wm{--DP@oR+8_=Wf8$^G_U;;+suA7hcW5Y{%Mv#tqh*7elF{r5}E*|EGusS literal 0 HcmV?d00001 diff --git a/librviz_tutorial/sources/images/skyblue.png b/librviz_tutorial/sources/images/skyblue.png new file mode 100644 index 0000000000000000000000000000000000000000..1a88dcf66e1eb06f5962f988c7c13db97712efbd GIT binary patch literal 157 zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1|+Qw)-3{3jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85qP=L734qNaX`i(8$xpF~r0B?O8)cpbiGdw_Af mC6~C5NhJ3eA`vt43wM?Ie2rP?qu~eC%i!ti=d#Wzp$Py2IxLU? literal 0 HcmV?d00001 diff --git a/librviz_tutorial/src/doc/conf.py b/librviz_tutorial/src/doc/conf.py old mode 100755 new mode 100644 diff --git a/librviz_tutorial/src/doc/index.rst b/librviz_tutorial/src/doc/index.rst old mode 100755 new mode 100644 diff --git a/librviz_tutorial/src/doc/myviz.png b/librviz_tutorial/src/doc/myviz.png old mode 100755 new mode 100644 diff --git a/librviz_tutorial/src/doc/tutorialformatter.py b/librviz_tutorial/src/doc/tutorialformatter.py old mode 100755 new mode 100644 diff --git a/librviz_tutorial/src/main.cpp b/librviz_tutorial/src/main.cpp old mode 100755 new mode 100644 diff --git a/librviz_tutorial/src/myviz.cpp b/librviz_tutorial/src/myviz.cpp old mode 100755 new mode 100644 index b8ec1b4..e738d49 --- a/librviz_tutorial/src/myviz.cpp +++ b/librviz_tutorial/src/myviz.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -14,13 +15,36 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "rviz/properties/property_tree_widget.h" +#include "rviz/selection/selection_manager.h" +#include "rviz/panel.h" + #include "rviz/visualization_manager.h" +#include"rviz/tool_manager.h" #include "rviz/render_panel.h" #include "rviz/display.h" #include "myviz.h" #include "../tools/color.h" - +#include "qthread.h" // BEGIN_TUTORIAL // Constructor for MyViz. This does most of the work of the class. MyViz::MyViz( QWidget* parent) @@ -34,86 +58,229 @@ MyViz::MyViz( QWidget* parent) // 全局变量存放处 // 颜色名称,可添加,待设置rgb类型设置颜色 - color_name = {"yellow","red","green","black","blue","white","pink","purple","skyblue","lightgreen","orange", + color_name = {"white","red","green","black","blue","yellow","pink","purple","skyblue","lightgreen","orange", }; + // 颜色路径名 + color_icon_filename = QString("/home/wbw/Rviz/librviz_ws/src/librviz_tutorial/sources/images/%1.png"); + speed_name = {"2.0","1.5","1.25","1.0","0.75","0.5",}; + duration = 0; + isclicked = true; + ispauseclick = true; + sliderreleased = false; + playagain = false; + isthreadplaying = false; + abs = false; + stored = false; - //pub_thread.join(); - // Construct and lay out labels and slider controls. - // Line Thickness - QLabel* thickness_label = new QLabel( "Line Thickness" ); - QSlider* thickness_slider = new QSlider( Qt::Horizontal ); - thickness_slider->setMinimum( 1 ); - thickness_slider->setMaximum( 100 ); - // Cell Size - QLabel* cell_size_label = new QLabel( "Cell Size" ); - QSlider* cell_size_slider = new QSlider( Qt::Horizontal ); - cell_size_slider->setMinimum( 1 ); - cell_size_slider->setMaximum( 100 ); - // Topic_Cloud - // QLabel* Topic=new QLabel("TOPIC:"); - // QLineEdit* Topic_text=new QLineEdit(); - // Topic_Laser 输入雷达 - QLabel* Topic_laser = new QLabel("TOPIC_Laser:"); - QLineEdit* Topic_laser_text = new QLineEdit(); - - // Laser - QLabel* Size=new QLabel("Laser Size"); - QSpinBox* size=new QSpinBox(); // 网格结构 - QGridLayout* controls_layout = new QGridLayout(); - controls_layout->addWidget( thickness_label, 0, 0 ); - controls_layout->addWidget( thickness_slider, 1, 0 ); - controls_layout->addWidget( cell_size_label, 2, 0 ); - controls_layout->addWidget( cell_size_slider, 3, 0 ); - // controls_layout->addWidget(Topic,0,4); - // controls_layout->addWidget(Topic_text,0,5); + QGridLayout* controls_layout = new QGridLayout(); + int ctl_index = 0; - controls_layout->addWidget(Topic_laser, 4, 0); - controls_layout->addWidget(Topic_laser_text, 5, 0); - - controls_layout->addWidget(Size,6,0); - controls_layout->addWidget(size,7,0); + //select按钮 + QPushButton* selection_button = new QPushButton("select"); + QPushButton* move_camera_button = new QPushButton("move_camera"); - // 颜色选择QComBox - QLabel* label_color = new QLabel("Color:"); - QComboBox * comboBox = new QComboBox(); - for(int i =0 ; i < color_name.size(); ++i){ - comboBox->addItem(color_name[i]); + controls_layout->addWidget( move_camera_button, ctl_index, 0); + controls_layout->addWidget( selection_button, ctl_index++ ,1); + + // offline 布局 + // QPushButton setting!//////////////////////////////////////////////////////////////////////////////////////////////// + QPushButton* play = new QPushButton("play", this); + QPushButton* pause = new QPushButton("pause", this); + QPushButton* but_save = new QPushButton("save", this);// buttonn: save one frame + QPushButton* but_saveMul = new QPushButton("saveMul", this);// button: save multiple frames + QPushButton* but_file = new QPushButton("file", this);// button: select file + + // QLabel setting!///////////////////////////////////////////////////////////////////////////////////////////////////// + QLabel* label_speed = new QLabel("speed:");//speed combobox + QLabel* label_split = new QLabel("");//speed combobox + + // QSlider setting!//////////////////////////////////////////////////////////////////////////////////////////////////// + progress = new QSlider(Qt::Horizontal); + // QComboBox setting!////////////////////////////////////////////////////////////////////////////////////////////////// + QComboBox * speed_combobox = new QComboBox(); + //enable button//////////////////////////////////////////////////////////////////////////////////////////////////////// + play->setEnabled(true); + pause->setEnabled(true); + but_save->setEnabled(true); + but_saveMul->setEnabled(true); + but_file->setEnabled(true); + + // setting button size!//////////////////////////////////////////////////////////////////////////////////////////////// + play->setFixedSize(100, 30); + pause->setFixedSize(100, 30); + but_save->setFixedSize(100, 30); + but_saveMul->setFixedSize(100, 30); + but_file->setFixedSize(100, 30); + + for(int i = 0; i < speed_name.size(); i++) + speed_combobox->addItem(speed_name[i] + "x"); + speed_combobox->setCurrentIndex(3); + + controls_layout->addWidget( label_split, ctl_index++, 0 ); + controls_layout->addWidget( but_file, ctl_index, 0 ); + controls_layout->addWidget( but_save, ctl_index++, 1 ); + controls_layout->addWidget( but_saveMul, ctl_index++, 0 ); + + controls_layout->addWidget(label_speed,ctl_index,0); + controls_layout->addWidget(speed_combobox,ctl_index++,1); + + controls_layout->addWidget( play, ctl_index, 0 ); + controls_layout->addWidget( pause, ctl_index++, 1 ); + controls_layout->addWidget(progress,ctl_index++,0, 1, 2); // addwidget(widget,row,col,m,n);//m是占几行,n是占几列, + + controls_layout->setSpacing(5); + + // 是否选择显示坐标轴 + QLabel* label_axes = new QLabel("Display Axes:"); + QComboBox * axesBox = new QComboBox(); + axesBox->addItem("no"); + axesBox->addItem("yes"); + + // 选择圆圈范围 + QLabel* label_circle = new QLabel("Circle Scale(m): "); + QComboBox* circleBox = new QComboBox(); + circleBox->addItem("cancel"); + for(int i =1; i<=3 ;++i){ + circleBox->addItem(QString(std::to_string(i).c_str())); } - controls_layout->addWidget(label_color,8,0); - controls_layout->addWidget(comboBox,8,1); + circleBox->addItem("5"); - // Tree - Tree_Display(controls_layout, 9); + controls_layout->addWidget(label_axes, ctl_index,0); + controls_layout->addWidget(axesBox, ctl_index++,1); + controls_layout->addWidget(label_circle, ctl_index,0); + controls_layout->addWidget(circleBox, ctl_index++,1); + + // 第二个layout + QGridLayout* display_layout = new QGridLayout(); + int display_index = 0; + + // Tree 全局变量存放地方 + Tree_Display(display_layout, display_index++); - // 设置网格某一行伸缩比例 - controls_layout->setRowStretch(9, 6); // controls_layout->setRowStretch(3, 0); + // Make signal/slot connections. 进行信号/插槽连接 + + // 增加切换select + connect(selection_button, SIGNAL(clicked()), this, SLOT( slot_select())); + connect(move_camera_button, SIGNAL(clicked()), this, SLOT( slot_move_camera())); + + + // 增加坐标变换 + connect(axesBox, SIGNAL(currentIndexChanged(int)), this, SLOT(AxesDisplayChanged(int))); + // 增加圆圈变换 + connect(circleBox, SIGNAL(currentIndexChanged(int)), this, SLOT(CircleDisplayChanged(int))); + //off + connect(progress,&QSlider::valueChanged,this,[=](){// 变动会触发 + if(!ismoved){ + ischanged = true;// “戳”这一个动作会使ischange变成true + // qDebug()<<"CLICK"<setSliderPosition(0); + std::thread rosBagPlay(&MyViz::openFile, this);// 新开线程执行操作 + rosBagPlay.detach(); + + } + } + + }); + connect(pause, &QPushButton::clicked, this, [&]() { + if(isthreadplaying){ + if(ispauseclick) + { + ispauseclick = false; + } + else + { + ispauseclick = true; + } + } + }); // Construct and lay out render panel. render_panel_ = new rviz::RenderPanel(); // RVIZ在QT上显示的类 QHBoxLayout* main_layout = new QHBoxLayout; // 主要layout QV垂直,QH水平 - main_layout->addLayout( controls_layout ); - main_layout->addWidget( render_panel_,2); // 存放rviz的位置, stretch 拉伸系数 // QSplitter *splitter = new QSplitter(); // main_layout->addWidget(splitter); // splitter->addWidget(render_panel_); - // Set the top-level layout for this MyViz widget. - setLayout( main_layout ); - - // Make signal/slot connections. 进行信号/插槽连接 - connect( thickness_slider, SIGNAL( valueChanged( int )), this, SLOT( setThickness( int ))); - connect( cell_size_slider, SIGNAL( valueChanged( int )), this, SLOT( setCellSize( int ))); - // 增加雷达话题 - connect(Topic_laser_text, SIGNAL(textChanged(const QString &)), this, SLOT(setLaserTopic(const QString &))); - connect(size,SIGNAL(valueChanged(int)),this,SLOT(setLaserSize(int))); - - // 增加颜色变换 - connect(comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(LaserColorChanged(int))); - // Next we initialize the main RViz classes. // // The VisualizationManager is the container for Display objects, @@ -124,9 +291,23 @@ MyViz::MyViz( QWidget* parent) // 初始化camera 这行代码实现放大 缩小 平移等操作 render_panel_->initialize( manager_->getSceneManager(), manager_ ); // manager_->setFixedFrame("world"); + // 初始化tool_manager_ + tool_manager_ = manager_->getToolManager(); + manager_->initialize(); manager_->startUpdate(); + // 创建select panel + QLabel *select_label = new QLabel("Select Display:"); + tree_widget_ = new rviz::PropertyTreeWidget(); + tree_widget_->setModel(manager_->getSelectionManager()->getPropertyModel()); + + display_layout->addWidget(select_label, display_index++, 0); + display_layout->addWidget(tree_widget_, display_index++, 0); + + // 设置网格某一行伸缩比例,放最后一行 + // controls_layout->setRowStretch(--ctl_index, 6); + // Create a Grid display. grid_ = manager_->createDisplay( "rviz/Grid", "adjustable grid", true ); ROS_ASSERT( grid_ != NULL ); @@ -134,13 +315,13 @@ MyViz::MyViz( QWidget* parent) // cloud = manager_->createDisplay( "rviz/PointCloud2", "point cloud", true ); // ROS_ASSERT( cloud != NULL ); - laser = manager_->createDisplay( "rviz/LaserScan", "Qlaser", true ); - ROS_ASSERT( laser ); + laser_ = manager_->createDisplay( "rviz/LaserScan", "Qlaser", true ); + ROS_ASSERT( laser_ ); // 新增雷达 - laser->subProp("Topic")->setValue("/scan"); - laser->subProp("Size (Pixels)")->setValue("2"); - laser->subProp("Color Transformer")->setValue("FlatColor"); - laser->subProp("Color")->setValue(comboBox->currentText()); + laser_->subProp("Topic")->setValue("/scan"); + laser_->subProp("Size (Pixels)")->setValue("2"); + laser_->subProp("Color Transformer")->setValue("FlatColor"); + // laser_->subProp("Color")->setValue(comboBox->currentText()); // cloud->subProp("Topic")->setValue("/pose_graph/octree"); // cloud->subProp("Style")->setValue("Points"); // cloud->subProp("Size (Pixels)")->setValue("2"); @@ -151,9 +332,23 @@ MyViz::MyViz( QWidget* parent) grid_->subProp( "Line Style" )->setValue( "Billboards" ); grid_->subProp( "Color" )->setValue( QColor( Qt::white ) ); - // Initialize the slider values. - thickness_slider->setValue( 5 ); - cell_size_slider->setValue( 6 ); + // 新增坐标系 + axes_display= manager_->createDisplay("rviz/Axes", "Axes", false); + ROS_ASSERT( axes_display != NULL ); + axes_display->subProp("Length")->setValue(5); // 设置透明度 + axes_display->subProp("Radius")->setValue(0.1); // 设置坐标系的缩放大小 + + // 新增Marker_ 显示圆圈 + marker_ = manager_->createDisplay("rviz/Marker", "Marker", false); + ROS_ASSERT( marker_ != NULL ); + marker_->subProp("Topic")->setValue("visualization_marker"); + + // Set the top-level layout for this MyViz widget. + main_layout->addLayout( controls_layout ); + main_layout->addLayout( display_layout ); + main_layout->addWidget( render_panel_,2); // 存放rviz的位置, stretch 拉伸系数 + setLayout( main_layout ); + } void MyViz::Tree_Display(QGridLayout* controls_layout, int index){ @@ -163,36 +358,32 @@ void MyViz::Tree_Display(QGridLayout* controls_layout, int index){ menu->header()->setSectionResizeMode(QHeaderView::ResizeToContents); menu->setHeaderLabels(QStringList()<<"key"<<"value"); + menu->setHeaderHidden(true); // menu->setColumnCount(2); - //设置不同层次菜单的缩进 + // 设置不同层次菜单的缩进 // menu->setIndentation(10); - // global-一层树 QTreeWidgetItem *global= new QTreeWidgetItem(menu, QStringList("全局变量")); menu->addTopLevelItem(global); global->setExpanded(true); - //fix frame + // fix frame QTreeWidgetItem *fixed_frame = new QTreeWidgetItem(global, QStringList("Fixed Frame")); QLineEdit* fixed_frame_text = new QLineEdit(); - fixed_frame_text->setText("world"); + fixed_frame_text->setText("laser"); fixed_frame_text->setStyleSheet("background:transparent;border-width:0;border-style:inset"); // 设置事件 connect(fixed_frame_text,SIGNAL(textChanged(const QString&)),this,SLOT(setFixedFrame(const QString&))); - // 将其他控件(非TreeWidgetItem)放入treeItem中 menu->setItemWidget(fixed_frame, 1, fixed_frame_text); // 将container 放到 Item ,数字为列数 - QTreeWidgetItem *bg_color = new QTreeWidgetItem(global, QStringList("BackGround Color")); QLineEdit* bg_color_text = new QLineEdit(); bg_color_text->setText("48;48;48"); bg_color_text->setStyleSheet("border-width:0;border-style:outset"); - // 设置事件 connect(bg_color_text,SIGNAL(textChanged(const QString&)),this,SLOT(setBackgroundColor(const QString&))); - menu->setItemWidget(bg_color, 1, bg_color_text); // 将container 放到 Item ,数字为列数 // global->addChild(fixed_frame); @@ -203,21 +394,194 @@ void MyViz::Tree_Display(QGridLayout* controls_layout, int index){ QTreeWidgetItem *grid_color = new QTreeWidgetItem(grid, QStringList("Color")); QComboBox * grid_color_cbox = new QComboBox(); for(int i =0 ; i < color_name.size(); ++i){ - grid_color_cbox->addItem(color_name[i]); + QString color_path = color_icon_filename.arg(color_name[i]); + QIcon color_icon(color_path); + grid_color_cbox->addItem(color_icon, color_name[i]); } connect(grid_color_cbox, SIGNAL(currentIndexChanged(int)), this, SLOT(GridColorChanged(int))); menu->setItemWidget(grid_color, 1, grid_color_cbox); - QTreeWidgetItem *item3 = new QTreeWidgetItem(menu, QStringList("Laser")); + // grid cell size + QTreeWidgetItem *grid_cell = new QTreeWidgetItem(grid, QStringList("Cell Size")); + QSlider* cell_size_slider = new QSlider( Qt::Horizontal ); + cell_size_slider->setMinimum( 1 ); + cell_size_slider->setMaximum( 100 ); + connect( cell_size_slider, SIGNAL( valueChanged( int )), this, SLOT( setCellSize( int ))); + cell_size_slider->setValue( 1 ); + menu->setItemWidget(grid_cell, 1, cell_size_slider); + + // grid Line Thickness + QTreeWidgetItem *grid_thickness = new QTreeWidgetItem(grid, QStringList("Line Thickness")); + QSlider* thickness_slider = new QSlider( Qt::Horizontal ); + thickness_slider->setMinimum( 1 ); + thickness_slider->setMaximum( 100 ); + connect( thickness_slider, SIGNAL( valueChanged( int )), this, SLOT( setThickness( int ))); + thickness_slider->setValue( 5 ); + menu->setItemWidget(grid_thickness, 1, thickness_slider); + + // laser - 一层树 + QTreeWidgetItem * laser = new QTreeWidgetItem(menu, QStringList("Laser")); + // 二层 + QTreeWidgetItem *laser_topic = new QTreeWidgetItem(laser, QStringList("Topic ")); + // Topic_Laser 输入雷达 + QLineEdit* laser_topic_text = new QLineEdit(); + // 增加雷达话题 + connect(laser_topic_text, SIGNAL(textChanged(const QString &)), this, SLOT(setLaserTopic(const QString &))); + menu->setItemWidget(laser_topic, 1, laser_topic_text); + + // Laser size + QTreeWidgetItem *laser_size = new QTreeWidgetItem(laser, QStringList("Size ")); + QSpinBox* laser_size_text=new QSpinBox(); + connect(laser_size_text,SIGNAL(valueChanged(int)),this,SLOT(setLaserSize(int))); + menu->setItemWidget(laser_size, 1, laser_size_text); + + // Laser color + QTreeWidgetItem *laser_color = new QTreeWidgetItem(laser, QStringList("Color ")); + QComboBox * comboBox = new QComboBox(); + for(int i =0 ; i < color_name.size(); ++i){ + QString color_path = color_icon_filename.arg(color_name[i]); + QIcon color_icon(color_path); + comboBox->addItem(color_icon, color_name[i]); + } + comboBox->setCurrentIndex(1); + // 增加颜色变换 + connect(comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(LaserColorChanged(int))); + menu->setItemWidget(laser_color, 1, comboBox); + QTreeWidgetItem *item13 = new QTreeWidgetItem(global, QStringList("Frame rate")); - QTreeWidgetItem *item21 = new QTreeWidgetItem(grid, QStringList("Cell Size")); QTreeWidgetItem *item22 = new QTreeWidgetItem(grid, QStringList("Line Style")); - QTreeWidgetItem *item23 = new QTreeWidgetItem(grid, QStringList("Color")); controls_layout->addWidget(menu, index, 0 ); } +void MyViz::PlayCircle(int index){ + int argc =0; + char** argv; + ros::init(argc, argv, "basic_shapes"); + ros::NodeHandle n; + ros::Rate r(1); + ros::Publisher marker_pub = n.advertise("visualization_marker", 1); + uint32_t shape = visualization_msgs::Marker::LINE_STRIP; + + if (ros::ok()) + { + visualization_msgs::Marker marker; + // Set the frame ID and timestamp. See the TF tutorials for information on these. + marker.header.frame_id = "laser"; + marker.header.stamp = ros::Time::now(); + + // Set the namespace and id for this marker. This serves to create a unique ID + // Any marker sent with the same namespace and id will overwrite the old one + marker.ns = "basic_shapes"; + marker.id = 0; + + // Set the marker type. Initially this is CUBE, and cycles between that and SPHERE, ARROW, and CYLINDER + marker.type = shape; + + // Set the marker action. Options are ADD, DELETE, and new in ROS Indigo: 3 (DELETEALL) + marker.action = visualization_msgs::Marker::ADD; + + // Set the pose of the marker. This is a full 6DOF pose relative to the frame/time specified in the header + marker.pose.position.x = 0; + marker.pose.position.y = 0; + marker.pose.position.z = 0; + marker.pose.orientation.x = 0.0; + marker.pose.orientation.y = 0.0; + marker.pose.orientation.z = 0.0; + marker.pose.orientation.w = 1.0; + + // Set the scale of the marker -- 1x1x1 here means 1m on a side + // 设置线段的宽度 + marker.scale.x = 0.02; + marker.scale.y = 1.0; + marker.scale.z = 1.0; + + // Set the color -- be sure to set alpha to something non-zero! + marker.color.r = 0.0f; + marker.color.g = 1.0f; + marker.color.b = 0.0f; + marker.color.a = 1.0; + // points + // 绘制同心圆 + // double r_c= std::stod(argv[1]); + double radius = index; + int num_points = 360; + // Create the vertices for the points and lines 画圆 + for (uint32_t i = 0; i < num_points; ++i) + { + // float y = sin(f + i / 100.0f * 2 * M_PI); + // float z = cos(f + i / 100.0f * 2 * M_PI); + double angle = 2 * M_PI * i / num_points; + geometry_msgs::Point point; + point.x = radius * cos(angle); + point.y = radius * sin(angle); + point.z = 0.0; + marker.points.push_back(point); + } + marker.lifetime = ros::Duration(); + + // Publish the marker + while (marker_pub.getNumSubscribers() < 1) + { + if (!ros::ok()) + { + std::cout<< "publish return 0" << std::endl; + } + ROS_WARN_ONCE("Please create a subscriber to the marker"); + // sleep(1); + } + marker_pub.publish(marker); + + r.sleep(); + } + +} + +void MyViz::CircleDisplayChanged(int index){ + if(index == 0){ + marker_->setValue(false); + }else + { + manager_->setFixedFrame("laser"); + + marker_->setValue(true); + std::thread ThreadCircle(&MyViz::PlayCircle, this, index);// 新开线程执行操作 + ThreadCircle.detach();// 执行完成后自动回收资源 + } +} + +void MyViz::AxesDisplayChanged(int index) +{ + switch (index) + { + case 0: // "yes" 选项被选择 + if (axes_display != NULL) + axes_display->setValue(false); + break; + + case 1: // "no" 选项被选择 + if (axes_display != NULL) + axes_display->setValue(true); + break; + } +} + +void MyViz::slot_move_camera(){ + rviz::Tool* current_tool_= tool_manager_->getDefaultTool(); + tool_manager_->setCurrentTool(current_tool_); + manager_->startUpdate(); +} + + +void MyViz::slot_select(){ + // 获得工具类 + // tool_manager_ = manager_->getToolManager(); + rviz::Tool* current_tool_ = tool_manager_->addTool("rviz/Select"); + tool_manager_->setCurrentTool(current_tool_); + manager_->startUpdate(); +} + void MyViz::setBackgroundColor(const QString& color_string){ if(manager_!=NULL){ const QString t = color_string; @@ -238,7 +602,7 @@ void MyViz::setBackgroundColor(const QString& color_string){ void MyViz::LaserColorChanged(int index){ - if(laser!=NULL) laser->subProp("Color")->setValue(color_name[index]); + if(laser_!=NULL) laser_->subProp("Color")->setValue(color_name[index]); } @@ -282,11 +646,11 @@ void MyViz::setCloudTopic(const QString &newTopic){ } void MyViz::setLaserTopic(const QString &newTopic){ - if(laser!=NULL){ - laser->subProp( "Topic" )->setValue(newTopic); + if(laser_!=NULL){ + laser_->subProp( "Topic" )->setValue(newTopic); ROS_INFO_STREAM("laser topic changed to => "<setEnabled(true); + laser_->setEnabled(true); // laser->subProp( "Color" )->setValue( QColor( Qt::yellow ) ); manager_->setFixedFrame("laser"); manager_->startUpdate(); @@ -304,8 +668,8 @@ void MyViz::setCloudSize(int cloudsize){ } void MyViz::setLaserSize(int lasersize){ - if(laser!=NULL){ - laser->subProp("Size (Pixels)")->setValue(lasersize); + if(laser_!=NULL){ + laser_->subProp("Size (Pixels)")->setValue(lasersize); } } @@ -317,4 +681,325 @@ void MyViz::pubThread(){ while(ros::ok()){ ROS_INFO_STREAM_ONCE("here is in publish process!"); } +} + + +void MyViz::openFile() +{ + ros::Rate r(10.0); + rosbag::Bag bag,newBag; + std::string pcdFilePathStr = filePath.toStdString(); + int frameEnd; + int frameStart; + bool saveFlag = false; + if(stored) + { + char** argv;// 字符串内容(输入) + int argc=0;// 字符串个数(输入) + countbag = 0; + ros::init(argc, argv, "laser_scan_publisher");// "laser"???????????重新启动一下roscore可以解决 + // qDebug()<<"11111"; + + ros::NodeHandle n; + scan_pub = n.advertise("scan", 5);// "topic" + // sleep time + + bag.open(pcdFilePathStr, rosbag::bagmode::Read); + + rosbag::View view1(bag, rosbag::TopicQuery("/scan")); + view = &view1; + std::cout<size()<begin(); it != view->end(); ++it)// 用于预先存储bag包的信息 + { + auto m = *it; + sensor_msgs::LaserScan::ConstPtr input = m.instantiate(); + indx.push_back(input); + } + stored = false; + indxsize = indx.size(); + bag.close(); + qDebug()<=indxsize) + { + scan_pub.publish(*indx[indxsize-1]); + end = true;// 停在当前位置 + countbag = 0;// 从头开始 + qDebug()<<"publish end"; + } + // progressmove = false; + + if(is_rateChanged){ + qDebug() << QString::number(speed_rate); + r = ros::Rate(speed_rate); + r.reset(); + is_rateChanged = false; + } + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + if(is_save){ + if(newBag.isOpen()) + newBag.close(); + std::string temFileStr = pcdFilePathStr; + temFileStr.resize(pcdFilePathStr.length() - 4); + std::string saveFilePathStr = temFileStr + "frame" \ + + std::to_string(countbag) + ".bag"; + std::cout << saveFilePathStr; + std::ifstream file(saveFilePathStr.c_str()); + if (!file.good()) { + // std::ofstream outputFile(saveFilePathStr); //create a file + // outputFile.close(); + + QFile newFile(QString::fromStdString(saveFilePathStr)); + + newBag.open(saveFilePathStr, rosbag::bagmode::Write); + // for(int i=0;i<10;i++){ + newBag.write("/scan", ros::Time::now(), indx[countbag]); + // } + newBag.close(); + }else{ + // file exist + } + + is_save = false; + r.sleep(); + countbag++; + continue; + } + if(is_saveMul || is_saveMulFinish){ + if(ispauseclick && is_saveMul) + { + is_saveMul = false; + QMessageBox msgBox; + msgBox.setWindowTitle("Tips"); + msgBox.setText("Pause First Please!"); + msgBox.resize(2000, 1000); + msgBox.exec(); + continue; + } + + if(is_saveMulFinish){ + frameEnd = countbag; + std::string temFileStr = pcdFilePathStr; + temFileStr.resize(pcdFilePathStr.length() - 4); + std::string saveFilePathStr = temFileStr + "frame" \ + + std::to_string(frameStart) + "to" + std::to_string(frameEnd) + ".bag"; + std::cout << saveFilePathStr; + std::ifstream file(saveFilePathStr.c_str()); + if (!file.good()) { + + + newBag.open(saveFilePathStr, rosbag::bagmode::Write); + + + for(int i = frameStart; i < frameEnd; i++){ + + newBag.write("/scan", ros::Time::now(), indx[i]); + + + } + is_saveMulFinish = false; + is_saveMul = false; + saveFlag = false; + newBag.close(); + }else{ + + } + } + else{ + qDebug()<setSliderPosition(ceil(countbag/indxsize*100)); + qDebug()<value()/100)*indxsize; + double valuedouble = progress->value(); + countbag = round((valuedouble/100)*indxsize); + if(countbag >= indxsize)// 直接重新开始for循环 + { + countbag = indxsize-1; + progress->setSliderPosition(100); + ispauseclick = false; + } + ismoved = false; + } + else if(ischanged)// 手戳动时改变进度条 + { + end = false; + int value = (progress->value()/100)*indxsize; + double valuedouble = progress->value(); + countbag = round((valuedouble/100)*indxsize); + if(countbag >= indxsize)// 直接重新开始for循环 + { + countbag = indxsize-1; + progress->setSliderPosition(100); + ispauseclick = false; + } + scan_pub.publish(*indx[countbag]); + countbag++; + ischanged = false; + r.sleep(); + continue; + // ismoved = false; + } + if(!ispauseclick || end) + { + qDebug()<<"pause"; + if(countbagsliderPosition()<=100 && countbagvalue/indxsize*100<=100) + { + qDebug()<<"pause"; + progress->setSliderPosition(ceil(countbagvalue/indxsize*100)); + qDebug()<setSliderPosition(0); + isthreadplaying = false; + playagain = false; + filePath = QFileDialog::getOpenFileName(nullptr, "select file", "/home", "bag(*.bag);;所有文件 (*)"); + qDebug()<< filePath; + if(filePath.isEmpty()){ + QMessageBox msgBox; + msgBox.setWindowTitle("Tips"); + msgBox.setText("No file is selected"); + msgBox.resize(2000, 1000); + // 设置样式表,包括透明度设置 + msgBox.setStyleSheet("QMessageBox {" + "background-color: rgba(255, 255, 255, 0.9);" // 设置背景颜色和透明度 + "border: 2px solid rgba(0, 0, 0, 0.9);" // 设置边框颜色和透明度 + "}" + "QLabel {" + "color: rgba(0, 0, 0, 0.9);" // 设置文本颜色和透明度 + "font-size: 16px;" + "}"); + QTimer selectTimer; + selectTimer.setSingleShot(true); // 设置定时器只触发一次 + selectTimer.start(2000); // 3秒后触发定时器,单位是毫秒 + + //连接定时器的超时信号到关闭消息框的槽函数 + QObject::connect(&selectTimer, &QTimer::timeout, [&]() { + msgBox.done(QMessageBox::Ok); // 关闭消息框 + }); + msgBox.exec(); + }else{ + + QMessageBox msgBox; + msgBox.setWindowTitle("Tips"); + msgBox.setText("File selected"); + msgBox.resize(2000, 1000); + // 设置样式表,包括透明度设置 + msgBox.setStyleSheet("QMessageBox {" + "background-color: rgba(255, 255, 255, 0.9);" // 设置背景颜色和透明度 + "border: 2px solid rgba(0, 0, 0, 0.9);" // 设置边框颜色和透明度 + "}" + "QLabel {" + "color: rgba(0, 0, 0, 0.9);" // 设置文本颜色和透明度 + "font-size: 16px;" + "}"); + QTimer selectTimer; + selectTimer.setSingleShot(true); // 设置定时器只触发一次 + selectTimer.start(2000); // 3秒后触发定时器,单位是毫秒 + + //连接定时器的超时信号到关闭消息框的槽函数 + QObject::connect(&selectTimer, &QTimer::timeout, [&]() { + msgBox.done(QMessageBox::Ok); // 关闭消息框 + }); + msgBox.exec(); + isthreadplaying = true; + } +} + + +void MyViz::SpeedChanged(int index){ + // if(isthreadplaying) + bool ok; + double number = speed_name[index].toDouble(&ok); + if(ok){ + speed_rate = 10.0 * number; + qDebug() << "*************func test" << QString::number(speed_rate); + is_rateChanged = true; + } + + else{ + qDebug() << "failed"; + } } \ No newline at end of file diff --git a/librviz_tutorial/src/myviz.h b/librviz_tutorial/src/myviz.h old mode 100755 new mode 100644 index 3450cbb..f21942c --- a/librviz_tutorial/src/myviz.h +++ b/librviz_tutorial/src/myviz.h @@ -29,17 +29,31 @@ #ifndef MYVIZ_H #define MYVIZ_H + #include #include #include #include #include"std_msgs/String.h" #include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + namespace rviz { class Display; class RenderPanel; class VisualizationManager; +class ToolManager; +class PropertyTreeWidget; } // BEGIN_TUTORIAL @@ -52,6 +66,8 @@ public: virtual ~MyViz(); void subCallback(const std_msgs::String& msg); void pubThread(); + void PlayCircle(int index); // 圆圈线程执行函数 + rosbag::View *view; private Q_SLOTS: // QT信号和槽 void setThickness( int thickness_percent ); void setCellSize( int cell_size_percent ); @@ -64,18 +80,71 @@ private Q_SLOTS: // QT信号和槽 void GridColorChanged(int index); // 格栅颜色 void setFixedFrame(const QString &FixedFrame); void setBackgroundColor(const QString& bg_color); // 背景颜色 + void AxesDisplayChanged(int index); // axe + void CircleDisplayChanged(int index); // circle void Tree_Display(QGridLayout* layout, int index); + + void slot_select(); // 切换至select模式 + void slot_move_camera(); + + // off + double extractDuration(const QByteArray& output); + void selectFile(); + void SpeedChanged(int index); + void openFile(); private: rviz::VisualizationManager* manager_; // rviz::RenderPanel* render_panel_; + rviz::ToolManager* tool_manager_; rviz::Display* grid_; rviz::Display* cloud; - rviz::Display* laser; + rviz::Display* laser_; + rviz::Display* axes_display; + rviz::Display* marker_; + rviz::PropertyTreeWidget* tree_widget_ ; ros::NodeHandle nh; ros::Subscriber sub; ros::Publisher pub; std::thread pub_thread; std::vector color_name; // 颜色的名称集合 + QString color_icon_filename; + // off + bool isclicked;// 用于判断play第几次按下play键 + bool ispauseclick;// 用于判断暂停键第几次按下 + int count;// 用于记录timeout的次数 + bool sliderreleased;// 用于判断是否拖动了进度条 + bool playagain;// 用于检测是否多次按下play按钮 + bool isthreadplaying;// 用于标识线程是否在运行 + bool abs;// 用于单独开线程? + bool stored;// 用于存储一次容器,只在第一次play的时候存储容器 + bool is_pause = false; + bool is_reset = false; + bool is_end = false; + bool is_save = false; + bool is_saveMul = false; + bool is_bagClosed = true; + bool is_rateChanged = false; + bool is_openFile = false; + bool is_setFrameIndex = false; + bool is_saveMulFinish = false; + bool end = false; + bool threadout = false; + bool ischanged = false; + bool ismoved = false; + double speed_rate; + QSlider* progress; + QString filePath; + double duration; + int remain; + int prog_num = 0; + std::vector speed_name; + ros::Publisher scan_pub; + std::vector indx;// 存储节点信息 + int countbag;// 存储播放的具体位置 + double indxsize; + int test = 0; + + }; // END_TUTORIAL #endif // MYVIZ_H diff --git a/librviz_tutorial/src/node.cpp b/librviz_tutorial/src/node.cpp old mode 100755 new mode 100644