Skip to content

Commit 2c5aad5

Browse files
committed
refactor(multi_object_tracker): remove BicycleTracker and update references to use VehicleTracker
1 parent 84c632c commit 2c5aad5

File tree

2 files changed

+44
-14
lines changed

2 files changed

+44
-14
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ namespace autoware::multi_object_tracker
3232
class BicycleTracker : public Tracker
3333
{
3434
private:
35+
object_model::ObjectModel object_model_ = object_model::bicycle;
3536
rclcpp::Logger logger_;
3637

37-
object_model::ObjectModel object_model_ = object_model::bicycle;
38+
double velocity_deviation_threshold_;
3839

3940
BicycleMotionModel motion_model_;
4041
using IDX = BicycleMotionModel::IDX;

perception/autoware_multi_object_tracker/lib/tracker/model/bicycle_tracker.cpp

+42-13
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ namespace autoware::multi_object_tracker
4343
BicycleTracker::BicycleTracker(const rclcpp::Time & time, const types::DynamicObject & object)
4444
: Tracker(time, object), logger_(rclcpp::get_logger("BicycleTracker"))
4545
{
46+
// velocity deviation threshold
47+
// if the predicted velocity is close to the observed velocity,
48+
// the observed velocity is used as the measurement.
49+
velocity_deviation_threshold_ = autoware_utils::kmph2mps(10); // [m/s]
50+
4651
if (object.shape.type != autoware_perception_msgs::msg::Shape::BOUNDING_BOX) {
4752
// set default initial size
4853
auto & object_extension = object_.shape.dimensions;
@@ -131,21 +136,44 @@ bool BicycleTracker::predict(const rclcpp::Time & time)
131136
bool BicycleTracker::measureWithPose(const types::DynamicObject & object)
132137
{
133138
// get measurement yaw angle to update
134-
const double tracked_yaw = motion_model_.getStateElement(IDX::YAW);
135-
double measurement_yaw = 0.0;
136-
bool is_yaw_available = shapes::getMeasurementYaw(object, tracked_yaw, measurement_yaw);
139+
bool is_yaw_available =
140+
object.kinematics.orientation_availability != types::OrientationAvailability::UNAVAILABLE;
141+
142+
// velocity capability is checked only when the object has velocity measurement
143+
// and the predicted velocity is close to the observed velocity
144+
bool is_velocity_available = false;
145+
if (object.kinematics.has_twist) {
146+
const double tracked_vel = motion_model_.getStateElement(IDX::VEL);
147+
const double & observed_vel = object.twist.linear.x;
148+
if (std::fabs(tracked_vel - observed_vel) < velocity_deviation_threshold_) {
149+
// Velocity deviation is small
150+
is_velocity_available = true;
151+
}
152+
}
137153

138154
// update
139155
bool is_updated = false;
140156
{
141157
const double x = object.pose.position.x;
142158
const double y = object.pose.position.y;
143-
const double yaw = measurement_yaw;
144-
145-
if (is_yaw_available) {
159+
const double yaw = tf2::getYaw(object.pose.orientation);
160+
const double vel = object.twist.linear.x;
161+
162+
if (is_yaw_available && is_velocity_available) {
163+
// update with yaw angle and velocity
164+
is_updated = motion_model_.updateStatePoseHeadVel(
165+
x, y, yaw, object.pose_covariance, vel, object.twist_covariance);
166+
} else if (is_yaw_available && !is_velocity_available) {
167+
// update with yaw angle, but without velocity
146168
is_updated = motion_model_.updateStatePoseHead(x, y, yaw, object.pose_covariance);
169+
} else if (!is_yaw_available && is_velocity_available) {
170+
// update without yaw angle, but with velocity
171+
is_updated = motion_model_.updateStatePoseVel(
172+
x, y, object.pose_covariance, vel, object.twist_covariance);
147173
} else {
148-
is_updated = motion_model_.updateStatePose(x, y, object.pose_covariance);
174+
// update without yaw angle and velocity
175+
is_updated = motion_model_.updateStatePose(
176+
x, y, object.pose_covariance); // update without yaw angle and velocity
149177
}
150178
motion_model_.limitStates();
151179
}
@@ -164,13 +192,14 @@ bool BicycleTracker::measureWithShape(const types::DynamicObject & object)
164192
return false;
165193
}
166194

167-
// check bound box size abnormality
168-
constexpr double size_max = 30.0; // [m]
169-
constexpr double size_min = 0.1; // [m]
195+
// check object size abnormality
196+
constexpr double size_max_multiplier = 1.5;
197+
constexpr double size_min_multiplier = 0.25;
170198
if (
171-
object.shape.dimensions.x > size_max || object.shape.dimensions.x < size_min ||
172-
object.shape.dimensions.y > size_max || object.shape.dimensions.y < size_min ||
173-
object.shape.dimensions.z > size_max || object.shape.dimensions.z < size_min) {
199+
object.shape.dimensions.x > object_model_.size_limit.length_max * size_max_multiplier ||
200+
object.shape.dimensions.x < object_model_.size_limit.length_min * size_min_multiplier ||
201+
object.shape.dimensions.y > object_model_.size_limit.width_max * size_max_multiplier ||
202+
object.shape.dimensions.y < object_model_.size_limit.width_min * size_min_multiplier) {
174203
return false;
175204
}
176205

0 commit comments

Comments
 (0)