Implement steering/throttle reading from simulator
This commit is contained in:
@ -3,30 +3,35 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"github.com/cyrilix/robocar-base/cli"
|
||||
"github.com/cyrilix/robocar-simulator/camera"
|
||||
"log"
|
||||
"github.com/cyrilix/robocar-simulator/pkg/gateway"
|
||||
log"github.com/sirupsen/logrus"
|
||||
"os"
|
||||
)
|
||||
|
||||
const DefaultClientId = "robocar-camera"
|
||||
const DefaultClientId = "robocar-simulator"
|
||||
|
||||
func main() {
|
||||
var mqttBroker, username, password, clientId, topicBase string
|
||||
var mqttBroker, username, password, clientId, topicFrame string
|
||||
var address string
|
||||
var debug bool
|
||||
|
||||
mqttQos := cli.InitIntFlag("MQTT_QOS", 0)
|
||||
_, mqttRetain := os.LookupEnv("MQTT_RETAIN")
|
||||
|
||||
cli.InitMqttFlags(DefaultClientId, &mqttBroker, &username, &password, &clientId, &mqttQos, &mqttRetain)
|
||||
|
||||
flag.StringVar(&topicBase, "mqtt-topic", os.Getenv("MQTT_TOPIC"), "Mqtt topic to publish camera frames, use MQTT_TOPIC if args not set")
|
||||
flag.StringVar(&topicFrame, "mqtt-topic-frame", os.Getenv("MQTT_TOPIC"), "Mqtt topic to publish gateway frames, use MQTT_TOPIC_FRAME if args not set")
|
||||
flag.StringVar(&address, "simulator-address", "127.0.0.1:9091", "Simulator address")
|
||||
flag.BoolVar(&debug, "debug", false, "Debug logs")
|
||||
|
||||
flag.Parse()
|
||||
if len(os.Args) <= 1 {
|
||||
flag.PrintDefaults()
|
||||
os.Exit(1)
|
||||
}
|
||||
if debug {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
}
|
||||
|
||||
client, err := cli.Connect(mqttBroker, username, password, clientId)
|
||||
if err != nil {
|
||||
@ -35,7 +40,7 @@ func main() {
|
||||
defer client.Disconnect(10)
|
||||
|
||||
|
||||
c := camera.New(camera.NewMqttPublisher(client, topicBase), address)
|
||||
c := gateway.New(gateway.NewMqttPublisher(client, topicFrame, "", ""), address)
|
||||
defer c.Stop()
|
||||
|
||||
cli.HandleExit(c)
|
||||
|
Reference in New Issue
Block a user