Exemple #1
0
    def __init__(self, pitch_p, pitch_i, pitch_d, elevator_p, elevator_i,
                 elevator_d, dt):
        self.target_altitude = 1000.0

        self.pitch_pid = PID(pitch_p, pitch_d, pitch_d, -15.0, 15.0, dt, 0.0)
        self.elevator_pid = PID(elevator_p, elevator_i, elevator_d, -1.0, 1.0,
                                dt, 200.0)
Exemple #2
0
class HeadingHoldAutopilot(object):
    def __init__(self, roll_p, roll_i, roll_d, aileron_p, aileron_i, aileron_d, dt):
        self.target_heading = 180.0
        
        self.course_pid = PID(roll_p, roll_i, roll_d, -15.0, 15.0, dt, 0.0)
        self.aileron_pid = PID(aileron_p, aileron_i, aileron_d, -1.0, 1.0, dt, 10.0)
        
    def set_target_heading(self, heading):
        self.target_heading = heading
    
    def get_aileron(self, current_course, current_roll):
        course_error = self.target_heading - current_course

        if course_error < -180.0:
            course_error = course_error + 360
        elif course_error > 180.0:
            course_error = course_error - 360

        target_roll = self.course_pid.calculateOutput(course_error)

        roll_error = target_roll - current_roll

        aileron = self.aileron_pid.calculateOutput(roll_error)
        
        return aileron;
Exemple #3
0
    def __init__(self, roll_p, roll_i, roll_d, aileron_p, aileron_i, aileron_d,
                 dt):
        self.target_heading = 180.0

        self.course_pid = PID(roll_p, roll_i, roll_d, -15.0, 15.0, dt, 0.0)
        self.aileron_pid = PID(aileron_p, aileron_i, aileron_d, -1.0, 1.0, dt,
                               10.0)
Exemple #4
0
class HeadingHoldAutopilot(object):
    def __init__(self, roll_p, roll_i, roll_d, aileron_p, aileron_i, aileron_d,
                 dt):
        self.target_heading = 180.0

        self.course_pid = PID(roll_p, roll_i, roll_d, -15.0, 15.0, dt, 0.0)
        self.aileron_pid = PID(aileron_p, aileron_i, aileron_d, -1.0, 1.0, dt,
                               10.0)

    def set_target_heading(self, heading):
        self.target_heading = heading

    def get_aileron(self, current_course, current_roll):
        course_error = self.target_heading - current_course

        if course_error < -180.0:
            course_error = course_error + 360
        elif course_error > 180.0:
            course_error = course_error - 360

        target_roll = self.course_pid.calculateOutput(course_error)

        roll_error = target_roll - current_roll

        aileron = self.aileron_pid.calculateOutput(roll_error)

        return aileron
Exemple #5
0
class AltitudeHoldAutopilot(object):
    def __init__(self, pitch_p, pitch_i, pitch_d, elevator_p, elevator_i, elevator_d, dt):
        self.target_altitude = 1000.0
        
        self.pitch_pid = PID(pitch_p, pitch_d, pitch_d, -15.0, 15.0, dt, 0.0)
        self.elevator_pid = PID(elevator_p, elevator_i, elevator_d, -1.0, 1.0, dt, 200.0)

    def set_target_altitude(self, altitude):
        self.target_altitude = altitude
    
    def get_elevator(self, current_altitude, current_pitch):
        altitude_error = self.target_altitude - current_altitude
        target_pitch = self.pitch_pid.calculateOutput(altitude_error)

        pitch_error = target_pitch - current_pitch
        elevator = -self.elevator_pid.calculateOutput(pitch_error)
        
        return elevator
Exemple #6
0
class AltitudeHoldAutopilot(object):
    def __init__(self, pitch_p, pitch_i, pitch_d, elevator_p, elevator_i,
                 elevator_d, dt):
        self.target_altitude = 1000.0

        self.pitch_pid = PID(pitch_p, pitch_d, pitch_d, -15.0, 15.0, dt, 0.0)
        self.elevator_pid = PID(elevator_p, elevator_i, elevator_d, -1.0, 1.0,
                                dt, 200.0)

    def set_target_altitude(self, altitude):
        self.target_altitude = altitude

    def get_elevator(self, current_altitude, current_pitch):
        altitude_error = self.target_altitude - current_altitude
        target_pitch = self.pitch_pid.calculateOutput(altitude_error)

        pitch_error = target_pitch - current_pitch
        elevator = -self.elevator_pid.calculateOutput(pitch_error)

        return elevator
Exemple #7
0
class AirspeedHoldAutopilot(object):
    def __init__(self, throttle_p, throttle_i, throttle_d, dt):
        self.target_airspeed = 65.0

        self.throttle_pid = PID(throttle_p, throttle_i, throttle_d, 0.0, 1.0, dt, 10.0)

    def set_target_airspeed(self, airspeed):
        self.target_airspeed = airspeed

    def get_throttle(self, current_airspeed):
        airspeed_error = self.target_airspeed - current_airspeed

        return self.throttle_pid.calculateOutput(airspeed_error)
Exemple #8
0
class AirspeedHoldAutopilot(object):
    def __init__(self, throttle_p, throttle_i, throttle_d, dt):
        self.target_airspeed = 65.0

        self.throttle_pid = PID(throttle_p, throttle_i, throttle_d, 0.0, 1.0,
                                dt, 10.0)

    def set_target_airspeed(self, airspeed):
        self.target_airspeed = airspeed

    def get_throttle(self, current_airspeed):
        airspeed_error = self.target_airspeed - current_airspeed

        return self.throttle_pid.calculateOutput(airspeed_error)
Exemple #9
0
    def __init__(self, throttle_p, throttle_i, throttle_d, dt):
        self.target_airspeed = 65.0

        self.throttle_pid = PID(throttle_p, throttle_i, throttle_d, 0.0, 1.0, dt, 10.0)
Exemple #10
0
 def __init__(self, roll_p, roll_i, roll_d, aileron_p, aileron_i, aileron_d, dt):
     self.target_heading = 180.0
     
     self.course_pid = PID(roll_p, roll_i, roll_d, -15.0, 15.0, dt, 0.0)
     self.aileron_pid = PID(aileron_p, aileron_i, aileron_d, -1.0, 1.0, dt, 10.0)
Exemple #11
0
    def __init__(self, throttle_p, throttle_i, throttle_d, dt):
        self.target_airspeed = 65.0

        self.throttle_pid = PID(throttle_p, throttle_i, throttle_d, 0.0, 1.0,
                                dt, 10.0)
Exemple #12
0
 def __init__(self, pitch_p, pitch_i, pitch_d, elevator_p, elevator_i, elevator_d, dt):
     self.target_altitude = 1000.0
     
     self.pitch_pid = PID(pitch_p, pitch_d, pitch_d, -15.0, 15.0, dt, 0.0)
     self.elevator_pid = PID(elevator_p, elevator_i, elevator_d, -1.0, 1.0, dt, 200.0)