Changeset 122 in flair-src for trunk/demos/CircleFollower/uav/src
- Timestamp:
- Jan 6, 2017, 1:56:26 PM (8 years ago)
- Location:
- trunk/demos/CircleFollower/uav/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/demos/CircleFollower/uav/src/CircleFollower.cpp
r121 r122 39 39 using namespace flair::meta; 40 40 41 CircleFollower::CircleFollower(Uav* uav,TargetController *controller): UavStateMachine(uav,controller), behaviourMode(BehaviourMode_t::Default), vrpnLost(false) { 42 uav->SetupVRPNAutoIP(uav->ObjectName()); 43 41 CircleFollower::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 44 49 startCircle=new PushButton(GetButtonsLayout()->NewRow(),"start_circle"); 45 50 stopCircle=new PushButton(GetButtonsLayout()->LastRowLastCol(),"stop_circle"); 46 51 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); 49 54 } else { 50 targetVrpn=new MetaVrpnObject( uav->GetVrpnClient(),"target");55 targetVrpn=new MetaVrpnObject("target"); 51 56 } 52 57 53 58 getFrameworkManager()->AddDeviceToLog(targetVrpn); 54 59 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"); 61 66 62 67 uX=new Pid(setupLawTab->At(1,0),"u_x"); … … 79 84 //get yaw from vrpn 80 85 Euler vrpnEuler; 81 GetUav()->GetVrpnObject()->GetEuler(vrpnEuler);86 uavVrpn->GetEuler(vrpnEuler); 82 87 83 88 //get roll, pitch and w from imu … … 98 103 Vector3D uav_pos,uav_vel; 99 104 100 GetUav()->GetVrpnObject()->GetPosition(uav_pos);101 GetUav()->GetVrpnObject()->GetSpeed(uav_vel);105 uavVrpn->GetPosition(uav_pos); 106 uavVrpn->GetSpeed(uav_vel); 102 107 //z and dz must be in uav's frame 103 108 z=-uav_pos.z; … … 131 136 Vector2D uav_2Dpos,uav_2Dvel; // in VRPN coordinate system 132 137 133 GetUav()->GetVrpnObject()->GetPosition(uav_pos);134 GetUav()->GetVrpnObject()->GetSpeed(uav_vel);138 uavVrpn->GetPosition(uav_pos); 139 uavVrpn->GetSpeed(uav_vel); 135 140 136 141 uav_pos.To2Dxy(uav_2Dpos); … … 195 200 Land(); 196 201 } 197 if (! GetUav()->GetVrpnObject()->IsTracked(500)) {202 if (!uavVrpn->IsTracked(500)) { 198 203 Thread::Err("VRPN, uav lost\n"); 199 204 vrpnLost=true; … … 239 244 circle->SetCenter(target_2Dpos); 240 245 241 GetUav()->GetVrpnObject()->GetPosition(uav_pos);246 uavVrpn->GetPosition(uav_pos); 242 247 uav_pos.To2Dxy(uav_2Dpos); 243 248 circle->StartTraj(uav_2Dpos); … … 258 263 Vector3D vrpn_pos; 259 264 260 GetUav()->GetVrpnObject()->GetEuler(vrpn_euler);265 uavVrpn->GetEuler(vrpn_euler); 261 266 yawHold=vrpn_euler.yaw; 262 267 263 GetUav()->GetVrpnObject()->GetPosition(vrpn_pos);268 uavVrpn->GetPosition(vrpn_pos); 264 269 vrpn_pos.To2Dxy(posHold); 265 270 -
trunk/demos/CircleFollower/uav/src/CircleFollower.h
r38 r122 34 34 class CircleFollower : public flair::meta::UavStateMachine { 35 35 public: 36 CircleFollower(flair:: meta::Uav* uav,flair::sensor::TargetController *controller);36 CircleFollower(flair::sensor::TargetController *controller); 37 37 ~CircleFollower(); 38 38 … … 65 65 66 66 flair::gui::PushButton *startCircle,*stopCircle; 67 flair::meta::MetaVrpnObject *targetVrpn ;67 flair::meta::MetaVrpnObject *targetVrpn,*uavVrpn; 68 68 flair::filter::TrajectoryGenerator2DCircle *circle; 69 69 flair::core::AhrsData *customReferenceOrientation,*customOrientation; -
trunk/demos/CircleFollower/uav/src/main.cpp
r38 r122 45 45 manager->SetupLogger(log_path); 46 46 47 Uav* drone=CreateUav( manager,name,uav_type);47 Uav* drone=CreateUav(name,uav_type); 48 48 TargetEthController *controller=new TargetEthController(manager,"Dualshock3",ds3port); 49 CircleFollower* demo=new CircleFollower( drone,controller);49 CircleFollower* demo=new CircleFollower(controller); 50 50 51 51 demo->Start();
Note:
See TracChangeset
for help on using the changeset viewer.