components

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2025 License: GPL-3.0 Imports: 13 Imported by: 0

README

components

Physical rocket components library that provides models for various rocket parts with accurate physics properties.

Notes

  • Implements component models for nosecones, bodytube, motors, parachutes
  • Calculates mass, inertia, and center of gravity properties
  • Provides geometric representation of physical rocket parts
  • Supports different nose cone profiles (ogive, conical, etc.)
  • Models motor thrust curves and propellant consumption over time
  • Implements parachute deployment and drag characteristics
  • Follows entity-component system (ECS) architecture for modularity
  • Includes precise physical properties required for accurate simulation

Documentation

Index

Constants

View Source
const (
	StateIdle     = "idle"
	StateBurning  = "burning"
	StateIgnited  = "IGNITED"
	StateCoasting = "coast"
)

MotorState represents the states of the motor

Variables

This section is empty.

Functions

This section is empty.

Types

type Bodytube

type Bodytube struct {
	ID            ecs.BasicEntity
	Position      types.Vector3
	Radius        float64
	Length        float64
	Mass          float64
	Thickness     float64
	Density       float64 // Material density
	Finish        string  // Surface finish
	MaterialName  string  // Name of material
	MaterialType  string  // Type of material
	CrossSection  float64 // Cross-sectional area
	SurfaceArea   float64 // Total surface area
	Volume        float64 // Volume of material
	CenterOfMass  types.Vector3
	InertiaTensor types.Matrix3x3
}

Bodytube represents the bodytube entity of a rocket

func NewBodytube

func NewBodytube(id ecs.BasicEntity, radius, length, thickness, density float64) *Bodytube

NewBodytube creates a new bodytube instance

func NewBodytubeFromORK

func NewBodytubeFromORK(id ecs.BasicEntity, orkData *openrocket.OpenrocketDocument) (*Bodytube, error)

NewBodytubeFromORK creates a new bodytube instance from an ORK Document

func (*Bodytube) GetCenterOfMassLocal added in v0.8.0

func (bt *Bodytube) GetCenterOfMassLocal() types.Vector3

GetCenterOfMassLocal returns the Center of Mass of the body tube relative to its own Position reference point.

func (*Bodytube) GetDensity

func (b *Bodytube) GetDensity() float64

GetDensity returns the material density of the bodytube

func (*Bodytube) GetInertiaTensorLocal added in v0.8.0

func (bt *Bodytube) GetInertiaTensorLocal() types.Matrix3x3

GetInertiaTensorLocal returns the inertia tensor of the body tube. This is about its own CM and aligned with its principal axes (assumed to be rocket body axes).

func (*Bodytube) GetMass

func (b *Bodytube) GetMass() float64

GetMass returns the mass of the bodytube

func (*Bodytube) GetPlanformArea

func (b *Bodytube) GetPlanformArea() float64

GetPlanformArea returns the planform area of the bodytube

func (*Bodytube) GetPosition added in v0.8.0

func (bt *Bodytube) GetPosition() types.Vector3

GetPosition returns the position of the body tube's reference point. This typically corresponds to one end of the bodytube in the rocket's coordinate system.

func (*Bodytube) GetSurfaceArea

func (b *Bodytube) GetSurfaceArea() float64

GetSurfaceArea returns the total surface area of the bodytube

func (*Bodytube) GetVolume

func (b *Bodytube) GetVolume() float64

GetVolume returns the volume of the bodytube material

func (*Bodytube) String

func (b *Bodytube) String() string

String returns a string representation of the bodytube

func (*Bodytube) Type

func (b *Bodytube) Type() string

Type returns the type of the component

func (*Bodytube) Update

func (b *Bodytube) Update(dt float64) error

Update updates the bodytube (currently does nothing)

type Motor

type Motor struct {
	ID          ecs.BasicEntity
	Position    types.Vector3
	Thrustcurve [][]float64
	Mass        float64 // Current total mass (casing + current propellant)
	Length      float64 // Length of the motor casing
	Diameter    float64 // Diameter of the motor casing

	Props *thrustcurves.MotorData
	FSM   *MotorFSM
	// contains filtered or unexported fields
}

func NewMotor

func NewMotor(id ecs.BasicEntity, md *thrustcurves.MotorData, logger logf.Logger) (*Motor, error)

NewMotor creates a new motor component from thrust curve data

func (*Motor) GetCasingMass added in v0.8.0

func (m *Motor) GetCasingMass() float64

func (*Motor) GetCenterOfMassLocal added in v0.8.0

func (m *Motor) GetCenterOfMassLocal() types.Vector3

func (*Motor) GetElapsedTime

func (m *Motor) GetElapsedTime() float64

func (*Motor) GetInertiaTensorLocal added in v0.8.0

func (m *Motor) GetInertiaTensorLocal() types.Matrix3x3

func (*Motor) GetMass

func (m *Motor) GetMass() float64

func (*Motor) GetPlanformArea

func (m *Motor) GetPlanformArea() float64

func (*Motor) GetPosition added in v0.8.0

func (m *Motor) GetPosition() types.Vector3

func (*Motor) GetState

func (m *Motor) GetState() string

func (*Motor) GetThrust

func (m *Motor) GetThrust() float64

func (*Motor) IsCoasting

func (m *Motor) IsCoasting() bool

func (*Motor) Reset

func (m *Motor) Reset()

func (*Motor) SetState

func (m *Motor) SetState(state string)

func (*Motor) String

func (m *Motor) String() string

func (*Motor) Type

func (m *Motor) Type() string

func (*Motor) Update

func (m *Motor) Update(dt float64) error

type MotorFSM

type MotorFSM struct {
	*fsm.FSM
	// contains filtered or unexported fields
}

MotorFSM represents the finite state machine for the motor

func NewMotorFSM

func NewMotorFSM(motor *Motor, log logf.Logger) *MotorFSM

NewMotorFSM creates a new FSM for the motor

func (*MotorFSM) GetState

func (fsm *MotorFSM) GetState() string

GetState returns the current state of the FSM

func (*MotorFSM) UpdateState

func (fsm *MotorFSM) UpdateState(mass float64, elapsedTime float64, burnTime float64) error

UpdateState updates the state based on elapsed time only

type Nosecone

type Nosecone struct {
	ID                ecs.BasicEntity
	Position          types.Vector3
	Radius            float64
	Length            float64
	Mass              float64
	ShapeParameter    float64
	Thickness         float64
	Shape             string
	Finish            string
	MaterialName      string
	MaterialType      string
	Density           float64
	Volume            float64
	SurfaceArea       float64
	AftShoulderRadius float64
	AftShoulderLength float64
	AftShoulderCapped bool
	ShapeClipped      bool
	IsFlipped         bool
}

Nosecone represents the nosecone entity of a rocket

func NewNosecone

func NewNosecone(id ecs.BasicEntity, radius, length, mass, shapeParameter float64) *Nosecone

NewNosecone creates a new nosecone instance

func NewNoseconeFromORK

func NewNoseconeFromORK(id ecs.BasicEntity, orkData *openrocket.OpenrocketDocument) *Nosecone

NewNoseconeFromORK creates a new nosecone instance from an ORK Document

func (*Nosecone) GetCenterOfMassLocal added in v0.8.0

func (n *Nosecone) GetCenterOfMassLocal() types.Vector3

GetCenterOfMassLocal returns the center of mass of the nosecone relative to its own reference point (Position). Assumes solid cone, tip at Z=0, base at Z=n.Length. CG is 3/4 Length from the tip.

func (*Nosecone) GetDensity

func (n *Nosecone) GetDensity() float64

GetDensity returns the material density

func (*Nosecone) GetInertiaTensorLocal added in v0.8.0

func (n *Nosecone) GetInertiaTensorLocal() types.Matrix3x3

GetInertiaTensorLocal returns the inertia tensor of the nosecone about its own center of mass, in local coordinates (Z-axis along cone height).

func (*Nosecone) GetMass

func (n *Nosecone) GetMass() float64

GetMass returns the mass of the nosecone

func (*Nosecone) GetPlanformArea

func (n *Nosecone) GetPlanformArea() float64

GetPlanformArea returns the planform area of the nosecone

func (*Nosecone) GetPosition added in v0.8.0

func (n *Nosecone) GetPosition() types.Vector3

GetPosition returns the global position of the nosecone's reference point (e.g., its tip or base attachment).

func (*Nosecone) GetSurfaceArea

func (n *Nosecone) GetSurfaceArea() float64

GetSurfaceArea returns the surface area of the nosecone

func (*Nosecone) GetVolume

func (n *Nosecone) GetVolume() float64

GetVolume returns the volume of the nosecone material

func (*Nosecone) String

func (n *Nosecone) String() string

String returns a string representation of the Nosecone

func (*Nosecone) Type

func (n *Nosecone) Type() string

Type returns the type of the component

func (*Nosecone) Update

func (n *Nosecone) Update(dt float64) error

Update updates the nosecone (currently does nothing)

type Parachute

type Parachute struct {
	ID              ecs.BasicEntity
	Name            string
	Position        types.Vector3
	Diameter        float64
	DragCoefficient float64
	Strands         int
	LineLength      float64
	Area            float64
	Trigger         ParachuteTrigger
	DeployAltitude  float64
	DeployDelay     float64
	Deployed        bool
}

Parachute is a component that allows the entity to descend under drag and control its descent rate.

func NewParachute

func NewParachute(id ecs.BasicEntity, diameter, dragCoefficient float64, strands int, trigger ParachuteTrigger) *Parachute

NewParachute creates a new parachute instance

func NewParachuteFromORK

func NewParachuteFromORK(id ecs.BasicEntity, orkData *openrocket.OpenrocketDocument) (*Parachute, error)

NewParachuteFromORK creates a new Parachute component from OpenRocket data. It attempts to find the first available parachute definition within the rocket's stages.

func (*Parachute) Deploy

func (p *Parachute) Deploy()

Deploy deploys the parachute

func (*Parachute) GetDensity

func (p *Parachute) GetDensity() float64

GetDensity returns the density of the Parachute

func (*Parachute) GetMass

func (p *Parachute) GetMass() float64

GetMass returns the mass of the parachute component in kg

func (*Parachute) GetPlanformArea

func (p *Parachute) GetPlanformArea() float64

GetPlanformArea returns the planform area of the parachute

func (*Parachute) GetSurfaceArea

func (p *Parachute) GetSurfaceArea() float64

GetSurfaceArea returns the surface area of the Parachute

func (*Parachute) GetVolume

func (p *Parachute) GetVolume() float64

GetVolume returns the volume of the parachute

func (*Parachute) IsDeployed

func (p *Parachute) IsDeployed() bool

IsDeployed returns whether the parachute is currently deployed

func (*Parachute) String

func (p *Parachute) String() string

String returns a string representation of the Parachute struct

func (*Parachute) Type

func (p *Parachute) Type() string

Type returns the type of the component

func (*Parachute) Update

func (p *Parachute) Update(dt float64) error

Update updates the parachute component

type ParachuteTrigger

type ParachuteTrigger string

ParachuteTrigger represents the trigger configuration of the parachute

const (
	// ParachuteTriggerNone represents no trigger
	ParachuteTriggerNone ParachuteTrigger = "none"
	// ParachuteTriggerApogee represents an apogee trigger
	ParachuteTriggerApogee ParachuteTrigger = "apogee"
	// ParachuteTriggerEjection represents an ejection charge trigger
	ParachuteTriggerEjection ParachuteTrigger = "ejection"
)

type TrapezoidFinset

type TrapezoidFinset struct {
	ecs.BasicEntity
	Name          string              // Name of the component
	RootChord     float64             // Root chord of a single fin
	TipChord      float64             // Tip chord of a single fin
	Span          float64             // Span (height) of a single fin
	SweepDistance float64             // Sweep distance (or length) of the leading edge of a single fin
	Thickness     float64             // Thickness of a single fin
	FinCount      int                 // Number of fins in the set
	Material      openrocket.Material // Material of the fins
	Position      types.Vector3       // Axial position of the fin set's attachment point (e.g., leading edge of root chord of fin 0)
	Mass          float64             // Total mass of the entire fin set (all fins)
	CenterOfMass  types.Vector3       // CM of the entire fin set, relative to rocket origin
	InertiaTensor types.Matrix3x3     // Inertia tensor of the entire fin set about its CM, aligned with rocket body axes
}

TrapezoidFinset represents a set of trapezoidal fins on a rocket. All properties are for the entire set unless otherwise specified. Individual fin properties are used to calculate set properties.

func NewTrapezoidFinsetFromORK

func NewTrapezoidFinsetFromORK(orkFinset *openrocket.TrapezoidFinset, orkPosition types.Vector3, orkMaterial openrocket.Material) (*TrapezoidFinset, error)

NewTrapezoidFinsetFromORK creates a new TrapezoidFinset component from OpenRocket data. TODO: This is a basic stub and needs to be fully implemented based on how openrocket.TrapezoidFinset fields map to the simulation's TrapezoidFinset.

func (*TrapezoidFinset) GetCenterOfMassLocal added in v0.8.0

func (fs *TrapezoidFinset) GetCenterOfMassLocal() types.Vector3

GetCenterOfMassLocal returns the finset's center of mass relative to its Position (attachment point).

func (*TrapezoidFinset) GetInertiaTensorLocal added in v0.8.0

func (fs *TrapezoidFinset) GetInertiaTensorLocal() types.Matrix3x3

GetInertiaTensorLocal returns the finset's inertia tensor about its own CG, aligned with rocket axes.

func (*TrapezoidFinset) GetMass

func (f *TrapezoidFinset) GetMass() float64

GetMass returns the total mass of the finset

func (*TrapezoidFinset) GetPlanformArea

func (f *TrapezoidFinset) GetPlanformArea() float64

GetPlanformArea returns the planform area of a single fin in the set.

func (*TrapezoidFinset) GetPosition added in v0.8.0

func (fs *TrapezoidFinset) GetPosition() types.Vector3

GetPosition returns the finset's reference position (attachment point) in rocket coordinates.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL