Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Global.cpp
- Revision:
- 0:2a15bd367891
- Child:
- 1:3f857674a290
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Global.cpp Mon Sep 07 01:19:55 2015 +0000 @@ -0,0 +1,122 @@ +#include "mbed.h" +#include "Global.h" +int Global::maxpitch = 10;// +int Global::minpitch = -10;// +int Global::Global::maxyaw = 10;// +int Global::minyaw = -10;// +float Global::maxrudderangle = 600.0;//係数変更でサーボ稼働幅調整 +float Global::minrudderangle = -maxrudderangle;//別の値を入れたら非対称にしたりもできる +float Global::maxelevatorangle = 900.0;//係数変更でサーボ稼働幅調整 +float Global::minelevatorangle = -maxelevatorangle;//別の値を入れたら非対称にしたりもできる +double Global::neutralpitchdegree; +double Global::neutralyawdegree; +double Global::maxpitchdegree; +double Global::minpitchdegree; +double Global::maxyawdegree; +double Global::minyawdegree; +double Global::neutralrudderangle; +double Global::neutralelevatorangle; +double Global::trimpitch; +double Global::trimyaw; +double Global::inttrimpitch; +double Global::inttrimyaw; +std::vector<double> Global::_pitch; +std::vector<double> Global::_yaw; +std::vector<double> Global::_airspeed; +std::vector<double> Global::_cadence; +std::vector<double> Global::_altitude; +//double Global::_pitch; +//double Global::_yaw; + +void Global::initialize(){ +} + +Timer Global::timer; +DigitalIn Global::initializeswitch(p23,PullUp);//否定で押しているとき +DigitalOut Global::led1(LED1); +DigitalOut Global::led2(LED2); +DigitalOut Global::led3(LED3); +DigitalOut Global::led4(LED4); + +//固定定数 +int Global::getmaxpitch(){return maxpitch;} +int Global::getminpitch(){return minpitch;} +int Global::getmaxyaw(){return maxyaw;} +int Global::getminyaw(){return minyaw;} +float Global::getmaxrudderangle(){return maxrudderangle;} +float Global::getminrudderangle(){return minrudderangle;} +float Global::getmaxelevatorangle(){return maxelevatorangle;} +float Global::getminelevatorangle(){return minelevatorangle;} +double Global::gettrimpitch(){return trimpitch;} +double Global::gettrimyaw(){return trimyaw;} +double Global::getinttrimpitch(){return inttrimpitch;} +double Global::getinttrimyaw(){return inttrimyaw;} +//初期化される定数 +void Global::setmaxpitchdegree(double _maxpitchdegree){maxpitchdegree=_maxpitchdegree;} +void Global::setneutralpitchdegree(double _neutralpitchdegree){neutralpitchdegree=_neutralpitchdegree;} +void Global::setminpitchdegree(double _minpitchdegree){minpitchdegree=_minpitchdegree;} +void Global::setmaxyawdegree(double _maxyawdegree){maxyawdegree=_maxyawdegree;} +void Global::setneutralyawdegree(double _neutralyawdegree){neutralyawdegree=_neutralyawdegree;} +void Global::setminyawdegree(double _minyawdegree){minyawdegree=_minyawdegree;} +void Global::setneutralrudderangle(double _neutralrudderangle){neutralrudderangle=_neutralrudderangle;} +void Global::setneutralelevatorangle(double _neutralelevatorangle){neutralelevatorangle=_neutralelevatorangle;} +void Global::settrimpitch(double _trimpitch){trimpitch = _trimpitch;} +void Global::settrimyaw(double _trimyaw){trimyaw = _trimyaw;} +void Global::setinttrimpitch(double _inttrimpitch){inttrimpitch = _inttrimpitch;} +void Global::setinttrimyaw(double _inttrimyaw){inttrimyaw = _inttrimyaw;} +//変数 +void Global::setpitch(double pitch){ + if(_pitch.size()>100)_pitch.clear(); + _pitch.push_back(pitch); +} +void Global::setyaw(double yaw){ + if(_yaw.size()>100)_yaw.clear(); + _yaw.push_back(yaw); +} +void Global::setairspeed(double airspeed){ + if(_airspeed.size()>100)_airspeed.clear(); + _airspeed.push_back(airspeed); +} +void Global::setcadence(double cadence){ + if(_cadence.size()>100)_cadence.clear(); + _cadence.push_back(cadence); +} +void Global::setaltitude(double altitude){ + if(_altitude.size()>100)_altitude.clear(); + _altitude.push_back(altitude); +} +double Global::getpitch(){ +// writeonpc("pitch=%f\t",_pitch.back()); + return _pitch.back(); +} +double Global::getyaw(){ +// writeonpc("yaw=%f\r\n",_yaw.back()); + return _yaw.back(); +} +double Global::getairspeed(){ +// writeonpc("airspeed=%f\r\n",_airspeed.back()); + return _airspeed.back(); +} +double Global::getcadence(){ +// writeonpc("cadence=%f\r\n",_cadence.back()); + return _cadence.back(); +} +double Global::getaltitude(){ +// writeonpc("altitude=%f\r\n",_altitude.back()); + return _altitude.back(); +} + +void Global::store(std::vector<double> &pitch, std::vector<double> &yaw, + std::vector<double> &airspeed, std::vector<double> &cadence, std::vector<double> &altitude){ + copy(_pitch.begin(), _pitch.end(), back_inserter(pitch)); + copy(_yaw.begin(), _yaw.end(), back_inserter(yaw)); + copy(_airspeed.begin(), _airspeed.end(), back_inserter(airspeed)); + copy(_cadence.begin(), _cadence.end(), back_inserter(cadence)); + copy(_altitude.begin(), _altitude.end(), back_inserter(altitude)); + + _pitch.clear(); + _yaw.clear(); + _airspeed.clear(); + _cadence.clear(); + _altitude.clear(); +}