source: flair-src/trunk/lib/FlairMeta/src/XAir.cpp@ 206

Last change on this file since 206 was 157, checked in by Sanahuja Guillaume, 8 years ago

iadded isready to iodevice:
avoid problem of imu not ready in ardrone2

File size: 2.1 KB
RevLine 
[10]1// %flair:license{
[15]2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
[10]4// %flair:license}
[7]5// created: 2015/02/08
6// filename: XAir.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: Class defining a Xair uav
14//
15//
16/*********************************************************************/
17
18#include "XAir.h"
19#include <FrameworkManager.h>
20#include <RTDM_I2cPort.h>
21#include <RTDM_SerialPort.h>
22#include <Srf08.h>
23#include <Gx3_25_ahrs.h>
24#include <AfroBldc.h>
25#include <X4X8Multiplex.h>
26#include <Ps3Eye.h>
27#include <BatteryMonitor.h>
28#include <Tab.h>
29
30using std::string;
31using namespace flair::core;
32using namespace flair::gui;
33using namespace flair::sensor;
34using namespace flair::filter;
35using namespace flair::actuator;
36
[15]37namespace flair {
38namespace meta {
[7]39
[157]40XAir::XAir(string name, string options,
[15]41 filter::UavMultiplex *multiplex)
[122]42 : Uav(name, multiplex) {
43 RTDM_I2cPort *i2cport = new RTDM_I2cPort(getFrameworkManager(), "rtdm_i2c", "rti2c3");
44 RTDM_SerialPort *imu_port = new RTDM_SerialPort(getFrameworkManager(), "imu_port", "rtser1");
[7]45
[15]46 if (multiplex == NULL)
[137]47 SetMultiplex(new X4X8Multiplex("motors", X4X8Multiplex::X8));
[7]48
[15]49 SetBldc(new AfroBldc(GetUavMultiplex(), GetUavMultiplex()->GetLayout(),
50 "motors", GetUavMultiplex()->MotorsCount(), i2cport));
[137]51 SetUsRangeFinder(new Srf08("SRF08", i2cport, 0x70, 60));
52 SetAhrs(new Gx3_25_ahrs("imu", imu_port,
[100]53 Gx3_25_imu::AccelerationAngularRateAndOrientationMatrix, 70));
[122]54 Tab *bat_tab = new Tab(getFrameworkManager()->GetTabWidget(), "battery");
[15]55 SetBatteryMonitor(new BatteryMonitor(bat_tab->NewRow(), "battery"));
56 GetBatteryMonitor()->SetBatteryValue(12);
[137]57 SetVerticalCamera(new Ps3Eye("camv", 0, 50));
[7]58}
59
[15]60XAir::~XAir() {}
[7]61
62void XAir::StartSensors(void) {
[157]63 ((Gx3_25_imu *)(GetAhrs()->GetImu()))->Start();
[15]64 ((Srf08 *)GetUsRangeFinder())->Start();
65 ((Ps3Eye *)GetVerticalCamera())->Start();
[7]66}
67
[157]68bool XAir::isReadyToFly(void) const {
69 return GetAhrs()->GetImu()->IsReady();
70}
71
[7]72} // end namespace meta
73} // end namespace flair
Note: See TracBrowser for help on using the repository browser.