Browse Source

change sim perfect control for apoll agx orin. have some problem need solve.

yuchuli 2 months ago
parent
commit
b4cc6be066
2 changed files with 18 additions and 6 deletions
  1. 17 5
      src/apollo/change/sim_perfect_control.cc
  2. 1 1
      src/apollo/change/sim_perfect_control.h

+ 17 - 5
src/apollo/change/sim_perfect_control.cc

@@ -70,7 +70,7 @@ void  adclog1(const char * strlog){
 }
 
 // gflags定义类型	描述
-DEFINE_bool(use_realveh, false, "set use real vehicle");   // bool位整型
+DEFINE_bool(use_realveh, true, "set use real vehicle");   // bool位整型
  
 DECLARE_bool(use_realveh);
 
@@ -137,6 +137,7 @@ SimPerfectControl::SimPerfectControl(const MapService *map_service)
 }
 
 void SimPerfectControl::InitTimerAndIO() {
+  std::cout<<"init timer."<<std::endl;
   localization_reader_ =
       node_->CreateReader<LocalizationEstimate>(FLAGS_localization_topic);
   localization_adc_reader_ = node_->CreateReader<LocalizationEstimate>(
@@ -416,12 +417,12 @@ void SimPerfectControl::Start() {
   }
 }
 
-void SimPerfectControl::Start(double x, double y) {
+void SimPerfectControl::Start(double x, double y,double v , double a ) {
   std::lock_guard<std::mutex> lock(mutex_);
   if (!enabled_) {
     // Do not use localization info. use scenario start point to init start
     // point.
-    InitStartPoint(x, y, 0, 0);
+    InitStartPoint(x, y, v, a);
     InternalReset();
     sim_control_timer_->Start();
     sim_prediction_timer_->Start();
@@ -460,13 +461,23 @@ void SimPerfectControl::RunOnce() {
 
   TrajectoryPoint trajectory_point;
   Chassis::GearPosition gear_position;
+  
+
+
+  
   if (!PerfectControlModel(&trajectory_point, &gear_position)) {
+    if(receiveadcloc == false){
     AERROR << "Failed to calculate next point with perfect control model";
     return;
+    }
   }
-
-  PublishChassis(trajectory_point.v(), gear_position);
+  
+      PublishChassis(trajectory_point.v(), gear_position);
   PublishLocalization(trajectory_point);
+  
+
+
+
 }
 
 bool SimPerfectControl::PerfectControlModel(
@@ -546,6 +557,7 @@ void SimPerfectControl::PublishChassis(double cur_speed,
   chassis->set_steering_percentage(fcmdsteer_);
 
   chassis_writer_->Write(chassis);
+  
 }
 
 void SimPerfectControl::PublishLocalization(const TrajectoryPoint &point) {

+ 1 - 1
src/apollo/change/sim_perfect_control.h

@@ -126,7 +126,7 @@ class SimPerfectControl final : public SimControlBase {
    * @brief Starts the timer to publish simulated localization and chassis
    * messages. Designated Start point for scenario
    */
-  void Start(double x, double y) override;
+  void Start(double x, double y, double v = 0.0, double a = 0.0) override;
 
   void InitStartPoint(double start_velocity, double start_acceleration);