adderbyte / GYM_XPLANE_ML

GYM Environment for XPlane. Reinforcement Learning and Autonomous Piloting.
GNU General Public License v3.0
65 stars 19 forks source link

Inconsistency between state and self.ControlParameters.state14 #12

Open rizwan-malik opened 2 years ago

rizwan-malik commented 2 years ago

While trying to understand the workings of the code and writing an agent myself, I noticed certain inconsistencies in the parameters defined in parameters.py file and value assignment to those variables in xplane_envBase.py file. In Line 14 of parameters.py file state14 is defined as: "state14" :{"roll_rate" :0 ,"pitch_rate" :0, "altitude": 0 ,"Pitch" :0 ,"Roll" :0, "velocity_x": 0, "velocity_y" :0 ,"velocity_z" :0 ,"delta_altitude" :0, "delta_heading" :0 ,"yaw_rate" :0},

then on Line 139 of xplane_envBase.py the variable state is assigned:

state = self.ControlParameters.stateAircraftPosition + self.ControlParameters.stateVariableValue

stateAircraftPosition is retrieved from XPlane Connect's getPOSI() function which returns these values : [Lat, Lon, Alt, Pitch, Roll, Yaw, Gear]

and stateVariableValue containes values for these drefs:

"stateVariable" : ["sim/flightmodel/position/local_vx" ,"sim/flightmodel/position/local_vy", "sim/flightmodel/position/local_vz"],

so, essentially the list 'state' contains following variables: state = [Lat, Lon, Alt, Pitch, Roll, Yaw, Gear, local_vx, local_vy, local_vz]

However, when we look at assignments in Line 175, 176 and 177 of xplane_envBase.py file it can be noted that

  1. state14['velocity_x'] = state[6] whereas state[6] = Gear
  2. state14['velocity_y'] = state[6] whereas state[6] = local_vx
  3. state14['velocity_z'] = state[6] whereas state[6] = local_vy

So, I don't know if I am missing on something or what, but this should have a major impact on training.

adderbyte commented 2 years ago

Hi, You could adapt the state parameters to suit the scenario you are trying to train. For example gear might not be needed for a point to point navigation but for landing it would be essential. Since I played with different training scenario it might be possible I changed it along the line.

Your observation is perhaps correct. You meant the indices should be 7, 8 and 9 correcponding to local_vx ,local_vy and local_vz. Additional data refs are defined here for position and velocity and are in fact well explained.

Thank you for the observation.

Best