Documentation
¶
Index ¶
- Constants
- func CalculateFlightTime(eventsData [][]string, launchIdx, touchdownIdx int) float64
- func ConvertMarkdownToSimpleHTML(mdContent string, recordID string) string
- func ExtractMotionPoints(motionData []*PlotSimRecord, motionHeaders []string, ...) []motionPoint
- func FindClosestMotionPoint(motionPoints []motionPoint, timestamp float64) *motionPoint
- func FindEventIndex(eventsData [][]string, eventName string) int
- func FindFlightEvents(eventsData [][]string, log *logf.Logger) (launchIdx, railExitIdx, burnoutIdx, apogeeEventIdx, touchdownIdx int)
- func FindMotionDataIndices(motionHeaders []string) (timeIdx, altitudeIdx, velocityIdx, accelIdx int)
- func FindPeakValues(motionPoints []motionPoint) (maxAlt, maxSpeed, maxAccel, timeAtApogee float64)
- func GetFloat64Value(record PlotSimRecord, key string) (float64, bool)
- func LoadCSVData(record *storage.Record, log *logf.Logger) (*storage.SimulationData, error)
- func LoadOpenRocketDocument(recordPath string, cfg *config.Config, log *logf.Logger) *openrocket.OpenrocketDocument
- func LoadSimulationConfig(recordPath string, currentConfig *config.Config, log *logf.Logger) *config.Config
- type EventSummary
- type ForcesAndMomentsData
- type LaunchRailData
- type MotionMetrics
- type MotorSummaryData
- type ParachuteSummaryData
- type PhaseSummaryData
- type PlotInfo
- type PlotSimRecord
- type RecordManager
- type RecoverySystem
- type RecoverySystemData
- type ReportData
- type ReportSummary
- type StageData
- type TemplateRenderer
- func (tr *TemplateRenderer) CreateReportBundle(data *ReportData, outputDir string) error
- func (tr *TemplateRenderer) GenerateAltitudeVsTimePlot(data *ReportData) error
- func (tr *TemplateRenderer) GeneratePlots(data *ReportData) error
- func (tr *TemplateRenderer) GenerateThrustVsTimePlot(data *ReportData, outputPath string) error
- func (tr *TemplateRenderer) RenderReport(data *ReportData) (string, error)
- func (tr *TemplateRenderer) RenderReportToFile(data *ReportData, outputPath string) error
- func (tr *TemplateRenderer) RenderToHTML(data *ReportData, templateName string) (string, error)
- func (tr *TemplateRenderer) RenderToMarkdown(data *ReportData, templateName string) (string, error)
- type WeatherData
Constants ¶
const ( RecoverySystemDrogue = "Drogue Parachute" RecoverySystemMain = "Main Parachute" )
Recovery system types
const ( EventLaunch = "Launch" EventRailExit = "Rail Exit" EventApogee = "Apogee" EventTouchdown = "Touchdown" EventBurnout = "Burnout" EventDeployment = "Deployment" )
Event types
const ( StatusDeployed = "DEPLOYED" StatusSafe = "SAFE" StatusArmed = "ARMED" )
Status values
const ( ColumnTimeSeconds = "Time (s)" ColumnAltitude = "Altitude (m)" ColumnVelocity = "Velocity (m/s)" ColumnAcceleration = "Acceleration (m/s²)" ColumnThrustNewtons = "Thrust (N)" ColumnEventName = "Event" ColumnEventStatus = "Status" ColumnEventComponent = "Component" )
Column headers and labels
const ( DefaultDescentRateDrogue = 20.0 // m/s DefaultDescentRateMain = 5.0 // m/s DefaultMainDeployAltitude = 300.0 // meters )
Default values
const ( // Axis labels LabelTimeSeconds = "Time (s)" // Error messages ErrCreateLinePlot = "failed to create new line plot: %w" ErrSavePlot = "failed to save plot: %w" )
Constants for plot labels and error messages
const ( PlotTitleAltitude = "Altitude vs Time" PlotTitleVelocity = "Velocity vs Time" PlotTitleAcceleration = "Acceleration vs Time" PlotTitleThrust = "Thrust vs Time" )
Plot titles
const ( PlotAxisTime = "Time (s)" PlotAxisAltitude = "Altitude (m)" PlotAxisVelocity = "Velocity (m/s)" PlotAxisAcceleration = "Acceleration (m/s²)" PlotAxisThrust = "Thrust (N)" )
Plot axis labels
const ( PlotFileAltitude = "altitude_vs_time.svg" PlotFileVelocity = "velocity_vs_time.svg" PlotFileAcceleration = "acceleration_vs_time.svg" PlotFileThrust = "thrust_vs_time.svg" )
Plot filenames
const ( DefaultPlotWidth = 800 DefaultPlotHeight = 600 DefaultPadding = 30 DefaultLineWidth = 2 )
Default values
const (
EventTypeRailExit = "Rail Exit"
)
Event types
const (
MsgSuccessPlotGeneration = "Successfully generated %s plot"
)
Message templates
Variables ¶
This section is empty.
Functions ¶
func CalculateFlightTime ¶ added in v0.9.0
CalculateFlightTime calculates total flight time from event data.
func ConvertMarkdownToSimpleHTML ¶ added in v0.9.0
ConvertMarkdownToSimpleHTML converts a markdown string to a very basic HTML representation.
func ExtractMotionPoints ¶ added in v0.9.0
func ExtractMotionPoints(motionData []*PlotSimRecord, motionHeaders []string, timeIdx, altitudeIdx, velocityIdx, accelIdx int, log *logf.Logger) []motionPoint
ExtractMotionPoints converts raw motion data records to structured motionPoint slices.
func FindClosestMotionPoint ¶ added in v0.9.0
func FindClosestMotionPoint(motionPoints []motionPoint, timestamp float64) *motionPoint
FindClosestMotionPoint finds the motion point closest to a given timestamp.
func FindEventIndex ¶ added in v0.9.0
findEventIndex searches for an event by name in the eventsData and returns its index. Assumes event name is in the first column (index 0) of each event row.
func FindFlightEvents ¶ added in v0.9.0
func FindFlightEvents(eventsData [][]string, log *logf.Logger) (launchIdx, railExitIdx, burnoutIdx, apogeeEventIdx, touchdownIdx int)
FindFlightEvents processes eventsData to find indices for key flight events. It assumes event name is in the first column and time in the second after headers.
func FindMotionDataIndices ¶ added in v0.9.0
func FindMotionDataIndices(motionHeaders []string) (timeIdx, altitudeIdx, velocityIdx, accelIdx int)
FindMotionDataIndices finds the indices of key motion data headers.
func FindPeakValues ¶ added in v0.9.0
func FindPeakValues(motionPoints []motionPoint) (maxAlt, maxSpeed, maxAccel, timeAtApogee float64)
FindPeakValues iterates through motion points to find max altitude, speed, and acceleration.
func GetFloat64Value ¶ added in v0.9.0
func GetFloat64Value(record PlotSimRecord, key string) (float64, bool)
GetFloat64Value safely extracts a float64 value from a PlotSimRecord.
func LoadCSVData ¶ added in v0.9.0
LoadCSVData loads data from CSV files stored in the record
func LoadOpenRocketDocument ¶ added in v0.9.0
func LoadOpenRocketDocument(recordPath string, cfg *config.Config, log *logf.Logger) *openrocket.OpenrocketDocument
LoadOpenRocketDocument attempts to load the OpenRocket document if available
Types ¶
type EventSummary ¶ added in v0.7.0
type EventSummary struct {
Time float64
Name string // Changed from Event to Name for consistency
Altitude float64
Velocity float64
Details string // Optional additional details
}
EventSummary provides a concise summary of a flight event.
type ForcesAndMomentsData ¶ added in v0.9.0
type ForcesAndMomentsData struct {
MaxAngleOfAttack float64
MaxNormalForce float64
MaxAxialForce float64
MaxRollRate float64
MaxPitchMoment float64
MaxDynamicPressure float64
CenterOfPressure float64
CenterOfGravity float64
StabilityMargin float64
}
ForcesAndMomentsData holds aerodynamic force and moment data
type LaunchRailData ¶ added in v0.9.0
type LaunchRailData struct {
Length float64
Angle float64
DepartureVelocity float64
MaxForce float64
DepartureTime float64
StabilityMargin float64
}
LaunchRailData holds data about launch rail performance
type MotionMetrics ¶ added in v0.7.0
type MotionMetrics struct {
TimeAtApogee float64 `json:"time_at_apogee" yaml:"time_at_apogee"` // Time of apogee from liftoff [s] (sensor data based)
FlightTime float64 `json:"flight_time" yaml:"flight_time"` // Total flight time from liftoff to landing [s] (event based)
BurnoutTime float64 `json:"burnout_time" yaml:"burnout_time"` // Time of motor burnout from liftoff [s]
MaxAltitudeAGL float64 `json:"max_altitude_agl" yaml:"max_altitude_agl"` // Max altitude above ground level [m]
MaxSpeed float64 `json:"max_speed" yaml:"max_speed"` // Max speed achieved during flight [m/s]
MaxAcceleration float64 `json:"max_acceleration" yaml:"max_acceleration"` // Max acceleration achieved (positive magnitude) [m/s^2]
RailExitVelocity float64 `json:"rail_exit_velocity" yaml:"rail_exit_velocity"` // Speed at launch rail clearance [m/s]
LaunchRailClearanceTime float64 `json:"launch_rail_clearance_time" yaml:"launch_rail_clearance_time"` // Time at launch rail clearance [s]
BurnoutAltitude float64 `json:"burnout_altitude" yaml:"burnout_altitude"` // Altitude at motor burnout AGL [m]
TimeToApogee float64 `json:"time_to_apogee" yaml:"time_to_apogee"` // Time from launch to apogee [s]
LandingSpeed float64 `json:"landing_speed" yaml:"landing_speed"` // Speed at landing [m/s]
DescentTime float64 `json:"descent_time" yaml:"descent_time"` // Time from apogee to landing [s]
CoastToApogeeTime float64 `json:"coast_to_apogee_time" yaml:"coast_to_apogee_time"` // Time from burnout to apogee [s]
LaunchStabilityMetric float64 `json:"launch_stability_metric" yaml:"launch_stability_metric"` // Barrowman stability margin (calibers)
LaunchRailExitMachNumber float64 `json:"launch_rail_exit_mach_number" yaml:"launch_rail_exit_mach_number"` // Mach number at launch rail exit
AverageDescentSpeed float64 `json:"average_descent_speed,omitempty" yaml:"average_descent_speed,omitempty"` // Average speed during descent [m/s]
// Additional optional metrics
MaxAltitudeASL float64 `json:"max_altitude_asl,omitempty" yaml:"max_altitude_asl,omitempty"` // Max altitude above sea level [m]
TerminalVelocity float64 `json:"terminal_velocity,omitempty" yaml:"terminal_velocity,omitempty"` // Estimated terminal velocity during descent [m/s]
// Error field for reporting issues during calculation
Error string `json:"error,omitempty" yaml:"error,omitempty"`
}
MotionMetrics holds summary statistics about the rocket's motion during flight.
func CalculateMotionMetrics ¶ added in v0.9.0
func CalculateMotionMetrics(motionData []*PlotSimRecord, motionHeaders []string, eventsData [][]string, launchRailLength float64, log *logf.Logger) *MotionMetrics
CalculateMotionMetrics computes summary motion statistics from telemetry and event data.
type MotorSummaryData ¶ added in v0.7.0
type MotorSummaryData struct {
BurnTime float64
MaxThrust float64 // same as PeakThrust but with standardized name
AvgThrust float64 // same as AverageThrust but with standardized name
TotalImpulse float64
SpecificImpulse float64
ThrustEfficiency float64
MotorClass string
MotorManufacturer string
PropellantMass float64
}
MotorSummaryData holds key performance indicators for the rocket motor.
type ParachuteSummaryData ¶ added in v0.7.0
type ParachuteSummaryData struct {
DeploymentTime float64
DeploymentAltitude float64
DeploymentVelocity float64
DragCoefficient float64
DescentRate float64
OpeningForce float64
Diameter float64
ParachuteType string
}
ParachuteSummaryData holds summary statistics for parachute performance.
type PhaseSummaryData ¶ added in v0.7.0
PhaseSummaryData holds summary statistics for flight phases.
type PlotInfo ¶ added in v0.7.0
type PlotInfo struct {
Title string
Filename string // Relative path to the plot image in the assets directory
Type string // e.g., "altitude_vs_time", "velocity_vs_time"
}
PlotInfo stores information about a generated plot.
type PlotSimRecord ¶ added in v0.9.0
type PlotSimRecord map[string]interface{}
PlotSimRecord represents a single row of parsed simulation data, typically motion data. Using a map allows flexibility with varying CSV headers. Values can be float64 (for numeric data) or string (for non-numeric or unconverted data).
func LoadMotorData ¶ added in v0.9.0
func LoadMotorData(motorDesignation string, log *logf.Logger) ([]*PlotSimRecord, []string)
LoadMotorData fetches motor data from ThrustCurve API for the specified motor
func ParseMotionDataForPlotting ¶ added in v0.9.0
func ParseMotionDataForPlotting(simData *storage.SimulationData, log *logf.Logger) ([]*PlotSimRecord, []string)
ParseMotionDataForPlotting converts raw motion data to PlotSimRecord format for plotting
type RecordManager ¶ added in v0.9.0
type RecordManager interface {
GetRecord(hash string) (*storage.Record, error)
GetStorageDir() string
}
RecordManager defines the interface for accessing record data, used by GenerateReportData. This allows for easier testing and decoupling from concrete storage implementations. It is satisfied by *storage.RecordManager and test mocks. Ensure HandlerRecordManager in cmd/server/handlers.go is compatible.
type RecoverySystem ¶ added in v0.9.0
type RecoverySystem struct {
Type string // Type of recovery system (parachute, streamer, etc)
Deployment float64 // Time of deployment in seconds
DescentRate float64 // Descent rate in m/s
}
RecoverySystem represents a recovery device like a parachute or streamer This is defined here if not already present in report.go
type RecoverySystemData ¶ added in v0.7.0
RecoverySystemData holds data for a recovery system.
func FindParachuteEvents ¶ added in v0.9.0
func FindParachuteEvents(eventsData [][]string, log *logf.Logger) []RecoverySystemData
FindParachuteEvents searches the event data for parachute deployment events with DEPLOYED status
type ReportData ¶
type ReportData struct {
RecordID string `json:"record_id" yaml:"record_id"`
Version string `json:"version" yaml:"version"`
RocketName string `json:"rocket_name" yaml:"rocket_name"`
MotorName string `json:"motor_name" yaml:"motor_name"`
LiftoffMassKg float64 `json:"liftoff_mass_kg" yaml:"liftoff_mass_kg"`
GeneratedTime string `json:"generated_time" yaml:"generated_time"`
Config config.Config `json:"config" yaml:"config"`
Summary ReportSummary `json:"summary" yaml:"summary"`
Plots map[string]string `json:"plots" yaml:"plots"`
MotionMetrics *MotionMetrics `json:"motion_metrics" yaml:"motion_metrics"`
MotorSummary MotorSummaryData `json:"motor_summary" yaml:"motor_summary"`
ParachuteSummary ParachuteSummaryData `json:"parachute_summary" yaml:"parachute_summary"`
PhaseSummary PhaseSummaryData `json:"phase_summary" yaml:"phase_summary"`
LaunchRail LaunchRailData `json:"launch_rail" yaml:"launch_rail"`
ForcesAndMoments ForcesAndMomentsData `json:"forces_and_moments" yaml:"forces_and_moments"`
Weather WeatherData `json:"weather" yaml:"weather"`
AllEvents []EventSummary `json:"all_events" yaml:"all_events"`
Stages []StageData `json:"stages" yaml:"stages"`
RecoverySystems []RecoverySystemData `json:"recovery_systems" yaml:"recovery_systems"`
MotionData []*PlotSimRecord `json:"motion_data" yaml:"motion_data"`
MotionHeaders []string `json:"motion_headers" yaml:"motion_headers"`
EventsData [][]string `json:"events_data" yaml:"events_data"`
Log *logf.Logger `json:"-"`
ReportTitle string `json:"report_title" yaml:"report_title"`
GenerationDate string `json:"generation_date" yaml:"generation_date"`
MotorData []*PlotSimRecord `json:"motor_data" yaml:"motor_data"`
MotorHeaders []string `json:"motor_headers" yaml:"motor_headers"`
Extensions map[string]interface{} `json:"extensions,omitempty" yaml:"extensions,omitempty"`
Assets map[string]string `json:"assets,omitempty" yaml:"assets,omitempty"`
RawData *storage.SimulationData `json:"raw_data" yaml:"raw_data"`
}
ReportData holds all data required to generate a report.
func GenerateReportData ¶ added in v0.9.0
func GenerateReportData(log *logf.Logger, cfg *config.Config, rm RecordManager, recordID string) (*ReportData, error)
GenerateReportData creates a new ReportData struct, populating it with information from the specified recordID, configuration, and storage backend. It now accepts a RecordManager interface instead of a concrete *storage.RecordManager.
type ReportSummary ¶ added in v0.7.0
type ReportSummary struct {
RocketName string `json:"rocket_name" yaml:"rocket_name"`
MotorDesignation string `json:"motor_designation" yaml:"motor_designation"`
LaunchSite string `json:"launch_site" yaml:"launch_site"`
TargetApogeeFt float64 `json:"target_apogee_ft" yaml:"target_apogee_ft"` // Ensure this field exists in config or is handled
LiftoffMassKg float64 `json:"liftoff_mass_kg" yaml:"liftoff_mass_kg"`
CoastToApogeeTime float64 `json:"coast_to_apogee_time" yaml:"coast_to_apogee_time"`
MotionMetrics MotionMetrics `json:"motion_metrics" yaml:"motion_metrics"`
// Use existing RecoverySystemData type for the recovery system information
RecoverySystem []RecoverySystemData `json:"recovery_system" yaml:"recovery_system"`
Notes string `json:"notes,omitempty" yaml:"notes,omitempty"`
}
ReportSummary aggregates all summary statistics for the report.
type TemplateRenderer ¶ added in v0.9.0
type TemplateRenderer struct {
// contains filtered or unexported fields
}
TemplateRenderer handles report template processing and rendering
func NewTemplateRenderer ¶ added in v0.9.0
func NewTemplateRenderer(log *logf.Logger, templatesDir, assetsDir string) (*TemplateRenderer, error)
NewTemplateRenderer creates a new template renderer with the specified templates directory
func (*TemplateRenderer) CreateReportBundle ¶ added in v0.9.0
func (tr *TemplateRenderer) CreateReportBundle(data *ReportData, outputDir string) error
CreateReportBundle creates a complete report bundle with the report file and all assets
func (*TemplateRenderer) GenerateAltitudeVsTimePlot ¶ added in v0.9.0
func (tr *TemplateRenderer) GenerateAltitudeVsTimePlot(data *ReportData) error
GenerateAltitudeVsTimePlot generates an SVG plot of altitude vs. time.
func (*TemplateRenderer) GeneratePlots ¶ added in v0.9.0
func (tr *TemplateRenderer) GeneratePlots(data *ReportData) error
GeneratePlots generates all plots defined in the ReportData and saves them to the assets directory. It iterates over the plot generation functions registered in the TemplateRenderer.
func (*TemplateRenderer) GenerateThrustVsTimePlot ¶ added in v0.9.0
func (tr *TemplateRenderer) GenerateThrustVsTimePlot(data *ReportData, outputPath string) error
GenerateThrustVsTimePlot generates a plot for thrust vs. time, if motor data is available.
func (*TemplateRenderer) RenderReport ¶ added in v0.9.0
func (tr *TemplateRenderer) RenderReport(data *ReportData) (string, error)
RenderReport renders the markdown report template with the provided data This function might need to be renamed or refactored if its primary purpose changes from MD.
func (*TemplateRenderer) RenderReportToFile ¶ added in v0.9.0
func (tr *TemplateRenderer) RenderReportToFile(data *ReportData, outputPath string) error
RenderReportToFile renders the report template and writes it to a file
func (*TemplateRenderer) RenderToHTML ¶ added in v0.9.0
func (tr *TemplateRenderer) RenderToHTML(data *ReportData, templateName string) (string, error)
RenderToHTML renders the report data to HTML using the report.html.tmpl template
func (*TemplateRenderer) RenderToMarkdown ¶ added in v0.9.0
func (tr *TemplateRenderer) RenderToMarkdown(data *ReportData, templateName string) (string, error)
RenderToMarkdown renders the report data to Markdown
type WeatherData ¶ added in v0.9.0
type WeatherData struct {
Latitude float64
Longitude float64
ElevationAMSL float64
WindSpeed float64
WindDirection float64
WindDirectionCardinal string
Pressure float64 // Atmospheric pressure at launch site altitude (Pa)
SeaLevelPressure float64 // Standard sea level pressure (Pa)
Density float64 // Air density at launch site (kg/m³)
LocalGravity float64 // Local gravity at launch site (m/s²)
SpeedOfSound float64 // Speed of sound in current conditions (m/s)
TemperatureK float64 // Temperature in Kelvin
}
WeatherData holds atmospheric conditions data