iCub-main
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
iCub::ctrl::OnlineCompensatorDesign Class Reference

Online Compensator Design. More...

#include <tuning.h>

+ Inheritance diagram for iCub::ctrl::OnlineCompensatorDesign:

Public Member Functions

 OnlineCompensatorDesign ()
 Default constructor. More...
 
virtual bool configure (yarp::dev::PolyDriver &driver, const yarp::os::Property &options)
 Configure the design. More...
 
virtual bool isConfigured () const
 Check the configuration status. More...
 
virtual bool tuneController (const yarp::os::Property &options, yarp::os::Property &results)
 Tune the controller once given the plant characteristics. More...
 
virtual bool startPlantEstimation (const yarp::os::Property &options)
 Start off the plant estimation procedure. More...
 
virtual bool startPlantValidation (const yarp::os::Property &options)
 Start off the plant validation procedure. More...
 
virtual bool startStictionEstimation (const yarp::os::Property &options)
 Start off the stiction estimation procedure. More...
 
virtual bool startControllerValidation (const yarp::os::Property &options)
 Start off the controller validation procedure. More...
 
virtual bool isDone ()
 Check the status of the current ongoing operation. More...
 
virtual bool waitUntilDone ()
 Wait until the current ongoing operation is accomplished. More...
 
virtual void stopOperation ()
 Stop any ongoing operation. More...
 
virtual bool getResults (yarp::os::Property &results)
 Retrieve the results of the current ongoing operation. More...
 
virtual ~OnlineCompensatorDesign ()
 Destructor. More...
 

Protected Types

enum  {
  plant_estimation ,
  plant_validation ,
  stiction_estimation ,
  controller_validation
}
 

Protected Member Functions

void commandJoint (double &enc, double &u)
 
bool threadInit ()
 
void run ()
 
void threadRelease ()
 
bool start ()
 
void stop ()
 

Protected Attributes

OnlineDCMotorEstimator plant
 
OnlineStictionEstimator stiction
 
Kalman predictor
 
yarp::dev::IControlMode * imod
 
yarp::dev::IControlLimits * ilim
 
yarp::dev::IEncoders * ienc
 
yarp::dev::IPositionControl * ipos
 
yarp::dev::IPositionDirect * idir
 
yarp::dev::IPidControl * ipid
 
yarp::dev::IPWMControl * ipwm
 
yarp::dev::ICurrentControl * icur
 
yarp::dev::Pid * pidCur
 
yarp::dev::Pid pidOld
 
yarp::dev::Pid pidNew
 
std::mutex mtx
 
std::mutex mtx_doneEvent
 
std::condition_variable cv_doneEvent
 
yarp::os::BufferedPort< yarp::sig::Vector > port
 
yarp::sig::Vector x0
 
yarp::sig::Vector meanParams
 
int meanCnt
 
double P0
 
int joint
 
double t0
 
double t1
 
double x_min
 
double x_max
 
double x_tg
 
double max_time
 
double max_pwm
 
double dpos_dV
 
double switch_timeout
 
int measure_update_ticks
 
int measure_update_cnt
 
bool controller_validation_ref_square
 
double controller_validation_ref_period
 
double controller_validation_ref_sustain_time
 
int controller_validation_cycles_to_switch
 
int controller_validation_num_cycles
 
bool controller_validation_stiction_yarp
 
double controller_validation_stiction_up
 
double controller_validation_stiction_down
 
bool pwm_pos
 
bool configured
 
enum iCub::ctrl::OnlineCompensatorDesign:: { ... }  mode
 

Detailed Description

Online Compensator Design.

Tune in an online fashion a controller for a DC motor plant identified by means of OnlineDCMotorEstimator .

The design of the controller is such that the properties of the compensated closed-loop system comply with specifications given in terms of bandwidth and disturbance rejection.

This class has four operative modes: one for the plant estimation, one for the plant validation, one for the stiction estimation and one for validating the controller's design.

Definition at line 347 of file tuning.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
plant_estimation 
plant_validation 
stiction_estimation 
controller_validation 

Definition at line 394 of file tuning.h.

Constructor & Destructor Documentation

◆ OnlineCompensatorDesign()

OnlineCompensatorDesign::OnlineCompensatorDesign ( )

Default constructor.

Definition at line 442 of file tuning.cpp.

◆ ~OnlineCompensatorDesign()

OnlineCompensatorDesign::~OnlineCompensatorDesign ( )
virtual

Destructor.

Definition at line 1115 of file tuning.cpp.

Member Function Documentation

◆ commandJoint()

void OnlineCompensatorDesign::commandJoint ( double &  enc,
double &  u 
)
protected

Definition at line 617 of file tuning.cpp.

◆ configure()

bool OnlineCompensatorDesign::configure ( yarp::dev::PolyDriver &  driver,
const yarp::os::Property &  options 
)
virtual

Configure the design.

Parameters
driverthe device driver to control the robot part.
optionsthe configuration options.

Available options are to be given within the following groups:

[general]

joint <int>: specify the joint to be controlled.

port <string>: if given, specify the name of a yarp port to open in order to stream out relevant information.

[plant_estimation]

Ts <double>: specify the estimator sample time given in seconds.

Q <double>: specify the process noise covariance.

R <double>: specify the measurement noise covariance.

P0 <double>: specify the initial error covariance.

tau <double>: specify the initial mechanical time constant given in seconds.

K <double>: specify the initial plant gain.

max_pwm <double>: specify the amplitude of the square voltage waveform applied to the joint for identification purpose.

[stiction_estimation]

see OnlineStictionEstimator for a detailed description of available options.

Note
the joint option is here overidden by the one specified within the [general] group.
Returns
true/false on success/failure.

Definition at line 459 of file tuning.cpp.

◆ getResults()

bool OnlineCompensatorDesign::getResults ( yarp::os::Property &  results)
virtual

Retrieve the results of the current ongoing operation.

Parameters
resultsproperty object containing the results depending on the current ongoing operation: while estimating the plant, results is (tau <double>) (K <double>) (tau_mean <double>) (K_mean <double>); while validating the plant, results is (position <double>) (velocity <double>); while estimating the stiction values, results is (stiction (<double> <double>)); while validating the controller, results is (voltage <double>) (reference <double>) (position <double>) (pid <string>), where pid is "old"|"new".
Returns
true/false on success/failure.

Definition at line 1048 of file tuning.cpp.

◆ isConfigured()

virtual bool iCub::ctrl::OnlineCompensatorDesign::isConfigured ( ) const
inlinevirtual

Check the configuration status.

Returns
true iff configured successfully.

Definition at line 470 of file tuning.h.

◆ isDone()

bool OnlineCompensatorDesign::isDone ( )
virtual

Check the status of the current ongoing operation.

Returns
true iff ongoing operation is finished.

Definition at line 1025 of file tuning.cpp.

◆ run()

void OnlineCompensatorDesign::run ( )
protected

Definition at line 646 of file tuning.cpp.

◆ start()

bool iCub::ctrl::OnlineCompensatorDesign::start ( )
protected

◆ startControllerValidation()

bool OnlineCompensatorDesign::startControllerValidation ( const yarp::os::Property &  options)
virtual

Start off the controller validation procedure.

The specified controller is put to test against the controller currently set within the firmware. The validation experiment foresees cycles of rising and falling transitions in the reference trajectory. The control is therefore continuously switched between the current and the new controller.

Once the validation has been carried out, then the low-level controller's paremeters are restored to their previous values.

Parameters
optionsproperty containing the validation options. Available otions are: (max_time <double>) specifies the maximum amount of time for the experiment; (Kp <double>) (Ki <double>) (Kd <double>) (tau_d <double>) (scale <int>) specify the controller's gains; (stiction (<double><double>)) specifies the stiction values; (stiction_compensation <string>) specifies whether the compensation is managed by the "firmware" (default) or the "middleware"; (ref_type <string>) specifies the waveform of the position reference ("square"|"min-jerk"); (ref_period <double>) specifies the period of the reference; (ref_sustain_time <double>) specifies how log (in seconds) the reference should be kept at the set-point before switching to next value (meaningful for min-jerk reference type); (cycles_to_switch <int>) specifies the number of cycles during which one controller is tested before the switch.
Note
if active, the yarp port streams out, respectively, the mode id 3, the commanded voltage, the actual encoder value, the position reference and a flag accounting for the old pid behavior (0) or the new pid behavior (1). Zero-padding allows being compliant with the data size used for plant estimation mode.
Returns
true iff started successfully.

Definition at line 971 of file tuning.cpp.

◆ startPlantEstimation()

bool OnlineCompensatorDesign::startPlantEstimation ( const yarp::os::Property &  options)
virtual

Start off the plant estimation procedure.

Parameters
optionsproperty containing the estimation options. Available otions are: (max_time <double>) specifies the maximum amount of time for the experiment; (switch_timeout <double>) if greater than 0.0 specifies the timeout for voltage switching logic.
Note
if active, the yarp port streams out, respectively, the mode id 0, the commanded voltage, the actual encoder value and the 4D internal state of the estimator as well as the averaged parameters.
Returns
true iff started successfully.

Definition at line 891 of file tuning.cpp.

◆ startPlantValidation()

bool OnlineCompensatorDesign::startPlantValidation ( const yarp::os::Property &  options)
virtual

Start off the plant validation procedure.

Parameters
optionsproperty containing the validation options. Available otions are: (max_time <double>) specifies the maximum amount of time for the experiment; (switch_timeout <double>) if greater than 0.0 specifies the timeout for voltage switching logic; (tau <double>) specifies the mechanical time constant of the plant to be validated; (K <double>) specifies the plant gain to be validated; (measure_update_ticks <int>) specifies how many sample ticks to take before updating the measurement in the Kalman filter, if <= 0 then no update is performed; (Q <double>) (R <double>) (P0 <double>) are the well known Kalman quantities for the noise statistics.
Note
if active, the yarp port streams out, respectively, the mode id 1, the commanded voltage, the actual encoder value and the predicted plant response which includes the estimated position and velocity. Zero-padding allows being compliant with the data size used for the plant estimation mode.
Returns
true iff started successfully.

Definition at line 905 of file tuning.cpp.

◆ startStictionEstimation()

bool OnlineCompensatorDesign::startStictionEstimation ( const yarp::os::Property &  options)
virtual

Start off the stiction estimation procedure.

Parameters
optionsproperty containing the estimation options. Available otions are: (max_time <double>) specifies the maximum amount of time for the experiment; all the other options used while configuring the stiction estimator.
Note
if active, the yarp port streams out, respectively, the mode id 2, the commanded voltage, the actual encoder value, the position reference and the the stiction values. Zero-padding allows being compliant with the data size used for plant estimation mode.
Returns
true iff started successfully.

Definition at line 953 of file tuning.cpp.

◆ stop()

void iCub::ctrl::OnlineCompensatorDesign::stop ( )
protected

◆ stopOperation()

virtual void iCub::ctrl::OnlineCompensatorDesign::stopOperation ( )
inlinevirtual

Stop any ongoing operation.

Definition at line 648 of file tuning.h.

◆ threadInit()

bool OnlineCompensatorDesign::threadInit ( )
protected

Definition at line 547 of file tuning.cpp.

◆ threadRelease()

void OnlineCompensatorDesign::threadRelease ( )
protected

Definition at line 803 of file tuning.cpp.

◆ tuneController()

bool OnlineCompensatorDesign::tuneController ( const yarp::os::Property &  options,
yarp::os::Property &  results 
)
virtual

Tune the controller once given the plant characteristics.

The design requirements for the closed loop system are given in terms of bandwidth and properties for disturbance rejection.

The plant is assumed to be in the form:

\( K/\left(s \cdot \left(1+s\tau\right)\right). \)

The controller is in the form:

\( K_p + K_i/s. \)

The tuning is symbolic and by no means affects the gains of the low-level controller.

Parameters
optionsproperty object containing the plant characteristics as well as the design requirements: (tau <double>) (K <double>) (f_c <double>) (T_dr <double>); (type <string>) specifies the controller's architecture which can be "P" or "PI".
resultsproperty containing the design outcome in terms of \( K_p, K_i \) controller's parameters. The property's tags are respectively: Kp, Ki.
Returns
true/false on success/failure.
Note
When designing a P controller the user is required to specify the gain crossover frequency f_c in Hz that represents the frequency at which the open loop response has a unity-gain, corresponding roughly to the closed-loop cut-off frequency regulating the control bandwidth.
When designing a PI controller the integral part is employed separately for disturbance rejection in that it tries to cancel out a step-wise disturbance in a time window specified by T_dr parameter, given in seconds.
Returns
true/false on success/failure.

Definition at line 838 of file tuning.cpp.

◆ waitUntilDone()

bool OnlineCompensatorDesign::waitUntilDone ( )
virtual

Wait until the current ongoing operation is accomplished.

Returns
true iff ongoing operation is finished.

Definition at line 1035 of file tuning.cpp.

Member Data Documentation

◆ configured

bool iCub::ctrl::OnlineCompensatorDesign::configured
protected

Definition at line 392 of file tuning.h.

◆ controller_validation_cycles_to_switch

int iCub::ctrl::OnlineCompensatorDesign::controller_validation_cycles_to_switch
protected

Definition at line 386 of file tuning.h.

◆ controller_validation_num_cycles

int iCub::ctrl::OnlineCompensatorDesign::controller_validation_num_cycles
protected

Definition at line 387 of file tuning.h.

◆ controller_validation_ref_period

double iCub::ctrl::OnlineCompensatorDesign::controller_validation_ref_period
protected

Definition at line 384 of file tuning.h.

◆ controller_validation_ref_square

bool iCub::ctrl::OnlineCompensatorDesign::controller_validation_ref_square
protected

Definition at line 383 of file tuning.h.

◆ controller_validation_ref_sustain_time

double iCub::ctrl::OnlineCompensatorDesign::controller_validation_ref_sustain_time
protected

Definition at line 385 of file tuning.h.

◆ controller_validation_stiction_down

double iCub::ctrl::OnlineCompensatorDesign::controller_validation_stiction_down
protected

Definition at line 390 of file tuning.h.

◆ controller_validation_stiction_up

double iCub::ctrl::OnlineCompensatorDesign::controller_validation_stiction_up
protected

Definition at line 389 of file tuning.h.

◆ controller_validation_stiction_yarp

bool iCub::ctrl::OnlineCompensatorDesign::controller_validation_stiction_yarp
protected

Definition at line 388 of file tuning.h.

◆ cv_doneEvent

std::condition_variable iCub::ctrl::OnlineCompensatorDesign::cv_doneEvent
protected

Definition at line 368 of file tuning.h.

◆ dpos_dV

double iCub::ctrl::OnlineCompensatorDesign::dpos_dV
protected

Definition at line 379 of file tuning.h.

◆ icur

yarp::dev::ICurrentControl* iCub::ctrl::OnlineCompensatorDesign::icur
protected

Definition at line 361 of file tuning.h.

◆ idir

yarp::dev::IPositionDirect* iCub::ctrl::OnlineCompensatorDesign::idir
protected

Definition at line 358 of file tuning.h.

◆ ienc

yarp::dev::IEncoders* iCub::ctrl::OnlineCompensatorDesign::ienc
protected

Definition at line 356 of file tuning.h.

◆ ilim

yarp::dev::IControlLimits* iCub::ctrl::OnlineCompensatorDesign::ilim
protected

Definition at line 355 of file tuning.h.

◆ imod

yarp::dev::IControlMode* iCub::ctrl::OnlineCompensatorDesign::imod
protected

Definition at line 354 of file tuning.h.

◆ ipid

yarp::dev::IPidControl* iCub::ctrl::OnlineCompensatorDesign::ipid
protected

Definition at line 359 of file tuning.h.

◆ ipos

yarp::dev::IPositionControl* iCub::ctrl::OnlineCompensatorDesign::ipos
protected

Definition at line 357 of file tuning.h.

◆ ipwm

yarp::dev::IPWMControl* iCub::ctrl::OnlineCompensatorDesign::ipwm
protected

Definition at line 360 of file tuning.h.

◆ joint

int iCub::ctrl::OnlineCompensatorDesign::joint
protected

Definition at line 376 of file tuning.h.

◆ max_pwm

double iCub::ctrl::OnlineCompensatorDesign::max_pwm
protected

Definition at line 379 of file tuning.h.

◆ max_time

double iCub::ctrl::OnlineCompensatorDesign::max_time
protected

Definition at line 379 of file tuning.h.

◆ meanCnt

int iCub::ctrl::OnlineCompensatorDesign::meanCnt
protected

Definition at line 373 of file tuning.h.

◆ meanParams

yarp::sig::Vector iCub::ctrl::OnlineCompensatorDesign::meanParams
protected

Definition at line 372 of file tuning.h.

◆ measure_update_cnt

int iCub::ctrl::OnlineCompensatorDesign::measure_update_cnt
protected

Definition at line 382 of file tuning.h.

◆ measure_update_ticks

int iCub::ctrl::OnlineCompensatorDesign::measure_update_ticks
protected

Definition at line 381 of file tuning.h.

◆ 

enum { ... } iCub::ctrl::OnlineCompensatorDesign::mode

◆ mtx

std::mutex iCub::ctrl::OnlineCompensatorDesign::mtx
protected

Definition at line 366 of file tuning.h.

◆ mtx_doneEvent

std::mutex iCub::ctrl::OnlineCompensatorDesign::mtx_doneEvent
protected

Definition at line 367 of file tuning.h.

◆ P0

double iCub::ctrl::OnlineCompensatorDesign::P0
protected

Definition at line 374 of file tuning.h.

◆ pidCur

yarp::dev::Pid* iCub::ctrl::OnlineCompensatorDesign::pidCur
protected

Definition at line 362 of file tuning.h.

◆ pidNew

yarp::dev::Pid iCub::ctrl::OnlineCompensatorDesign::pidNew
protected

Definition at line 364 of file tuning.h.

◆ pidOld

yarp::dev::Pid iCub::ctrl::OnlineCompensatorDesign::pidOld
protected

Definition at line 363 of file tuning.h.

◆ plant

OnlineDCMotorEstimator iCub::ctrl::OnlineCompensatorDesign::plant
protected

Definition at line 350 of file tuning.h.

◆ port

yarp::os::BufferedPort<yarp::sig::Vector> iCub::ctrl::OnlineCompensatorDesign::port
protected

Definition at line 369 of file tuning.h.

◆ predictor

Kalman iCub::ctrl::OnlineCompensatorDesign::predictor
protected

Definition at line 352 of file tuning.h.

◆ pwm_pos

bool iCub::ctrl::OnlineCompensatorDesign::pwm_pos
protected

Definition at line 391 of file tuning.h.

◆ stiction

OnlineStictionEstimator iCub::ctrl::OnlineCompensatorDesign::stiction
protected

Definition at line 351 of file tuning.h.

◆ switch_timeout

double iCub::ctrl::OnlineCompensatorDesign::switch_timeout
protected

Definition at line 380 of file tuning.h.

◆ t0

double iCub::ctrl::OnlineCompensatorDesign::t0
protected

Definition at line 377 of file tuning.h.

◆ t1

double iCub::ctrl::OnlineCompensatorDesign::t1
protected

Definition at line 377 of file tuning.h.

◆ x0

yarp::sig::Vector iCub::ctrl::OnlineCompensatorDesign::x0
protected

Definition at line 371 of file tuning.h.

◆ x_max

double iCub::ctrl::OnlineCompensatorDesign::x_max
protected

Definition at line 378 of file tuning.h.

◆ x_min

double iCub::ctrl::OnlineCompensatorDesign::x_min
protected

Definition at line 378 of file tuning.h.

◆ x_tg

double iCub::ctrl::OnlineCompensatorDesign::x_tg
protected

Definition at line 378 of file tuning.h.


The documentation for this class was generated from the following files: