Documentation ¶
Overview ¶
Control for the ailerons
Index ¶
- Constants
- Variables
- func ConfigureLogger(file *os.File)
- func IsPi() bool
- func LoadConfiguration(configurationReader io.Reader) error
- func SetLed(on bool) error
- func ToCoordinateRadians(coordinate Coordinate) float64
- func ToggleLed() error
- type Adxl345
- type Adxl345Range
- type Adxl345Rate
- type Axes
- type Control
- type Coordinate
- type Degrees
- type Hmc5883L
- func (a *Hmc5883L) Sense() (physic.MagneticFluxDensity, physic.MagneticFluxDensity, ...)
- func (a *Hmc5883L) SenseRaw() (int16, int16, int16, error)
- func (a *Hmc5883L) SenseRawSlow() (int16, int16, int16, error)
- func (a *Hmc5883L) SetMeasurementMode(newMode Hmc5883LMeasurementMode) error
- func (a *Hmc5883L) SetRange(newGain Hmc5883LGain) error
- func (a *Hmc5883L) SetRate(newRate Hmc5883LRate) error
- func (a *Hmc5883L) SetSampleAveraging(newSample Hmc5883LSampleAveraging) error
- type Hmc5883LGain
- type Hmc5883LMeasurementMode
- type Hmc5883LRate
- type Hmc5883LSampleAveraging
- type LedStatusIndicator
- type Meters
- type MetersPerSecond
- type MultiLogger
- func (logger *MultiLogger) Critical(msg string)
- func (logger *MultiLogger) Criticalf(msg string, args ...interface{})
- func (*MultiLogger) Debug(msg string)
- func (*MultiLogger) Debugf(msg string, args ...interface{})
- func (logger *MultiLogger) Error(msg string)
- func (logger *MultiLogger) Errorf(msg string, args ...interface{})
- func (*MultiLogger) Info(msg string)
- func (*MultiLogger) Infof(msg string, args ...interface{})
- func (logger *MultiLogger) Warning(msg string)
- func (logger *MultiLogger) Warningf(msg string, args ...interface{})
- type Pilot
- type PilotState
- type Point
- type Radians
- type StringWriter
- type Telemetry
- func (telemetry *Telemetry) GetAxes() (Axes, error)
- func (telemetry *Telemetry) GetFilteredAxes() (Axes, error)
- func (telemetry *Telemetry) GetPosition() Point
- func (telemetry *Telemetry) GetSpeed() MetersPerSecond
- func (telemetry *Telemetry) GetTimestamp() int64
- func (telemetry *Telemetry) ParseQueuedMessage() (bool, error)
- type TurnDirection
- type Waypoints
Constants ¶
View Source
const ( ADXL345_RATE_1600HZ Adxl345Rate = 0x0F ADXL345_RATE_800HZ = 0x0E ADXL345_RATE_400HZ = 0x0D ADXL345_RATE_200HZ = 0x0C ADXL345_RATE_100HZ = 0x0B ADXL345_RATE_50HZ = 0x0A ADXL345_RATE_25HZ = 0x09 )
View Source
const ( ADXL345_RANGE_2G Adxl345Range = 0x00 ADXL345_RANGE_4G = 0x01 ADXL345_RANGE_8G = 0x02 ADXL345_RANGE_16G = 0x03 )
View Source
const ( // Copied from the data sheet. Unused values are commented out. ADXL345_DEVID = 0x00 // Device ID. // 0x01 to 0x01C are reserved. Do not access. //ADXL345_THRESH_TAP = 0x1D // Tap threshold. //ADXL345_OFSX = 0x1E // X-axis offset. //ADXL345_OFSY = 0x1F // Y-axis offset. //ADXL345_OFSZ = 0x20 // Z-axis offset. //ADXL345_DUR = 0x21 // Tap duration. //ADXL345_Latent = 0x22 // Tap latency. //ADXL345_Window = 0x23 // Tap window. //ADXL345_THRESH_ACT = 0x24 // Activity threshold. //ADXL345_THRESH_INACT = 0x25 // Inactivity threshold. //ADXL345_TIME_INACT = 0x26 // Inactivity time. //ADXL345_ACT_INACT_CTL = 0x27 // Axis enable control for activity and inactivity detection. //ADXL345_THRESH_FF = 0x28 // Free-fall threshold. //ADXL345_TIME_FF = 0x29 // Free-fall time. //ADXL345_TAP_AXES = 0x2A // Axis control for tap/double tap. //ADXL345_ACT_TAP_STATUS = 0x2B // Source of tap/double tap. ADXL345_BW_RATE = 0x2C // Data rate and power mode control. ADXL345_POWER_CTL = 0x2D // Power-saving features control. //ADXL345_INT_ENABLE = 0x2E // Interrupt enable control. //ADXL345_INT_MAP = 0x2F // Interrupt mapping control. //ADXL345_INT_SOURCE = 0x30 // Source of interrupts. ADXL345_DATA_FORMAT = 0x31 // Data format control. ADXL345_DATAX0 = 0x32 // X-Axis Data 0. ADXL345_DATAX1 = 0x33 // X-Axis Data 1. ADXL345_DATAY0 = 0x34 // Y-Axis Data 0. ADXL345_DATAY1 = 0x35 // Y-Axis Data 1. ADXL345_DATAZ0 = 0x36 // Z-Axis Data 0. ADXL345_DATAZ1 = 0x37 // Z-Axis Data 1. )
ADXL345 registers
View Source
const ( HMC5883L_RATE_0_75_HZ Hmc5883LRate = 0x00 HMC5883L_RATE_1_5HZ = 0x01 HMC5883L_RATE_3_HZ = 0x02 HMC5883L_RATE_7_5_HZ = 0x03 HMC5883L_RATE_15_HZ = 0x04 HMC5883L_RATE_30_HZ = 0x05 HMC5883L_RATE_75_HZ = 0x06 )
View Source
const ( HMC5883L_GAIN_0_88_GA Hmc5883LGain = 0b000 HMC5883L_GAIN_1_3_GA = 0b001 HMC5883L_GAIN_1_9_GA = 0b010 HMC5883L_GAIN_2_5_GA = 0b011 HMC5883L_GAIN_4_0_GA = 0b100 HMC5883L_GAIN_4_7_GA = 0b101 HMC5883L_GAIN_5_6_GA = 0b110 HMC5883L_GAIN_8_1_GA = 0b111 // The physic package uses Tesla, and 1 Tesla = 10,000 Ga HMC5883L_GAIN_0_000088_T Hmc5883LGain = HMC5883L_GAIN_0_88_GA HMC5883L_GAIN_0_00013_T = HMC5883L_GAIN_1_3_GA HMC5883L_GAIN_0_00019_T = HMC5883L_GAIN_1_9_GA HMC5883L_GAIN_0_00025_T = HMC5883L_GAIN_2_5_GA HMC5883L_GAIN_0_00040_T = HMC5883L_GAIN_4_0_GA HMC5883L_GAIN_0_00047_T = HMC5883L_GAIN_4_7_GA HMC5883L_GAIN_0_00056_T = HMC5883L_GAIN_5_6_GA HMC5883L_GAIN_0_00081_T = HMC5883L_GAIN_8_1_GA )
View Source
const ( HMC5883L_MODE_CONTINUOUS Hmc5883LMeasurementMode = 0b00 HMC5883L_MODE_SINGLE = 0b01 HMC5883L_MODE_IDLE = 0b10 )
View Source
const ( HMC5883L_SAMPLES_1 Hmc5883LSampleAveraging = 0b00 HMC5883L_SAMPLES_2 = 0b01 HMC5883L_SAMPLES_4 = 0b10 HMC5883L_SAMPLES_8 = 0b11 )
View Source
const ( // Copied from the data sheet. Unused values are commented out. HMC5883L_CONFIGURATION_REGISTER_A = 0 HMC5883L_CONFIGURATION_REGISTER_B = 1 HMC5883L_MODE_REGISTER = 2 HMC5883L_DATA_OUTPUT_XMSB_REGISTER = 3 HMC5883L_DATA_OUTPUT_XLSB_REGISTER = 4 HMC5883L_DATA_OUTPUT_ZMSB_REGISTER = 5 HMC5883L_DATA_OUTPUT_ZLSB_REGISTER = 6 HMC5883L_DATA_OUTPUT_YMSB_REGISTER = 7 HMC5883L_DATA_OUTPUT_YLSB_REGISTER = 8 HMC5883L_STATUS_REGISTER = 9 HMC5883L_IDENTIFICATION_REGISTER_A = 10 HMC5883L_IDENTIFICATION_REGISTER_B = 11 HMC5883L_IDENTIFICATION_REGISTER_C = 12 )
HMC5883L registers
View Source
const ( DISTANCE_FORMULA_HAVERSINE distanceFormula_t = iota DISTANCE_FORMULA_SPHERICAL_LAW_OF_COSINES DISTANCE_FORMULA_EQUIRECTANGULAR DISTANCE_FORMULA_CACHED_EQUIRECTANGULAR )
View Source
const ( BEARING_FORMULA_EQUIRECTANGULAR bearingFormula_t = iota BEARING_FORMULA_CACHED_EQUIRECTANGULAR )
View Source
const ADXL345_ADDRESS = 0x53
View Source
const HERTZ = 50
View Source
const HMC5883L_READ_ADDRESS = 0x1E
View Source
const MULTIPLIER = 20000
Originally I had MULTIPLIER set to 100_000 but then my cycle wouldn't come out as 20 us, instead it was around 16? Checked with an oscilloscope. Maybe some overflow.
View Source
const PI = 3.14159265358979
View Source
const RADIUS_M = 6371e3
View Source
const US_PER_CYCLE = (1000 * 1000) / HERTZ
View Source
const US_PER_DEGREE = 800 / 90
Variables ¶
View Source
var Logger = newLogger()
Functions ¶
func ConfigureLogger ¶
func LoadConfiguration ¶
func ToCoordinateRadians ¶
func ToCoordinateRadians(coordinate Coordinate) float64
Types ¶
type Adxl345 ¶
func (*Adxl345) SetRange ¶
func (a *Adxl345) SetRange(newRange Adxl345Range) error
func (*Adxl345) SetRate ¶
func (a *Adxl345) SetRate(newRate Adxl345Rate) error
type Control ¶
type Control struct {
// contains filtered or unexported fields
}
func NewControl ¶
func NewControl() *Control
type Coordinate ¶
type Coordinate = float64
type Hmc5883L ¶
func (*Hmc5883L) Sense ¶
func (a *Hmc5883L) Sense() (physic.MagneticFluxDensity, physic.MagneticFluxDensity, physic.MagneticFluxDensity, error)
func (*Hmc5883L) SenseRawSlow ¶
This method is disabled because it's probably slower than the above
func (*Hmc5883L) SetMeasurementMode ¶
func (a *Hmc5883L) SetMeasurementMode(newMode Hmc5883LMeasurementMode) error
func (*Hmc5883L) SetRange ¶
func (a *Hmc5883L) SetRange(newGain Hmc5883LGain) error
func (*Hmc5883L) SetRate ¶
func (a *Hmc5883L) SetRate(newRate Hmc5883LRate) error
func (*Hmc5883L) SetSampleAveraging ¶
func (a *Hmc5883L) SetSampleAveraging(newSample Hmc5883LSampleAveraging) error
type LedStatusIndicator ¶
type LedStatusIndicator struct {
// contains filtered or unexported fields
}
func NewLedStatusIndicator ¶
func NewLedStatusIndicator(blinksToShow uint8) *LedStatusIndicator
func (*LedStatusIndicator) BlinkState ¶
func (statusIndicator *LedStatusIndicator) BlinkState(newBlinkCount uint8) bool
Continues blinking the state. If the blink finishes, it will start blinking the next state.
func (*LedStatusIndicator) Reset ¶
func (statusIndicator *LedStatusIndicator) Reset()
type MetersPerSecond ¶
type MetersPerSecond = float64
type MultiLogger ¶
type MultiLogger struct {
// contains filtered or unexported fields
}
func (*MultiLogger) Critical ¶
func (logger *MultiLogger) Critical(msg string)
func (*MultiLogger) Criticalf ¶
func (logger *MultiLogger) Criticalf(msg string, args ...interface{})
func (*MultiLogger) Debug ¶
func (*MultiLogger) Debug(msg string)
func (*MultiLogger) Debugf ¶
func (*MultiLogger) Debugf(msg string, args ...interface{})
func (*MultiLogger) Error ¶
func (logger *MultiLogger) Error(msg string)
func (*MultiLogger) Errorf ¶
func (logger *MultiLogger) Errorf(msg string, args ...interface{})
func (*MultiLogger) Info ¶
func (*MultiLogger) Info(msg string)
func (*MultiLogger) Infof ¶
func (*MultiLogger) Infof(msg string, args ...interface{})
func (*MultiLogger) Warning ¶
func (logger *MultiLogger) Warning(msg string)
func (*MultiLogger) Warningf ¶
func (logger *MultiLogger) Warningf(msg string, args ...interface{})
type Pilot ¶
type Pilot struct {
// contains filtered or unexported fields
}
func (*Pilot) RunGlideTestForever ¶
func (pilot *Pilot) RunGlideTestForever()
Run the local glide test, e.g. when throwing the plane down a hill
type PilotState ¶
type PilotState uint8
func (PilotState) String ¶
func (ps PilotState) String() string
type Point ¶
type Point struct { Latitude Coordinate Longitude Coordinate Altitude Meters }
type StringWriter ¶
type StringWriter struct {
Line int
}
func (*StringWriter) IndentLine ¶
func (writer *StringWriter) IndentLine(str string)
func (*StringWriter) WriteLine ¶
func (writer *StringWriter) WriteLine(str string)
type Telemetry ¶
type Telemetry struct { HasGpsLock bool // contains filtered or unexported fields }
func NewTelemetry ¶
func (*Telemetry) GetFilteredAxes ¶
func (*Telemetry) GetPosition ¶
func (*Telemetry) GetSpeed ¶
func (telemetry *Telemetry) GetSpeed() MetersPerSecond
func (*Telemetry) GetTimestamp ¶
func (*Telemetry) ParseQueuedMessage ¶
Parse any waiting GPS messages. Users need not call this, but may.
type TurnDirection ¶
type TurnDirection uint8
const ( Left TurnDirection = iota Right Straight UTurn )
func GetTurnDirection ¶
func GetTurnDirection(bearing_r Radians, start, end Point) TurnDirection
Returns the direction needed to turn to get from start to end
func (TurnDirection) String ¶
func (td TurnDirection) String() string
type Waypoints ¶
type Waypoints struct {
// contains filtered or unexported fields
}
Continues through several waypoints, then repeats the last few
func NewWaypoints ¶
func NewWaypoints() *Waypoints
func (*Waypoints) GetWaypoint ¶
Click to show internal directories.
Click to hide internal directories.