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

Last change on this file since 452 was 417, checked in by Sanahuja Guillaume, 3 years ago

define and use passthrough ahrs

File size: 2.4 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
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#ifdef ARMV7A
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 <PassthroughAhrs.h>
25#include <Gx3_25_imu.h>
26#include <AfroBldc.h>
27#include <X4X8Multiplex.h>
28#include <Ps3Eye.h>
29#include <BatteryMonitor.h>
30#include <Tab.h>
31
32using std::string;
33using namespace flair::core;
34using namespace flair::gui;
35using namespace flair::sensor;
36using namespace flair::filter;
37using namespace flair::actuator;
38
39namespace flair {
40namespace meta {
41
42XAir::XAir(string name, string options,
43 filter::UavMultiplex *multiplex)
44 : Uav(name, multiplex) {
45 RTDM_I2cPort *i2cport = new RTDM_I2cPort(getFrameworkManager(), "rtdm_i2c", "rti2c3");
46 RTDM_SerialPort *imu_port = new RTDM_SerialPort(getFrameworkManager(), "imu_port", "rtser1");
47
48 if (multiplex == NULL)
49 SetMultiplex(new X4X8Multiplex("motors", X4X8Multiplex::X8));
50
51 SetBldc(new AfroBldc(GetUavMultiplex(), GetUavMultiplex()->GetLayout(),
52 "motors", GetUavMultiplex()->MotorsCount(), i2cport));
53 SetUsRangeFinder(new Srf08("SRF08", i2cport, 0x70, 60));
54 SetAhrs(new PassthroughAhrs(new Gx3_25_imu("imu",imu_port,Gx3_25_imu::AccelerationAngularRateAndOrientationMatrix, 70),"ahrs"));
55
56 Tab *bat_tab = new Tab(getFrameworkManager()->GetTabWidget(), "battery");
57 SetBatteryMonitor(new BatteryMonitor(bat_tab->NewRow(), "battery"));
58 GetBatteryMonitor()->SetBatteryValue(12);
59
60 if(Image::IsUsingDefaultAllocAndFree()) {
61 SetVerticalCamera(new Ps3Eye("camv", 0, false,50));//no cmem and no dsp
62 } else {
63 SetVerticalCamera(new Ps3Eye("camv", 0, true,50));//cmem and dsp
64 }
65}
66
67XAir::~XAir() {}
68
69void XAir::StartSensors(void) {
70 ((Gx3_25_imu *)(GetAhrs()->GetImu()))->Start();
71 ((Srf08 *)GetUsRangeFinder())->Start();
72 ((Ps3Eye *)GetVerticalCamera())->Start();
73}
74
75bool XAir::isReadyToFly(void) const {
76 return GetAhrs()->GetImu()->IsReady();
77}
78
79} // end namespace meta
80} // end namespace flair
81
82#endif
Note: See TracBrowser for help on using the repository browser.