Apollo 10.0
自动驾驶开放平台
sim_control_with_model_base.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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 "modules/common_msgs/control_msgs/control_cmd.pb.h"
23#include "modules/common_msgs/localization_msgs/localization.pb.h"
24#include "modules/common_msgs/planning_msgs/planning_command.pb.h"
25#include "modules/common_msgs/prediction_msgs/prediction_obstacle.pb.h"
26#include "modules/common_msgs/routing_msgs/routing.pb.h"
27#include "modules/dreamview/backend/common/sim_control_manager/proto/sim_control_internal.pb.h"
28
29#include "cyber/common/log.h"
30#include "cyber/cyber.h"
41
46namespace apollo {
47namespace dreamview {
48
53 public:
58 explicit SimControlWithModelBase(const std::string& node_name);
59
64 void Start() override;
65
66 void Start(double x, double y, double v = 0.0, double a = 0.0) override;
67
71 void ReSetPoinstion(double x, double y, double heading) override;
72
73 void Stop() override;
74
78 void Reset() override;
79
80 protected:
81 void InitTimerAndIO();
82
83 void UpdateGearPosition();
84 void InitStartPoint(nlohmann::json start_point_attr,
85 bool use_start_point_position = false);
86
87 void InternalReset();
88 void OnControlCommand(const apollo::control::ControlCommand& control_command);
90 const std::shared_ptr<apollo::planning::PlanningCommand>&
91 planning_command);
93 const std::shared_ptr<apollo::prediction::PredictionObstacles>&
94 obstacles);
95
96 virtual void SetStartPoint(const ::apollo::sim_control::SimCarStatus& point);
97
98 void PublishChassis(const std::string model_name);
99 void PublishLocalization(const std::string model_name);
101
102 // Whether the sim control is initialized.
103 bool start_auto_ = false;
107
108 std::unique_ptr<cyber::Node> node_;
109
110 std::shared_ptr<cyber::Reader<apollo::control::ControlCommand>>
112 std::shared_ptr<cyber::Reader<apollo::planning::PlanningCommand>>
114 std::shared_ptr<cyber::Reader<apollo::localization::LocalizationEstimate>>
116 std::shared_ptr<cyber::Reader<apollo::prediction::PredictionObstacles>>
118
119 std::shared_ptr<cyber::Writer<apollo::canbus::Chassis>> chassis_writer_;
120 std::shared_ptr<cyber::Writer<apollo::prediction::PredictionObstacles>>
122 std::shared_ptr<cyber::Writer<apollo::localization::LocalizationEstimate>>
124
127
129
130 // Filtered control command, used to fulfill chassis feedback
132
133 // The header of the routing planning is following.
135
137
138 // vehicle parameter
140
142 double dt_;
143
144 // Time interval of the timer, in milliseconds.
145 static constexpr double kModelIntervalMs = 10;
146 static constexpr double kSimPredictionIntervalMs = 100;
147
148 // Whether planning has requested a re-routing.
150
151 // Whether to send dummy predictions
154};
155
156} // namespace dreamview
157} // namespace apollo
Interface of simulated control algorithm
std::shared_ptr< cyber::Reader< apollo::planning::PlanningCommand > > planning_command_reader_
std::shared_ptr< cyber::Writer< apollo::localization::LocalizationEstimate > > localization_writer_
void PublishLocalization(const std::string model_name)
void OnControlCommand(const apollo::control::ControlCommand &control_command)
void Start() override
Starts the timer to publish simulated localization and chassis messages.
void ReSetPoinstion(double x, double y, double heading) override
Set vehicle position.
void OnPlanningCommand(const std::shared_ptr< apollo::planning::PlanningCommand > &planning_command)
void InitStartPoint(nlohmann::json start_point_attr, bool use_start_point_position=false)
std::shared_ptr< cyber::Reader< apollo::localization::LocalizationEstimate > > localization_reader_
void OnPredictionObstacles(const std::shared_ptr< apollo::prediction::PredictionObstacles > &obstacles)
std::shared_ptr< cyber::Reader< apollo::prediction::PredictionObstacles > > prediction_reader_
void PublishChassis(const std::string model_name)
pubish chassis info
std::shared_ptr< cyber::Writer< apollo::prediction::PredictionObstacles > > prediction_writer_
std::shared_ptr< cyber::Writer< apollo::canbus::Chassis > > chassis_writer_
std::shared_ptr< cyber::Reader< apollo::control::ControlCommand > > control_command_reader_
void Reset() override
Resets the internal state.
virtual void SetStartPoint(const ::apollo::sim_control::SimCarStatus &point)
Linear interpolation functions.
Math-related util functions.
Some string util functions.
class register implement
Definition arena_queue.h:37
Contains a number of helper functions related to quaternions.