Skip to content

Commit

Permalink
code:追加代码
Browse files Browse the repository at this point in the history
  • Loading branch information
Natsu-Akatsuki committed Apr 7, 2024
1 parent 5a9a033 commit ba29357
Show file tree
Hide file tree
Showing 48 changed files with 4,847 additions and 0 deletions.
66 changes: 66 additions & 0 deletions code/ROS2/am_rviz_plugins/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: None
AlignOperands: Align
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 0
CompactNamespaces: false
ContinuationIndentWidth: 2
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Right
ReflowComments: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 2
UseTab: Never
5 changes: 5 additions & 0 deletions code/ROS2/am_rviz_plugins/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build
install
log
.idea
cmake-*
65 changes: 65 additions & 0 deletions code/ROS2/am_rviz_plugins/src/am_rviz_plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
cmake_minimum_required(VERSION 3.11)
project(am_rviz_plugins)

# >>> 通用配置 >>>
# 设置优化等级
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif ()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")

# 设置标准
set(CMAKE_CXX_STANDARD 17)

# 设置编译选项
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
set(CMAKE_AUTOMOC ON)

# >>> 导入三方包 >>>
find_package(Qt5 REQUIRED Core Widgets)
find_package(OpenCV REQUIRED)
find_package(FMT REQUIRED)

# >>> 导入 ROS 包 >>>
find_package(ament_cmake_auto REQUIRED)

# >>> 查找相关的依赖 >>>
ament_auto_find_build_dependencies()

# >>> 生成自定义消息类型 >>>
rosidl_generate_interfaces(${PROJECT_NAME}
msg/BoundingBox.msg
msg/BoundingBoxArray.msg
msg/OverlayMenu.msg
DEPENDENCIES
geometry_msgs std_msgs
)

# >>> 构建目标文件 >>>
ament_auto_add_library(rviz_plugins SHARED
src/log_panel.cpp
src/log_display.cpp
src/bounding_box_array_display.cpp
src/bounding_box_display.cpp
src/polar_grid_display.cpp
src/bev_controller.cpp
)

# This CMake code is only required when you want to use interfaces in the same package as the one in which they are defined.
rosidl_get_typesupport_target(cpp_typesupport_target ${PROJECT_NAME} "rosidl_typesupport_cpp")
target_link_libraries(rviz_plugins "${cpp_typesupport_target}")

# 指定第三方库依赖(等价于 target_link_library())
ament_target_dependencies(rviz_plugins
OpenCV
Qt5)

# 导出插件描述文件
pluginlib_export_plugin_description_file(rviz_common plugins/plugin_description.xml)

# >>> 导出相关的配置文件和进行安装 >>>
ament_auto_package(
INSTALL_TO_SHARE
icons
)
29 changes: 29 additions & 0 deletions code/ROS2/am_rviz_plugins/src/am_rviz_plugins/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# am_rviz_plugins

## Task

1)需求 1:基于 ROS2 C++ 创建一个名为 o3d_dashboard 的 RViz2 插件 \
2)需求 2:该 dashboard 订阅三维目标检测的日志信息,然后显示 TP(真阳)、FP(假阳:误检、定位不准)、FN(漏检)的个数

# Roadmap

- [ ] 在每个预测框身上追加类别 Logo、样本信息
- 包含:激光点个数、类别 ID、属性(GT,FP,FN)
- [ ] 读取 Text 文件并进行发布
- [ ] 追加背景色和前景色的修改
- [ ] 追加前进使用交叉线

- 可视化预测框和真值框
- [ ] 发布预测框和真值框
- [ ] 统计预测框、检测框、真阳、假阳、假阴的个数(单帧的效果)

## Install

```bash
$ sudo apt install libfmt-dev
```

- [ ] 添加类型不合适时的异常处理
- [ ] 清零后数据需要更新
- [ ] 对文本颜色进行修改
- [ ] 追加一个 filter 功能,可以选择显示哪些类别的框
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions code/ROS2/am_rviz_plugins/src/am_rviz_plugins/msg/BoundingBox.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#uint8 GT_GT=1 # 真值框(检出)
#uint8 FN_GT=2 # 真值框(漏检)
#uint8 TP_PRED=3 # 预测框(真阳)
#uint8 FP_PRED=4 # 预测框(假阳)

uint8 GT=1 # 真值框(检出)
uint8 FN=2 # 真值框(漏检)
uint8 TP=3 # 预测框(真阳)
uint8 FP=4 # 预测框(假阳)

# BoundingBox represents a oriented bounding box.
std_msgs/Header header
geometry_msgs/Pose pose
geometry_msgs/Vector3 dimensions # x, y, z 分别对应长、宽、高
float32 value # 得分
uint32 label # 类别信息
uint32 point_num # 激光点个数
uint8 attr # 框的属性
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# BoundingBoxArray is a list of BoundingBox.
std_msgs/Header header
BoundingBox[] boxes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
int32 ACTION_SELECT=0
int32 ACTION_CLOSE=1
int32 action
uint32 current_index
string[] menus
string title
std_msgs/ColorRGBA bg_color
std_msgs/ColorRGBA fg_color
34 changes: 34 additions & 0 deletions code/ROS2/am_rviz_plugins/src/am_rviz_plugins/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<package format="3">
<name>am_rviz_plugins</name>
<version>0.0.1</version>
<description>rviz2 plugins</description>

<maintainer email="[email protected]">Your Name</maintainer>

<license>TODO</license>

<!-- Build and export dependencies. -->
<buildtool_depend>ament_cmake_auto</buildtool_depend>
<member_of_group>rosidl_interface_packages</member_of_group>

<buildtool_depend>rosidl_default_generators</buildtool_depend>
<exec_depend>rosidl_default_runtime</exec_depend>

<depend>rclcpp</depend>
<depend>rviz_common</depend>
<depend>rviz_default_plugins</depend>
<depend>rviz_rendering</depend>
<depend>qtbase5-dev</depend>
<depend>sensor_msgs</depend>
<depend>std_msgs</depend>
<depend>geometry_msgs</depend>
<depend>libopencv-dev</depend>
<exec_depend>rosidl_default_runtime</exec_depend>
<exec_depend>libqt5-core</exec_depend>
<exec_depend>libqt5-gui</exec_depend>
<exec_depend>libqt5-widgets</exec_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<library path="rviz_plugins">
<class name="rviz_plugins/LogPanels"
type="rviz_plugins::LogPanels"
base_class_type="rviz_common::Panel">
<description>rviz panel for 3D object detection</description>
</class>
<class name="rviz_plugins/LogDisplay"
type="rviz_plugins::LogDisplay"
base_class_type="rviz_common::Display">
<description>...</description>
</class>
<class name="rviz_plugins/PolarGridDisplay"
type="rviz_plugins::PolarGridDisplay"
base_class_type="rviz_common::Display">
<description>...</description>
</class>
<class name="rviz_plugins/OverlayMenuDisplay"
type="rviz_plugins::OverlayMenuDisplay"
base_class_type="rviz_common::Display">
<description>...</description>
</class>
<class name="rviz_plugins/BoundingBoxArrayDisplay"
type="rviz_plugins::BoundingBoxArrayDisplay"
base_class_type="rviz_common::Display">
<description>...</description>
</class>
<class name="rviz_plugins/BoundingBoxDisplay"
type="rviz_plugins::BoundingBoxDisplay"
base_class_type="rviz_common::Display">
<description>...</description>
</class>
<class name="rviz_plugins/PointCloud3Display"
type="rviz_plugins::PointCloud3Display"
base_class_type="rviz_common::Display">
<description>...</description>
</class>
<class name="rviz_plugins/BEVController"
type="view_controllers::BEVController"
base_class_type="rviz_common::ViewController">
<description>...</description>
</class>
</library>
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import rclpy
from am_rviz_plugins_msgs.msg import BoundingBox, BoundingBoxArray
from rclpy.node import Node
from rclpy.qos import QoSDurabilityPolicy, QoSProfile


class MyNode(Node):
def __init__(self):
super().__init__("bounding_box_sample")
timer_period = 0.2 # 单位:秒
self.timer = self.create_timer(timer_period, self.timer_callback)
self.counter = 0
latching_qos = QoSProfile(depth=1, durability=QoSDurabilityPolicy.TRANSIENT_LOCAL)
self.pub = self.create_publisher(BoundingBoxArray, "bounding_box_array", qos_profile=latching_qos)

def timer_callback(self):
box_a = BoundingBox()
box_b = BoundingBox()
box_a.label = 2
box_b.label = 5
box_arr = BoundingBoxArray()
now = self.get_clock().now().to_msg()
box_a.header.stamp = now
box_b.header.stamp = now
box_arr.header.stamp = now
box_a.header.frame_id = "map"
box_b.header.frame_id = "map"
box_arr.header.frame_id = "map"
q = [0.0, 0.0, 0.0, 1.0]
box_a.pose.orientation.x = q[0]
box_a.pose.orientation.y = q[1]
box_a.pose.orientation.z = q[2]
box_a.pose.orientation.w = q[3]
box_b.pose.orientation.w = 1.0
box_b.pose.position.y = 2.0
box_b.dimensions.x = (self.counter % 10 + 1) * 0.1
box_b.dimensions.y = ((self.counter + 1) % 10 + 1) * 0.1
box_b.dimensions.z = ((self.counter + 2) % 10 + 1) * 0.1
box_a.dimensions.x = 1.0
box_a.dimensions.y = 1.0
box_a.dimensions.z = 1.0
box_a.value = (self.counter % 100) / 100.0
box_b.value = 1 - (self.counter % 100) / 100.0
box_arr.boxes.append(box_a)
box_arr.boxes.append(box_b)
self.pub.publish(box_arr)
self.counter = self.counter + 1


def main(args=None):
rclpy.init(args=args)
node = MyNode()
rclpy.spin(node)
node.destroy_node()
rclpy.shutdown()


if __name__ == '__main__':
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
DatasetParam:
# description (mandatory): 数据集的文件夹路径
dataset_dir: "/home/helios/mnt/dataset/Kitti/object/"
# description (optional): 相对于 dataset_dir 的子目录,存放图像数据
img_dir: "training/image_2"
# description (optional): 相对于 dataset_dir 的子目录,存放点云数据
pc_dir: "training/velodyne"
# description (optional): 相对于 dataset_dir 的子目录,存放真值标签
gt_label_dir: "training/label_2"
# description (optional): 相对于 dataset_dir 的子目录,存放标定文件
cal_dir: "training/calib"
# description (optional): 相对于 dataset_dir 的子目录,存放 split 文件,
# 可从https://github.com/open-mmlab/OpenPCDet/tree/master/data/kitti/ImageSets 处下载
split_file: "ImageSets/val.txt"
pred_label_dir: "/home/helios/Github/shenlan memo/Pointcloud/classSix/other/kitti_eval/result_dir/data/"


AlgorithmParam:
# description (optional):直通滤波的相关参数 x_min, x_max, y_min, y_max, z_min, z_max
limit_range: [0.0, 70.4, -40.0, 40.0, -3.0, 1.0]
# description (optional): 自动还是手动触发显示数据(终端按回车键触发下一帧)True or False
auto_update: False
# description (optional): 单位(秒)
update_time: 0.1
# description (optional): 是否只显示相机视野内的点云
apply_fov_filter: True

ROSParam:
# description: 发布的主题所绑定的坐标系
frame_id: "velodyne"

Loading

0 comments on commit ba29357

Please sign in to comment.