2024-02-05 01:50:43 +08:00
|
|
|
package sphero
|
|
|
|
|
|
|
|
import (
|
|
|
|
"gobot.io/x/gobot/v2"
|
2024-02-11 01:02:09 +08:00
|
|
|
"gobot.io/x/gobot/v2/drivers/ble"
|
2024-02-05 01:50:43 +08:00
|
|
|
"gobot.io/x/gobot/v2/drivers/common/sphero"
|
|
|
|
)
|
|
|
|
|
|
|
|
// BB8Driver represents a Sphero BB-8
|
|
|
|
type BB8Driver struct {
|
|
|
|
*OllieDriver
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewBB8Driver creates a driver for a Sphero BB-8
|
2024-02-11 01:02:09 +08:00
|
|
|
func NewBB8Driver(a gobot.BLEConnector, opts ...ble.OptionApplier) *BB8Driver {
|
|
|
|
return &BB8Driver{OllieDriver: newOllieBaseDriver(a, "BB8", bb8DefaultCollisionConfig(), opts...)}
|
2024-02-05 01:50:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// bb8DefaultCollisionConfig returns a CollisionConfig with sensible collision defaults
|
|
|
|
func bb8DefaultCollisionConfig() sphero.CollisionConfig {
|
|
|
|
return sphero.CollisionConfig{
|
|
|
|
Method: 0x01,
|
|
|
|
Xt: 0x20,
|
|
|
|
Yt: 0x20,
|
|
|
|
Xs: 0x20,
|
|
|
|
Ys: 0x20,
|
|
|
|
Dead: 0x01,
|
|
|
|
}
|
|
|
|
}
|