Re: Indexing an interface, a possible bug ?
"Rich Mattes" <[email protected]>
| Newsgroups | gmane.science.robotics.playerstage |
|---|---|
| Message-ID | <000901cb1790$76170260$62450720$@com> |
You could try using keys: I.e. have a Requires line in the config file like
requires ["laser0:::laser:0" "laser1:::laser:5"]
and then when you read the device addr you do something like:
for (int i<0; i<NumLasers; i++)
{
char device_key[16];
sprintf(device_key, "laser%d",i);
cf->ReadDeviceAddr(&this->laser_addr[i], section, "requires",
PLAYER_LASER_CODE,-1, device_key)
// the rest of the device reading stuff
}
I took this approach when I wrote a driver that merges the laser readings
from two separate lasers into one laser device. I had the same issue in
trying to subscribe to two separate lasers, this is the method that worked
the best for me.
In order to maintain compatibility for people that have been using mricp for
a while with one laser, it might also be good to check for a laser without a
key if numLasers == 1, so people don't have to add the laser0::: key to
their config files.
Rich
From: Tarek Taha [mailto:[email protected]]
Sent: Tuesday, June 29, 2010 6:52 AM
To: [email protected]
Subject: [Playerstage-developers] Indexing an interface, a possible bug ?
Hi all,
I am trying to fix a bug in the MRICP driver. This driver allows the usage
of multiple lasers, previously using the "ReadDeviceAddr" I was able to
index the interface directly using "ReadDeviceId" which is now depreciated.
Some of the users highlighted that recently the multi laser support doesn't
work as it uses the same interface multiple times. In my driver I loop
"number of laser" times to load any laser interface using this :
cf->ReadDeviceAddr(&this->laser_addr[i], section, "requires",
PLAYER_LASER_CODE,-1, NULL). This however seems to load the same interface
"the first listed in the tuple" multiple times (verified by printing the
actual address and geom properties). I tried to use the previous method by
indexing the interface directly using :
cf->ReadDeviceAddr(&this->laser_addr[i], section, "requires",
PLAYER_LASER_CODE,i, NULL) but the file configuration parser fails to load
correctly.
I then tried to trace the problem by debugging the configfile.cpp. This
section :
// Match the tuple index (< 0 matches all indices)
if (index >= 0 && i != index)
continue;
didn't make much of a senses, the if statement I think should be if (index
>= 0 && ind != index), but changing that breaks a lot of interface loading
in other drivers. I am puzzled at the moment, anyone can point me to a
solution that doesn't require major hacking of the player core ? Or is it a
bug in loading an interface by index perhaps ?
Regards,
Tarek
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Playerstage-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-developers