36 SignalTargetInterface* signal_target, ReferenceTrajectoryInterface* sref, ReferenceTrajectoryInterface* xinit,
37 ReferenceTrajectoryInterface* uinit,
const std::string& ns)
39 assert(
x.rows() == xref.getDimension() &&
"Dimension mismatch in controller: current state x and reference");
42 xref.getReference(t, yref);
46 PRINT_WARNING(
"PidController number of parallel PID controllers does not match dimension of the state vector.");
51 PRINT_WARNING(
"PidController: number of parallel PID controllers does not match number of required control inputs");
66 _d_error[i] = dt.toSec() > 0 ? (
_p_error[i] - p_error_last) / dt.toSec() : 0.0;
74 signal_target->sendMeasurement(ns +
"controller/error/p", t.toSec(),
_p_error);
75 signal_target->sendMeasurement(ns +
"controller/error/i", t.toSec(),
_i_error);
76 signal_target->sendMeasurement(ns +
"controller/error/d", t.toSec(),
_d_error);
82 u_sequence->add(0.0, u);
83 x_sequence->add(0.0,
x);
105 #ifdef MESSAGE_SUPPORT
106 void PidController::toMessage(corbo::messages::Controller& message)
const
108 message.mutable_pid_controller()->set_p_gain(
_p_gain);
109 message.mutable_pid_controller()->set_i_gain(
_i_gain);
110 message.mutable_pid_controller()->set_d_gain(
_d_gain);
114 message.mutable_pid_controller()->set_publish_error(
_publish_error);
117 void PidController::fromMessage(
const corbo::messages::Controller& message, std::stringstream* issues)
119 _p_gain = message.pid_controller().p_gain();
121 _d_gain = message.pid_controller().d_gain();