Hi, I'm using Player 2.0.5 and Stage 2.0.4. I'm newbie of Player and I need some helps.

I want to use wavefront and vfh algorithm with my own
driver for localization (instead of amcl). So, first of all, I want to write a driver that gives some
pose value to wavefront driver only for testing that all works.
I run player on my cfg file then I run playernav, and I have this message
     playerc error   : got NACK from request
     playerc error   : failed to get response
Some advice?
This is my cfg file:
 
************ wavefront.cfg ***************
driver
(
  name "stage"
  plugin "libstageplugin"
  provides ["6665:simulation:0"]
  worldfile "simple.world"
)

driver
(
  name "stage"
  provides ["6665:map:0"]
  model "cave"
)

driver
(
  name "stage"
  provides ["6665:position2d:0" "6665:sonar:0"]
  model "robot1"
)

driver
(
  name "vfh"
  provides ["6665:position2d:1"]
  requires ["6665:position2d:0" "6665:sonar:0"]
  distance_epsilon 0.3
  angle_epsilon 5
)

#driver
#(
#  name "amcl"
#  provides ["6665:localize:0" "6665:position2d:2"]
#  requires ["odometry::6665:position2d:0" "6665:laser:0" "sonar::6665:map:0"]
#)

driver
(
    name       "LocalizationDriver"
    plugin     "LocalizationDriver.so"
    provides   ["6665:position2d:2"]
    start_point [0 0 0]
    alwayson    1
)

driver
(
  name "wavefront"
  provides ["6665:planner:0"]
  requires ["output::6665:position2d:1" "input::6665:position2d:2" "6665:map:0"]
  safety_dist 0.15
  distance_epsilon 0.5
  angle_epsilon 10
  alwayson 0
)
**************************************************
And this is the simple C++ code

********* LocalizationDriver.cc ********************
#include <unistd.h>
#include <string.h>

#include <libplayercore/playercore.h>

////////////////////////////////////////////////////////////////////////////////
// The class for the driver
class LocalizationDriver : public Driver
{
  public:
   
    // Constructor; need that
    LocalizationDriver(ConfigFile* cf, int section);

    // Must implement the following methods.
    virtual int Setup();
    virtual int Shutdown();

    // This method will be invoked on each incoming message
    virtual int ProcessMessage(MessageQueue* resp_queue,
                               player_msghdr * hdr,
                               void * data);

  private:

    // Main function for device thread.
    virtual void Main();

    player_pose_t start_point;
};

Driver* LocalizationDriver_Init(ConfigFile* cf, int section)
{
  // Create and return a new instance of this driver
  return((Driver*)(new LocalizationDriver(cf, section)));
}

void LocalizationDriver_Register(DriverTable* table)
{
  table->AddDriver("LocalizationDriver", LocalizationDriver_Init);
}

////////////////////////////////////////////////////////////////////////////////
// Constructor.  Retrieve options from the configuration file and do any
// pre-Setup() setup.
LocalizationDriver::LocalizationDriver(ConfigFile* cf, int section)
    : Driver(cf, section, false, PLAYER_MSGQUEUE_DEFAULT_MAXLEN,
             PLAYER_POSITION2D_CODE)
{
  // Read an option from the configuration file
  this->start_point.px = cf->ReadInt(section, "start_point", 0);
  this->start_point.py = cf->ReadInt(section, "start_point", 1);
  this->start_point.pa = cf->ReadInt(section, "start_point", 2);

  return;
}

////////////////////////////////////////////////////////////////////////////////
// Set up the device.  Return 0 if things go well, and -1 otherwise.
int LocalizationDriver::Setup()
{  
  puts("Example driver initialising");

  // Here you do whatever is necessary to setup the device, like open and
  // configure a serial port.

  //printf("Was foo option given in config file? %d\n", this->foop);
   
  puts("Example driver ready");

  // Start the device thread; spawns a new thread and executes
  // LocalizationDriver::Main(), which contains the main loop for the driver.
  StartThread();

  return(0);
}


////////////////////////////////////////////////////////////////////////////////
// Shutdown the device
int LocalizationDriver::Shutdown()
{
  puts("Shutting example driver down");

  // Stop and join the driver thread
  StopThread();

  puts("Example driver has been shutdown");

  return(0);
}

int LocalizationDriver::ProcessMessage(MessageQueue* resp_queue,
                                  player_msghdr * hdr,
                                  void * data)
{
  // Process messages here.  Send a response if necessary, using Publish().
  // If you handle the message successfully, return 0.  Otherwise,
  // return -1, and a NACK will be sent for you, if a response is required.
 
  return(0);
}



////////////////////////////////////////////////////////////////////////////////
// Main function for device thread
void LocalizationDriver::Main()
{
  // The main loop; interact with the device here
  for(;;)
  {
    // test if we are supposed to cancel
    pthread_testcancel();

    // Process incoming messages.  LocalizationDriver::ProcessMessage() is
    // called on each message.
    ProcessMessages();

    // Interact with the device, and push out the resulting data, using
    Driver::Publish(device_addr, NULL,
                PLAYER_MSGTYPE_DATA,
                PLAYER_POSITION2D_DATA_STATE,
                (void*)&start_point,sizeof(start_point),NULL);
   
  }
}

////////////////////////////////////////////////////////////////////////////////
// Extra stuff for building a shared object.

/* need the extern to avoid C++ name-mangling  */
extern "C" {
  int player_driver_init(DriverTable* table)
  {
    puts("Example driver initializing");
    LocalizationDriver_Register(table);
    puts("Example driver done");
    return(0);
  }
}

**********************************************
And this is what I have:
_______________________________________________________

ale@ale-laptop:~/test_Wavefront$ player wavefront.cfg
Player v.2.0.5

* Part of the Player/Stage/Gazebo Project [http://playerstage.sourceforge.net].
* Copyright (C) 2000 - 2006 Brian Gerkey, Richard Vaughan, Andrew Howard,
* Nate Koenig, and contributors. Released under the GNU General Public License.
* Player comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
* are welcome to redistribute it under certain conditions; see COPYING
* for details.

trying to load /home/ale/test_Wavefront/./libstageplugin...
trying to load /usr/local/lib/libstageplugin...
success
invoking player_driver_init()...
 Stage driver plugin init

 ** Stage plugin v2.0.4 **
 * Part of the Player/Stage Project [http://playerstage.sourceforge.net]
 * Copyright 2000-2006 Richard Vaughan, Andrew Howard, Brian Gerkey
 * and contributors. Released under the GNU General Public License v2.
success
  Stage driver creating 1 device
   6665.31.0 is a Stage world [Loading ./simple.world][Include pioneer.inc][Include map.inc]

  Stage driver creating 1 device
   6665.42.0 is "cave"
  Stage driver creating 2 devices
   6665.4.0 is "robot1"
   6665.5.0 is "robot1.ranger:0"
trying to load /home/ale/test_Wavefront/./LocalizationDriver.so...
success
invoking player_driver_init()...
Example driver initializing
Example driver done
success
wavefront.cfg:49 warning: field [start_point] has unused element 1
wavefront.cfg:49 warning: field [start_point] has unused element 2
Listening on ports: 6665
accepted client 0 on port 6665, fd 9
warn: model cave has no startup function registered (TODO: remove this warning before release) (model.c stg_model_startup)
warning : skipping subscription to unknown device 25:0
warn: Stage ignores motor power state (1) (p_position.cc ProcessMessage)
Wavefront: Loading map from map:0...
Stage: device "cave" received map info request
Stage: creating map for model "cave" of 159 by 159 cells at res 0.10
Stage computing map tile (0,0)(159,159)... done.
Done.
Example driver initialising
Example driver ready
Stage: device "cave" received map info request
Stage: creating map for model "cave" of 159 by 159 cells at res 0.10
Stage computing map tile (0,0)(159,159)... done.
__________________________________________________________________________________

ale@ale-laptop:~/test_Wavefront$ playernav
calling connect
done
playerc error   : got NACK from request
playerc error   : failed to get response
Warning: Failed to subscribe to localize on robot 0; you won't be able to set its pose.
requesting map
done
__________________________________________________________________________________


Thanks!

Rastaxe