gobot.io/x/gobot@v1.16.0/platforms/parrot/bebop/bebop_driver.go (about) 1 package bebop 2 3 import ( 4 "gobot.io/x/gobot" 5 ) 6 7 const ( 8 // Flying event 9 Flying = "flying" 10 ) 11 12 // Driver is gobot.Driver representation for the Bebop 13 type Driver struct { 14 name string 15 connection gobot.Connection 16 gobot.Eventer 17 } 18 19 // NewDriver creates an Bebop Driver. 20 func NewDriver(connection *Adaptor) *Driver { 21 d := &Driver{ 22 name: gobot.DefaultName("Bebop"), 23 connection: connection, 24 Eventer: gobot.NewEventer(), 25 } 26 d.AddEvent(Flying) 27 return d 28 } 29 30 // Name returns the Bebop Drivers Name 31 func (a *Driver) Name() string { return a.name } 32 33 // SetName sets the Bebop Drivers Name 34 func (a *Driver) SetName(n string) { a.name = n } 35 36 // Connection returns the Bebop Drivers Connection 37 func (a *Driver) Connection() gobot.Connection { return a.connection } 38 39 // adaptor returns ardrone adaptor 40 func (a *Driver) adaptor() *Adaptor { 41 return a.Connection().(*Adaptor) 42 } 43 44 // Start starts the Bebop Driver 45 func (a *Driver) Start() (err error) { 46 return 47 } 48 49 // Halt halts the Bebop Driver 50 func (a *Driver) Halt() (err error) { 51 return 52 } 53 54 // TakeOff makes the drone start flying 55 func (a *Driver) TakeOff() { 56 a.Publish(a.Event("flying"), a.adaptor().drone.TakeOff()) 57 } 58 59 // Land causes the drone to land 60 func (a *Driver) Land() { 61 a.adaptor().drone.Land() 62 } 63 64 // Up makes the drone gain altitude. 65 // speed can be a value from `0` to `100`. 66 func (a *Driver) Up(speed int) { 67 a.adaptor().drone.Up(speed) 68 } 69 70 // Down makes the drone reduce altitude. 71 // speed can be a value from `0` to `100`. 72 func (a *Driver) Down(speed int) { 73 a.adaptor().drone.Down(speed) 74 } 75 76 // Left causes the drone to bank to the left, controls the roll, which is 77 // a horizontal movement using the camera as a reference point. 78 // speed can be a value from `0` to `100`. 79 func (a *Driver) Left(speed int) { 80 a.adaptor().drone.Left(speed) 81 } 82 83 // Right causes the drone to bank to the right, controls the roll, which is 84 // a horizontal movement using the camera as a reference point. 85 // speed can be a value from `0` to `100`. 86 func (a *Driver) Right(speed int) { 87 a.adaptor().drone.Right(speed) 88 } 89 90 // Forward causes the drone go forward, controls the pitch. 91 // speed can be a value from `0` to `100`. 92 func (a *Driver) Forward(speed int) { 93 a.adaptor().drone.Forward(speed) 94 } 95 96 // Backward causes the drone go forward, controls the pitch. 97 // speed can be a value from `0` to `100`. 98 func (a *Driver) Backward(speed int) { 99 a.adaptor().drone.Backward(speed) 100 } 101 102 // Clockwise causes the drone to spin in clockwise direction 103 // speed can be a value from `0` to `100`. 104 func (a *Driver) Clockwise(speed int) { 105 a.adaptor().drone.Clockwise(speed) 106 } 107 108 // CounterClockwise the drone to spin in counter clockwise direction 109 // speed can be a value from `0` to `100`. 110 func (a *Driver) CounterClockwise(speed int) { 111 a.adaptor().drone.CounterClockwise(speed) 112 } 113 114 // Stop makes the drone to hover in place. 115 func (a *Driver) Stop() { 116 a.adaptor().drone.Stop() 117 } 118 119 // Video returns a channel which raw video frames will be broadcast on 120 func (a *Driver) Video() chan []byte { 121 return a.adaptor().drone.Video() 122 } 123 124 // StartRecording starts the recording video to the drones interal storage 125 func (a *Driver) StartRecording() error { 126 return a.adaptor().drone.StartRecording() 127 } 128 129 // StopRecording stops a previously started recording 130 func (a *Driver) StopRecording() error { 131 return a.adaptor().drone.StopRecording() 132 } 133 134 // HullProtection tells the drone if the hull/prop protectors are attached. This is needed to adjust flight characteristics of the Bebop. 135 func (a *Driver) HullProtection(protect bool) error { 136 return a.adaptor().drone.HullProtection(protect) 137 } 138 139 // Outdoor tells the drone if flying Outdoor or not. This is needed to adjust flight characteristics of the Bebop. 140 func (a *Driver) Outdoor(outdoor bool) error { 141 return a.adaptor().drone.Outdoor(outdoor) 142 } 143 144 // VideoEnable tells the drone to start/stop streaming video 145 func (a *Driver) VideoEnable(enable bool) error { 146 return a.adaptor().drone.VideoEnable(enable) 147 } 148 149 // VideoStreamMode tells the drone what mode to use for streaming video 150 func (a *Driver) VideoStreamMode(mode int8) error { 151 return a.adaptor().drone.VideoStreamMode(mode) 152 }