uncrustify libraries/AP_PID/examples/AP_pid/AP_pid.pde

This commit is contained in:
uncrustify 2012-08-16 23:20:59 -07:00 committed by Pat Hickey
parent c4059511cb
commit 90a600fd82

View File

@ -1,51 +1,51 @@
/* /*
Example of PID library. * Example of PID library.
2010 Code by Jason Short. DIYDrones.com * 2010 Code by Jason Short. DIYDrones.com
*/ */
#include <Arduino_Mega_ISR_Registry.h> #include <Arduino_Mega_ISR_Registry.h>
#include <FastSerial.h> #include <FastSerial.h>
#include <AP_Common.h> #include <AP_Common.h>
#include <APM_RC.h> // ArduPilot RC Library #include <APM_RC.h> // ArduPilot RC Library
#include <AP_PID.h> // ArduPilot Mega RC Library #include <AP_PID.h> // ArduPilot Mega RC Library
long radio_in; long radio_in;
long radio_trim; long radio_trim;
Arduino_Mega_ISR_Registry isr_registry; Arduino_Mega_ISR_Registry isr_registry;
AP_PID pid; AP_PID pid;
APM_RC_APM1 APM_RC; APM_RC_APM1 APM_RC;
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
Serial.println("ArduPilot Mega AP_PID library test"); Serial.println("ArduPilot Mega AP_PID library test");
isr_registry.init(); isr_registry.init();
APM_RC.Init(&isr_registry); // APM Radio initialization APM_RC.Init(&isr_registry); // APM Radio initialization
delay(1000); delay(1000);
//rc.trim(); //rc.trim();
radio_trim = APM_RC.InputCh(0); radio_trim = APM_RC.InputCh(0);
pid.kP(1); pid.kP(1);
pid.kI(0); pid.kI(0);
pid.kD(0.5); pid.kD(0.5);
pid.imax(50); pid.imax(50);
pid.kP(0); pid.kP(0);
pid.kI(0); pid.kI(0);
pid.kD(0); pid.kD(0);
pid.imax(0); pid.imax(0);
Serial.printf("P %f I %f D %f imax %f\n", pid.kP(), pid.kI(), pid.kD(), pid.imax()); Serial.printf("P %f I %f D %f imax %f\n", pid.kP(), pid.kI(), pid.kD(), pid.imax());
} }
void loop() void loop()
{ {
delay(20); delay(20);
//rc.read_pwm(); //rc.read_pwm();
long error = APM_RC.InputCh(0) - radio_trim; long error = APM_RC.InputCh(0) - radio_trim;
long control = pid.get_pid(error, 20, 1); long control = pid.get_pid(error, 20, 1);
Serial.print("control: "); Serial.print("control: ");
Serial.println(control,DEC); Serial.println(control,DEC);
} }