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 | #ifdef ARMV7A
|
---|
18 |
|
---|
19 | #include "HdsX8.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 <BlCtrlV2.h>
|
---|
27 | #include <X4X8Multiplex.h>
|
---|
28 | #include <Ps3Eye.h>
|
---|
29 | #include <Mb800.h>
|
---|
30 | #include <FindArgument.h>
|
---|
31 |
|
---|
32 | using std::string;
|
---|
33 | using namespace flair::core;
|
---|
34 | using namespace flair::sensor;
|
---|
35 | using namespace flair::filter;
|
---|
36 | using namespace flair::actuator;
|
---|
37 |
|
---|
38 | namespace flair {
|
---|
39 | namespace meta {
|
---|
40 |
|
---|
41 | HdsX8::HdsX8(string name,string options,
|
---|
42 | filter::UavMultiplex *multiplex)
|
---|
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");
|
---|
46 |
|
---|
47 | if (multiplex == NULL)
|
---|
48 | SetMultiplex(new X4X8Multiplex( "motors", X4X8Multiplex::X8));
|
---|
49 |
|
---|
50 | SetBldc(new BlCtrlV2(GetUavMultiplex(), GetUavMultiplex()->GetLayout(),
|
---|
51 | "motors", GetUavMultiplex()->MotorsCount(), i2cport));
|
---|
52 | SetUsRangeFinder(new Srf08("SRF08", i2cport, 0x70, 60));
|
---|
53 |
|
---|
54 | SetAhrs(new PassthroughAhrs(new Gx3_25_imu("imu",imu_port,Gx3_25_imu::AccelerationAngularRateAndOrientationMatrix, 70),"ahrs"));
|
---|
55 | SetBatteryMonitor(((BlCtrlV2 *)GetBldc())->GetBatteryMonitor());
|
---|
56 |
|
---|
57 | if(Image::IsUsingDefaultAllocAndFree()) {
|
---|
58 | SetVerticalCamera(new Ps3Eye("camv", 0, false,50));//no cmem and no dsp
|
---|
59 | } else {
|
---|
60 | SetVerticalCamera(new Ps3Eye("camv", 0, true,50));//cmem and dsp
|
---|
61 | }
|
---|
62 |
|
---|
63 | string useGps=FindArgument(options,"use_gps=",false);
|
---|
64 | if(useGps=="true") {
|
---|
65 | RTDM_SerialPort *gps_port = new RTDM_SerialPort(getFrameworkManager(), "gps_port", "rtser2");
|
---|
66 | SetGps(new Mb800("gps",gps_port,(NmeaGps::NMEAFlags_t)(NmeaGps::GGA|NmeaGps::VTG|NmeaGps::GSA),40));
|
---|
67 | }
|
---|
68 | }
|
---|
69 |
|
---|
70 | HdsX8::~HdsX8() {}
|
---|
71 |
|
---|
72 | void HdsX8::StartSensors(void) {
|
---|
73 | ((Gx3_25_imu *)(GetAhrs()->GetImu()))->Start();
|
---|
74 | ((Srf08 *)GetUsRangeFinder())->Start();
|
---|
75 | ((Ps3Eye *)GetVerticalCamera())->Start();
|
---|
76 | if(GetGps()) ((Mb800 *)GetGps())->Start();
|
---|
77 | }
|
---|
78 |
|
---|
79 | bool HdsX8::isReadyToFly(void) const {
|
---|
80 | return GetAhrs()->GetImu()->IsReady();
|
---|
81 | }
|
---|
82 |
|
---|
83 | } // end namespace meta
|
---|
84 | } // end namespace flair
|
---|
85 |
|
---|
86 | #endif
|
---|