def process_state(self, t, dt): StateAgent.process_state(self, t, dt) # Calculate the lateral distance to the threat aircraft entity = self.beliefs.entity_state threat = self.beliefs.threat_state self.is_param_one = helpers.transition_condition( entity.tactical_3d(), threat.tactical_3d(), self.PARAMETER_SET_ONE) self.is_param_two = helpers.transition_condition( entity.tactical_3d(), threat.tactical_3d(), self.PARAMETER_SET_TWO) self.is_param_three = helpers.transition_condition( entity.tactical_3d(), threat.tactical_3d(), self.PARAMETER_SET_THREE) self.is_param_four = helpers.transition_condition( entity.tactical_3d(), threat.tactical_3d(), self.PARAMETER_SET_FOUR) self.is_param_five = helpers.transition_condition( entity.tactical_3d(), threat.tactical_3d(), self.PARAMETER_SET_FIVE) self.is_param_six = helpers.transition_condition( entity.tactical_3d(), threat.tactical_3d(), self.PARAMETER_SET_SIX) if self.is_param_one or self.is_param_two or self.is_param_three or self.is_param_four or self.is_param_five or self.is_param_six: self.transition_request = transition( self.is_param_one, self.is_param_two, self.is_param_three, self.is_param_four, self.is_param_five, self.is_param_six, LeftDown, LeftUp, PullUp, LevelFlight, PushDown, RightUp)
def process_state(self, t, dt): StateAgent.process_state(self, t, dt) # Calculate the lateral distance to the threat aircraft entity = self.beliefs.entity_state threat = self.beliefs.threat_state self.is_left_down = helpers.transition_condition( entity.tactical_3d(), threat.tactical_3d(), self.LEFT_DOWN) self.is_left_up = helpers.transition_condition(entity.tactical_3d(), threat.tactical_3d(), self.LEFT_UP) self.is_pull_up = helpers.transition_condition(entity.tactical_3d(), threat.tactical_3d(), self.PULL_UP) self.is_level_flight = helpers.transition_condition( entity.tactical_3d(), threat.tactical_3d(), self.LEVEL_FLIGHT) self.is_push_down = helpers.transition_condition( entity.tactical_3d(), threat.tactical_3d(), self.PUSH_DOWN) self.is_right_up = helpers.transition_condition( entity.tactical_3d(), threat.tactical_3d(), self.RIGHT_UP) if self.is_left_down or self.is_left_up or self.is_pull_up or self.is_level_flight or self.is_push_down or self.is_right_up: self.transition_request = transition( self.is_left_down, self.is_left_up, self.is_pull_up, self.is_level_flight, self.is_push_down, self.is_right_up, LeftDown, LeftUp, PullUp, LevelFlight, PushDown, RightUp)
def process_state(self, t, dt): StateAgent.process_state(self, t, dt) # print 'State: ', self.__class__.__name__, ' at time step: ', t if self.beliefs.threat_state: entity = self.beliefs.entity_state threat = self.beliefs.threat_state self.is_param_one = helpers.transition_condition(entity.tactical_3d(), threat.tactical_3d(), self.PP2FR) self.is_param_two = helpers.transition_condition(entity.tactical_3d(), threat.tactical_3d(), self.PP2FO) self.is_param_three = helpers.transition_condition(entity.tactical_3d(), threat.tactical_3d(), self.PP2C) if self.is_param_one or self.is_param_two or self.is_param_three: self.transition_request = transition(self.is_param_one, self.is_param_two, self.is_param_three, EcuFlyRelativeBearing, EcuFlyingOffset, EcuConverting)
def process_state(self, t, dt): StateAgent.process_state(self, t, dt) # print 'State: ', self.__class__.__name__, ' at time step: ', t if self.beliefs.threat_state: # Calculate the lateral distance to the threat aircraft entity = self.beliefs.entity_state threat = self.beliefs.threat_state self.is_param_one = helpers.transition_condition(entity.tactical_3d(), threat.tactical_3d(), self.C2PP) self.is_param_two = helpers.transition_condition(entity.tactical_3d(), threat.tactical_3d(), self.C2FR) self.is_param_three = helpers.transition_condition(entity.tactical_3d(), threat.tactical_3d(), self.C2FO) if self.is_param_one or self.is_param_two or self.is_param_three: self.transition_request = transition(self.is_param_one, self.is_param_two, self.is_param_three, EcuPureIntercept, EcuFlyRelativeBearing, EcuFlyingOffset)
def process_state(self, t, dt): StateAgent.process_state(self, t, dt) if self.beliefs.threat_state: # Calculate the lateral distance to the threat aircraft entity = self.beliefs.entity_state threat = self.beliefs.threat_state distance = ut.distance(entity.pos_2d(), threat.pos_2d()) displacement = ut.lateral_displacement(entity.x, entity.y, threat.x, threat.y, threat.heading, distance) displacement = ut.metres_to_feet(displacement) # Check whether the desired lateral separation has been reached if displacement >= self.DESIRED_DISPLACEMENT: self.transition_request = FlyingOffset else: # No threats detected so return to default state self.transition_request = PureIntercept
def process_state(self, t, dt): StateAgent.process_state(self, t, dt) if self.beliefs.threat_state: entity = self.beliefs.entity_state threat = self.beliefs.threat_state # Check whether threat is aligned with aircraft taa = ut.target_aspect_angle(entity.x, entity.y, threat.x, threat.y, threat.heading) bearing_to_entity = ut.relative_bearing(threat.x, threat.y, entity.x, entity.y) bearing_offset = abs(threat.heading - bearing_to_entity) if bearing_offset > self.MAX_ALIGNMENT_DIFF: # Threat not aligned so don't proceed to next state return # Check whether at turn range from threat distance = ut.distance(entity.pos_2d(), threat.pos_2d()) if ut.metres_to_nautical_miles(distance) <= self.TURN_RANGE: self.transition_request = FlyRelativeBearing
def process_state(self, t, dt): StateAgent.process_state(self, t, dt) if self.beliefs.threat_state: entity = self.beliefs.entity_state threat = self.beliefs.threat_state distance = ut.distance(entity.pos_2d(), threat.pos_2d()) # Check whether the conversion point has been reached if ut.metres_to_nautical_miles(distance) <= self.CONVERSION_RANGE: self.transition_request = Converting # Check if still closing with threat if self._last_range: if distance > self._last_range: # Not closing with threat so return to default state self.transition_request = PureIntercept self._last_range = distance else: # No threats detected so return to default state self.transition_request = PureIntercept
def process_state(self, t, dt): StateAgent.process_state(self, t, dt) if not self.beliefs.threat_state: # No threats detected so return to the default state self.transition_request = PureIntercept