modules/planning/tasks/traffic_decider/stop_sign.cc
/**
 * @brief: process & update stop status
 */
@brief: process & update stop status
@brief : process & update stop status
int StopSign::ProcessStopStatus(
    ReferenceLineInfo* const reference_line_info,
    const StopSignInfo& stop_sign_info) {
  if (reference_line_info == nullptr) {
    AWARN << "reference_line_info is nullptr. skip";
    return 0;
  }
  std::string stop_sign_id = stop_sign_info.id().id();
  std::string db_key_stop_status =
      db_key_stop_sign_stop_status_prefix_ + stop_sign_id;
  StopSignStopStatus* status = Dropbox<StopSignStopStatus>::Open()->Get(
      db_key_stop_status);
  stop_status_ = (status == nullptr) ?
      StopSignStopStatus::TO_STOP : *status;
  ADEBUG << "get stop_status_: "
      << static_cast<typename std::underlying_type<StopSignStopStatus>::type>(
          stop_status_);
  std::string db_key_stop_starttime =
      db_key_stop_sign_stop_starttime_prefix_ + stop_sign_id;
  double* start_time = Dropbox<double>::Open()->Get(
      db_key_stop_starttime);
  double stop_start_time =  (start_time == nullptr) ?
      Clock::NowInSeconds() + 1 : *start_time;
  double wait_time = Clock::NowInSeconds() - stop_start_time;
  ADEBUG << "stop_start_time: " << stop_start_time
      << "; wait_time: " << wait_time;
  switch (stop_status_) {
    case StopSignStopStatus::TO_STOP:
      if (ChecADCkStop(reference_line_info)) {
        stop_start_time = Clock::NowInSeconds();
        stop_status_ = StopSignStopStatus::STOPPING;
      }
      break;
    case StopSignStopStatus::STOPPING:
      if (wait_time > FLAGS_stop_duration_for_stop_sign) {
        stop_status_ = StopSignStopStatus::STOP_DONE;
      }
      break;
    case StopSignStopStatus::STOP_DONE:
      break;
  }
  Dropbox<StopSignStopStatus>::Open()->Set(db_key_stop_status,
                                           stop_status_);
  ADEBUG<< "update dropbox: [" << db_key_stop_status << "] = "
      << static_cast<typename std::underlying_type<StopSignStopStatus>::type>(
          stop_status_);
  Dropbox<double>::Open()->Set(db_key_stop_starttime,
                               stop_start_time);
  ADEBUG << "update dropbox: [" << db_key_stop_starttime
      << "] = " << stop_start_time;
  return 0;
}
int StopSign :: ProcessStopStatus ( ReferenceLineInfo * const reference_line_info , const StopSignInfo & stop_sign_info ) { if ( reference_line_info == nullptr ) { AWARN << " " ; return 0 ; } std :: string stop_sign_id = stop_sign_info . id ( ) . id ( ) ; std :: string db_key_stop_status = db_key_stop_sign_stop_status_prefix_ + stop_sign_id ; StopSignStopStatus * status = Dropbox < StopSignStopStatus > :: Open ( ) -> Get ( db_key_stop_status ) ; stop_status_ = ( status == nullptr ) ? StopSignStopStatus :: TO_STOP : * status ; ADEBUG << " " << static_cast < typename std :: underlying_type < StopSignStopStatus > :: type > ( stop_status_ ) ; std :: string db_key_stop_starttime = db_key_stop_sign_stop_starttime_prefix_ + stop_sign_id ; double * start_time = Dropbox < double > :: Open ( ) -> Get ( db_key_stop_starttime ) ; double stop_start_time = ( start_time == nullptr ) ? Clock :: NowInSeconds ( ) + 1 : * start_time ; double wait_time = Clock :: NowInSeconds ( ) - stop_start_time ; ADEBUG << " " << stop_start_time << " " << wait_time ; switch ( stop_status_ ) { case StopSignStopStatus :: TO_STOP : if ( ChecADCkStop ( reference_line_info ) ) { stop_start_time = Clock :: NowInSeconds ( ) ; stop_status_ = StopSignStopStatus :: STOPPING ; } break ; case StopSignStopStatus :: STOPPING : if ( wait_time > FLAGS_stop_duration_for_stop_sign ) { stop_status_ = StopSignStopStatus :: STOP_DONE ; } break ; case StopSignStopStatus :: STOP_DONE : break ; } Dropbox < StopSignStopStatus > :: Open ( ) -> Set ( db_key_stop_status , stop_status_ ) ; ADEBUG << " " << db_key_stop_status << " " << static_cast < typename std :: underlying_type < StopSignStopStatus > :: type > ( stop_status_ ) ; Dropbox < double > :: Open ( ) -> Set ( db_key_stop_starttime , stop_start_time ) ; ADEBUG << " " << db_key_stop_starttime << " " << stop_start_time ; return 0 ; }
@brief: process & update stop status
@brief : process & update stop status
// get stop status from dropbox // get stop start time from dropbox // check & update stop status // update dropbox: stop status // update dropbox: stop start time