@@ -135,22 +135,20 @@ VehicleTracker::VehicleTracker(
135
135
136
136
bool VehicleTracker::predict (const rclcpp::Time & time)
137
137
{
138
- bool success = motion_model_.predictState (time );
139
- if (!success) {
140
- return false ;
141
- }
142
- return true ;
138
+ return motion_model_.predictState (time );
143
139
}
144
140
145
141
bool VehicleTracker::measureWithPose (const types::DynamicObject & object)
146
142
{
147
- // current (predicted) state
148
- const double tracked_vel = motion_model_.getStateElement (IDX::VEL);
143
+ // get measurement yaw angle to update
144
+ bool is_yaw_available =
145
+ object.kinematics .orientation_availability != types::OrientationAvailability::UNAVAILABLE;
149
146
150
147
// velocity capability is checked only when the object has velocity measurement
151
148
// and the predicted velocity is close to the observed velocity
152
149
bool is_velocity_available = false ;
153
150
if (object.kinematics .has_twist ) {
151
+ const double tracked_vel = motion_model_.getStateElement (IDX::VEL);
154
152
const double & observed_vel = object.twist .linear .x ;
155
153
if (std::fabs (tracked_vel - observed_vel) < velocity_deviation_threshold_) {
156
154
// Velocity deviation is small
@@ -166,11 +164,21 @@ bool VehicleTracker::measureWithPose(const types::DynamicObject & object)
166
164
const double yaw = tf2::getYaw (object.pose .orientation );
167
165
const double vel = object.twist .linear .x ;
168
166
169
- if (is_velocity_available) {
167
+ if (is_yaw_available && is_velocity_available) {
168
+ // update with yaw angle and velocity
170
169
is_updated = motion_model_.updateStatePoseHeadVel (
171
170
x, y, yaw, object.pose_covariance , vel, object.twist_covariance );
172
- } else {
171
+ } else if (is_yaw_available && !is_velocity_available) {
172
+ // update with yaw angle, but without velocity
173
173
is_updated = motion_model_.updateStatePoseHead (x, y, yaw, object.pose_covariance );
174
+ } else if (!is_yaw_available && is_velocity_available) {
175
+ // update without yaw angle, but with velocity
176
+ is_updated = motion_model_.updateStatePoseVel (
177
+ x, y, object.pose_covariance , vel, object.twist_covariance );
178
+ } else {
179
+ // update without yaw angle and velocity
180
+ is_updated = motion_model_.updateStatePose (
181
+ x, y, object.pose_covariance ); // update without yaw angle and velocity
174
182
}
175
183
motion_model_.limitStates ();
176
184
}
@@ -206,6 +214,9 @@ bool VehicleTracker::measureWithShape(const types::DynamicObject & object)
206
214
object_extension.y = gain_inv * object_extension.y + gain * object.shape .dimensions .y ;
207
215
object_extension.z = gain_inv * object_extension.z + gain * object.shape .dimensions .z ;
208
216
217
+ // set shape type, which is bounding box
218
+ object_.shape .type = object.shape .type ;
219
+
209
220
// set maximum and minimum size
210
221
limitObjectExtension (object_model_);
211
222
0 commit comments