@@ -46,6 +46,7 @@ LaneChangeModule::LaneChangeModule(
46
46
uuid_left_{generateUUID ()},
47
47
uuid_right_{generateUUID ()}
48
48
{
49
+ steering_factor_interface_ptr_ = std::make_unique<SteeringFactorInterface>(&node, " lane_change" );
49
50
}
50
51
51
52
BehaviorModuleOutput LaneChangeModule::run ()
@@ -61,11 +62,24 @@ BehaviorModuleOutput LaneChangeModule::run()
61
62
status_.lane_change_path .shift_point .start .position );
62
63
const double finish_distance = motion_utils::calcSignedArcLength (
63
64
output.path ->points , current_pose.position , status_.lane_change_path .shift_point .end .position );
64
- if (turn_signal_info.turn_signal .command == TurnIndicatorsCommand::ENABLE_LEFT) {
65
- waitApprovalLeft (start_distance, finish_distance);
66
- } else if (turn_signal_info.turn_signal .command == TurnIndicatorsCommand::ENABLE_RIGHT) {
67
- waitApprovalRight (start_distance, finish_distance);
68
- }
65
+
66
+ const uint16_t steering_factor_direction =
67
+ std::invoke ([this , &start_distance, &finish_distance, &turn_signal_info]() {
68
+ if (turn_signal_info.turn_signal .command == TurnIndicatorsCommand::ENABLE_LEFT) {
69
+ waitApprovalLeft (start_distance, finish_distance);
70
+ return SteeringFactor::LEFT;
71
+ }
72
+ if (turn_signal_info.turn_signal .command == TurnIndicatorsCommand::ENABLE_RIGHT) {
73
+ waitApprovalRight (start_distance, finish_distance);
74
+ return SteeringFactor::RIGHT;
75
+ }
76
+ return SteeringFactor::UNKNOWN;
77
+ });
78
+ // TODO(tkhmy) add handle status TRYING
79
+ steering_factor_interface_ptr_->updateSteeringFactor (
80
+ {status_.lane_change_path .shift_point .start , status_.lane_change_path .shift_point .end },
81
+ {start_distance, finish_distance}, SteeringFactor::LANE_CHANGE, steering_factor_direction,
82
+ SteeringFactor::TURNING, " " );
69
83
return output;
70
84
}
71
85
@@ -85,6 +99,7 @@ void LaneChangeModule::onExit()
85
99
{
86
100
clearWaitingApproval ();
87
101
removeRTCStatus ();
102
+ steering_factor_interface_ptr_->clearSteeringFactors ();
88
103
debug_marker_.markers .clear ();
89
104
current_state_ = BT::NodeStatus::IDLE;
90
105
RCLCPP_DEBUG (getLogger (), " LANE_CHANGE onExit" );
@@ -209,6 +224,18 @@ CandidateOutput LaneChangeModule::planCandidate() const
209
224
selected_path.path .points , planner_data_->self_pose ->pose .position ,
210
225
selected_path.shift_point .end .position );
211
226
227
+ const uint16_t steering_factor_direction = std::invoke ([&output]() {
228
+ if (output.lateral_shift > 0.0 ) {
229
+ return SteeringFactor::LEFT;
230
+ }
231
+ return SteeringFactor::RIGHT;
232
+ });
233
+
234
+ steering_factor_interface_ptr_->updateSteeringFactor (
235
+ {selected_path.shift_point .start , selected_path.shift_point .end },
236
+ {output.start_distance_to_path_change , output.finish_distance_to_path_change },
237
+ SteeringFactor::LANE_CHANGE, steering_factor_direction, SteeringFactor::APPROACHING, " " );
238
+
212
239
return output;
213
240
}
214
241
0 commit comments