Пример #1
0
func NewInstances(c Config) (i Instances, err error) {
	i.log = log.DefaultLogger
	i.navboard = navboard.NewNavboard(c.NavboardTTY, i.log)
	i.motorboard, err = motorboard.NewMotorboard(c.MotorboardTTY)
	if err != nil {
		return
	}
	i.attitude = attitude.NewComplementary()
	i.control = control.NewControl(c.RollPID, c.PitchPID, c.YawPID)
	i.http = http.NewHandler(i.control, i.log)
	return
}
Пример #2
0
func main() {
	m, err := motorboard.NewMotorboard(motorboard.DefaultTTY, log)
	if err != nil {
		panic(err)
	}

	if err := navboard.Calibrate(); err != nil {
		log.Fatal(err)
	}
	defer navboard.Close()

	go loop(m)

	sigCh := make(chan os.Signal, 1)
	signal.Notify(sigCh, os.Interrupt)
	<-sigCh

	log.Debug("Shutting down")
}