Comments (5)
@tangsoft thank's for reporting the issue, I'll look into it
from gobot.
@tangsoft I created this branch with a hotfix https://github.com/hybridgroup/gobot/tree/sphero_hotfix. Can you pull the code a test that it works for you?
Sometimes the sphero takes too long to respond, or the packet it sends back is incomplete. If that is the case I will now return an empty array, but if the packet is well formed you will get an array with the three RGB values.
Here's the output from my local test
2014/07/25 09:12:18 Initializing Robot sphero ...
2014/07/25 09:12:18 Initializing connections...
2014/07/25 09:12:18 Initializing connection Sphero ...
2014/07/25 09:12:18 Initializing devices...
2014/07/25 09:12:18 Initializing device sphero ...
2014/07/25 09:12:18 Starting Robot sphero ...
2014/07/25 09:12:18 Starting connections...
2014/07/25 09:12:18 Starting connection Sphero on port /dev/rfcomm0...
2014/07/25 09:12:18 Starting devices...
2014/07/25 09:12:18 Starting device sphero...
2014/07/25 09:12:18 Starting work...
spheroDriver.SetRGB(153, 61, 202)
spheroDriver.GetRGB() [153 61 202]
spheroDriver.SetRGB(45, 18, 187)
spheroDriver.GetRGB() [45 18 187]
spheroDriver.SetRGB(103, 214, 72)
spheroDriver.GetRGB() [103 214 72]
spheroDriver.SetRGB(215, 63, 139)
from gobot.
@zankich thanks, it works now.
additionally, i have to wait about half a second before sending a request to sphero like this, especially when you want send several requests sequentially:
time.Sleep(500 * time.Millisecond)
by the way, is there any plan you guys will implement a full set of sphero API 1.5?
at the same time, i have a suggestion, since there are more than one DID, shall we have one more parameter pass to craftPacket func? for example when I want to get power state, i have to send request virtual device 0x00, not 0x02.
func (s *SpheroDriver) GetPowerState() []uint8 {
189 return s.getSyncResponse(s.craftPacket([]uint8{}, 0x00, 0x20))
190 }
func (s *SpheroDriver) craftPacket(body []uint8, did byte, cid byte) *packet {
249 packet := new(packet)
250 packet.body = body
251 dlen := len(packet.body) + 1
252 packet.header = []uint8{0xFF, 0xFF, did, cid, s.seq, uint8(dlen)}
253 packet.checksum = s.calculateChecksum(packet)
254 return packet
2014/07/26 10:46:10 Starting work...
ChassisID is [255 255 0 1 3 0 4 247]
Current DeviceMode is [255 255 0 2 2 1 250]
Versioning is [255 255 0 3 9 1 3 1 3 59 51 23 6 96]
PowerState is [255 255 0 4 9 1 2 3 33 0 43 6 63 91]
2014/07/26 10:46:22 Sphero Changing Direction 306
GetRGB is [244 2 197]
SetRGB is 37 196 9
PowerState is [255 255 0 8 9 1 2 3 28 0 43 6 73 82]
2014/07/26 10:46:32 Sphero Changing Direction 69
GetRGB is [37 196 9]
SetRGB is 47 163 34
from gobot.
@tangsoft Yes it takes the sphero about half of a second to respond to your request, so you may not be able to request information from the sphero at the speed that you want.
We do plan on implementing more of the sphero API, and pull requests are graciously accepted! So if you've implemented more of the API, you're more than welcome to submit a pull request to the dev branch and we'll get it merged in.
I will merge this hotfix into the master branch and cut a new release.
from gobot.
@zankich cool. let me close this case at first.
from gobot.
Related Issues (20)
- roadmap(i2c): MMA8452 3-Axial Accelerometer
- roadmap(I2C): VCNL4010 distance/light sensor module
- roadmap(1-wire): add support for 1-wire protocol HOT 1
- roadmap(serial): create a common serial adaptor HOT 1
- roadmap(ble): implement support for more peripherals HOT 2
- Support for Sphero BOLT HOT 3
- adafruit_driver.go contains shared variables and init() HOT 1
- avoid master/slave terminology HOT 1
- code and test contains data race HOT 2
- PCA9685 wrong initialisation HOT 2
- golangci-lint v1.55.2 is there HOT 1
- raspi with gpio.servo not work (like expected) HOT 1
- HX711 Support HOT 2
- Go 1.22 is released
- Write pwm export() failed for id xx "with open gpiochip0" HOT 4
- Stepper over MCP23017
- Stepper driver DRV8825 HOT 1
- Drones
- [SPI] Do you have any plan to add Waveshare LCD Driver?
- Xbox_360_controller golang driver
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gobot.