1 #include "header/controller.h" 8 this->robotName = robotName;
9 std::cout <<
"[" << robotName<<
"][CONTROLLER] Start " << std::endl;
22 int numTasks = tasks.size();
23 for (
int i=0; i<(numTasks-1); i++){
24 if (tasks[i]->updated ==
false){
25 tasks[i]->updateMatrices(robInfo);
26 tasks[i]->updated =
true;
45 if (task->updated ==
false){
46 task->updateMatrices(robInfo);
48 std::cout <<
"[" << robotName<<
"][CONTROLLER] Calculated transforms for only the " <<
49 task->getName() <<
" task" << std::endl;
51 std::cout <<
"[" << robotName<<
"][CONTROLLER] " <<
52 task->getName() <<
" task already updated" << std::endl;
65 int numTasks = tasks.size();
66 for (
int i=0; i<(numTasks-1); i++){
67 tasks[i]->updated =
false;
81 int numTasks = tasks.size();
82 for (
int i=0; i<(numTasks); i++){
83 tasks[i]->setFlag_G(0);
84 tasks[i]->setFlag_W(0);
85 tasks[i]->setMu_G(0.0);
86 tasks[i]->setMu_W(0.0);
107 CMAT::Matrix yDot_cmat = CMAT::Matrix::Zeros(TOT_DOF,1);
108 CMAT::Matrix Q = CMAT::Matrix::Eye(TOT_DOF);
109 for (
int i=0; i<tasks.size(); i++){
111 if (tasks[i]->eqType){
113 Controller::equalityIcat(tasks[i], &yDot_cmat, &Q);
116 Controller::inequalityIcat(tasks[i], &yDot_cmat, &Q);
127 return (CONV::vector_cmat2std(yDot_cmat));
147 int Controller::equalityIcat(
Task* task, CMAT::Matrix* rhop, CMAT::Matrix* Q) {
149 CMAT::Matrix J = task->getJacobian();
150 CMAT::Matrix ref = task->getReference();
152 CMAT::Matrix I = CMAT::Matrix::Eye(task->getDof());
153 CMAT::Matrix barG, barGtransp, T, W, barGpinv;
156 barGtransp = barG.Transpose();
161 T = (I - (*Q)).Transpose() * (I-(*Q));
165 (barGtransp * barG + T)
166 .RegPseudoInverse(task->getThreshold(), task->getLambda(),
171 barGpinv = (barGtransp * barG)
172 .RegPseudoInverse(task->getThreshold(), task->getLambda(),
174 (*rhop) = (*rhop) + (*Q) * barGpinv * barGtransp * W * (ref - J * (*rhop));
180 (*Q) = (*Q) * (I - barGpinv * barGtransp * barG);
198 int Controller::inequalityIcat(
Task* task, CMAT::Matrix* rhop, CMAT::Matrix* Q) {
200 CMAT::Matrix J = task->getJacobian();
201 CMAT::Matrix ref = task->getReference();
202 CMAT::Matrix A = task->getActivation();
204 CMAT::Matrix I = CMAT::Matrix::Eye(task->getDof());
205 CMAT::Matrix barG, barGtransp, barGtranspAA, T, H, W, barGpinv;
208 barGtransp = barG.Transpose();
209 barGtranspAA = barGtransp * A * A;
214 T = (I - (*Q)).Transpose() * (I-(*Q));
217 (CMAT::Matrix::Eye(task->getDimension()) - A)*
222 (barGtranspAA * barG + T + H)
223 .RegPseudoInverse(task->getThreshold(), task->getLambda(),
227 barGpinv = (barGtranspAA * barG + H)
228 .RegPseudoInverse(task->getThreshold(), task->getLambda(),
236 (*rhop) = (*rhop) + (*Q) * barGpinv * barGtranspAA * W * (ref - J * (*rhop));
239 (*Q) = (*Q) * (I - barGpinv * barGtranspAA * barG);
Controller(std::string robotName)
Controller::Controller constructor.
int resetAllUpdatedFlags(std::vector< Task * > tasks)
Controller::resetAllUpdatedFlags to be called at the end of the control loop, so next loop all matric...
std::vector< double > execAlgorithm(std::vector< Task * > tasks)
Controller::execAlgorithm this function calls the step of the algorithm modifying (in the for) each t...
int & getFlag_G()
Task::getFlag_G Various getter methods.
int & getFlag_W()
Task::getFlag_W Various getter methods.
double & getMu_G()
Task::getMu_G Various getter methods.
double & getMu_W()
Task::getMu_W Various getter methods.
int updateSingleTaskMatrices(Task *task, struct Infos *const robInfo)
Controller::updateSingleTaskMatrices This function calls the updateMatrices for a single task...
ABSTRACT class task. Each task is a derived class of this class. It contains all the variable that th...
int updateMultipleTasksMatrices(std::vector< Task * > tasks, struct Infos *const robInfo)
Controller::updateAllTaskMatrices This function calls all the updateMatrices of each task...
int resetAllAlgosFlag(std::vector< Task * > tasks)
Controller::resetAllAlgosFlag Flag_W Mu_W Flag_G Mu_G must be resetted before each TPIK...