Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add traffic_light_recognition packages #94

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
ed1f838
release v0.4.0
mitsudome-r Sep 18, 2020
d773bdd
check if gdown command exists (#707)
harihitode Jul 21, 2020
4a02612
Add nodelets of tlr nodes (#715)
wep21 Jul 30, 2020
6bd655e
remove libutils dependency when unable gpu (#761)
Aug 13, 2020
7d1fd21
Fix typo cliped -> clipped (#776)
kosuke55 Aug 16, 2020
e900a8b
install launch when disable gpu (#829)
Aug 25, 2020
54ec7a4
change raw pointer to vector and shared_ptr (#817)
Aug 26, 2020
f46c1a4
Fix/cublas dependency (#849)
yukkysaito Aug 28, 2020
26fdb4c
remove ROS1 packages temporarily
mitsudome-r Sep 29, 2020
6adc13b
Revert "remove ROS1 packages temporarily"
mitsudome-r Oct 8, 2020
2ae39ee
add COLCON_IGNORE to ros1 packages
mitsudome-r Oct 8, 2020
eb2348c
Rename launch files to launch.xml (#28)
nnmm Oct 15, 2020
03b3991
Port traffic light classifier (#70)
mitsudome-r Nov 5, 2020
64e0727
[traffic_light_ssd_fine_detector] port to ROS2 (#113)
mitsudome-r Nov 24, 2020
a7516a2
Ros2 port traffic light map (#99)
simon-t4 Nov 26, 2020
f2d7db9
Convert calls of Duration to Duration::from_seconds where appropriate…
nnmm Nov 30, 2020
02c1cf2
Rename h files to hpp (#142)
nnmm Dec 3, 2020
45e736a
Adjust copyright notice on 532 out of 699 source files (#143)
nnmm Dec 3, 2020
04957ea
Use quotes for includes where appropriate (#144)
nnmm Dec 7, 2020
a35c670
fixing trasient_local in ROS2 packages (#160)
nik-tier4 Dec 11, 2020
c476ca5
adding linters in traffic_light_map_based_detector (#179)
nik-tier4 Dec 15, 2020
bb9aad1
traffic_light_classifier: Fix engine save dir (#250)
wep21 Jan 13, 2021
284bae5
traffic light map based detector: Fix launch (#253)
wep21 Jan 19, 2021
c5df6d4
Ros2 v0.8.0 traffic light map based detector (#262)
wep21 Jan 17, 2021
078470e
Ros2 v0.8.0 traffic light classifier (#261)
wep21 Jan 17, 2021
9078aa7
Ros2 v0.8.0 traffic light ssd fine detector (#260)
wep21 Jan 17, 2021
86b5b03
Rename ROS-related .yaml to .param.yaml (#352)
kenji-miyake Feb 24, 2021
a79bc54
Ros2 v0.8.0 beta rm std msgs ssd traffic light (#395) (#400)
mitsudome-r Mar 4, 2021
20d97bd
add use_sim-time option (#454)
tkimura4 Mar 26, 2021
576a207
Fix rolling build errors (#1225)
kenji-miyake Apr 5, 2021
3855283
Sync public repo (#1228)
mitsudome-r Apr 5, 2021
59c93aa
Unify Apache-2.0 license name (#1242)
kmiya Apr 15, 2021
a7f2e61
Remove use_sim_time for set_parameter (#1260)
wep21 Apr 26, 2021
06f79d5
handle wrong route (#1312)
wep21 May 18, 2021
39a0d60
Dealing with wrong image size (#1320)
wep21 May 18, 2021
7f34e1f
Perception components (#1368)
wep21 May 26, 2021
e4bea3d
Use sensor data qos for traffic light recognition (#1440)
wep21 Jun 9, 2021
5efba2d
Fix/ssd fine detector (#1421) (#1468)
wep21 Jun 15, 2021
9f7a101
Feature/tl map based detector ros2 (#1475)
wep21 Jun 16, 2021
5ae9a38
Add pre-commit (#1560)
KeisukeShima Jul 19, 2021
5729382
Fix build error with TensorRT v8 (#1612)
wep21 Jul 19, 2021
ecd678f
Add markdownlint and prettier (#1661)
kenji-miyake Jul 20, 2021
5e5869e
suppress warnings for declare parameters (#1724)
h-ohta Jul 28, 2021
cafc24b
suppress warnings for traffic light classifier (#1762)
h-ohta Aug 3, 2021
3a0cf42
Fix -Wunused-parameter (#1836)
kenji-miyake Aug 14, 2021
c57e859
Fix compiler warnings (#1837)
kenji-miyake Aug 15, 2021
90eda50
Fix clang warnings (#1859)
kenji-miyake Aug 16, 2021
b25297c
Invoke code formatter at pre-commit (#1935)
IshitaTakeshi Sep 1, 2021
042302d
add sort-package-xml hook in pre-commit (#1881)
KeisukeShima Sep 9, 2021
bd7058e
Fix readme traffic light map based detector (#2282)
kminoda Oct 25, 2021
0b6a506
Change formatter to clang-format and black (#2332)
kenji-miyake Nov 2, 2021
b705ae9
Add COLCON_IGNORE (#500)
kenji-miyake Nov 4, 2021
eba1558
[traffic_light_ssd_fine_detector] support autoware auto msgs (#514)
Nov 8, 2021
de89cb2
[traffic_light_map_based_detector] support autoware auto msgs (#511)
Nov 8, 2021
5f9b554
[traffic_light_classifier] support autoware auto msgs (#504)
Nov 10, 2021
2de4c77
update README of traffic_light_classifier (#649)
yukke42 Nov 16, 2021
0340445
add readme for traffic light ssd fine detector (#637)
Nov 17, 2021
e0ec56b
declare variable before subscriber registration (#705)
Nov 18, 2021
b2ac2b6
update traffic light classifier readme (#726)
Nov 24, 2021
f695283
Update traffic light topic name (#729)
wep21 Nov 25, 2021
9b7a8e3
Merge branch 'tier4/proposal' into 1-add-traffic-light-recognition-pa…
taikitanaka3 Dec 3, 2021
e82bf5a
Merge branch 'tier4/proposal' into 1-add-traffic-light-recognition-pa…
tkimura4 Dec 3, 2021
ff8e0aa
Apply suggestions from code review
tkimura4 Dec 3, 2021
b011ab3
Apply suggestions from code review
tkimura4 Dec 3, 2021
7f4470a
Merge branch 'tier4/proposal' into 1-add-traffic-light-recognition-pa…
tkimura4 Dec 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[traffic_light_ssd_fine_detector] port to ROS2 (#113)
Signed-off-by: mitsudome-r <ryohsuke.mitsudome@tier4.jp>
  • Loading branch information
mitsudome-r authored and 1222-takeshi committed Dec 2, 2021
commit 64e072763b7b51b097feeb5631333e6faf73cc56
92 changes: 21 additions & 71 deletions perception/traffic_light_ssd_fine_detector/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
cmake_minimum_required(VERSION 3.0.2)
cmake_minimum_required(VERSION 3.5)

add_compile_options(-std=c++14)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

project(traffic_light_ssd_fine_detector)

option(CUDA_VERBOSE "Verbose output of CUDA modules" OFF)

find_package(catkin REQUIRED COMPONENTS
cv_bridge
roscpp
image_transport
message_filters
sensor_msgs
std_msgs
autoware_perception_msgs
nodelet
)
find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()

find_package(OpenCV REQUIRED)

Expand Down Expand Up @@ -102,22 +101,14 @@ endif()

if(TRT_AVAIL AND CUDA_AVAIL AND CUDNN_AVAIL)
include_directories(
include
${Opencv_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
${CUDA_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
)

catkin_package(
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
CATKIN_DEPENDS
)

set(CMAKE_CXX_FLAGS "-O2 -Wall -Wunused-variable ${CMAKE_CXX_FLAGS} -fpic -std=c++11 -pthread")

### ssd ###
add_library(ssd
ament_auto_add_library(ssd
lib/src/trt_ssd.cpp
)

Expand All @@ -135,67 +126,26 @@ if(TRT_AVAIL AND CUDA_AVAIL AND CUDNN_AVAIL)
${CUDNN_LIBRARY}
)

add_library(traffic_light_ssd_fine_detector_nodelet SHARED
ament_auto_add_library(traffic_light_ssd_fine_detector_nodelet SHARED
src/nodelet.cpp
)

add_dependencies(traffic_light_ssd_fine_detector_nodelet
${catkin_EXPORTED_TARGETS}
)

target_link_libraries(traffic_light_ssd_fine_detector_nodelet
${catkin_LIBRARIES}
${OpenCV_LIBS}
${OpenCV_LIB}
ssd
)

add_executable(traffic_light_ssd_fine_detector_node
src/node.cpp
rclcpp_components_register_node(traffic_light_ssd_fine_detector_nodelet
PLUGIN "traffic_light::TrafficLightSSDFineDetectorNodelet"
EXECUTABLE traffic_light_ssd_fine_detector_node
)

target_link_libraries(traffic_light_ssd_fine_detector_node
traffic_light_ssd_fine_detector_nodelet
${catkin_LIBRARIES}
${OpenCV_LIBS}
ssd
)

add_dependencies(traffic_light_ssd_fine_detector_node
${catkin_EXPORTED_TARGETS}
)

install(TARGETS
traffic_light_ssd_fine_detector_node
traffic_light_ssd_fine_detector_nodelet
ssd
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

install(
FILES
traffic_light_ssd_fine_detector.xml
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

install(
DIRECTORY
launch
data
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
ament_auto_package(INSTALL_TO_SHARE
data
launch
)

else()
find_package(catkin REQUIRED)
catkin_package()
message("TrafficLightSSDFineDetector won't be built, CUDA and/or TensorRT were not found.")

install(
DIRECTORY
launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

endif()

Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,26 @@
#include <mutex>
#include <string>

#include <opencv/cv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

#include "trt_ssd.h"

#include <image_transport/image_transport.h>
#include <image_transport/subscriber_filter.h>
#include <image_transport/image_transport.hpp>
#include <image_transport/subscriber_filter.hpp>
#include <message_filters/subscriber.h>
#include <message_filters/sync_policies/approximate_time.h>
#include <message_filters/synchronizer.h>
#include <message_filters/time_synchronizer.h>
#include <nodelet/nodelet.h>
#include <pluginlib/class_list_macros.h>
#include <ros/ros.h>
#include <rclcpp/rclcpp.hpp>

#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/image_encodings.h>
#include <std_msgs/Float32.h>
#include <std_msgs/Header.h>
#include <sensor_msgs/msg/image.hpp>
#include <sensor_msgs/image_encodings.hpp>
#include <std_msgs/msg/float32.hpp>
#include <std_msgs/msg/header.hpp>

#include <autoware_perception_msgs/TrafficLightRoiArray.h>
#include <autoware_perception_msgs/msg/traffic_light_roi_array.hpp>

typedef struct Detection
{
Expand All @@ -53,45 +50,45 @@ typedef struct Detection

namespace traffic_light
{
class TrafficLightSSDFineDetectorNodelet : public nodelet::Nodelet
class TrafficLightSSDFineDetectorNodelet : public rclcpp::Node
{
public:
virtual void onInit();
TrafficLightSSDFineDetectorNodelet(const rclcpp::NodeOptions & options);
void connectCb();
void callback(
const sensor_msgs::Image::ConstPtr & image_msg,
const autoware_perception_msgs::TrafficLightRoiArray::ConstPtr & traffic_light_roi_msg);
const sensor_msgs::msg::Image::ConstSharedPtr image_msg,
const autoware_perception_msgs::msg::TrafficLightRoiArray::ConstSharedPtr traffic_light_roi_msg);

private:
bool cvMat2CnnInput(
const std::vector<cv::Mat> & in_imgs, const int num_rois, std::vector<float> & data);
bool cnnOutput2BoxDetection(
const float * scores, const float * boxes, const int tlr_id,
const std::vector<cv::Mat> & in_imgs, const int num_rois, std::vector<Detection> & detctions);
bool rosMsg2CvMat(const sensor_msgs::Image::ConstPtr & image_msg, cv::Mat & image);
bool rosMsg2CvMat(const sensor_msgs::msg::Image::ConstSharedPtr image_msg, cv::Mat & image);
bool fitInFrame(cv::Point & lt, cv::Point & rb, const cv::Size & size);
void cvRect2TlRoiMsg(
const cv::Rect & rect, const int32_t id, autoware_perception_msgs::TrafficLightRoi & tl_roi);
const cv::Rect & rect, const int32_t id, autoware_perception_msgs::msg::TrafficLightRoi & tl_roi);
bool readLabelFile(std::string filepath, std::vector<std::string> & labels);
bool getTlrIdFromLabel(const std::vector<std::string> & labels, int & tlr_id);

// variables
ros::NodeHandle nh_, pnh_;
std::shared_ptr<image_transport::ImageTransport> image_transport_;
image_transport::SubscriberFilter image_sub_;
message_filters::Subscriber<autoware_perception_msgs::TrafficLightRoiArray> roi_sub_;
message_filters::Subscriber<autoware_perception_msgs::msg::TrafficLightRoiArray> roi_sub_;
std::mutex connect_mutex_;
ros::Publisher output_roi_pub_;
ros::Publisher exe_time_pub_;
rclcpp::Publisher<autoware_perception_msgs::msg::TrafficLightRoiArray>::SharedPtr output_roi_pub_;
rclcpp::Publisher<std_msgs::msg::Float32>::SharedPtr exe_time_pub_;
rclcpp::TimerBase::SharedPtr timer_;

typedef message_filters::sync_policies::ExactTime<
sensor_msgs::Image, autoware_perception_msgs::TrafficLightRoiArray>
sensor_msgs::msg::Image, autoware_perception_msgs::msg::TrafficLightRoiArray>
SyncPolicy;
typedef message_filters::Synchronizer<SyncPolicy> Sync;
std::shared_ptr<Sync> sync_;

typedef message_filters::sync_policies::ApproximateTime<
sensor_msgs::Image, autoware_perception_msgs::TrafficLightRoiArray>
sensor_msgs::msg::Image, autoware_perception_msgs::msg::TrafficLightRoiArray>
ApproximateSyncPolicy;
typedef message_filters::Synchronizer<ApproximateSyncPolicy> ApproximateSync;
std::shared_ptr<ApproximateSync> approximate_sync_;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<launch>

<arg name="onnx_file" default="$(find traffic_light_ssd_fine_detector)/data/mb2-ssd-lite-tlr.onnx"/>
<arg name="label_file" default="$(find traffic_light_ssd_fine_detector)/data/voc_labels_tl.txt"/>
<arg name="onnx_file" default="$(find-pkg-share traffic_light_ssd_fine_detector)/data/mb2-ssd-lite-tlr.onnx"/>
<arg name="label_file" default="$(find-pkg-share traffic_light_ssd_fine_detector)/data/voc_labels_tl.txt"/>
<arg name="mode" default="FP32"/>
<arg name="input/image" default="/image_raw"/>
<arg name="input/rois" default="/traffic_light_map_based_detector/output/rois" />
Expand All @@ -14,24 +14,24 @@
<arg name="save_rough_roi_image" default="false"/>
<arg name="manager" default="traffic_light_recognition_nodelet_manager"/>

<node pkg="nodelet" type="nodelet" name="traffic_light_ssd_fine_detector" args="load traffic_light/traffic_light_ssd_fine_detector $(arg manager)">
<remap from="input/image" to="$(arg input/image)" />
<remap from="~input/rois" to="$(arg input/rois)" />
<remap from="~output/rois" to="$(arg output/rois)" />
<param name="onnx_file" type="str" value="$(arg onnx_file)"/>
<param name="label_file" type="str" value="$(arg label_file)"/>
<param name="mode" type="str" value="$(arg mode)"/>
<param name="score_thresh" value="$(arg score_thresh)"/>
<param name="max_batch_size" value="$(arg max_batch_size)"/>
<param name="approximate_sync" value="$(arg approximate_sync)"/>
<rosparam param="mean" subst_value="True">$(arg mean)</rosparam>
<rosparam param="std" subst_value="True">$(arg std)</rosparam>
<node pkg="traffic_light_ssd_fine_detector" exec="traffic_light_ssd_fine_detector_node" name="traffic_light_ssd_fine_detector">
<remap from="input/image" to="$(var input/image)" />
<remap from="input/rois" to="$(var input/rois)" />
<remap from="output/rois" to="$(var output/rois)" />
<param name="onnx_file" type="str" value="$(var onnx_file)"/>
<param name="label_file" type="str" value="$(var label_file)"/>
<param name="mode" type="str" value="$(var mode)"/>
<param name="score_thresh" value="$(var score_thresh)"/>
<param name="max_batch_size" value="$(var max_batch_size)"/>
<param name="approximate_sync" value="$(var approximate_sync)"/>
<param name="mean" value="$(var mean)" />
<param name="std" value="$(var std)" />
</node>

<node if="$(eval save_rough_roi_image)" pkg="roi_image_saver" type="traffic_light_roi_image_saver_node" name="$(anon traffic_light_roi_image_saver)" output="screen">
<remap from="~input/image" to="$(arg input/image)"/>
<remap from="~input/rois" to="$(arg input/rois)"/>
<param name="save_dir" value="$(find roi_image_saver)/train_image"/>
<node if="$(var save_rough_roi_image)" pkg="roi_image_saver" exec="traffic_light_roi_image_saver_node" name="$(anon traffic_light_roi_image_saver)" output="screen">
<remap from="input/image" to="$(var input/image)"/>
<remap from="input/rois" to="$(var input/rois)"/>
<param name="save_dir" value="$(find-pkg-share roi_image_saver)/train_image"/>
<param name="save_rate" value="1.0"/>
</node>
</launch>
33 changes: 11 additions & 22 deletions perception/traffic_light_ssd_fine_detector/package.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0"?>
<package format="2">
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>traffic_light_ssd_fine_detector</name>
<version>0.1.0</version>
<description>The traffic_light_ssd_fine_detector package</description>
Expand All @@ -15,30 +16,18 @@
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>Apache 2</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>

<buildtool_depend>catkin</buildtool_depend>
<build_depend>autoware_perception_msgs</build_depend>
<build_depend>cv_bridge</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>message_filters</build_depend>
<build_depend>nodelet</build_depend>
<build_export_depend>autoware_perception_msgs</build_export_depend>
<build_export_depend>cv_bridge</build_export_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>sensor_msgs</build_export_depend>
<build_export_depend>message_filters</build_export_depend>
<build_export_depend>nodelet</build_export_depend>
<exec_depend>autoware_perception_msgs</exec_depend>
<exec_depend>cv_bridge</exec_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<exec_depend>message_filters</exec_depend>
<exec_depend>nodelet</exec_depend>

<depend>autoware_perception_msgs</depend>
<depend>cv_bridge</depend>
<depend>image_transport</depend>
<depend>rclcpp</depend>
<depend>rclcpp_components</depend>
<depend>sensor_msgs</depend>
<depend>message_filters</depend>

<!-- The export tag contains other, unspecified, tags -->
<export>
<nodelet plugin="${prefix}/traffic_light_ssd_fine_detector.xml" />
<build_type>ament_cmake</build_type>
</export>
</package>
34 changes: 0 additions & 34 deletions perception/traffic_light_ssd_fine_detector/src/node.cpp

This file was deleted.

Loading