Presentation is loading. Please wait.

Presentation is loading. Please wait.

Andi’s Autopilot A Hard Real-Time Control Application Broderic Gonzales CS 722 May 2, 2005 v.05.

Similar presentations


Presentation on theme: "Andi’s Autopilot A Hard Real-Time Control Application Broderic Gonzales CS 722 May 2, 2005 v.05."— Presentation transcript:

1 Andi’s Autopilot A Hard Real-Time Control Application Broderic Gonzales CS 722 May 2, 2005 v.05

2 Purpose “Cruise control” for an airplane. During flight the autopilot must maintain a plane’s: –Altitude: keep the plane level at its current height –Direction: keep the plane traveling in its current heading –Attitude: keep the plane’s orientation stable The autopilot is a hard real-time system.

3 What makes a system real time? 1 Timeliness Reactiveness Concurrency Device abstractions Distributive State-dependency Dynamic internal structure 1 Coad[230]

4 Timeliness Timing constraints if not met cause unwanted loss of data. The autopilot uses separate, prioritized threads of control.

5 Reactiveness Immediately identify, respond and process changes in the system. The autopilot continuously polls instruments and reports deviations to the autopilot to correct the plane’s flight.

6 Concurrency Multiple activities may be taking place at the same time. The autopilot uses multiple threads of control. Each thread does a single task and is assigned to different subsystems to either monitor an instrument or manipulate a control.

7 Device Abstractions Abstract representations of both the physical (problem domain) and the logical (program design.) The autopilot abstracts the instruments and controls as objects of the airplane. The autopilot is built on a framework layer that abstracts the implementation details of the operating system.

8 Distributive Responsibility of controls is spread amongst objects. The autopilot allows the instrumentation to maintain only the information that is relevant to them.

9 Design Overview

10 Main Classes

11 Airplane Class Implementation Details Airplane::Airplane() :_elevators(0), _ailerons(0), _rudders(0) { Controls* controls = Controls::On(); _elevators = controls->GetElevators(); _ailerons = controls->GetAilerons(); _rudders = controls->GetRudders(); } bool Airplane::ActivateAutopilot() { bool elevatorsActivated = _elevators->ActivateAltitudeMaint(); bool aileronsActivated = _ailerons->ActivateHeadingMaint(); bool ruddersActivated = _rudders->ActivateHeadingMaint(); // Was activation of sensor monitors successful? if( elevatorsActivated && aileronsActivated && ruddersActivated ) return true; else return false; }

12 Elevators Class Details

13 Elevators Class Details Continued bool Elevators::ActivateAltitudeMaint( ) { Initialize(); bool status = false; // Create thread to monitor for updates. taskId = _task->Start( &CallBack, (void*)this); if( _taskId == Sthread::GOOD_TID ) status = true; // Spawn subthreads. if( status ) status = Activate(); return status; }

14 Elevators Class Details Continued float Elevators::CalcAdjustments() { float length = 0.0; if( _altChgRate != 0.0 ) length = RATE *(_altDeviation/_altChgRate); float angle = 0.0; if( length != 0.0 ) angle = atan( length/_altDeviation ); return (_pitch + angle); }

15 Altimeter Class Detail void Altimeter::MonitorAltitudeDeviation( void* pid ) { Altimeter* a = (Altimeter*)pid; for( ;; ){ // Lock. a->_mutex->Acquire(); float current = a->ReadAltitude(); a->_altDeviation = a->CalcDeviation( current ); if( a->IsReportable() ){ a->ReportDeviation(); } // Unlock a->_mutex->Release(); } Thread function example

16 Vertical Speed Gyro Detail void VerticalSpeedGyro::Register( Elevators* e ) { // May eventually want to store // this into a subscribers list. _elevators = e; } void VerticalSpeedGyro::ReportChangeRate( float changeRate ) { _elevators->Update( VSI, changeRate ); } Register-Update example

17 Attitude Gyro Detail Perhaps, the composite pattern would’ve helped solve the complexity of this class. bool AttitudeGyro::DeactivatePitchMonitoring() { _pitchMutex->Acquire(); _pitchTask->Cancel(); _pitchMutex->Release(); return true; }

18 System Interaction Classes Test drivers. They generated data for the instruments.

19 SI Classes - Details Composite Pattern Not really a gyro

20 OS Abstraction Layer Although, these classes are concrete, their design is intended to act as a framework for this autopilot to work on different OS.

21 OS Abstraction Layer Details Relying on POSIX threads

22 References Coad, Peter. Object Models: Strategies, Patterns, & Applications. 2nd ed. New Jersey:Prentice Hall,1997


Download ppt "Andi’s Autopilot A Hard Real-Time Control Application Broderic Gonzales CS 722 May 2, 2005 v.05."

Similar presentations


Ads by Google