predictor.cc 1.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/******************************************************************************
 * 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.
 *****************************************************************************/

#include "modules/prediction/predictor/predictor.h"

D
Dong Li 已提交
19 20
#include <vector>

21 22 23 24 25 26 27
namespace apollo {
namespace prediction {

const PredictionObstacle& Predictor::prediction_obstacle() {
  return prediction_obstacle_;
}

C
Calvin Miao 已提交
28 29 30 31 32
int Predictor::GetTrajectorySize() {
  return prediction_obstacle_.trajectory_size();
}

void Predictor::GenerateTrajectory(
D
Dong Li 已提交
33 34
    const std::vector<::apollo::common::TrajectoryPoint>& points,
    Trajectory* trajectory) {
35 36
  trajectory->mutable_trajectory_point()->MergeFrom(
      {points.begin(), points.end()});
C
Calvin Miao 已提交
37 38 39 40
}

void Predictor::SetEqualProbability(double probability, int start_index) {
  int num = GetTrajectorySize();
41 42
  if (start_index >= 0 && num > start_index) {
    probability /= static_cast<double>(num - start_index);
C
Calvin Miao 已提交
43 44 45 46 47 48
    for (int i = start_index; i < num; ++i) {
      prediction_obstacle_.mutable_trajectory(i)->set_probability(probability);
    }
  }
}

A
Aaron Xiao 已提交
49 50
}  // namespace prediction
}  // namespace apollo