Configure car and camera at startup

This commit is contained in:
2021-02-16 17:46:10 +01:00
parent 3d81336c9b
commit 0fe45a3c9c
7 changed files with 423 additions and 99 deletions

View File

@ -1,18 +1,22 @@
package simulator
const(
MsgTypeControl = "control"
MsgTypeTelemetry = "telemetry"
MsgTypeCarConfig = "car_config"
MsgTypeCarLoaded = "car_loaded"
type MsgType string
const (
MsgTypeControl = MsgType("control")
MsgTypeTelemetry = MsgType("telemetry")
MsgTypeCarConfig = MsgType("car_config")
MsgTypeCarLoaded = MsgType("car_loaded")
MsgTypeRacerInfo = MsgType("racer_info")
MsgTypeCameraConfig = MsgType("cam_config")
)
type Msg struct {
MsgType string `json:"msg_type"`
MsgType MsgType `json:"msg_type"`
}
type TelemetryMsg struct {
MsgType string `json:"msg_type"`
MsgType MsgType `json:"msg_type"`
SteeringAngle float64 `json:"steering_angle"`
Throttle float64 `json:"throttle"`
Speed float64 `json:"speed"`
@ -27,40 +31,43 @@ type TelemetryMsg struct {
/* Json msg used to control cars. MsgType must be filled with "control" */
type ControlMsg struct {
MsgType string `json:"msg_type"`
Steering string `json:"steering"`
Throttle string `json:"throttle"`
Brake string `json:"brake"`
MsgType MsgType `json:"msg_type"`
Steering string `json:"steering"`
Throttle string `json:"throttle"`
Brake string `json:"brake"`
}
type GetSceneNamesMsg struct {
MsgType string `json:"msg_type"`
SceneName string `json:"scene_name"`
MsgType MsgType `json:"msg_type"`
SceneName string `json:"scene_name"`
}
type LoadSceneMsg struct {
MsgType string `json:"msg_type"`
SceneName string `json:"scene_name"`
MsgType MsgType `json:"msg_type"`
SceneName string `json:"scene_name"`
}
const(
CarConfigBodyStyleDonkey = "donkey"
CarConfigBodyStyleBare = "bare"
CarConfigBodyStyleCar01 = "car01"
type CarStyle string
const (
CarConfigBodyStyleDonkey = CarStyle("donkey")
CarConfigBodyStyleBare = CarStyle("bare")
CarConfigBodyStyleCar01 = CarStyle("car01")
)
/*
# body_style = "donkey" | "bare" | "car01" choice of string
# body_rgb = (128, 128, 128) tuple of ints
# car_name = "string less than 64 char"
*/
type CarConfigMsg struct {
MsgType string `json:"msg_type"`
BodyStyle string `json:"body_style"`
BodyR string `json:"body_r"`
BodyG string `json:"body_g"`
BodyB string `json:"body_b"`
CarName string `json:"car_name"`
FontSize string `json:"font_size"`
MsgType MsgType `json:"msg_type"`
BodyStyle CarStyle `json:"body_style"`
BodyR string `json:"body_r"`
BodyG string `json:"body_g"`
BodyB string `json:"body_b"`
CarName string `json:"car_name"`
FontSize string `json:"font_size"`
}
/*
@ -68,14 +75,22 @@ type CarConfigMsg struct {
# guid = "some random string"
*/
type RacerBioMsg struct {
MsgType string `json:"msg_type"`
RacerName string `json:"racer_name"`
CarName string `json:"car_name"`
Bio string `json:"bio"`
Country string `json:"country"`
Guid string `json:"guid"`
MsgType MsgType `json:"msg_type"`
RacerName string `json:"racer_name"`
CarName string `json:"car_name"`
Bio string `json:"bio"`
Country string `json:"country"`
Guid string `json:"guid"`
}
type CameraImageEnc string
const (
CameraImageEncJpeg = CameraImageEnc("JPG")
CameraImageEncPng = CameraImageEnc("PNG")
CameraImageEncTga = CameraImageEnc("TGA")
)
/* Camera config
set any field to Zero to get the default camera setting.
offset_x moves camera left/right
@ -86,16 +101,16 @@ with fish_eye_x/y == 0.0 then you get no distortion
img_enc can be one of JPG|PNG|TGA
*/
type CamConfigMsg struct {
MsgType string `json:"msg_type"`
Fov string `json:"fov"`
FishEyeX string `json:"fish_eye_x"`
FishEyeY string `json:"fish_eye_Y"`
ImgW string `json:"img_w"`
ImgH string `json:"img_h"`
ImgD string `json:"img_d"`
ImgEnc string `json:"img_enc"`
OffsetX string `json:"offset_x"`
OffsetY string `json:"offset_y"`
OffsetZ string `json:"offset_z"`
RotX string `json:"rot_x"`
MsgType MsgType `json:"msg_type"`
Fov string `json:"fov"`
FishEyeX string `json:"fish_eye_x"`
FishEyeY string `json:"fish_eye_Y"`
ImgW string `json:"img_w"`
ImgH string `json:"img_h"`
ImgD string `json:"img_d"`
ImgEnc CameraImageEnc `json:"img_enc"`
OffsetX string `json:"offset_x"`
OffsetY string `json:"offset_y"`
OffsetZ string `json:"offset_z"`
RotX string `json:"rot_x"`
}