diff --git a/README.md b/README.md index fd90ec8b0b9a250ad65c3bacedfa200646682f62..00cceab71b9a49a0961de081c1f84a86fafb77b4 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,12 @@ mviz_plugin是包含MViz(一款华为自研的可视化工具软件)、规控ST图(包括车辆第一次ST折线图、车辆优化后的ST折线图、ST空间限速信息、多障碍物实时ST空间信息)、规控二维曲线图(包括UTM轨迹跟踪图、里程-方向盘角度跟踪曲线、纵向位置曲线(时间-里程)、纵向速度曲线(时间-纵向速度)等)和规控SLT图(车辆优化后的SLT折线图、SLT空间限速信息、多障碍物实时SLT空间信息)的可视化插件。 # 编译和安装 -当前插件在Ubuntu 18.04 LTS的环境中验证发布,CMake最低版本为3.10。 +当前插件在Ubuntu 18.04 LTS和Ubuntu 20.04 LTS的环境中验证发布,CMake最低版本为3.10。 **1. 初始化ROS工作空间** - 请先参考[ROS官方提供的指导文档](http://wiki.ros.org/melodic/Installation/Ubuntu)在Ubuntu里安装ROS Melodic。 + 请根据Ubuntu版本,参考ROS的官方文档安装对应版本的ROS + Ubuntu18:[Melodic](http://wiki.ros.org/melodic/Installation/Ubuntu) + Ubuntu20:[Noetic](http://wiki.ros.org/noetic/Installation/Ubuntu) - 1.1 新建并初始化ROS工作空间catkin_ws。 ``` mkdir -p ~/workspace/catkin_ws/src diff --git a/chart_plugin/CMakeLists.txt b/chart_plugin/CMakeLists.txt index 20966375c44b1db20c364a611113250959c5e13e..a49fa8126abcdd5458026ae998dca731cce1461b 100755 --- a/chart_plugin/CMakeLists.txt +++ b/chart_plugin/CMakeLists.txt @@ -20,20 +20,19 @@ set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_ALL_OPTIONS} -fno-sized-deallocation") add_custom_target(CustomMsgDependency) -add_subdirectory(src/common) -set(ROS_VERSION melodic) -set(CI_ENV OFF) -set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};/opt/ros/${ROS_VERSION};/usr/lib/x86_64-linux-gnu/cmake/Qt5;${CMAKE_BINARY_DIR}/third_party/sysroot/opt/ros/melodic;${CMAKE_BINARY_DIR}/third_party/qt/5.9.5/gcc_64/lib/cmake/Qt5") +set(ROS_VERSION "$ENV{ROS_DISTRO}") +if("$ENV{ROS_DISTRO}" STREQUAL "noetic") + add_compile_definitions(NOETIC) +endif() + +set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};/opt/ros/${ROS_VERSION};/usr/lib/x86_64-linux-gnu/cmake/Qt5;${CMAKE_BINARY_DIR}/third_party/sysroot/opt/ros/${ROS_VERSION};${CMAKE_BINARY_DIR}/third_party/qt/5.9.5/gcc_64/lib/cmake/Qt5") if (EXISTS ${CMAKE_BINARY_DIR}/third_party/sysroot/usr/include/OGRE/RenderSystems/GL/) set(_qt5gui_OPENGL_INCLUDE_DIR "${CMAKE_BINARY_DIR}/third_party/sysroot/usr/include/OGRE/RenderSystems/GL") - set(CI_ENV ON) endif () -if (NOT CI_ENV) - find_package(catkin REQUIRED COMPONENTS roscpp rviz std_msgs) -endif () +find_package(catkin REQUIRED COMPONENTS roscpp rviz std_msgs) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) @@ -42,9 +41,7 @@ set(CMAKE_BUILD_TYPE "Release") find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui) set(QT_LIBRARIES Qt5::Widgets) -if (NOT CI_ENV) - catkin_package(CATKIN_DEPENDS roscpp rviz std_msgs) -endif () +catkin_package(CATKIN_DEPENDS roscpp rviz std_msgs) set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/st_space_display.cpp @@ -64,7 +61,7 @@ link_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../third_party/qwt-6.1.4/qwt-6.1.4/build/lib/ ${catkin_LIBRARY_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/../third_party/mathgl-2.4.4/mathgl-2.4.4/build/lib/ - ${CMAKE_BINARY_DIR}/third_party/sysroot/opt/ros/melodic/lib) + ${CMAKE_BINARY_DIR}/third_party/sysroot/opt/ros/${ROS_VERSION}/lib) add_library(${PROJECT_NAME} ${SOURCE_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/resource/res.qrc) add_dependencies(${PROJECT_NAME} CustomMsgDependency) @@ -77,9 +74,9 @@ target_include_directories(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/../third_party/qwt-6.1.4/qwt-6.1.4/build/include/ ${catkin_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/../third_party/mathgl-2.4.4/mathgl-2.4.4/build/include/ - ${CMAKE_CURRENT_BINARY_DIR}/src/common/ - ${CMAKE_BINARY_DIR}/third_party/sysroot/opt/ros/melodic/include - ${CMAKE_BINARY_DIR}/third_party/sysroot/opt/ros/melodic/include/rviz + ${CMAKE_BINARY_DIR}/../devel/include/ + ${CMAKE_BINARY_DIR}/third_party/sysroot/opt/ros/${ROS_VERSION}/include + ${CMAKE_BINARY_DIR}/third_party/sysroot/opt/ros/${ROS_VERSION}/include/rviz ${CMAKE_BINARY_DIR}/third_party/sysroot/usr/include/OGRE ${CMAKE_BINARY_DIR}/third_party/class_loader/include ${CMAKE_BINARY_DIR}/third_party/console_bridge/include diff --git a/chart_plugin/src/common/CMakeLists.txt b/chart_plugin/src/common/CMakeLists.txt deleted file mode 100755 index 53846760ef102dc5ce2dfeb7c2243b88119d3de8..0000000000000000000000000000000000000000 --- a/chart_plugin/src/common/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# 生成感知和规控的自定义消息 -include(${CMAKE_ROOT}/Modules/ExternalProject.cmake) - -set(ROS_VERSION melodic) -ExternalProject_Add(GenCustomMsg - URL ${CMAKE_CURRENT_SOURCE_DIR}/custom - SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/custom - CONFIGURE_COMMAND cp -fr ${CMAKE_CURRENT_SOURCE_DIR}/custom/ ${CMAKE_CURRENT_BINARY_DIR}/ - BUILD_COMMAND /usr/bin/python2.7 ${CMAKE_CURRENT_SOURCE_DIR}/gen_msg.py ${ROS_VERSION} ${CMAKE_CURRENT_BINARY_DIR}/../../ - BUILD_IN_SOURCE 1 - INSTALL_COMMAND "" - TEST_COMMAND "") -add_dependencies(CustomMsgDependency GenCustomMsg) \ No newline at end of file diff --git a/chart_plugin/src/common/chart_display_base.h b/chart_plugin/src/common/chart_display_base.h index 8a971f74438cce6b00247ef2e9bfb059582e5754..93b0fbd318966d002eae56e87476d89a1df2e9c9 100755 --- a/chart_plugin/src/common/chart_display_base.h +++ b/chart_plugin/src/common/chart_display_base.h @@ -39,6 +39,9 @@ public: QString messageType = QString::fromStdString(ros::message_traits::datatype()); topic_property_->setMessageType(messageType); topic_property_->setDescription(messageType + " topic to subscribe to."); +#ifdef NOETIC + queue_size_property_->setHidden(true); +#endif } virtual ~ChartDisplayBase() @@ -183,6 +186,19 @@ protected: reset(); } +#ifdef NOETIC + /* + * 在noetic版本的rviz中,父类rviz::_RosTopicDisplay新增了以下两个纯虚函数 + * 由于曲线插件不会用到这两个函数,所以实现为空 + */ + + void updateQueueSize() override + {} + + void processTypeErasedMessage(boost::shared_ptr type_erased_msg) override + {} +#endif + using ChartDisplayClass = ChartDisplayBase; message_filters::Subscriber sub {}; diff --git a/chart_plugin/src/common/gen_msg.py b/chart_plugin/src/common/gen_msg.py deleted file mode 100755 index 5cf5d5c60c1e52be75d0553ade5c766833b3dd25..0000000000000000000000000000000000000000 --- a/chart_plugin/src/common/gen_msg.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -""" -Copyright Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. -""" -import glob -import os -import sys -import genmsg.template_tools - - -def pre_process_ros_msg(ros_version, build_fold): - """ - 功能描述:编译ros的msg - """ - package_name = 'custom' - - # 开发环境上的模板所在路径 - template_dir = os.path.join('/', 'opt', 'ros', ros_version, 'share', - 'gencpp') - if not os.path.exists(template_dir): - # CI环境上的模板所在路径 - template_dir = os.path.join('/', 'opt', 'buildtools', 'gencpp-0.6.3', - 'gencpp-0.6.3', 'scripts') - - # 开发环境上的msg所在路径 - msg_path = os.path.join('/', 'opt', 'ros', ros_version, 'share') - if not os.path.exists(msg_path): - # CI环境上的msg所在路径 - msg_path = os.path.join(build_fold, 'third_party', - 'sysroot', 'opt', 'ros', ros_version, 'share') - - custom_msg_dir = os.path.join(build_fold, 'src', 'common', - 'custom') - std_msgs_path = os.path.join(msg_path, 'std_msgs', 'msg') - geometry_msgs_path = os.path.join(msg_path, 'geometry_msgs', 'msg') - msg_include_path = ['custom:%s' % custom_msg_dir, - 'std_msgs:%s' % std_msgs_path, - 'geometry_msgs:%s' % geometry_msgs_path] - - msg_template_map = {'msg.h.template': '@NAME@.h'} - srv_template_map = {'srv.h.template': '@NAME@.h'} - - if not os.path.exists(custom_msg_dir): - print('[Error] %s not exists' % custom_msg_dir) - return 1 - - for file_name in glob.glob(os.path.join(custom_msg_dir, '*.msg')): - print('[Info] %s was used to generate ros header ' % file_name) - genmsg.template_tools.generate_from_file( - file_name, package_name, custom_msg_dir, template_dir, - msg_include_path, msg_template_map, srv_template_map) - - return 0 - - -if __name__ == "__main__": - pre_process_ros_msg(sys.argv[1], sys.argv[2]) diff --git a/custom/CMakeLists.txt b/custom/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..5605f297a037e2ae98a2c728e058184dd6d0fec1 --- /dev/null +++ b/custom/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 2.8.3) + +project(custom) + +find_package(catkin REQUIRED COMPONENTS + std_msgs + message_generation +) + +add_message_files( + FILES + PlotData.msg + PlotPoint.msg + SltPoint.msg + SltSpace.msg + StPoint.msg + StSpace.msg +) + +generate_messages( + DEPENDENCIES + std_msgs +) + +catkin_package( + CATKIN_DEPENDS + std_msgs +) + +include_directories( + ${catkin_INCLUDE_DIRS} +) \ No newline at end of file diff --git a/chart_plugin/src/common/custom/PlotData.msg b/custom/msg/PlotData.msg old mode 100755 new mode 100644 similarity index 100% rename from chart_plugin/src/common/custom/PlotData.msg rename to custom/msg/PlotData.msg diff --git a/chart_plugin/src/common/custom/PlotPoint.msg b/custom/msg/PlotPoint.msg old mode 100755 new mode 100644 similarity index 100% rename from chart_plugin/src/common/custom/PlotPoint.msg rename to custom/msg/PlotPoint.msg diff --git a/chart_plugin/src/common/custom/SltPoint.msg b/custom/msg/SltPoint.msg old mode 100755 new mode 100644 similarity index 100% rename from chart_plugin/src/common/custom/SltPoint.msg rename to custom/msg/SltPoint.msg diff --git a/chart_plugin/src/common/custom/SltSpace.msg b/custom/msg/SltSpace.msg old mode 100755 new mode 100644 similarity index 100% rename from chart_plugin/src/common/custom/SltSpace.msg rename to custom/msg/SltSpace.msg diff --git a/chart_plugin/src/common/custom/StPoint.msg b/custom/msg/StPoint.msg old mode 100755 new mode 100644 similarity index 100% rename from chart_plugin/src/common/custom/StPoint.msg rename to custom/msg/StPoint.msg diff --git a/chart_plugin/src/common/custom/StSpace.msg b/custom/msg/StSpace.msg old mode 100755 new mode 100644 similarity index 100% rename from chart_plugin/src/common/custom/StSpace.msg rename to custom/msg/StSpace.msg diff --git a/custom/package.xml b/custom/package.xml new file mode 100644 index 0000000000000000000000000000000000000000..8047da6fd369bc5c87d83f270176f5c5ff466a60 --- /dev/null +++ b/custom/package.xml @@ -0,0 +1,17 @@ + + + custom + 0.0.0 + The custom msgs package + MDC + BSD + MViz + + catkin + std_msgs + message_generation + + std_msgs + message_generation + +