7#include <nlohmann/json.hpp>
55 const PlantMeasurement& measurement,
double startFrequencyHz,
double endFrequencyHz)>;
85void to_json(nlohmann::json& j,
const PlantModelChirp& chirp);
101 std::optional<double>
inertia()
const;
105 std::optional<double>
friction()
const;
115 std::chrono::milliseconds transitionTime);
123 uint32_t ratedTorqueMilliNm);
ChirpSignalType
Which excitation the system-identification run sweeps with (parameter 4).
Definition somanet_drive.h:543
@ kLogarithmic
Logarithmic frequency sweep whose amplitude rises with it, from half the target to the target.
Definition bus_health_source.h:7
constexpr std::string_view kPlantModelFile
The file on the drive that holds the identified plant model.
Definition plant_identification.h:58
std::function< std::expected< PlantModelFit, std::string >(const PlantMeasurement &measurement, double startFrequencyHz, double endFrequencyHz)> PlantModelFitFn
Fits a plant model to a measurement.
Definition plant_identification.h:55
constexpr double kLowMeanAbsVelocityRadPerSecond
Mean absolute velocity, in rad/s, below which a recording is accepted with a warning,...
Definition plant_identification.h:75
std::expected< std::optional< std::string >, std::string > checkPlantMeasurementAmplitudes(const PlantMeasurement &measurement, uint32_t ratedTorqueMilliNm)
Checks that the recording excited the plant enough for a fit.
Definition plant_identification.cc:133
void to_json(nlohmann::json &j, const Cia402Status &s)
Serialises a Cia402Status. Emits state/modeName as human-readable strings alongside the numeric statu...
Definition cia402_drive.cc:13
PlantMeasurement convertPlantMeasurement(std::span< const HrdSystemIdentificationSample > samples, uint32_t ratedTorqueMilliNm)
Converts a recording into the units the fit takes.
Definition plant_identification.cc:120
constexpr double kMinMeanAbsTorquePermil
Mean absolute torque, in per mille of rated torque, below which a recording is refused.
Definition plant_identification.h:68
constexpr std::chrono::milliseconds kChirpPaddingMs
Recording time added around the chirp.
Definition plant_identification.h:65
std::expected< std::chrono::milliseconds, std::string > plantIdentificationStreamDuration(std::chrono::milliseconds transitionTime)
How long the HRD stream must run for a chirp of transitionTime.
Definition plant_identification.cc:106
std::expected< PlantModel, std::string > parsePlantModelCsv(std::string_view text)
Reads the text of kPlantModelFile.
Definition plant_identification.cc:173
bool isStablePlantModel(std::span< const double > denominator)
Whether a model with this denominator is stable.
Definition plant_identification.cc:161
std::string plantModelCsv(const PlantModel &model)
Renders a model as the text of kPlantModelFile.
Definition plant_identification.cc:165
constexpr double kMinMeanAbsVelocityRadPerSecond
Mean absolute velocity, in rad/s, below which a recording is refused.
Definition plant_identification.h:71
std::string text
Definition soem_fieldbus_driver.cc:1254
The recorded response of a drive to a chirp, in the units the fit takes.
Definition plant_identification.h:32
std::vector< double > velocitiesRadPerSecond
Velocity of the velocity-control encoder.
Definition plant_identification.h:34
std::vector< double > torquesNm
Actual torque, in Nm.
Definition plant_identification.h:33
The chirp a plant model was identified with, stored beside the model.
Definition plant_identification.h:78
double startFrequencyHz
Where the sweep began.
Definition plant_identification.h:79
somanet::ChirpSignalType signalType
Definition plant_identification.h:83
uint32_t durationMs
How long the sweep took.
Definition plant_identification.h:82
uint32_t amplitudePermil
Peak excitation, per mille of rated torque.
Definition plant_identification.h:81
double endFrequencyHz
Where it ended.
Definition plant_identification.h:80
A plant model as the fit returns it: a transfer function from torque to velocity.
Definition plant_identification.h:38
std::vector< double > numerator
Numerator coefficients, highest order first.
Definition plant_identification.h:39
std::vector< double > denominator
Definition plant_identification.h:40
nlohmann::json bode
Definition plant_identification.h:44
An identified plant model: the transfer function from torque in Nm to velocity in rad/s,...
Definition plant_identification.h:94
std::vector< double > numerator
Numerator coefficients, highest order first.
Definition plant_identification.h:95
std::optional< double > friction() const
The effective viscous friction: the last denominator coefficient.
Definition plant_identification.cc:89
std::optional< double > inertia() const
The effective inertia: the denominator coefficient before the last.
Definition plant_identification.cc:82
PlantModelChirp chirp
What excited the plant.
Definition plant_identification.h:97
std::vector< double > denominator
Denominator coefficients, highest order first.
Definition plant_identification.h:96