Closed NielsTalens closed 10 years ago
Hi @NielsTalens,
We will take a look into this, have you tried printing the contents of:
console.log(curentLocation[0]) console.log(curentLocation[1])
Regards,
Hi @edgarSilva,
Both result in "undefined".
Regards,
@NielsTalens I will check it out as soon as I'm back home and have a sphero available, which might be in a couple of weeks. I will keep you posted.
Perhaps @stewart can look into this sooner?
@NielsTalens Turns out the GetLocator does not work at all in the API with node-serialport. But we've implemented this functionality with an event called locator
that is activated the same way as collision detection. Here is an example:
https://github.com/hybridgroup/cylon-sphero/blob/master/examples/locator/locator.js
There is no release of this yet, but you can use the repo to check it out:
my.sphero.on('locator', function(data) {
console.log("locator:");
console.log(data);
});
The param returned data
contains [y-dist, x-dist, accel, x-vel, y-vel], let me know if you need anything else or if you spot any weird behavior or issues.
Cool @edgarsilva thanks! I'm currently experimenting with this ;-)
I've faced the same issue. To make it clearer, perhaps readLocator could return any of:
I think it would also be useful to include this information in the docs. Thank you !
Hi @palmerabollo,
ReadLocator does not work, neither in sphero itself or spheron module, as explained above, the sphero API does not return anything.
That's why we have to use the events along with setDataStreamming and bitMasks to activate and obtain the information we want.
We'll continue to update the docs that are out of date, but in short reasLocator will never work.
I have some examples for this but I'm not at my computer right now, I will add the example to the docs site and also paste here, then I'll update and remove the confusing info from the docs site tomorrow, thanks for the heads up.
Found an example on how to read the locator info from the sphero, maybe this will work for you.
https://github.com/hybridgroup/cylon-sphero/blob/master/examples/locator/locator.js
Yes, that example is great, thanks. But even in that case, there are some information you can't get with the locator, such as the sphero heading. Is it possible to get the current heading?
Yes you just need to pass that to the setDataStreamming, chech the sphero API or cylon-sphero adaptor for a full list of possible values, there's another setDataStreamming example there.
Thanks Edgar. I am not sure. This is what I get using all the datasources (except 'motorsPWM', 'motorsIMF' and 'quaternion'):
my.sphero.configureLocator(0, 0, 0, 0);
var datasources = ['locator', 'accelOne', 'velocity', 'gyroscope', 'accelerometer', 'imu'];
my.sphero.setDataStreaming(datasources, opts);
my.sphero.on('data', function ondata(data) {
console.log('data', data);
// output example [ 2, -5, -1, -445, -143, 4105, 3, 3, 0, 0, 5, 100, 0, 0 ]
});
The heading is provided by the 'imu' datasource, but my.sphero.setHeading(90)
doesn't move the backLED. The only method that worked for me was my.shpero.roll(speed, heading)
, but in this case the heading
is relative to the current heading and it is not persistent (the sphero gets back to heading=0 after rolling).
I can move this question to stackoverflow if you don't want to ruin this issue.
Let me go through the sphero API and check the commands and values we are sending. You should be able to change the heading.
I'll update here once I know more about the problem.
@palmerabollo I don't think setHeading does what you think it does. If you want the sphero to keep pointing forward when you roll the sphero and the LED to adjust check the calibrate method and this examples:
https://github.com/hybridgroup/cylon-sphero#how-to-calibrate-sphero https://gist.github.com/zankich/04be4e3468e74ab54c6c
In the example the tailLED moves to set the direction the sphero is heading.
Let me know if this works for you.
@palmerabollo regarding the stackoverflow thing go ahead and do either that or open a new issue for cylon-sphero, since this is getting out of scope of this issue.
Let me know how it goes.
I'm trying to get the location of the Sphero by using readLocator(). I can't seem to get a proper return.
I tried the following to try and find out what is returned by readLocator:
Which results in:
Any ideas on how to get the positions returned from readLocator?