fix: default values
This commit is contained in:
parent
fdedd70471
commit
71c93f2e73
@ -63,7 +63,7 @@ func main() {
|
|||||||
flag.Float64Var(&cameraFishEyeX, "camera-fish-eye-x", 0.4, "")
|
flag.Float64Var(&cameraFishEyeX, "camera-fish-eye-x", 0.4, "")
|
||||||
flag.Float64Var(&cameraFishEyeY, "camera-fish-eye-y", 0.7, "")
|
flag.Float64Var(&cameraFishEyeY, "camera-fish-eye-y", 0.7, "")
|
||||||
flag.IntVar(&cameraImgW, "camera-img-w", 160, "image width")
|
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.IntVar(&cameraImgD, "camera-img-d", 3, "Image depth")
|
||||||
flag.StringVar(&cameraImgEnc, "camera-img-enc", string(simulator.CameraImageEncJpeg), "")
|
flag.StringVar(&cameraImgEnc, "camera-img-enc", string(simulator.CameraImageEncJpeg), "")
|
||||||
flag.Float64Var(&cameraOffsetX, "camera-offset-x", 0, "moves camera left/right")
|
flag.Float64Var(&cameraOffsetX, "camera-offset-x", 0, "moves camera left/right")
|
||||||
@ -107,16 +107,16 @@ func main() {
|
|||||||
camera := simulator.CamConfigMsg{
|
camera := simulator.CamConfigMsg{
|
||||||
MsgType: simulator.MsgTypeCameraConfig,
|
MsgType: simulator.MsgTypeCameraConfig,
|
||||||
Fov: strconv.Itoa(cameraFov),
|
Fov: strconv.Itoa(cameraFov),
|
||||||
FishEyeX: fmt.Sprintf("%f", cameraFishEyeX),
|
FishEyeX: fmt.Sprintf("%.2f", cameraFishEyeX),
|
||||||
FishEyeY: fmt.Sprintf("%f",cameraFishEyeY),
|
FishEyeY: fmt.Sprintf("%.2f",cameraFishEyeY),
|
||||||
ImgW: strconv.Itoa(cameraImgW),
|
ImgW: strconv.Itoa(cameraImgW),
|
||||||
ImgH: strconv.Itoa(cameraImgH),
|
ImgH: strconv.Itoa(cameraImgH),
|
||||||
ImgD: strconv.Itoa(cameraImgD),
|
ImgD: strconv.Itoa(cameraImgD),
|
||||||
ImgEnc: simulator.CameraImageEnc(cameraImgEnc),
|
ImgEnc: simulator.CameraImageEnc(cameraImgEnc),
|
||||||
OffsetX: fmt.Sprintf("%f",cameraOffsetX),
|
OffsetX: fmt.Sprintf("%.2f",cameraOffsetX),
|
||||||
OffsetY: fmt.Sprintf("%f", cameraOffsetY),
|
OffsetY: fmt.Sprintf("%.2f", cameraOffsetY),
|
||||||
OffsetZ: fmt.Sprintf("%f", cameraOffsetZ),
|
OffsetZ: fmt.Sprintf("%.2f", cameraOffsetZ),
|
||||||
RotX: fmt.Sprintf("%f", cameraOffsetZ),
|
RotX: fmt.Sprintf("%.2f", cameraRotX),
|
||||||
}
|
}
|
||||||
gtw := gateway.New(address, &carConfig, &racer, &camera)
|
gtw := gateway.New(address, &carConfig, &racer, &camera)
|
||||||
defer gtw.Stop()
|
defer gtw.Stop()
|
||||||
|
@ -87,14 +87,14 @@ func (g *Gateway) Start() error {
|
|||||||
|
|
||||||
go g.run()
|
go g.run()
|
||||||
|
|
||||||
err := g.writeCarConfig()
|
err := g.writeRacerConfig()
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("unable to configure car to server: %v", err)
|
|
||||||
}
|
|
||||||
err = g.writeRacerConfig()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to configure racer to server: %v", err)
|
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()
|
err = g.writeCameraConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to configure camera to server: %v", err)
|
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)
|
g.log.Errorf("unable to connect to simulator to send control command: %v", err)
|
||||||
return nil
|
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)
|
w := bufio.NewWriter(g.conn)
|
||||||
|
|
||||||
_, err := w.Write(append(content, '\n'))
|
_, err := w.Write(append(content, '\n'))
|
||||||
@ -458,6 +458,7 @@ func (g *Gateway) writeCarConfig() error {
|
|||||||
|
|
||||||
msg := <-carChan
|
msg := <-carChan
|
||||||
g.log.Infof("Car loaded: %v", msg)
|
g.log.Infof("Car loaded: %v", msg)
|
||||||
|
time.Sleep(250 * time.Millisecond)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -477,10 +478,10 @@ func (g *Gateway) writeRacerConfig() error {
|
|||||||
return fmt.Errorf("unable to send racer config to simulator: %v", err)
|
return fmt.Errorf("unable to send racer config to simulator: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
select{
|
select {
|
||||||
case msg := <-racerChan:
|
case msg := <-racerChan:
|
||||||
g.log.Infof("Racer loaded: %v", msg)
|
g.log.Infof("Racer loaded: %v", msg)
|
||||||
case <- time.Tick(25 * time.Millisecond):
|
case <-time.Tick(250 * time.Millisecond):
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -501,10 +502,10 @@ func (g *Gateway) writeCameraConfig() error {
|
|||||||
return fmt.Errorf("unable to send camera config to simulator: %v", err)
|
return fmt.Errorf("unable to send camera config to simulator: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
select{
|
select {
|
||||||
case msg := <-cameraChan:
|
case msg := <-cameraChan:
|
||||||
g.log.Infof("Camera configured: %v", msg)
|
g.log.Infof("Camera configured: %v", msg)
|
||||||
case <- time.Tick(25 * time.Millisecond):
|
case <-time.Tick(250 * time.Millisecond):
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ type CamConfigMsg struct {
|
|||||||
MsgType MsgType `json:"msg_type"`
|
MsgType MsgType `json:"msg_type"`
|
||||||
Fov string `json:"fov"`
|
Fov string `json:"fov"`
|
||||||
FishEyeX string `json:"fish_eye_x"`
|
FishEyeX string `json:"fish_eye_x"`
|
||||||
FishEyeY string `json:"fish_eye_Y"`
|
FishEyeY string `json:"fish_eye_y"`
|
||||||
ImgW string `json:"img_w"`
|
ImgW string `json:"img_w"`
|
||||||
ImgH string `json:"img_h"`
|
ImgH string `json:"img_h"`
|
||||||
ImgD string `json:"img_d"`
|
ImgD string `json:"img_d"`
|
||||||
|
Loading…
Reference in New Issue
Block a user