From: Pablo R. <ri...@cs...> - 2006-06-20 23:52:58
|
hi, I am developing some drivers for Player to read various devices (speed controllers, sonar array, compass, gps,) over serial. No Player drivers exist for our particular devices as of now. I used the example driver code in "player-1.6.5/examples/plugins/exampledriver" to start writing my sonar array driver. For now I just start player: $ player pingsonar.cfg & Then run a client to read data using a SonarProxy: $ ./controller Everything goes fine, except that the client does not get data from the Proxy: --------------------------- $ player pingsonar.cfg & ** Player v1.6.5 ** * Part of the Player/Stage Project [http://playerstage.sourceforge.net]. * Copyright 2000-2005 Brian Gerkey, Richard Vaughan, Andrew Howard, * Nate Koenig and contributors. * Released under the GNU General Public License. Startup options: [TCP] Parsing configuration file "pingsonar.cfg" trying to load /home/rivera/Desktop/player/ping_sonar2/./pingsonar.so...success invoking player_driver_init()...PingSonar initializing PingSonar initialization done success Using device table: ------------------------------------------------------------ driver pingsonar provides 6665:sonar:0 ------------------------------------------------------------ listening on ports: 6665 $ ./controller ** Player [port 6665] client accepted from 127.0.0.1 on socket 7 ** PingSonar driver initialising Using /dev/ttyS0 as serial port for pings PingSonar driver ready sonar : 0 sonar : 0 sonar : 0 --------------------------- For now I am not having the driver actually open the serial port or read from it, it just generates a random integer and stores it in data.ranges[0] (data is a player_sonar_data_t). The client does a robot.Read() and attempts to read sp.ranges[0] (sp is the SonarProxy) but only gets "0" every time. Here is my code: --------------------------- char host[32] = "localhost"; int port = PLAYER_PORTNUM; int device_index = 0; int main(int argc, char **argv){ PlayerClient robot(host, port); robot.SetDataMode(PLAYER_DATAMODE_PULL_ALL); SonarProxy sp(&robot, device_index, 'r'); for (;;){ robot.RequestData(); robot.Read(); printf("sonar : %d\n", (int)sp.ranges[0]); sleep(1); } return 0; } --------------------------- /////////////////////////////////////////////////////////////// // Main function for device thread void PingSonar::Main() { struct timeval time; // The main loop; interact with the device here for(;;){ // test if we are supposed to cancel pthread_testcancel(); // Check for and handle configuration requests, using Driver::GetConfig() // Check for and execute commands, using Driver::GetCommand() // read newest data data.ranges[0] = htons((unsigned short)(rand() % 100)); // Interact with the device, and push out the resulting data, using // Driver::PutData() GlobalTime->GetTime(&time); PutData((void*)&(this->data), sizeof(this->data), &time); usleep(1000); } return; } --------------------------- # Instantiate the example driver, which supports the sonar interface driver ( name "pingsonar" plugin "pingsonar.so" provides ["sonar:0"] port "/dev/ttyS0" ) --------------------------- I have looked through code for other drivers and cannot figure out what I am doing wrong. (it's probably something obvious,..) Any ideas? thanks, Pablo Rivera Grad CS at University of Nevada, Reno |
From: Toby C. <tco...@pl...> - 2006-06-21 03:29:29
|
Hi, Unless you have reasons otherwise I would strongly recommend developing new drivers for player 2.0.2. If you have to stick with 1.6.5 then what you have looks okay, so you will have to look deeper in your code. Are you setting the number of sonar readings int he data structure, this is not in your code as attached and could be an issue. Also for the client try using playerprint that way you only have one end of the connection to debug, Toby Pablo Rivera wrote: > hi, > I am developing some drivers for Player to read various devices (speed > controllers, sonar array, compass, gps,) over serial. No Player drivers > exist for our particular devices as of now. I used the example driver code in > "player-1.6.5/examples/plugins/exampledriver" to start writing my sonar > array driver. For now I just start player: > > $ player pingsonar.cfg & > > Then run a client to read data using a SonarProxy: > > $ ./controller > > Everything goes fine, except that the client does not get data from > the Proxy: > --------------------------- > $ player pingsonar.cfg & > > ** Player v1.6.5 ** > * Part of the Player/Stage Project [http://playerstage.sourceforge.net]. > * Copyright 2000-2005 Brian Gerkey, Richard Vaughan, Andrew Howard, > * Nate Koenig and contributors. > * Released under the GNU General Public License. > Startup options: [TCP] > > Parsing configuration file "pingsonar.cfg" > trying to load > /home/rivera/Desktop/player/ping_sonar2/./pingsonar.so...success > invoking player_driver_init()...PingSonar initializing > PingSonar initialization done > success > Using device table: > ------------------------------------------------------------ > driver pingsonar provides 6665:sonar:0 > ------------------------------------------------------------ > listening on ports: 6665 > > $ ./controller > ** Player [port 6665] client accepted from 127.0.0.1 on socket 7 ** > PingSonar driver initialising > Using /dev/ttyS0 as serial port for pings > PingSonar driver ready > sonar : 0 > sonar : 0 > sonar : 0 > --------------------------- > > For now I am not having the driver actually open the serial port or read > from it, it just generates a random integer and stores it in > data.ranges[0] (data is a player_sonar_data_t). The client does a > robot.Read() and attempts to read sp.ranges[0] (sp is the SonarProxy) but > only gets "0" every time. Here is my code: > > --------------------------- > > char host[32] = "localhost"; > int port = PLAYER_PORTNUM; > int device_index = 0; > > int main(int argc, char **argv){ > PlayerClient robot(host, port); > robot.SetDataMode(PLAYER_DATAMODE_PULL_ALL); > SonarProxy sp(&robot, device_index, 'r'); > > for (;;){ > robot.RequestData(); > robot.Read(); > printf("sonar : %d\n", (int)sp.ranges[0]); > sleep(1); > } > return 0; > } > > --------------------------- > > /////////////////////////////////////////////////////////////// > // Main function for device thread > void PingSonar::Main() { > struct timeval time; > > // The main loop; interact with the device here > for(;;){ > // test if we are supposed to cancel > pthread_testcancel(); > > // Check for and handle configuration requests, using > Driver::GetConfig() > // Check for and execute commands, using Driver::GetCommand() > > // read newest data > data.ranges[0] = htons((unsigned short)(rand() % 100)); > > // Interact with the device, and push out the resulting data, using > // Driver::PutData() > GlobalTime->GetTime(&time); > PutData((void*)&(this->data), sizeof(this->data), &time); > > usleep(1000); > } > return; > } > > --------------------------- > > # Instantiate the example driver, which supports the sonar interface > > driver > ( > name "pingsonar" > plugin "pingsonar.so" > provides ["sonar:0"] > port "/dev/ttyS0" > ) > > --------------------------- > > I have looked through code for other drivers and cannot figure out what I > am doing wrong. (it's probably something obvious,..) Any ideas? > > thanks, > Pablo Rivera > Grad CS at University of Nevada, Reno > > > _______________________________________________ > Playerstage-developers mailing list > Pla...@li... > https://lists.sourceforge.net/lists/listinfo/playerstage-developers > |