Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Map/Objectifs/Obj_pince.cpp
- Committer:
- Jagang
- Date:
- 2015-05-06
- Revision:
- 117:f8c147141a0c
- Parent:
- 114:be06d518b4a7
- Child:
- 119:c45efcd706d9
File content as of revision 117:f8c147141a0c:
#include "Obj_pince.h"
#include <vector>
#ifdef PLAN_A
    extern Asserv<float> asserv;
#else
    extern aserv_planB asserv;
#endif
extern Odometry2 odometry;
extern std::vector<Objectif*> objectifs;
Obj_pince::Obj_pince(float x, float y, float theta, AX12 *ax12_pince)
:Objectif(x,y,theta)
{
    this->ax12_pince = ax12_pince;
}
void Obj_pince::run()
{
    float thetaGoal = atan2(y-odometry.getY(),x-odometry.getX());
    asserv.setGoal(odometry.getX()+cos(thetaGoal)*200,odometry.getY()+sin(thetaGoal)*200,thetaGoal); //On avance jusqu'au goblet/spot
    while(!asserv.isArrived())wait(0.1);
    
    ax12_pince->setGoal(PINCE_FERMEE);
    done = true;
    
    for(unsigned int i=0;i < objectifs.size();i++)
    {
        if(objectifs[i]->getId() == IDO_DEPOT && !objectifs[i]->isDone())
        {
            objectifs[i]->activate();
            break;
        }
    }
}
int Obj_pince::isActive()
{
    if(!active)
        return false;
    
    if(ax12_pince->getGoal() == PINCE_FERMEE)
        return false;
    
    return true;
}
            
    
