source: flair-src/trunk/lib/FlairFilter/src/PidThrust.cpp@ 200

Last change on this file since 200 was 157, checked in by Sanahuja Guillaume, 7 years ago

iadded isready to iodevice:
avoid problem of imu not ready in ardrone2

File size: 2.0 KB
RevLine 
[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: 2014/11/07
6// filename: PidThrust.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: Class defining a PidThrust
14//
15//
16/*********************************************************************/
17
18#include "PidThrust.h"
19#include "PidThrust_impl.h"
20#include <cvmatrix.h>
21#include <Layout.h>
22#include <LayoutPosition.h>
23#include <DoubleSpinBox.h>
24
25using std::string;
26using namespace flair::core;
27using namespace flair::gui;
28
[15]29namespace flair {
30namespace filter {
[7]31
[15]32PidThrust::PidThrust(const LayoutPosition *position, string name)
33 : ControlLaw(position->getLayout(), name) {
34 pimpl_ = new PidThrust_impl(this, position, name);
[157]35
36 SetIsReady(true);
[7]37}
38
[15]39PidThrust::~PidThrust(void) { delete pimpl_; }
[7]40
[15]41void PidThrust::UseDefaultPlot(const flair::gui::LayoutPosition *position) {
42 pimpl_->UseDefaultPlot(position);
[7]43}
44
45void PidThrust::Reset(void) {
[15]46 pimpl_->i = 0;
47 pimpl_->offset_g = 0;
[7]48}
49
[15]50void PidThrust::ResetI(void) { pimpl_->i = 0; }
[7]51
[15]52float PidThrust::GetOffset(void) { return pimpl_->offset_g; }
[7]53
[15]54void PidThrust::UpdateFrom(const io_data *data) {
55 pimpl_->UpdateFrom(data);
56 ProcessUpdate(output);
[7]57}
58
[15]59void PidThrust::SetValues(float p, float d) {
60 input->SetValue(0, 0, p);
61 input->SetValue(1, 0, d);
[7]62}
63
[15]64void PidThrust::ResetOffset(void) { pimpl_->offset_g = 0; }
[7]65
[15]66void PidThrust::SetOffset(void) { pimpl_->offset_g = pimpl_->offset->Value(); }
[7]67
[15]68bool PidThrust::OffsetStepUp(void) {
69 pimpl_->offset_g += pimpl_->pas_offset->Value();
70 if (pimpl_->offset_g > 1) {
71 pimpl_->offset_g = 1;
72 return false;
73 } else {
74 return true;
75 }
[7]76}
77
[15]78bool PidThrust::OffsetStepDown(void) {
79 pimpl_->offset_g -= pimpl_->pas_offset->Value();
80 if (pimpl_->offset_g < pimpl_->offset->Value()) {
81 pimpl_->offset_g = pimpl_->offset->Value();
82 return false;
83 } else {
84 return true;
85 }
[7]86}
87
88} // end namespace filter
89} // end namespace flair
Note: See TracBrowser for help on using the repository browser.