00001 /* 00002 Copyright (c) 2010 Les Newell. All rights reserved 00003 00004 This program is free software: you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation, either version 3 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 /* 00019 Kinematics base class. 00020 Kinematics modules convert flight control pitch, yaw, roll and throttle commands 00021 to motor and servo commands. 00022 */ 00023 00035 class Kinematics : public Module 00036 { 00037 DECLARE_MODULE(Kinematics,Module) 00038 00039 00040 //Only use this to expose sockets and parameters. Do most of your 00041 //initialisastion in Init() 00042 Kinematics() 00043 { 00044 } 00045 00046 //A parameter has changed. This happens at bootup if the EEPROM 00047 //contains valid data and at run-time if the user changes a 00048 //parameter over the serial link 00049 virtual void ParamChanged(Socket * param) 00050 { 00051 } 00052 00053 //Initialise the module 00054 //set up hardware etc 00055 //NOTE: You must call Kinematics::Init() from your INit() function 00056 virtual void Init() 00057 { 00058 m_commands[PITCH].Connect("FlightControl.Pitch"); 00059 m_commands[ROLL].Connect("FlightControl.Roll"); 00060 m_commands[YAW].Connect("FlightControl.Yaw"); 00061 m_commands[THROTTLE].Connect("FlightControl.Throttle"); 00062 m_flightMode.Connect("FlightMode.Status"); 00063 } 00064 00065 //Here is where you do your work. It is called at the rate defined by SetInterval 00066 virtual void Loop(const unsigned long& interval) 00067 { 00068 } 00069 00070 protected: 00071 Plug8 m_flightMode; 00072 PlugF m_commands[MAX_COMMANDS]; 00073 }; 00074
1.7.0