source: flair-src/tags/latest/lib/FlairMeta/src/HdsX8.cpp

Last change on this file was 403, checked in by Sanahuja Guillaume, 7 months ago

select user memory pointer (v4l) if using custom alloc function in images (ie if initdsp was called)

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