[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: HdsX8.cpp
|
---|
| 7 | //
|
---|
| 8 | // author: Guillaume Sanahuja
|
---|
| 9 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 10 | //
|
---|
| 11 | // version: $Id: $
|
---|
| 12 | //
|
---|
[22] | 13 | // purpose: Class defining a HDS X8 uav
|
---|
[7] | 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>
|
---|
[185] | 27 | #include <Mb800.h>
|
---|
| 28 | #include <FindArgument.h>
|
---|
[7] | 29 |
|
---|
| 30 | using std::string;
|
---|
| 31 | using namespace flair::core;
|
---|
| 32 | using namespace flair::sensor;
|
---|
| 33 | using namespace flair::filter;
|
---|
| 34 | using namespace flair::actuator;
|
---|
| 35 |
|
---|
[15] | 36 | namespace flair {
|
---|
| 37 | namespace meta {
|
---|
[7] | 38 |
|
---|
[157] | 39 | HdsX8::HdsX8(string name,string options,
|
---|
[15] | 40 | filter::UavMultiplex *multiplex)
|
---|
[122] | 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");
|
---|
[7] | 44 |
|
---|
[15] | 45 | if (multiplex == NULL)
|
---|
[137] | 46 | SetMultiplex(new X4X8Multiplex( "motors", X4X8Multiplex::X8));
|
---|
[7] | 47 |
|
---|
[15] | 48 | SetBldc(new BlCtrlV2(GetUavMultiplex(), GetUavMultiplex()->GetLayout(),
|
---|
| 49 | "motors", GetUavMultiplex()->MotorsCount(), i2cport));
|
---|
[137] | 50 | SetUsRangeFinder(new Srf08("SRF08", i2cport, 0x70, 60));
|
---|
[186] | 51 | SetAhrs(new Gx3_25_ahrs("ahrs", imu_port,
|
---|
[100] | 52 | Gx3_25_imu::AccelerationAngularRateAndOrientationMatrix, 70));
|
---|
[15] | 53 | SetBatteryMonitor(((BlCtrlV2 *)GetBldc())->GetBatteryMonitor());
|
---|
[137] | 54 | SetVerticalCamera(new Ps3Eye("camv", 0, 50));
|
---|
[185] | 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");
|
---|
[186] | 59 | SetGps(new Mb800("gps",gps_port,(NmeaGps::NMEAFlags_t)(NmeaGps::GGA|NmeaGps::VTG|NmeaGps::GSA),40));
|
---|
[185] | 60 | }
|
---|
[7] | 61 | }
|
---|
| 62 |
|
---|
[15] | 63 | HdsX8::~HdsX8() {}
|
---|
[7] | 64 |
|
---|
| 65 | void HdsX8::StartSensors(void) {
|
---|
[157] | 66 | ((Gx3_25_imu *)(GetAhrs()->GetImu()))->Start();
|
---|
[15] | 67 | ((Srf08 *)GetUsRangeFinder())->Start();
|
---|
[107] | 68 | ((Ps3Eye *)GetVerticalCamera())->Start();
|
---|
[186] | 69 | if(GetGps()) ((Mb800 *)GetGps())->Start();
|
---|
[7] | 70 | }
|
---|
| 71 |
|
---|
[157] | 72 | bool HdsX8::isReadyToFly(void) const {
|
---|
| 73 | return GetAhrs()->GetImu()->IsReady();
|
---|
| 74 | }
|
---|
| 75 |
|
---|
[7] | 76 | } // end namespace meta
|
---|
| 77 | } // end namespace flair
|
---|