<commit_before>/******************************************************************************
 * Copyright 2017 The Apollo Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *****************************************************************************/

/**
 * @file
 * @brief Obstacle
 */

#ifndef MODULES_PREDICTION_CONTAINER_OBSTACLES_OBSTACLE_H_
#define MODULES_PREDICTION_CONTAINER_OBSTACLES_OBSTACLE_H_

#include <deque>
#include <mutex>
#include <string>
#include <unordered_map>
#include <vector>
#include <memory>

#include "modules/common/math/kalman_filter.h"
#include "modules/common/proto/error_code.pb.h"
#include "modules/map/hdmap/hdmap_common.h"
#include "modules/perception/proto/perception_obstacle.pb.h"
#include "modules/prediction/proto/feature.pb.h"

namespace apollo {
namespace prediction {

class Obstacle {
 public:
  Obstacle();

  virtual ~Obstacle();

  void Insert(const apollo::perception::PerceptionObstacle& perception_obstacle,
              const double timestamp);

  apollo::perception::PerceptionObstacle::Type type() const;

  int id() const;

  double timestamp() const;

  const Feature& feature(size_t i) const;

  Feature* mutable_feature(size_t i);

  const Feature& latest_feature() const;

  Feature* mutable_latest_feature();

  size_t history_size() const;

  const apollo::common::math::KalmanFilter<double, 4, 2, 0>&
      kf_lane_tracker(const std::string& lane_id);

  const apollo::common::math::KalmanFilter<double, 6, 2, 0>&
      kf_motion_tracker() const;

  const apollo::common::math::KalmanFilter<double, 2, 2, 4>&
      kf_pedestrian_tracker() const;

  bool IsOnLane();

 private:
  apollo::common::ErrorCode SetId(
      const apollo::perception::PerceptionObstacle& perception_obstacle,
      Feature* feature);

  apollo::common::ErrorCode SetType(
      const apollo::perception::PerceptionObstacle& perception_obstacle);

  void SetTimestamp(
      const apollo::perception::PerceptionObstacle& perception_obstacle,
      const double timestamp, Feature* feature);

  void SetPosition(
      const apollo::perception::PerceptionObstacle& perception_obstacle,
      Feature* feature);

  void SetVelocity(
      const apollo::perception::PerceptionObstacle& perception_obstacle,
      Feature* feature);
<commit_msg>Prediction: add document comments for obstacle.h<commit_after>/******************************************************************************
 * Copyright 2017 The Apollo Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *****************************************************************************/

/**
 * @file
 * @brief Obstacle
 */

#ifndef MODULES_PREDICTION_CONTAINER_OBSTACLES_OBSTACLE_H_
#define MODULES_PREDICTION_CONTAINER_OBSTACLES_OBSTACLE_H_

#include <deque>
#include <mutex>
#include <string>
#include <unordered_map>
#include <vector>
#include <memory>

#include "modules/common/math/kalman_filter.h"
#include "modules/common/proto/error_code.pb.h"
#include "modules/map/hdmap/hdmap_common.h"
#include "modules/perception/proto/perception_obstacle.pb.h"
#include "modules/prediction/proto/feature.pb.h"

/**
 * @namespace apollo::prediction
 * @brief apollo::prediction
 */
namespace apollo {
namespace prediction {

/**
 * @class Obstacle
 * @brief Prediction obstacle.
 */
class Obstacle {
 public:
  /**
   * @brief Constructor
   */
  Obstacle();

  /**
   * @brief Destructor
   */
  virtual ~Obstacle();

  /**
   * @brief Insert a perception obstacle with its timestamp.
   * @param perception_obstacle The obstacle from perception.
   * @param timestamp The timestamp when the perception obstacle was detected.
   */
  void Insert(const apollo::perception::PerceptionObstacle& perception_obstacle,
              const double timestamp);

  /**
   * @brief Get the type of perception obstacle's type.
   * @return The type pf perception obstacle.
   */
  apollo::perception::PerceptionObstacle::Type type() const;

  /**
   * @brief Get the obstacle's ID.
   * @return The obstacle's ID.
   */
  int id() const;

  /**
   * @brief Get the obstacle's timestamp.
   * @return The obstacle's timestamp.
   */
  double timestamp() const;

  /**
   * @brief Get the ith feature from latest to earliest.
   * @param i The index of the feature.
   * @return The ith feature.
   */
  const Feature& feature(size_t i) const;

  /**
   * @brief Get a pointer to the ith feature from latest to earliest.
   * @param i The index of the feature.
   * @return A pointer to the ith feature.
   */
  Feature* mutable_feature(size_t i);

  /**
   * @brief Get the latest feature.
   * @return The latest feature.
   */
  const Feature& latest_feature() const;

  /**
   * @brief Get a pointer to the latest feature.
   * @return A pointer to the latest feature.
   */
  Feature* mutable_latest_feature();

  /**
   * @brief Get the number of historical features.
   * @return The number of historical features.
   */
  size_t history_size() const;

  /**
   * @brief Get the lane Kalman filter by lane ID.
   * @param lane_id The lane ID.
   * @return The lane Kalman filter.
   */
  const apollo::common::math::KalmanFilter<double, 4, 2, 0>&
      kf_lane_tracker(const std::string& lane_id);

  /**
   * @brief Get the motion Kalman filter.
   * @return The motion Kalman filter.
   */
  const apollo::common::math::KalmanFilter<double, 6, 2, 0>&
      kf_motion_tracker() const;

  /**
   * @brief Get the pedestrian Kalman filter.
   * @return The pedestrian Kalman filter.
   */
  const apollo::common::math::KalmanFilter<double, 2, 2, 4>&
      kf_pedestrian_tracker() const;

  /**
   * @brief Check if the obstacle is on any lane.
   * @return If the obstacle is on any lane.
   */
  bool IsOnLane();

 private:
  apollo::common::ErrorCode SetId(
      const apollo::perception::PerceptionObstacle& perception_obstacle,
      Feature* feature);

  apollo::common::ErrorCode SetType(
      const apollo::perception::PerceptionObstacle& perception_obstacle);

  void SetTimestamp(
      const apollo::perception::PerceptionObstacle& perception_obstacle,
      const double timestamp, Feature* feature);

  void SetPosition(
      const apollo::perception::PerceptionObstacle& perception_obstacle,
      Feature* feature);

  void SetVelocity(
      const apollo::perception::PerceptionObstacle& perception_obstacle,
      Feature* feature);

{'fraction_non_alphanumeric': 0.14270284865667612, 'fraction_numerical': 0.004590252463885514, 'mean_word_length': 4.169574319609212, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6607276', 'n_tokens_mistral': 2297, 'n_tokens_neox': 2164, 'n_words': 655}