Skip to content

Commit e69b61d

Browse files
refactor(multi_object_tracker): internal message driven process (#10203)
* refactor(multi_object_tracker): streamline input channel configuration handling feat(multi_object_tracker): introduce InputChannel struct for input channel configuration refactor(multi_object_tracker): improve marker handling and initialization in TrackerObjectDebugger feat(multi_object_tracker): enhance InputChannel with trust flags for object properties refactor(multi_object_tracker): remove unused channel_size parameter from tracker constructors feat(multi_object_tracker): update InputChannel flags to trust object extension and classification fix(multi_object_tracker): replace channel.index with channel_index for consistency feat(multi_object_tracker): update TrackerObjectDebugger and TrackerProcessor to accept channels_config parameter refactor(multi_object_tracker): remove redundant existence probability initialization from tracker constructors feat(multi_object_tracker): integrate data association into TrackerProcessor and add associate method feat(multi_object_tracker): enhance updateWithMeasurement to include channel_info for improved classification handling refactor(multi_object_tracker): replace object_id with uuid in DynamicObject and related classes fix(multi_object_tracker): update UUID handling in Tracker to use uuid_msg for consistency refactor(multi_object_tracker): simplify pose and covariance handling in tracker classes refactor(multi_object_tracker): replace pose_with_covariance with separate pose and covariance attributes in DynamicObject refactor: remove z state from tracker. it will uses object state refactor(multi_object_tracker): streamline object handling in trackers and remove unnecessary shape processing refactor(multi_object_tracker): remove z position handling from trackers and update object kinematics structure refactor(multi_object_tracker): remove BoundingBox structure from trackers and implement object extension limits refactor(multi_object_tracker): remove unnecessary blank lines in tracker getTrackedObject methods refactor(multi_object_tracker): simplify input channel configuration by removing trust flags and consolidating parameters Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp> * refactor(multi_object_tracker): use const reference in loop and simplify tracker update logic Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp> * refactor(multi_object_tracker): update shape handling and streamline object tracking logic Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp> * refactor(multi_object_tracker): update shape handling to use geometry_msgs::msg::Point for anchor vectors Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp> * style(pre-commit): autofix Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp> * refactor(multi_object_tracker): modify getNearestCornerOrSurface function signature and update related logic Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp> refactor(multi_object_tracker): remove self_transform parameter from measure and update methods refactor(multi_object_tracker): update calcAnchorPointOffset function signature and streamline object handling refactor(multi_object_tracker): set shape type to BOUNDING_BOX for object trackers --------- Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 1fcbfc4 commit e69b61d

37 files changed

+749
-1109
lines changed

perception/autoware_multi_object_tracker/include/autoware/multi_object_tracker/association/association.hpp

+18-5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@
3636

3737
namespace autoware::multi_object_tracker
3838
{
39+
struct AssociatorConfig
40+
{
41+
std::vector<int> can_assign_matrix;
42+
std::vector<double> max_dist_matrix;
43+
std::vector<double> max_area_matrix;
44+
std::vector<double> min_area_matrix;
45+
std::vector<double> max_rad_matrix;
46+
std::vector<double> min_iou_matrix;
47+
};
48+
3949
class DataAssociation
4050
{
4151
private:
@@ -50,17 +60,20 @@ class DataAssociation
5060

5161
public:
5262
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
53-
DataAssociation(
54-
std::vector<int> can_assign_vector, std::vector<double> max_dist_vector,
55-
std::vector<double> max_area_vector, std::vector<double> min_area_vector,
56-
std::vector<double> max_rad_vector, std::vector<double> min_iou_vector);
63+
explicit DataAssociation(const AssociatorConfig & config);
64+
virtual ~DataAssociation() {}
65+
5766
void assign(
5867
const Eigen::MatrixXd & src, std::unordered_map<int, int> & direct_assignment,
5968
std::unordered_map<int, int> & reverse_assignment);
69+
70+
double calculateScore(
71+
const types::DynamicObject & tracked_object, const std::uint8_t tracker_label,
72+
const types::DynamicObject & measurement_object, const std::uint8_t measurement_label) const;
73+
6074
Eigen::MatrixXd calcScoreMatrix(
6175
const types::DynamicObjectList & measurements,
6276
const std::list<std::shared_ptr<Tracker>> & trackers);
63-
virtual ~DataAssociation() {}
6477
};
6578

6679
} // namespace autoware::multi_object_tracker

perception/autoware_multi_object_tracker/include/autoware/multi_object_tracker/object_model/shapes.hpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
//
15-
//
16-
// Author: v1.0 Taekjin Lee
1714

1815
#ifndef AUTOWARE__MULTI_OBJECT_TRACKER__OBJECT_MODEL__SHAPES_HPP_
1916
#define AUTOWARE__MULTI_OBJECT_TRACKER__OBJECT_MODEL__SHAPES_HPP_
@@ -40,13 +37,12 @@ bool convertConvexHullToBoundingBox(
4037
bool getMeasurementYaw(
4138
const types::DynamicObject & object, const double & predicted_yaw, double & measurement_yaw);
4239

43-
int getNearestCornerOrSurface(
44-
const double x, const double y, const double yaw, const double width, const double length,
45-
const geometry_msgs::msg::Transform & self_transform);
40+
void getNearestCornerOrSurface(
41+
const geometry_msgs::msg::Transform & self_transform, types::DynamicObject & object);
4642

4743
void calcAnchorPointOffset(
48-
const double w, const double l, const int indx, const types::DynamicObject & input_object,
49-
const double & yaw, types::DynamicObject & offset_object, Eigen::Vector2d & tracking_offset);
44+
const types::DynamicObject & this_object, Eigen::Vector2d & tracking_offset,
45+
types::DynamicObject & offset_object);
5046
} // namespace shapes
5147
} // namespace autoware::multi_object_tracker
5248

perception/autoware_multi_object_tracker/include/autoware/multi_object_tracker/object_model/types.hpp

+32-7
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
//
15-
//
16-
// Author: v1.0 Taekjin Lee
1714

1815
#ifndef AUTOWARE__MULTI_OBJECT_TRACKER__OBJECT_MODEL__TYPES_HPP_
1916
#define AUTOWARE__MULTI_OBJECT_TRACKER__OBJECT_MODEL__TYPES_HPP_
@@ -25,6 +22,7 @@
2522
#include <autoware_perception_msgs/msg/shape.hpp>
2623
#include <autoware_perception_msgs/msg/tracked_object.hpp>
2724
#include <autoware_perception_msgs/msg/tracked_object_kinematics.hpp>
25+
#include <geometry_msgs/msg/point.hpp>
2826
#include <geometry_msgs/msg/polygon.hpp>
2927
#include <geometry_msgs/msg/pose_with_covariance.hpp>
3028
#include <geometry_msgs/msg/twist_with_covariance.hpp>
@@ -34,12 +32,27 @@
3432

3533
#include <boost/optional.hpp>
3634

35+
#include <string>
3736
#include <vector>
3837

3938
namespace autoware::multi_object_tracker
4039
{
4140
namespace types
4241
{
42+
// constants
43+
constexpr size_t max_channel_size = 16;
44+
45+
// channel configuration
46+
struct InputChannel
47+
{
48+
uint index; // index of the channel
49+
std::string input_topic; // topic name of the detection, e.g. "/detection/lidar"
50+
std::string long_name = "Detected Object"; // full name of the detection
51+
std::string short_name = "DET"; // abbreviation of the name
52+
bool is_spawn_enabled = true; // enable spawn of the object
53+
};
54+
55+
// object model
4356
enum OrientationAvailability : uint8_t {
4457
UNAVAILABLE = 0,
4558
SIGN_UNKNOWN = 1,
@@ -48,8 +61,6 @@ enum OrientationAvailability : uint8_t {
4861

4962
struct ObjectKinematics
5063
{
51-
geometry_msgs::msg::PoseWithCovariance pose_with_covariance;
52-
geometry_msgs::msg::TwistWithCovariance twist_with_covariance;
5364
bool has_position_covariance = false;
5465
OrientationAvailability orientation_availability;
5566
bool has_twist = false;
@@ -58,12 +69,27 @@ struct ObjectKinematics
5869

5970
struct DynamicObject
6071
{
61-
unique_identifier_msgs::msg::UUID object_id = unique_identifier_msgs::msg::UUID();
72+
// identification
73+
unique_identifier_msgs::msg::UUID uuid = unique_identifier_msgs::msg::UUID();
74+
75+
// existence information
6276
uint channel_index;
6377
float existence_probability;
78+
std::vector<float> existence_probabilities;
79+
80+
// object classification
6481
std::vector<autoware_perception_msgs::msg::ObjectClassification> classification;
82+
83+
// object kinematics (pose and twist)
6584
ObjectKinematics kinematics;
85+
geometry_msgs::msg::Pose pose;
86+
std::array<double, 36> pose_covariance;
87+
geometry_msgs::msg::Twist twist;
88+
std::array<double, 36> twist_covariance;
89+
90+
// object extension (size and shape)
6691
autoware_perception_msgs::msg::Shape shape;
92+
geometry_msgs::msg::Point anchor_point;
6793
};
6894

6995
struct DynamicObjectList
@@ -82,7 +108,6 @@ DynamicObjectList toDynamicObjectList(
82108
autoware_perception_msgs::msg::TrackedObject toTrackedObjectMsg(const DynamicObject & dyn_object);
83109

84110
} // namespace types
85-
86111
} // namespace autoware::multi_object_tracker
87112

88113
#endif // AUTOWARE__MULTI_OBJECT_TRACKER__OBJECT_MODEL__TYPES_HPP_

perception/autoware_multi_object_tracker/include/autoware/multi_object_tracker/tracker/model/bicycle_tracker.hpp

+2-21
Original file line numberDiff line numberDiff line change
@@ -32,40 +32,21 @@ namespace autoware::multi_object_tracker
3232
class BicycleTracker : public Tracker
3333
{
3434
private:
35-
types::DynamicObject object_;
3635
rclcpp::Logger logger_;
3736

3837
object_model::ObjectModel object_model_ = object_model::bicycle;
3938

40-
double z_;
41-
42-
struct BoundingBox
43-
{
44-
double length;
45-
double width;
46-
double height;
47-
};
48-
BoundingBox bounding_box_;
49-
5039
BicycleMotionModel motion_model_;
5140
using IDX = BicycleMotionModel::IDX;
5241

5342
public:
54-
BicycleTracker(
55-
const rclcpp::Time & time, const types::DynamicObject & object, const size_t channel_size);
43+
BicycleTracker(const rclcpp::Time & time, const types::DynamicObject & object);
5644

5745
bool predict(const rclcpp::Time & time) override;
58-
bool measure(
59-
const types::DynamicObject & object, const rclcpp::Time & time,
60-
const geometry_msgs::msg::Transform & self_transform) override;
46+
bool measure(const types::DynamicObject & object, const rclcpp::Time & time) override;
6147
bool measureWithPose(const types::DynamicObject & object);
6248
bool measureWithShape(const types::DynamicObject & object);
6349
bool getTrackedObject(const rclcpp::Time & time, types::DynamicObject & object) const override;
64-
65-
private:
66-
types::DynamicObject getUpdatingObject(
67-
const types::DynamicObject & object,
68-
const geometry_msgs::msg::Transform & self_transform) const;
6950
};
7051

7152
} // namespace autoware::multi_object_tracker

perception/autoware_multi_object_tracker/include/autoware/multi_object_tracker/tracker/model/multiple_vehicle_tracker.hpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,10 @@ class MultipleVehicleTracker : public Tracker
3636
VehicleTracker big_vehicle_tracker_;
3737

3838
public:
39-
MultipleVehicleTracker(
40-
const rclcpp::Time & time, const types::DynamicObject & object, const size_t channel_size);
39+
MultipleVehicleTracker(const rclcpp::Time & time, const types::DynamicObject & object);
4140

4241
bool predict(const rclcpp::Time & time) override;
43-
bool measure(
44-
const types::DynamicObject & object, const rclcpp::Time & time,
45-
const geometry_msgs::msg::Transform & self_transform) override;
42+
bool measure(const types::DynamicObject & object, const rclcpp::Time & time) override;
4643
bool getTrackedObject(const rclcpp::Time & time, types::DynamicObject & object) const override;
4744
virtual ~MultipleVehicleTracker() {}
4845
};

perception/autoware_multi_object_tracker/include/autoware/multi_object_tracker/tracker/model/pass_through_tracker.hpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,14 @@ namespace autoware::multi_object_tracker
3030
class PassThroughTracker : public Tracker
3131
{
3232
private:
33-
types::DynamicObject object_;
3433
types::DynamicObject prev_observed_object_;
3534
rclcpp::Logger logger_;
3635
rclcpp::Time last_update_time_;
3736

3837
public:
39-
PassThroughTracker(
40-
const rclcpp::Time & time, const types::DynamicObject & object, const size_t channel_size);
38+
PassThroughTracker(const rclcpp::Time & time, const types::DynamicObject & object);
4139
bool predict(const rclcpp::Time & time) override;
42-
bool measure(
43-
const types::DynamicObject & object, const rclcpp::Time & time,
44-
const geometry_msgs::msg::Transform & self_transform) override;
40+
bool measure(const types::DynamicObject & object, const rclcpp::Time & time) override;
4541
bool getTrackedObject(const rclcpp::Time & time, types::DynamicObject & object) const override;
4642
};
4743

perception/autoware_multi_object_tracker/include/autoware/multi_object_tracker/tracker/model/pedestrian_and_bicycle_tracker.hpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,10 @@ class PedestrianAndBicycleTracker : public Tracker
3636
BicycleTracker bicycle_tracker_;
3737

3838
public:
39-
PedestrianAndBicycleTracker(
40-
const rclcpp::Time & time, const types::DynamicObject & object, const size_t channel_size);
39+
PedestrianAndBicycleTracker(const rclcpp::Time & time, const types::DynamicObject & object);
4140

4241
bool predict(const rclcpp::Time & time) override;
43-
bool measure(
44-
const types::DynamicObject & object, const rclcpp::Time & time,
45-
const geometry_msgs::msg::Transform & self_transform) override;
42+
bool measure(const types::DynamicObject & object, const rclcpp::Time & time) override;
4643
bool getTrackedObject(const rclcpp::Time & time, types::DynamicObject & object) const override;
4744
virtual ~PedestrianAndBicycleTracker() {}
4845
};

perception/autoware_multi_object_tracker/include/autoware/multi_object_tracker/tracker/model/pedestrian_tracker.hpp

+2-26
Original file line numberDiff line numberDiff line change
@@ -32,46 +32,22 @@ namespace autoware::multi_object_tracker
3232
class PedestrianTracker : public Tracker
3333
{
3434
private:
35-
types::DynamicObject object_;
3635
rclcpp::Logger logger_;
3736

3837
object_model::ObjectModel object_model_ = object_model::pedestrian;
3938

40-
double z_;
41-
42-
struct BoundingBox
43-
{
44-
double length;
45-
double width;
46-
double height;
47-
};
48-
struct Cylinder
49-
{
50-
double width;
51-
double height;
52-
};
53-
BoundingBox bounding_box_;
54-
Cylinder cylinder_;
5539
// cspell: ignore CTRV
5640
CTRVMotionModel motion_model_;
5741
using IDX = CTRVMotionModel::IDX;
5842

5943
public:
60-
PedestrianTracker(
61-
const rclcpp::Time & time, const types::DynamicObject & object, const size_t channel_size);
44+
PedestrianTracker(const rclcpp::Time & time, const types::DynamicObject & object);
6245

6346
bool predict(const rclcpp::Time & time) override;
64-
bool measure(
65-
const types::DynamicObject & object, const rclcpp::Time & time,
66-
const geometry_msgs::msg::Transform & self_transform) override;
47+
bool measure(const types::DynamicObject & object, const rclcpp::Time & time) override;
6748
bool measureWithPose(const types::DynamicObject & object);
6849
bool measureWithShape(const types::DynamicObject & object);
6950
bool getTrackedObject(const rclcpp::Time & time, types::DynamicObject & object) const override;
70-
71-
private:
72-
types::DynamicObject getUpdatingObject(
73-
const types::DynamicObject & object,
74-
const geometry_msgs::msg::Transform & self_transform) const;
7551
};
7652

7753
} // namespace autoware::multi_object_tracker

perception/autoware_multi_object_tracker/include/autoware/multi_object_tracker/tracker/model/tracker_base.hpp

+9-30
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define AUTOWARE__MULTI_OBJECT_TRACKER__TRACKER__MODEL__TRACKER_BASE_HPP_
2121

2222
#define EIGEN_MPL2_ONLY
23+
#include "autoware/multi_object_tracker/object_model/object_model.hpp"
2324
#include "autoware/multi_object_tracker/object_model/types.hpp"
2425

2526
#include <Eigen/Core>
@@ -39,11 +40,6 @@ namespace autoware::multi_object_tracker
3940
class Tracker
4041
{
4142
private:
42-
unique_identifier_msgs::msg::UUID uuid_;
43-
44-
// classification
45-
std::vector<autoware_perception_msgs::msg::ObjectClassification> classification_;
46-
4743
// existence states
4844
int no_measurement_count_;
4945
int total_no_measurement_count_;
@@ -53,10 +49,7 @@ class Tracker
5349
float total_existence_probability_;
5450

5551
public:
56-
Tracker(
57-
const rclcpp::Time & time,
58-
const std::vector<autoware_perception_msgs::msg::ObjectClassification> & classification,
59-
const size_t & channel_size);
52+
Tracker(const rclcpp::Time & time, const types::DynamicObject & object);
6053
virtual ~Tracker() = default;
6154

6255
void initializeExistenceProbabilities(
@@ -68,17 +61,12 @@ class Tracker
6861
}
6962
bool updateWithMeasurement(
7063
const types::DynamicObject & object, const rclcpp::Time & measurement_time,
71-
const geometry_msgs::msg::Transform & self_transform);
64+
const types::InputChannel & channel_info);
7265
bool updateWithoutMeasurement(const rclcpp::Time & now);
7366

74-
// classification
75-
std::vector<autoware_perception_msgs::msg::ObjectClassification> getClassification() const
76-
{
77-
return classification_;
78-
}
7967
std::uint8_t getHighestProbLabel() const
8068
{
81-
return autoware::object_recognition_utils::getHighestProbLabel(classification_);
69+
return autoware::object_recognition_utils::getHighestProbLabel(object_.classification);
8270
}
8371

8472
// existence states
@@ -91,24 +79,15 @@ class Tracker
9179
}
9280

9381
protected:
94-
unique_identifier_msgs::msg::UUID getUUID() const { return uuid_; }
95-
void setClassification(
96-
const std::vector<autoware_perception_msgs::msg::ObjectClassification> & classification)
97-
{
98-
classification_ = classification;
99-
}
82+
types::DynamicObject object_;
83+
10084
void updateClassification(
10185
const std::vector<autoware_perception_msgs::msg::ObjectClassification> & classification);
10286

103-
// virtual functions
104-
public:
105-
virtual geometry_msgs::msg::PoseWithCovariance getPoseWithCovariance(
106-
const rclcpp::Time & time) const;
87+
void limitObjectExtension(const object_model::ObjectModel object_model);
10788

108-
protected:
109-
virtual bool measure(
110-
const types::DynamicObject & object, const rclcpp::Time & time,
111-
const geometry_msgs::msg::Transform & self_transform) = 0;
89+
// virtual functions
90+
virtual bool measure(const types::DynamicObject & object, const rclcpp::Time & time) = 0;
11291

11392
public:
11493
virtual bool getTrackedObject(const rclcpp::Time & time, types::DynamicObject & object) const = 0;

0 commit comments

Comments
 (0)