Apollo 10.0
自动驾驶开放平台
apollo::dreamview::SimPerfectControl类 参考final

A module that simulates a 'perfect control' algorithm, which assumes an ideal world where the car can be perfectly placed wherever the planning asks it to be, with the expected speed, acceleration, etc. 更多...

#include <sim_perfect_control.h>

类 apollo::dreamview::SimPerfectControl 继承关系图:
apollo::dreamview::SimPerfectControl 的协作图:

Public 成员函数

 SimPerfectControl (const MapService *map_service)
 Constructor of SimPerfectControl.
 
void Init (bool set_start_point, nlohmann::json start_point_attr, bool use_start_point_position=false) override
 setup callbacks and timer
 
void Start () override
 Starts the timer to publish simulated localization and chassis messages.
 
void Stop () override
 Stops the timer.
 
void ReSetPoinstion (double x, double y, double heading) override
 Set vehicle position.
 
void Reset () override
 Resets the internal state.
 
void RunOnce () override
 Main logic of the simulated control algorithm.
 
- Public 成员函数 继承自 apollo::dreamview::SimControlBase
virtual ~SimControlBase ()
 

额外继承的成员函数

- Protected 成员函数 继承自 apollo::dreamview::SimControlBase
void TransformToVRF (const apollo::common::Point3D &point_mrf, const apollo::common::Quaternion &orientation, apollo::common::Point3D *point_vrf)
 
- Protected 属性 继承自 apollo::dreamview::SimControlBase
std::unique_ptr< cyber::Timersim_control_timer_
 
std::unique_ptr< cyber::Timersim_prediction_timer_
 
std::mutex mutex_
 
bool enabled_ = false
 
bool start_point_from_localization_ = false
 
double start_velocity_ = 0.0
 
double start_acceleration_ = 0.0
 
double start_heading_ = std::numeric_limits<double>::max()
 

详细描述

A module that simulates a 'perfect control' algorithm, which assumes an ideal world where the car can be perfectly placed wherever the planning asks it to be, with the expected speed, acceleration, etc.

在文件 sim_perfect_control.h52 行定义.

构造及析构函数说明

◆ SimPerfectControl()

apollo::dreamview::SimPerfectControl::SimPerfectControl ( const MapService map_service)
explicit

Constructor of SimPerfectControl.

参数
map_servicethe pointer of MapService.

在文件 sim_perfect_control.cc66 行定义.

67 : SimControlBase(),
68 map_service_(map_service),
69 node_(cyber::CreateNode("sim_perfect_control")),
70 current_trajectory_(std::make_shared<ADCTrajectory>()) {
71 InitTimerAndIO();
72}
std::unique_ptr< Node > CreateNode(const std::string &node_name, const std::string &name_space)
Definition cyber.cc:33

成员函数说明

◆ Init()

void apollo::dreamview::SimPerfectControl::Init ( bool  set_start_point,
nlohmann::json  start_point_attr,
bool  use_start_point_position = false 
)
overridevirtual

setup callbacks and timer

参数
set_start_pointinitialize localization.

实现了 apollo::dreamview::SimControlBase.

在文件 sim_perfect_control.cc112 行定义.

114 {
115 if (set_start_point && !FLAGS_use_navigation_mode) {
116 InitStartPoint(start_point_attr["start_velocity"],
117 start_point_attr["start_acceleration"]);
118 }
119}

◆ Reset()

void apollo::dreamview::SimPerfectControl::Reset ( )
overridevirtual

Resets the internal state.

实现了 apollo::dreamview::SimControlBase.

在文件 sim_perfect_control.cc210 行定义.

210 {
211 std::lock_guard<std::mutex> lock(mutex_);
212 InternalReset();
213}

◆ ReSetPoinstion()

void apollo::dreamview::SimPerfectControl::ReSetPoinstion ( double  x,
double  y,
double  heading 
)
overridevirtual

Set vehicle position.

实现了 apollo::dreamview::SimControlBase.

在文件 sim_perfect_control.cc140 行定义.

140 {
141 std::lock_guard<std::mutex> lock(mutex_);
142 TrajectoryPoint point;
143 point.mutable_path_point()->set_x(x);
144 point.mutable_path_point()->set_y(y);
145 // z use default 0
146 point.mutable_path_point()->set_z(0);
147 point.mutable_path_point()->set_theta(heading);
148 SetStartPoint(point);
149 InternalReset();
150}

◆ RunOnce()

void apollo::dreamview::SimPerfectControl::RunOnce ( )
overridevirtual

Main logic of the simulated control algorithm.

实现了 apollo::dreamview::SimControlBase.

在文件 sim_perfect_control.cc363 行定义.

363 {
364 std::lock_guard<std::mutex> lock(mutex_);
365
366 TrajectoryPoint trajectory_point;
367 Chassis::GearPosition gear_position;
368 if (!PerfectControlModel(&trajectory_point, &gear_position)) {
369 AERROR << "Failed to calculate next point with perfect control model";
370 return;
371 }
372
373 PublishChassis(trajectory_point.v(), gear_position);
374 PublishLocalization(trajectory_point);
375}
#define AERROR
Definition log.h:44

◆ Start()

void apollo::dreamview::SimPerfectControl::Start ( )
overridevirtual

Starts the timer to publish simulated localization and chassis messages.

实现了 apollo::dreamview::SimControlBase.

在文件 sim_perfect_control.cc299 行定义.

299 {
300 std::lock_guard<std::mutex> lock(mutex_);
301
302 if (!enabled_) {
303 // When there is no localization yet, Init(true) will use a
304 // dummy point from the current map as an arbitrary start.
305 // When localization is already available, we do not need to
306 // reset/override the start point.
307 localization_reader_->Observe();
308 Json start_point_attr({});
309 start_point_attr["start_velocity"] =
310 next_point_.has_v() ? next_point_.v() : 0.0;
311 start_point_attr["start_acceleration"] =
312 next_point_.has_a() ? next_point_.a() : 0.0;
313 Init(true, start_point_attr);
314 InternalReset();
315 {
316 std::lock_guard<std::mutex> lock(timer_mutex_);
317 sim_control_timer_->Start();
318 sim_prediction_timer_->Start();
319 }
320 enabled_ = true;
321 }
322}
void Init(bool set_start_point, nlohmann::json start_point_attr, bool use_start_point_position=false) override
setup callbacks and timer
nlohmann::json Json

◆ Stop()

void apollo::dreamview::SimPerfectControl::Stop ( )
overridevirtual

Stops the timer.

实现了 apollo::dreamview::SimControlBase.

在文件 sim_perfect_control.cc215 行定义.

215 {
216 if (enabled_) {
217 {
218 std::lock_guard<std::mutex> lock(timer_mutex_);
219 sim_control_timer_->Stop();
220 sim_prediction_timer_->Stop();
221 }
222 enabled_ = false;
223 }
224}

该类的文档由以下文件生成: