- 3.0.2 optimal control module.
MpcSettings.h
Go to the documentation of this file.
1 /**********************************************************************************************************************
2 This file is part of the Control Toolbox (https://github.com/ethz-adrl/control-toolbox), copyright by ETH Zurich.
3 Licensed under the BSD-2 license (see LICENSE file in main directory)
4 **********************************************************************************************************************/
5 
6 #pragma once
7 
8 namespace ct {
9 namespace optcon {
10 
11 
13 
32 {
33 
35 
37 
39 
41 };
42 
43 
46 {
54 
58  ct::core::IntegrationType stateForwardIntegratorType_ = ct::core::IntegrationType::RK4;
59 
64 
71  bool measureDelay_ = false;
72 
80 
84  int fixedDelayUs_ = 0;
85 
90 
94  bool postTruncation_ = false;
95 
100 
105 
111  bool coldStart_ = false;
112 
113 
118  bool useExternalTiming_ = false;
119 
120 
122  void print()
123  {
124  std::cout << " ========================= MPC SETTINGS =============================" << std::endl;
125  std::cout << " stateForwardIntegration: \t " << stateForwardIntegration_ << std::endl;
126  std::cout << " stateForwardIntegrator: \t " << stateForwardIntegratorType_ << std::endl;
127  std::cout << " stateForwardIntegration_dt: \t " << stateForwardIntegration_dt_ << std::endl;
128  std::cout << " measureDelay: \t " << measureDelay_ << std::endl;
129  std::cout << " delayMeasurementMultiplier: \t " << delayMeasurementMultiplier_ << std::endl;
130  std::cout << " fixedDelayUs: \t " << fixedDelayUs_ << std::endl;
131  std::cout << " additionalDelayUs: \t " << additionalDelayUs_ << std::endl;
132  std::cout << " postTruncation_: \t " << postTruncation_ << std::endl;
133  std::cout << " mpc_mode: \t " << (int)mpc_mode << std::endl;
134  std::cout << " minimumTimeHorizonMpc: \t " << minimumTimeHorizonMpc_ << std::endl;
135  std::cout << " coldStart: \t " << coldStart_ << std::endl;
136  std::cout << " useExternalTiming: \t " << useExternalTiming_ << std::endl;
137  std::cout << " ============================== END =================================" << std::endl;
138  }
139 };
140 
141 
143 
151 inline void loadMpcSettings(const std::string& filename, mpc_settings& settings)
152 {
153  boost::property_tree::ptree pt;
154  boost::property_tree::read_info(filename, pt);
155 
156  settings.measureDelay_ = pt.get<bool>("mpc.measureDelay");
157  settings.stateForwardIntegration_ = pt.get<bool>("mpc.stateForwardIntegration");
158  settings.stateForwardIntegration_dt_ = pt.get<double>("mpc.stateForwardIntegration_dt");
159  settings.stateForwardIntegratorType_ = (ct::core::IntegrationType)pt.get<int>("mpc.stateForwardIntegratorType");
160  settings.fixedDelayUs_ = pt.get<int>("mpc.fixedDelayUs");
161  settings.additionalDelayUs_ = pt.get<int>("mpc.additionalDelayUs");
162  settings.minimumTimeHorizonMpc_ = pt.get<double>("mpc.timeHorizon");
163  settings.coldStart_ = pt.get<bool>("mpc.coldStart");
164  settings.postTruncation_ = pt.get<bool>("mpc.postTruncation");
165  settings.delayMeasurementMultiplier_ = pt.get<double>("mpc.delayMeasurementMultiplier");
166  settings.useExternalTiming_ = pt.get<bool>("mpc.useExternalTiming");
167 }
168 
169 
170 } // namespace optcon
171 } // namespace ct
bool measureDelay_
Definition: MpcSettings.h:71
void loadMpcSettings(const std::string &filename, mpc_settings &settings)
load the mpc settings from file
Definition: MpcSettings.h:151
MPC_MODE mpc_mode
Definition: MpcSettings.h:99
double stateForwardIntegration_dt_
Definition: MpcSettings.h:63
double delayMeasurementMultiplier_
Definition: MpcSettings.h:79
bool coldStart_
Definition: MpcSettings.h:111
bool postTruncation_
Definition: MpcSettings.h:94
MPC_MODE
select a mode in which MPC is supposed to run
Definition: MpcSettings.h:31
int additionalDelayUs_
Definition: MpcSettings.h:89
MPC Settings struct.
Definition: MpcSettings.h:45
RECEDING_HORIZON_WITH_FIXED_FINAL_TIME.
Definition: MpcSettings.h:40
void print()
Print MPC settings to console.
Definition: MpcSettings.h:122
bool useExternalTiming_
Definition: MpcSettings.h:118
FIXED_FINAL_TIME.
Definition: MpcSettings.h:34
bool stateForwardIntegration_
Definition: MpcSettings.h:53
CONSTANT_RECEDING_HORIZON.
Definition: MpcSettings.h:36
ct::core::IntegrationType stateForwardIntegratorType_
Definition: MpcSettings.h:58
int fixedDelayUs_
Definition: MpcSettings.h:84
core::Time minimumTimeHorizonMpc_
Definition: MpcSettings.h:104
double Time
FIXED_FINAL_TIME_WITH_MIN_TIME_HORIZON.
Definition: MpcSettings.h:38