Apollo 10.0
自动驾驶开放平台
sim_control_base.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16#pragma once
17
18#include <limits>
19#include <memory>
20#include <string>
21
22#include "nlohmann/json.hpp"
23
24#include "modules/common_msgs/localization_msgs/localization.pb.h"
25#include "modules/common_msgs/prediction_msgs/prediction_obstacle.pb.h"
26#include "modules/dreamview/backend/common/sim_control_manager/proto/sim_control_internal.pb.h"
27
28#include "cyber/common/log.h"
29#include "cyber/cyber.h"
41namespace apollo {
42namespace dreamview {
43
50 public:
51 virtual ~SimControlBase() {}
55 virtual void RunOnce() = 0;
56
60 virtual void Init(bool set_start_point, nlohmann::json start_point_attr,
61 bool use_start_point_position = false) = 0;
62
67 virtual void Start() = 0;
68
73 virtual void Start(double x, double y, double v = 0.0, double a = 0.0) = 0;
74
78 virtual void ReSetPoinstion(double x, double y, double heading) = 0;
79
83 virtual void Stop() = 0;
84
88 virtual void Reset() = 0;
89
90 // virtual std::unique_ptr<SimControlBase> GetDynamicModel();
91
92 protected:
93 void TransformToVRF(const apollo::common::Point3D& point_mrf,
94 const apollo::common::Quaternion& orientation,
95 apollo::common::Point3D* point_vrf);
96
97 // The timer to publish simulated localization and chassis messages.
98 std::unique_ptr<cyber::Timer> sim_control_timer_;
99
100 // The timer to publish dummy prediction
101 std::unique_ptr<cyber::Timer> sim_prediction_timer_;
102
103 // Linearized reader/timer callbacks and external operations.
104 std::mutex mutex_;
105
106 // Whether the sim control is enabled / initialized.
107 bool enabled_ = false;
108
109 // Whether start point is initialized from actual localization data
111
112 // Initial state of the ego vehicle
113 double start_velocity_ = 0.0;
115 double start_heading_ = std::numeric_limits<double>::max();
116};
117
121typedef SimControlBase* create_t(std::string dynamic_name,
122 std::string home_path);
123
124} // namespace dreamview
125} // namespace apollo
Interface of simulated control algorithm
virtual void Start(double x, double y, double v=0.0, double a=0.0)=0
Starts running the simulated control algorithm with position, e.g., publish simulated localization an...
void TransformToVRF(const apollo::common::Point3D &point_mrf, const apollo::common::Quaternion &orientation, apollo::common::Point3D *point_vrf)
std::unique_ptr< cyber::Timer > sim_control_timer_
virtual void Start()=0
Starts running the simulated control algorithm, e.g., publish simulated localization and chassis mess...
virtual void Stop()=0
Stops the algorithm.
std::unique_ptr< cyber::Timer > sim_prediction_timer_
virtual void Reset()=0
Resets the internal state.
virtual void ReSetPoinstion(double x, double y, double heading)=0
Set vehicle position.
virtual void RunOnce()=0
Main logic of the simulated control algorithm.
virtual void Init(bool set_start_point, nlohmann::json start_point_attr, bool use_start_point_position=false)=0
Initialization.
Math-related util functions.
Some string util functions.
SimControlBase * create_t(std::string dynamic_name, std::string home_path)
Get SimControl class
class register implement
Definition arena_queue.h:37
Contains a number of helper functions related to quaternions.