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
Add nodelets of tlr nodes (#715)
* Add classifier nodelet

Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>

* Replace boost::shared_ptr into std::shared_ptr

Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>

* Add lock guard

Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>

* Add detetcor nodelet

Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>

* Integrate main into node

Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>

* Add SubscriberStatusCallback

Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>

* add image_transport_decompresser nodelet

Signed-off-by: Yukihiro Saito <yukky.saito@gmail.com>

* Add visualizer nodelet

Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>

* fixed bug

Signed-off-by: Yukihiro Saito <yukky.saito@gmail.com>

* Fix plugin name

Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>

* Launch nodelet

Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>

* Fix classifier constructor

Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>

* add decompresser node

Signed-off-by: Yukihiro Saito <yukky.saito@gmail.com>

* fix typo

Signed-off-by: Yukihiro Saito <yukky.saito@gmail.com>

* fixed bug

Signed-off-by: Yukihiro Saito <yukky.saito@gmail.com>

* fixed bug

Signed-off-by: Yukihiro Saito <yukky.saito@gmail.com>

* cosmetic change

Signed-off-by: Yukihiro Saito <yukky.saito@gmail.com>

* add param

Signed-off-by: Yukihiro Saito <yukky.saito@gmail.com>

* fix bug

Signed-off-by: Yukihiro Saito <yukky.saito@gmail.com>

* Fix build warning

Signed-off-by: Daisuke Nishimatsu <border_goldenmarket@yahoo.co.jp>

* change rgb

Signed-off-by: Yukihiro Saito <yukky.saito@gmail.com>

* change rgb

Signed-off-by: Yukihiro Saito <yukky.saito@gmail.com>

Co-authored-by: Yukihiro Saito <yukky.saito@gmail.com>
  • Loading branch information
2 people authored and 1222-takeshi committed Dec 2, 2021
commit 4a02612acb35b5e631c882904931bfc405fc75a3
64 changes: 58 additions & 6 deletions perception/traffic_light_classifier/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ find_package(catkin REQUIRED COMPONENTS
image_transport
message_filters
dynamic_reconfigure
nodelet
)

generate_dynamic_reconfigure_options(cfg/HSVFilter.cfg)
Expand Down Expand Up @@ -131,30 +132,55 @@ if(TRT_AVAIL AND CUDA_AVAIL AND CUDNN_AVAIL)
add_dependencies(libutils
${catkin_EXPORTED_TARGETS})

add_executable(traffic_light_classifier_node
add_library(traffic_light_classifier_nodelet SHARED
src/color_classifier.cpp
src/cnn_classifier.cpp
src/nodelet.cpp
)

add_dependencies(traffic_light_classifier_nodelet
${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
)

target_link_libraries(traffic_light_classifier_nodelet
libutils
${catkin_LIBRARIES}
${OpenCV_LIBRARIES}
)

add_executable(traffic_light_classifier_node
src/node.cpp
src/main.cpp
)

add_dependencies(traffic_light_classifier_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}
add_dependencies(traffic_light_classifier_node
${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
)

target_link_libraries(traffic_light_classifier_node
libutils
traffic_light_classifier_nodelet
${catkin_LIBRARIES}
${OpenCV_LIBRARIES}
)

install(
TARGETS
traffic_light_classifier_node
traffic_light_classifier_nodelet
libutils
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

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

install(
DIRECTORY
launch
Expand All @@ -177,27 +203,53 @@ else()
CATKIN_DEPENDS
)

add_executable(traffic_light_classifier_node
add_library(traffic_light_classifier_nodelet SHARED
src/color_classifier.cpp
src/nodelet.cpp
)

add_dependencies(traffic_light_classifier_nodelet
${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
)

target_link_libraries(traffic_light_classifier_nodelet
libutils
${catkin_LIBRARIES}
${OpenCV_LIBRARIES}
)

add_executable(traffic_light_classifier_node
src/node.cpp
src/main.cpp
)

add_dependencies(traffic_light_classifier_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}
add_dependencies(traffic_light_classifier_node
${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
)

target_link_libraries(traffic_light_classifier_node
libutils
traffic_light_classifier_nodelet
${catkin_LIBRARIES}
${OpenCV_LIBRARIES}
)

install(
TARGETS
traffic_light_classifier_node
traffic_light_classifier_nodelet
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

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

install(
DIRECTORY
launch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ namespace traffic_light
class CNNClassifier : public ClassifierInterface
{
public:
CNNClassifier();
~CNNClassifier(){};
explicit CNNClassifier(const ros::NodeHandle & nh, const ros::NodeHandle & pnh);

bool getLampState(
const cv::Mat & input_image,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ namespace traffic_light
class ColorClassifier : public ClassifierInterface
{
public:
ColorClassifier();
~ColorClassifier(){};
explicit ColorClassifier(const ros::NodeHandle & nh, const ros::NodeHandle & pnh);

bool getLampState(
const cv::Mat & input_image,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#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 <sensor_msgs/Image.h>
#include <sensor_msgs/image_encodings.h>
Expand All @@ -43,14 +45,18 @@
#include <opencv2/highgui/highgui.hpp>

#include <memory>
#include <mutex>

namespace traffic_light
{
class TrafficLightClassifierNode
class TrafficLightClassifierNodelet : public nodelet::Nodelet
{
public:
TrafficLightClassifierNode();
virtual ~TrafficLightClassifierNode(){};
virtual void onInit();
void connectCb();
void imageRoiCallback(
const sensor_msgs::ImageConstPtr & input_image_msg,
const autoware_perception_msgs::TrafficLightRoiArrayConstPtr & input_rois_msg);

private:
enum ClassifierType {
Expand All @@ -60,25 +66,23 @@ class TrafficLightClassifierNode

ros::NodeHandle nh_;
ros::NodeHandle pnh_;
image_transport::ImageTransport image_transport_;
std::shared_ptr<image_transport::ImageTransport> image_transport_;
image_transport::SubscriberFilter image_sub_;
message_filters::Subscriber<autoware_perception_msgs::TrafficLightRoiArray> roi_sub_;
typedef message_filters::sync_policies::ExactTime<
sensor_msgs::Image, autoware_perception_msgs::TrafficLightRoiArray>
SyncPolicy;
typedef message_filters::Synchronizer<SyncPolicy> Sync;
Sync sync_;
std::shared_ptr<Sync> sync_;
typedef message_filters::sync_policies::ApproximateTime<
sensor_msgs::Image, autoware_perception_msgs::TrafficLightRoiArray>
ApproximateSyncPolicy;
typedef message_filters::Synchronizer<ApproximateSyncPolicy> ApproximateSync;
ApproximateSync approximate_sync_;
std::shared_ptr<ApproximateSync> approximate_sync_;
bool is_approximate_sync_;
std::mutex connect_mutex_;
ros::Publisher tl_states_pub_;
std::shared_ptr<ClassifierInterface> classifier_ptr_;
void imageRoiCallback(
const sensor_msgs::ImageConstPtr & input_image_msg,
const autoware_perception_msgs::TrafficLightRoiArrayConstPtr & input_rois_msg);
};

} // namespace traffic_light
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
<arg name="input/image" default="image_raw" />
<arg name="input/rois" default="rois" />
<arg name="output/traffic_light_states" default="traffic_light_states" />
<arg name="manager" default="traffic_light_recognition_nodelet_manager" />

<arg name="use_gpu" default="false" />
<!-- classifier_type {hsv_filter: 0, cnn: 1} -->
<arg name="classifier_type" default="1" if="$(arg use_gpu)"/>
<arg name="classifier_type" default="0" unless="$(arg use_gpu)"/>

<node name="traffic_light_classifier" pkg="traffic_light_classifier" type="traffic_light_classifier_node" output="screen">
<node pkg="nodelet" type="nodelet" name="traffic_light_classifier" args="load traffic_light/traffic_light_classifier $(arg manager)">
<remap from="~input/image" to="$(arg input/image)" />
<remap from="~input/rois" to="$(arg input/rois)" />
<remap from="~output/traffic_light_states" to="$(arg output/traffic_light_states)" />
Expand Down
6 changes: 4 additions & 2 deletions perception/traffic_light_classifier/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,27 @@
<build_depend>image_transport</build_depend>
<build_depend>message_filters</build_depend>
<build_depend>dynamic_reconfigure</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>image_transport</build_export_depend>
<build_export_depend>message_filters</build_export_depend>
<build_export_depend>dynamic_reconfigure</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>image_transport</exec_depend>
<exec_depend>message_filters</exec_depend>
<exec_depend>dynamic_reconfigure</exec_depend>
<exec_depend>nodelet</exec_depend>


<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->

<nodelet plugin="${prefix}/traffic_light_classifier.xml" />
</export>
</package>
9 changes: 5 additions & 4 deletions perception/traffic_light_classifier/src/cnn_classifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

namespace traffic_light
{
CNNClassifier::CNNClassifier() : nh_(""), pnh_("~"), image_transport_(pnh_)
CNNClassifier::CNNClassifier(const ros::NodeHandle & nh, const ros::NodeHandle & pnh)
: nh_(nh), pnh_(pnh), image_transport_(pnh_)
{
image_pub_ = image_transport_.advertise("output/debug/image", 1);

Expand Down Expand Up @@ -119,7 +120,7 @@ void CNNClassifier::outputDebugImage(
cv::vconcat(debug_image, text_img, debug_image);

sensor_msgs::ImagePtr debug_image_msg =
cv_bridge::CvImage(std_msgs::Header(), "bgr8", debug_image).toImageMsg();
cv_bridge::CvImage(std_msgs::Header(), "rgb8", debug_image).toImageMsg();
image_pub_.publish(debug_image_msg);
}

Expand All @@ -128,7 +129,7 @@ void CNNClassifier::preProcess(cv::Mat & image, float * input_tensor, bool norma
/* normalize */
/* ((channel[0] / 255) - mean[0]) / std[0] */

cv::cvtColor(image, image, cv::COLOR_BGR2RGB, 3);
// cv::cvtColor(image, image, cv::COLOR_BGR2RGB, 3);
cv::resize(image, image, cv::Size(input_w_, input_h_));

const size_t strides_cv[3] = {static_cast<size_t>(input_w_ * input_c_),
Expand Down Expand Up @@ -174,7 +175,7 @@ bool CNNClassifier::postProcess(
boost::algorithm::split(splited_label, match_label, boost::is_any_of(","));
for (auto label : splited_label) {
if (label2state_.find(label) == label2state_.end()) {
ROS_DEBUG("cnn_classifier does not have a key [%s]", label);
ROS_DEBUG("cnn_classifier does not have a key [%s]", label.c_str());
continue;
}
autoware_perception_msgs::LampState state;
Expand Down
5 changes: 3 additions & 2 deletions perception/traffic_light_classifier/src/color_classifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@

namespace traffic_light
{
ColorClassifier::ColorClassifier()
: nh_(""), pnh_("~"), image_transport_(pnh_), ratio_threshold_(0.02)
ColorClassifier::ColorClassifier(const ros::NodeHandle & nh, const ros::NodeHandle & pnh)
: nh_(nh), pnh_(pnh), image_transport_(pnh), ratio_threshold_(0.02)
{
image_transport_ = image_transport::ImageTransport(pnh_);
image_pub_ = image_transport_.advertise("debug/image", 1);
dynamic_reconfigure_.setCallback(boost::bind(&ColorClassifier::parametersCallback, this, _1, _2));
}
Expand Down
25 changes: 0 additions & 25 deletions perception/traffic_light_classifier/src/main.cpp

This file was deleted.

Loading