Changeset 122 in flair-src for trunk/demos


Ignore:
Timestamp:
Jan 6, 2017, 1:56:26 PM (5 years ago)
Author:
Sanahuja Guillaume
Message:

modifs uav vrpn i686

Location:
trunk/demos
Files:
29 added
7 deleted
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/demos/CircleFollower/uav/src/CircleFollower.cpp

    r121 r122  
    3939using namespace flair::meta;
    4040
    41 CircleFollower::CircleFollower(Uav* uav,TargetController *controller): UavStateMachine(uav,controller), behaviourMode(BehaviourMode_t::Default), vrpnLost(false) {
    42     uav->SetupVRPNAutoIP(uav->ObjectName());
    43 
     41CircleFollower::CircleFollower(TargetController *controller): UavStateMachine(controller), behaviourMode(BehaviourMode_t::Default), vrpnLost(false) {
     42    Uav* uav=GetUav();
     43               
     44                VrpnClient* vrpnclient=new VrpnClient("vrpn", uav->GetDefaultVrpnAddress(),10000, 80);
     45                uavVrpn = new MetaVrpnObject(uav->ObjectName());
     46                getFrameworkManager()->AddDeviceToLog(uavVrpn);
     47                uav->GetAhrs()->YawPlot()->AddCurve(uavVrpn->State()->Element(2),DataPlot::Green);
     48                                                                                                                                 
    4449    startCircle=new PushButton(GetButtonsLayout()->NewRow(),"start_circle");
    4550    stopCircle=new PushButton(GetButtonsLayout()->LastRowLastCol(),"stop_circle");
    4651
    47     if(uav->GetVrpnClient()->UseXbee()==true) {
    48         targetVrpn=new MetaVrpnObject(uav->GetVrpnClient(),"target",1);
     52    if(vrpnclient->UseXbee()==true) {
     53        targetVrpn=new MetaVrpnObject("target",1);
    4954    } else {
    50         targetVrpn=new MetaVrpnObject(uav->GetVrpnClient(),"target");
     55        targetVrpn=new MetaVrpnObject("target");
    5156    }
    5257
    5358    getFrameworkManager()->AddDeviceToLog(targetVrpn);
    5459
    55     circle=new TrajectoryGenerator2DCircle(uav->GetVrpnClient()->GetLayout()->NewRow(),"circle");
    56     uav->GetVrpnObject()->xPlot()->AddCurve(circle->Matrix()->Element(0,0),DataPlot::Blue);
    57     uav->GetVrpnObject()->yPlot()->AddCurve(circle->Matrix()->Element(0,1),DataPlot::Blue);
    58     uav->GetVrpnObject()->VxPlot()->AddCurve(circle->Matrix()->Element(1,0),DataPlot::Blue);
    59     uav->GetVrpnObject()->VyPlot()->AddCurve(circle->Matrix()->Element(1,1),DataPlot::Blue);
    60     uav->GetVrpnObject()->XyPlot()->AddCurve(circle->Matrix()->Element(0,1),circle->Matrix()->Element(0,0),DataPlot::Blue,"circle");
     60    circle=new TrajectoryGenerator2DCircle(vrpnclient->GetLayout()->NewRow(),"circle");
     61    uavVrpn->xPlot()->AddCurve(circle->Matrix()->Element(0,0),DataPlot::Blue);
     62    uavVrpn->yPlot()->AddCurve(circle->Matrix()->Element(0,1),DataPlot::Blue);
     63    uavVrpn->VxPlot()->AddCurve(circle->Matrix()->Element(1,0),DataPlot::Blue);
     64    uavVrpn->VyPlot()->AddCurve(circle->Matrix()->Element(1,1),DataPlot::Blue);
     65    uavVrpn->XyPlot()->AddCurve(circle->Matrix()->Element(0,1),circle->Matrix()->Element(0,0),DataPlot::Blue,"circle");
    6166
    6267    uX=new Pid(setupLawTab->At(1,0),"u_x");
     
    7984    //get yaw from vrpn
    8085    Euler vrpnEuler;
    81     GetUav()->GetVrpnObject()->GetEuler(vrpnEuler);
     86    uavVrpn->GetEuler(vrpnEuler);
    8287
    8388    //get roll, pitch and w from imu
     
    98103    Vector3D uav_pos,uav_vel;
    99104
    100     GetUav()->GetVrpnObject()->GetPosition(uav_pos);
    101     GetUav()->GetVrpnObject()->GetSpeed(uav_vel);
     105    uavVrpn->GetPosition(uav_pos);
     106    uavVrpn->GetSpeed(uav_vel);
    102107    //z and dz must be in uav's frame
    103108    z=-uav_pos.z;
     
    131136    Vector2D uav_2Dpos,uav_2Dvel; // in VRPN coordinate system
    132137
    133     GetUav()->GetVrpnObject()->GetPosition(uav_pos);
    134     GetUav()->GetVrpnObject()->GetSpeed(uav_vel);
     138    uavVrpn->GetPosition(uav_pos);
     139    uavVrpn->GetSpeed(uav_vel);
    135140
    136141    uav_pos.To2Dxy(uav_2Dpos);
     
    195200            Land();
    196201        }
    197         if (!GetUav()->GetVrpnObject()->IsTracked(500)) {
     202        if (!uavVrpn->IsTracked(500)) {
    198203            Thread::Err("VRPN, uav lost\n");
    199204            vrpnLost=true;
     
    239244    circle->SetCenter(target_2Dpos);
    240245
    241     GetUav()->GetVrpnObject()->GetPosition(uav_pos);
     246    uavVrpn->GetPosition(uav_pos);
    242247    uav_pos.To2Dxy(uav_2Dpos);
    243248    circle->StartTraj(uav_2Dpos);
     
    258263    Vector3D vrpn_pos;
    259264
    260     GetUav()->GetVrpnObject()->GetEuler(vrpn_euler);
     265    uavVrpn->GetEuler(vrpn_euler);
    261266    yawHold=vrpn_euler.yaw;
    262267
    263     GetUav()->GetVrpnObject()->GetPosition(vrpn_pos);
     268    uavVrpn->GetPosition(vrpn_pos);
    264269    vrpn_pos.To2Dxy(posHold);
    265270
  • trunk/demos/CircleFollower/uav/src/CircleFollower.h

    r38 r122  
    3434class CircleFollower : public flair::meta::UavStateMachine {
    3535    public:
    36         CircleFollower(flair::meta::Uav* uav,flair::sensor::TargetController *controller);
     36        CircleFollower(flair::sensor::TargetController *controller);
    3737        ~CircleFollower();
    3838
     
    6565
    6666        flair::gui::PushButton *startCircle,*stopCircle;
    67         flair::meta::MetaVrpnObject *targetVrpn;
     67        flair::meta::MetaVrpnObject *targetVrpn,*uavVrpn;
    6868        flair::filter::TrajectoryGenerator2DCircle *circle;
    6969        flair::core::AhrsData *customReferenceOrientation,*customOrientation;
  • trunk/demos/CircleFollower/uav/src/main.cpp

    r38 r122  
    4545    manager->SetupLogger(log_path);
    4646
    47     Uav* drone=CreateUav(manager,name,uav_type);
     47    Uav* drone=CreateUav(name,uav_type);
    4848    TargetEthController *controller=new TargetEthController(manager,"Dualshock3",ds3port);
    49     CircleFollower* demo=new CircleFollower(drone,controller);
     49    CircleFollower* demo=new CircleFollower(controller);
    5050
    5151    demo->Start();
  • trunk/demos/Gps/uav/CMakeLists.txt

    r89 r122  
    66SET(FLAIR_USE_SENSOR_ACTUATOR TRUE)
    77SET(FLAIR_USE_META TRUE)
    8 SET(FLAIR_USE_VRPN TRUE)
    98SET(FLAIR_USE_GPS TRUE)
    109
  • trunk/demos/Gps/uav/src/DemoGps.cpp

    r101 r122  
    3939using namespace flair::meta;
    4040
    41 DemoGps::DemoGps(Uav* uav,TargetController *controller): UavStateMachine(uav,controller), behaviourMode(BehaviourMode_t::Default) {
    42 
     41DemoGps::DemoGps(TargetController *controller): UavStateMachine(controller), behaviourMode(BehaviourMode_t::Default) {
     42                Uav* uav=GetUav();
    4343    startCircle=new PushButton(GetButtonsLayout()->NewRow(),"start_circle");
    4444    stopCircle=new PushButton(GetButtonsLayout()->LastRowLastCol(),"stop_circle");
  • trunk/demos/Gps/uav/src/DemoGps.h

    r89 r122  
    3333class DemoGps : public flair::meta::UavStateMachine {
    3434    public:
    35         DemoGps(flair::meta::Uav* uav,flair::sensor::TargetController *controller);
     35        DemoGps(flair::sensor::TargetController *controller);
    3636        ~DemoGps();
    3737
  • trunk/demos/Gps/uav/src/main.cpp

    r89 r122  
    4545    manager->SetupLogger(log_path);
    4646
    47     Uav* drone=CreateUav(manager,name,uav_type);
     47    Uav* drone=CreateUav(name,uav_type);
    4848    TargetEthController *controller=new TargetEthController(manager,"Dualshock3",ds3port);
    49     DemoGps* demo=new DemoGps(drone,controller);
     49    DemoGps* demo=new DemoGps(controller);
    5050
    5151    demo->Start();
  • trunk/demos/SimpleFleet/uav/src/SimpleFleet.cpp

    r104 r122  
    5050
    5151
    52 SimpleFleet::SimpleFleet(flair::meta::Uav* uav,string broadcast,TargetController *controller): UavStateMachine(uav,controller), behaviourMode(BehaviourMode_t::Default), vrpnLost(false) {
    53     uav->SetupVRPNAutoIP(uav->ObjectName());
    54 
    55     circle=new TrajectoryGenerator2DCircle(uav->GetVrpnClient()->GetLayout()->NewRow(),"circle");
    56     uav->GetVrpnObject()->xPlot()->AddCurve(circle->Matrix()->Element(0,0),0,0,255);
    57     uav->GetVrpnObject()->yPlot()->AddCurve(circle->Matrix()->Element(0,1),0,0,255);
    58     uav->GetVrpnObject()->VxPlot()->AddCurve(circle->Matrix()->Element(1,0),0,0,255);
    59     uav->GetVrpnObject()->VyPlot()->AddCurve(circle->Matrix()->Element(1,1),0,0,255);
    60 
    61     xCircleCenter=new DoubleSpinBox(uav->GetVrpnClient()->GetLayout()->NewRow(),"x circle center"," m",-5,5,0.1,1,0);
    62     yCircleCenter=new DoubleSpinBox(uav->GetVrpnClient()->GetLayout()->NewRow(),"y circle center"," m",-5,5,0.1,1,0);
    63     yDisplacement=new DoubleSpinBox(uav->GetVrpnClient()->GetLayout()->NewRow(),"y displacement"," m",0,2,0.1,1,0);
     52SimpleFleet::SimpleFleet(string broadcast,TargetController *controller): UavStateMachine(controller), behaviourMode(BehaviourMode_t::Default), vrpnLost(false) {
     53    Uav* uav=GetUav();
     54               
     55                VrpnClient* vrpnclient=new VrpnClient("vrpn", uav->GetDefaultVrpnAddress(),10000, 80);
     56                uavVrpn = new MetaVrpnObject(uav->ObjectName());
     57                getFrameworkManager()->AddDeviceToLog(uavVrpn);
     58                uav->GetAhrs()->YawPlot()->AddCurve(uavVrpn->State()->Element(2),DataPlot::Green);
     59
     60    circle=new TrajectoryGenerator2DCircle(vrpnclient->GetLayout()->NewRow(),"circle");
     61    uavVrpn->xPlot()->AddCurve(circle->Matrix()->Element(0,0),0,0,255);
     62    uavVrpn->yPlot()->AddCurve(circle->Matrix()->Element(0,1),0,0,255);
     63    uavVrpn->VxPlot()->AddCurve(circle->Matrix()->Element(1,0),0,0,255);
     64    uavVrpn->VyPlot()->AddCurve(circle->Matrix()->Element(1,1),0,0,255);
     65
     66    xCircleCenter=new DoubleSpinBox(vrpnclient->GetLayout()->NewRow(),"x circle center"," m",-5,5,0.1,1,0);
     67    yCircleCenter=new DoubleSpinBox(vrpnclient->GetLayout()->NewRow(),"y circle center"," m",-5,5,0.1,1,0);
     68    yDisplacement=new DoubleSpinBox(vrpnclient->GetLayout()->NewRow(),"y displacement"," m",0,2,0.1,1,0);
    6469
    6570    //parent->AddDeviceToLog(Uz());
     
    101106    //get yaw from vrpn
    102107    Euler vrpnEuler;
    103     GetUav()->GetVrpnObject()->GetEuler(vrpnEuler);
     108    uavVrpn->GetEuler(vrpnEuler);
    104109
    105110    //get roll, pitch and w from imu
     
    120125    Vector3D uav_pos,uav_vel;
    121126
    122     GetUav()->GetVrpnObject()->GetPosition(uav_pos);
    123     GetUav()->GetVrpnObject()->GetSpeed(uav_vel);
     127    uavVrpn->GetPosition(uav_pos);
     128    uavVrpn->GetSpeed(uav_vel);
    124129    //z and dz must be in uav's frame
    125130    z=-uav_pos.z;
     
    154159    Euler vrpn_euler; // in VRPN coordinate system
    155160
    156     GetUav()->GetVrpnObject()->GetPosition(uav_pos);
    157     GetUav()->GetVrpnObject()->GetSpeed(uav_vel);
    158     GetUav()->GetVrpnObject()->GetEuler(vrpn_euler);
     161    uavVrpn->GetPosition(uav_pos);
     162    uavVrpn->GetSpeed(uav_vel);
     163    uavVrpn->GetEuler(vrpn_euler);
    159164
    160165    uav_pos.To2Dxy(uav_2Dpos);
     
    294299void SimpleFleet::ExtraSecurityCheck(void) {
    295300    if (!vrpnLost && behaviourMode!=BehaviourMode_t::Default) {
    296         if (!GetUav()->GetVrpnObject()->IsTracked(500)) {
     301        if (!uavVrpn->IsTracked(500)) {
    297302            Thread::Err("Optitrack, uav lost\n");
    298303            vrpnLost=true;
     
    322327    circle->SetCenter(target_2Dpos);
    323328
    324     GetUav()->GetVrpnObject()->GetPosition(uav_pos);
     329    uavVrpn->GetPosition(uav_pos);
    325330    uav_pos.To2Dxy(uav_2Dpos);
    326331    circle->StartTraj(uav_2Dpos,1);
     
    347352    }
    348353
    349     GetUav()->GetVrpnObject()->GetEuler(vrpn_euler);
     354    uavVrpn->GetEuler(vrpn_euler);
    350355    yaw_hold=vrpn_euler.yaw;
    351356
    352     GetUav()->GetVrpnObject()->GetPosition(vrpn_pos);
     357    uavVrpn->GetPosition(vrpn_pos);
    353358    vrpn_pos.To2Dxy(pos_hold);
    354359
  • trunk/demos/SimpleFleet/uav/src/SimpleFleet.h

    r38 r122  
    2626        class TrajectoryGenerator2DCircle;
    2727    }
     28                namespace meta {
     29        class MetaVrpnObject;
     30    }
    2831    namespace gui {
    2932        class DoubleSpinBox;
     
    3437class SimpleFleet : public flair::meta::UavStateMachine {
    3538    public:
    36         SimpleFleet(flair::meta::Uav* uav,std::string broadcast,flair::sensor::TargetController *controller);
     39        SimpleFleet(std::string broadcast,flair::sensor::TargetController *controller);
    3740        ~SimpleFleet();
    3841
     
    7578        flair::gui::DoubleSpinBox *xCircleCenter,*yCircleCenter,*yDisplacement;
    7679        flair::core::AhrsData *customReferenceOrientation,*customOrientation;
     80                                flair::meta::MetaVrpnObject *uavVrpn;
    7781};
    7882
  • trunk/demos/SimpleFleet/uav/src/main.cpp

    r38 r122  
    4646    manager->SetupUserInterface(xml_file);
    4747
    48     Uav* drone=CreateUav(manager,name,uav_type);
     48    Uav* drone=CreateUav(name,uav_type);
    4949    TargetEthController *controller=new TargetEthController(manager,"Dualshock3",ds3port);
    50     SimpleFleet* demo=new SimpleFleet(drone,broadcast,controller);
     50    SimpleFleet* demo=new SimpleFleet(broadcast,controller);
    5151
    5252    demo->Start();
  • trunk/demos/Skeletons/CustomReferenceAngles/CMakeLists.txt

    r43 r122  
    66SET(FLAIR_USE_SENSOR_ACTUATOR TRUE)
    77SET(FLAIR_USE_META TRUE)
    8 SET(FLAIR_USE_VRPN TRUE)
    98
    109include($ENV{FLAIR_ROOT}/flair-dev/cmake-modules/GlobalCmakeFlair.cmake)
  • trunk/demos/Skeletons/CustomReferenceAngles/src/MyApp.cpp

    r43 r122  
    2929using namespace flair::sensor;
    3030
    31 MyApp::MyApp(Uav* uav,TargetController *controller): UavStateMachine(uav,controller), behaviourMode(BehaviourMode_t::Default) {
     31MyApp::MyApp(TargetController *controller): UavStateMachine(controller), behaviourMode(BehaviourMode_t::Default) {
    3232    start_CustomAngles=new PushButton(GetButtonsLayout()->NewRow(),"start CustomReferenceAngles");
    3333    stop_CustomAngles=new PushButton(GetButtonsLayout()->NewRow(),"stop CustomReferenceAngles");
    3434
    3535    customReferenceOrientation= new AhrsData(this,"reference");
    36     uav->GetAhrs()->AddPlot(customReferenceOrientation,DataPlot::Yellow);
     36    GetUav()->GetAhrs()->AddPlot(customReferenceOrientation,DataPlot::Yellow);
    3737    AddDataToControlLawLog(customReferenceOrientation);
    3838}
  • trunk/demos/Skeletons/CustomReferenceAngles/src/MyApp.h

    r43 r122  
    3131class MyApp : public flair::meta::UavStateMachine {
    3232    public:
    33         MyApp(flair::meta::Uav* uav,flair::sensor::TargetController *controller);
     33        MyApp(flair::sensor::TargetController *controller);
    3434        ~MyApp();
    3535
  • trunk/demos/Skeletons/CustomReferenceAngles/src/main.cpp

    r43 r122  
    4444    manager->SetupLogger(log_path);
    4545
    46     Uav* drone=CreateUav(manager,name,uav_type);
     46    Uav* drone=CreateUav(name,uav_type);
    4747    TargetEthController *controller=new TargetEthController(manager,"Dualshock3",ds3port);
    48     MyApp* app=new MyApp(drone,controller);
     48    MyApp* app=new MyApp(controller);
    4949
    5050    app->Start();
  • trunk/demos/Skeletons/CustomTorques/CMakeLists.txt

    r43 r122  
    66SET(FLAIR_USE_SENSOR_ACTUATOR TRUE)
    77SET(FLAIR_USE_META TRUE)
    8 SET(FLAIR_USE_VRPN TRUE)
    98
    109include($ENV{FLAIR_ROOT}/flair-dev/cmake-modules/GlobalCmakeFlair.cmake)
  • trunk/demos/Skeletons/CustomTorques/src/MyApp.cpp

    r43 r122  
    2626using namespace flair::sensor;
    2727
    28 MyApp::MyApp(Uav* uav,TargetController *controller): UavStateMachine(uav,controller), behaviourMode(BehaviourMode_t::Default) {
     28MyApp::MyApp(TargetController *controller): UavStateMachine(controller), behaviourMode(BehaviourMode_t::Default) {
    2929    start_CustomTorques=new PushButton(GetButtonsLayout()->NewRow(),"start CustomTorques");
    3030    stop_CustomTorques=new PushButton(GetButtonsLayout()->NewRow(),"stop CustomTorques");
  • trunk/demos/Skeletons/CustomTorques/src/MyApp.h

    r43 r122  
    2828class MyApp : public flair::meta::UavStateMachine {
    2929    public:
    30         MyApp(flair::meta::Uav* uav,flair::sensor::TargetController *controller);
     30        MyApp(flair::sensor::TargetController *controller);
    3131        ~MyApp();
    3232
  • trunk/demos/Skeletons/CustomTorques/src/main.cpp

    r43 r122  
    4545    manager->SetupLogger(log_path);
    4646
    47     Uav* drone=CreateUav(manager,name,uav_type);
     47    Uav* drone=CreateUav(name,uav_type);
    4848    TargetEthController *controller=new TargetEthController(manager,"Dualshock3",ds3port);
    49     MyApp* app=new MyApp(drone,controller);
     49    MyApp* app=new MyApp(controller);
    5050
    5151    app->Start();
Note: See TracChangeset for help on using the changeset viewer.