AirControl  1.3.0
Open Source, Modular, and Extensible Flight Simulator For Deep Learning Research
AirControl.AC_BaseAirplane_Input Class Reference

Base class to listen for keyboard Inputs More...

Inheritance diagram for AirControl.AC_BaseAirplane_Input:
Collaboration diagram for AirControl.AC_BaseAirplane_Input:

Public Attributes

int maxFlapIncrements =2
 

Protected Member Functions

virtual void HandleInputOld ()
 Take input such as Pitch, Yaw, Roll etc More...
 
virtual void HandleInputNew ()
 
void ClampInputs ()
 Clamping inputs between limits More...
 
void IOSwitch ()
 Receive input from external program like python More...
 

Protected Attributes

float pitch = 0f
 
float roll = 0f
 
float yaw = 0f
 
float throttle = 0f
 
float brake = 0f
 
int flaps = 0
 
KeyCode cameraKey = KeyCode.C
 
bool camerSwitch = false
 
float throttleSpeed
 
float stickyThrottle
 

Properties

float Pitch [get]
 
float Roll [get]
 
float Yaw [get]
 
float Throttle [get]
 
int Flaps [get]
 
float NormalizedFlaps [get]
 
float Brake [get]
 
float StickyThrottle [get]
 
bool CameraSwitch [get]
 

Detailed Description

Base class to listen for keyboard Inputs

Definition at line 12 of file AC_BaseAirplane_Input.cs.

Member Function Documentation

◆ ClampInputs()

void AirControl.AC_BaseAirplane_Input.ClampInputs ( )
inlineprotected

Clamping inputs between limits

Definition at line 137 of file AC_BaseAirplane_Input.cs.

138  {
139  pitch = Mathf.Clamp(pitch,-1f,1f);
140  roll = Mathf.Clamp(roll,-1f,1f);
141  yaw = Mathf.Clamp(yaw,-1f,1f);
142  throttle = Mathf.Clamp(throttle,-1f,1f);
143  brake = Mathf.Clamp(brake,0f,1f);
144  flaps = Mathf.Clamp(flaps, 0, maxFlapIncrements);
145  }

◆ HandleInputOld()

virtual void AirControl.AC_BaseAirplane_Input.HandleInputOld ( )
inlineprotectedvirtual

Take input such as Pitch, Yaw, Roll etc

Reimplemented in AirControl.AC_XboxAirplane_Input.

Definition at line 97 of file AC_BaseAirplane_Input.cs.

97  {
98  // Process pitch, roll, yaw and throttle
99  pitch = Input.GetAxis("Vertical");
100  roll = Input.GetAxis("Horizontal");
101  yaw = Input.GetAxis("yaw");
102  throttle = Input.GetAxis("throttle");
103 
104  StickyThrottleControl();
105  // Process brakes bool
106  brake = Input.GetKey(KeyCode.Space)?1f:0f;
107  // Process flaps
108  // get GetKeyDown is used because it fires only once when key pressed. GetKey constantly fire events
109  if(Input.GetKeyDown(KeyCode.F)){
110  flaps+=1;
111  }
112  if(Input.GetKeyDown(KeyCode.G)){
113  flaps-=1;
114  }
115  flaps = Mathf.Clamp(flaps, 0,maxFlapIncrements);
116 
117  //camera switch key
118  camerSwitch = Input.GetKeyDown(cameraKey);
119 
120  }

◆ IOSwitch()

void AirControl.AC_BaseAirplane_Input.IOSwitch ( )
inlineprotected

Receive input from external program like python

Definition at line 149 of file AC_BaseAirplane_Input.cs.

150  {
151  string DBInputControlType = StaticControlSchema.InputControlType;
152  // if control type is code then lock the controls and fly it
153  // else let user fly manually
154  if(DBInputControlType == "Code")
155  {
156  throttle = StaticControlSchema.Throttle;
157  stickyThrottle = StaticControlSchema.StickyThrottle;
158  pitch = StaticControlSchema.Pitch;
159  roll = StaticControlSchema.Roll;
160  yaw = StaticControlSchema.Yaw;
161  brake = StaticControlSchema.Brake;
162  flaps = StaticControlSchema.Flaps;
163  }
164  }

The documentation for this class was generated from the following file:
Communicator.StaticControlSchema
Input control class, acts a dictionary. This class can be accessed anywhere in the code as dict....
Definition: IOSchema.cs:41