9#ifndef WIN32_LEAN_AND_MEAN
10#define WIN32_LEAN_AND_MEAN
22#include <nlohmann/json.hpp>
60NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(
PIDGains, kp, ki, kd)
127 act_bw, vel_cl, noise_resp, max_KS)
177 gm_v, pm_v, msens_v, noise_resp, max_KS,
178 bw_p, bw_v, act_st, pos_cl)
201 double demanded_zeta;
208 demanded_bw, demanded_zeta, state)
231 double demanded_zeta;
238 demanded_st, demanded_zeta, state)
251 std::vector<double> numerators;
254 std::vector<double> denominators;
262 std::string bode_file_content;
292 std::string programPath;
302 PROCESS_INFORMATION pi;
324 nlohmann::json request(
const std::string& method,
const std::string& target,
325 const std::string& body,
326 unsigned int timeoutMilliseconds);
334 bool isProcessRunning();
380 const std::string& host =
"127.0.0.1");
453 const nlohmann::json& jsonObj,
516 const nlohmann::json& data);
538 const nlohmann::json& data);
592 const nlohmann::json& data);
Holds the gains resulting from the autotuning process.
Definition standalone_autotuning.h:86
ControllerGains gains
The resulting controller gains for velocity and position.
Definition standalone_autotuning.h:89
Holds position and velocity PID gains for a controller.
Definition standalone_autotuning.h:69
PIDGains velocity
PID gains for the velocity controller.
Definition standalone_autotuning.h:75
PIDGains position
PID gains for the position controller.
Definition standalone_autotuning.h:72
Represents the result of a full position autotuning process.
Definition standalone_autotuning.h:207
Represents the result of a full velocity autotuning process.
Definition standalone_autotuning.h:176
Represents the bode plot data computed for a given plant model.
Definition standalone_autotuning.h:269
std::string bode_file_content
Bode plot data in CSV form, with a header row naming the columns.
Definition standalone_autotuning.h:274
Represents the gains for a PID controller.
Definition standalone_autotuning.h:48
double ki
Integral gain.
Definition standalone_autotuning.h:54
double kd
Derivative gain.
Definition standalone_autotuning.h:57
double kp
Proportional gain.
Definition standalone_autotuning.h:51
Represents the result of a plant model identification process.
Definition standalone_autotuning.h:237
Represents the state of the position autotuning process.
Definition standalone_autotuning.h:126
Represents an error that occurs during standalone autotuning.
Definition standalone_autotuning.h:31
std::string message
Descriptive error message.
Definition standalone_autotuning.h:36
FullVelocityAutoTuningResult full_auto_tune_velocity_controller(const nlohmann::json &data)
Performs a full velocity controller autotuning sequence using external autotuning program.
Definition standalone_autotuning.cc:588
static constexpr unsigned int kFitRequestTimeoutMilliseconds
Timeout applied to the functions that fit a model, in milliseconds.
Definition standalone_autotuning.h:357
ControllerGains auto_tune_position_controller(const nlohmann::json &data)
Performs position controller autotuning using external autotuning program.
Definition standalone_autotuning.cc:571
nlohmann::json exchange(const nlohmann::json &jsonObj, unsigned int timeoutMilliseconds=kRequestTimeoutMilliseconds)
Runs a function on the autotuning server and returns its result.
Definition standalone_autotuning.cc:513
PlantModelResult identify_plant_model(const nlohmann::json &data)
Identifies the plant model based on the input data.
Definition standalone_autotuning.cc:627
~StandaloneAutotuning()
Destroys the StandaloneAutotuning instance.
Definition standalone_autotuning.cc:197
ControllerGains compute_position_controller_gains(const nlohmann::json &data)
Computes the position controller gains without performing full autotuning.
Definition standalone_autotuning.cc:611
static constexpr unsigned int kRequestTimeoutMilliseconds
Timeout applied to a function call, in milliseconds.
Definition standalone_autotuning.h:346
void stop()
Stops the external autotuning process.
Definition standalone_autotuning.cc:346
static constexpr uint16_t kDefaultPort
Port the autotuning HTTP server listens on by default.
Definition standalone_autotuning.h:338
static constexpr unsigned int kHealthTimeoutMilliseconds
Timeout applied to a health request, in milliseconds.
Definition standalone_autotuning.h:360
FullPositionAutoTuningResult full_auto_tune_position_controller(const nlohmann::json &data)
Performs a full position controller autotuning sequence using external autotuning program.
Definition standalone_autotuning.cc:600
bool isHealthy(unsigned int timeoutMilliseconds=kHealthTimeoutMilliseconds)
Reports whether the autotuning server is accepting requests.
Definition standalone_autotuning.cc:422
ControllerGains auto_tune_velocity_controller(const nlohmann::json &data)
Performs velocity controller autotuning using external autotuning program.
Definition standalone_autotuning.cc:555
StandaloneAutotuning(const std::string &programPath, const std::string &host="127.0.0.1")
Constructs the StandaloneAutotuning instance.
Definition standalone_autotuning.cc:186
GeneratePlantBodeFileResult generate_plant_bode_file(const nlohmann::json &data)
Computes the bode plot data for the given plant model.
Definition standalone_autotuning.cc:649
bool start(uint16_t port=kDefaultPort)
Starts the external autotuning program and waits for its HTTP server to accept requests.
Definition standalone_autotuning.cc:199
static constexpr unsigned int kReadyTimeoutMilliseconds
How long start() waits for the server to accept requests, in milliseconds.
Definition standalone_autotuning.h:366
Represents the state of the velocity autotuning process.
Definition standalone_autotuning.h:102
double vel_cl
Closed-loop velocity value of the system.
Definition standalone_autotuning.h:117
double noise_resp
Noise response in the velocity autotuning process.
Definition standalone_autotuning.h:120
double pm
Phase margin of the velocity system.
Definition standalone_autotuning.h:108
double act_bw
Active bandwidth of the system.
Definition standalone_autotuning.h:114
double max_KS
Maximum allowed gain scale factor.
Definition standalone_autotuning.h:123
double gm
Gain margin of the velocity system.
Definition standalone_autotuning.h:105
double msens
Measurement sensitivity of the velocity system.
Definition standalone_autotuning.h:111