[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 | /*********************************************************************/
|
---|
[268] | 17 | #ifdef ARMV7A
|
---|
[7] | 18 |
|
---|
| 19 | #include "XAir.h"
|
---|
| 20 | #include <FrameworkManager.h>
|
---|
| 21 | #include <RTDM_I2cPort.h>
|
---|
| 22 | #include <RTDM_SerialPort.h>
|
---|
| 23 | #include <Srf08.h>
|
---|
| 24 | #include <Gx3_25_ahrs.h>
|
---|
| 25 | #include <AfroBldc.h>
|
---|
| 26 | #include <X4X8Multiplex.h>
|
---|
| 27 | #include <Ps3Eye.h>
|
---|
| 28 | #include <BatteryMonitor.h>
|
---|
| 29 | #include <Tab.h>
|
---|
| 30 |
|
---|
| 31 | using std::string;
|
---|
| 32 | using namespace flair::core;
|
---|
| 33 | using namespace flair::gui;
|
---|
| 34 | using namespace flair::sensor;
|
---|
| 35 | using namespace flair::filter;
|
---|
| 36 | using namespace flair::actuator;
|
---|
| 37 |
|
---|
[15] | 38 | namespace flair {
|
---|
| 39 | namespace meta {
|
---|
[7] | 40 |
|
---|
[157] | 41 | XAir::XAir(string name, string options,
|
---|
[15] | 42 | filter::UavMultiplex *multiplex)
|
---|
[122] | 43 | : Uav(name, multiplex) {
|
---|
| 44 | RTDM_I2cPort *i2cport = new RTDM_I2cPort(getFrameworkManager(), "rtdm_i2c", "rti2c3");
|
---|
| 45 | RTDM_SerialPort *imu_port = new RTDM_SerialPort(getFrameworkManager(), "imu_port", "rtser1");
|
---|
[7] | 46 |
|
---|
[15] | 47 | if (multiplex == NULL)
|
---|
[137] | 48 | SetMultiplex(new X4X8Multiplex("motors", X4X8Multiplex::X8));
|
---|
[7] | 49 |
|
---|
[15] | 50 | SetBldc(new AfroBldc(GetUavMultiplex(), GetUavMultiplex()->GetLayout(),
|
---|
| 51 | "motors", GetUavMultiplex()->MotorsCount(), i2cport));
|
---|
[137] | 52 | SetUsRangeFinder(new Srf08("SRF08", i2cport, 0x70, 60));
|
---|
| 53 | SetAhrs(new Gx3_25_ahrs("imu", imu_port,
|
---|
[100] | 54 | Gx3_25_imu::AccelerationAngularRateAndOrientationMatrix, 70));
|
---|
[122] | 55 | Tab *bat_tab = new Tab(getFrameworkManager()->GetTabWidget(), "battery");
|
---|
[15] | 56 | SetBatteryMonitor(new BatteryMonitor(bat_tab->NewRow(), "battery"));
|
---|
| 57 | GetBatteryMonitor()->SetBatteryValue(12);
|
---|
[137] | 58 | SetVerticalCamera(new Ps3Eye("camv", 0, 50));
|
---|
[7] | 59 | }
|
---|
| 60 |
|
---|
[15] | 61 | XAir::~XAir() {}
|
---|
[7] | 62 |
|
---|
| 63 | void XAir::StartSensors(void) {
|
---|
[157] | 64 | ((Gx3_25_imu *)(GetAhrs()->GetImu()))->Start();
|
---|
[15] | 65 | ((Srf08 *)GetUsRangeFinder())->Start();
|
---|
| 66 | ((Ps3Eye *)GetVerticalCamera())->Start();
|
---|
[7] | 67 | }
|
---|
| 68 |
|
---|
[157] | 69 | bool XAir::isReadyToFly(void) const {
|
---|
| 70 | return GetAhrs()->GetImu()->IsReady();
|
---|
| 71 | }
|
---|
| 72 |
|
---|
[7] | 73 | } // end namespace meta
|
---|
| 74 | } // end namespace flair
|
---|
[268] | 75 |
|
---|
| 76 | #endif |
---|