fonction terminée à vérifier
This commit is contained in:
parent
796bfcc45f
commit
aa79fbc9d2
2 changed files with 42 additions and 8 deletions
|
@ -146,6 +146,10 @@ void Tasks::Init() {
|
||||||
cerr << "Error task create: " << strerror(-err) << endl << flush;
|
cerr << "Error task create: " << strerror(-err) << endl << flush;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
if (err = rt_task_create(&th_vision, "th_vision", 0, PRIORITY_TMOVE, 0)) {
|
||||||
|
cerr << "Error task create: " << strerror(-err) << endl << flush;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
cout << "Tasks created successfully" << endl << flush;
|
cout << "Tasks created successfully" << endl << flush;
|
||||||
|
|
||||||
|
@ -199,6 +203,10 @@ void Tasks::Run() {
|
||||||
cerr << "Error task start: " << strerror(-err) << endl << flush;
|
cerr << "Error task start: " << strerror(-err) << endl << flush;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
if (err = rt_task_start(&th_vision, (void(*)(void*)) & Tasks::Vision, this)) {
|
||||||
|
cerr << "Error task start: " << strerror(-err) << endl << flush;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
cout << "Tasks launched" << endl << flush;
|
cout << "Tasks launched" << endl << flush;
|
||||||
}
|
}
|
||||||
|
@ -507,6 +515,9 @@ void Tasks::AskBattery(void *arg){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//This task works on a difficult principle that fully make it controllable through
|
||||||
|
// monitor, accessing booleans variables to set getPosition or searchArena
|
||||||
|
|
||||||
void Tasks::Vision(void *arg){
|
void Tasks::Vision(void *arg){
|
||||||
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
|
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
|
||||||
// Synchronization barrier (waiting that all tasks are starting)
|
// Synchronization barrier (waiting that all tasks are starting)
|
||||||
|
@ -521,7 +532,12 @@ void Tasks::Vision(void *arg){
|
||||||
list<Position> positionList;
|
list<Position> positionList;
|
||||||
list<Position>::iterator it;
|
list<Position>::iterator it;
|
||||||
string strPos;
|
string strPos;
|
||||||
MessagePosition msgPos;
|
MessagePosition* msgPos;
|
||||||
|
Message* msgPosMsg;
|
||||||
|
MessageImg* msgImg;
|
||||||
|
Message* msgImgMsg;
|
||||||
|
msgPos->SetID(MESSAGE_CAM_POSITION);
|
||||||
|
msgImg->SetID(MESSAGE_CAM_IMAGE);
|
||||||
rt_mutex_acquire(&mutex_killVision, TM_INFINITE);
|
rt_mutex_acquire(&mutex_killVision, TM_INFINITE);
|
||||||
killVision=0;
|
killVision=0;
|
||||||
rt_mutex_release(&mutex_killVision);
|
rt_mutex_release(&mutex_killVision);
|
||||||
|
@ -545,17 +561,35 @@ void Tasks::Vision(void *arg){
|
||||||
acquireImageOk=acquireImage;
|
acquireImageOk=acquireImage;
|
||||||
}
|
}
|
||||||
if(getPositionOk==1){
|
if(getPositionOk==1){
|
||||||
|
//On démarre la recherche du robot dans la zone définie par l'arène
|
||||||
positionList=img.SearchRobot(arena);
|
positionList=img.SearchRobot(arena);
|
||||||
|
//Définitition et assignation de l'itérateur de parcrous de la liste positionList
|
||||||
it=positionList.begin();
|
it=positionList.begin();
|
||||||
//it++;
|
//Définition d'un messagePosition qui va contenir l'information (x,y)
|
||||||
//msgPos(MESSAGE_CAM_POSITION,*it);
|
msgPos->SetPosition(*it);
|
||||||
//WriteInQueue(&q_messageToMon,msgPos);r
|
//Transformation en message classique
|
||||||
//img.DrawRobot(position.);
|
msgPosMsg=msgPos->Copy();
|
||||||
|
//Envoi
|
||||||
|
WriteInQueue(&q_messageToMon,msgPos);
|
||||||
|
//Dessis du robot sur l'image
|
||||||
|
img.DrawRobot(*it);
|
||||||
}
|
}
|
||||||
|
//Définition d'un messageImg contenant l'image avec le robot et l'arène dessinés (ou pas)
|
||||||
|
msgImg->SetImage(&img);
|
||||||
|
//Transformation en message classique
|
||||||
|
msgImgMsg=msgImg->Copy();
|
||||||
|
//Envoi
|
||||||
|
WriteInQueue(&q_messageToMon,msgImg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
rt_mutex_acquire(&mutex_searchArena, TM_INFINITE);
|
||||||
|
searchArena=0;
|
||||||
|
rt_mutex_release(&mutex_searchArena);
|
||||||
|
searchArenaOk=1;
|
||||||
|
rt_mutex_acquire(&mutex_getPosition, TM_INFINITE);
|
||||||
|
getPosition=0;
|
||||||
|
rt_mutex_release(&mutex_getPosition);
|
||||||
|
getPositionOk=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ int main(int argc, char const *argv[]) {
|
||||||
break;
|
break;
|
||||||
case LABEL_ROBOT_START_WITH_WD:
|
case LABEL_ROBOT_START_WITH_WD:
|
||||||
s += LABEL_ROBOT_OK;
|
s += LABEL_ROBOT_OK;
|
||||||
cout << ">>> I start without watchdog" << endl;
|
cout << ">>> I start with watchdog" << endl;
|
||||||
break;
|
break;
|
||||||
case LABEL_ROBOT_MOVE:
|
case LABEL_ROBOT_MOVE:
|
||||||
switch (buffer[2]) {
|
switch (buffer[2]) {
|
||||||
|
|
Loading…
Reference in a new issue