source: flair-src/trunk/lib/FlairMeta/src/HdsX8.cpp@ 186

Last change on this file since 186 was 186, checked in by Sanahuja Guillaume, 5 years ago

maj imu

File size: 2.3 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: HdsX8.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: Class defining a HDS X8 uav
14//
15//
16/*********************************************************************/
17
18#include "HdsX8.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 <BlCtrlV2.h>
25#include <X4X8Multiplex.h>
26#include <Ps3Eye.h>
27#include <Mb800.h>
28#include <FindArgument.h>
29
30using std::string;
31using namespace flair::core;
32using namespace flair::sensor;
33using namespace flair::filter;
34using namespace flair::actuator;
35
36namespace flair {
37namespace meta {
38
39HdsX8::HdsX8(string name,string options,
40 filter::UavMultiplex *multiplex)
41 : Uav(name, multiplex) {
42 RTDM_I2cPort *i2cport = new RTDM_I2cPort(getFrameworkManager(), "rtdm_i2c", "rti2c3");
43 RTDM_SerialPort *imu_port = new RTDM_SerialPort(getFrameworkManager(), "imu_port", "rtser1");
44
45 if (multiplex == NULL)
46 SetMultiplex(new X4X8Multiplex( "motors", X4X8Multiplex::X8));
47
48 SetBldc(new BlCtrlV2(GetUavMultiplex(), GetUavMultiplex()->GetLayout(),
49 "motors", GetUavMultiplex()->MotorsCount(), i2cport));
50 SetUsRangeFinder(new Srf08("SRF08", i2cport, 0x70, 60));
51 SetAhrs(new Gx3_25_ahrs("ahrs", imu_port,
52 Gx3_25_imu::AccelerationAngularRateAndOrientationMatrix, 70));
53 SetBatteryMonitor(((BlCtrlV2 *)GetBldc())->GetBatteryMonitor());
54 SetVerticalCamera(new Ps3Eye("camv", 0, 50));
55
56 string useGps=FindArgument(options,"use_gps=",false);
57 if(useGps=="true") {
58 RTDM_SerialPort *gps_port = new RTDM_SerialPort(getFrameworkManager(), "gps_port", "rtser2");
59 SetGps(new Mb800("gps",gps_port,(NmeaGps::NMEAFlags_t)(NmeaGps::GGA|NmeaGps::VTG|NmeaGps::GSA),40));
60 }
61}
62
63HdsX8::~HdsX8() {}
64
65void HdsX8::StartSensors(void) {
66 ((Gx3_25_imu *)(GetAhrs()->GetImu()))->Start();
67 ((Srf08 *)GetUsRangeFinder())->Start();
68 ((Ps3Eye *)GetVerticalCamera())->Start();
69 if(GetGps()) ((Mb800 *)GetGps())->Start();
70}
71
72bool HdsX8::isReadyToFly(void) const {
73 return GetAhrs()->GetImu()->IsReady();
74}
75
76} // end namespace meta
77} // end namespace flair
Note: See TracBrowser for help on using the repository browser.