/*********************************************************
 *
 * This source code is part of the Carnegie Mellon Robot
 * Navigation Toolkit (CARMEN)
 *
 * CARMEN Copyright (c) 2002 Michael Montemerlo, Nicholas
 * Roy, and Sebastian Thrun
 *
 * CARMEN is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU General Public 
 * License as published by the Free Software Foundation; 
 * either version 2 of the License, or (at your option)
 * any later version.
 *
 * CARMEN is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied 
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more 
 * details.
 *
 * You should have received a copy of the GNU General 
 * Public License along with CARMEN; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place, 
 * Suite 330, Boston, MA  02111-1307 USA
 *
 ********************************************************/

/** @addtogroup robot librobot **/
// @{

/** 
 * \file robot_central.h 
 * \brief Library for robot.
 *
 * ...
 **/


#ifndef CARMEN_ROBOT_H
#define CARMEN_ROBOT_H

#include <carmen/base_messages.h>

#ifdef __cplusplus
extern "C" {
#endif

  // MAX_READINGS controls the number of odometry measurements we 
  // remember for interpolating position stamps.

  // Clock skew estimate is guaranteed only if sufficient odometry
  // is available, so ESTIMATES_CONVERGE is the amount of odometry
  // we need to estimate the clock skew

#define      CARMEN_ROBOT_MAX_READINGS         5
#define      CARMEN_ROBOT_ESTIMATES_CONVERGE   (CARMEN_ROBOT_MAX_READINGS+25)

#define      CARMEN_ROBOT_ALL_STOP             1
#define      CARMEN_ROBOT_ALLOW_ROTATE         2

#define      CARMEN_ROBOT_MIN_ALLOWED_VELOCITY 0.03 // cm/s

#define      CARMEN_ROBOT_ODOMETRY_AVERAGE     0
#define      CARMEN_ROBOT_FRONT_LASER_AVERAGE  1
#define      CARMEN_ROBOT_REAR_LASER_AVERAGE   2

#define      CARMEN_ROBOT_BUMPER_AVERAGE       3
#define      CARMEN_ROBOT_SONAR_AVERAGE        4

extern carmen_base_odometry_message carmen_robot_latest_odometry;
extern carmen_base_odometry_message carmen_robot_odometry[CARMEN_ROBOT_MAX_READINGS];
extern int carmen_robot_position_received;
extern int carmen_robot_converge;
extern carmen_robot_config_t carmen_robot_config;
extern char *carmen_robot_host;

extern double carmen_robot_collision_avoidance_frequency;
extern double carmen_robot_sensor_time_of_last_update;
  

double carmen_robot_get_fraction(double timestamp, double skew,
				 int *low, int *high);
int carmen_robot_get_skew(int msg_count, double *skew,
			  int data_type, char *hostname);
void carmen_robot_update_skew(int data_type, int *count, double time,
			      char *hostname);

#ifdef __cplusplus
}
#endif

#endif
// @}
