From 2de5220071f515ac59261d1e40b076701f40923a Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Mon, 21 Aug 2017 23:20:18 +0200 Subject: Add trim --- car/elegoo/elegoo.pb.go | 48 ++++++++++++++++++++++++++++-------------------- car/elegoo/elegoo.proto | 5 +++-- car/elegoo/main.go | 8 +------- 3 files changed, 32 insertions(+), 29 deletions(-) (limited to 'car/elegoo') diff --git a/car/elegoo/elegoo.pb.go b/car/elegoo/elegoo.pb.go index a0e9704..b20c09c 100644 --- a/car/elegoo/elegoo.pb.go +++ b/car/elegoo/elegoo.pb.go @@ -32,8 +32,9 @@ type Command struct { SpeedR int32 `protobuf:"zigzag32,1,opt,name=SpeedR" json:"SpeedR,omitempty"` SpeedL int32 `protobuf:"zigzag32,2,opt,name=SpeedL" json:"SpeedL,omitempty"` Stop bool `protobuf:"varint,3,opt,name=Stop" json:"Stop,omitempty"` - TurnHead int32 `protobuf:"zigzag32,4,opt,name=TurnHead" json:"TurnHead,omitempty"` - Center bool `protobuf:"varint,5,opt,name=Center" json:"Center,omitempty"` + Center bool `protobuf:"varint,4,opt,name=Center" json:"Center,omitempty"` + TurnHead int32 `protobuf:"zigzag32,5,opt,name=TurnHead" json:"TurnHead,omitempty"` + Trim int32 `protobuf:"zigzag32,6,opt,name=Trim" json:"Trim,omitempty"` } func (m *Command) Reset() { *m = Command{} } @@ -62,6 +63,13 @@ func (m *Command) GetStop() bool { return false } +func (m *Command) GetCenter() bool { + if m != nil { + return m.Center + } + return false +} + func (m *Command) GetTurnHead() int32 { if m != nil { return m.TurnHead @@ -69,11 +77,11 @@ func (m *Command) GetTurnHead() int32 { return 0 } -func (m *Command) GetCenter() bool { +func (m *Command) GetTrim() int32 { if m != nil { - return m.Center + return m.Trim } - return false + return 0 } type Event struct { @@ -132,19 +140,19 @@ func init() { func init() { proto.RegisterFile("elegoo.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 212 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x49, 0xcd, 0x49, 0x4d, - 0xcf, 0xcf, 0xd7, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x57, 0x6a, 0x64, 0xe4, 0x62, 0x77, 0xce, 0xcf, - 0xcd, 0x4d, 0xcc, 0x4b, 0x11, 0x12, 0xe3, 0x62, 0x0b, 0x2e, 0x48, 0x4d, 0x4d, 0x09, 0x92, 0x60, - 0x54, 0x60, 0xd4, 0x10, 0x0c, 0x82, 0xf2, 0xe0, 0xe2, 0x3e, 0x12, 0x4c, 0x48, 0xe2, 0x3e, 0x42, - 0x42, 0x5c, 0x2c, 0xc1, 0x25, 0xf9, 0x05, 0x12, 0xcc, 0x0a, 0x8c, 0x1a, 0x1c, 0x41, 0x60, 0xb6, - 0x90, 0x14, 0x17, 0x47, 0x48, 0x69, 0x51, 0x9e, 0x47, 0x6a, 0x62, 0x8a, 0x04, 0x0b, 0x58, 0x35, - 0x9c, 0x0f, 0x32, 0xc7, 0x39, 0x35, 0xaf, 0x24, 0xb5, 0x48, 0x82, 0x15, 0xac, 0x03, 0xca, 0x53, - 0xea, 0x65, 0xe4, 0x62, 0x75, 0x2d, 0x4b, 0xcd, 0x2b, 0x01, 0xe9, 0x76, 0xc9, 0x2c, 0x2e, 0x49, - 0xcc, 0x4b, 0x4e, 0x05, 0xbb, 0x81, 0x37, 0x08, 0xce, 0x17, 0x92, 0xe0, 0x62, 0x0f, 0x4e, 0xcd, - 0x2b, 0xce, 0x2f, 0x0a, 0x02, 0x3b, 0x83, 0x23, 0x08, 0xc6, 0x45, 0xc8, 0x38, 0x43, 0x9d, 0x02, - 0xe3, 0x22, 0x64, 0x7c, 0xc0, 0x8e, 0x81, 0xcb, 0xf8, 0x80, 0x6c, 0xf2, 0x4e, 0xad, 0x0c, 0x28, - 0x4a, 0x2d, 0x2e, 0x06, 0xbb, 0x86, 0x37, 0x08, 0xce, 0x77, 0x62, 0x8b, 0x62, 0xc9, 0x4d, 0xcc, - 0xcc, 0x4b, 0x62, 0x03, 0x07, 0x91, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x8f, 0x9d, 0x88, 0x7d, - 0x32, 0x01, 0x00, 0x00, + // 219 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xb1, 0x4a, 0xc5, 0x30, + 0x14, 0x86, 0x89, 0xb6, 0x69, 0x09, 0x76, 0x30, 0x83, 0x04, 0xa7, 0xd2, 0xa9, 0x93, 0x8b, 0x6f, + 0x60, 0x15, 0x04, 0x3b, 0x48, 0xda, 0xc9, 0x2d, 0xda, 0x83, 0x14, 0x4c, 0x52, 0x92, 0x28, 0xf8, + 0x10, 0x8e, 0xbe, 0xef, 0x25, 0x87, 0x34, 0xbd, 0xdb, 0xf9, 0xfe, 0x93, 0xfc, 0xf9, 0x08, 0xbb, + 0x82, 0x2f, 0xf8, 0xb4, 0xf6, 0x6e, 0x73, 0x36, 0xd8, 0xee, 0x9f, 0xb0, 0x6a, 0xb0, 0x5a, 0x2b, + 0xb3, 0xf0, 0x1b, 0x46, 0xa7, 0x0d, 0x60, 0x91, 0x82, 0xb4, 0xa4, 0xbf, 0x96, 0x89, 0x72, 0x3e, + 0x8a, 0x8b, 0xb3, 0x7c, 0xe4, 0x9c, 0x15, 0x53, 0xb0, 0x9b, 0xb8, 0x6c, 0x49, 0x5f, 0x4b, 0x9c, + 0xe3, 0xd9, 0x01, 0x4c, 0x00, 0x27, 0x0a, 0x4c, 0x13, 0xf1, 0x5b, 0x56, 0xcf, 0xdf, 0xce, 0x3c, + 0x83, 0x5a, 0x44, 0x89, 0x2d, 0x99, 0x63, 0xcf, 0xec, 0x56, 0x2d, 0x28, 0xe6, 0x38, 0x77, 0x7f, + 0x84, 0x95, 0x4f, 0x3f, 0x60, 0x42, 0xbc, 0xf9, 0xb8, 0xfa, 0xa0, 0xcc, 0x07, 0xa0, 0x57, 0x23, + 0x33, 0x73, 0xc1, 0xaa, 0x09, 0x8c, 0xb7, 0x4e, 0xa2, 0x5a, 0x2d, 0x77, 0x3c, 0x36, 0x43, 0xd2, + 0xdb, 0xf1, 0xd8, 0x8c, 0x49, 0x71, 0xc7, 0xf8, 0xd2, 0x0b, 0xfc, 0xbe, 0x3a, 0xf0, 0x1e, 0x1d, + 0x1b, 0x99, 0xf9, 0x81, 0xbe, 0x15, 0x5a, 0xad, 0xe6, 0x9d, 0xe2, 0xb7, 0xdd, 0x9f, 0x02, 0x00, + 0x00, 0xff, 0xff, 0x67, 0x52, 0x91, 0x80, 0x46, 0x01, 0x00, 0x00, } diff --git a/car/elegoo/elegoo.proto b/car/elegoo/elegoo.proto index f310b62..bdf1b95 100644 --- a/car/elegoo/elegoo.proto +++ b/car/elegoo/elegoo.proto @@ -6,8 +6,9 @@ message Command { sint32 SpeedR = 1; sint32 SpeedL = 2; bool Stop = 3; - sint32 TurnHead = 4; // ±90 deg - bool Center = 5; + bool Center = 4; + sint32 TurnHead = 5; // ±90 deg + sint32 Trim = 6; } message Event { diff --git a/car/elegoo/main.go b/car/elegoo/main.go index 900b584..df5dabc 100644 --- a/car/elegoo/main.go +++ b/car/elegoo/main.go @@ -7,7 +7,6 @@ import ( "bufio" "io" "log" - "time" "github.com/dim13/cobs" "github.com/golang/protobuf/proto" @@ -51,12 +50,7 @@ func main() { go func() { cmd := &Command{} - for i := -45; i < 45; i += 5 { - cmd.TurnHead = int32(i) - Write(s, cmd) - time.Sleep(time.Second / 2) - } - cmd.TurnHead = 0 + cmd.Trim = -10 cmd.Center = true Write(s, cmd) -- cgit v1.2.3