Documente Academic
Documente Profesional
Documente Cultură
import (
"net/http"
"time"
"github.com/lhemala/dt/api"
"github.com/lhemala/dt/api/command_handler"
"github.com/lhemala/dt/application"
"github.com/lhemala/dt/devices/arduino"
"github.com/lhemala/dt/devices/dw1000"
"github.com/lhemala/dt/devices/dw1000/filter"
"github.com/lhemala/dt/devices/engine"
"github.com/lhemala/dt/devices/hokuyo"
"github.com/lhemala/dt/devices/sonic_sensors"
"github.com/lhemala/dt/gui"
"github.com/lhemala/dt/log"
"github.com/lhemala/dt/state"
)
func main() {
logger := logger.ForFunc("main")
logger.Debug("enter func")
defer logger.Debug("leave func")
engine := engine.New(arduino)
sonics := sonic_sensors.New(arduino)
break
}
if err != nil {
panic("laser sensor could not be initialised")
}
err = engine.Run()
if err != nil {
panic(err)
}
engine.SetAngle(0)
engine.SetSpeed(0)
dw.Run()
sm := state.NewStateManager(
state.WithDW1000(dw),
state.WithEngine(engine),
state.WithSonicSensors(sonics),
state.WithHokuyo(laser),
)
sm.Run()
//sm.AddDestination(&state.Location{
// X: 100,
// Y: 100,
//})
//sm.AddDestination(&state.Location{
// X: 250,
// Y: 250,
//})
ch := command_handler.NewCommandHandler(sm, engine)
time.Sleep(time.Millisecond * 100)
}
}()
mux := http.NewServeMux()
mux.HandleFunc("/", gui.Handle)
mux.Handle("/api", api.Handler)
s := &http.Server{
Addr: ":1717",
Handler: mux,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,
}
sm.SetMode(state.RemoteDriving)
//time.AfterFunc(time.Second*5, func()
{ sm.SetMode(state.AutonomousDriving) })
panic(s.ListenAndServe())
}