#include <stdio.h>
#include <libplayerc/playerc.h>

int main(int argc, const char **argv)
{
  playerc_client_t *client;
	playerc_position2d_t *position2d;
  playerc_laser_t *laser;
  playerc_sonar_t *sonar;

// Conecta ao servidor
  client = playerc_client_create(NULL, "localhost", 6665);
  if (playerc_client_connect(client) != 0)
    return -1;

// Conecta ao position (comando e odometria)
  position2d = playerc_position2d_create(client, 1);
  if (playerc_position2d_subscribe(position2d, PLAYERC_OPEN_MODE) != 0)  return -1;

// Conecta ao laser
  laser = playerc_laser_create(client, 0);
  if (playerc_laser_subscribe(laser, PLAYERC_OPEN_MODE))
    return -1;

// Configura parametros do player
if (playerc_client_datamode (client, PLAYERC_DATAMODE_PULL) != 0)
{
  fprintf(stderr, "error: %s\n", playerc_error_str());
  return -1;
}

if (playerc_client_set_replace_rule (client, -1, -1, PLAYER_MSGTYPE_DATA, -1, 1) != 0)
{
  fprintf(stderr, "error: %s\n", playerc_error_str());
  return -1;
}

// Ativa os motores do robo
	playerc_position2d_enable(position2d, 1);
	
// ******************** Comandos para o robô **************************8








// ******************** Fim Comandos para o robô **************************8


  playerc_laser_unsubscribe(laser);
  playerc_laser_destroy(laser);
  playerc_position2d_unsubscribe(position2d);
  playerc_position2d_destroy(position2d);
  playerc_client_disconnect(client);
  playerc_client_destroy(client);

  return 0;
}
