aboutsummaryrefslogtreecommitdiff
path: root/car/elegoo
diff options
context:
space:
mode:
Diffstat (limited to 'car/elegoo')
-rw-r--r--car/elegoo/elegoo.pb.go44
-rw-r--r--car/elegoo/elegoo.proto15
-rw-r--r--car/elegoo/main.go24
3 files changed, 35 insertions, 48 deletions
diff --git a/car/elegoo/elegoo.pb.go b/car/elegoo/elegoo.pb.go
index f453f44..3a367e0 100644
--- a/car/elegoo/elegoo.pb.go
+++ b/car/elegoo/elegoo.pb.go
@@ -32,9 +32,8 @@ 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"`
- Center bool `protobuf:"varint,4,opt,name=Center" json:"Center,omitempty"`
- Direction int32 `protobuf:"zigzag32,5,opt,name=Direction" json:"Direction,omitempty"`
- StopAfter uint32 `protobuf:"varint,6,opt,name=StopAfter" json:"StopAfter,omitempty"`
+ Direction uint32 `protobuf:"varint,4,opt,name=Direction" json:"Direction,omitempty"`
+ StopAfter uint32 `protobuf:"varint,5,opt,name=StopAfter" json:"StopAfter,omitempty"`
}
func (m *Command) Reset() { *m = Command{} }
@@ -63,14 +62,7 @@ func (m *Command) GetStop() bool {
return false
}
-func (m *Command) GetCenter() bool {
- if m != nil {
- return m.Center
- }
- return false
-}
-
-func (m *Command) GetDirection() int32 {
+func (m *Command) GetDirection() uint32 {
if m != nil {
return m.Direction
}
@@ -156,20 +148,20 @@ func init() {
func init() { proto.RegisterFile("elegoo.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
- // 240 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0xb1, 0x4e, 0xc3, 0x30,
- 0x10, 0x86, 0xe5, 0x12, 0x9c, 0x72, 0xa2, 0x03, 0x1e, 0x90, 0x85, 0x18, 0xa2, 0x4e, 0x99, 0x58,
+ // 234 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x90, 0xb1, 0x4e, 0xc3, 0x30,
+ 0x10, 0x86, 0x65, 0x08, 0x4e, 0x39, 0xd1, 0x01, 0x0f, 0xe8, 0x84, 0x18, 0xa2, 0x4e, 0x99, 0x58,
0x78, 0x02, 0x48, 0x99, 0xc8, 0x80, 0x1c, 0x26, 0xb6, 0xd0, 0x1e, 0xc8, 0x12, 0xf1, 0x45, 0xb6,
- 0x85, 0xc4, 0xe3, 0xf0, 0x26, 0x3c, 0x1a, 0xf2, 0xc9, 0x49, 0xa0, 0x9b, 0xff, 0xef, 0xcf, 0xe5,
- 0x3e, 0x1d, 0x9c, 0xe3, 0x07, 0xbe, 0x13, 0xdd, 0x8c, 0x9e, 0x22, 0x6d, 0xbf, 0x05, 0x94, 0x0d,
- 0x0d, 0x43, 0xef, 0x0e, 0xea, 0x12, 0x64, 0x37, 0x22, 0x1e, 0x8c, 0x16, 0x95, 0xa8, 0x2f, 0x4c,
- 0x4e, 0x33, 0x6f, 0xf5, 0xea, 0x0f, 0x6f, 0x95, 0x82, 0xa2, 0x8b, 0x34, 0xea, 0x93, 0x4a, 0xd4,
- 0x6b, 0xc3, 0xef, 0xf4, 0x6d, 0x83, 0x2e, 0xa2, 0xd7, 0x05, 0xd3, 0x9c, 0xd4, 0x35, 0x9c, 0xed,
- 0xac, 0xc7, 0x7d, 0xb4, 0xe4, 0xf4, 0x29, 0xff, 0x66, 0x01, 0xa9, 0x4d, 0xd3, 0x77, 0x6f, 0x69,
- 0x50, 0x56, 0xa2, 0xde, 0x98, 0x05, 0x6c, 0x7f, 0x04, 0xc8, 0x87, 0x4f, 0x74, 0x31, 0xa8, 0x2b,
- 0x58, 0xef, 0x6c, 0x88, 0xbd, 0xdb, 0x23, 0x4b, 0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, 0xdb, 0x1d, 0x25, 0x99, 0xb5,
+ 0xce, 0xf9, 0xff, 0x8a, 0xc9, 0x68, 0xb1, 0x02, 0xa1, 0xec, 0xc8, 0x7a, 0x76, 0xfa, 0xe0, 0x75,
+ 0x8c, 0x33, 0x69, 0x92, 0x58, 0x26, 0xcd, 0x4c, 0xda, 0x24, 0x95, 0x49, 0x1b, 0x3d, 0x9e, 0xe8,
+ 0xfb, 0xd9, 0x91, 0xf7, 0x28, 0x27, 0x8f, 0x63, 0x8e, 0xdf, 0x7f, 0x31, 0x03, 0x61, 0x99, 0xfa,
+ 0x34, 0x3f, 0xc8, 0xd7, 0x62, 0xe8, 0x8d, 0x7d, 0x93, 0xe9, 0xba, 0x77, 0x7f, 0x01, 0x00, 0x00,
+ 0xff, 0xff, 0x22, 0x73, 0x73, 0x8b, 0x6d, 0x01, 0x00, 0x00,
}
diff --git a/car/elegoo/elegoo.proto b/car/elegoo/elegoo.proto
index a25f592..7cfd826 100644
--- a/car/elegoo/elegoo.proto
+++ b/car/elegoo/elegoo.proto
@@ -5,20 +5,19 @@ syntax = "proto3";
option go_package = "main";
message Command {
- sint32 SpeedR = 1;
- sint32 SpeedL = 2;
+ sint32 SpeedR = 1; // -255 .. +255
+ sint32 SpeedL = 2; // -255 .. +255
bool Stop = 3;
- bool Center = 4;
- sint32 Direction = 5; // +90 left; -90 right
- uint32 StopAfter = 6; // milliseconds
+ uint32 Direction = 4; // deg: 0 right .. 180 left
+ uint32 StopAfter = 5; // milliseconds
}
message Events {
- uint32 Distance = 1;
- sint32 Direction = 2;
+ uint32 Distance = 1; // cm
+ sint32 Direction = 2; // deg
bool SensorR = 3;
bool SensorC = 4;
bool SensorL = 5;
uint32 KeyPress = 6;
- uint32 Time = 7;
+ uint32 Time = 7; // milliseconds
}
diff --git a/car/elegoo/main.go b/car/elegoo/main.go
index 46d3058..3d7fcde 100644
--- a/car/elegoo/main.go
+++ b/car/elegoo/main.go
@@ -39,9 +39,9 @@ func Read(buf *bufio.Reader, pb proto.Message) error {
func main() {
c := &serial.Config{
- //Name: "/dev/tty.usbmodem1421",
+ Name: "/dev/tty.usbmodem1421",
//Name: "/dev/tty.usbmodem1411",
- Name: "/dev/tty.Elegoo-DevB",
+ //Name: "/dev/tty.Elegoo-DevB",
Baud: 57600,
}
s, err := serial.OpenPort(c)
@@ -64,25 +64,20 @@ func main() {
}()
log.Println("send -45")
- time.Sleep(time.Second)
- Write(s, &Command{Direction: -45})
+ time.Sleep(3 * time.Second)
+ Write(s, &Command{Direction: 5})
log.Println("send +45")
- time.Sleep(time.Second)
- Write(s, &Command{Direction: 45})
-
- log.Println("send center")
- time.Sleep(time.Second)
- Write(s, &Command{Center: true})
+ time.Sleep(3 * time.Second)
+ Write(s, &Command{Direction: 175})
- log.Println("send -5")
- time.Sleep(time.Second)
- Write(s, &Command{Direction: -5})
+ log.Println("send +0")
+ time.Sleep(3 * time.Second)
+ Write(s, &Command{Direction: 90})
/* log.Println("send motor")
Write(s, &Command{SpeedL: 200, SpeedR: 200, StopAfter: 1000})
time.Sleep(time.Second)
- */
log.Println("send motor turn")
time.Sleep(time.Second)
@@ -91,6 +86,7 @@ func main() {
log.Println("send motor turn")
time.Sleep(time.Second)
Write(s, &Command{SpeedL: 250, SpeedR: -250, StopAfter: 500})
+ */
time.Sleep(time.Minute)