[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: 2016/02/08
|
---|
| 6 | // filename: SimuX4.cpp
|
---|
| 7 | //
|
---|
| 8 | // author: Guillaume Sanahuja
|
---|
| 9 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 10 | //
|
---|
| 11 | // version: $Id: $
|
---|
| 12 | //
|
---|
[22] | 13 | // purpose: Class defining a simulation x4 uav
|
---|
[7] | 14 | //
|
---|
| 15 | //
|
---|
| 16 | /*********************************************************************/
|
---|
| 17 |
|
---|
| 18 | #include "SimuX4.h"
|
---|
| 19 | #include <FrameworkManager.h>
|
---|
| 20 | #include <X4X8Multiplex.h>
|
---|
| 21 | #include <SimuImu.h>
|
---|
| 22 | #include <SimuAhrs.h>
|
---|
| 23 | #include <SimuBldc.h>
|
---|
| 24 | #include <SimuUs.h>
|
---|
| 25 | #include <SimuCamera.h>
|
---|
| 26 | #include <BatteryMonitor.h>
|
---|
| 27 | #include <Tab.h>
|
---|
[157] | 28 | #include <FindArgument.h>
|
---|
[7] | 29 |
|
---|
| 30 | using std::string;
|
---|
| 31 | using namespace flair::core;
|
---|
| 32 | using namespace flair::gui;
|
---|
| 33 | using namespace flair::sensor;
|
---|
| 34 | using namespace flair::filter;
|
---|
| 35 | using namespace flair::actuator;
|
---|
| 36 |
|
---|
[15] | 37 | namespace flair {
|
---|
| 38 | namespace meta {
|
---|
[7] | 39 |
|
---|
[158] | 40 | SimuX4::SimuX4(string name, uint32_t simu_id,string options,
|
---|
[15] | 41 | filter::UavMultiplex *multiplex)
|
---|
[122] | 42 | : Uav(name, multiplex) {
|
---|
[7] | 43 |
|
---|
[15] | 44 | if (multiplex == NULL)
|
---|
[137] | 45 | SetMultiplex(new X4X8Multiplex("motors", X4X8Multiplex::X4));
|
---|
[7] | 46 |
|
---|
[15] | 47 | SetBldc(new SimuBldc(GetUavMultiplex(), GetUavMultiplex()->GetLayout(),
|
---|
[158] | 48 | "motors", GetUavMultiplex()->MotorsCount(), simu_id,0));
|
---|
| 49 | SetUsRangeFinder(new SimuUs("us", simu_id,0, 60));
|
---|
| 50 | SetAhrs(new SimuAhrs("imu", simu_id, 0,70));
|
---|
[122] | 51 | Tab *bat_tab = new Tab(getFrameworkManager()->GetTabWidget(), "battery");
|
---|
[15] | 52 | SetBatteryMonitor(new BatteryMonitor(bat_tab->NewRow(), "battery"));
|
---|
| 53 | GetBatteryMonitor()->SetBatteryValue(12);
|
---|
[157] | 54 |
|
---|
| 55 | string camvOpts=FindArgument(options,"camv=",false);
|
---|
| 56 | uint16_t camvWidth=320,camvHeight=240;
|
---|
| 57 | if(camvOpts=="") {
|
---|
| 58 | Info("using default vertical camera resolution: %ix%i\n",camvWidth, camvHeight);
|
---|
| 59 | }
|
---|
| 60 |
|
---|
[158] | 61 | SetVerticalCamera(new SimuCamera("simu_cam_v", camvWidth, camvHeight, 3, simu_id,0, 10));
|
---|
| 62 | //SetHorizontalCamera(new SimuCamera("simu_cam_h", 320, 240, 3, simu_id,1, 10));
|
---|
[7] | 63 | }
|
---|
| 64 |
|
---|
[15] | 65 | SimuX4::~SimuX4() {}
|
---|
[7] | 66 |
|
---|
| 67 | void SimuX4::StartSensors(void) {
|
---|
[157] | 68 | ((SimuImu *)(GetAhrs()->GetImu()))->Start();
|
---|
[15] | 69 | ((SimuUs *)GetUsRangeFinder())->Start();
|
---|
| 70 | ((SimuCamera *)GetVerticalCamera())->Start();
|
---|
[7] | 71 | }
|
---|
| 72 |
|
---|
[157] | 73 |
|
---|
[7] | 74 | } // end namespace meta
|
---|
| 75 | } // end namespace flair
|
---|