fix: default values

This commit is contained in:
Cyrille Nofficial 2021-10-12 22:13:44 +02:00
parent fdedd70471
commit 71c93f2e73
3 changed files with 28 additions and 27 deletions

View File

@ -63,7 +63,7 @@ func main() {
flag.Float64Var(&cameraFishEyeX, "camera-fish-eye-x", 0.4, "")
flag.Float64Var(&cameraFishEyeY, "camera-fish-eye-y", 0.7, "")
flag.IntVar(&cameraImgW, "camera-img-w", 160, "image width")
flag.IntVar(&cameraImgH, "camera-img-h", 120, "image height")
flag.IntVar(&cameraImgH, "camera-img-h", 128, "image height")
flag.IntVar(&cameraImgD, "camera-img-d", 3, "Image depth")
flag.StringVar(&cameraImgEnc, "camera-img-enc", string(simulator.CameraImageEncJpeg), "")
flag.Float64Var(&cameraOffsetX, "camera-offset-x", 0, "moves camera left/right")
@ -107,16 +107,16 @@ func main() {
camera := simulator.CamConfigMsg{
MsgType: simulator.MsgTypeCameraConfig,
Fov: strconv.Itoa(cameraFov),
FishEyeX: fmt.Sprintf("%f", cameraFishEyeX),
FishEyeY: fmt.Sprintf("%f",cameraFishEyeY),
FishEyeX: fmt.Sprintf("%.2f", cameraFishEyeX),
FishEyeY: fmt.Sprintf("%.2f",cameraFishEyeY),
ImgW: strconv.Itoa(cameraImgW),
ImgH: strconv.Itoa(cameraImgH),
ImgD: strconv.Itoa(cameraImgD),
ImgEnc: simulator.CameraImageEnc(cameraImgEnc),
OffsetX: fmt.Sprintf("%f",cameraOffsetX),
OffsetY: fmt.Sprintf("%f", cameraOffsetY),
OffsetZ: fmt.Sprintf("%f", cameraOffsetZ),
RotX: fmt.Sprintf("%f", cameraOffsetZ),
OffsetX: fmt.Sprintf("%.2f",cameraOffsetX),
OffsetY: fmt.Sprintf("%.2f", cameraOffsetY),
OffsetZ: fmt.Sprintf("%.2f", cameraOffsetZ),
RotX: fmt.Sprintf("%.2f", cameraRotX),
}
gtw := gateway.New(address, &carConfig, &racer, &camera)
defer gtw.Stop()

View File

@ -87,14 +87,14 @@ func (g *Gateway) Start() error {
go g.run()
err := g.writeCarConfig()
if err != nil {
return fmt.Errorf("unable to configure car to server: %v", err)
}
err = g.writeRacerConfig()
err := g.writeRacerConfig()
if err != nil {
return fmt.Errorf("unable to configure racer to server: %v", err)
}
err = g.writeCarConfig()
if err != nil {
return fmt.Errorf("unable to configure car to server: %v", err)
}
err = g.writeCameraConfig()
if err != nil {
return fmt.Errorf("unable to configure camera to server: %v", err)
@ -398,7 +398,7 @@ func (g *Gateway) writeCommand(content []byte) error {
g.log.Errorf("unable to connect to simulator to send control command: %v", err)
return nil
}
log.Debugf("write command to simulator: %v", g.lastControl)
log.Debugf("write command to simulator: %v", string(content))
w := bufio.NewWriter(g.conn)
_, err := w.Write(append(content, '\n'))
@ -458,6 +458,7 @@ func (g *Gateway) writeCarConfig() error {
msg := <-carChan
g.log.Infof("Car loaded: %v", msg)
time.Sleep(250 * time.Millisecond)
return nil
}
@ -480,7 +481,7 @@ func (g *Gateway) writeRacerConfig() error {
select {
case msg := <-racerChan:
g.log.Infof("Racer loaded: %v", msg)
case <- time.Tick(25 * time.Millisecond):
case <-time.Tick(250 * time.Millisecond):
}
return nil
}
@ -504,7 +505,7 @@ func (g *Gateway) writeCameraConfig() error {
select {
case msg := <-cameraChan:
g.log.Infof("Camera configured: %v", msg)
case <- time.Tick(25 * time.Millisecond):
case <-time.Tick(250 * time.Millisecond):
}
return nil
}

View File

@ -104,7 +104,7 @@ type CamConfigMsg struct {
MsgType MsgType `json:"msg_type"`
Fov string `json:"fov"`
FishEyeX string `json:"fish_eye_x"`
FishEyeY string `json:"fish_eye_Y"`
FishEyeY string `json:"fish_eye_y"`
ImgW string `json:"img_w"`
ImgH string `json:"img_h"`
ImgD string `json:"img_d"`