Giter Site home page Giter Site logo

Comments (5)

zankich avatar zankich commented on May 13, 2024

@tangsoft thank's for reporting the issue, I'll look into it

from gobot.

zankich avatar zankich commented on May 13, 2024

@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.

tangsoft avatar tangsoft commented on May 13, 2024

@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.

zankich avatar zankich commented on May 13, 2024

@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.

tangsoft avatar tangsoft commented on May 13, 2024

@zankich cool. let me close this case at first.

from gobot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.