Skip to content

Commit

Permalink
added table generator for UCAs by types
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael12304 committed Jan 23, 2025
1 parent 5f02fb5 commit 31c5014
Show file tree
Hide file tree
Showing 3 changed files with 231 additions and 7 deletions.
118 changes: 118 additions & 0 deletions misc/resources/uca_by_types_table.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
\newcolumntype{R}[1]{>{\raggedright\arraybackslash}p{#1}}
\begin{table}[h]
\resizebox{\textwidth}{!}{%
\begin{tabular}{|R{2.00cm}|R{3.00cm}|R{3.00cm}|R{3.00cm}|R{3.00cm}|}
\hline
\textbf{Control Action} & \textbf{Providing causes hazard} & \textbf{Not providing causes hazard} & \textbf{Incorrect timing/order} & \textbf{Stopped too soon/Applied too long} \\
\hline
the Brake control action & UCA{-}2: BSCU Autobrake provides Brake control action during a normal takeoff {[}H{-}4.3, H{-}4.6{]}\newline%
\newline%
UCA{-}5: BSCU Autobrake provides Brake control action with an insufficient level of braking during landing roll {[}H{-}4.1{]}\newline%
\newline%
UCA{-}6: BSCU Autobrake provides Brake control action with directional or asymmetrical braking during landing roll {[}H{-}4.1, H{-}4.2{]} & UCA{-}1: BSCU Autobrake does not provide the Brake control action during landing roll when the BSCU is armed {[}H{-}4.1{]} & UCA{-}3: BSCU Autobrake provides the Brake control action too late (\textgreater{}TBD seconds) after touchdown {[}H{-}4.1{]}\newline%
\newline%
BSCU.1c4: Autobrake provides Brake more than TBD seconds after V1 during rejected takeoff (assumes that Autobrake is responsible for braking during RTO after crew throttle down) {[}H4{-}2{]} & UCA{-}4: BSCU Autobrake stops providing the Brake control action too early (before TBD taxi speed attained) when aircraft lands {[}H{-}4.1{]}\newline%
\newline%
BSCU.1d1: Autobrake stops providing Brake during landing roll before TBD taxi speed attained (causing reduced deceleration) {[}H4{-}1, H4{-}5{]} \\
\hline
BSCU Power Off & Crew{-}UCA{-}2: Crew provides BSCU Power Off when Anti{-}Skid functionality is needed and WBS is functioning normally {[}H{-}4.1, H{-}7{]}\newline%
\newline%
Crew{-}UCA{-}3: Crew powers off BSCU too early before Autobrake or Anti{-}Skid behavior is completed when it is needed {[}H{-}4.1, H{-}7{]}\newline%
\newline%
CREW.4b1: Crew powers off BSCU when Autobraking is needed and WBS functioning normally {[}H4{-}1, H4{-}5{]}\newline%
\newline%
CREW.4b2: Crew powers off BSCU when Autobrake is needed (or about to be used) and WBS if funtioning normally {[}H4{-}1, H4{-}5{]}\newline%
\newline%
CREW.4b3: Crew powers off BSCU when Anti{-}Skid functionality is needed (or will be needed) and WBS is functioning normally {[}H4{-}1, H4{-}5{]}\newline%
\newline%
CREW.4c1: Crew powers off BSCU too late (TBD) to enable alternate braking mode in the event of abnormal WBS behavior {[}H4{-}1, H4{-}5{]}\newline%
\newline%
CREW.4c2: Crew powers off BSCU too early before Autobrake or Anti{-}Skid behavior is completed when it is needed {[}H4{-}1, H4{-}5{]}\newline%
\newline%
CREW.5c1: Crew powers on BSCU too late after Normal braking mode, Autobrake, or Anti{-}Skid is needed {[}H4{-}1, H4{-}5{]} & Crew{-}UCA{-}1: Crew does not provide BSCU Power Off when abnormal WBS behavior occurs {[}H{-}4.1, H{-}4.4, H{-}7{]}\newline%
\newline%
CREW.4a1: Crew does not power off BSCU in the event of abnormal WBS behavior (needed to enable alternate braking mode) {[}H4{-}1, H4{-}2, H4{-}5{]}\newline%
\newline%
CREW.5a1: Crew does not power on BSCU when Normal braking mode, Autobrake, or Anti{-}Skid is to be used and WBS functioning normally {[}H4{-}1, H4{-}5{]} & N/A & N/A \\
\hline
Brake command & BSCU.1b3: Autobrake provides Brake command with insufficient level (resulting in insufficient deceleration during landing roll) {[}H4{-}1, H4{-}5{]}\newline%
\newline%
BSCU.1c3: Autobrake provides Brake command at any time before wheels have left ground and RTO has not been requested (brake might be applied to stop wheels before gear retraction) {[}H4{-}1, H4{-}2, H4{-}5{]} & BSCU.1a1: Autobrake does not provide Brake command during RTO to V1 (resulting in inability to stop within available runway length) {[}H4{-}1, H4{-}5{]}\newline%
\newline%
BSCU.1a2: Autobrake does not provides Brake command during landing roll when BSCU is armed (resulting in insufficient deceleration and potential overshoot) {[}H4{-}1, H4{-}5{]}\newline%
\newline%
BSCU.1a4: Autobrake does not provide Brake command after takeoff (needed to lock wheels, results in potential equipment damage during landing gear retraction or wheel rotation in flight) {[}H4{-}6{]} & BSCU.1c2: Autobrake provides Brake command more than TBD seconds after touchdown (resulting in insufficient deceleration and potential loss of control, overshoot) {[}H4{-}1, H4{-}5{]}\newline%
\newline%
BSCU.1d2: Autobrake provides Brake command too long (more than TBD seconds) during landing roll (causing stop on runway) {[}H4{-}1{]}\newline%
\newline%
BSCU.1d3: Autobrake provides Brake command for tire lock until less than TBD seconds before touchdown during approach (resulting in loss of control, equipment damage) {[}H4{-}1, H4{-}5{]} & N/A \\
\hline
excessive Braking commands & BSCU.1b1: Autobrake provides excessive Braking commands during landing roll {[}H4{-}1, H4{-}5{]} & N/A & BSCU.1c1: Autobrake provides Braking command before touchdown (resulting in tire burst, loss of control, injury, other damage) {[}H4{-}1, H4{-}5{]} & N/A \\
\hline
Braking command inappropriately & BSCU.1b2: Autobrake provides Braking command inappropriately during takeoff (resulting in inadequate acceleration) {[}H4{-}1, H4{-}2, H4{-}5{]} & N/A & N/A & N/A \\
\hline
HOLD & UCA{-}AH{-}2: AH provides HOLD when driver is applying the accelerator {[}H{-}1{]}\newline%
\newline%
UCA{-}AH{-}3: AH provides HOLD when AH is DISABLED {[}H{-}1{]}\newline%
\newline%
UCA{-}AH{-}4: AH provides HOLD when vehicle is moving {[}H{-}1{]}\newline%
\newline%
UCA{-}AH{-}5: AH provides HOLD when driver is not applying brake {[}H{-}1, H{-}2{]} & UCA{-}AH{-}1: AH does not provide HOLD when vehicle stops and brake pedal released {[}H{-}1, H{-}2{]} & UCA{-}AH{-}6: AH provides HOLD too early before the required time at rest has not been met {[}H{-}1{]}\newline%
\newline%
UCA{-}AH{-}7: AH provides HOLD too late after vehicle stops, begins to roll {[}H{-}1{]} & N/A \\
\hline
RELEASE & UCA{-}AH{-}12: AH provides RELEASE when driver is not applying accelerator {[}H{-}1, H{-}2{]} & UCA{-}AH{-}10: AH does not provide RELEASE when driver applies accelerator pedal {[}H{-}1, H{-}2{]} & UCA{-}AH{-}13: AH provides RELEASE too early before there is sufficient wheel torque {[}H{-}1, H{-}2{]}\newline%
\newline%
UCA{-}AH{-}13: AH provides RELEASE too late after accelerator applied, engine torque exceeds wheel torque {[}H{-}1, H{-}2{]} & N/A \\
\hline
ADDITIONALPRESSURE & UCA{-}AH{-}15: AH provides ADDITIONALPRESSURE when AH is not active {[}H{-}1, H{-}2{]}\newline%
\newline%
UCA{-}AH{-}16: AH provides ADDITIONALPRESSURE when brake system specs are exceeded {[}H{-}1, H{-}2{]} & UCA{-}AH{-}14: AH does not provide ADDITIONALPRESSURE when vehicle is slipping and AH is active {[}H{-}1, H{-}2{]} & N/A & N/A \\
\hline
ADDITIONAL{-}PRESSURE & N/A & N/A & UCA{-}AH{-}16: AH provides ADDITIONAL{-}PRESSURE too late after vehicle is slipping {[}H{-}1, H{-}2{]} & N/A \\
\hline
Abort Cmd & UCA{-}HTV{-}2: ISS crew provides Abort Cmd when HTV is captured {[}H{-}1{]}\newline%
\newline%
UCA{-}HTV{-}3: ISS crew provides Abort Cmd when ISS is in Abort path {[}H{-}1{]} & UCA{-}HTV{-}1: ISS crew does not provide Abort Cmd when emergency condition exists {[}H{-}1{]} & UCA{-}HTV{-}4: ISS crew provides Abort Cmd too late to avoid collision {[}H{-}1{]}\newline%
\newline%
UCA{-}HTV{-}5: ISS crew provides Abort Cmd too early before capture is released {[}H{-}1{]} & N/A \\
\hline
Free Drift Cmd & UCA{-}HTV{-}7: ISS crew provides Free Drift Cmd when HTV is approaching ISS {[}H{-}1{]} & UCA{-}HTV{-}6: ISS crew does not provide Free Drift Cmd when HTV is stopped in capture box {[}H{-}1{]} & UCA{-}HTV{-}8: ISS crew provides Free Drift Cmd too late, more than X minutes after HTV stops {[}H{-}1{]}\newline%
\newline%
UCA{-}HTV{-}9: ISS crew provides Free Drift Cmd too early before HTV stops {[}H{-}1{]} & N/A \\
\hline
Capture & UCA{-}HTV{-}11: ISS crew performs Capture when HTV is not in free drift {[}H{-}1{]}\newline%
\newline%
UCA{-}HTV{-}12: ISS crew performs Capture when HTV is aborting {[}H{-}1{]}\newline%
\newline%
UCA{-}HTV{-}13: ISS crew performs Capture with excessive/insufficient movement (can impact HTV, cause collision course) {[}H{-}1{]} & UCA{-}HTV{-}10: ISS crew does not perform Capture when HTV is in capture box in free drift {[}H{-}1{]} & UCA{-}HTV{-}14: ISS crew performs Capture too late, more than X minutes after HTV deactivated {[}H{-}1{]}\newline%
\newline%
UCA{-}HTV{-}15: ISS crew performs Capture too early before HTV deactivated {[}H{-}1{]} & UCA{-}HTV{-}16: ISS crew continues performing Capture too long after emergency condition exists {[}H{-}1{]} \\
\hline
manual braking & CREW.1b1: Crew provides manual braking with insufficient pedal pressure {[}H4.1{]}\newline%
\newline%
CREW.1b2: Crew provides manual braking with excessive pedal pressure (resulting in loss of control, passenger/crew injury, brake overheating, brake fade or tire burst during landing) {[}H4{-}1, H4{-}5{]}\newline%
\newline%
CREW.1b3: Crew provides manual braking provided during normal takeoff {[}H4{-}2, H4{-}5{]}\newline%
\newline%
CREW.1c1: Crew provides manual braking before touchdown (causes wheel lockup, loss of control, tire burst) {[}H4.1{]} & CREW.1a1: Crew does not provide manual braking during landing, RTO, or taxiing when Autobrake is not providing braking or is providing insufficient braking {[}H4.1{]} & CREW.1c2: Crew provides manual braking too late (TBD) to avoid collision or conflict with another object (can overload braking capability given aircraft weight, speed, distance to object (conflict), and tarmac conditions) {[}H4{-}1, H4{-}5{]}\newline%
\newline%
CREW.1d2: Crew provides manual braking too long (resulting in stopped aircraft on runway or active taxiway) {[}H4{-}1{]} & CREW.1d1: Crew stops providing manual braking command before safe taxi speed (TBD) is reached {[}H4.1, H4.4{]} \\
\hline
Autobrake & CREW.3b1: Crew disarms Autobrake during landing or RTO (resulting in loss of automatic brake operation when spoilers deploy. Crew reaction time may lead to overshoot) {[}H4{-}1, H4{-}5{]}\newline%
\newline%
CREW.3c1: Crew disarms Autobrake more than TBD seconds after (a) aircraft descent exceeds TBD fps, (b) visibility is less than TBD ft, (c) etc…, (resulting in either loss of control of aircraft or loss of acceleration during (re)takeoff) {[}H4{-}1, H4{-}2, H4{-}5{]} & CREW.2a1: Crew does not arm Autobrake before landing (causing loss of automatic brake operation when spoilers deploy. Crew reaction time may lead to overshoot.) {[}H4{-}1, H4{-}5{]}\newline%
\newline%
CREW.2a2: Crew does not arm Autobrake prior to takeoff (resulting in insufficient braking during rejected takeoff, assuming that Autobrake is responsible for braking during RTO after crew throttle down) {[}H4{-}2{]}\newline%
\newline%
CREW.2b1: Crew does not arm Autobrake to maximum level during takeoff. (assumes that maximum braking force is necessary for rejected takeoff) {[}H4{-}2{]}\newline%
\newline%
CREW.3a1: Crew does not disarm Autobrake during TOGA (resulting in loss of acceleration during (re)takeoff) {[}H4{-}1, H4{-}2, H4{-}5{]} & N/A & N/A \\
\hline
autobrake & CREW.2b2: Crew armed autobrake with too high of a deceleration rate for runway conditions (resulting in loss of control and passenger or crew injury). {[}H4{-}1, H4{-}5{]} & N/A & N/A & N/A \\
\hline
arm command & N/A & N/A & CREW.2c1: Crew provides arm command too late (TBD) (resulting in insufficient time for BSCU to apply brakes) {[}H4{-}1, H4{-}5{]} & N/A \\
\hline
\end{tabular}
}
\end{table}
116 changes: 111 additions & 5 deletions misc/table_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import pandas as pd
from textwrap import wrap
from pylatex.utils import escape_latex
import re
from collections import defaultdict
from enum import Enum

class LatexTableGenerator(ABC):

Expand Down Expand Up @@ -41,7 +44,7 @@ def generate(self):
'\\newcolumntype{R}[1]{>{\\raggedright\\arraybackslash}p{#1}}',
'\\begin{table}[h]',
'\\resizebox{\\textwidth}{!}{%\n'
'\\begin{tabular}{|' + '|'.join([f'R{{{self._COLUMN_WIDTHS_CM[column]:.2f}cm}}' for column in self.COLUMN_NAMES]) + '|}',
'\\begin{tabular}{|' + '|'.join([f'R{{{self._COLUMN_WIDTHS_CM.get(column, 2):.2f}cm}}' for column in self.COLUMN_NAMES]) + '|}',
'\\hline'
]

Expand All @@ -50,7 +53,7 @@ def generate(self):
latex.append('\\hline')

for _, row in df.iterrows():
formatted_row = [self._escape_latex(cell) for cell in row]
formatted_row = [self._escape_latex(cell) if cell else 'N/A' for cell in row]
latex.append(' & '.join(formatted_row) + ' \\\\ ')
latex.append('\\hline')

Expand Down Expand Up @@ -81,7 +84,7 @@ def __init__(self, unsafe_control_actions: list[UnsafeControlAction]):

self.unsafe_control_actions = unsafe_control_actions

class UCAAttributeTableGenerator(UCATableGenerator):
class UCAAttributesTableGenerator(UCATableGenerator):

COLUMN_NAMES : ClassVar[list[str]] = ["Source", "Name", "Type", "Control Action", "Context", "Hazards"]
_COLUMN_WIDTHS_CM : ClassVar[dict[str, float]] = {
Expand Down Expand Up @@ -114,11 +117,114 @@ def get_all_row_values(self) -> pd.DataFrame:
df = pd.DataFrame(rows, columns=self.COLUMN_NAMES)
return df



class UCAType:
NEGATIVE = "NEGATIVE"
POSITIVE = "POSITIVE"
TIMING = "TIMING"
STATE_CHANGE = "STATE_CHANGE"
UNKNOWN = "UNKNOWN"

class UCAByTypesTableGenerator(UCATableGenerator):

COLUMN_NAMES : ClassVar[list[str]] = ["Control Action",
"Providing causes hazard",
"Not providing causes hazard",
"Incorrect timing/order",
"Stopped too soon/Applied too long"]
_COLUMN_WIDTHS_CM : ClassVar[dict[str, float]] = {
"Control Action": 2,
"Providing causes hazard": 3,
"Not providing causes hazard": 3,
"Incorrect timing/order": 3,
"Stopped too soon/Applied too long": 3,
}

@staticmethod
def categorize_uca_type(uca_type: str) -> UCAType:
"""
Categorizes a control action string into main types:
- NEGATIVE: Does not provide/perform
- POSITIVE: Provides/performs (without timing)
- TIMING: Provides too early/late/long/before/after
- STATE_CHANGE: Stops/continues providing
- UNKNOWN: Doesn't match known patterns
"""

# Normalize string to lowercase for matching
type = uca_type.lower()

# Negative patterns
if re.match(r"does not (provide|perform|arm|power|disarm)", type):
return UCAType.NEGATIVE

# State change patterns
if re.match(r"(stops|continues)", type):
return UCAType.STATE_CHANGE

# Timing patterns
timing_words = r"(before|after|early|late|long|until|more than)"
if re.search(fr"provides.*{timing_words}", type) or \
re.search(fr"performs.*{timing_words}", type):
return UCAType.TIMING

# Basic positive patterns (without timing)
if re.match(r"(provides|performs|arms|powers|disarms|armed)", type):
return UCAType.POSITIVE

return UCAType.UNKNOWN

def get_all_row_values(self) -> pd.DataFrame:
"""
Returns a list of all row values for the table being generated.
"""

control_actions_to_ucas= defaultdict(list[UnsafeControlAction])

for uca in self.unsafe_control_actions:

for key in control_actions_to_ucas.keys():
if uca.control_action in key or key in uca.control_action:
control_actions_to_ucas[key].append(uca)
break
else:
control_actions_to_ucas[uca.control_action].append(uca)

rows = []

for control_action, ucas in control_actions_to_ucas.items():
new_row = [control_action]
ucas_by_type = {
UCAType.NEGATIVE: [],
UCAType.POSITIVE: [],
UCAType.TIMING: [],
UCAType.STATE_CHANGE: []
}
for uca in ucas:
uca_type = self.categorize_uca_type(uca.type_)
ucas_by_type[uca_type].append(uca)

new_row.append("\n\n".join([str(uca) for uca in ucas_by_type[UCAType.POSITIVE]]))
new_row.append("\n\n".join([str(uca) for uca in ucas_by_type[UCAType.NEGATIVE]]))
new_row.append("\n\n".join([str(uca) for uca in ucas_by_type[UCAType.TIMING]]))
new_row.append("\n\n".join([str(uca) for uca in ucas_by_type[UCAType.STATE_CHANGE]]))

rows.append(new_row)

df = pd.DataFrame(rows, columns=self.COLUMN_NAMES)
return df






if __name__ == "__main__":

uca_table_generator = UCAAttributeTableGenerator(UNSAFE_CONTROL_ACTIONS[0:5])
uca_table_generator = UCAByTypesTableGenerator(UNSAFE_CONTROL_ACTIONS[0:100])
latex = uca_table_generator.generate()
with open("misc/resources/uca_table.tex", "w") as f:
with open("misc/resources/uca_by_types_table.tex", "w") as f:
f.write(latex)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@
UnsafeControlAction(
'BSCU.1c3',
'Autobrake',
'provides',
'Brake command at any time',
'provides {} at any time',
'Brake command',
(
'before wheels have left ground and RTO has not been requested'
' (brake might be applied to stop wheels before gear retraction)'
Expand Down

0 comments on commit 31c5014

Please # to comment.