2020-09-20 21:16:06 +00:00
|
|
|
package simulator
|
|
|
|
|
2021-02-16 16:46:10 +00:00
|
|
|
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")
|
2021-02-09 18:14:29 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Msg struct {
|
2021-02-16 16:46:10 +00:00
|
|
|
MsgType MsgType `json:"msg_type"`
|
2021-02-09 18:14:29 +00:00
|
|
|
}
|
|
|
|
|
2020-11-29 17:42:33 +00:00
|
|
|
type TelemetryMsg struct {
|
2021-02-16 16:46:10 +00:00
|
|
|
MsgType MsgType `json:"msg_type"`
|
2020-09-20 21:16:06 +00:00
|
|
|
SteeringAngle float64 `json:"steering_angle"`
|
|
|
|
Throttle float64 `json:"throttle"`
|
|
|
|
Speed float64 `json:"speed"`
|
|
|
|
Image []byte `json:"image"`
|
|
|
|
Hit string `json:"hit"`
|
|
|
|
PosX float64 `json:"pos_x"`
|
|
|
|
PosY float64 `json:"posy"`
|
|
|
|
PosZ float64 `json:"pos_z"`
|
|
|
|
Time float64 `json:"time"`
|
|
|
|
Cte float64 `json:"cte"`
|
|
|
|
}
|
2020-11-29 17:42:33 +00:00
|
|
|
|
|
|
|
/* Json msg used to control cars. MsgType must be filled with "control" */
|
|
|
|
type ControlMsg struct {
|
2021-02-16 16:46:10 +00:00
|
|
|
MsgType MsgType `json:"msg_type"`
|
|
|
|
Steering string `json:"steering"`
|
|
|
|
Throttle string `json:"throttle"`
|
|
|
|
Brake string `json:"brake"`
|
2021-02-09 18:14:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type GetSceneNamesMsg struct {
|
2021-02-16 16:46:10 +00:00
|
|
|
MsgType MsgType `json:"msg_type"`
|
|
|
|
SceneName string `json:"scene_name"`
|
2021-02-09 18:14:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type LoadSceneMsg struct {
|
2021-02-16 16:46:10 +00:00
|
|
|
MsgType MsgType `json:"msg_type"`
|
|
|
|
SceneName string `json:"scene_name"`
|
2021-02-09 18:14:29 +00:00
|
|
|
}
|
|
|
|
|
2021-02-16 16:46:10 +00:00
|
|
|
type CarStyle string
|
|
|
|
|
|
|
|
const (
|
|
|
|
CarConfigBodyStyleDonkey = CarStyle("donkey")
|
|
|
|
CarConfigBodyStyleBare = CarStyle("bare")
|
|
|
|
CarConfigBodyStyleCar01 = CarStyle("car01")
|
2021-02-09 18:14:29 +00:00
|
|
|
)
|
2021-02-16 16:46:10 +00:00
|
|
|
|
2021-02-09 18:14:29 +00:00
|
|
|
/*
|
|
|
|
# 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 {
|
2021-02-16 16:46:10 +00:00
|
|
|
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"`
|
2021-02-09 18:14:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
# car_name = "string less than 64 char"
|
|
|
|
# guid = "some random string"
|
|
|
|
*/
|
|
|
|
type RacerBioMsg struct {
|
2021-02-16 16:46:10 +00:00
|
|
|
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"`
|
2021-02-09 18:14:29 +00:00
|
|
|
}
|
|
|
|
|
2021-02-16 16:46:10 +00:00
|
|
|
type CameraImageEnc string
|
|
|
|
|
|
|
|
const (
|
|
|
|
CameraImageEncJpeg = CameraImageEnc("JPG")
|
|
|
|
CameraImageEncPng = CameraImageEnc("PNG")
|
|
|
|
CameraImageEncTga = CameraImageEnc("TGA")
|
|
|
|
)
|
|
|
|
|
2021-02-09 18:14:29 +00:00
|
|
|
/* Camera config
|
|
|
|
set any field to Zero to get the default camera setting.
|
|
|
|
offset_x moves camera left/right
|
|
|
|
offset_y moves camera up/down
|
|
|
|
offset_z moves camera forward/back
|
|
|
|
rot_x will rotate the camera
|
|
|
|
with fish_eye_x/y == 0.0 then you get no distortion
|
|
|
|
img_enc can be one of JPG|PNG|TGA
|
|
|
|
*/
|
|
|
|
type CamConfigMsg struct {
|
2021-02-16 16:46:10 +00:00
|
|
|
MsgType MsgType `json:"msg_type"`
|
|
|
|
Fov string `json:"fov"`
|
|
|
|
FishEyeX string `json:"fish_eye_x"`
|
2021-10-12 20:13:44 +00:00
|
|
|
FishEyeY string `json:"fish_eye_y"`
|
2021-02-16 16:46:10 +00:00
|
|
|
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"`
|
2020-11-29 17:42:33 +00:00
|
|
|
}
|