Skip to content

Commit

Permalink
refactor(bytetrack): fix namespace and directory structure (autowaref…
Browse files Browse the repository at this point in the history
…oundation#8125)

* chore: fix namespace

Signed-off-by: yoshiri <[email protected]>

* chore: change include name

Signed-off-by: yoshiri <[email protected]>

* refactor: rename perception/bytetrack to perception/autoware_bytetrack

Signed-off-by: Taekjin LEE <[email protected]>

* refactor: fix node exe

Signed-off-by: Taekjin LEE <[email protected]>

---------

Signed-off-by: yoshiri <[email protected]>
Signed-off-by: Taekjin LEE <[email protected]>
Co-authored-by: Taekjin LEE <[email protected]>
  • Loading branch information
YoshiRi and technolojin authored Jul 25, 2024
1 parent d4ce122 commit 4ef61d7
Show file tree
Hide file tree
Showing 22 changed files with 48 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ perception/autoware_radar_fusion_to_detected_object/** [email protected] s
perception/autoware_radar_object_clustering/** [email protected] [email protected] [email protected] [email protected]
perception/autoware_radar_object_tracker/** [email protected] [email protected] [email protected]
perception/autoware_tracking_object_merger/** [email protected] [email protected] [email protected]
perception/bytetrack/** [email protected] [email protected]
perception/autoware_bytetrack/** [email protected] [email protected]
perception/autoware_cluster_merger/** [email protected] [email protected] [email protected]
perception/autoware_compare_map_segmentation/** [email protected] [email protected] [email protected]
perception/autoware_detected_object_feature_remover/** [email protected]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5)
project(bytetrack)
project(autoware_bytetrack)

find_package(autoware_cmake REQUIRED)
autoware_package()
Expand All @@ -16,20 +16,20 @@ find_package(Boost REQUIRED)
#
# Core library
#
file(GLOB bytetrack_lib_src
file(GLOB project_lib_src
"lib/src/*.cpp"
)

ament_auto_add_library(bytetrack_lib SHARED
${bytetrack_lib_src}
ament_auto_add_library(${PROJECT_NAME}_lib SHARED
${project_lib_src}
)

target_include_directories(bytetrack_lib
target_include_directories(${PROJECT_NAME}_lib
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(bytetrack_lib
target_link_libraries(${PROJECT_NAME}_lib
Eigen3::Eigen
yaml-cpp
)
Expand Down Expand Up @@ -72,8 +72,8 @@ target_compile_definitions(${PROJECT_NAME}_node PRIVATE
)

rclcpp_components_register_node(${PROJECT_NAME}_node
PLUGIN "bytetrack::ByteTrackNode"
EXECUTABLE ${PROJECT_NAME}_node_exe
PLUGIN "autoware::bytetrack::ByteTrackNode"
EXECUTABLE bytetrack_node_exe
)

#
Expand All @@ -88,8 +88,8 @@ ament_target_dependencies(${PROJECT_NAME}_visualizer
)

rclcpp_components_register_node(${PROJECT_NAME}_visualizer
PLUGIN "bytetrack::ByteTrackVisualizerNode"
EXECUTABLE ${PROJECT_NAME}_visualizer_node_exe
PLUGIN "autoware::bytetrack::ByteTrackVisualizerNode"
EXECUTABLE bytetrack_visualizer_node_exe
)

ament_auto_package(INSTALL_TO_SHARE
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef BYTETRACK__BYTETRACK_HPP_
#define BYTETRACK__BYTETRACK_HPP_
#ifndef AUTOWARE__BYTETRACK__BYTETRACK_HPP_
#define AUTOWARE__BYTETRACK__BYTETRACK_HPP_

#include "byte_tracker.h"
#include "strack.h"
Expand All @@ -28,7 +28,7 @@
#include <string>
#include <vector>

namespace bytetrack
namespace autoware::bytetrack
{
struct Object
{
Expand Down Expand Up @@ -57,6 +57,6 @@ class ByteTrack
ObjectArray latest_objects_;
};

} // namespace bytetrack
} // namespace autoware::bytetrack

#endif // BYTETRACK__BYTETRACK_HPP_
#endif // AUTOWARE__BYTETRACK__BYTETRACK_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef BYTETRACK__BYTETRACK_NODE_HPP_
#define BYTETRACK__BYTETRACK_NODE_HPP_
#ifndef AUTOWARE__BYTETRACK__BYTETRACK_NODE_HPP_
#define AUTOWARE__BYTETRACK__BYTETRACK_NODE_HPP_

#include <bytetrack/bytetrack.hpp>
#include <autoware/bytetrack/bytetrack.hpp>
#include <rclcpp/rclcpp.hpp>

#include <tier4_perception_msgs/msg/detected_objects_with_feature.hpp>
Expand All @@ -34,7 +34,7 @@
#include <string>
#include <vector>

namespace bytetrack
namespace autoware::bytetrack
{
using LabelMap = std::map<int, std::string>;

Expand All @@ -55,9 +55,9 @@ class ByteTrackNode : public rclcpp::Node

rclcpp::TimerBase::SharedPtr timer_;

std::unique_ptr<bytetrack::ByteTrack> bytetrack_;
std::unique_ptr<autoware::bytetrack::ByteTrack> bytetrack_;
};

} // namespace bytetrack
} // namespace autoware::bytetrack

#endif // BYTETRACK__BYTETRACK_NODE_HPP_
#endif // AUTOWARE__BYTETRACK__BYTETRACK_NODE_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef BYTETRACK__BYTETRACK_VISUALIZER_NODE_HPP_
#define BYTETRACK__BYTETRACK_VISUALIZER_NODE_HPP_
#ifndef AUTOWARE__BYTETRACK__BYTETRACK_VISUALIZER_NODE_HPP_
#define AUTOWARE__BYTETRACK__BYTETRACK_VISUALIZER_NODE_HPP_

#include <image_transport/image_transport.hpp>
#include <image_transport/subscriber_filter.hpp>
Expand All @@ -35,7 +35,7 @@
#include <string>
#include <vector>

namespace bytetrack
namespace autoware::bytetrack
{
// A helper class to generate bright color instance
class ColorMapper
Expand Down Expand Up @@ -99,6 +99,6 @@ class ByteTrackVisualizerNode : public rclcpp::Node
bool use_raw_;
ColorMapper color_map_;
};
} // namespace bytetrack
} // namespace autoware::bytetrack

#endif // BYTETRACK__BYTETRACK_VISUALIZER_NODE_HPP_
#endif // AUTOWARE__BYTETRACK__BYTETRACK_VISUALIZER_NODE_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
<arg name="in_image_compressed" default="$(var in_image)/compressed"/>
<arg name="detection_rect" default="/perception/object_recognition/detection/rois0"/>
<arg name="tracked_rect" default="/perception/object_recognition/detection/tracked/rois0"/>
<arg name="bytetrack_param_path" default="$(find-pkg-share bytetrack)/config/bytetrack.param.yaml"/>
<arg name="bytetrack_visualizer_param_path" default="$(find-pkg-share bytetrack)/config/bytetrack.param.yaml"/>
<arg name="bytetrack_param_path" default="$(find-pkg-share autoware_bytetrack)/config/bytetrack.param.yaml"/>
<arg name="bytetrack_visualizer_param_path" default="$(find-pkg-share autoware_bytetrack)/config/bytetrack.param.yaml"/>
<arg name="enable_visualizer" default="true"/>

<node pkg="bytetrack" exec="bytetrack_node_exe" output="screen">
<node pkg="autoware_bytetrack" exec="bytetrack_node_exe" output="screen">
<remap from="~/in/rect" to="$(var detection_rect)"/>
<remap from="~/out/objects" to="$(var tracked_rect)"/>
<remap from="~/out/objects/debug/uuid" to="$(var tracked_rect)/debug/uuid"/>
<param from="$(var bytetrack_param_path)"/>
</node>

<node pkg="bytetrack" exec="bytetrack_visualizer_node_exe" output="screen" if="$(var enable_visualizer)">
<node pkg="autoware_bytetrack" exec="bytetrack_visualizer_node_exe" output="screen" if="$(var enable_visualizer)">
<remap from="~/in/image" to="$(var in_image)"/>
<remap from="~/in/rect" to="$(var tracked_rect)"/>
<remap from="~/in/uuid" to="$(var tracked_rect)/debug/uuid"/>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ STrack::STrack(std::vector<float> input_tlwh, float score, int label)

// load static kf parameters: initialized once in program
const std::string package_share_directory =
ament_index_cpp::get_package_share_directory("bytetrack");
ament_index_cpp::get_package_share_directory("autoware_bytetrack");
const std::string default_config_path =
package_share_directory + "/config/kalman_filter.param.yaml";
if (!_parameters_loaded) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>bytetrack</name>
<name>autoware_bytetrack</name>
<version>0.0.1</version>
<description>ByteTrack implementation ported toward Autoware</description>
<maintainer email="[email protected]">Manato HIRABAYASHI</maintainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <bytetrack/bytetrack.hpp>
#include <autoware/bytetrack/bytetrack.hpp>

#include <algorithm>
#include <fstream>
#include <functional>

namespace bytetrack
namespace autoware::bytetrack
{
ByteTrack::ByteTrack(const int track_buffer_length)
{
Expand Down Expand Up @@ -66,4 +66,4 @@ ObjectArray ByteTrack::update_tracker(ObjectArray & input_objects)
do_inference(input_objects);
return latest_objects_;
}
} // namespace bytetrack
} // namespace autoware::bytetrack
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "bytetrack/bytetrack.hpp"

#include <bytetrack/bytetrack_node.hpp>
#include <autoware/bytetrack/bytetrack.hpp>
#include <autoware/bytetrack/bytetrack_node.hpp>
#include <rclcpp/qos.hpp>

#include "autoware_perception_msgs/msg/object_classification.hpp"
Expand All @@ -24,7 +23,7 @@
#include <utility>
#include <vector>

namespace bytetrack
namespace autoware::bytetrack
{
ByteTrackNode::ByteTrackNode(const rclcpp::NodeOptions & node_options)
: Node("bytetrack", node_options)
Expand All @@ -34,7 +33,7 @@ ByteTrackNode::ByteTrackNode(const rclcpp::NodeOptions & node_options)

int track_buffer_length = declare_parameter("track_buffer_length", 30);

this->bytetrack_ = std::make_unique<bytetrack::ByteTrack>(track_buffer_length);
this->bytetrack_ = std::make_unique<autoware::bytetrack::ByteTrack>(track_buffer_length);

timer_ =
rclcpp::create_timer(this, get_clock(), 100ms, std::bind(&ByteTrackNode::on_connect, this));
Expand Down Expand Up @@ -80,7 +79,7 @@ void ByteTrackNode::on_rect(
object_array.emplace_back(obj);
}

bytetrack::ObjectArray objects = bytetrack_->update_tracker(object_array);
autoware::bytetrack::ObjectArray objects = bytetrack_->update_tracker(object_array);
for (const auto & tracked_object : objects) {
tier4_perception_msgs::msg::DetectedObjectWithFeature object;
// fit xy offset to 0 if roi is outside of image
Expand Down Expand Up @@ -115,7 +114,7 @@ void ByteTrackNode::on_rect(
out_objects_uuid.header = msg->header;
objects_uuid_pub_->publish(out_objects_uuid);
}
} // namespace bytetrack
} // namespace autoware::bytetrack

#include "rclcpp_components/register_node_macro.hpp"
RCLCPP_COMPONENTS_REGISTER_NODE(bytetrack::ByteTrackNode)
RCLCPP_COMPONENTS_REGISTER_NODE(autoware::bytetrack::ByteTrackNode)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "bytetrack/bytetrack_visualizer_node.hpp"
#include "autoware/bytetrack/bytetrack_visualizer_node.hpp"

#include <boost/lexical_cast.hpp>
#include <boost/uuid/uuid_io.hpp>
Expand All @@ -26,7 +26,7 @@
#include <chrono>
#include <string>

namespace bytetrack
namespace autoware::bytetrack
{

ByteTrackVisualizerNode::ByteTrackVisualizerNode(const rclcpp::NodeOptions & node_options)
Expand Down Expand Up @@ -190,7 +190,7 @@ void ByteTrackVisualizerNode::draw(
}
}

} // namespace bytetrack
} // namespace autoware::bytetrack

#include "rclcpp_components/register_node_macro.hpp"
RCLCPP_COMPONENTS_REGISTER_NODE(bytetrack::ByteTrackVisualizerNode)
RCLCPP_COMPONENTS_REGISTER_NODE(autoware::bytetrack::ByteTrackVisualizerNode)

0 comments on commit 4ef61d7

Please sign in to comment.